diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:58 +0000 |
commit | a4b7ed7a42c716ab9f05e351f003d589124fd55d (patch) | |
tree | b620cd3f223850b28716e474e80c58059dca5dd4 /src/test/ui/inline-const | |
parent | Adding upstream version 1.67.1+dfsg1. (diff) | |
download | rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.tar.xz rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.zip |
Adding upstream version 1.68.2+dfsg1.upstream/1.68.2+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/inline-const')
24 files changed, 0 insertions, 466 deletions
diff --git a/src/test/ui/inline-const/const-expr-array-init.rs b/src/test/ui/inline-const/const-expr-array-init.rs deleted file mode 100644 index 8a92cdbc0..000000000 --- a/src/test/ui/inline-const/const-expr-array-init.rs +++ /dev/null @@ -1,9 +0,0 @@ -// build-pass - -#![feature(inline_const)] - -use std::cell::Cell; - -fn main() { - let _x = [const { Cell::new(0) }; 20]; -} diff --git a/src/test/ui/inline-const/const-expr-basic.rs b/src/test/ui/inline-const/const-expr-basic.rs deleted file mode 100644 index dac46fe25..000000000 --- a/src/test/ui/inline-const/const-expr-basic.rs +++ /dev/null @@ -1,14 +0,0 @@ -// run-pass - -#![feature(inline_const)] - -fn foo() -> i32 { - const { - let x = 5 + 10; - x / 3 - } -} - -fn main() { - assert_eq!(5, foo()); -} diff --git a/src/test/ui/inline-const/const-expr-generic-err.rs b/src/test/ui/inline-const/const-expr-generic-err.rs deleted file mode 100644 index 4e8879af5..000000000 --- a/src/test/ui/inline-const/const-expr-generic-err.rs +++ /dev/null @@ -1,15 +0,0 @@ -// build-fail -#![feature(inline_const)] - -fn foo<T>() { - const { assert!(std::mem::size_of::<T>() == 0); } //~ ERROR E0080 -} - -fn bar<const N: usize>() -> usize { - const { N - 1 } //~ ERROR E0080 -} - -fn main() { - foo::<i32>(); - bar::<0>(); -} diff --git a/src/test/ui/inline-const/const-expr-generic-err.stderr b/src/test/ui/inline-const/const-expr-generic-err.stderr deleted file mode 100644 index fc0b6cc44..000000000 --- a/src/test/ui/inline-const/const-expr-generic-err.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0080]: evaluation of `foo::<i32>::{constant#0}` failed - --> $DIR/const-expr-generic-err.rs:5:13 - | -LL | const { assert!(std::mem::size_of::<T>() == 0); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: std::mem::size_of::<T>() == 0', $DIR/const-expr-generic-err.rs:5:13 - | - = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) - -note: the above error was encountered while instantiating `fn foo::<i32>` - --> $DIR/const-expr-generic-err.rs:13:5 - | -LL | foo::<i32>(); - | ^^^^^^^^^^^^ - -error[E0080]: evaluation of `bar::<0>::{constant#0}` failed - --> $DIR/const-expr-generic-err.rs:9:13 - | -LL | const { N - 1 } - | ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow - -note: the above error was encountered while instantiating `fn bar::<0>` - --> $DIR/const-expr-generic-err.rs:14:5 - | -LL | bar::<0>(); - | ^^^^^^^^^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/inline-const/const-expr-generic-err2.rs b/src/test/ui/inline-const/const-expr-generic-err2.rs deleted file mode 100644 index e097cbe9d..000000000 --- a/src/test/ui/inline-const/const-expr-generic-err2.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![feature(inline_const)] - -fn foo<T>() { - let _ = [0u8; const { std::mem::size_of::<T>() }]; - //~^ ERROR: constant expression depends on a generic parameter -} - -fn main() { - foo::<i32>(); -} diff --git a/src/test/ui/inline-const/const-expr-generic-err2.stderr b/src/test/ui/inline-const/const-expr-generic-err2.stderr deleted file mode 100644 index 00b716cd2..000000000 --- a/src/test/ui/inline-const/const-expr-generic-err2.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: constant expression depends on a generic parameter - --> $DIR/const-expr-generic-err2.rs:4:19 - | -LL | let _ = [0u8; const { std::mem::size_of::<T>() }]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this may fail depending on what value the parameter takes - -error: aborting due to previous error - diff --git a/src/test/ui/inline-const/const-expr-generic.rs b/src/test/ui/inline-const/const-expr-generic.rs deleted file mode 100644 index 3207bfa0e..000000000 --- a/src/test/ui/inline-const/const-expr-generic.rs +++ /dev/null @@ -1,15 +0,0 @@ -// check-pass -#![feature(inline_const)] - -fn foo<T>() -> usize { - const { std::mem::size_of::<T>() } -} - -fn bar<const N: usize>() -> usize { - const { N + 1 } -} - -fn main() { - foo::<i32>(); - bar::<1>(); -} diff --git a/src/test/ui/inline-const/const-expr-inference.rs b/src/test/ui/inline-const/const-expr-inference.rs deleted file mode 100644 index 0d5892a74..000000000 --- a/src/test/ui/inline-const/const-expr-inference.rs +++ /dev/null @@ -1,11 +0,0 @@ -// check-pass - -#![feature(inline_const)] - -pub fn todo<T>() -> T { - const { todo!() } -} - -fn main() { - let _: usize = const { 0 }; -} diff --git a/src/test/ui/inline-const/const-expr-lifetime-err.rs b/src/test/ui/inline-const/const-expr-lifetime-err.rs deleted file mode 100644 index 0a032a733..000000000 --- a/src/test/ui/inline-const/const-expr-lifetime-err.rs +++ /dev/null @@ -1,29 +0,0 @@ -#![feature(const_mut_refs)] -#![feature(inline_const)] - -use std::marker::PhantomData; - -#[derive(PartialEq, Eq)] -pub struct InvariantRef<'a, T: ?Sized>(&'a T, PhantomData<&'a mut &'a T>); - -impl<'a, T: ?Sized> InvariantRef<'a, T> { - pub const fn new(r: &'a T) -> Self { - InvariantRef(r, PhantomData) - } -} - -impl<'a> InvariantRef<'a, ()> { - pub const NEW: Self = InvariantRef::new(&()); -} - -fn equate<T>(x: T, y: T){} - -fn foo<'a>() { - let y = (); - equate(InvariantRef::new(&y), const { InvariantRef::<'a>::NEW }); - //~^ ERROR `y` does not live long enough [E0597] -} - -fn main() { - foo(); -} diff --git a/src/test/ui/inline-const/const-expr-lifetime-err.stderr b/src/test/ui/inline-const/const-expr-lifetime-err.stderr deleted file mode 100644 index a23f7c9a7..000000000 --- a/src/test/ui/inline-const/const-expr-lifetime-err.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0597]: `y` does not live long enough - --> $DIR/const-expr-lifetime-err.rs:23:30 - | -LL | fn foo<'a>() { - | -- lifetime `'a` defined here -LL | let y = (); -LL | equate(InvariantRef::new(&y), const { InvariantRef::<'a>::NEW }); - | ------------------^^- - | | | - | | borrowed value does not live long enough - | argument requires that `y` is borrowed for `'a` -LL | -LL | } - | - `y` dropped here while still borrowed - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/inline-const/const-expr-lifetime.rs b/src/test/ui/inline-const/const-expr-lifetime.rs deleted file mode 100644 index d883deb28..000000000 --- a/src/test/ui/inline-const/const-expr-lifetime.rs +++ /dev/null @@ -1,35 +0,0 @@ -// run-pass - -#![feature(const_mut_refs)] -#![feature(inline_const)] - -use std::marker::PhantomData; - -// rust-lang/rust#78174: ICE: "cannot convert ReErased to a region vid" -fn issue_78174() { - let foo = const { "foo" }; - assert_eq!(foo, "foo"); -} - -pub struct InvariantRef<'a, T: ?Sized>(&'a T, PhantomData<&'a mut &'a T>); - -impl<'a, T: ?Sized> InvariantRef<'a, T> { - pub const fn new(r: &'a T) -> Self { - InvariantRef(r, PhantomData) - } -} - -fn get_invariant_ref<'a>() -> InvariantRef<'a, ()> { - const { InvariantRef::<'a, ()>::new(&()) } -} - -fn get_invariant_ref2<'a>() -> InvariantRef<'a, ()> { - // Try some type inference - const { InvariantRef::new(&()) } -} - -fn main() { - issue_78174(); - get_invariant_ref(); - get_invariant_ref2(); -} diff --git a/src/test/ui/inline-const/const-expr-macro.rs b/src/test/ui/inline-const/const-expr-macro.rs deleted file mode 100644 index 041f3e15a..000000000 --- a/src/test/ui/inline-const/const-expr-macro.rs +++ /dev/null @@ -1,12 +0,0 @@ -// run-pass - -#![feature(inline_const)] - -macro_rules! do_const_block{ - ($val:block) => { const $val } -} - -fn main() { - let s = do_const_block!({ 22 }); - assert_eq!(s, 22); -} diff --git a/src/test/ui/inline-const/const-expr-reference.rs b/src/test/ui/inline-const/const-expr-reference.rs deleted file mode 100644 index a54d879f6..000000000 --- a/src/test/ui/inline-const/const-expr-reference.rs +++ /dev/null @@ -1,14 +0,0 @@ -// run-pass - -#![feature(inline_const)] - -const fn bar() -> i32 { - const { - 2 + 3 - } -} - -fn main() { - let x: &'static i32 = &const{bar()}; - assert_eq!(&5, x); -} diff --git a/src/test/ui/inline-const/const-match-pat-generic.rs b/src/test/ui/inline-const/const-match-pat-generic.rs deleted file mode 100644 index 7c0d83516..000000000 --- a/src/test/ui/inline-const/const-match-pat-generic.rs +++ /dev/null @@ -1,31 +0,0 @@ -#![allow(incomplete_features)] -#![feature(inline_const_pat)] - -// rust-lang/rust#82518: ICE with inline-const in match referencing const-generic parameter - -fn foo<const V: usize>() { - match 0 { - const { V } => {}, - //~^ ERROR constant pattern depends on a generic parameter - //~| ERROR constant pattern depends on a generic parameter - _ => {}, - } -} - -const fn f(x: usize) -> usize { - x + 1 -} - -fn bar<const V: usize>() { - match 0 { - const { f(V) } => {}, - //~^ ERROR constant pattern depends on a generic parameter - //~| ERROR constant pattern depends on a generic parameter - _ => {}, - } -} - -fn main() { - foo::<1>(); - bar::<1>(); -} diff --git a/src/test/ui/inline-const/const-match-pat-generic.stderr b/src/test/ui/inline-const/const-match-pat-generic.stderr deleted file mode 100644 index 77267f12f..000000000 --- a/src/test/ui/inline-const/const-match-pat-generic.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error: constant pattern depends on a generic parameter - --> $DIR/const-match-pat-generic.rs:8:9 - | -LL | const { V } => {}, - | ^^^^^^^^^^^ - -error: constant pattern depends on a generic parameter - --> $DIR/const-match-pat-generic.rs:21:9 - | -LL | const { f(V) } => {}, - | ^^^^^^^^^^^^^^ - -error: constant pattern depends on a generic parameter - --> $DIR/const-match-pat-generic.rs:8:9 - | -LL | const { V } => {}, - | ^^^^^^^^^^^ - -error: constant pattern depends on a generic parameter - --> $DIR/const-match-pat-generic.rs:21:9 - | -LL | const { f(V) } => {}, - | ^^^^^^^^^^^^^^ - -error: aborting due to 4 previous errors - diff --git a/src/test/ui/inline-const/const-match-pat-inference.rs b/src/test/ui/inline-const/const-match-pat-inference.rs deleted file mode 100644 index d83ae6e98..000000000 --- a/src/test/ui/inline-const/const-match-pat-inference.rs +++ /dev/null @@ -1,12 +0,0 @@ -// check-pass - -#![feature(inline_const_pat)] -#![allow(incomplete_features)] - -fn main() { - match 1u64 { - 0 => (), - const { 0 + 1 } => (), - const { 2 - 1 } ..= const { u64::MAX } => (), - } -} diff --git a/src/test/ui/inline-const/const-match-pat-lifetime-err.rs b/src/test/ui/inline-const/const-match-pat-lifetime-err.rs deleted file mode 100644 index 436b8037f..000000000 --- a/src/test/ui/inline-const/const-match-pat-lifetime-err.rs +++ /dev/null @@ -1,34 +0,0 @@ -// ignore-test - -#![allow(incomplete_features)] -#![feature(const_mut_refs)] -#![feature(inline_const_pat)] - -use std::marker::PhantomData; - -#[derive(PartialEq, Eq)] -pub struct InvariantRef<'a, T: ?Sized>(&'a T, PhantomData<&'a mut &'a T>); - -impl<'a, T: ?Sized> InvariantRef<'a, T> { - pub const fn new(r: &'a T) -> Self { - InvariantRef(r, PhantomData) - } -} - -impl<'a> InvariantRef<'a, ()> { - pub const NEW: Self = InvariantRef::new(&()); -} - -fn match_invariant_ref<'a>() { - let y = (); - match InvariantRef::new(&y) { - //~^ ERROR `y` does not live long enough [E0597] - // FIXME(nbdd0121): This should give the same error as `InvariantRef::<'a>::NEW` (without - // const block) - const { InvariantRef::<'a>::NEW } => (), - } -} - -fn main() { - match_invariant_ref(); -} diff --git a/src/test/ui/inline-const/const-match-pat-lifetime.rs b/src/test/ui/inline-const/const-match-pat-lifetime.rs deleted file mode 100644 index 6d943bbcc..000000000 --- a/src/test/ui/inline-const/const-match-pat-lifetime.rs +++ /dev/null @@ -1,37 +0,0 @@ -// run-pass - -#![allow(incomplete_features)] -#![feature(const_mut_refs)] -#![feature(inline_const)] -#![feature(inline_const_pat)] - -use std::marker::PhantomData; - -// rust-lang/rust#78174: ICE: "cannot convert ReErased to a region vid" -fn issue_78174() { - match "foo" { - const { concat!("fo", "o") } => (), - _ => unreachable!(), - } -} - -#[derive(PartialEq, Eq)] -pub struct InvariantRef<'a, T: ?Sized>(&'a T, PhantomData<&'a mut &'a T>); - -impl<'a, T: ?Sized> InvariantRef<'a, T> { - pub const fn new(r: &'a T) -> Self { - InvariantRef(r, PhantomData) - } -} - -fn match_invariant_ref<'a>() { - match const { InvariantRef::<'a, _>::new(&()) } { - const { InvariantRef::<'a, ()>::new(&()) } => { - } - } -} - -fn main() { - issue_78174(); - match_invariant_ref(); -} diff --git a/src/test/ui/inline-const/const-match-pat-range.rs b/src/test/ui/inline-const/const-match-pat-range.rs deleted file mode 100644 index 73d6334c3..000000000 --- a/src/test/ui/inline-const/const-match-pat-range.rs +++ /dev/null @@ -1,39 +0,0 @@ -// build-pass - -#![allow(incomplete_features)] -#![feature(inline_const_pat, exclusive_range_pattern)] - -fn main() { - const N: u32 = 10; - let x: u32 = 3; - - match x { - 1 ..= const { N + 1 } => {}, - _ => {}, - } - - match x { - const { N - 1 } ..= 10 => {}, - _ => {}, - } - - match x { - const { N - 1 } ..= const { N + 1 } => {}, - _ => {}, - } - - match x { - .. const { N + 1 } => {}, - _ => {}, - } - - match x { - const { N - 1 } .. => {}, - _ => {}, - } - - match x { - ..= const { N + 1 } => {}, - _ => {} - } -} diff --git a/src/test/ui/inline-const/const-match-pat.rs b/src/test/ui/inline-const/const-match-pat.rs deleted file mode 100644 index 2f55e16b3..000000000 --- a/src/test/ui/inline-const/const-match-pat.rs +++ /dev/null @@ -1,21 +0,0 @@ -// run-pass - -#![allow(incomplete_features)] -#![feature(inline_const_pat)] -const MMIO_BIT1: u8 = 4; -const MMIO_BIT2: u8 = 5; - -fn main() { - let s = match read_mmio() { - 0 => "FOO", - const { 1 << MMIO_BIT1 } => "BAR", - const { 1 << MMIO_BIT2 } => "BAZ", - _ => unreachable!(), - }; - - assert_eq!("BAZ", s); -} - -fn read_mmio() -> i32 { - 1 << 5 -} diff --git a/src/test/ui/inline-const/expr-with-block-err.rs b/src/test/ui/inline-const/expr-with-block-err.rs deleted file mode 100644 index f7547742d..000000000 --- a/src/test/ui/inline-const/expr-with-block-err.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![feature(inline_const)] - -fn main() { - const { 2 } - const { 1 }; - //~^ ERROR mismatched types -} diff --git a/src/test/ui/inline-const/expr-with-block-err.stderr b/src/test/ui/inline-const/expr-with-block-err.stderr deleted file mode 100644 index 6f7408f4e..000000000 --- a/src/test/ui/inline-const/expr-with-block-err.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/expr-with-block-err.rs:4:13 - | -LL | const { 2 } - const { 1 }; - | ^ expected `()`, found integer - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/inline-const/expr-with-block.rs b/src/test/ui/inline-const/expr-with-block.rs deleted file mode 100644 index 391872476..000000000 --- a/src/test/ui/inline-const/expr-with-block.rs +++ /dev/null @@ -1,10 +0,0 @@ -// check-pass -#![feature(inline_const)] -fn main() { - match true { - true => const {} - false => () - } - const {} - () -} diff --git a/src/test/ui/inline-const/macro-with-const.rs b/src/test/ui/inline-const/macro-with-const.rs deleted file mode 100644 index e7393166d..000000000 --- a/src/test/ui/inline-const/macro-with-const.rs +++ /dev/null @@ -1,20 +0,0 @@ -// check-pass - -macro_rules! exp { - (const $n:expr) => { - $n - }; -} - -macro_rules! stmt { - (exp $e:expr) => { - $e - }; - (exp $($t:tt)+) => { - exp!($($t)+) - }; -} - -fn main() { - stmt!(exp const 1); -} |