@@ -3,6 +3,7 @@ use super::{
33 mir:: { Body , Mutability } ,
44 with, DefId , Error , Symbol ,
55} ;
6+ use crate :: crate_def:: CrateDef ;
67use crate :: mir:: alloc:: AllocId ;
78use crate :: { Filename , Opaque } ;
89use std:: fmt:: { self , Debug , Display , Formatter } ;
@@ -295,32 +296,41 @@ pub enum Movability {
295296 Movable ,
296297}
297298
298- #[ derive( Clone , Copy , PartialEq , Eq , Debug ) ]
299- pub struct ForeignDef ( pub DefId ) ;
299+ crate_def ! {
300+ /// Hold information about a ForeignItem in a crate.
301+ pub ForeignDef ;
302+ }
300303
301- #[ derive( Clone , Copy , PartialEq , Eq , Debug ) ]
302- pub struct FnDef ( pub DefId ) ;
304+ crate_def ! {
305+ /// Hold information about a function definition in a crate.
306+ pub FnDef ;
307+ }
303308
304309impl FnDef {
305310 pub fn body ( & self ) -> Body {
306311 with ( |ctx| ctx. mir_body ( self . 0 ) )
307312 }
308313}
309314
310- #[ derive( Clone , Copy , PartialEq , Eq , Debug ) ]
311- pub struct ClosureDef ( pub DefId ) ;
315+ crate_def ! {
316+ pub ClosureDef ;
317+ }
312318
313- #[ derive( Clone , Copy , PartialEq , Eq , Debug ) ]
314- pub struct CoroutineDef ( pub DefId ) ;
319+ crate_def ! {
320+ pub CoroutineDef ;
321+ }
315322
316- #[ derive( Clone , Copy , PartialEq , Eq , Debug ) ]
317- pub struct ParamDef ( pub DefId ) ;
323+ crate_def ! {
324+ pub ParamDef ;
325+ }
318326
319- #[ derive( Clone , Copy , PartialEq , Eq , Debug ) ]
320- pub struct BrNamedDef ( pub DefId ) ;
327+ crate_def ! {
328+ pub BrNamedDef ;
329+ }
321330
322- #[ derive( Clone , Copy , PartialEq , Eq , Debug ) ]
323- pub struct AdtDef ( pub DefId ) ;
331+ crate_def ! {
332+ pub AdtDef ;
333+ }
324334
325335#[ derive( Clone , Copy , PartialEq , Eq , Debug , Hash ) ]
326336pub enum AdtKind {
@@ -363,26 +373,33 @@ impl AdtKind {
363373 }
364374}
365375
366- #[ derive( Clone , Copy , PartialEq , Eq , Debug ) ]
367- pub struct AliasDef ( pub DefId ) ;
376+ crate_def ! {
377+ pub AliasDef ;
378+ }
368379
369- #[ derive( Clone , Copy , PartialEq , Eq , Debug ) ]
370- pub struct TraitDef ( pub DefId ) ;
380+ crate_def ! {
381+ pub TraitDef ;
382+ }
371383
372- #[ derive( Clone , Copy , PartialEq , Eq , Debug ) ]
373- pub struct GenericDef ( pub DefId ) ;
384+ crate_def ! {
385+ pub GenericDef ;
386+ }
374387
375- #[ derive( Clone , Copy , PartialEq , Eq , Debug ) ]
376- pub struct ConstDef ( pub DefId ) ;
388+ crate_def ! {
389+ pub ConstDef ;
390+ }
377391
378- #[ derive( Clone , PartialEq , Eq , Debug ) ]
379- pub struct ImplDef ( pub DefId ) ;
392+ crate_def ! {
393+ pub ImplDef ;
394+ }
380395
381- #[ derive( Clone , PartialEq , Eq , Debug ) ]
382- pub struct RegionDef ( pub DefId ) ;
396+ crate_def ! {
397+ pub RegionDef ;
398+ }
383399
384- #[ derive( Clone , PartialEq , Eq , Debug ) ]
385- pub struct CoroutineWitnessDef ( pub DefId ) ;
400+ crate_def ! {
401+ pub CoroutineWitnessDef ;
402+ }
386403
387404/// A list of generic arguments.
388405#[ derive( Clone , Debug , Eq , PartialEq ) ]
0 commit comments