diff options
| author | Gabriel Smith <ga29smith@gmail.com> | 2020-07-04 23:43:48 -0400 |
|---|---|---|
| committer | Gabriel Smith <ga29smith@gmail.com> | 2020-07-19 12:52:36 -0400 |
| commit | 69d5dd6a5023a21ae755381f28f8450227be6daf (patch) | |
| tree | abe8333adbae4ae75a0cc9ad1cd9692f67a9decc /src/test/ui/error-codes | |
| parent | 48036804d2bc461b243c5d291b850e44bcca68ef (diff) | |
| download | rust-69d5dd6a5023a21ae755381f28f8450227be6daf.tar.gz rust-69d5dd6a5023a21ae755381f28f8450227be6daf.zip | |
disallow non-static lifetimes in const generics
This has been put in place to patch over an ICE caused when we encounter a non-static lifetime in a const generic during borrow checking. This restriction may be relaxed in the future, but we need more discussion before then, and in the meantime we should still deal with this ICE. Fixes issue #60814
Diffstat (limited to 'src/test/ui/error-codes')
| -rw-r--r-- | src/test/ui/error-codes/E0771.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/error-codes/E0771.stderr | 20 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/test/ui/error-codes/E0771.rs b/src/test/ui/error-codes/E0771.rs new file mode 100644 index 00000000000..ba359271940 --- /dev/null +++ b/src/test/ui/error-codes/E0771.rs @@ -0,0 +1,8 @@ +#![feature(const_generics)] +//~^ WARN the feature `const_generics` is incomplete + +fn function_with_str<'a, const STRING: &'a str>() {} //~ ERROR E0771 + +fn main() { + function_with_str::<"Hello, world!">() +} diff --git a/src/test/ui/error-codes/E0771.stderr b/src/test/ui/error-codes/E0771.stderr new file mode 100644 index 00000000000..60220be6b57 --- /dev/null +++ b/src/test/ui/error-codes/E0771.stderr @@ -0,0 +1,20 @@ +warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/E0771.rs:1:12 + | +LL | #![feature(const_generics)] + | ^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information + +error[E0771]: use of non-static lifetime `'a` in const generic + --> $DIR/E0771.rs:4:41 + | +LL | fn function_with_str<'a, const STRING: &'a str>() {} + | ^^ + | + = note: for more information, see issue #74052 <https://github.com/rust-lang/rust/issues/74052> + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0771`. |
