Make trait_map an Option.
This commit is contained in:
parent
0839cd5e9a
commit
93b25bd293
2 changed files with 6 additions and 15 deletions
|
@ -1959,7 +1959,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
|
|||
if ns == ValueNS {
|
||||
let item_name = path.last().unwrap().ident;
|
||||
let traits = self.traits_in_scope(item_name, ns);
|
||||
self.r.trait_map.insert(id, traits);
|
||||
self.r.trait_map.as_mut().unwrap().insert(id, traits);
|
||||
}
|
||||
|
||||
if PrimTy::from_name(path[0].ident.name).is_some() {
|
||||
|
@ -2435,12 +2435,12 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
|
|||
// the field name so that we can do some nice error reporting
|
||||
// later on in typeck.
|
||||
let traits = self.traits_in_scope(ident, ValueNS);
|
||||
self.r.trait_map.insert(expr.id, traits);
|
||||
self.r.trait_map.as_mut().unwrap().insert(expr.id, traits);
|
||||
}
|
||||
ExprKind::MethodCall(ref segment, ..) => {
|
||||
debug!("(recording candidate traits for expr) recording traits for {}", expr.id);
|
||||
let traits = self.traits_in_scope(segment.ident, ValueNS);
|
||||
self.r.trait_map.insert(expr.id, traits);
|
||||
self.r.trait_map.as_mut().unwrap().insert(expr.id, traits);
|
||||
}
|
||||
_ => {
|
||||
// Nothing to do.
|
||||
|
|
|
@ -909,9 +909,7 @@ pub struct Resolver<'a> {
|
|||
/// `CrateNum` resolutions of `extern crate` items.
|
||||
extern_crate_map: FxHashMap<LocalDefId, CrateNum>,
|
||||
export_map: ExportMap<LocalDefId>,
|
||||
trait_map: NodeMap<Vec<TraitCandidate>>,
|
||||
#[cfg(debug_assertions)]
|
||||
took_trait_map: bool,
|
||||
trait_map: Option<NodeMap<Vec<TraitCandidate>>>,
|
||||
|
||||
/// A map from nodes to anonymous modules.
|
||||
/// Anonymous modules are pseudo-modules that are implicitly created around items
|
||||
|
@ -1141,12 +1139,7 @@ impl ResolverAstLowering for Resolver<'_> {
|
|||
}
|
||||
|
||||
fn take_trait_map(&mut self) -> NodeMap<Vec<TraitCandidate>> {
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
debug_assert!(!self.took_trait_map);
|
||||
self.took_trait_map = true;
|
||||
}
|
||||
std::mem::take(&mut self.trait_map)
|
||||
std::mem::replace(&mut self.trait_map, None).unwrap()
|
||||
}
|
||||
|
||||
fn opt_local_def_id(&self, node: NodeId) -> Option<LocalDefId> {
|
||||
|
@ -1293,9 +1286,7 @@ impl<'a> Resolver<'a> {
|
|||
label_res_map: Default::default(),
|
||||
extern_crate_map: Default::default(),
|
||||
export_map: FxHashMap::default(),
|
||||
trait_map: Default::default(),
|
||||
#[cfg(debug_assertions)]
|
||||
took_trait_map: false,
|
||||
trait_map: Some(NodeMap::default()),
|
||||
underscore_disambiguator: 0,
|
||||
empty_module,
|
||||
module_map,
|
||||
|
|
Loading…
Add table
Reference in a new issue