Skip to content

Commit

Permalink
Clarify errors and warnings about the transition to the new asm!
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanieu committed May 31, 2020
1 parent 4b1f86a commit d490205
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/libcore/macros/mod.rs
Expand Up @@ -1315,7 +1315,7 @@ pub(crate) mod builtin {
#[unstable(
feature = "llvm_asm",
issue = "70173",
reason = "LLVM-style inline assembly will never be stabilized, prefer using asm! instead"
reason = "prefer using the new asm! syntax instead"
)]
#[rustc_builtin_macro]
#[macro_export]
Expand Down
5 changes: 4 additions & 1 deletion src/librustc_builtin_macros/asm.rs
Expand Up @@ -33,7 +33,10 @@ fn parse_args<'a>(

// Detect use of the legacy llvm_asm! syntax (which used to be called asm!)
if p.look_ahead(1, |t| *t == token::Colon || *t == token::ModSep) {
let mut err = ecx.struct_span_err(sp, "legacy asm! syntax is no longer supported");
let mut err =
ecx.struct_span_err(sp, "the legacy LLVM-style asm! syntax is no longer supported");
err.note("consider migrating to the new asm! syntax specified in RFC 2873");
err.note("alternatively, switch to llvm_asm! to keep your code working as it is");

// Find the span of the "asm!" so that we can offer an automatic suggestion
let asm_span = sp.from_inner(InnerSpan::new(0, 4));
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/asm/rustfix-asm.fixed
Expand Up @@ -8,9 +8,9 @@ fn main() {
let x = 1;
let y: i32;
llvm_asm!("" :: "r" (x));
//~^ ERROR legacy asm! syntax is no longer supported
//~^ ERROR the legacy LLVM-style asm! syntax is no longer supported
llvm_asm!("" : "=r" (y));
//~^ ERROR legacy asm! syntax is no longer supported
//~^ ERROR the legacy LLVM-style asm! syntax is no longer supported
let _ = y;
}
}
4 changes: 2 additions & 2 deletions src/test/ui/asm/rustfix-asm.rs
Expand Up @@ -8,9 +8,9 @@ fn main() {
let x = 1;
let y: i32;
asm!("" :: "r" (x));
//~^ ERROR legacy asm! syntax is no longer supported
//~^ ERROR the legacy LLVM-style asm! syntax is no longer supported
asm!("" : "=r" (y));
//~^ ERROR legacy asm! syntax is no longer supported
//~^ ERROR the legacy LLVM-style asm! syntax is no longer supported
let _ = y;
}
}
10 changes: 8 additions & 2 deletions src/test/ui/asm/rustfix-asm.stderr
@@ -1,18 +1,24 @@
error: legacy asm! syntax is no longer supported
error: the legacy LLVM-style asm! syntax is no longer supported
--> $DIR/rustfix-asm.rs:10:9
|
LL | asm!("" :: "r" (x));
| ----^^^^^^^^^^^^^^^^
| |
| help: replace with: `llvm_asm!`
|
= note: consider migrating to the new asm! syntax specified in RFC 2873
= note: alternatively, switch to llvm_asm! to keep your code working as it is

error: legacy asm! syntax is no longer supported
error: the legacy LLVM-style asm! syntax is no longer supported
--> $DIR/rustfix-asm.rs:12:9
|
LL | asm!("" : "=r" (y));
| ----^^^^^^^^^^^^^^^^
| |
| help: replace with: `llvm_asm!`
|
= note: consider migrating to the new asm! syntax specified in RFC 2873
= note: alternatively, switch to llvm_asm! to keep your code working as it is

error: aborting due to 2 previous errors

2 changes: 1 addition & 1 deletion src/test/ui/feature-gates/feature-gate-asm.rs
Expand Up @@ -5,6 +5,6 @@ fn main() {
asm!("");
//~^ ERROR inline assembly is not stable enough
llvm_asm!("");
//~^ ERROR LLVM-style inline assembly will never be stabilized
//~^ ERROR prefer using the new asm! syntax instead
}
}
2 changes: 1 addition & 1 deletion src/test/ui/feature-gates/feature-gate-asm.stderr
Expand Up @@ -7,7 +7,7 @@ LL | asm!("");
= note: see issue #72016 <https://github.com/rust-lang/rust/issues/72016> for more information
= help: add `#![feature(asm)]` to the crate attributes to enable

error[E0658]: use of unstable library feature 'llvm_asm': LLVM-style inline assembly will never be stabilized, prefer using asm! instead
error[E0658]: use of unstable library feature 'llvm_asm': prefer using the new asm! syntax instead
--> $DIR/feature-gate-asm.rs:7:9
|
LL | llvm_asm!("");
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/feature-gates/feature-gate-asm2.rs
Expand Up @@ -5,6 +5,6 @@ fn main() {
println!("{:?}", asm!(""));
//~^ ERROR inline assembly is not stable enough
println!("{:?}", llvm_asm!(""));
//~^ ERROR LLVM-style inline assembly will never be stabilized
//~^ ERROR prefer using the new asm! syntax instead
}
}
2 changes: 1 addition & 1 deletion src/test/ui/feature-gates/feature-gate-asm2.stderr
Expand Up @@ -7,7 +7,7 @@ LL | println!("{:?}", asm!(""));
= note: see issue #72016 <https://github.com/rust-lang/rust/issues/72016> for more information
= help: add `#![feature(asm)]` to the crate attributes to enable

error[E0658]: use of unstable library feature 'llvm_asm': LLVM-style inline assembly will never be stabilized, prefer using asm! instead
error[E0658]: use of unstable library feature 'llvm_asm': prefer using the new asm! syntax instead
--> $DIR/feature-gate-asm2.rs:7:26
|
LL | println!("{:?}", llvm_asm!(""));
Expand Down

0 comments on commit d490205

Please sign in to comment.