diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2021-12-13 18:15:15 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-13 18:15:15 +0100 |
| commit | f8de2f56e8628ec830d2bfd77a30f681f27bb46a (patch) | |
| tree | 590a05b8c7734423a48c6a33fdbd84696ca422e3 /src | |
| parent | dca8ddeade657e00236b2d0de2561f2fc175d6ae (diff) | |
| parent | 6c795951346b846964fb031df07fba2d2cd8c7d0 (diff) | |
| download | rust-f8de2f56e8628ec830d2bfd77a30f681f27bb46a.tar.gz rust-f8de2f56e8628ec830d2bfd77a30f681f27bb46a.zip | |
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
Diffstat (limited to 'src')
3 files changed, 41 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/generic_arg_infer/dont-use-defaults.rs b/src/test/ui/const-generics/generic_arg_infer/dont-use-defaults.rs new file mode 100644 index 00000000000..251160a0f5f --- /dev/null +++ b/src/test/ui/const-generics/generic_arg_infer/dont-use-defaults.rs @@ -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(); +} diff --git a/src/test/ui/const-generics/generic_arg_infer/issue-91614.rs b/src/test/ui/const-generics/generic_arg_infer/issue-91614.rs new file mode 100644 index 00000000000..413cc153924 --- /dev/null +++ b/src/test/ui/const-generics/generic_arg_infer/issue-91614.rs @@ -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}>` +} diff --git a/src/test/ui/const-generics/generic_arg_infer/issue-91614.stderr b/src/test/ui/const-generics/generic_arg_infer/issue-91614.stderr new file mode 100644 index 00000000000..71a5ff79280 --- /dev/null +++ b/src/test/ui/const-generics/generic_arg_infer/issue-91614.stderr @@ -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`. |
