fix binding const argument to assoc type suggestion#157908
Conversation
| .filter(|(potential, item)| match potential { | ||
| hir::GenericArg::Const(_) => item.is_type_const(), | ||
| hir::GenericArg::Type(_) => item.is_type(), | ||
| _ => false, | ||
| }) |
There was a problem hiding this comment.
... this check assumes that the type & const arguments magically line up with the associated types & consts, respectively, which doesn't hold up in reality IINM because the unbound_assoc_items (unbound_types) come in definition order.
What I'm saying is that your code probably emits a suggestion here:
trait Trait { type A; type const B: usize; }
fn f<T: Trait<(), 0>>(); // your PR emits a suggestionbut not here:
trait Trait { type const A: usize; type B; }
fn f<T: Trait<(), 0>>(); // your PR does *not* emit a suggestion IINMbecause "[(TyAssocConst, Ty), (AssocTy, Const)]" doesn't contain any matches according to the filter.
|
it seems like i've addressed all reviews, but not sure @rustbot ready |
This comment has been minimized.
This comment has been minimized.
d1c91a7 to
d0c3c77
Compare
|
are you fine if i will stack commits on top of each other while review is going, but i will squash them later before merge, just to make it easier to follow what's changed after every push? |
|
You can already squash / fix up / amend everything as you go, I'm gonna use the View changes since this review link in #157908 (review) which is sufficient for this patch. Anyway, r=me with suggestions applied @bors rollup |
d0c3c77 to
8aa97c0
Compare
| error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied | ||
| --> $DIR/use-type-argument-instead-of-assoc-type.rs:11:17 | ||
| | | ||
| LL | fn take(_: impl Iterator<0>) {} | ||
| | ^^^^^^^^ expected 0 generic arguments | ||
|
|
||
| error: aborting due to 2 previous errors |
There was a problem hiding this comment.
here is new test, i've extended existed test with it
8aa97c0 to
c1f6331
Compare
|
@bors r=fmease rollup |
fix binding const argument to assoc type suggestion r? fmease fixes rust-lang#151602
View all comments
r? fmease
fixes #151602