Skip to content

Commit b652325

Browse files
authored
Unrolled build for rust-lang#140193
Rollup merge of rust-lang#140193 - folkertdev:fix-issue-140082, r=jdonszelmann fix ICE in `#[naked]` attribute validation fixes rust-lang#140082 The comment here https://github.com/rust-lang/rust/pull/139615/files#r2040684192 is relevant, a better way to print the full path would be nice. If there's an issue I should `FIXME` this with let me know. r? `@jdonszelmann` cc `@nnethercote` rust-lang#139615
2 parents e3e432d + a4630f7 commit b652325

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

compiler/rustc_passes/src/check_attr.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -680,10 +680,14 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
680680
}
681681

682682
if !other_attr.has_any_name(ALLOW_LIST) {
683+
let path = other_attr.path();
684+
let path: Vec<_> = path.iter().map(|s| s.as_str()).collect();
685+
let other_attr_name = path.join("::");
686+
683687
self.dcx().emit_err(errors::NakedFunctionIncompatibleAttribute {
684688
span: other_attr.span(),
685689
naked_span: attr.span(),
686-
attr: other_attr.name().unwrap(),
690+
attr: other_attr_name,
687691
});
688692

689693
return;

compiler/rustc_passes/src/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,7 @@ pub(crate) struct NakedFunctionIncompatibleAttribute {
12491249
pub span: Span,
12501250
#[label(passes_naked_attribute)]
12511251
pub naked_span: Span,
1252-
pub attr: Symbol,
1252+
pub attr: String,
12531253
}
12541254

12551255
#[derive(Diagnostic)]

tests/ui/asm/naked-invalid-attr.rs

+9
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,12 @@ fn main() {
5151
#[unsafe(naked)] //~ ERROR should be applied to a function definition
5252
|| {};
5353
}
54+
55+
// Check that the path of an attribute without a name is printed correctly (issue #140082)
56+
#[::a]
57+
//~^ ERROR attribute incompatible with `#[unsafe(naked)]`
58+
//~| ERROR failed to resolve: use of unresolved module or unlinked crate `a`
59+
#[unsafe(naked)]
60+
extern "C" fn issue_140082() {
61+
naked_asm!("")
62+
}

tests/ui/asm/naked-invalid-attr.stderr

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `a`
2+
--> $DIR/naked-invalid-attr.rs:56:5
3+
|
4+
LL | #[::a]
5+
| ^ use of unresolved module or unlinked crate `a`
6+
17
error: attribute should be applied to a function definition
28
--> $DIR/naked-invalid-attr.rs:13:1
39
|
@@ -27,6 +33,15 @@ LL | #[unsafe(naked)]
2733
LL | || {};
2834
| ----- not a function definition
2935

36+
error[E0736]: attribute incompatible with `#[unsafe(naked)]`
37+
--> $DIR/naked-invalid-attr.rs:56:1
38+
|
39+
LL | #[::a]
40+
| ^^^^^^ the `{{root}}::a` attribute is incompatible with `#[unsafe(naked)]`
41+
...
42+
LL | #[unsafe(naked)]
43+
| ---------------- function marked with `#[unsafe(naked)]` here
44+
3045
error: attribute should be applied to a function definition
3146
--> $DIR/naked-invalid-attr.rs:22:5
3247
|
@@ -49,5 +64,7 @@ error: attribute should be applied to a function definition
4964
LL | #![unsafe(naked)]
5065
| ^^^^^^^^^^^^^^^^^ cannot be applied to crates
5166

52-
error: aborting due to 6 previous errors
67+
error: aborting due to 8 previous errors
5368

69+
Some errors have detailed explanations: E0433, E0736.
70+
For more information about an error, try `rustc --explain E0433`.

0 commit comments

Comments
 (0)