diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
commit | 64d98f8ee037282c35007b64c2649055c56af1db (patch) | |
tree | 5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/ui/inline-const | |
parent | Adding debian version 1.67.1+dfsg1-1. (diff) | |
download | rustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/inline-const')
32 files changed, 585 insertions, 0 deletions
diff --git a/tests/ui/inline-const/const-expr-array-init.rs b/tests/ui/inline-const/const-expr-array-init.rs new file mode 100644 index 000000000..8a92cdbc0 --- /dev/null +++ b/tests/ui/inline-const/const-expr-array-init.rs @@ -0,0 +1,9 @@ +// build-pass + +#![feature(inline_const)] + +use std::cell::Cell; + +fn main() { + let _x = [const { Cell::new(0) }; 20]; +} diff --git a/tests/ui/inline-const/const-expr-basic.rs b/tests/ui/inline-const/const-expr-basic.rs new file mode 100644 index 000000000..dac46fe25 --- /dev/null +++ b/tests/ui/inline-const/const-expr-basic.rs @@ -0,0 +1,14 @@ +// run-pass + +#![feature(inline_const)] + +fn foo() -> i32 { + const { + let x = 5 + 10; + x / 3 + } +} + +fn main() { + assert_eq!(5, foo()); +} diff --git a/tests/ui/inline-const/const-expr-generic-err.rs b/tests/ui/inline-const/const-expr-generic-err.rs new file mode 100644 index 000000000..4e8879af5 --- /dev/null +++ b/tests/ui/inline-const/const-expr-generic-err.rs @@ -0,0 +1,15 @@ +// 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/tests/ui/inline-const/const-expr-generic-err.stderr b/tests/ui/inline-const/const-expr-generic-err.stderr new file mode 100644 index 000000000..fc0b6cc44 --- /dev/null +++ b/tests/ui/inline-const/const-expr-generic-err.stderr @@ -0,0 +1,29 @@ +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/tests/ui/inline-const/const-expr-generic-err2.rs b/tests/ui/inline-const/const-expr-generic-err2.rs new file mode 100644 index 000000000..e097cbe9d --- /dev/null +++ b/tests/ui/inline-const/const-expr-generic-err2.rs @@ -0,0 +1,10 @@ +#![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/tests/ui/inline-const/const-expr-generic-err2.stderr b/tests/ui/inline-const/const-expr-generic-err2.stderr new file mode 100644 index 000000000..00b716cd2 --- /dev/null +++ b/tests/ui/inline-const/const-expr-generic-err2.stderr @@ -0,0 +1,10 @@ +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/tests/ui/inline-const/const-expr-generic.rs b/tests/ui/inline-const/const-expr-generic.rs new file mode 100644 index 000000000..3207bfa0e --- /dev/null +++ b/tests/ui/inline-const/const-expr-generic.rs @@ -0,0 +1,15 @@ +// 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/tests/ui/inline-const/const-expr-inference.rs b/tests/ui/inline-const/const-expr-inference.rs new file mode 100644 index 000000000..0d5892a74 --- /dev/null +++ b/tests/ui/inline-const/const-expr-inference.rs @@ -0,0 +1,11 @@ +// check-pass + +#![feature(inline_const)] + +pub fn todo<T>() -> T { + const { todo!() } +} + +fn main() { + let _: usize = const { 0 }; +} diff --git a/tests/ui/inline-const/const-expr-lifetime-err.rs b/tests/ui/inline-const/const-expr-lifetime-err.rs new file mode 100644 index 000000000..0a032a733 --- /dev/null +++ b/tests/ui/inline-const/const-expr-lifetime-err.rs @@ -0,0 +1,29 @@ +#![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/tests/ui/inline-const/const-expr-lifetime-err.stderr b/tests/ui/inline-const/const-expr-lifetime-err.stderr new file mode 100644 index 000000000..a23f7c9a7 --- /dev/null +++ b/tests/ui/inline-const/const-expr-lifetime-err.stderr @@ -0,0 +1,18 @@ +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/tests/ui/inline-const/const-expr-lifetime.rs b/tests/ui/inline-const/const-expr-lifetime.rs new file mode 100644 index 000000000..d883deb28 --- /dev/null +++ b/tests/ui/inline-const/const-expr-lifetime.rs @@ -0,0 +1,35 @@ +// 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/tests/ui/inline-const/const-expr-macro.rs b/tests/ui/inline-const/const-expr-macro.rs new file mode 100644 index 000000000..041f3e15a --- /dev/null +++ b/tests/ui/inline-const/const-expr-macro.rs @@ -0,0 +1,12 @@ +// 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/tests/ui/inline-const/const-expr-reference.rs b/tests/ui/inline-const/const-expr-reference.rs new file mode 100644 index 000000000..a54d879f6 --- /dev/null +++ b/tests/ui/inline-const/const-expr-reference.rs @@ -0,0 +1,14 @@ +// 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/tests/ui/inline-const/const-match-pat-generic.rs b/tests/ui/inline-const/const-match-pat-generic.rs new file mode 100644 index 000000000..7c0d83516 --- /dev/null +++ b/tests/ui/inline-const/const-match-pat-generic.rs @@ -0,0 +1,31 @@ +#![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/tests/ui/inline-const/const-match-pat-generic.stderr b/tests/ui/inline-const/const-match-pat-generic.stderr new file mode 100644 index 000000000..77267f12f --- /dev/null +++ b/tests/ui/inline-const/const-match-pat-generic.stderr @@ -0,0 +1,26 @@ +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/tests/ui/inline-const/const-match-pat-inference.rs b/tests/ui/inline-const/const-match-pat-inference.rs new file mode 100644 index 000000000..d83ae6e98 --- /dev/null +++ b/tests/ui/inline-const/const-match-pat-inference.rs @@ -0,0 +1,12 @@ +// 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/tests/ui/inline-const/const-match-pat-lifetime-err.rs b/tests/ui/inline-const/const-match-pat-lifetime-err.rs new file mode 100644 index 000000000..436b8037f --- /dev/null +++ b/tests/ui/inline-const/const-match-pat-lifetime-err.rs @@ -0,0 +1,34 @@ +// 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/tests/ui/inline-const/const-match-pat-lifetime.rs b/tests/ui/inline-const/const-match-pat-lifetime.rs new file mode 100644 index 000000000..6d943bbcc --- /dev/null +++ b/tests/ui/inline-const/const-match-pat-lifetime.rs @@ -0,0 +1,37 @@ +// 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/tests/ui/inline-const/const-match-pat-range.rs b/tests/ui/inline-const/const-match-pat-range.rs new file mode 100644 index 000000000..73d6334c3 --- /dev/null +++ b/tests/ui/inline-const/const-match-pat-range.rs @@ -0,0 +1,39 @@ +// 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/tests/ui/inline-const/const-match-pat.rs b/tests/ui/inline-const/const-match-pat.rs new file mode 100644 index 000000000..2f55e16b3 --- /dev/null +++ b/tests/ui/inline-const/const-match-pat.rs @@ -0,0 +1,21 @@ +// 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/tests/ui/inline-const/expr-unsafe-err.mir.stderr b/tests/ui/inline-const/expr-unsafe-err.mir.stderr new file mode 100644 index 000000000..1bec41e2e --- /dev/null +++ b/tests/ui/inline-const/expr-unsafe-err.mir.stderr @@ -0,0 +1,11 @@ +error[E0133]: call to unsafe function is unsafe and requires unsafe function or block + --> $DIR/expr-unsafe-err.rs:8:9 + | +LL | require_unsafe(); + | ^^^^^^^^^^^^^^^^ call to unsafe function + | + = note: consult the function's documentation for information on how to avoid undefined behavior + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0133`. diff --git a/tests/ui/inline-const/expr-unsafe-err.rs b/tests/ui/inline-const/expr-unsafe-err.rs new file mode 100644 index 000000000..adf05d352 --- /dev/null +++ b/tests/ui/inline-const/expr-unsafe-err.rs @@ -0,0 +1,11 @@ +// revisions: mir thir +// [thir]compile-flags: -Z thir-unsafeck +#![feature(inline_const)] +const unsafe fn require_unsafe() -> usize { 1 } + +fn main() { + const { + require_unsafe(); + //~^ ERROR [E0133] + } +} diff --git a/tests/ui/inline-const/expr-unsafe-err.thir.stderr b/tests/ui/inline-const/expr-unsafe-err.thir.stderr new file mode 100644 index 000000000..c971e8afb --- /dev/null +++ b/tests/ui/inline-const/expr-unsafe-err.thir.stderr @@ -0,0 +1,11 @@ +error[E0133]: call to unsafe function `require_unsafe` is unsafe and requires unsafe function or block + --> $DIR/expr-unsafe-err.rs:8:9 + | +LL | require_unsafe(); + | ^^^^^^^^^^^^^^^^ call to unsafe function + | + = note: consult the function's documentation for information on how to avoid undefined behavior + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0133`. diff --git a/tests/ui/inline-const/expr-unsafe.mir.stderr b/tests/ui/inline-const/expr-unsafe.mir.stderr new file mode 100644 index 000000000..1ab6e42fb --- /dev/null +++ b/tests/ui/inline-const/expr-unsafe.mir.stderr @@ -0,0 +1,14 @@ +warning: unnecessary `unsafe` block + --> $DIR/expr-unsafe.rs:12:13 + | +LL | unsafe {} + | ^^^^^^ unnecessary `unsafe` block + | +note: the lint level is defined here + --> $DIR/expr-unsafe.rs:4:9 + | +LL | #![warn(unused_unsafe)] + | ^^^^^^^^^^^^^ + +warning: 1 warning emitted + diff --git a/tests/ui/inline-const/expr-unsafe.rs b/tests/ui/inline-const/expr-unsafe.rs new file mode 100644 index 000000000..d71efd33d --- /dev/null +++ b/tests/ui/inline-const/expr-unsafe.rs @@ -0,0 +1,16 @@ +// check-pass +// revisions: mir thir +// [thir]compile-flags: -Z thir-unsafeck +#![warn(unused_unsafe)] +#![feature(inline_const)] +const unsafe fn require_unsafe() -> usize { 1 } + +fn main() { + unsafe { + const { + require_unsafe(); + unsafe {} + //~^ WARNING unnecessary `unsafe` block + } + } +} diff --git a/tests/ui/inline-const/expr-unsafe.thir.stderr b/tests/ui/inline-const/expr-unsafe.thir.stderr new file mode 100644 index 000000000..4737444fb --- /dev/null +++ b/tests/ui/inline-const/expr-unsafe.thir.stderr @@ -0,0 +1,17 @@ +warning: unnecessary `unsafe` block + --> $DIR/expr-unsafe.rs:12:13 + | +LL | unsafe { + | ------ because it's nested under this `unsafe` block +... +LL | unsafe {} + | ^^^^^^ unnecessary `unsafe` block + | +note: the lint level is defined here + --> $DIR/expr-unsafe.rs:4:9 + | +LL | #![warn(unused_unsafe)] + | ^^^^^^^^^^^^^ + +warning: 1 warning emitted + diff --git a/tests/ui/inline-const/expr-with-block-err.rs b/tests/ui/inline-const/expr-with-block-err.rs new file mode 100644 index 000000000..f7547742d --- /dev/null +++ b/tests/ui/inline-const/expr-with-block-err.rs @@ -0,0 +1,6 @@ +#![feature(inline_const)] + +fn main() { + const { 2 } - const { 1 }; + //~^ ERROR mismatched types +} diff --git a/tests/ui/inline-const/expr-with-block-err.stderr b/tests/ui/inline-const/expr-with-block-err.stderr new file mode 100644 index 000000000..6f7408f4e --- /dev/null +++ b/tests/ui/inline-const/expr-with-block-err.stderr @@ -0,0 +1,9 @@ +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/tests/ui/inline-const/expr-with-block.rs b/tests/ui/inline-const/expr-with-block.rs new file mode 100644 index 000000000..391872476 --- /dev/null +++ b/tests/ui/inline-const/expr-with-block.rs @@ -0,0 +1,10 @@ +// check-pass +#![feature(inline_const)] +fn main() { + match true { + true => const {} + false => () + } + const {} + () +} diff --git a/tests/ui/inline-const/macro-with-const.rs b/tests/ui/inline-const/macro-with-const.rs new file mode 100644 index 000000000..e7393166d --- /dev/null +++ b/tests/ui/inline-const/macro-with-const.rs @@ -0,0 +1,20 @@ +// 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); +} diff --git a/tests/ui/inline-const/pat-unsafe-err.rs b/tests/ui/inline-const/pat-unsafe-err.rs new file mode 100644 index 000000000..e290b438c --- /dev/null +++ b/tests/ui/inline-const/pat-unsafe-err.rs @@ -0,0 +1,17 @@ +// ignore-test This is currently broken +// revisions: mir thir +// [thir]compile-flags: -Z thir-unsafeck + +#![allow(incomplete_features)] +#![feature(inline_const_pat)] + +const unsafe fn require_unsafe() -> usize { 1 } + +fn main() { + match () { + const { + require_unsafe(); + //~^ ERROR [E0133] + } => (), + } +} diff --git a/tests/ui/inline-const/pat-unsafe.rs b/tests/ui/inline-const/pat-unsafe.rs new file mode 100644 index 000000000..bcf7f6e01 --- /dev/null +++ b/tests/ui/inline-const/pat-unsafe.rs @@ -0,0 +1,22 @@ +// ignore-test This is currently broken +// check-pass +// revisions: mir thir +// [thir]compile-flags: -Z thir-unsafeck + +#![allow(incomplete_features)] +#![warn(unused_unsafe)] +#![feature(inline_const_pat)] + +const unsafe fn require_unsafe() -> usize { 1 } + +fn main() { + unsafe { + match () { + const { + require_unsafe(); + unsafe {} + //~^ WARNING unnecessary `unsafe` block + } => (), + } + } +} |