Suggest typo fix when trait path expression is typo'ed#135374
Merged
bors merged 1 commit intorust-lang:masterfrom Jan 12, 2025
Merged
Suggest typo fix when trait path expression is typo'ed#135374bors merged 1 commit intorust-lang:masterfrom
bors merged 1 commit intorust-lang:masterfrom
Conversation
Collaborator
|
r? @fee1-dead rustbot has assigned @fee1-dead. Use |
Collaborator
|
HIR ty lowering was modified cc @fmease |
fee1-dead
approved these changes
Jan 12, 2025
Member
fee1-dead
left a comment
There was a problem hiding this comment.
A little sad that this suggestion is only for edition >= 2021, but I imagine that supporting all editions will be more complicated than this simple diff, so LGTM!
Member
|
@bors r+ rollup |
Collaborator
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jan 12, 2025
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#129259 (Add inherent versions of MaybeUninit methods for slices) - rust-lang#135374 (Suggest typo fix when trait path expression is typo'ed) - rust-lang#135377 (Make MIR cleanup for functions with impossible predicates into a real MIR pass) - rust-lang#135378 (Remove a bunch of diagnostic stashing that doesn't do anything) - rust-lang#135397 (compiletest: add erroneous variant to `string_enum`s conversions error) - rust-lang#135398 (add more crash tests) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jan 12, 2025
Rollup merge of rust-lang#135374 - compiler-errors:typo-trait-method, r=fee1-dead Suggest typo fix when trait path expression is typo'ed When users write something like `Default::defualt()` (notice the typo), failure to resolve the erroneous `defualt` item will cause resolution + lowering to interpret this as a type-dependent path whose self type is `Default` which is a trait object without `dyn`, rather than a trait function like `<_ as Default>::default()`. Try to provide a bit of guidance in this situation when we can detect the typo. Fixes rust-lang#135349
github-actions bot
pushed a commit
to tautschnig/verify-rust-std
that referenced
this pull request
Mar 11, 2025
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#129259 (Add inherent versions of MaybeUninit methods for slices) - rust-lang#135374 (Suggest typo fix when trait path expression is typo'ed) - rust-lang#135377 (Make MIR cleanup for functions with impossible predicates into a real MIR pass) - rust-lang#135378 (Remove a bunch of diagnostic stashing that doesn't do anything) - rust-lang#135397 (compiletest: add erroneous variant to `string_enum`s conversions error) - rust-lang#135398 (add more crash tests) r? `@ghost` `@rustbot` modify labels: rollup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When users write something like
Default::defualt()(notice the typo), failure to resolve the erroneousdefualtitem will cause resolution + lowering to interpret this as a type-dependent path whose self type isDefaultwhich is a trait object withoutdyn, rather than a trait function like<_ as Default>::default().Try to provide a bit of guidance in this situation when we can detect the typo.
Fixes #135349