-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Confusing error if accidentially defining a type paramter with the same name as an existing type #52082
Comments
Clippy has such a lint, but it would trigger after the errors I think. We could mention that something is a type parameter whenever errors related to it occur. Or have a lint at resolve time |
E0609 should point at the type that doesn't have the field, in this case it would point at the type argument and not the struct, making it easier to figure out what's happening. |
The cases rust/src/librustc_typeck/check/expr.rs Line 1437 in f7af19c
for the former by doing something like
and finding the appropriate param name and use its span to point to. For the |
I would like to work on this as I'm currently learning Rust, if you don't mind. |
Great! you can reserve this issue via |
@rustbot claim |
I would appreciate some hand-holding here. From |
The |
…bank Print ParamTy span when accessing a field (rust-lang#52082)
Rollup of 10 pull requests Successful merges: - #64131 (data_structures: Add deterministic FxHashMap and FxHashSet wrappers) - #64387 (Fix redundant semicolon lint interaction with proc macro attributes) - #64678 (added more context for duplicate lang item errors (fixes #60561)) - #64763 (Add E0734 and its long explanation) - #64793 (Fix format macro expansions spans to be macro-generated) - #64837 (Improve wording in documentation of MaybeUninit) - #64852 (Print ParamTy span when accessing a field (#52082)) - #64875 (Upgrade async/await to "used" keywords.) - #64876 (Fix typo in intrinsics op safety) - #64880 (Slice docs: fix typo) Failed merges: r? @ghost
I believe this issue can now be closed. |
An example from IRC just now:
https://play.rust-lang.org/?gist=ad253f7f1b851935890346136fe47912&version=stable&mode=debug&edition=2015
The mistake here is that
Point
is also used as a shadowing type parameter inside the Function.Maybe have a warn lint that tries to detect cases like this? (With a type parameter that also exist as a concrete type in the surrounding scope)
This issue has been assigned to @Baranowski via this comment.
The text was updated successfully, but these errors were encountered: