about summary refs log tree commit diff
path: root/tests/ui/inline-const
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/inline-const')
-rw-r--r--tests/ui/inline-const/const-expr-array-init.rs9
-rw-r--r--tests/ui/inline-const/const-expr-basic.rs14
-rw-r--r--tests/ui/inline-const/const-expr-generic-err.rs15
-rw-r--r--tests/ui/inline-const/const-expr-generic-err.stderr29
-rw-r--r--tests/ui/inline-const/const-expr-generic-err2.rs10
-rw-r--r--tests/ui/inline-const/const-expr-generic-err2.stderr10
-rw-r--r--tests/ui/inline-const/const-expr-generic.rs15
-rw-r--r--tests/ui/inline-const/const-expr-inference.rs11
-rw-r--r--tests/ui/inline-const/const-expr-lifetime-err.rs29
-rw-r--r--tests/ui/inline-const/const-expr-lifetime-err.stderr18
-rw-r--r--tests/ui/inline-const/const-expr-lifetime.rs35
-rw-r--r--tests/ui/inline-const/const-expr-macro.rs12
-rw-r--r--tests/ui/inline-const/const-expr-reference.rs14
-rw-r--r--tests/ui/inline-const/const-match-pat-generic.rs31
-rw-r--r--tests/ui/inline-const/const-match-pat-generic.stderr26
-rw-r--r--tests/ui/inline-const/const-match-pat-inference.rs12
-rw-r--r--tests/ui/inline-const/const-match-pat-lifetime-err.rs34
-rw-r--r--tests/ui/inline-const/const-match-pat-lifetime.rs37
-rw-r--r--tests/ui/inline-const/const-match-pat-range.rs39
-rw-r--r--tests/ui/inline-const/const-match-pat.rs21
-rw-r--r--tests/ui/inline-const/expr-unsafe-err.mir.stderr11
-rw-r--r--tests/ui/inline-const/expr-unsafe-err.rs11
-rw-r--r--tests/ui/inline-const/expr-unsafe-err.thir.stderr11
-rw-r--r--tests/ui/inline-const/expr-unsafe.mir.stderr14
-rw-r--r--tests/ui/inline-const/expr-unsafe.rs16
-rw-r--r--tests/ui/inline-const/expr-unsafe.thir.stderr17
-rw-r--r--tests/ui/inline-const/expr-with-block-err.rs6
-rw-r--r--tests/ui/inline-const/expr-with-block-err.stderr9
-rw-r--r--tests/ui/inline-const/expr-with-block.rs10
-rw-r--r--tests/ui/inline-const/macro-with-const.rs20
-rw-r--r--tests/ui/inline-const/pat-unsafe-err.rs17
-rw-r--r--tests/ui/inline-const/pat-unsafe.rs22
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 00000000000..8a92cdbc0f9
--- /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 00000000000..dac46fe25ec
--- /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 00000000000..4e8879af54a
--- /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 00000000000..fc0b6cc4451
--- /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 00000000000..e097cbe9dd6
--- /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 00000000000..00b716cd259
--- /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 00000000000..3207bfa0e89
--- /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 00000000000..0d5892a74d9
--- /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 00000000000..0a032a7338a
--- /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 00000000000..a23f7c9a796
--- /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 00000000000..d883deb2845
--- /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 00000000000..041f3e15a29
--- /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 00000000000..a54d879f69d
--- /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 00000000000..7c0d83516ea
--- /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 00000000000..77267f12fb1
--- /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 00000000000..d83ae6e9834
--- /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 00000000000..436b8037f30
--- /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 00000000000..6d943bbcc01
--- /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 00000000000..73d6334c36f
--- /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 00000000000..2f55e16b35c
--- /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 00000000000..1bec41e2efa
--- /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 00000000000..adf05d352ea
--- /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 00000000000..c971e8afb35
--- /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 00000000000..1ab6e42fba0
--- /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 00000000000..d71efd33db1
--- /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 00000000000..4737444fb61
--- /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 00000000000..f7547742ddc
--- /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 00000000000..6f7408f4e2a
--- /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 00000000000..391872476fc
--- /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 00000000000..e7393166d8d
--- /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 00000000000..e290b438c51
--- /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 00000000000..bcf7f6e0180
--- /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
+            } => (),
+        }
+    }
+}