Skip to content

Commit 8103bd6

Browse files
authored
Rollup merge of rust-lang#92611 - Amanieu:asm-reference, r=m-ou-se
Add links to the reference and rust by example for asm! docs and lints These were previously removed in rust-lang#91728 due to broken links. cc `@ehuss` since this updates the rust-by-example submodule
2 parents e0e70c0 + 5eb6fff commit 8103bd6

File tree

6 files changed

+57
-1
lines changed

6 files changed

+57
-1
lines changed

compiler/rustc_lint/src/builtin.rs

+3
Original file line numberDiff line numberDiff line change
@@ -3158,7 +3158,10 @@ declare_lint! {
31583158
/// of this, GNU assembler [local labels] *must* be used instead of labels
31593159
/// with a name. Using named labels might cause assembler or linker errors.
31603160
///
3161+
/// See the explanation in [Rust By Example] for more details.
3162+
///
31613163
/// [local labels]: https://sourceware.org/binutils/docs/as/Symbol-Names.html#Local-Labels
3164+
/// [Rust By Example]: https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels
31623165
pub NAMED_ASM_LABELS,
31633166
Deny,
31643167
"named labels in inline assembly",

compiler/rustc_lint/src/context.rs

+1
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,7 @@ pub trait LintContext: Sized {
762762
}
763763
BuiltinLintDiagnostics::NamedAsmLabel(help) => {
764764
db.help(&help);
765+
db.note("see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information");
765766
}
766767
}
767768
// Rewrap `db`, and pass control to the user.

compiler/rustc_lint_defs/src/builtin.rs

+4
Original file line numberDiff line numberDiff line change
@@ -2456,6 +2456,10 @@ declare_lint! {
24562456
/// register size, to alert you of possibly using the incorrect width. To
24572457
/// fix this, add the suggested modifier to the template, or cast the
24582458
/// value to the correct size.
2459+
///
2460+
/// See [register template modifiers] in the reference for more details.
2461+
///
2462+
/// [register template modifiers]: https://doc.rust-lang.org/nightly/reference/inline-assembly.html#template-modifiers
24592463
pub ASM_SUB_REGISTER,
24602464
Warn,
24612465
"using only a subset of a register for inline asm inputs",

library/core/src/lib.rs

+12
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,25 @@ pub mod arch {
374374
pub use crate::core_arch::arch::*;
375375

376376
/// Inline assembly.
377+
///
378+
/// Refer to [rust by example] for a usage guide and the [reference] for
379+
/// detailed information about the syntax and available options.
380+
///
381+
/// [rust by example]: https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html
382+
/// [reference]: https://doc.rust-lang.org/nightly/reference/inline-assembly.html
377383
#[stable(feature = "asm", since = "1.59.0")]
378384
#[rustc_builtin_macro]
379385
pub macro asm("assembly template", $(operands,)* $(options($(option),*))?) {
380386
/* compiler built-in */
381387
}
382388
383389
/// Module-level inline assembly.
390+
///
391+
/// Refer to [rust by example] for a usage guide and the [reference] for
392+
/// detailed information about the syntax and available options.
393+
///
394+
/// [rust by example]: https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html
395+
/// [reference]: https://doc.rust-lang.org/nightly/reference/inline-assembly.html
384396
#[stable(feature = "global_asm", since = "1.59.0")]
385397
#[rustc_builtin_macro]
386398
pub macro global_asm("assembly template", $(operands,)* $(options($(option),*))?) {

src/test/ui/asm/named-asm-labels.stderr

+36
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ LL | asm!("bar: nop");
66
|
77
= note: `#[deny(named_asm_labels)]` on by default
88
= help: only local labels of the form `<number>:` should be used in inline asm
9+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
910

1011
error: avoid using named labels in inline assembly
1112
--> $DIR/named-asm-labels.rs:27:15
@@ -14,6 +15,7 @@ LL | asm!("abcd:");
1415
| ^^^^
1516
|
1617
= help: only local labels of the form `<number>:` should be used in inline asm
18+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
1719

1820
error: avoid using named labels in inline assembly
1921
--> $DIR/named-asm-labels.rs:30:15
@@ -22,6 +24,7 @@ LL | asm!("foo: bar1: nop");
2224
| ^^^ ^^^^
2325
|
2426
= help: only local labels of the form `<number>:` should be used in inline asm
27+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
2528

2629
error: avoid using named labels in inline assembly
2730
--> $DIR/named-asm-labels.rs:34:15
@@ -30,6 +33,7 @@ LL | asm!("foo1: nop", "nop");
3033
| ^^^^
3134
|
3235
= help: only local labels of the form `<number>:` should be used in inline asm
36+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
3337

3438
error: avoid using named labels in inline assembly
3539
--> $DIR/named-asm-labels.rs:35:15
@@ -38,6 +42,7 @@ LL | asm!("foo2: foo3: nop", "nop");
3842
| ^^^^ ^^^^
3943
|
4044
= help: only local labels of the form `<number>:` should be used in inline asm
45+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
4146

4247
error: avoid using named labels in inline assembly
4348
--> $DIR/named-asm-labels.rs:37:22
@@ -46,6 +51,7 @@ LL | asm!("nop", "foo4: nop");
4651
| ^^^^
4752
|
4853
= help: only local labels of the form `<number>:` should be used in inline asm
54+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
4955

5056
error: avoid using named labels in inline assembly
5157
--> $DIR/named-asm-labels.rs:38:15
@@ -54,6 +60,7 @@ LL | asm!("foo5: nop", "foo6: nop");
5460
| ^^^^
5561
|
5662
= help: only local labels of the form `<number>:` should be used in inline asm
63+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
5764

5865
error: avoid using named labels in inline assembly
5966
--> $DIR/named-asm-labels.rs:38:28
@@ -62,6 +69,7 @@ LL | asm!("foo5: nop", "foo6: nop");
6269
| ^^^^
6370
|
6471
= help: only local labels of the form `<number>:` should be used in inline asm
72+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
6573

6674
error: avoid using named labels in inline assembly
6775
--> $DIR/named-asm-labels.rs:43:15
@@ -70,6 +78,7 @@ LL | asm!("foo7: nop; foo8: nop");
7078
| ^^^^ ^^^^
7179
|
7280
= help: only local labels of the form `<number>:` should be used in inline asm
81+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
7382

7483
error: avoid using named labels in inline assembly
7584
--> $DIR/named-asm-labels.rs:45:15
@@ -78,6 +87,7 @@ LL | asm!("foo9: nop; nop");
7887
| ^^^^
7988
|
8089
= help: only local labels of the form `<number>:` should be used in inline asm
90+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
8191

8292
error: avoid using named labels in inline assembly
8393
--> $DIR/named-asm-labels.rs:46:20
@@ -86,6 +96,7 @@ LL | asm!("nop; foo10: nop");
8696
| ^^^^^
8797
|
8898
= help: only local labels of the form `<number>:` should be used in inline asm
99+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
89100

90101
error: avoid using named labels in inline assembly
91102
--> $DIR/named-asm-labels.rs:49:15
@@ -94,6 +105,7 @@ LL | asm!("bar2: nop\n bar3: nop");
94105
| ^^^^ ^^^^
95106
|
96107
= help: only local labels of the form `<number>:` should be used in inline asm
108+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
97109

98110
error: avoid using named labels in inline assembly
99111
--> $DIR/named-asm-labels.rs:51:15
@@ -102,6 +114,7 @@ LL | asm!("bar4: nop\n nop");
102114
| ^^^^
103115
|
104116
= help: only local labels of the form `<number>:` should be used in inline asm
117+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
105118

106119
error: avoid using named labels in inline assembly
107120
--> $DIR/named-asm-labels.rs:52:21
@@ -110,6 +123,7 @@ LL | asm!("nop\n bar5: nop");
110123
| ^^^^
111124
|
112125
= help: only local labels of the form `<number>:` should be used in inline asm
126+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
113127

114128
error: avoid using named labels in inline assembly
115129
--> $DIR/named-asm-labels.rs:53:21
@@ -118,6 +132,7 @@ LL | asm!("nop\n bar6: bar7: nop");
118132
| ^^^^ ^^^^
119133
|
120134
= help: only local labels of the form `<number>:` should be used in inline asm
135+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
121136

122137
error: avoid using named labels in inline assembly
123138
--> $DIR/named-asm-labels.rs:59:13
@@ -128,6 +143,7 @@ LL | blah3: nop
128143
| ^^^^^
129144
|
130145
= help: only local labels of the form `<number>:` should be used in inline asm
146+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
131147

132148
error: avoid using named labels in inline assembly
133149
--> $DIR/named-asm-labels.rs:68:19
@@ -136,6 +152,7 @@ LL | nop ; blah4: nop
136152
| ^^^^^
137153
|
138154
= help: only local labels of the form `<number>:` should be used in inline asm
155+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
139156

140157
error: avoid using named labels in inline assembly
141158
--> $DIR/named-asm-labels.rs:82:15
@@ -144,6 +161,7 @@ LL | asm!("blah1: 2bar: nop");
144161
| ^^^^^
145162
|
146163
= help: only local labels of the form `<number>:` should be used in inline asm
164+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
147165

148166
error: avoid using named labels in inline assembly
149167
--> $DIR/named-asm-labels.rs:85:15
@@ -152,6 +170,7 @@ LL | asm!("def: def: nop");
152170
| ^^^
153171
|
154172
= help: only local labels of the form `<number>:` should be used in inline asm
173+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
155174

156175
error: avoid using named labels in inline assembly
157176
--> $DIR/named-asm-labels.rs:86:15
@@ -160,6 +179,7 @@ LL | asm!("def: nop\ndef: nop");
160179
| ^^^
161180
|
162181
= help: only local labels of the form `<number>:` should be used in inline asm
182+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
163183

164184
error: avoid using named labels in inline assembly
165185
--> $DIR/named-asm-labels.rs:87:15
@@ -168,6 +188,7 @@ LL | asm!("def: nop; def: nop");
168188
| ^^^
169189
|
170190
= help: only local labels of the form `<number>:` should be used in inline asm
191+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
171192

172193
error: avoid using named labels in inline assembly
173194
--> $DIR/named-asm-labels.rs:95:15
@@ -176,6 +197,7 @@ LL | asm!("fooo\u{003A} nop");
176197
| ^^^^^^^^^^^^^^^^
177198
|
178199
= help: only local labels of the form `<number>:` should be used in inline asm
200+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
179201

180202
error: avoid using named labels in inline assembly
181203
--> $DIR/named-asm-labels.rs:96:15
@@ -184,6 +206,7 @@ LL | asm!("foooo\x3A nop");
184206
| ^^^^^^^^^^^^^
185207
|
186208
= help: only local labels of the form `<number>:` should be used in inline asm
209+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
187210

188211
error: avoid using named labels in inline assembly
189212
--> $DIR/named-asm-labels.rs:99:15
@@ -192,6 +215,7 @@ LL | asm!("fooooo:\u{000A} nop");
192215
| ^^^^^^
193216
|
194217
= help: only local labels of the form `<number>:` should be used in inline asm
218+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
195219

196220
error: avoid using named labels in inline assembly
197221
--> $DIR/named-asm-labels.rs:100:15
@@ -200,6 +224,7 @@ LL | asm!("foooooo:\x0A nop");
200224
| ^^^^^^^
201225
|
202226
= help: only local labels of the form `<number>:` should be used in inline asm
227+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
203228

204229
error: avoid using named labels in inline assembly
205230
--> $DIR/named-asm-labels.rs:104:14
@@ -208,6 +233,7 @@ LL | asm!("\x41\x42\x43\x3A\x20\x6E\x6F\x70");
208233
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
209234
|
210235
= help: only local labels of the form `<number>:` should be used in inline asm
236+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
211237

212238
error: avoid using named labels in inline assembly
213239
--> $DIR/named-asm-labels.rs:112:13
@@ -216,6 +242,7 @@ LL | ab: nop // ab: does foo
216242
| ^^
217243
|
218244
= help: only local labels of the form `<number>:` should be used in inline asm
245+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
219246

220247
error: avoid using named labels in inline assembly
221248
--> $DIR/named-asm-labels.rs:124:14
@@ -224,6 +251,7 @@ LL | asm!(include_str!("named-asm-labels.s"));
224251
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
225252
|
226253
= help: only local labels of the form `<number>:` should be used in inline asm
254+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
227255

228256
warning: avoid using named labels in inline assembly
229257
--> $DIR/named-asm-labels.rs:134:19
@@ -237,6 +265,7 @@ note: the lint level is defined here
237265
LL | #[warn(named_asm_labels)]
238266
| ^^^^^^^^^^^^^^^^
239267
= help: only local labels of the form `<number>:` should be used in inline asm
268+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
240269

241270
error: avoid using named labels in inline assembly
242271
--> $DIR/named-asm-labels.rs:143:20
@@ -245,6 +274,7 @@ LL | unsafe { asm!(".Lfoo: mov rax, {}; ret;", "nop", const 1, options(noret
245274
| ^^^^^
246275
|
247276
= help: only local labels of the form `<number>:` should be used in inline asm
277+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
248278

249279
error: avoid using named labels in inline assembly
250280
--> $DIR/named-asm-labels.rs:149:20
@@ -253,6 +283,7 @@ LL | unsafe { asm!(".Lbar: mov rax, {}; ret;", "nop", const 1, options(noret
253283
| ^^^^^
254284
|
255285
= help: only local labels of the form `<number>:` should be used in inline asm
286+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
256287

257288
error: avoid using named labels in inline assembly
258289
--> $DIR/named-asm-labels.rs:157:20
@@ -261,6 +292,7 @@ LL | unsafe { asm!(".Laaa: nop; ret;", options(noreturn)) }
261292
| ^^^^^
262293
|
263294
= help: only local labels of the form `<number>:` should be used in inline asm
295+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
264296

265297
error: avoid using named labels in inline assembly
266298
--> $DIR/named-asm-labels.rs:167:24
@@ -269,6 +301,7 @@ LL | unsafe { asm!(".Lbbb: nop; ret;", options(noreturn)) }
269301
| ^^^^^
270302
|
271303
= help: only local labels of the form `<number>:` should be used in inline asm
304+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
272305

273306
error: avoid using named labels in inline assembly
274307
--> $DIR/named-asm-labels.rs:176:15
@@ -277,6 +310,7 @@ LL | asm!("closure1: nop");
277310
| ^^^^^^^^
278311
|
279312
= help: only local labels of the form `<number>:` should be used in inline asm
313+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
280314

281315
error: avoid using named labels in inline assembly
282316
--> $DIR/named-asm-labels.rs:180:15
@@ -285,6 +319,7 @@ LL | asm!("closure2: nop");
285319
| ^^^^^^^^
286320
|
287321
= help: only local labels of the form `<number>:` should be used in inline asm
322+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
288323

289324
error: avoid using named labels in inline assembly
290325
--> $DIR/named-asm-labels.rs:190:19
@@ -293,6 +328,7 @@ LL | asm!("closure3: nop");
293328
| ^^^^^^^^
294329
|
295330
= help: only local labels of the form `<number>:` should be used in inline asm
331+
= note: see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
296332

297333
error: aborting due to 35 previous errors; 1 warning emitted
298334

0 commit comments

Comments
 (0)