Skip to content

Conversation

@TomtheCoder2
Copy link

@TomtheCoder2 TomtheCoder2 commented Nov 10, 2025

This PR is an attempt to solve the issue described in the issue #107295

@rustbot
Copy link
Collaborator

rustbot commented Nov 10, 2025

This PR modifies tests/ui/issues/. If this PR is adding new tests to tests/ui/issues/,
please refrain from doing so, and instead add it to more descriptive subdirectories.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Nov 10, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 10, 2025

r? @davidtwco

rustbot has assigned @davidtwco.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

)
};

diag.multipart_suggestions(msg, suggestions, Applicability::MaybeIncorrect);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should use a multi-part suggestion for this, these should be multiple distinct suggestions


// search if the parameter is used in the impl body
let mut visitor = ParamUsageVisitor {
tcx, // Pass the TyCtxt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tcx, // Pass the TyCtxt
tcx,

LL - unsafe impl<Q: Trait> Send for Inner {}
LL + unsafe impl Send for Inner {}
|
LL | unsafe impl<Q: Trait> Send for Inner<Q> {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should only suggest this if it could be correct (maybe by checking if the self type has generic parameters), or we should be very clear that it's just illustrative:

help: if `Inner` takes generic parameters, consider instantiating it with `Q` to constrain `Q`
   |
LL - unsafe impl<Q: Trait> Send for Inner {}
LL + unsafe impl<Q: Trait> Send for Inner<Q> {}
   |                                     ^^^ `Q` could be used here

Copy link
Author

@TomtheCoder2 TomtheCoder2 Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well there would another error if the Inner struct took a generic parameter. I made a similar example here:

struct Foo<N> {x: N}

impl<N> Foo {}

which obviously gives the error, that the generic parameter N should be provided for the implementation of Foo:

error[E0107]: missing generics for struct `Foo`
 --> src/lib.rs:3:9
  |
3 | impl<N> Foo {}
  |         ^^^ expected 1 generic argument
  |
note: struct defined here, with 1 generic parameter: `N`
 --> src/lib.rs:1:8
  |
1 | struct Foo<N> {x: N}
  |        ^^^ -
help: add missing generic argument
  |
3 | impl<N> Foo<N> {}
  |            +++

For more information about this error, try `rustc --explain E0107`.

Therefore I would even suggest never suggesting to add the generic argument in general or did I miss some edgecase?
Or we could suggest adding it as a type parameter to the struct and to the impl

|
help: make use of the lifetime parameter `'a` in the `self` type
|
LL | impl<'a> Foo<fn(&()), 'a> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly to above, we should make sure this is correct or clearly indicate that it is purely illustrative.

self.tcx
}

/// We use `ControlFlow` to stop visiting as soon as we find what we're looking for.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the comments in this impl feel redundant

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 11, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 11, 2025

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rustbot
Copy link
Collaborator

rustbot commented Nov 11, 2025

⚠️ Warning ⚠️

  • The following commits have merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged.

    You can start a rebase with the following commands:

    $ # rebase
    $ git pull --rebase https://github.com/rust-lang/rust.git main
    $ git push --force-with-lease
    

@rustbot rustbot added the has-merge-commits PR has merge commits, merge with caution. label Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants