Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filter with following segment while lookup typo for path #113331

Merged
merged 3 commits into from
Jul 10, 2023

Conversation

chenyukang
Copy link
Member

From the discussion: #112917 (comment)

Seems we can not get the assoc items for Struct, Enum in the resolving phase.
A obvious filter is avoid suggesting the same name with the following segment path.

Use following_seg can extend the function smart_resolve_partial_mod_path_errors for more scenarios, such as std::sync_error::atomic::AtomicBool in test case.

r? @estebank

@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 Jul 4, 2023
@chenyukang chenyukang force-pushed the yukang-fix-112590-false-positive branch from 9c2118d to 6a373c1 Compare July 4, 2023 16:59
tests/ui/resolve/112590-2.rs Outdated Show resolved Hide resolved
compiler/rustc_resolve/src/late/diagnostics.rs Outdated Show resolved Hide resolved
compiler/rustc_resolve/src/late/diagnostics.rs Outdated Show resolved Hide resolved
@chenyukang chenyukang force-pushed the yukang-fix-112590-false-positive branch from 6a373c1 to 45c1218 Compare July 6, 2023 15:24
@chenyukang chenyukang force-pushed the yukang-fix-112590-false-positive branch from 45c1218 to 2099022 Compare July 7, 2023 00:56
@chenyukang chenyukang force-pushed the yukang-fix-112590-false-positive branch from 2099022 to 6f53e61 Compare July 7, 2023 01:01
@rust-log-analyzer

This comment has been minimized.

@chenyukang chenyukang force-pushed the yukang-fix-112590-false-positive branch 2 times, most recently from d922b82 to 0aa79d3 Compare July 7, 2023 02:12
@chenyukang chenyukang force-pushed the yukang-fix-112590-false-positive branch from 0aa79d3 to 9763472 Compare July 7, 2023 02:18
Comment on lines 30 to +43
|
LL | bar: std::cell::Cell<bool>
| ~~~
help: consider importing one of these items
|
LL + use core::cell;
|
LL + use std::cell;
|
help: if you import `cell`, refer to it directly
|
LL - bar: st::cell::Cell<bool>
LL + bar: cell::Cell<bool>
|
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm noticing that these suggestions are now redundant. Could we check if the first suggestion has been emitted, and if so not try the import one?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a little bit redundant, but sometimes the import one is the right advice to fix an error, I changed the code to skip the import suggestions if typo is found, and found this case changed:

error[E0433]: failed to resolve: use of undeclared type `FromIterator`
  --> $DIR/suggest-tryinto-edition-change.rs:23:22
   |
LL |     let _v: Vec<_> = FromIterator::from_iter(&[1]);
   |                      ^^^^^^^^^^^^ use of undeclared type `FromIterator`
   |
   = note: 'std::iter::FromIterator' is included in the prelude starting in Edition 2021
   = note: 'core::iter::FromIterator' is included in the prelude starting in Edition 2021
help: a trait with a similar name exists
   |
LL |     let _v: Vec<_> = IntoIterator::from_iter(&[1]);
   |                      ~~~~~~~~~~~~
help: consider importing one of these items
   |
LL + use core::iter::FromIterator;
   |
LL + use std::iter::FromIterator;
   |

it's better than the new result after code changed:

error[E0433]: failed to resolve: use of undeclared type `FromIterator`
  --> $DIR/suggest-tryinto-edition-change.rs:23:22
   |
LL |     let _v: Vec<_> = FromIterator::from_iter(&[1]);
   |                      ^^^^^^^^^^^^
   |                      |
   |                      use of undeclared type `FromIterator`
   |                      help: a trait with a similar name exists: `IntoIterator`

we are unsure which is better in all scenarios, so let's keep it right now.

@estebank
Copy link
Contributor

estebank commented Jul 7, 2023

r=me, with #113331 (comment) addressed or not

@chenyukang
Copy link
Member Author

@bors r=estebank

@bors
Copy link
Contributor

bors commented Jul 10, 2023

📌 Commit 37b40e5 has been approved by estebank

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 10, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 10, 2023
…iaskrgr

Rollup of 2 pull requests

Successful merges:

 - rust-lang#113331 (Add filter with following segment while lookup typo for path)
 - rust-lang#113524 (Remove the library/term exception in tidy's pal checker code)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 70c6378 into rust-lang:master Jul 10, 2023
11 checks passed
@rustbot rustbot added this to the 1.73.0 milestone Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

None yet

5 participants