Skip to content

Conversation

@rperier
Copy link
Contributor

@rperier rperier commented Nov 16, 2025

cc #148892

…raph

Currently, If `expected_def_id` and `another_trait_def_id` have their
crate imported as ExternCrateSource::Path the method
get_extern_crate_renamed_symbol() will return None for both, resulting
in a false positive. This fixes the issue by using a slitly different
approach, we use a predicate instead and do the comparison of the item
names only when both crates are imported as ExternCrateSource::Extern,
otherwise false is returned.
@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. labels Nov 16, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 16, 2025

r? @jackh726

rustbot has assigned @jackh726.
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

@rperier
Copy link
Contributor Author

rperier commented Nov 16, 2025

r? @lcnr

@rustbot rustbot assigned lcnr and unassigned jackh726 Nov 16, 2025
Some(ExternCrate { src: ExternCrateSource::Extern(trait_def_id), .. }),
) => {
let expected_sym = self.tcx.item_name(expected_def_id);
expected_sym == self.tcx.item_name(trait_def_id) && expected_sym != sym::std
Copy link
Contributor

Choose a reason for hiding this comment

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

why the check for != std?

Copy link
Contributor Author

@rperier rperier Nov 17, 2025

Choose a reason for hiding this comment

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

That's weird, it seems that, in some cases, there are tests in ui suite that report two crates being imported as std. In such a case, the predicate returns true. It's the test tests/ui/typeck/issue-50687-ice-on-borrow.rs, if I remember correctly. Note: I had the same kind of reports with the old version.

Copy link
Contributor

Choose a reason for hiding this comment

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

that seems worth debugging because right now it feels arbitrary.

In such cases we should figure out why things work the way they do as

  • it prevents confusing future readers by adding a comment#
  • the "arbitrary" check may actually hide a more general underlying issue and without properly fixing it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, no my bad, it's the tests tests/ui/suggestions/issue-105645.rs and tests/ui/suggestions/mut-borrow-needed-by-trait.rs both report : "there are multiple different versions of crate std in the dependency graph" :=D .

Yeah, I agree, I am going to investigate.

Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

can you add a test to our ui suite?

View changes since this review

@rperier
Copy link
Contributor Author

rperier commented Nov 17, 2025

can you add a test to our ui suite?

View changes since this review

Sure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants