Rollup merge of #91847 - BoxyUwU:generic_arg_infer_fixme, r=lcnr

Fix FIXME for `generic_arg_infer` in `create_substs_for_ast_path`

Fixes a FIXME, does some general refactoring of this fn, and also fixes a bug where we would use a const params defaults instead of an inference var ([playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=19456f65ea5dc3fcaa9b696f842ab380))
(lot of stuff in one PR but it was all so close together...)

r? `@lcnr`

Fixes #91614
This commit is contained in:
Matthias Krüger 2021-12-13 18:15:15 +01:00 committed by GitHub
commit f8de2f56e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 74 additions and 55 deletions

View file

@ -0,0 +1,15 @@
// run-pass
#![feature(generic_arg_infer)]
// test that we dont use defaults to aide in type inference
struct Foo<const N: usize = 2>;
impl<const N: usize> Foo<N> {
fn make_arr() -> [(); N] {
[(); N]
}
}
fn main() {
let [(), (), ()] = Foo::<_>::make_arr();
}

View file

@ -0,0 +1,8 @@
#![feature(portable_simd)]
#![feature(generic_arg_infer)]
use std::simd::Mask;
fn main() {
let y = Mask::<_, _>::splat(false);
//~^ error: type annotations needed for `Mask<_, {_: usize}>`
}

View file

@ -0,0 +1,18 @@
error[E0283]: type annotations needed for `Mask<_, {_: usize}>`
--> $DIR/issue-91614.rs:6:13
|
LL | let y = Mask::<_, _>::splat(false);
| - ^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T`
| |
| consider giving `y` the explicit type `Mask<_, LANES>`, where the type parameter `T` is specified
|
= note: cannot satisfy `_: MaskElement`
note: required by a bound in `Mask::<T, LANES>::splat`
--> $SRC_DIR/core/src/../../portable-simd/crates/core_simd/src/masks.rs:LL:COL
|
LL | T: MaskElement,
| ^^^^^^^^^^^ required by this bound in `Mask::<T, LANES>::splat`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0283`.