@@ -218,6 +218,8 @@ pub enum InlineAsmReg {
218218 Mips ( MipsInlineAsmReg ) ,
219219 SpirV ( SpirVInlineAsmReg ) ,
220220 Wasm ( WasmInlineAsmReg ) ,
221+ // Fake register used by rustdoc to support foreign asm!
222+ RustdocDummy ,
221223}
222224
223225impl InlineAsmReg {
@@ -229,6 +231,7 @@ impl InlineAsmReg {
229231 Self :: RiscV ( r) => r. name ( ) ,
230232 Self :: Hexagon ( r) => r. name ( ) ,
231233 Self :: Mips ( r) => r. name ( ) ,
234+ Self :: RustdocDummy => "<reg>" ,
232235 }
233236 }
234237
@@ -240,6 +243,7 @@ impl InlineAsmReg {
240243 Self :: RiscV ( r) => InlineAsmRegClass :: RiscV ( r. reg_class ( ) ) ,
241244 Self :: Hexagon ( r) => InlineAsmRegClass :: Hexagon ( r. reg_class ( ) ) ,
242245 Self :: Mips ( r) => InlineAsmRegClass :: Mips ( r. reg_class ( ) ) ,
246+ Self :: RustdocDummy => InlineAsmRegClass :: RustdocDummy ,
243247 }
244248 }
245249
@@ -298,6 +302,7 @@ impl InlineAsmReg {
298302 Self :: RiscV ( r) => r. emit ( out, arch, modifier) ,
299303 Self :: Hexagon ( r) => r. emit ( out, arch, modifier) ,
300304 Self :: Mips ( r) => r. emit ( out, arch, modifier) ,
305+ Self :: RustdocDummy => unreachable ! ( ) ,
301306 }
302307 }
303308
@@ -309,6 +314,10 @@ impl InlineAsmReg {
309314 Self :: RiscV ( _) => cb ( self ) ,
310315 Self :: Hexagon ( r) => r. overlapping_regs ( |r| cb ( Self :: Hexagon ( r) ) ) ,
311316 Self :: Mips ( _) => cb ( self ) ,
317+ Self :: RustdocDummy => {
318+ // This effectively disables the register conflict check since
319+ // we don't report RustdocDummy as conflicting with itself.
320+ }
312321 }
313322 }
314323}
@@ -324,6 +333,8 @@ pub enum InlineAsmRegClass {
324333 Mips ( MipsInlineAsmRegClass ) ,
325334 SpirV ( SpirVInlineAsmRegClass ) ,
326335 Wasm ( WasmInlineAsmRegClass ) ,
336+ // Fake register class used by rustdoc to support foreign asm!
337+ RustdocDummy ,
327338}
328339
329340impl InlineAsmRegClass {
@@ -338,6 +349,7 @@ impl InlineAsmRegClass {
338349 Self :: Mips ( r) => r. name ( ) ,
339350 Self :: SpirV ( r) => r. name ( ) ,
340351 Self :: Wasm ( r) => r. name ( ) ,
352+ Self :: RustdocDummy => rustc_span:: symbol:: sym:: reg,
341353 }
342354 }
343355
@@ -355,6 +367,7 @@ impl InlineAsmRegClass {
355367 Self :: Mips ( r) => r. suggest_class ( arch, ty) . map ( InlineAsmRegClass :: Mips ) ,
356368 Self :: SpirV ( r) => r. suggest_class ( arch, ty) . map ( InlineAsmRegClass :: SpirV ) ,
357369 Self :: Wasm ( r) => r. suggest_class ( arch, ty) . map ( InlineAsmRegClass :: Wasm ) ,
370+ Self :: RustdocDummy => None ,
358371 }
359372 }
360373
@@ -379,6 +392,7 @@ impl InlineAsmRegClass {
379392 Self :: Mips ( r) => r. suggest_modifier ( arch, ty) ,
380393 Self :: SpirV ( r) => r. suggest_modifier ( arch, ty) ,
381394 Self :: Wasm ( r) => r. suggest_modifier ( arch, ty) ,
395+ Self :: RustdocDummy => None ,
382396 }
383397 }
384398
@@ -399,6 +413,7 @@ impl InlineAsmRegClass {
399413 Self :: Mips ( r) => r. default_modifier ( arch) ,
400414 Self :: SpirV ( r) => r. default_modifier ( arch) ,
401415 Self :: Wasm ( r) => r. default_modifier ( arch) ,
416+ Self :: RustdocDummy => None ,
402417 }
403418 }
404419
@@ -418,6 +433,9 @@ impl InlineAsmRegClass {
418433 Self :: Mips ( r) => r. supported_types ( arch) ,
419434 Self :: SpirV ( r) => r. supported_types ( arch) ,
420435 Self :: Wasm ( r) => r. supported_types ( arch) ,
436+ // Rustdoc never gets around to type-checking the asm!, this is just
437+ // used to indicate the lack of any dependency on target features.
438+ Self :: RustdocDummy => & [ ] ,
421439 }
422440 }
423441
@@ -454,6 +472,8 @@ impl InlineAsmRegClass {
454472 Self :: Mips ( r) => r. valid_modifiers ( arch) ,
455473 Self :: SpirV ( r) => r. valid_modifiers ( arch) ,
456474 Self :: Wasm ( r) => r. valid_modifiers ( arch) ,
475+ // The modifier check is skipped in the code for rustdoc
476+ Self :: RustdocDummy => & [ ] ,
457477 }
458478 }
459479}
0 commit comments