Skip to content

Commit

Permalink
tests/ui/asm: Remove uses of rustc_attrs, lang_items, and decl_macro …
Browse files Browse the repository at this point in the history
…features by using minicore
  • Loading branch information
taiki-e committed Dec 16, 2024
1 parent eedc229 commit 86e0eab
Show file tree
Hide file tree
Showing 45 changed files with 537 additions and 618 deletions.
10 changes: 9 additions & 1 deletion tests/auxiliary/minicore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//! <https://github.com/rust-lang/rust/blob/c0b5cc9003f6464c11ae1c0662c6a7e06f6f5cab/compiler/rustc_codegen_cranelift/example/mini_core.rs>.
// ignore-tidy-linelength

#![feature(no_core, lang_items, rustc_attrs, decl_macro)]
#![feature(no_core, lang_items, rustc_attrs, decl_macro, naked_functions)]
#![allow(unused, improper_ctypes_definitions, internal_features)]
#![feature(asm_experimental_arch)]
#![no_std]
Expand Down Expand Up @@ -80,3 +80,11 @@ pub struct UnsafeCell<T: ?Sized> {
pub macro asm("assembly template", $(operands,)* $(options($(option),*))?) {
/* compiler built-in */
}
#[rustc_builtin_macro]
pub macro naked_asm("assembly template", $(operands,)* $(options($(option),*))?) {
/* compiler built-in */
}
#[rustc_builtin_macro]
pub macro global_asm("assembly template", $(operands,)* $(options($(option),*))?) {
/* compiler built-in */
}
14 changes: 1 addition & 13 deletions tests/ui/asm/aarch64/aarch64-sve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,10 @@
//@ needs-asm-support

#![crate_type = "rlib"]
#![feature(no_core, rustc_attrs, lang_items)]
#![no_core]

// AArch64 test corresponding to arm64ec-sve.rs.

#[lang = "sized"]
trait Sized {}
#[lang = "copy"]
trait Copy {}

impl Copy for f64 {}

#[rustc_builtin_macro]
macro_rules! asm {
() => {};
}
use std::arch::asm;

fn f(x: f64) {
unsafe {
Expand Down
16 changes: 4 additions & 12 deletions tests/ui/asm/aarch64/arm64ec-sve.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
//@ add-core-stubs
//@ compile-flags: --target arm64ec-pc-windows-msvc
//@ needs-asm-support
//@ needs-llvm-components: aarch64

#![crate_type = "rlib"]
#![feature(no_core, rustc_attrs, lang_items)]
#![feature(no_core)]
#![no_core]

// SVE cannot be used for Arm64EC
// https://github.com/rust-lang/rust/pull/131332#issuecomment-2401189142

#[lang = "sized"]
trait Sized {}
#[lang = "copy"]
trait Copy {}

impl Copy for f64 {}

#[rustc_builtin_macro]
macro_rules! asm {
() => {};
}
extern crate minicore;
use minicore::*;

fn f(x: f64) {
unsafe {
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/asm/aarch64/arm64ec-sve.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error: cannot use register `p0`: x13, x14, x23, x24, x28, v16-v31, p*, ffr cannot be used for Arm64EC
--> $DIR/arm64ec-sve.rs:26:18
--> $DIR/arm64ec-sve.rs:18:18
|
LL | asm!("", out("p0") _);
| ^^^^^^^^^^^

error: cannot use register `ffr`: x13, x14, x23, x24, x28, v16-v31, p*, ffr cannot be used for Arm64EC
--> $DIR/arm64ec-sve.rs:28:18
--> $DIR/arm64ec-sve.rs:20:18
|
LL | asm!("", out("ffr") _);
| ^^^^^^^^^^^^
Expand Down
19 changes: 4 additions & 15 deletions tests/ui/asm/arm-low-dreg.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,17 @@
//@ add-core-stubs
//@ build-pass
//@ compile-flags: --target=armv7-unknown-linux-gnueabihf
//@ needs-llvm-components: arm
#![feature(no_core, rustc_attrs, decl_macro, lang_items)]
#![feature(no_core)]
#![crate_type = "rlib"]
#![no_std]
#![no_core]

// We accidentally classified "d0"..="d15" as dregs, even though they are in dreg_low16,
// and thus didn't compile them on platforms with only 16 dregs.
// Highlighted in https://github.com/rust-lang/rust/issues/126797

#[lang = "sized"]
trait Sized {}

#[lang = "copy"]
trait Copy {}

impl Copy for f64 {}

#[rustc_builtin_macro]
pub macro asm("assembly template", $(operands,)* $(options($(option),*))?) {
/* compiler built-in */
}

extern crate minicore;
use minicore::*;

fn f(x: f64) -> f64 {
let out: f64;
Expand Down
52 changes: 26 additions & 26 deletions tests/ui/asm/bad-template.aarch64.stderr
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:30:15
--> $DIR/bad-template.rs:19:15
|
LL | asm!("{}");
| ^^ from here
|
= note: no arguments were given

error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:32:15
--> $DIR/bad-template.rs:21:15
|
LL | asm!("{1}", in(reg) foo);
| ^^^ from here
|
= note: there is 1 argument

error: argument never used
--> $DIR/bad-template.rs:32:21
--> $DIR/bad-template.rs:21:21
|
LL | asm!("{1}", in(reg) foo);
| ^^^^^^^^^^^ argument never used
|
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {0} */"`

error: there is no argument named `a`
--> $DIR/bad-template.rs:35:16
--> $DIR/bad-template.rs:24:16
|
LL | asm!("{a}");
| ^

error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:37:15
--> $DIR/bad-template.rs:26:15
|
LL | asm!("{}", a = in(reg) foo);
| ^^ --------------- named argument
Expand All @@ -38,37 +38,37 @@ LL | asm!("{}", a = in(reg) foo);
|
= note: no positional arguments were given
note: named arguments cannot be referenced by position
--> $DIR/bad-template.rs:37:20
--> $DIR/bad-template.rs:26:20
|
LL | asm!("{}", a = in(reg) foo);
| ^^^^^^^^^^^^^^^

error: named argument never used
--> $DIR/bad-template.rs:37:20
--> $DIR/bad-template.rs:26:20
|
LL | asm!("{}", a = in(reg) foo);
| ^^^^^^^^^^^^^^^ named argument never used
|
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`

error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:40:15
--> $DIR/bad-template.rs:29:15
|
LL | asm!("{1}", a = in(reg) foo);
| ^^^ from here
|
= note: no positional arguments were given

error: named argument never used
--> $DIR/bad-template.rs:40:21
--> $DIR/bad-template.rs:29:21
|
LL | asm!("{1}", a = in(reg) foo);
| ^^^^^^^^^^^^^^^ named argument never used
|
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`

error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:47:15
--> $DIR/bad-template.rs:36:15
|
LL | asm!("{}", in("x0") foo);
| ^^ ------------ explicit register argument
Expand All @@ -77,24 +77,24 @@ LL | asm!("{}", in("x0") foo);
|
= note: no positional arguments were given
note: explicit register arguments cannot be used in the asm template
--> $DIR/bad-template.rs:47:20
--> $DIR/bad-template.rs:36:20
|
LL | asm!("{}", in("x0") foo);
| ^^^^^^^^^^^^
help: use the register name directly in the assembly code
--> $DIR/bad-template.rs:47:20
--> $DIR/bad-template.rs:36:20
|
LL | asm!("{}", in("x0") foo);
| ^^^^^^^^^^^^

error: asm template modifier must be a single character
--> $DIR/bad-template.rs:49:17
--> $DIR/bad-template.rs:38:17
|
LL | asm!("{:foo}", in(reg) foo);
| ^^^

error: multiple unused asm arguments
--> $DIR/bad-template.rs:52:18
--> $DIR/bad-template.rs:41:18
|
LL | asm!("", in(reg) 0, in(reg) 1);
| ^^^^^^^^^ ^^^^^^^^^ argument never used
Expand All @@ -104,37 +104,37 @@ LL | asm!("", in(reg) 0, in(reg) 1);
= help: if these arguments are intentionally unused, consider using them in an asm comment: `"/* {0} {1} */"`

error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:58:14
--> $DIR/bad-template.rs:47:14
|
LL | global_asm!("{}");
| ^^ from here
|
= note: no arguments were given

error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:60:14
--> $DIR/bad-template.rs:49:14
|
LL | global_asm!("{1}", const FOO);
| ^^^ from here
|
= note: there is 1 argument

error: argument never used
--> $DIR/bad-template.rs:60:20
--> $DIR/bad-template.rs:49:20
|
LL | global_asm!("{1}", const FOO);
| ^^^^^^^^^ argument never used
|
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {0} */"`

error: there is no argument named `a`
--> $DIR/bad-template.rs:63:15
--> $DIR/bad-template.rs:52:15
|
LL | global_asm!("{a}");
| ^

error: invalid reference to argument at index 0
--> $DIR/bad-template.rs:65:14
--> $DIR/bad-template.rs:54:14
|
LL | global_asm!("{}", a = const FOO);
| ^^ ------------- named argument
Expand All @@ -143,43 +143,43 @@ LL | global_asm!("{}", a = const FOO);
|
= note: no positional arguments were given
note: named arguments cannot be referenced by position
--> $DIR/bad-template.rs:65:19
--> $DIR/bad-template.rs:54:19
|
LL | global_asm!("{}", a = const FOO);
| ^^^^^^^^^^^^^

error: named argument never used
--> $DIR/bad-template.rs:65:19
--> $DIR/bad-template.rs:54:19
|
LL | global_asm!("{}", a = const FOO);
| ^^^^^^^^^^^^^ named argument never used
|
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`

error: invalid reference to argument at index 1
--> $DIR/bad-template.rs:68:14
--> $DIR/bad-template.rs:57:14
|
LL | global_asm!("{1}", a = const FOO);
| ^^^ from here
|
= note: no positional arguments were given

error: named argument never used
--> $DIR/bad-template.rs:68:20
--> $DIR/bad-template.rs:57:20
|
LL | global_asm!("{1}", a = const FOO);
| ^^^^^^^^^^^^^ named argument never used
|
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`

error: asm template modifier must be a single character
--> $DIR/bad-template.rs:71:16
--> $DIR/bad-template.rs:60:16
|
LL | global_asm!("{:foo}", const FOO);
| ^^^

error: multiple unused asm arguments
--> $DIR/bad-template.rs:73:17
--> $DIR/bad-template.rs:62:17
|
LL | global_asm!("", const FOO, const FOO);
| ^^^^^^^^^ ^^^^^^^^^ argument never used
Expand All @@ -189,7 +189,7 @@ LL | global_asm!("", const FOO, const FOO);
= help: if these arguments are intentionally unused, consider using them in an asm comment: `"/* {0} {1} */"`

warning: formatting may not be suitable for sub-register argument
--> $DIR/bad-template.rs:49:15
--> $DIR/bad-template.rs:38:15
|
LL | asm!("{:foo}", in(reg) foo);
| ^^^^^^ --- for this argument
Expand Down
19 changes: 4 additions & 15 deletions tests/ui/asm/bad-template.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ add-core-stubs
//@ revisions: x86_64 aarch64

//@ [x86_64] compile-flags: --target x86_64-unknown-linux-gnu
Expand All @@ -6,23 +7,11 @@
//@ [x86_64] needs-llvm-components: x86
//@ [aarch64] needs-llvm-components: aarch64

#![feature(no_core, lang_items, rustc_attrs)]
#![feature(no_core)]
#![no_core]

#[rustc_builtin_macro]
macro_rules! asm {
() => {};
}
#[rustc_builtin_macro]
macro_rules! global_asm {
() => {};
}

#[lang = "sized"]
trait Sized {}

#[lang = "copy"]
trait Copy {}
extern crate minicore;
use minicore::*;

fn main() {
let mut foo = 0;
Expand Down
Loading

0 comments on commit 86e0eab

Please sign in to comment.