[Syntax Breaking] Rename DefaultImpl to AutoImpl
DefaultImpl is a highly confusing name for what we now call auto impls, as in `impl Send for ..`. The name auto impl is not formally decided but for sanity anything is better than `DefaultImpl` which refers neither to `default impl` nor to `impl Default`.
This commit is contained in:
parent
5ce3d482e2
commit
06506bb751
60 changed files with 163 additions and 163 deletions
|
|
@ -498,7 +498,7 @@ define_dep_nodes!( <'tcx>
|
|||
[] SuperPredicatesOfItem(DefId),
|
||||
[] TraitDefOfItem(DefId),
|
||||
[] AdtDefOfItem(DefId),
|
||||
[] IsDefaultImpl(DefId),
|
||||
[] IsAutoImpl(DefId),
|
||||
[] ImplTraitRef(DefId),
|
||||
[] ImplPolarity(DefId),
|
||||
[] ClosureKind(DefId),
|
||||
|
|
|
|||
|
|
@ -503,7 +503,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
|
|||
// visit_enum_def() takes care of visiting the Item's NodeId
|
||||
visitor.visit_enum_def(enum_definition, type_parameters, item.id, item.span)
|
||||
}
|
||||
ItemDefaultImpl(_, ref trait_ref) => {
|
||||
ItemAutoImpl(_, ref trait_ref) => {
|
||||
visitor.visit_id(item.id);
|
||||
visitor.visit_trait_ref(trait_ref)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ pub struct LoweringContext<'a> {
|
|||
exported_macros: Vec<hir::MacroDef>,
|
||||
|
||||
trait_impls: BTreeMap<DefId, Vec<NodeId>>,
|
||||
trait_default_impl: BTreeMap<DefId, NodeId>,
|
||||
trait_auto_impl: BTreeMap<DefId, NodeId>,
|
||||
|
||||
is_generator: bool,
|
||||
|
||||
|
|
@ -146,7 +146,7 @@ pub fn lower_crate(sess: &Session,
|
|||
impl_items: BTreeMap::new(),
|
||||
bodies: BTreeMap::new(),
|
||||
trait_impls: BTreeMap::new(),
|
||||
trait_default_impl: BTreeMap::new(),
|
||||
trait_auto_impl: BTreeMap::new(),
|
||||
exported_macros: Vec::new(),
|
||||
catch_scopes: Vec::new(),
|
||||
loop_scopes: Vec::new(),
|
||||
|
|
@ -284,7 +284,7 @@ impl<'a> LoweringContext<'a> {
|
|||
bodies: self.bodies,
|
||||
body_ids,
|
||||
trait_impls: self.trait_impls,
|
||||
trait_default_impl: self.trait_default_impl,
|
||||
trait_auto_impl: self.trait_auto_impl,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1479,14 +1479,14 @@ impl<'a> LoweringContext<'a> {
|
|||
let vdata = self.lower_variant_data(vdata);
|
||||
hir::ItemUnion(vdata, self.lower_generics(generics))
|
||||
}
|
||||
ItemKind::DefaultImpl(unsafety, ref trait_ref) => {
|
||||
ItemKind::AutoImpl(unsafety, ref trait_ref) => {
|
||||
let trait_ref = self.lower_trait_ref(trait_ref);
|
||||
|
||||
if let Def::Trait(def_id) = trait_ref.path.def {
|
||||
self.trait_default_impl.insert(def_id, id);
|
||||
self.trait_auto_impl.insert(def_id, id);
|
||||
}
|
||||
|
||||
hir::ItemDefaultImpl(self.lower_unsafety(unsafety),
|
||||
hir::ItemAutoImpl(self.lower_unsafety(unsafety),
|
||||
trait_ref)
|
||||
}
|
||||
ItemKind::Impl(unsafety,
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
|
|||
impl_items: _,
|
||||
bodies: _,
|
||||
trait_impls: _,
|
||||
trait_default_impl: _,
|
||||
trait_auto_impl: _,
|
||||
body_ids: _,
|
||||
} = *krate;
|
||||
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
|
|||
// Pick the def data. This need not be unique, but the more
|
||||
// information we encapsulate into
|
||||
let def_data = match i.node {
|
||||
ItemKind::DefaultImpl(..) | ItemKind::Impl(..) =>
|
||||
ItemKind::AutoImpl(..) | ItemKind::Impl(..) =>
|
||||
DefPathData::Impl,
|
||||
ItemKind::Enum(..) | ItemKind::Struct(..) | ItemKind::Union(..) | ItemKind::Trait(..) |
|
||||
ItemKind::ExternCrate(..) | ItemKind::ForeignMod(..) | ItemKind::Ty(..) =>
|
||||
|
|
|
|||
|
|
@ -474,16 +474,16 @@ impl<'hir> Map<'hir> {
|
|||
self.forest.krate.trait_impls.get(&trait_did).map_or(&[], |xs| &xs[..])
|
||||
}
|
||||
|
||||
pub fn trait_default_impl(&self, trait_did: DefId) -> Option<NodeId> {
|
||||
pub fn trait_auto_impl(&self, trait_did: DefId) -> Option<NodeId> {
|
||||
self.dep_graph.read(DepNode::new_no_params(DepKind::AllLocalTraitImpls));
|
||||
|
||||
// NB: intentionally bypass `self.forest.krate()` so that we
|
||||
// do not trigger a read of the whole krate here
|
||||
self.forest.krate.trait_default_impl.get(&trait_did).cloned()
|
||||
self.forest.krate.trait_auto_impl.get(&trait_did).cloned()
|
||||
}
|
||||
|
||||
pub fn trait_is_auto(&self, trait_did: DefId) -> bool {
|
||||
self.trait_default_impl(trait_did).is_some()
|
||||
self.trait_auto_impl(trait_did).is_some()
|
||||
}
|
||||
|
||||
/// Get the attributes on the krate. This is preferable to
|
||||
|
|
@ -1140,7 +1140,7 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
|
|||
ItemUnion(..) => "union",
|
||||
ItemTrait(..) => "trait",
|
||||
ItemImpl(..) => "impl",
|
||||
ItemDefaultImpl(..) => "default impl",
|
||||
ItemAutoImpl(..) => "default impl",
|
||||
};
|
||||
format!("{} {}{}", item_str, path_str(), id_str)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -499,7 +499,7 @@ pub struct Crate {
|
|||
pub impl_items: BTreeMap<ImplItemId, ImplItem>,
|
||||
pub bodies: BTreeMap<BodyId, Body>,
|
||||
pub trait_impls: BTreeMap<DefId, Vec<NodeId>>,
|
||||
pub trait_default_impl: BTreeMap<DefId, NodeId>,
|
||||
pub trait_auto_impl: BTreeMap<DefId, NodeId>,
|
||||
|
||||
/// A list of the body ids written out in the order in which they
|
||||
/// appear in the crate. If you're going to process all the bodies
|
||||
|
|
@ -1813,10 +1813,10 @@ pub enum Item_ {
|
|||
/// Represents a Trait Declaration
|
||||
ItemTrait(Unsafety, Generics, TyParamBounds, HirVec<TraitItemRef>),
|
||||
|
||||
// Default trait implementations
|
||||
/// Auto trait implementations
|
||||
///
|
||||
/// `impl Trait for .. {}`
|
||||
ItemDefaultImpl(Unsafety, TraitRef),
|
||||
ItemAutoImpl(Unsafety, TraitRef),
|
||||
/// An implementation, eg `impl<A> Trait for Foo { .. }`
|
||||
ItemImpl(Unsafety,
|
||||
ImplPolarity,
|
||||
|
|
@ -1844,7 +1844,7 @@ impl Item_ {
|
|||
ItemUnion(..) => "union",
|
||||
ItemTrait(..) => "trait",
|
||||
ItemImpl(..) |
|
||||
ItemDefaultImpl(..) => "item",
|
||||
ItemAutoImpl(..) => "item",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -660,7 +660,7 @@ impl<'a> State<'a> {
|
|||
self.head(&visibility_qualified(&item.vis, "union"))?;
|
||||
self.print_struct(struct_def, generics, item.name, item.span, true)?;
|
||||
}
|
||||
hir::ItemDefaultImpl(unsafety, ref trait_ref) => {
|
||||
hir::ItemAutoImpl(unsafety, ref trait_ref) => {
|
||||
self.head("")?;
|
||||
self.print_visibility(&item.vis)?;
|
||||
self.print_unsafety(unsafety)?;
|
||||
|
|
|
|||
|
|
@ -898,7 +898,7 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for hir::Item {
|
|||
hir::ItemForeignMod(..) |
|
||||
hir::ItemGlobalAsm(..) |
|
||||
hir::ItemMod(..) |
|
||||
hir::ItemDefaultImpl(..) |
|
||||
hir::ItemAutoImpl(..) |
|
||||
hir::ItemTrait(..) |
|
||||
hir::ItemImpl(..) |
|
||||
hir::ItemTy(..) |
|
||||
|
|
@ -945,7 +945,7 @@ impl_stable_hash_for!(enum hir::Item_ {
|
|||
ItemStruct(variant_data, generics),
|
||||
ItemUnion(variant_data, generics),
|
||||
ItemTrait(unsafety, generics, bounds, item_refs),
|
||||
ItemDefaultImpl(unsafety, trait_ref),
|
||||
ItemAutoImpl(unsafety, trait_ref),
|
||||
ItemImpl(unsafety, impl_polarity, impl_defaultness, generics, trait_ref, ty, impl_item_refs)
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -731,13 +731,13 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::TraitDef {
|
|||
def_id: _,
|
||||
unsafety,
|
||||
paren_sugar,
|
||||
has_default_impl,
|
||||
has_auto_impl,
|
||||
def_path_hash,
|
||||
} = *self;
|
||||
|
||||
unsafety.hash_stable(hcx, hasher);
|
||||
paren_sugar.hash_stable(hcx, hasher);
|
||||
has_default_impl.hash_stable(hcx, hasher);
|
||||
has_auto_impl.hash_stable(hcx, hasher);
|
||||
def_path_hash.hash_stable(hcx, hasher);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -562,7 +562,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> {
|
|||
hir::ItemStruct(..) |
|
||||
hir::ItemUnion(..) |
|
||||
hir::ItemTrait(..) |
|
||||
hir::ItemDefaultImpl(..) |
|
||||
hir::ItemAutoImpl(..) |
|
||||
hir::ItemImpl(..) => self.tcx.sess.codemap().def_span(item.span),
|
||||
_ => item.span,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
|||
hir::ItemMod(..) | hir::ItemForeignMod(..) |
|
||||
hir::ItemImpl(..) | hir::ItemTrait(..) |
|
||||
hir::ItemStruct(..) | hir::ItemEnum(..) |
|
||||
hir::ItemUnion(..) | hir::ItemDefaultImpl(..) |
|
||||
hir::ItemUnion(..) | hir::ItemAutoImpl(..) |
|
||||
hir::ItemGlobalAsm(..) => {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -313,7 +313,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
|||
hir::ItemExternCrate(_) |
|
||||
hir::ItemUse(..) |
|
||||
hir::ItemMod(..) |
|
||||
hir::ItemDefaultImpl(..) |
|
||||
hir::ItemAutoImpl(..) |
|
||||
hir::ItemForeignMod(..) |
|
||||
hir::ItemGlobalAsm(..) => {
|
||||
// These sorts of items have no lifetime parameters at all.
|
||||
|
|
|
|||
|
|
@ -288,11 +288,11 @@ pub enum Vtable<'tcx, N> {
|
|||
/// Vtable identifying a particular impl.
|
||||
VtableImpl(VtableImplData<'tcx, N>),
|
||||
|
||||
/// Vtable for default trait implementations
|
||||
/// Vtable for auto trait implementations
|
||||
/// This carries the information and nested obligations with regards
|
||||
/// to a default implementation for a trait `Trait`. The nested obligations
|
||||
/// to an auto implementation for a trait `Trait`. The nested obligations
|
||||
/// ensure the trait implementation holds for all the constituent types.
|
||||
VtableDefaultImpl(VtableDefaultImplData<N>),
|
||||
VtableAutoImpl(VtableAutoImplData<N>),
|
||||
|
||||
/// Successful resolution to an obligation provided by the caller
|
||||
/// for some type parameter. The `Vec<N>` represents the
|
||||
|
|
@ -354,7 +354,7 @@ pub struct VtableClosureData<'tcx, N> {
|
|||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct VtableDefaultImplData<N> {
|
||||
pub struct VtableAutoImplData<N> {
|
||||
pub trait_def_id: DefId,
|
||||
pub nested: Vec<N>
|
||||
}
|
||||
|
|
@ -758,7 +758,7 @@ impl<'tcx, N> Vtable<'tcx, N> {
|
|||
VtableImpl(i) => i.nested,
|
||||
VtableParam(n) => n,
|
||||
VtableBuiltin(i) => i.nested,
|
||||
VtableDefaultImpl(d) => d.nested,
|
||||
VtableAutoImpl(d) => d.nested,
|
||||
VtableClosure(c) => c.nested,
|
||||
VtableGenerator(c) => c.nested,
|
||||
VtableObject(d) => d.nested,
|
||||
|
|
@ -771,7 +771,7 @@ impl<'tcx, N> Vtable<'tcx, N> {
|
|||
&mut VtableImpl(ref mut i) => &mut i.nested,
|
||||
&mut VtableParam(ref mut n) => n,
|
||||
&mut VtableBuiltin(ref mut i) => &mut i.nested,
|
||||
&mut VtableDefaultImpl(ref mut d) => &mut d.nested,
|
||||
&mut VtableAutoImpl(ref mut d) => &mut d.nested,
|
||||
&mut VtableGenerator(ref mut c) => &mut c.nested,
|
||||
&mut VtableClosure(ref mut c) => &mut c.nested,
|
||||
&mut VtableObject(ref mut d) => &mut d.nested,
|
||||
|
|
@ -795,7 +795,7 @@ impl<'tcx, N> Vtable<'tcx, N> {
|
|||
vtable_base: o.vtable_base,
|
||||
nested: o.nested.into_iter().map(f).collect(),
|
||||
}),
|
||||
VtableDefaultImpl(d) => VtableDefaultImpl(VtableDefaultImplData {
|
||||
VtableAutoImpl(d) => VtableAutoImpl(VtableAutoImplData {
|
||||
trait_def_id: d.trait_def_id,
|
||||
nested: d.nested.into_iter().map(f).collect(),
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -1116,7 +1116,7 @@ fn assemble_candidates_from_impls<'cx, 'gcx, 'tcx>(
|
|||
// projection. And the projection where clause is handled
|
||||
// in `assemble_candidates_from_param_env`.
|
||||
}
|
||||
super::VtableDefaultImpl(..) |
|
||||
super::VtableAutoImpl(..) |
|
||||
super::VtableBuiltin(..) => {
|
||||
// These traits have no associated types.
|
||||
span_bug!(
|
||||
|
|
@ -1182,7 +1182,7 @@ fn confirm_select_candidate<'cx, 'gcx, 'tcx>(
|
|||
confirm_fn_pointer_candidate(selcx, obligation, data),
|
||||
super::VtableObject(_) =>
|
||||
confirm_object_candidate(selcx, obligation, obligation_trait_ref),
|
||||
super::VtableDefaultImpl(..) |
|
||||
super::VtableAutoImpl(..) |
|
||||
super::VtableParam(..) |
|
||||
super::VtableBuiltin(..) =>
|
||||
// we don't create Select candidates with this kind of resolution
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ use super::TraitNotObjectSafe;
|
|||
use super::Selection;
|
||||
use super::SelectionResult;
|
||||
use super::{VtableBuiltin, VtableImpl, VtableParam, VtableClosure, VtableGenerator,
|
||||
VtableFnPointer, VtableObject, VtableDefaultImpl};
|
||||
VtableFnPointer, VtableObject, VtableAutoImpl};
|
||||
use super::{VtableImplData, VtableObjectData, VtableBuiltinData, VtableGeneratorData,
|
||||
VtableClosureData, VtableDefaultImplData, VtableFnPointerData};
|
||||
VtableClosureData, VtableAutoImplData, VtableFnPointerData};
|
||||
use super::util;
|
||||
|
||||
use dep_graph::{DepNodeIndex, DepKind};
|
||||
|
|
@ -225,7 +225,7 @@ enum SelectionCandidate<'tcx> {
|
|||
BuiltinCandidate { has_nested: bool },
|
||||
ParamCandidate(ty::PolyTraitRef<'tcx>),
|
||||
ImplCandidate(DefId),
|
||||
DefaultImplCandidate(DefId),
|
||||
AutoImplCandidate(DefId),
|
||||
|
||||
/// This is a trait matching with a projected type as `Self`, and
|
||||
/// we found an applicable bound in the trait definition.
|
||||
|
|
@ -260,7 +260,7 @@ impl<'a, 'tcx> ty::Lift<'tcx> for SelectionCandidate<'a> {
|
|||
}
|
||||
}
|
||||
ImplCandidate(def_id) => ImplCandidate(def_id),
|
||||
DefaultImplCandidate(def_id) => DefaultImplCandidate(def_id),
|
||||
AutoImplCandidate(def_id) => AutoImplCandidate(def_id),
|
||||
ProjectionCandidate => ProjectionCandidate,
|
||||
FnPointerCandidate => FnPointerCandidate,
|
||||
ObjectCandidate => ObjectCandidate,
|
||||
|
|
@ -910,7 +910,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
fn coinductive_predicate(&self, predicate: ty::Predicate<'tcx>) -> bool {
|
||||
let result = match predicate {
|
||||
ty::Predicate::Trait(ref data) => {
|
||||
self.tcx().trait_has_default_impl(data.def_id())
|
||||
self.tcx().trait_has_auto_impl(data.def_id())
|
||||
}
|
||||
_ => {
|
||||
false
|
||||
|
|
@ -1368,10 +1368,10 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
|
||||
self.assemble_candidates_from_projected_tys(obligation, &mut candidates);
|
||||
self.assemble_candidates_from_caller_bounds(stack, &mut candidates)?;
|
||||
// Default implementations have lower priority, so we only
|
||||
// Auto implementations have lower priority, so we only
|
||||
// consider triggering a default if there is no other impl that can apply.
|
||||
if candidates.vec.is_empty() {
|
||||
self.assemble_candidates_from_default_impls(obligation, &mut candidates)?;
|
||||
self.assemble_candidates_from_auto_impls(obligation, &mut candidates)?;
|
||||
}
|
||||
debug!("candidate list size: {}", candidates.vec.len());
|
||||
Ok(candidates)
|
||||
|
|
@ -1686,18 +1686,18 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn assemble_candidates_from_default_impls(&mut self,
|
||||
fn assemble_candidates_from_auto_impls(&mut self,
|
||||
obligation: &TraitObligation<'tcx>,
|
||||
candidates: &mut SelectionCandidateSet<'tcx>)
|
||||
-> Result<(), SelectionError<'tcx>>
|
||||
{
|
||||
// OK to skip binder here because the tests we do below do not involve bound regions
|
||||
let self_ty = *obligation.self_ty().skip_binder();
|
||||
debug!("assemble_candidates_from_default_impls(self_ty={:?})", self_ty);
|
||||
debug!("assemble_candidates_from_auto_impls(self_ty={:?})", self_ty);
|
||||
|
||||
let def_id = obligation.predicate.def_id();
|
||||
|
||||
if self.tcx().trait_has_default_impl(def_id) {
|
||||
if self.tcx().trait_has_auto_impl(def_id) {
|
||||
match self_ty.sty {
|
||||
ty::TyDynamic(..) => {
|
||||
// For object types, we don't know what the closed
|
||||
|
|
@ -1728,11 +1728,11 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
// this path.
|
||||
}
|
||||
ty::TyInfer(ty::TyVar(_)) => {
|
||||
// the defaulted impl might apply, we don't know
|
||||
// the auto impl might apply, we don't know
|
||||
candidates.ambiguous = true;
|
||||
}
|
||||
_ => {
|
||||
candidates.vec.push(DefaultImplCandidate(def_id.clone()))
|
||||
candidates.vec.push(AutoImplCandidate(def_id.clone()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1933,7 +1933,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
match other.candidate {
|
||||
ObjectCandidate |
|
||||
ParamCandidate(_) | ProjectionCandidate => match victim.candidate {
|
||||
DefaultImplCandidate(..) => {
|
||||
AutoImplCandidate(..) => {
|
||||
bug!(
|
||||
"default implementations shouldn't be recorded \
|
||||
when there are other valid candidates");
|
||||
|
|
@ -2282,9 +2282,9 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
Ok(VtableParam(obligations))
|
||||
}
|
||||
|
||||
DefaultImplCandidate(trait_def_id) => {
|
||||
let data = self.confirm_default_impl_candidate(obligation, trait_def_id);
|
||||
Ok(VtableDefaultImpl(data))
|
||||
AutoImplCandidate(trait_def_id) => {
|
||||
let data = self.confirm_auto_impl_candidate(obligation, trait_def_id);
|
||||
Ok(VtableAutoImpl(data))
|
||||
}
|
||||
|
||||
ImplCandidate(impl_def_id) => {
|
||||
|
|
@ -2417,29 +2417,29 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
///
|
||||
/// 1. For each constituent type `Y` in `X`, `Y : Foo` holds
|
||||
/// 2. For each where-clause `C` declared on `Foo`, `[Self => X] C` holds.
|
||||
fn confirm_default_impl_candidate(&mut self,
|
||||
fn confirm_auto_impl_candidate(&mut self,
|
||||
obligation: &TraitObligation<'tcx>,
|
||||
trait_def_id: DefId)
|
||||
-> VtableDefaultImplData<PredicateObligation<'tcx>>
|
||||
-> VtableAutoImplData<PredicateObligation<'tcx>>
|
||||
{
|
||||
debug!("confirm_default_impl_candidate({:?}, {:?})",
|
||||
debug!("confirm_auto_impl_candidate({:?}, {:?})",
|
||||
obligation,
|
||||
trait_def_id);
|
||||
|
||||
// binder is moved below
|
||||
let self_ty = self.infcx.shallow_resolve(obligation.predicate.skip_binder().self_ty());
|
||||
let types = self.constituent_types_for_ty(self_ty);
|
||||
self.vtable_default_impl(obligation, trait_def_id, ty::Binder(types))
|
||||
self.vtable_auto_impl(obligation, trait_def_id, ty::Binder(types))
|
||||
}
|
||||
|
||||
/// See `confirm_default_impl_candidate`
|
||||
fn vtable_default_impl(&mut self,
|
||||
/// See `confirm_auto_impl_candidate`
|
||||
fn vtable_auto_impl(&mut self,
|
||||
obligation: &TraitObligation<'tcx>,
|
||||
trait_def_id: DefId,
|
||||
nested: ty::Binder<Vec<Ty<'tcx>>>)
|
||||
-> VtableDefaultImplData<PredicateObligation<'tcx>>
|
||||
-> VtableAutoImplData<PredicateObligation<'tcx>>
|
||||
{
|
||||
debug!("vtable_default_impl: nested={:?}", nested);
|
||||
debug!("vtable_auto_impl: nested={:?}", nested);
|
||||
|
||||
let cause = obligation.derived_cause(BuiltinDerivedObligation);
|
||||
let mut obligations = self.collect_predicates_for_types(
|
||||
|
|
@ -2465,9 +2465,9 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
|
||||
obligations.extend(trait_obligations);
|
||||
|
||||
debug!("vtable_default_impl: obligations={:?}", obligations);
|
||||
debug!("vtable_auto_impl: obligations={:?}", obligations);
|
||||
|
||||
VtableDefaultImplData {
|
||||
VtableAutoImplData {
|
||||
trait_def_id,
|
||||
nested: obligations
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ impl<'tcx, N: fmt::Debug> fmt::Debug for traits::Vtable<'tcx, N> {
|
|||
super::VtableImpl(ref v) =>
|
||||
write!(f, "{:?}", v),
|
||||
|
||||
super::VtableDefaultImpl(ref t) =>
|
||||
super::VtableAutoImpl(ref t) =>
|
||||
write!(f, "{:?}", t),
|
||||
|
||||
super::VtableClosure(ref d) =>
|
||||
|
|
@ -104,9 +104,9 @@ impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableBuiltinData<N> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableDefaultImplData<N> {
|
||||
impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableAutoImplData<N> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "VtableDefaultImplData(trait_def_id={:?}, nested={:?})",
|
||||
write!(f, "VtableAutoImplData(trait_def_id={:?}, nested={:?})",
|
||||
self.trait_def_id,
|
||||
self.nested)
|
||||
}
|
||||
|
|
@ -292,7 +292,7 @@ impl<'a, 'tcx> Lift<'tcx> for traits::Vtable<'a, ()> {
|
|||
})
|
||||
})
|
||||
}
|
||||
traits::VtableDefaultImpl(t) => Some(traits::VtableDefaultImpl(t)),
|
||||
traits::VtableAutoImpl(t) => Some(traits::VtableAutoImpl(t)),
|
||||
traits::VtableGenerator(traits::VtableGeneratorData {
|
||||
closure_def_id,
|
||||
substs,
|
||||
|
|
@ -407,9 +407,9 @@ impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::VtableClosureDa
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::VtableDefaultImplData<N> {
|
||||
impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::VtableAutoImplData<N> {
|
||||
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
|
||||
traits::VtableDefaultImplData {
|
||||
traits::VtableAutoImplData {
|
||||
trait_def_id: self.trait_def_id,
|
||||
nested: self.nested.fold_with(folder),
|
||||
}
|
||||
|
|
@ -463,7 +463,7 @@ impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::Vtable<'tcx, N>
|
|||
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
|
||||
match *self {
|
||||
traits::VtableImpl(ref v) => traits::VtableImpl(v.fold_with(folder)),
|
||||
traits::VtableDefaultImpl(ref t) => traits::VtableDefaultImpl(t.fold_with(folder)),
|
||||
traits::VtableAutoImpl(ref t) => traits::VtableAutoImpl(t.fold_with(folder)),
|
||||
traits::VtableGenerator(ref d) => {
|
||||
traits::VtableGenerator(d.fold_with(folder))
|
||||
}
|
||||
|
|
@ -482,7 +482,7 @@ impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::Vtable<'tcx, N>
|
|||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
||||
match *self {
|
||||
traits::VtableImpl(ref v) => v.visit_with(visitor),
|
||||
traits::VtableDefaultImpl(ref t) => t.visit_with(visitor),
|
||||
traits::VtableAutoImpl(ref t) => t.visit_with(visitor),
|
||||
traits::VtableGenerator(ref d) => d.visit_with(visitor),
|
||||
traits::VtableClosure(ref d) => d.visit_with(visitor),
|
||||
traits::VtableFnPointer(ref d) => d.visit_with(visitor),
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ fn resolve_associated_item<'a, 'tcx>(
|
|||
None
|
||||
}
|
||||
}
|
||||
traits::VtableDefaultImpl(..) | traits::VtableParam(..) => None
|
||||
traits::VtableAutoImpl(..) | traits::VtableParam(..) => None
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
|
||||
// Always use types for non-local impls, where types are always
|
||||
// available, and filename/line-number is mostly uninteresting.
|
||||
let use_types = !self.is_default_impl(impl_def_id) && (!impl_def_id.is_local() || {
|
||||
let use_types = !self.is_auto_impl(impl_def_id) && (!impl_def_id.is_local() || {
|
||||
// Otherwise, use filename/line-number if forced.
|
||||
let force_no_types = FORCE_IMPL_FILENAME_LINE.with(|f| f.get());
|
||||
!force_no_types
|
||||
|
|
|
|||
|
|
@ -113,8 +113,8 @@ define_maps! { <'tcx>
|
|||
/// True if this is a foreign item (i.e., linked via `extern { ... }`).
|
||||
[] fn is_foreign_item: IsForeignItem(DefId) -> bool,
|
||||
|
||||
/// True if this is a default impl (aka impl Foo for ..)
|
||||
[] fn is_default_impl: IsDefaultImpl(DefId) -> bool,
|
||||
/// True if this is an auto impl (aka impl Foo for ..)
|
||||
[] fn is_auto_impl: IsAutoImpl(DefId) -> bool,
|
||||
|
||||
/// Get a map with the variance of every item; use `item_variance`
|
||||
/// instead.
|
||||
|
|
|
|||
|
|
@ -731,7 +731,7 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
|
|||
DepKind::SuperPredicatesOfItem => { force!(super_predicates_of, def_id!()); }
|
||||
DepKind::TraitDefOfItem => { force!(trait_def, def_id!()); }
|
||||
DepKind::AdtDefOfItem => { force!(adt_def, def_id!()); }
|
||||
DepKind::IsDefaultImpl => { force!(is_default_impl, def_id!()); }
|
||||
DepKind::IsAutoImpl => { force!(is_auto_impl, def_id!()); }
|
||||
DepKind::ImplTraitRef => { force!(impl_trait_ref, def_id!()); }
|
||||
DepKind::ImplPolarity => { force!(impl_polarity, def_id!()); }
|
||||
DepKind::ClosureKind => { force!(closure_kind, def_id!()); }
|
||||
|
|
|
|||
|
|
@ -2308,8 +2308,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
self.get_attrs(did).iter().any(|item| item.check_name(attr))
|
||||
}
|
||||
|
||||
pub fn trait_has_default_impl(self, trait_def_id: DefId) -> bool {
|
||||
self.trait_def(trait_def_id).has_default_impl
|
||||
pub fn trait_has_auto_impl(self, trait_def_id: DefId) -> bool {
|
||||
self.trait_def(trait_def_id).has_auto_impl
|
||||
}
|
||||
|
||||
pub fn generator_layout(self, def_id: DefId) -> &'tcx GeneratorLayout<'tcx> {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ pub struct TraitDef {
|
|||
/// be usable with the sugar (or without it).
|
||||
pub paren_sugar: bool,
|
||||
|
||||
pub has_default_impl: bool,
|
||||
pub has_auto_impl: bool,
|
||||
|
||||
/// The ICH of this trait's DefPath, cached here so it doesn't have to be
|
||||
/// recomputed all the time.
|
||||
|
|
@ -51,14 +51,14 @@ impl<'a, 'gcx, 'tcx> TraitDef {
|
|||
pub fn new(def_id: DefId,
|
||||
unsafety: hir::Unsafety,
|
||||
paren_sugar: bool,
|
||||
has_default_impl: bool,
|
||||
has_auto_impl: bool,
|
||||
def_path_hash: DefPathHash)
|
||||
-> TraitDef {
|
||||
TraitDef {
|
||||
def_id,
|
||||
paren_sugar,
|
||||
unsafety,
|
||||
has_default_impl,
|
||||
has_auto_impl,
|
||||
def_path_hash,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue