about summary refs log tree commit diff
path: root/tests/ui/asm
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/asm')
-rw-r--r--tests/ui/asm/aarch64/bad-reg.stderr2
-rw-r--r--tests/ui/asm/aarch64/parse-error.stderr40
-rw-r--r--tests/ui/asm/asm-with-nested-closure.rs11
-rw-r--r--tests/ui/asm/conditionally-sized-ptr-fail.rs19
-rw-r--r--tests/ui/asm/conditionally-sized-ptr-fail.stderr18
-rw-r--r--tests/ui/asm/conditionally-sized-ptr.rs12
-rw-r--r--tests/ui/asm/global-asm-with-lifetimes.rs8
-rw-r--r--tests/ui/asm/inline-asm-with-lifetimes.bad.stderr17
-rw-r--r--tests/ui/asm/inline-asm-with-lifetimes.rs22
-rw-r--r--tests/ui/asm/invalid-const-operand.stderr15
-rw-r--r--tests/ui/asm/parse-error.stderr25
-rw-r--r--tests/ui/asm/x86_64/bad-reg.stderr2
-rw-r--r--tests/ui/asm/x86_64/issue-82869.stderr4
-rw-r--r--tests/ui/asm/x86_64/issue-89875.rs2
-rw-r--r--tests/ui/asm/x86_64/x86_64_parse_error.stderr15
15 files changed, 172 insertions, 40 deletions
diff --git a/tests/ui/asm/aarch64/bad-reg.stderr b/tests/ui/asm/aarch64/bad-reg.stderr
index 370752ad0f1..c76722f32a7 100644
--- a/tests/ui/asm/aarch64/bad-reg.stderr
+++ b/tests/ui/asm/aarch64/bad-reg.stderr
@@ -3,6 +3,8 @@ error: invalid register class `foo`: unknown register class
    |
 LL |         asm!("{}", in(foo) foo);
    |                    ^^^^^^^^^^^
+   |
+   = note: the following register classes are supported on this target: `reg`, `vreg`, `vreg_low16`, `preg`
 
 error: invalid register `foo`: unknown register
   --> $DIR/bad-reg.rs:14:18
diff --git a/tests/ui/asm/aarch64/parse-error.stderr b/tests/ui/asm/aarch64/parse-error.stderr
index 7b273282ee6..b5e1169e5f6 100644
--- a/tests/ui/asm/aarch64/parse-error.stderr
+++ b/tests/ui/asm/aarch64/parse-error.stderr
@@ -330,8 +330,9 @@ LL |         asm!("{}", options(), const foo);
    |
 help: consider using `const` instead of `let`
    |
-LL |     const foo: /* Type */ = 0;
-   |     ~~~~~    ++++++++++++
+LL -     let mut foo = 0;
+LL +     const foo: /* Type */ = 0;
+   |
 
 error[E0435]: attempt to use a non-constant value in a constant
   --> $DIR/parse-error.rs:45:44
@@ -341,8 +342,9 @@ LL |         asm!("{}", clobber_abi("C"), const foo);
    |
 help: consider using `const` instead of `let`
    |
-LL |     const foo: /* Type */ = 0;
-   |     ~~~~~    ++++++++++++
+LL -     let mut foo = 0;
+LL +     const foo: /* Type */ = 0;
+   |
 
 error[E0435]: attempt to use a non-constant value in a constant
   --> $DIR/parse-error.rs:48:55
@@ -352,8 +354,9 @@ LL |         asm!("{}", options(), clobber_abi("C"), const foo);
    |
 help: consider using `const` instead of `let`
    |
-LL |     const foo: /* Type */ = 0;
-   |     ~~~~~    ++++++++++++
+LL -     let mut foo = 0;
+LL +     const foo: /* Type */ = 0;
+   |
 
 error[E0435]: attempt to use a non-constant value in a constant
   --> $DIR/parse-error.rs:50:31
@@ -363,8 +366,9 @@ LL |         asm!("{a}", a = const foo, a = const bar);
    |
 help: consider using `const` instead of `let`
    |
-LL |     const foo: /* Type */ = 0;
-   |     ~~~~~    ++++++++++++
+LL -     let mut foo = 0;
+LL +     const foo: /* Type */ = 0;
+   |
 
 error[E0435]: attempt to use a non-constant value in a constant
   --> $DIR/parse-error.rs:50:46
@@ -374,8 +378,9 @@ LL |         asm!("{a}", a = const foo, a = const bar);
    |
 help: consider using `const` instead of `let`
    |
-LL |     const bar: /* Type */ = 0;
-   |     ~~~~~    ++++++++++++
+LL -     let mut bar = 0;
+LL +     const bar: /* Type */ = 0;
+   |
 
 error[E0435]: attempt to use a non-constant value in a constant
   --> $DIR/parse-error.rs:57:45
@@ -385,8 +390,9 @@ LL |         asm!("{a}", in("x0") foo, a = const bar);
    |
 help: consider using `const` instead of `let`
    |
-LL |     const bar: /* Type */ = 0;
-   |     ~~~~~    ++++++++++++
+LL -     let mut bar = 0;
+LL +     const bar: /* Type */ = 0;
+   |
 
 error[E0435]: attempt to use a non-constant value in a constant
   --> $DIR/parse-error.rs:59:45
@@ -396,8 +402,9 @@ LL |         asm!("{a}", in("x0") foo, a = const bar);
    |
 help: consider using `const` instead of `let`
    |
-LL |     const bar: /* Type */ = 0;
-   |     ~~~~~    ++++++++++++
+LL -     let mut bar = 0;
+LL +     const bar: /* Type */ = 0;
+   |
 
 error[E0435]: attempt to use a non-constant value in a constant
   --> $DIR/parse-error.rs:61:41
@@ -407,8 +414,9 @@ LL |         asm!("{1}", in("x0") foo, const bar);
    |
 help: consider using `const` instead of `let`
    |
-LL |     const bar: /* Type */ = 0;
-   |     ~~~~~    ++++++++++++
+LL -     let mut bar = 0;
+LL +     const bar: /* Type */ = 0;
+   |
 
 error: aborting due to 59 previous errors
 
diff --git a/tests/ui/asm/asm-with-nested-closure.rs b/tests/ui/asm/asm-with-nested-closure.rs
new file mode 100644
index 00000000000..3a5cd48d5d4
--- /dev/null
+++ b/tests/ui/asm/asm-with-nested-closure.rs
@@ -0,0 +1,11 @@
+//@ build-pass
+//@ needs-asm-support
+
+fn foo<const N: usize>() {}
+
+core::arch::global_asm!("/* {} */", sym foo::<{
+    || {};
+    0
+}>);
+
+fn main() {}
diff --git a/tests/ui/asm/conditionally-sized-ptr-fail.rs b/tests/ui/asm/conditionally-sized-ptr-fail.rs
new file mode 100644
index 00000000000..b0a93495ffa
--- /dev/null
+++ b/tests/ui/asm/conditionally-sized-ptr-fail.rs
@@ -0,0 +1,19 @@
+//@ needs-asm-support
+
+use std::arch::asm;
+
+fn _f<T: ?Sized>(p: *mut T) {
+    unsafe {
+        asm!("/* {} */", in(reg) p);
+        //~^ ERROR cannot use value of unsized pointer type `*mut T` for inline assembly
+    }
+}
+
+fn _g(p: *mut [u8]) {
+    unsafe {
+        asm!("/* {} */", in(reg) p);
+        //~^ ERROR cannot use value of unsized pointer type `*mut [u8]` for inline assembly
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/asm/conditionally-sized-ptr-fail.stderr b/tests/ui/asm/conditionally-sized-ptr-fail.stderr
new file mode 100644
index 00000000000..b88f59f569c
--- /dev/null
+++ b/tests/ui/asm/conditionally-sized-ptr-fail.stderr
@@ -0,0 +1,18 @@
+error: cannot use value of unsized pointer type `*mut T` for inline assembly
+  --> $DIR/conditionally-sized-ptr-fail.rs:7:34
+   |
+LL |         asm!("/* {} */", in(reg) p);
+   |                                  ^
+   |
+   = note: only sized pointers can be used in inline assembly
+
+error: cannot use value of unsized pointer type `*mut [u8]` for inline assembly
+  --> $DIR/conditionally-sized-ptr-fail.rs:14:34
+   |
+LL |         asm!("/* {} */", in(reg) p);
+   |                                  ^
+   |
+   = note: only sized pointers can be used in inline assembly
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/asm/conditionally-sized-ptr.rs b/tests/ui/asm/conditionally-sized-ptr.rs
new file mode 100644
index 00000000000..8ff18fd1da1
--- /dev/null
+++ b/tests/ui/asm/conditionally-sized-ptr.rs
@@ -0,0 +1,12 @@
+//@ check-pass
+//@ needs-asm-support
+
+use std::arch::asm;
+
+fn _f<T>(p: *mut T) {
+    unsafe {
+        asm!("/* {} */", in(reg) p);
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/asm/global-asm-with-lifetimes.rs b/tests/ui/asm/global-asm-with-lifetimes.rs
new file mode 100644
index 00000000000..2709ff90fe3
--- /dev/null
+++ b/tests/ui/asm/global-asm-with-lifetimes.rs
@@ -0,0 +1,8 @@
+//@ build-pass
+//@ needs-asm-support
+
+fn foo<T>() {}
+
+core::arch::global_asm!("/* {} */", sym foo::<&'static ()>);
+
+fn main() {}
diff --git a/tests/ui/asm/inline-asm-with-lifetimes.bad.stderr b/tests/ui/asm/inline-asm-with-lifetimes.bad.stderr
new file mode 100644
index 00000000000..f04482f9c59
--- /dev/null
+++ b/tests/ui/asm/inline-asm-with-lifetimes.bad.stderr
@@ -0,0 +1,17 @@
+error[E0309]: the parameter type `T` may not live long enough
+  --> $DIR/inline-asm-with-lifetimes.rs:17:26
+   |
+LL | fn test<'a: 'a, T>() {
+   |         -- the parameter type `T` must be valid for the lifetime `'a` as defined here...
+LL |     unsafe {
+LL |         asm!("/* {} */", sym dep::<'a, T> );
+   |                          ^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
+   |
+help: consider adding an explicit lifetime bound
+   |
+LL | fn test<'a: 'a, T: 'a>() {
+   |                  ++++
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0309`.
diff --git a/tests/ui/asm/inline-asm-with-lifetimes.rs b/tests/ui/asm/inline-asm-with-lifetimes.rs
new file mode 100644
index 00000000000..79def03eeb2
--- /dev/null
+++ b/tests/ui/asm/inline-asm-with-lifetimes.rs
@@ -0,0 +1,22 @@
+//@ revisions: good bad
+//@[good] build-pass
+//@ needs-asm-support
+
+use std::arch::asm;
+
+// lifetime requirement, we should check it!!
+#[cfg(bad)]
+fn dep<'a, T: 'a>() {}
+
+// no lifetime requirement
+#[cfg(good)]
+fn dep<'a: 'a, T>() {}
+
+fn test<'a: 'a, T>() {
+    unsafe {
+        asm!("/* {} */", sym dep::<'a, T> );
+        //[bad]~^ ERROR the parameter type `T` may not live long enough
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/asm/invalid-const-operand.stderr b/tests/ui/asm/invalid-const-operand.stderr
index bda4b0355b7..13bb10e84a5 100644
--- a/tests/ui/asm/invalid-const-operand.stderr
+++ b/tests/ui/asm/invalid-const-operand.stderr
@@ -6,8 +6,9 @@ LL |         asm!("{}", const x);
    |
 help: consider using `const` instead of `let`
    |
-LL |         const x: /* Type */ = 0;
-   |         ~~~~~  ++++++++++++
+LL -         let x = 0;
+LL +         const x: /* Type */ = 0;
+   |
 
 error[E0435]: attempt to use a non-constant value in a constant
   --> $DIR/invalid-const-operand.rs:43:36
@@ -17,8 +18,9 @@ LL |         asm!("{}", const const_foo(x));
    |
 help: consider using `const` instead of `let`
    |
-LL |         const x: /* Type */ = 0;
-   |         ~~~~~  ++++++++++++
+LL -         let x = 0;
+LL +         const x: /* Type */ = 0;
+   |
 
 error[E0435]: attempt to use a non-constant value in a constant
   --> $DIR/invalid-const-operand.rs:46:36
@@ -28,8 +30,9 @@ LL |         asm!("{}", const const_bar(x));
    |
 help: consider using `const` instead of `let`
    |
-LL |         const x: /* Type */ = 0;
-   |         ~~~~~  ++++++++++++
+LL -         let x = 0;
+LL +         const x: /* Type */ = 0;
+   |
 
 error: invalid type for `const` operand
   --> $DIR/invalid-const-operand.rs:12:19
diff --git a/tests/ui/asm/parse-error.stderr b/tests/ui/asm/parse-error.stderr
index 6d0e629b937..74647372a35 100644
--- a/tests/ui/asm/parse-error.stderr
+++ b/tests/ui/asm/parse-error.stderr
@@ -424,8 +424,9 @@ LL |         asm!("{}", options(), const foo);
    |
 help: consider using `const` instead of `let`
    |
-LL |     const foo: /* Type */ = 0;
-   |     ~~~~~    ++++++++++++
+LL -     let mut foo = 0;
+LL +     const foo: /* Type */ = 0;
+   |
 
 error[E0435]: attempt to use a non-constant value in a constant
   --> $DIR/parse-error.rs:69:44
@@ -435,8 +436,9 @@ LL |         asm!("{}", clobber_abi("C"), const foo);
    |
 help: consider using `const` instead of `let`
    |
-LL |     const foo: /* Type */ = 0;
-   |     ~~~~~    ++++++++++++
+LL -     let mut foo = 0;
+LL +     const foo: /* Type */ = 0;
+   |
 
 error[E0435]: attempt to use a non-constant value in a constant
   --> $DIR/parse-error.rs:72:55
@@ -446,8 +448,9 @@ LL |         asm!("{}", options(), clobber_abi("C"), const foo);
    |
 help: consider using `const` instead of `let`
    |
-LL |     const foo: /* Type */ = 0;
-   |     ~~~~~    ++++++++++++
+LL -     let mut foo = 0;
+LL +     const foo: /* Type */ = 0;
+   |
 
 error[E0435]: attempt to use a non-constant value in a constant
   --> $DIR/parse-error.rs:74:31
@@ -457,8 +460,9 @@ LL |         asm!("{a}", a = const foo, a = const bar);
    |
 help: consider using `const` instead of `let`
    |
-LL |     const foo: /* Type */ = 0;
-   |     ~~~~~    ++++++++++++
+LL -     let mut foo = 0;
+LL +     const foo: /* Type */ = 0;
+   |
 
 error[E0435]: attempt to use a non-constant value in a constant
   --> $DIR/parse-error.rs:74:46
@@ -468,8 +472,9 @@ LL |         asm!("{a}", a = const foo, a = const bar);
    |
 help: consider using `const` instead of `let`
    |
-LL |     const bar: /* Type */ = 0;
-   |     ~~~~~    ++++++++++++
+LL -     let mut bar = 0;
+LL +     const bar: /* Type */ = 0;
+   |
 
 error: aborting due to 72 previous errors
 
diff --git a/tests/ui/asm/x86_64/bad-reg.stderr b/tests/ui/asm/x86_64/bad-reg.stderr
index 3df1f7b2208..6a02957210b 100644
--- a/tests/ui/asm/x86_64/bad-reg.stderr
+++ b/tests/ui/asm/x86_64/bad-reg.stderr
@@ -3,6 +3,8 @@ error: invalid register class `foo`: unknown register class
    |
 LL |         asm!("{}", in(foo) foo);
    |                    ^^^^^^^^^^^
+   |
+   = note: the following register classes are supported on this target: `reg`, `reg_abcd`, `reg_byte`, `xmm_reg`, `ymm_reg`, `zmm_reg`, `kreg`, `kreg0`, `mmx_reg`, `x87_reg`, `tmm_reg`
 
 error: invalid register `foo`: unknown register
   --> $DIR/bad-reg.rs:14:18
diff --git a/tests/ui/asm/x86_64/issue-82869.stderr b/tests/ui/asm/x86_64/issue-82869.stderr
index 3cf9d6d1c1c..56e49099569 100644
--- a/tests/ui/asm/x86_64/issue-82869.stderr
+++ b/tests/ui/asm/x86_64/issue-82869.stderr
@@ -3,12 +3,16 @@ error: invalid register class `vreg`: unknown register class
    |
 LL |     asm!("add {:d}, {:d}, d0", out(vreg) c, in(vreg) a, in("d0") {
    |                                ^^^^^^^^^^^
+   |
+   = note: the following register classes are supported on this target: `reg`, `reg_abcd`, `reg_byte`, `xmm_reg`, `ymm_reg`, `zmm_reg`, `kreg`, `kreg0`, `mmx_reg`, `x87_reg`, `tmm_reg`
 
 error: invalid register class `vreg`: unknown register class
   --> $DIR/issue-82869.rs:11:45
    |
 LL |     asm!("add {:d}, {:d}, d0", out(vreg) c, in(vreg) a, in("d0") {
    |                                             ^^^^^^^^^^
+   |
+   = note: the following register classes are supported on this target: `reg`, `reg_abcd`, `reg_byte`, `xmm_reg`, `ymm_reg`, `zmm_reg`, `kreg`, `kreg0`, `mmx_reg`, `x87_reg`, `tmm_reg`
 
 error: invalid register `d0`: unknown register
   --> $DIR/issue-82869.rs:11:57
diff --git a/tests/ui/asm/x86_64/issue-89875.rs b/tests/ui/asm/x86_64/issue-89875.rs
index af940f05fea..0252859cff0 100644
--- a/tests/ui/asm/x86_64/issue-89875.rs
+++ b/tests/ui/asm/x86_64/issue-89875.rs
@@ -2,8 +2,6 @@
 //@ needs-asm-support
 //@ only-x86_64
 
-#![feature(target_feature_11)]
-
 use std::arch::asm;
 
 #[target_feature(enable = "avx")]
diff --git a/tests/ui/asm/x86_64/x86_64_parse_error.stderr b/tests/ui/asm/x86_64/x86_64_parse_error.stderr
index b64f6c1127e..dfa3e1d0ef2 100644
--- a/tests/ui/asm/x86_64/x86_64_parse_error.stderr
+++ b/tests/ui/asm/x86_64/x86_64_parse_error.stderr
@@ -20,8 +20,9 @@ LL |         asm!("{a}", in("eax") foo, a = const bar);
    |
 help: consider using `const` instead of `let`
    |
-LL |     const bar: /* Type */ = 0;
-   |     ~~~~~    ++++++++++++
+LL -     let mut bar = 0;
+LL +     const bar: /* Type */ = 0;
+   |
 
 error[E0435]: attempt to use a non-constant value in a constant
   --> $DIR/x86_64_parse_error.rs:13:46
@@ -31,8 +32,9 @@ LL |         asm!("{a}", in("eax") foo, a = const bar);
    |
 help: consider using `const` instead of `let`
    |
-LL |     const bar: /* Type */ = 0;
-   |     ~~~~~    ++++++++++++
+LL -     let mut bar = 0;
+LL +     const bar: /* Type */ = 0;
+   |
 
 error[E0435]: attempt to use a non-constant value in a constant
   --> $DIR/x86_64_parse_error.rs:15:42
@@ -42,8 +44,9 @@ LL |         asm!("{1}", in("eax") foo, const bar);
    |
 help: consider using `const` instead of `let`
    |
-LL |     const bar: /* Type */ = 0;
-   |     ~~~~~    ++++++++++++
+LL -     let mut bar = 0;
+LL +     const bar: /* Type */ = 0;
+   |
 
 error: aborting due to 5 previous errors