Account for associated type, const and static when using type argument#62004
Account for associated type, const and static when using type argument#62004estebank wants to merge 2 commits intorust-lang:masterfrom
Conversation
|
r? @cramertj (rust_highfive has picked a reviewer for you, use r? to override) |
495a620 to
7932b04
Compare
src/librustc_resolve/lib.rs
Outdated
There was a problem hiding this comment.
Please use some other terminology than "scope", it's incredibly overloaded in resolve.
Also, could you move enum CurrentScope and its impls into diagnostics.rs?
There was a problem hiding this comment.
What would be a better name?
There was a problem hiding this comment.
BodyOwner / DefOwner maybe? (though Def is similarly unfortunately overloaded)
When using a type argument from the enclosing scope in an associated type, const or static item provide a more targetted E0401 error, instead of blaming the "outer function" blindly.
7932b04 to
7515e71
Compare
|
☔ The latest upstream changes (presumably #62467) made this pull request unmergeable. Please resolve the merge conflicts. |
| //~^ ERROR can't use generic parameters in a `const` | ||
| //~| ERROR can't use generic parameters in a `const` | ||
| type Type = T; | ||
| //~^ ERROR can't use generic parameters in associated type |
There was a problem hiding this comment.
Here Type is not an associated type alias but rather a free type alias.
| if let Some((sugg_span, new_snippet)) = cm.generate_local_type_param_snippet(span) { | ||
| if !resolver.scope.is_other() { | ||
| err.help(&format!( | ||
| "{} need a type instead of a generic parameter", |
There was a problem hiding this comment.
| "{} need a type instead of a generic parameter", | |
| "{} needs a type instead of a generic parameter", |
|
ping from triage @estebank any updates on this? |
|
ping from triage @cramertj this PR is waiting for your review? |
|
I have some WIP code in my local branch to address some of the comments and will need a rebase. I won't be getting to it until at least the weekend. |
|
Closing, I'll reopen when I get back to this. |
When using a type argument from the enclosing scope in an associated type,
const or static item provide a more targetted E0401 error, instead of
blaming the "outer function" blindly.
Fix #45447.