1
- //! Module that define a common trait for things that represent a crate definition.
1
+ //! Module that define a common trait for things that represent a crate definition,
2
+ //! such as, a function, a trait, an enum, and any other definitions.
2
3
3
4
use crate :: ty:: Span ;
4
5
use crate :: { with, Crate , Symbol } ;
@@ -7,21 +8,23 @@ use crate::{with, Crate, Symbol};
7
8
#[ derive( Clone , Copy , PartialEq , Eq , Hash ) ]
8
9
pub struct DefId ( pub ( crate ) usize ) ;
9
10
10
- /// A trait for retrieving information about a crate definition.
11
+ /// A trait for retrieving information about a particular definition.
11
12
///
12
13
/// Implementors must provide the implementation of `def_id` which will be used to retrieve
13
- /// information about its definition.
14
+ /// information about a crate's definition.
14
15
pub trait CrateDef {
15
- /// Retrieve the unique identifier for the given definition.
16
+ /// Retrieve the unique identifier for the current definition.
16
17
fn def_id ( & self ) -> DefId ;
17
18
18
- /// Return the fully qualified name of the given definition.
19
+ /// Return the fully qualified name of the current definition.
19
20
fn name ( & self ) -> Symbol {
20
21
let def_id = self . def_id ( ) ;
21
22
with ( |cx| cx. def_name ( def_id, false ) )
22
23
}
23
24
24
- /// Return a trimmed name of the given definition.
25
+ /// Return a trimmed name of this definition.
26
+ ///
27
+ /// This can be used to print more user friendly diagnostic messages.
25
28
///
26
29
/// If a symbol name can only be imported from one place for a type, and as
27
30
/// long as it was not glob-imported anywhere in the current crate, we trim its
0 commit comments