diff options
| author | Bastian Kauschke <bastian_kauschke@hotmail.de> | 2020-11-10 10:21:11 +0100 |
|---|---|---|
| committer | Bastian Kauschke <bastian_kauschke@hotmail.de> | 2020-11-10 12:31:57 +0100 |
| commit | a30b28e8932f8eb2931d1a41bc9271961e90f1cb (patch) | |
| tree | dd65e02cc400141707ca6eb96c9b8be775570331 | |
| parent | 19a3fe632432b74af8ef04b72eada3b7a6577d4d (diff) | |
| download | rust-a30b28e8932f8eb2931d1a41bc9271961e90f1cb.tar.gz rust-a30b28e8932f8eb2931d1a41bc9271961e90f1cb.zip | |
try referencing outer params
| -rw-r--r-- | src/test/ui/const-generics/const-arg-in-const-arg.min.stderr | 203 | ||||
| -rw-r--r-- | src/test/ui/const-generics/const-arg-in-const-arg.rs | 44 |
2 files changed, 247 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/const-arg-in-const-arg.min.stderr b/src/test/ui/const-generics/const-arg-in-const-arg.min.stderr new file mode 100644 index 00000000000..7dfe250b78e --- /dev/null +++ b/src/test/ui/const-generics/const-arg-in-const-arg.min.stderr @@ -0,0 +1,203 @@ +error: generic parameters may not be used in const operations + --> $DIR/const-arg-in-const-arg.rs:14:23 + | +LL | let _: [u8; foo::<T>()]; + | ^ cannot perform const operation using `T` + | + = note: type parameters may not be used in const expressions + +error: generic parameters may not be used in const operations + --> $DIR/const-arg-in-const-arg.rs:15:23 + | +LL | let _: [u8; bar::<N>()]; + | ^ cannot perform const operation using `N` + | + = help: const parameters may only be used as standalone arguments, i.e. `N` + +error: generic parameters may not be used in const operations + --> $DIR/const-arg-in-const-arg.rs:25:23 + | +LL | let _ = [0; bar::<N>()]; + | ^ cannot perform const operation using `N` + | + = help: const parameters may only be used as standalone arguments, i.e. `N` + +error: generic parameters may not be used in const operations + --> $DIR/const-arg-in-const-arg.rs:30:24 + | +LL | let _: Foo<{ foo::<T>() }>; + | ^ cannot perform const operation using `T` + | + = note: type parameters may not be used in const expressions + +error: generic parameters may not be used in const operations + --> $DIR/const-arg-in-const-arg.rs:31:24 + | +LL | let _: Foo<{ bar::<N>() }>; + | ^ cannot perform const operation using `N` + | + = help: const parameters may only be used as standalone arguments, i.e. `N` + +error: generic parameters may not be used in const operations + --> $DIR/const-arg-in-const-arg.rs:36:27 + | +LL | let _ = Foo::<{ foo::<T>() }>; + | ^ cannot perform const operation using `T` + | + = note: type parameters may not be used in const expressions + +error: generic parameters may not be used in const operations + --> $DIR/const-arg-in-const-arg.rs:37:27 + | +LL | let _ = Foo::<{ bar::<N>() }>; + | ^ cannot perform const operation using `N` + | + = help: const parameters may only be used as standalone arguments, i.e. `N` + +error[E0658]: a non-static lifetime is not allowed in a `const` + --> $DIR/const-arg-in-const-arg.rs:16:23 + | +LL | let _: [u8; faz::<'a>(&())]; + | ^^ + | + = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information + = help: add `#![feature(const_generics)]` to the crate attributes to enable + +error[E0658]: a non-static lifetime is not allowed in a `const` + --> $DIR/const-arg-in-const-arg.rs:17:23 + | +LL | let _: [u8; baz::<'a>(&())]; + | ^^ + | + = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information + = help: add `#![feature(const_generics)]` to the crate attributes to enable + +error[E0658]: a non-static lifetime is not allowed in a `const` + --> $DIR/const-arg-in-const-arg.rs:18:23 + | +LL | let _: [u8; faz::<'b>(&())]; + | ^^ + | + = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information + = help: add `#![feature(const_generics)]` to the crate attributes to enable + +error[E0658]: a non-static lifetime is not allowed in a `const` + --> $DIR/const-arg-in-const-arg.rs:19:23 + | +LL | let _: [u8; baz::<'b>(&())]; + | ^^ + | + = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information + = help: add `#![feature(const_generics)]` to the crate attributes to enable + +error[E0658]: a non-static lifetime is not allowed in a `const` + --> $DIR/const-arg-in-const-arg.rs:26:23 + | +LL | let _ = [0; faz::<'a>(&())]; + | ^^ + | + = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information + = help: add `#![feature(const_generics)]` to the crate attributes to enable + +error[E0658]: a non-static lifetime is not allowed in a `const` + --> $DIR/const-arg-in-const-arg.rs:27:23 + | +LL | let _ = [0; baz::<'a>(&())]; + | ^^ + | + = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information + = help: add `#![feature(const_generics)]` to the crate attributes to enable + +error[E0658]: a non-static lifetime is not allowed in a `const` + --> $DIR/const-arg-in-const-arg.rs:28:23 + | +LL | let _ = [0; faz::<'b>(&())]; + | ^^ + | + = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information + = help: add `#![feature(const_generics)]` to the crate attributes to enable + +error[E0658]: a non-static lifetime is not allowed in a `const` + --> $DIR/const-arg-in-const-arg.rs:29:23 + | +LL | let _ = [0; baz::<'b>(&())]; + | ^^ + | + = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information + = help: add `#![feature(const_generics)]` to the crate attributes to enable + +error[E0658]: a non-static lifetime is not allowed in a `const` + --> $DIR/const-arg-in-const-arg.rs:32:24 + | +LL | let _: Foo<{ faz::<'a>(&()) }>; + | ^^ + | + = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information + = help: add `#![feature(const_generics)]` to the crate attributes to enable + +error[E0658]: a non-static lifetime is not allowed in a `const` + --> $DIR/const-arg-in-const-arg.rs:33:24 + | +LL | let _: Foo<{ baz::<'a>(&()) }>; + | ^^ + | + = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information + = help: add `#![feature(const_generics)]` to the crate attributes to enable + +error[E0658]: a non-static lifetime is not allowed in a `const` + --> $DIR/const-arg-in-const-arg.rs:34:24 + | +LL | let _: Foo<{ faz::<'b>(&()) }>; + | ^^ + | + = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information + = help: add `#![feature(const_generics)]` to the crate attributes to enable + +error[E0658]: a non-static lifetime is not allowed in a `const` + --> $DIR/const-arg-in-const-arg.rs:35:24 + | +LL | let _: Foo<{ baz::<'b>(&()) }>; + | ^^ + | + = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information + = help: add `#![feature(const_generics)]` to the crate attributes to enable + +error[E0658]: a non-static lifetime is not allowed in a `const` + --> $DIR/const-arg-in-const-arg.rs:38:27 + | +LL | let _ = Foo::<{ faz::<'a>(&()) }>; + | ^^ + | + = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information + = help: add `#![feature(const_generics)]` to the crate attributes to enable + +error[E0658]: a non-static lifetime is not allowed in a `const` + --> $DIR/const-arg-in-const-arg.rs:39:27 + | +LL | let _ = Foo::<{ baz::<'a>(&()) }>; + | ^^ + | + = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information + = help: add `#![feature(const_generics)]` to the crate attributes to enable + +error[E0658]: a non-static lifetime is not allowed in a `const` + --> $DIR/const-arg-in-const-arg.rs:40:27 + | +LL | let _ = Foo::<{ faz::<'b>(&()) }>; + | ^^ + | + = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information + = help: add `#![feature(const_generics)]` to the crate attributes to enable + +error[E0658]: a non-static lifetime is not allowed in a `const` + --> $DIR/const-arg-in-const-arg.rs:41:27 + | +LL | let _ = Foo::<{ baz::<'b>(&()) }>; + | ^^ + | + = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information + = help: add `#![feature(const_generics)]` to the crate attributes to enable + +error: aborting due to 23 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/const-generics/const-arg-in-const-arg.rs b/src/test/ui/const-generics/const-arg-in-const-arg.rs new file mode 100644 index 00000000000..9927538ef50 --- /dev/null +++ b/src/test/ui/const-generics/const-arg-in-const-arg.rs @@ -0,0 +1,44 @@ +// revisions: min +// FIXME(const_generics): This test currently causes an ICE because +// we don't yet correctly deal with lifetimes, reenable this test once +// this is fixed. +#![cfg_attr(min, feature(min_const_generics))] + +const fn foo<T>() -> usize { std::mem::size_of::<T>() } +const fn bar<const N: usize>() -> usize { N } +const fn faz<'a>(_: &'a ()) -> usize { 13 } +const fn baz<'a>(_: &'a ()) -> usize where &'a (): Sized { 13 } + +struct Foo<const N: usize>; +fn test<'a, 'b, T, const N: usize>() where &'b (): Sized { + let _: [u8; foo::<T>()]; //~ ERROR generic parameters may not + let _: [u8; bar::<N>()]; //~ ERROR generic parameters may not + let _: [u8; faz::<'a>(&())]; //~ ERROR a non-static lifetime + let _: [u8; baz::<'a>(&())]; //~ ERROR a non-static lifetime + let _: [u8; faz::<'b>(&())]; //~ ERROR a non-static lifetime + let _: [u8; baz::<'b>(&())]; //~ ERROR a non-static lifetime + + // NOTE: This can be a future compat warning instead of an error, + // so we stop compilation before emitting this error in this test. + let _ = [0; foo::<T>()]; + + let _ = [0; bar::<N>()]; //~ ERROR generic parameters may not + let _ = [0; faz::<'a>(&())]; //~ ERROR a non-static lifetime + let _ = [0; baz::<'a>(&())]; //~ ERROR a non-static lifetime + let _ = [0; faz::<'b>(&())]; //~ ERROR a non-static lifetime + let _ = [0; baz::<'b>(&())]; //~ ERROR a non-static lifetime + let _: Foo<{ foo::<T>() }>; //~ ERROR generic parameters may not + let _: Foo<{ bar::<N>() }>; //~ ERROR generic parameters may not + let _: Foo<{ faz::<'a>(&()) }>; //~ ERROR a non-static lifetime + let _: Foo<{ baz::<'a>(&()) }>; //~ ERROR a non-static lifetime + let _: Foo<{ faz::<'b>(&()) }>; //~ ERROR a non-static lifetime + let _: Foo<{ baz::<'b>(&()) }>; //~ ERROR a non-static lifetime + let _ = Foo::<{ foo::<T>() }>; //~ ERROR generic parameters may not + let _ = Foo::<{ bar::<N>() }>; //~ ERROR generic parameters may not + let _ = Foo::<{ faz::<'a>(&()) }>; //~ ERROR a non-static lifetime + let _ = Foo::<{ baz::<'a>(&()) }>; //~ ERROR a non-static lifetime + let _ = Foo::<{ faz::<'b>(&()) }>; //~ ERROR a non-static lifetime + let _ = Foo::<{ baz::<'b>(&()) }>; //~ ERROR a non-static lifetime +} + +fn main() {} |
