diff options
| author | bors <bors@rust-lang.org> | 2021-01-01 00:59:12 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-01-01 00:59:12 +0000 |
| commit | 99ad5a1a2824fea1ecf60068fd3636beae7ea2da (patch) | |
| tree | f2c6fa747e14362fef92cbdd624b978fe93d3c5a /src/test/ui/const-generics | |
| parent | 44e3daf5eee8263dfc3a2509e78ddd1f6f783a0e (diff) | |
| parent | 96c11f98d7148f5d49cb1600101c7f9ce057c08b (diff) | |
| download | rust-99ad5a1a2824fea1ecf60068fd3636beae7ea2da.tar.gz rust-99ad5a1a2824fea1ecf60068fd3636beae7ea2da.zip | |
Auto merge of #80566 - Dylan-DPC:rollup-rns6est, r=Dylan-DPC
Rollup of 8 pull requests
Successful merges:
- #80323 (Update and improve `rustc_codegen_{llvm,ssa}` docs)
- #80368 (rustdoc: Render visibilities succinctly)
- #80514 (Fix broken ./x.py install)
- #80519 (Take type defaults into account in suggestions to reorder generic parameters)
- #80526 (Update LLVM)
- #80532 (remove unnecessary trailing semicolon from bootstrap)
- #80548 (FIx ICE on wf check for foreign fns)
- #80551 (support pattern as const parents in type_of)
Failed merges:
- #80547 (In which we start to parse const generics defaults)
r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src/test/ui/const-generics')
9 files changed, 86 insertions, 10 deletions
diff --git a/src/test/ui/const-generics/arg-in-pat-1.rs b/src/test/ui/const-generics/arg-in-pat-1.rs new file mode 100644 index 00000000000..82555084e41 --- /dev/null +++ b/src/test/ui/const-generics/arg-in-pat-1.rs @@ -0,0 +1,23 @@ +// check-pass +enum ConstGenericEnum<const N: usize> { + Foo([i32; N]), + Bar, +} + +fn foo<const N: usize>(val: &ConstGenericEnum<N>) { + if let ConstGenericEnum::<N>::Foo(field, ..) = val {} +} + +fn bar<const N: usize>(val: &ConstGenericEnum<N>) { + match val { + ConstGenericEnum::<N>::Foo(field, ..) => (), + ConstGenericEnum::<N>::Bar => (), + } +} + +fn main() { + match ConstGenericEnum::Bar { + ConstGenericEnum::<3>::Foo(field, ..) => (), + ConstGenericEnum::<3>::Bar => (), + } +} diff --git a/src/test/ui/const-generics/arg-in-pat-2.rs b/src/test/ui/const-generics/arg-in-pat-2.rs new file mode 100644 index 00000000000..dc9e722eda8 --- /dev/null +++ b/src/test/ui/const-generics/arg-in-pat-2.rs @@ -0,0 +1,10 @@ +// check-pass +enum Generic<const N: usize> { + Variant, +} + +fn main() { + match todo!() { + Generic::<0usize>::Variant => todo!() + } +} diff --git a/src/test/ui/const-generics/arg-in-pat-3.rs b/src/test/ui/const-generics/arg-in-pat-3.rs new file mode 100644 index 00000000000..24626a3b68a --- /dev/null +++ b/src/test/ui/const-generics/arg-in-pat-3.rs @@ -0,0 +1,43 @@ +// check-pass +struct Foo<const N: usize>; + +fn bindingp() { + match Foo { + mut x @ Foo::<3> => { + let ref mut _x @ Foo::<3> = x; + } + } +} + +struct Bar<const N: usize> { + field: Foo<N>, +} + +fn structp() { + match todo!() { + Bar::<3> { + field: Foo::<3>, + } => (), + } +} + +struct Baz<const N: usize>(Foo<N>); + +fn tuplestructp() { + match Baz(Foo) { + Baz::<3>(Foo::<3>) => (), + } +} + +impl<const N: usize> Baz<N> { + const ASSOC: usize = 3; +} + +fn pathp() { + match 3 { + Baz::<3>::ASSOC => (), + _ => (), + } +} + +fn main() {} diff --git a/src/test/ui/const-generics/defaults/complex-unord-param.min.stderr b/src/test/ui/const-generics/defaults/complex-unord-param.min.stderr index cec56d7038a..8e8d26a0004 100644 --- a/src/test/ui/const-generics/defaults/complex-unord-param.min.stderr +++ b/src/test/ui/const-generics/defaults/complex-unord-param.min.stderr @@ -2,7 +2,7 @@ error: type parameters must be declared prior to const parameters --> $DIR/complex-unord-param.rs:8:41 | LL | struct NestedArrays<'a, const N: usize, A: 'a, const M: usize, T:'a =u32> { - | ---------------------^----------------------^--------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, A: 'a, T: 'a, const N: usize, const M: usize>` + | ---------------------^----------------------^--------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, A: 'a, T: 'a = u32, const N: usize, const M: usize>` error: aborting due to previous error diff --git a/src/test/ui/const-generics/defaults/intermixed-lifetime.full.stderr b/src/test/ui/const-generics/defaults/intermixed-lifetime.full.stderr index 98352addaef..c4a666a829d 100644 --- a/src/test/ui/const-generics/defaults/intermixed-lifetime.full.stderr +++ b/src/test/ui/const-generics/defaults/intermixed-lifetime.full.stderr @@ -2,13 +2,13 @@ error: lifetime parameters must be declared prior to const parameters --> $DIR/intermixed-lifetime.rs:6:28 | LL | struct Foo<const N: usize, 'a, T = u32>(&'a (), T); - | -----------------^^---------- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T>` + | -----------------^^---------- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T = u32>` error: lifetime parameters must be declared prior to type parameters --> $DIR/intermixed-lifetime.rs:10:37 | LL | struct Bar<const N: usize, T = u32, 'a>(&'a (), T); - | --------------------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T>` + | --------------------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T = u32>` error: aborting due to 2 previous errors diff --git a/src/test/ui/const-generics/defaults/intermixed-lifetime.min.stderr b/src/test/ui/const-generics/defaults/intermixed-lifetime.min.stderr index 532f6d700b2..69a490978d1 100644 --- a/src/test/ui/const-generics/defaults/intermixed-lifetime.min.stderr +++ b/src/test/ui/const-generics/defaults/intermixed-lifetime.min.stderr @@ -2,25 +2,25 @@ error: lifetime parameters must be declared prior to const parameters --> $DIR/intermixed-lifetime.rs:6:28 | LL | struct Foo<const N: usize, 'a, T = u32>(&'a (), T); - | -----------------^^---------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, const N: usize>` + | -----------------^^---------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T = u32, const N: usize>` error: type parameters must be declared prior to const parameters --> $DIR/intermixed-lifetime.rs:6:32 | LL | struct Foo<const N: usize, 'a, T = u32>(&'a (), T); - | ---------------------^------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, const N: usize>` + | ---------------------^------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T = u32, const N: usize>` error: lifetime parameters must be declared prior to const parameters --> $DIR/intermixed-lifetime.rs:10:37 | LL | struct Bar<const N: usize, T = u32, 'a>(&'a (), T); - | --------------------------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, const N: usize>` + | --------------------------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T = u32, const N: usize>` error: type parameters must be declared prior to const parameters --> $DIR/intermixed-lifetime.rs:10:28 | LL | struct Bar<const N: usize, T = u32, 'a>(&'a (), T); - | -----------------^----------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, const N: usize>` + | -----------------^----------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T = u32, const N: usize>` error: aborting due to 4 previous errors diff --git a/src/test/ui/const-generics/defaults/needs-feature.min.stderr b/src/test/ui/const-generics/defaults/needs-feature.min.stderr index 86d6173fa02..a4006203e4a 100644 --- a/src/test/ui/const-generics/defaults/needs-feature.min.stderr +++ b/src/test/ui/const-generics/defaults/needs-feature.min.stderr @@ -2,7 +2,7 @@ error: type parameters must be declared prior to const parameters --> $DIR/needs-feature.rs:9:26 | LL | struct A<const N: usize, T=u32>(T); - | -----------------^----- help: reorder the parameters: lifetimes, then types, then consts: `<T, const N: usize>` + | -----------------^----- help: reorder the parameters: lifetimes, then types, then consts: `<T = u32, const N: usize>` error: aborting due to previous error diff --git a/src/test/ui/const-generics/defaults/needs-feature.none.stderr b/src/test/ui/const-generics/defaults/needs-feature.none.stderr index 86d6173fa02..a4006203e4a 100644 --- a/src/test/ui/const-generics/defaults/needs-feature.none.stderr +++ b/src/test/ui/const-generics/defaults/needs-feature.none.stderr @@ -2,7 +2,7 @@ error: type parameters must be declared prior to const parameters --> $DIR/needs-feature.rs:9:26 | LL | struct A<const N: usize, T=u32>(T); - | -----------------^----- help: reorder the parameters: lifetimes, then types, then consts: `<T, const N: usize>` + | -----------------^----- help: reorder the parameters: lifetimes, then types, then consts: `<T = u32, const N: usize>` error: aborting due to previous error diff --git a/src/test/ui/const-generics/defaults/simple-defaults.min.stderr b/src/test/ui/const-generics/defaults/simple-defaults.min.stderr index 01fb4210dd6..0746c64ac8c 100644 --- a/src/test/ui/const-generics/defaults/simple-defaults.min.stderr +++ b/src/test/ui/const-generics/defaults/simple-defaults.min.stderr @@ -2,7 +2,7 @@ error: type parameters must be declared prior to const parameters --> $DIR/simple-defaults.rs:8:40 | LL | struct FixedOutput<'a, const N: usize, T=u32> { - | ---------------------^----- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, const N: usize>` + | ---------------------^----- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T = u32, const N: usize>` error: aborting due to previous error |
