Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify errors and warnings about the transition to the new asm! #72825

Merged
merged 1 commit into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libcore/macros/mod.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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