Improve documentation and fix the fixme comment
This commit is contained in:
parent
591b41abb8
commit
b6e977243f
@ -256,6 +256,9 @@ fn instance_mangled_name(&self, instance: InstanceDef) -> Symbol {
|
||||
tables.tcx.symbol_name(instance).name.to_string()
|
||||
}
|
||||
|
||||
/// Retrieve the instance name for diagnostic messages.
|
||||
///
|
||||
/// This will return the specialized name, e.g., `Vec<char>::new`.
|
||||
fn instance_name(&self, def: InstanceDef, trimmed: bool) -> Symbol {
|
||||
let tables = self.0.borrow_mut();
|
||||
let instance = tables.instances[def];
|
||||
|
@ -1,4 +1,5 @@
|
||||
//! Module that define a common trait for things that represent a crate definition.
|
||||
//! Module that define a common trait for things that represent a crate definition,
|
||||
//! such as, a function, a trait, an enum, and any other definitions.
|
||||
|
||||
use crate::ty::Span;
|
||||
use crate::{with, Crate, Symbol};
|
||||
@ -7,21 +8,23 @@
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct DefId(pub(crate) usize);
|
||||
|
||||
/// A trait for retrieving information about a crate definition.
|
||||
/// A trait for retrieving information about a particular definition.
|
||||
///
|
||||
/// Implementors must provide the implementation of `def_id` which will be used to retrieve
|
||||
/// information about its definition.
|
||||
/// information about a crate's definition.
|
||||
pub trait CrateDef {
|
||||
/// Retrieve the unique identifier for the given definition.
|
||||
/// Retrieve the unique identifier for the current definition.
|
||||
fn def_id(&self) -> DefId;
|
||||
|
||||
/// Return the fully qualified name of the given definition.
|
||||
/// Return the fully qualified name of the current definition.
|
||||
fn name(&self) -> Symbol {
|
||||
let def_id = self.def_id();
|
||||
with(|cx| cx.def_name(def_id, false))
|
||||
}
|
||||
|
||||
/// Return a trimmed name of the given definition.
|
||||
/// Return a trimmed name of this definition.
|
||||
///
|
||||
/// This can be used to print more user friendly diagnostic messages.
|
||||
///
|
||||
/// If a symbol name can only be imported from one place for a type, and as
|
||||
/// long as it was not glob-imported anywhere in the current crate, we trim its
|
||||
|
@ -48,10 +48,16 @@ pub fn ty(&self) -> Ty {
|
||||
with(|context| context.instance_ty(self.def))
|
||||
}
|
||||
|
||||
/// Retrieve the instance's mangled name used for calling the given instance.
|
||||
///
|
||||
/// This will also look up the correct name of instances from upstream crates.
|
||||
pub fn mangled_name(&self) -> Symbol {
|
||||
with(|context| context.instance_mangled_name(self.def))
|
||||
}
|
||||
|
||||
/// Retrieve the instance name for diagnostic messages.
|
||||
///
|
||||
/// This will return the specialized name, e.g., `std::vec::Vec<u8>::new`.
|
||||
pub fn name(&self) -> Symbol {
|
||||
with(|context| context.instance_name(self.def, false))
|
||||
}
|
||||
@ -118,8 +124,8 @@ impl TryFrom<CrateItem> for Instance {
|
||||
|
||||
fn try_from(item: CrateItem) -> Result<Self, Self::Error> {
|
||||
with(|context| {
|
||||
/// FIXME(celinval):
|
||||
/// - Check `has_body`.
|
||||
// FIXME(celinval):
|
||||
// - Return `Err` if instance does not have a body.
|
||||
if !context.requires_monomorphization(item.0) {
|
||||
Ok(context.mono_instance(item))
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user