@@ -3,6 +3,7 @@ use super::{
3
3
mir:: { Body , Mutability } ,
4
4
with, DefId , Error , Symbol ,
5
5
} ;
6
+ use crate :: crate_def:: CrateDef ;
6
7
use crate :: mir:: alloc:: AllocId ;
7
8
use crate :: { Filename , Opaque } ;
8
9
use std:: fmt:: { self , Debug , Display , Formatter } ;
@@ -295,32 +296,41 @@ pub enum Movability {
295
296
Movable ,
296
297
}
297
298
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
+ }
300
303
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
+ }
303
308
304
309
impl FnDef {
305
310
pub fn body ( & self ) -> Body {
306
311
with ( |ctx| ctx. mir_body ( self . 0 ) )
307
312
}
308
313
}
309
314
310
- #[ derive( Clone , Copy , PartialEq , Eq , Debug ) ]
311
- pub struct ClosureDef ( pub DefId ) ;
315
+ crate_def ! {
316
+ pub ClosureDef ;
317
+ }
312
318
313
- #[ derive( Clone , Copy , PartialEq , Eq , Debug ) ]
314
- pub struct CoroutineDef ( pub DefId ) ;
319
+ crate_def ! {
320
+ pub CoroutineDef ;
321
+ }
315
322
316
- #[ derive( Clone , Copy , PartialEq , Eq , Debug ) ]
317
- pub struct ParamDef ( pub DefId ) ;
323
+ crate_def ! {
324
+ pub ParamDef ;
325
+ }
318
326
319
- #[ derive( Clone , Copy , PartialEq , Eq , Debug ) ]
320
- pub struct BrNamedDef ( pub DefId ) ;
327
+ crate_def ! {
328
+ pub BrNamedDef ;
329
+ }
321
330
322
- #[ derive( Clone , Copy , PartialEq , Eq , Debug ) ]
323
- pub struct AdtDef ( pub DefId ) ;
331
+ crate_def ! {
332
+ pub AdtDef ;
333
+ }
324
334
325
335
#[ derive( Clone , Copy , PartialEq , Eq , Debug , Hash ) ]
326
336
pub enum AdtKind {
@@ -363,26 +373,33 @@ impl AdtKind {
363
373
}
364
374
}
365
375
366
- #[ derive( Clone , Copy , PartialEq , Eq , Debug ) ]
367
- pub struct AliasDef ( pub DefId ) ;
376
+ crate_def ! {
377
+ pub AliasDef ;
378
+ }
368
379
369
- #[ derive( Clone , Copy , PartialEq , Eq , Debug ) ]
370
- pub struct TraitDef ( pub DefId ) ;
380
+ crate_def ! {
381
+ pub TraitDef ;
382
+ }
371
383
372
- #[ derive( Clone , Copy , PartialEq , Eq , Debug ) ]
373
- pub struct GenericDef ( pub DefId ) ;
384
+ crate_def ! {
385
+ pub GenericDef ;
386
+ }
374
387
375
- #[ derive( Clone , Copy , PartialEq , Eq , Debug ) ]
376
- pub struct ConstDef ( pub DefId ) ;
388
+ crate_def ! {
389
+ pub ConstDef ;
390
+ }
377
391
378
- #[ derive( Clone , PartialEq , Eq , Debug ) ]
379
- pub struct ImplDef ( pub DefId ) ;
392
+ crate_def ! {
393
+ pub ImplDef ;
394
+ }
380
395
381
- #[ derive( Clone , PartialEq , Eq , Debug ) ]
382
- pub struct RegionDef ( pub DefId ) ;
396
+ crate_def ! {
397
+ pub RegionDef ;
398
+ }
383
399
384
- #[ derive( Clone , PartialEq , Eq , Debug ) ]
385
- pub struct CoroutineWitnessDef ( pub DefId ) ;
400
+ crate_def ! {
401
+ pub CoroutineWitnessDef ;
402
+ }
386
403
387
404
/// A list of generic arguments.
388
405
#[ derive( Clone , Debug , Eq , PartialEq ) ]
0 commit comments