Uh oh!
There was an error while loading. Please reload this page.
fix type of const params in assoc fns. - #70276
Conversation
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
<S as T<123>>::f::<456>() should also work, if you added a const param to f as well.
There was a problem hiding this comment.
I mean you'll need to implement it, it won't work with the current approach.
There was a problem hiding this comment.
for whatever reason adding a const param to f actually prevents the ice. not quite sure why, but this is new behavior so lets add a test for it
The following works on the current nightly.
#![feature(const_generics)]//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crashtraitT<constA:usize>{fnl<constN:usize>() -> usize;fnr<constN:usize>() -> usize;}structS;impl<constN:usize>T<N>forS{fnl<constM:usize>() -> usize{N}fnr<constM:usize>() -> usize{M}}fnmain(){assert_eq!(<SasT<123>>::l::<456>(),123);assert_eq!(<SasT<123>>::r::<456>(),456);}There was a problem hiding this comment.
Oh, oops, it's because both the trait and the method have the exact same number of parameters and the same types. Make one of them a bool instead of usize, then you should see how it thinks the method segment has the trait's parameter (which is wrong).
There was a problem hiding this comment.
jup. Quite surprisingly, using usize and u16 works 🤔
but using bool and usize does not work on nightly rn
There was a problem hiding this comment.
Yes, because the integer literals will work with any integer type.
lcnr
commented
Mar 22, 2020
I am going to experiment with using the res of the segment instead of the path. Closing this for now as I don't know how long this will take. |
…r=eddyb correctly handle const params in type_of extends rust-lang#70223, retry of rust-lang#70276fixesrust-lang#70273 r? @eddyb cc @varkor
…r=eddyb correctly handle const params in type_of extends rust-lang#70223, retry of rust-lang#70276fixesrust-lang#70273 r? @eddyb cc @varkor
…r=eddyb correctly handle const params in type_of extends rust-lang#70223, retry of rust-lang#70276fixesrust-lang#70273 r? @eddyb cc @varkor
extends and blocked on #70223
fixes#70273
r? @eddyb cc @varkor