diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2018-03-23 09:27:16 -0500 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2018-03-23 10:16:08 -0700 |
| commit | 7c0c7ef330fd87e8b169f0afc832d15bf098d0f0 (patch) | |
| tree | ddd4d8c545630c041e2f91ef72bdc4913ccdcd58 /src/rustllvm/RustWrapper.cpp | |
| parent | f836ae48e6e0b55af1d0d6cd579424f26314d530 (diff) | |
| parent | c05d23406ead7b5747256c02127097807db45b83 (diff) | |
| download | rust-7c0c7ef330fd87e8b169f0afc832d15bf098d0f0.tar.gz rust-7c0c7ef330fd87e8b169f0afc832d15bf098d0f0.zip | |
Rollup merge of #48909 - RalfJung:type_alias_bounds, r=petrochenkov
Improve lint for type alias bounds First of all, I learned just today that I was wrong assuming that the bounds in type aliases are entirely ignored: It turns out they are used to resolve associated types in type aliases. So: ```rust type T1<U: Bound> = U::Assoc; // compiles type T2<U> = U::Assoc; // fails type T3<U> = <U as Bound>::Assoc; // "correct" way to write this, maybe? ``` I am sorry for creating this mess. This PR changes the wording of the lint accordingly. Moreover, since just removing the bound is no longer always a possible fix, I tried to detect cases like `T1` above and show a helpful message to the user: ``` warning: bounds on generic parameters are not enforced in type aliases --> $DIR/type-alias-bounds.rs:57:12 | LL | type T1<U: Bound> = U::Assoc; //~ WARN not enforced in type aliases | ^^^^^ | = help: the bound will not be checked when the type alias is used, and should be removed help: use absolute paths (i.e., <T as Trait>::Assoc) to refer to associated types in type aliases --> $DIR/type-alias-bounds.rs:57:21 | LL | type T1<U: Bound> = U::Assoc; //~ WARN not enforced in type aliases | ^^^^^^^^ ``` I am not sure if I got this entirely right. Ideally, we could provide a suggestion involving the correct trait and type name -- however, while I have access to the HIR in the lint, I do not know how to get access to the resolved name information, like which trait `Assoc` belongs to above. The lint does not even run if that resolution fails, so I assume that information is available *somewhere*... This is a follow-up for (parts of) https://github.com/rust-lang/rust/pull/48326. Also see https://github.com/rust-lang/rust/issues/21903. This changes the name of a lint, but that lint was just merged to master yesterday and has never even been on beta.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
