[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),
|
[] SuperPredicatesOfItem(DefId),
|
||||||
[] TraitDefOfItem(DefId),
|
[] TraitDefOfItem(DefId),
|
||||||
[] AdtDefOfItem(DefId),
|
[] AdtDefOfItem(DefId),
|
||||||
[] IsDefaultImpl(DefId),
|
[] IsAutoImpl(DefId),
|
||||||
[] ImplTraitRef(DefId),
|
[] ImplTraitRef(DefId),
|
||||||
[] ImplPolarity(DefId),
|
[] ImplPolarity(DefId),
|
||||||
[] ClosureKind(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
|
// visit_enum_def() takes care of visiting the Item's NodeId
|
||||||
visitor.visit_enum_def(enum_definition, type_parameters, item.id, item.span)
|
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_id(item.id);
|
||||||
visitor.visit_trait_ref(trait_ref)
|
visitor.visit_trait_ref(trait_ref)
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ pub struct LoweringContext<'a> {
|
||||||
exported_macros: Vec<hir::MacroDef>,
|
exported_macros: Vec<hir::MacroDef>,
|
||||||
|
|
||||||
trait_impls: BTreeMap<DefId, Vec<NodeId>>,
|
trait_impls: BTreeMap<DefId, Vec<NodeId>>,
|
||||||
trait_default_impl: BTreeMap<DefId, NodeId>,
|
trait_auto_impl: BTreeMap<DefId, NodeId>,
|
||||||
|
|
||||||
is_generator: bool,
|
is_generator: bool,
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ pub fn lower_crate(sess: &Session,
|
||||||
impl_items: BTreeMap::new(),
|
impl_items: BTreeMap::new(),
|
||||||
bodies: BTreeMap::new(),
|
bodies: BTreeMap::new(),
|
||||||
trait_impls: BTreeMap::new(),
|
trait_impls: BTreeMap::new(),
|
||||||
trait_default_impl: BTreeMap::new(),
|
trait_auto_impl: BTreeMap::new(),
|
||||||
exported_macros: Vec::new(),
|
exported_macros: Vec::new(),
|
||||||
catch_scopes: Vec::new(),
|
catch_scopes: Vec::new(),
|
||||||
loop_scopes: Vec::new(),
|
loop_scopes: Vec::new(),
|
||||||
|
@ -284,7 +284,7 @@ impl<'a> LoweringContext<'a> {
|
||||||
bodies: self.bodies,
|
bodies: self.bodies,
|
||||||
body_ids,
|
body_ids,
|
||||||
trait_impls: self.trait_impls,
|
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);
|
let vdata = self.lower_variant_data(vdata);
|
||||||
hir::ItemUnion(vdata, self.lower_generics(generics))
|
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);
|
let trait_ref = self.lower_trait_ref(trait_ref);
|
||||||
|
|
||||||
if let Def::Trait(def_id) = trait_ref.path.def {
|
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)
|
trait_ref)
|
||||||
}
|
}
|
||||||
ItemKind::Impl(unsafety,
|
ItemKind::Impl(unsafety,
|
||||||
|
|
|
@ -71,7 +71,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
|
||||||
impl_items: _,
|
impl_items: _,
|
||||||
bodies: _,
|
bodies: _,
|
||||||
trait_impls: _,
|
trait_impls: _,
|
||||||
trait_default_impl: _,
|
trait_auto_impl: _,
|
||||||
body_ids: _,
|
body_ids: _,
|
||||||
} = *krate;
|
} = *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
|
// Pick the def data. This need not be unique, but the more
|
||||||
// information we encapsulate into
|
// information we encapsulate into
|
||||||
let def_data = match i.node {
|
let def_data = match i.node {
|
||||||
ItemKind::DefaultImpl(..) | ItemKind::Impl(..) =>
|
ItemKind::AutoImpl(..) | ItemKind::Impl(..) =>
|
||||||
DefPathData::Impl,
|
DefPathData::Impl,
|
||||||
ItemKind::Enum(..) | ItemKind::Struct(..) | ItemKind::Union(..) | ItemKind::Trait(..) |
|
ItemKind::Enum(..) | ItemKind::Struct(..) | ItemKind::Union(..) | ItemKind::Trait(..) |
|
||||||
ItemKind::ExternCrate(..) | ItemKind::ForeignMod(..) | ItemKind::Ty(..) =>
|
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[..])
|
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));
|
self.dep_graph.read(DepNode::new_no_params(DepKind::AllLocalTraitImpls));
|
||||||
|
|
||||||
// NB: intentionally bypass `self.forest.krate()` so that we
|
// NB: intentionally bypass `self.forest.krate()` so that we
|
||||||
// do not trigger a read of the whole krate here
|
// 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 {
|
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
|
/// 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",
|
ItemUnion(..) => "union",
|
||||||
ItemTrait(..) => "trait",
|
ItemTrait(..) => "trait",
|
||||||
ItemImpl(..) => "impl",
|
ItemImpl(..) => "impl",
|
||||||
ItemDefaultImpl(..) => "default impl",
|
ItemAutoImpl(..) => "default impl",
|
||||||
};
|
};
|
||||||
format!("{} {}{}", item_str, path_str(), id_str)
|
format!("{} {}{}", item_str, path_str(), id_str)
|
||||||
}
|
}
|
||||||
|
|
|
@ -499,7 +499,7 @@ pub struct Crate {
|
||||||
pub impl_items: BTreeMap<ImplItemId, ImplItem>,
|
pub impl_items: BTreeMap<ImplItemId, ImplItem>,
|
||||||
pub bodies: BTreeMap<BodyId, Body>,
|
pub bodies: BTreeMap<BodyId, Body>,
|
||||||
pub trait_impls: BTreeMap<DefId, Vec<NodeId>>,
|
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
|
/// 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
|
/// appear in the crate. If you're going to process all the bodies
|
||||||
|
@ -1813,10 +1813,10 @@ pub enum Item_ {
|
||||||
/// Represents a Trait Declaration
|
/// Represents a Trait Declaration
|
||||||
ItemTrait(Unsafety, Generics, TyParamBounds, HirVec<TraitItemRef>),
|
ItemTrait(Unsafety, Generics, TyParamBounds, HirVec<TraitItemRef>),
|
||||||
|
|
||||||
// Default trait implementations
|
/// Auto trait implementations
|
||||||
///
|
///
|
||||||
/// `impl Trait for .. {}`
|
/// `impl Trait for .. {}`
|
||||||
ItemDefaultImpl(Unsafety, TraitRef),
|
ItemAutoImpl(Unsafety, TraitRef),
|
||||||
/// An implementation, eg `impl<A> Trait for Foo { .. }`
|
/// An implementation, eg `impl<A> Trait for Foo { .. }`
|
||||||
ItemImpl(Unsafety,
|
ItemImpl(Unsafety,
|
||||||
ImplPolarity,
|
ImplPolarity,
|
||||||
|
@ -1844,7 +1844,7 @@ impl Item_ {
|
||||||
ItemUnion(..) => "union",
|
ItemUnion(..) => "union",
|
||||||
ItemTrait(..) => "trait",
|
ItemTrait(..) => "trait",
|
||||||
ItemImpl(..) |
|
ItemImpl(..) |
|
||||||
ItemDefaultImpl(..) => "item",
|
ItemAutoImpl(..) => "item",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -660,7 +660,7 @@ impl<'a> State<'a> {
|
||||||
self.head(&visibility_qualified(&item.vis, "union"))?;
|
self.head(&visibility_qualified(&item.vis, "union"))?;
|
||||||
self.print_struct(struct_def, generics, item.name, item.span, true)?;
|
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.head("")?;
|
||||||
self.print_visibility(&item.vis)?;
|
self.print_visibility(&item.vis)?;
|
||||||
self.print_unsafety(unsafety)?;
|
self.print_unsafety(unsafety)?;
|
||||||
|
|
|
@ -898,7 +898,7 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for hir::Item {
|
||||||
hir::ItemForeignMod(..) |
|
hir::ItemForeignMod(..) |
|
||||||
hir::ItemGlobalAsm(..) |
|
hir::ItemGlobalAsm(..) |
|
||||||
hir::ItemMod(..) |
|
hir::ItemMod(..) |
|
||||||
hir::ItemDefaultImpl(..) |
|
hir::ItemAutoImpl(..) |
|
||||||
hir::ItemTrait(..) |
|
hir::ItemTrait(..) |
|
||||||
hir::ItemImpl(..) |
|
hir::ItemImpl(..) |
|
||||||
hir::ItemTy(..) |
|
hir::ItemTy(..) |
|
||||||
|
@ -945,7 +945,7 @@ impl_stable_hash_for!(enum hir::Item_ {
|
||||||
ItemStruct(variant_data, generics),
|
ItemStruct(variant_data, generics),
|
||||||
ItemUnion(variant_data, generics),
|
ItemUnion(variant_data, generics),
|
||||||
ItemTrait(unsafety, generics, bounds, item_refs),
|
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)
|
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: _,
|
def_id: _,
|
||||||
unsafety,
|
unsafety,
|
||||||
paren_sugar,
|
paren_sugar,
|
||||||
has_default_impl,
|
has_auto_impl,
|
||||||
def_path_hash,
|
def_path_hash,
|
||||||
} = *self;
|
} = *self;
|
||||||
|
|
||||||
unsafety.hash_stable(hcx, hasher);
|
unsafety.hash_stable(hcx, hasher);
|
||||||
paren_sugar.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);
|
def_path_hash.hash_stable(hcx, hasher);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -562,7 +562,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> {
|
||||||
hir::ItemStruct(..) |
|
hir::ItemStruct(..) |
|
||||||
hir::ItemUnion(..) |
|
hir::ItemUnion(..) |
|
||||||
hir::ItemTrait(..) |
|
hir::ItemTrait(..) |
|
||||||
hir::ItemDefaultImpl(..) |
|
hir::ItemAutoImpl(..) |
|
||||||
hir::ItemImpl(..) => self.tcx.sess.codemap().def_span(item.span),
|
hir::ItemImpl(..) => self.tcx.sess.codemap().def_span(item.span),
|
||||||
_ => item.span,
|
_ => item.span,
|
||||||
};
|
};
|
||||||
|
|
|
@ -270,7 +270,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
||||||
hir::ItemMod(..) | hir::ItemForeignMod(..) |
|
hir::ItemMod(..) | hir::ItemForeignMod(..) |
|
||||||
hir::ItemImpl(..) | hir::ItemTrait(..) |
|
hir::ItemImpl(..) | hir::ItemTrait(..) |
|
||||||
hir::ItemStruct(..) | hir::ItemEnum(..) |
|
hir::ItemStruct(..) | hir::ItemEnum(..) |
|
||||||
hir::ItemUnion(..) | hir::ItemDefaultImpl(..) |
|
hir::ItemUnion(..) | hir::ItemAutoImpl(..) |
|
||||||
hir::ItemGlobalAsm(..) => {}
|
hir::ItemGlobalAsm(..) => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -313,7 +313,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||||
hir::ItemExternCrate(_) |
|
hir::ItemExternCrate(_) |
|
||||||
hir::ItemUse(..) |
|
hir::ItemUse(..) |
|
||||||
hir::ItemMod(..) |
|
hir::ItemMod(..) |
|
||||||
hir::ItemDefaultImpl(..) |
|
hir::ItemAutoImpl(..) |
|
||||||
hir::ItemForeignMod(..) |
|
hir::ItemForeignMod(..) |
|
||||||
hir::ItemGlobalAsm(..) => {
|
hir::ItemGlobalAsm(..) => {
|
||||||
// These sorts of items have no lifetime parameters at all.
|
// These sorts of items have no lifetime parameters at all.
|
||||||
|
|
|
@ -288,11 +288,11 @@ pub enum Vtable<'tcx, N> {
|
||||||
/// Vtable identifying a particular impl.
|
/// Vtable identifying a particular impl.
|
||||||
VtableImpl(VtableImplData<'tcx, N>),
|
VtableImpl(VtableImplData<'tcx, N>),
|
||||||
|
|
||||||
/// Vtable for default trait implementations
|
/// Vtable for auto trait implementations
|
||||||
/// This carries the information and nested obligations with regards
|
/// 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.
|
/// 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
|
/// Successful resolution to an obligation provided by the caller
|
||||||
/// for some type parameter. The `Vec<N>` represents the
|
/// for some type parameter. The `Vec<N>` represents the
|
||||||
|
@ -354,7 +354,7 @@ pub struct VtableClosureData<'tcx, N> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct VtableDefaultImplData<N> {
|
pub struct VtableAutoImplData<N> {
|
||||||
pub trait_def_id: DefId,
|
pub trait_def_id: DefId,
|
||||||
pub nested: Vec<N>
|
pub nested: Vec<N>
|
||||||
}
|
}
|
||||||
|
@ -758,7 +758,7 @@ impl<'tcx, N> Vtable<'tcx, N> {
|
||||||
VtableImpl(i) => i.nested,
|
VtableImpl(i) => i.nested,
|
||||||
VtableParam(n) => n,
|
VtableParam(n) => n,
|
||||||
VtableBuiltin(i) => i.nested,
|
VtableBuiltin(i) => i.nested,
|
||||||
VtableDefaultImpl(d) => d.nested,
|
VtableAutoImpl(d) => d.nested,
|
||||||
VtableClosure(c) => c.nested,
|
VtableClosure(c) => c.nested,
|
||||||
VtableGenerator(c) => c.nested,
|
VtableGenerator(c) => c.nested,
|
||||||
VtableObject(d) => d.nested,
|
VtableObject(d) => d.nested,
|
||||||
|
@ -771,7 +771,7 @@ impl<'tcx, N> Vtable<'tcx, N> {
|
||||||
&mut VtableImpl(ref mut i) => &mut i.nested,
|
&mut VtableImpl(ref mut i) => &mut i.nested,
|
||||||
&mut VtableParam(ref mut n) => n,
|
&mut VtableParam(ref mut n) => n,
|
||||||
&mut VtableBuiltin(ref mut i) => &mut i.nested,
|
&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 VtableGenerator(ref mut c) => &mut c.nested,
|
||||||
&mut VtableClosure(ref mut c) => &mut c.nested,
|
&mut VtableClosure(ref mut c) => &mut c.nested,
|
||||||
&mut VtableObject(ref mut d) => &mut d.nested,
|
&mut VtableObject(ref mut d) => &mut d.nested,
|
||||||
|
@ -795,7 +795,7 @@ impl<'tcx, N> Vtable<'tcx, N> {
|
||||||
vtable_base: o.vtable_base,
|
vtable_base: o.vtable_base,
|
||||||
nested: o.nested.into_iter().map(f).collect(),
|
nested: o.nested.into_iter().map(f).collect(),
|
||||||
}),
|
}),
|
||||||
VtableDefaultImpl(d) => VtableDefaultImpl(VtableDefaultImplData {
|
VtableAutoImpl(d) => VtableAutoImpl(VtableAutoImplData {
|
||||||
trait_def_id: d.trait_def_id,
|
trait_def_id: d.trait_def_id,
|
||||||
nested: d.nested.into_iter().map(f).collect(),
|
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
|
// projection. And the projection where clause is handled
|
||||||
// in `assemble_candidates_from_param_env`.
|
// in `assemble_candidates_from_param_env`.
|
||||||
}
|
}
|
||||||
super::VtableDefaultImpl(..) |
|
super::VtableAutoImpl(..) |
|
||||||
super::VtableBuiltin(..) => {
|
super::VtableBuiltin(..) => {
|
||||||
// These traits have no associated types.
|
// These traits have no associated types.
|
||||||
span_bug!(
|
span_bug!(
|
||||||
|
@ -1182,7 +1182,7 @@ fn confirm_select_candidate<'cx, 'gcx, 'tcx>(
|
||||||
confirm_fn_pointer_candidate(selcx, obligation, data),
|
confirm_fn_pointer_candidate(selcx, obligation, data),
|
||||||
super::VtableObject(_) =>
|
super::VtableObject(_) =>
|
||||||
confirm_object_candidate(selcx, obligation, obligation_trait_ref),
|
confirm_object_candidate(selcx, obligation, obligation_trait_ref),
|
||||||
super::VtableDefaultImpl(..) |
|
super::VtableAutoImpl(..) |
|
||||||
super::VtableParam(..) |
|
super::VtableParam(..) |
|
||||||
super::VtableBuiltin(..) =>
|
super::VtableBuiltin(..) =>
|
||||||
// we don't create Select candidates with this kind of resolution
|
// we don't create Select candidates with this kind of resolution
|
||||||
|
|
|
@ -25,9 +25,9 @@ use super::TraitNotObjectSafe;
|
||||||
use super::Selection;
|
use super::Selection;
|
||||||
use super::SelectionResult;
|
use super::SelectionResult;
|
||||||
use super::{VtableBuiltin, VtableImpl, VtableParam, VtableClosure, VtableGenerator,
|
use super::{VtableBuiltin, VtableImpl, VtableParam, VtableClosure, VtableGenerator,
|
||||||
VtableFnPointer, VtableObject, VtableDefaultImpl};
|
VtableFnPointer, VtableObject, VtableAutoImpl};
|
||||||
use super::{VtableImplData, VtableObjectData, VtableBuiltinData, VtableGeneratorData,
|
use super::{VtableImplData, VtableObjectData, VtableBuiltinData, VtableGeneratorData,
|
||||||
VtableClosureData, VtableDefaultImplData, VtableFnPointerData};
|
VtableClosureData, VtableAutoImplData, VtableFnPointerData};
|
||||||
use super::util;
|
use super::util;
|
||||||
|
|
||||||
use dep_graph::{DepNodeIndex, DepKind};
|
use dep_graph::{DepNodeIndex, DepKind};
|
||||||
|
@ -225,7 +225,7 @@ enum SelectionCandidate<'tcx> {
|
||||||
BuiltinCandidate { has_nested: bool },
|
BuiltinCandidate { has_nested: bool },
|
||||||
ParamCandidate(ty::PolyTraitRef<'tcx>),
|
ParamCandidate(ty::PolyTraitRef<'tcx>),
|
||||||
ImplCandidate(DefId),
|
ImplCandidate(DefId),
|
||||||
DefaultImplCandidate(DefId),
|
AutoImplCandidate(DefId),
|
||||||
|
|
||||||
/// This is a trait matching with a projected type as `Self`, and
|
/// This is a trait matching with a projected type as `Self`, and
|
||||||
/// we found an applicable bound in the trait definition.
|
/// 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),
|
ImplCandidate(def_id) => ImplCandidate(def_id),
|
||||||
DefaultImplCandidate(def_id) => DefaultImplCandidate(def_id),
|
AutoImplCandidate(def_id) => AutoImplCandidate(def_id),
|
||||||
ProjectionCandidate => ProjectionCandidate,
|
ProjectionCandidate => ProjectionCandidate,
|
||||||
FnPointerCandidate => FnPointerCandidate,
|
FnPointerCandidate => FnPointerCandidate,
|
||||||
ObjectCandidate => ObjectCandidate,
|
ObjectCandidate => ObjectCandidate,
|
||||||
|
@ -910,7 +910,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
||||||
fn coinductive_predicate(&self, predicate: ty::Predicate<'tcx>) -> bool {
|
fn coinductive_predicate(&self, predicate: ty::Predicate<'tcx>) -> bool {
|
||||||
let result = match predicate {
|
let result = match predicate {
|
||||||
ty::Predicate::Trait(ref data) => {
|
ty::Predicate::Trait(ref data) => {
|
||||||
self.tcx().trait_has_default_impl(data.def_id())
|
self.tcx().trait_has_auto_impl(data.def_id())
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
false
|
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_projected_tys(obligation, &mut candidates);
|
||||||
self.assemble_candidates_from_caller_bounds(stack, &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.
|
// consider triggering a default if there is no other impl that can apply.
|
||||||
if candidates.vec.is_empty() {
|
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());
|
debug!("candidate list size: {}", candidates.vec.len());
|
||||||
Ok(candidates)
|
Ok(candidates)
|
||||||
|
@ -1686,18 +1686,18 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn assemble_candidates_from_default_impls(&mut self,
|
fn assemble_candidates_from_auto_impls(&mut self,
|
||||||
obligation: &TraitObligation<'tcx>,
|
obligation: &TraitObligation<'tcx>,
|
||||||
candidates: &mut SelectionCandidateSet<'tcx>)
|
candidates: &mut SelectionCandidateSet<'tcx>)
|
||||||
-> Result<(), SelectionError<'tcx>>
|
-> Result<(), SelectionError<'tcx>>
|
||||||
{
|
{
|
||||||
// OK to skip binder here because the tests we do below do not involve bound regions
|
// OK to skip binder here because the tests we do below do not involve bound regions
|
||||||
let self_ty = *obligation.self_ty().skip_binder();
|
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();
|
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 {
|
match self_ty.sty {
|
||||||
ty::TyDynamic(..) => {
|
ty::TyDynamic(..) => {
|
||||||
// For object types, we don't know what the closed
|
// For object types, we don't know what the closed
|
||||||
|
@ -1728,11 +1728,11 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
||||||
// this path.
|
// this path.
|
||||||
}
|
}
|
||||||
ty::TyInfer(ty::TyVar(_)) => {
|
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.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 {
|
match other.candidate {
|
||||||
ObjectCandidate |
|
ObjectCandidate |
|
||||||
ParamCandidate(_) | ProjectionCandidate => match victim.candidate {
|
ParamCandidate(_) | ProjectionCandidate => match victim.candidate {
|
||||||
DefaultImplCandidate(..) => {
|
AutoImplCandidate(..) => {
|
||||||
bug!(
|
bug!(
|
||||||
"default implementations shouldn't be recorded \
|
"default implementations shouldn't be recorded \
|
||||||
when there are other valid candidates");
|
when there are other valid candidates");
|
||||||
|
@ -2282,9 +2282,9 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
||||||
Ok(VtableParam(obligations))
|
Ok(VtableParam(obligations))
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultImplCandidate(trait_def_id) => {
|
AutoImplCandidate(trait_def_id) => {
|
||||||
let data = self.confirm_default_impl_candidate(obligation, trait_def_id);
|
let data = self.confirm_auto_impl_candidate(obligation, trait_def_id);
|
||||||
Ok(VtableDefaultImpl(data))
|
Ok(VtableAutoImpl(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
ImplCandidate(impl_def_id) => {
|
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
|
/// 1. For each constituent type `Y` in `X`, `Y : Foo` holds
|
||||||
/// 2. For each where-clause `C` declared on `Foo`, `[Self => X] C` 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>,
|
obligation: &TraitObligation<'tcx>,
|
||||||
trait_def_id: DefId)
|
trait_def_id: DefId)
|
||||||
-> VtableDefaultImplData<PredicateObligation<'tcx>>
|
-> VtableAutoImplData<PredicateObligation<'tcx>>
|
||||||
{
|
{
|
||||||
debug!("confirm_default_impl_candidate({:?}, {:?})",
|
debug!("confirm_auto_impl_candidate({:?}, {:?})",
|
||||||
obligation,
|
obligation,
|
||||||
trait_def_id);
|
trait_def_id);
|
||||||
|
|
||||||
// binder is moved below
|
// binder is moved below
|
||||||
let self_ty = self.infcx.shallow_resolve(obligation.predicate.skip_binder().self_ty());
|
let self_ty = self.infcx.shallow_resolve(obligation.predicate.skip_binder().self_ty());
|
||||||
let types = self.constituent_types_for_ty(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`
|
/// See `confirm_auto_impl_candidate`
|
||||||
fn vtable_default_impl(&mut self,
|
fn vtable_auto_impl(&mut self,
|
||||||
obligation: &TraitObligation<'tcx>,
|
obligation: &TraitObligation<'tcx>,
|
||||||
trait_def_id: DefId,
|
trait_def_id: DefId,
|
||||||
nested: ty::Binder<Vec<Ty<'tcx>>>)
|
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 cause = obligation.derived_cause(BuiltinDerivedObligation);
|
||||||
let mut obligations = self.collect_predicates_for_types(
|
let mut obligations = self.collect_predicates_for_types(
|
||||||
|
@ -2465,9 +2465,9 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
||||||
|
|
||||||
obligations.extend(trait_obligations);
|
obligations.extend(trait_obligations);
|
||||||
|
|
||||||
debug!("vtable_default_impl: obligations={:?}", obligations);
|
debug!("vtable_auto_impl: obligations={:?}", obligations);
|
||||||
|
|
||||||
VtableDefaultImplData {
|
VtableAutoImplData {
|
||||||
trait_def_id,
|
trait_def_id,
|
||||||
nested: obligations
|
nested: obligations
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ impl<'tcx, N: fmt::Debug> fmt::Debug for traits::Vtable<'tcx, N> {
|
||||||
super::VtableImpl(ref v) =>
|
super::VtableImpl(ref v) =>
|
||||||
write!(f, "{:?}", v),
|
write!(f, "{:?}", v),
|
||||||
|
|
||||||
super::VtableDefaultImpl(ref t) =>
|
super::VtableAutoImpl(ref t) =>
|
||||||
write!(f, "{:?}", t),
|
write!(f, "{:?}", t),
|
||||||
|
|
||||||
super::VtableClosure(ref d) =>
|
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 {
|
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.trait_def_id,
|
||||||
self.nested)
|
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 {
|
traits::VtableGenerator(traits::VtableGeneratorData {
|
||||||
closure_def_id,
|
closure_def_id,
|
||||||
substs,
|
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 {
|
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,
|
trait_def_id: self.trait_def_id,
|
||||||
nested: self.nested.fold_with(folder),
|
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 {
|
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
|
||||||
match *self {
|
match *self {
|
||||||
traits::VtableImpl(ref v) => traits::VtableImpl(v.fold_with(folder)),
|
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(ref d) => {
|
||||||
traits::VtableGenerator(d.fold_with(folder))
|
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 {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
||||||
match *self {
|
match *self {
|
||||||
traits::VtableImpl(ref v) => v.visit_with(visitor),
|
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::VtableGenerator(ref d) => d.visit_with(visitor),
|
||||||
traits::VtableClosure(ref d) => d.visit_with(visitor),
|
traits::VtableClosure(ref d) => d.visit_with(visitor),
|
||||||
traits::VtableFnPointer(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
|
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
|
// Always use types for non-local impls, where types are always
|
||||||
// available, and filename/line-number is mostly uninteresting.
|
// 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.
|
// Otherwise, use filename/line-number if forced.
|
||||||
let force_no_types = FORCE_IMPL_FILENAME_LINE.with(|f| f.get());
|
let force_no_types = FORCE_IMPL_FILENAME_LINE.with(|f| f.get());
|
||||||
!force_no_types
|
!force_no_types
|
||||||
|
|
|
@ -113,8 +113,8 @@ define_maps! { <'tcx>
|
||||||
/// True if this is a foreign item (i.e., linked via `extern { ... }`).
|
/// True if this is a foreign item (i.e., linked via `extern { ... }`).
|
||||||
[] fn is_foreign_item: IsForeignItem(DefId) -> bool,
|
[] fn is_foreign_item: IsForeignItem(DefId) -> bool,
|
||||||
|
|
||||||
/// True if this is a default impl (aka impl Foo for ..)
|
/// True if this is an auto impl (aka impl Foo for ..)
|
||||||
[] fn is_default_impl: IsDefaultImpl(DefId) -> bool,
|
[] fn is_auto_impl: IsAutoImpl(DefId) -> bool,
|
||||||
|
|
||||||
/// Get a map with the variance of every item; use `item_variance`
|
/// Get a map with the variance of every item; use `item_variance`
|
||||||
/// instead.
|
/// 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::SuperPredicatesOfItem => { force!(super_predicates_of, def_id!()); }
|
||||||
DepKind::TraitDefOfItem => { force!(trait_def, def_id!()); }
|
DepKind::TraitDefOfItem => { force!(trait_def, def_id!()); }
|
||||||
DepKind::AdtDefOfItem => { force!(adt_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::ImplTraitRef => { force!(impl_trait_ref, def_id!()); }
|
||||||
DepKind::ImplPolarity => { force!(impl_polarity, def_id!()); }
|
DepKind::ImplPolarity => { force!(impl_polarity, def_id!()); }
|
||||||
DepKind::ClosureKind => { force!(closure_kind, 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))
|
self.get_attrs(did).iter().any(|item| item.check_name(attr))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn trait_has_default_impl(self, trait_def_id: DefId) -> bool {
|
pub fn trait_has_auto_impl(self, trait_def_id: DefId) -> bool {
|
||||||
self.trait_def(trait_def_id).has_default_impl
|
self.trait_def(trait_def_id).has_auto_impl
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn generator_layout(self, def_id: DefId) -> &'tcx GeneratorLayout<'tcx> {
|
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).
|
/// be usable with the sugar (or without it).
|
||||||
pub paren_sugar: bool,
|
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
|
/// The ICH of this trait's DefPath, cached here so it doesn't have to be
|
||||||
/// recomputed all the time.
|
/// recomputed all the time.
|
||||||
|
@ -51,14 +51,14 @@ impl<'a, 'gcx, 'tcx> TraitDef {
|
||||||
pub fn new(def_id: DefId,
|
pub fn new(def_id: DefId,
|
||||||
unsafety: hir::Unsafety,
|
unsafety: hir::Unsafety,
|
||||||
paren_sugar: bool,
|
paren_sugar: bool,
|
||||||
has_default_impl: bool,
|
has_auto_impl: bool,
|
||||||
def_path_hash: DefPathHash)
|
def_path_hash: DefPathHash)
|
||||||
-> TraitDef {
|
-> TraitDef {
|
||||||
TraitDef {
|
TraitDef {
|
||||||
def_id,
|
def_id,
|
||||||
paren_sugar,
|
paren_sugar,
|
||||||
unsafety,
|
unsafety,
|
||||||
has_default_impl,
|
has_auto_impl,
|
||||||
def_path_hash,
|
def_path_hash,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,7 +253,7 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> {
|
||||||
hir::ItemUnion(..) |
|
hir::ItemUnion(..) |
|
||||||
hir::ItemTrait(..) |
|
hir::ItemTrait(..) |
|
||||||
hir::ItemImpl(..) |
|
hir::ItemImpl(..) |
|
||||||
hir::ItemDefaultImpl(..) => None,
|
hir::ItemAutoImpl(..) => None,
|
||||||
|
|
||||||
hir::ItemMod(ref m) => search_mod(this, m, idx, names),
|
hir::ItemMod(ref m) => search_mod(this, m, idx, names),
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,7 +23,7 @@ use rustc::hir::intravisit::FnKind;
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
pub enum MethodLateContext {
|
pub enum MethodLateContext {
|
||||||
TraitDefaultImpl,
|
TraitAutoImpl,
|
||||||
TraitImpl,
|
TraitImpl,
|
||||||
PlainImpl,
|
PlainImpl,
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ pub fn method_context(cx: &LateContext, id: ast::NodeId) -> MethodLateContext {
|
||||||
let def_id = cx.tcx.hir.local_def_id(id);
|
let def_id = cx.tcx.hir.local_def_id(id);
|
||||||
let item = cx.tcx.associated_item(def_id);
|
let item = cx.tcx.associated_item(def_id);
|
||||||
match item.container {
|
match item.container {
|
||||||
ty::TraitContainer(..) => MethodLateContext::TraitDefaultImpl,
|
ty::TraitContainer(..) => MethodLateContext::TraitAutoImpl,
|
||||||
ty::ImplContainer(cid) => {
|
ty::ImplContainer(cid) => {
|
||||||
match cx.tcx.impl_trait_ref(cid) {
|
match cx.tcx.impl_trait_ref(cid) {
|
||||||
Some(_) => MethodLateContext::TraitImpl,
|
Some(_) => MethodLateContext::TraitImpl,
|
||||||
|
@ -245,7 +245,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase {
|
||||||
MethodLateContext::PlainImpl => {
|
MethodLateContext::PlainImpl => {
|
||||||
self.check_snake_case(cx, "method", &name.as_str(), Some(span))
|
self.check_snake_case(cx, "method", &name.as_str(), Some(span))
|
||||||
}
|
}
|
||||||
MethodLateContext::TraitDefaultImpl => {
|
MethodLateContext::TraitAutoImpl => {
|
||||||
self.check_snake_case(cx, "trait method", &name.as_str(), Some(span))
|
self.check_snake_case(cx, "trait method", &name.as_str(), Some(span))
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
|
|
|
@ -144,7 +144,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
|
||||||
inherent_impls => { Rc::new(cdata.get_inherent_implementations_for_type(def_id.index)) }
|
inherent_impls => { Rc::new(cdata.get_inherent_implementations_for_type(def_id.index)) }
|
||||||
is_const_fn => { cdata.is_const_fn(def_id.index) }
|
is_const_fn => { cdata.is_const_fn(def_id.index) }
|
||||||
is_foreign_item => { cdata.is_foreign_item(def_id.index) }
|
is_foreign_item => { cdata.is_foreign_item(def_id.index) }
|
||||||
is_default_impl => { cdata.is_default_impl(def_id.index) }
|
is_auto_impl => { cdata.is_auto_impl(def_id.index) }
|
||||||
describe_def => { cdata.get_def(def_id.index) }
|
describe_def => { cdata.get_def(def_id.index) }
|
||||||
def_span => { cdata.get_span(def_id.index, &tcx.sess) }
|
def_span => { cdata.get_span(def_id.index, &tcx.sess) }
|
||||||
lookup_stability => {
|
lookup_stability => {
|
||||||
|
|
|
@ -459,7 +459,7 @@ impl<'tcx> EntryKind<'tcx> {
|
||||||
|
|
||||||
EntryKind::ForeignMod |
|
EntryKind::ForeignMod |
|
||||||
EntryKind::Impl(_) |
|
EntryKind::Impl(_) |
|
||||||
EntryKind::DefaultImpl(_) |
|
EntryKind::AutoImpl(_) |
|
||||||
EntryKind::Field |
|
EntryKind::Field |
|
||||||
EntryKind::Generator(_) |
|
EntryKind::Generator(_) |
|
||||||
EntryKind::Closure(_) => return None,
|
EntryKind::Closure(_) => return None,
|
||||||
|
@ -529,7 +529,7 @@ impl<'a, 'tcx> CrateMetadata {
|
||||||
ty::TraitDef::new(self.local_def_id(item_id),
|
ty::TraitDef::new(self.local_def_id(item_id),
|
||||||
data.unsafety,
|
data.unsafety,
|
||||||
data.paren_sugar,
|
data.paren_sugar,
|
||||||
data.has_default_impl,
|
data.has_auto_impl,
|
||||||
self.def_path_table.def_path_hash(item_id))
|
self.def_path_table.def_path_hash(item_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -735,7 +735,7 @@ impl<'a, 'tcx> CrateMetadata {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
EntryKind::Impl(_) |
|
EntryKind::Impl(_) |
|
||||||
EntryKind::DefaultImpl(_) => continue,
|
EntryKind::AutoImpl(_) => continue,
|
||||||
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
@ -1082,9 +1082,9 @@ impl<'a, 'tcx> CrateMetadata {
|
||||||
self.dllimport_foreign_items.contains(&id)
|
self.dllimport_foreign_items.contains(&id)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_default_impl(&self, impl_id: DefIndex) -> bool {
|
pub fn is_auto_impl(&self, impl_id: DefIndex) -> bool {
|
||||||
match self.entry(impl_id).kind {
|
match self.entry(impl_id).kind {
|
||||||
EntryKind::DefaultImpl(_) => true,
|
EntryKind::AutoImpl(_) => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -919,7 +919,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
|
||||||
ctor_sig: None,
|
ctor_sig: None,
|
||||||
}), repr_options)
|
}), repr_options)
|
||||||
}
|
}
|
||||||
hir::ItemDefaultImpl(..) => {
|
hir::ItemAutoImpl(..) => {
|
||||||
let data = ImplData {
|
let data = ImplData {
|
||||||
polarity: hir::ImplPolarity::Positive,
|
polarity: hir::ImplPolarity::Positive,
|
||||||
defaultness: hir::Defaultness::Final,
|
defaultness: hir::Defaultness::Final,
|
||||||
|
@ -928,7 +928,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
|
||||||
trait_ref: tcx.impl_trait_ref(def_id).map(|trait_ref| self.lazy(&trait_ref)),
|
trait_ref: tcx.impl_trait_ref(def_id).map(|trait_ref| self.lazy(&trait_ref)),
|
||||||
};
|
};
|
||||||
|
|
||||||
EntryKind::DefaultImpl(self.lazy(&data))
|
EntryKind::AutoImpl(self.lazy(&data))
|
||||||
}
|
}
|
||||||
hir::ItemImpl(_, polarity, defaultness, ..) => {
|
hir::ItemImpl(_, polarity, defaultness, ..) => {
|
||||||
let trait_ref = tcx.impl_trait_ref(def_id);
|
let trait_ref = tcx.impl_trait_ref(def_id);
|
||||||
|
@ -970,7 +970,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
|
||||||
let data = TraitData {
|
let data = TraitData {
|
||||||
unsafety: trait_def.unsafety,
|
unsafety: trait_def.unsafety,
|
||||||
paren_sugar: trait_def.paren_sugar,
|
paren_sugar: trait_def.paren_sugar,
|
||||||
has_default_impl: tcx.trait_has_default_impl(def_id),
|
has_auto_impl: tcx.trait_has_auto_impl(def_id),
|
||||||
super_predicates: self.lazy(&tcx.super_predicates_of(def_id)),
|
super_predicates: self.lazy(&tcx.super_predicates_of(def_id)),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1517,7 +1517,7 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
|
||||||
hir::ItemGlobalAsm(..) |
|
hir::ItemGlobalAsm(..) |
|
||||||
hir::ItemExternCrate(..) |
|
hir::ItemExternCrate(..) |
|
||||||
hir::ItemUse(..) |
|
hir::ItemUse(..) |
|
||||||
hir::ItemDefaultImpl(..) |
|
hir::ItemAutoImpl(..) |
|
||||||
hir::ItemTy(..) => {
|
hir::ItemTy(..) => {
|
||||||
// no sub-item recording needed in these cases
|
// no sub-item recording needed in these cases
|
||||||
}
|
}
|
||||||
|
|
|
@ -303,7 +303,7 @@ pub enum EntryKind<'tcx> {
|
||||||
Generator(Lazy<GeneratorData<'tcx>>),
|
Generator(Lazy<GeneratorData<'tcx>>),
|
||||||
Trait(Lazy<TraitData<'tcx>>),
|
Trait(Lazy<TraitData<'tcx>>),
|
||||||
Impl(Lazy<ImplData<'tcx>>),
|
Impl(Lazy<ImplData<'tcx>>),
|
||||||
DefaultImpl(Lazy<ImplData<'tcx>>),
|
AutoImpl(Lazy<ImplData<'tcx>>),
|
||||||
Method(Lazy<MethodData<'tcx>>),
|
Method(Lazy<MethodData<'tcx>>),
|
||||||
AssociatedType(AssociatedContainer),
|
AssociatedType(AssociatedContainer),
|
||||||
AssociatedConst(AssociatedContainer, u8),
|
AssociatedConst(AssociatedContainer, u8),
|
||||||
|
@ -359,7 +359,7 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for EntryKind<'gcx> {
|
||||||
EntryKind::Trait(ref trait_data) => {
|
EntryKind::Trait(ref trait_data) => {
|
||||||
trait_data.hash_stable(hcx, hasher);
|
trait_data.hash_stable(hcx, hasher);
|
||||||
}
|
}
|
||||||
EntryKind::DefaultImpl(ref impl_data) |
|
EntryKind::AutoImpl(ref impl_data) |
|
||||||
EntryKind::Impl(ref impl_data) => {
|
EntryKind::Impl(ref impl_data) => {
|
||||||
impl_data.hash_stable(hcx, hasher);
|
impl_data.hash_stable(hcx, hasher);
|
||||||
}
|
}
|
||||||
|
@ -426,14 +426,14 @@ impl_stable_hash_for!(struct VariantData<'tcx> {
|
||||||
pub struct TraitData<'tcx> {
|
pub struct TraitData<'tcx> {
|
||||||
pub unsafety: hir::Unsafety,
|
pub unsafety: hir::Unsafety,
|
||||||
pub paren_sugar: bool,
|
pub paren_sugar: bool,
|
||||||
pub has_default_impl: bool,
|
pub has_auto_impl: bool,
|
||||||
pub super_predicates: Lazy<ty::GenericPredicates<'tcx>>,
|
pub super_predicates: Lazy<ty::GenericPredicates<'tcx>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_stable_hash_for!(struct TraitData<'tcx> {
|
impl_stable_hash_for!(struct TraitData<'tcx> {
|
||||||
unsafety,
|
unsafety,
|
||||||
paren_sugar,
|
paren_sugar,
|
||||||
has_default_impl,
|
has_auto_impl,
|
||||||
super_predicates
|
super_predicates
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -213,7 +213,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||||
item.span,
|
item.span,
|
||||||
Some("place qualifiers on individual impl items instead"));
|
Some("place qualifiers on individual impl items instead"));
|
||||||
}
|
}
|
||||||
ItemKind::DefaultImpl(..) => {
|
ItemKind::AutoImpl(..) => {
|
||||||
self.invalid_visibility(&item.vis, item.span, None);
|
self.invalid_visibility(&item.vis, item.span, None);
|
||||||
}
|
}
|
||||||
ItemKind::ForeignMod(..) => {
|
ItemKind::ForeignMod(..) => {
|
||||||
|
|
|
@ -147,7 +147,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
|
||||||
let def_id = self.tcx.hir.local_def_id(item.id);
|
let def_id = self.tcx.hir.local_def_id(item.id);
|
||||||
cmp::min(self.item_ty_level(def_id), self.impl_trait_level(def_id))
|
cmp::min(self.item_ty_level(def_id), self.impl_trait_level(def_id))
|
||||||
}
|
}
|
||||||
hir::ItemDefaultImpl(..) => {
|
hir::ItemAutoImpl(..) => {
|
||||||
let def_id = self.tcx.hir.local_def_id(item.id);
|
let def_id = self.tcx.hir.local_def_id(item.id);
|
||||||
self.impl_trait_level(def_id)
|
self.impl_trait_level(def_id)
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
hir::ItemUse(..) | hir::ItemStatic(..) | hir::ItemConst(..) |
|
hir::ItemUse(..) | hir::ItemStatic(..) | hir::ItemConst(..) |
|
||||||
hir::ItemGlobalAsm(..) | hir::ItemTy(..) | hir::ItemMod(..) |
|
hir::ItemGlobalAsm(..) | hir::ItemTy(..) | hir::ItemMod(..) |
|
||||||
hir::ItemFn(..) | hir::ItemExternCrate(..) | hir::ItemDefaultImpl(..) => {}
|
hir::ItemFn(..) | hir::ItemExternCrate(..) | hir::ItemAutoImpl(..) => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark all items in interfaces of reachable items as reachable
|
// Mark all items in interfaces of reachable items as reachable
|
||||||
|
@ -225,7 +225,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
|
||||||
// Reexports are handled in visit_mod
|
// Reexports are handled in visit_mod
|
||||||
hir::ItemUse(..) => {}
|
hir::ItemUse(..) => {}
|
||||||
// The interface is empty
|
// The interface is empty
|
||||||
hir::ItemDefaultImpl(..) => {}
|
hir::ItemAutoImpl(..) => {}
|
||||||
// The interface is empty
|
// The interface is empty
|
||||||
hir::ItemGlobalAsm(..) => {}
|
hir::ItemGlobalAsm(..) => {}
|
||||||
// Visit everything
|
// Visit everything
|
||||||
|
@ -1504,7 +1504,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// The interface is empty
|
// The interface is empty
|
||||||
hir::ItemDefaultImpl(..) => {}
|
hir::ItemAutoImpl(..) => {}
|
||||||
// An inherent impl is public when its type is public
|
// An inherent impl is public when its type is public
|
||||||
// Subitems of inherent impls have their own publicity
|
// Subitems of inherent impls have their own publicity
|
||||||
hir::ItemImpl(.., None, _, ref impl_item_refs) => {
|
hir::ItemImpl(.., None, _, ref impl_item_refs) => {
|
||||||
|
|
|
@ -376,7 +376,7 @@ impl<'a> Resolver<'a> {
|
||||||
self.insert_field_names(item_def_id, field_names);
|
self.insert_field_names(item_def_id, field_names);
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemKind::DefaultImpl(..) | ItemKind::Impl(..) => {}
|
ItemKind::AutoImpl(..) | ItemKind::Impl(..) => {}
|
||||||
|
|
||||||
ItemKind::Trait(..) => {
|
ItemKind::Trait(..) => {
|
||||||
let def_id = self.definitions.local_def_id(item.id);
|
let def_id = self.definitions.local_def_id(item.id);
|
||||||
|
|
|
@ -1841,7 +1841,7 @@ impl<'a> Resolver<'a> {
|
||||||
|this| visit::walk_item(this, item));
|
|this| visit::walk_item(this, item));
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemKind::DefaultImpl(_, ref trait_ref) => {
|
ItemKind::AutoImpl(_, ref trait_ref) => {
|
||||||
self.with_optional_trait_ref(Some(trait_ref), |this, _| {
|
self.with_optional_trait_ref(Some(trait_ref), |this, _| {
|
||||||
// Resolve type arguments in trait path
|
// Resolve type arguments in trait path
|
||||||
visit::walk_trait_ref(this, trait_ref);
|
visit::walk_trait_ref(this, trait_ref);
|
||||||
|
|
|
@ -499,7 +499,7 @@ impl Sig for ast::Item {
|
||||||
|
|
||||||
Ok(sig)
|
Ok(sig)
|
||||||
}
|
}
|
||||||
ast::ItemKind::DefaultImpl(unsafety, ref trait_ref) => {
|
ast::ItemKind::AutoImpl(unsafety, ref trait_ref) => {
|
||||||
let mut text = String::new();
|
let mut text = String::new();
|
||||||
if unsafety == ast::Unsafety::Unsafe {
|
if unsafety == ast::Unsafety::Unsafe {
|
||||||
text.push_str("unsafe ");
|
text.push_str("unsafe ");
|
||||||
|
|
|
@ -883,7 +883,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> {
|
||||||
hir::ItemUse(..) |
|
hir::ItemUse(..) |
|
||||||
hir::ItemForeignMod(..) |
|
hir::ItemForeignMod(..) |
|
||||||
hir::ItemTy(..) |
|
hir::ItemTy(..) |
|
||||||
hir::ItemDefaultImpl(..) |
|
hir::ItemAutoImpl(..) |
|
||||||
hir::ItemTrait(..) |
|
hir::ItemTrait(..) |
|
||||||
hir::ItemMod(..) => {
|
hir::ItemMod(..) => {
|
||||||
// Nothing to do, just keep recursing...
|
// Nothing to do, just keep recursing...
|
||||||
|
|
|
@ -114,7 +114,7 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
|
||||||
// FIXME(#27579) what amount of WF checking do we need for neg impls?
|
// FIXME(#27579) what amount of WF checking do we need for neg impls?
|
||||||
|
|
||||||
let trait_ref = tcx.impl_trait_ref(tcx.hir.local_def_id(item.id)).unwrap();
|
let trait_ref = tcx.impl_trait_ref(tcx.hir.local_def_id(item.id)).unwrap();
|
||||||
if !tcx.trait_has_default_impl(trait_ref.def_id) {
|
if !tcx.trait_has_auto_impl(trait_ref.def_id) {
|
||||||
error_192(tcx, item.span);
|
error_192(tcx, item.span);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -318,7 +318,7 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
|
||||||
fn check_trait(&mut self, item: &hir::Item) {
|
fn check_trait(&mut self, item: &hir::Item) {
|
||||||
let trait_def_id = self.tcx.hir.local_def_id(item.id);
|
let trait_def_id = self.tcx.hir.local_def_id(item.id);
|
||||||
|
|
||||||
if self.tcx.trait_has_default_impl(trait_def_id) {
|
if self.tcx.trait_has_auto_impl(trait_def_id) {
|
||||||
self.check_auto_trait(trait_def_id, item.span);
|
self.check_auto_trait(trait_def_id, item.span);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,7 @@ pub fn check_coherence<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||||
|
|
||||||
unsafety::check(tcx);
|
unsafety::check(tcx);
|
||||||
orphan::check(tcx);
|
orphan::check(tcx);
|
||||||
overlap::check_default_impls(tcx);
|
overlap::check_auto_impls(tcx);
|
||||||
|
|
||||||
// these queries are executed for side-effects (error reporting):
|
// these queries are executed for side-effects (error reporting):
|
||||||
tcx.crate_inherent_impls(LOCAL_CRATE);
|
tcx.crate_inherent_impls(LOCAL_CRATE);
|
||||||
|
|
|
@ -100,11 +100,11 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OrphanChecker<'cx, 'tcx> {
|
||||||
// This final impl is legal according to the orpan
|
// This final impl is legal according to the orpan
|
||||||
// rules, but it invalidates the reasoning from
|
// rules, but it invalidates the reasoning from
|
||||||
// `two_foos` above.
|
// `two_foos` above.
|
||||||
debug!("trait_ref={:?} trait_def_id={:?} trait_has_default_impl={}",
|
debug!("trait_ref={:?} trait_def_id={:?} trait_has_auto_impl={}",
|
||||||
trait_ref,
|
trait_ref,
|
||||||
trait_def_id,
|
trait_def_id,
|
||||||
self.tcx.trait_has_default_impl(trait_def_id));
|
self.tcx.trait_has_auto_impl(trait_def_id));
|
||||||
if self.tcx.trait_has_default_impl(trait_def_id) &&
|
if self.tcx.trait_has_auto_impl(trait_def_id) &&
|
||||||
!trait_def_id.is_local() {
|
!trait_def_id.is_local() {
|
||||||
let self_ty = trait_ref.self_ty();
|
let self_ty = trait_ref.self_ty();
|
||||||
let opt_self_def_id = match self_ty.sty {
|
let opt_self_def_id = match self_ty.sty {
|
||||||
|
@ -142,7 +142,7 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OrphanChecker<'cx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hir::ItemDefaultImpl(_, ref item_trait_ref) => {
|
hir::ItemAutoImpl(_, ref item_trait_ref) => {
|
||||||
// "Trait" impl
|
// "Trait" impl
|
||||||
debug!("coherence2::orphan check: default trait impl {}",
|
debug!("coherence2::orphan check: default trait impl {}",
|
||||||
self.tcx.hir.node_to_string(item.id));
|
self.tcx.hir.node_to_string(item.id));
|
||||||
|
|
|
@ -18,7 +18,7 @@ use syntax::ast;
|
||||||
use rustc::hir;
|
use rustc::hir;
|
||||||
use rustc::hir::itemlikevisit::ItemLikeVisitor;
|
use rustc::hir::itemlikevisit::ItemLikeVisitor;
|
||||||
|
|
||||||
pub fn check_default_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
pub fn check_auto_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||||
let mut overlap = OverlapChecker { tcx };
|
let mut overlap = OverlapChecker { tcx };
|
||||||
|
|
||||||
// this secondary walk specifically checks for some other cases,
|
// this secondary walk specifically checks for some other cases,
|
||||||
|
@ -74,19 +74,19 @@ struct OverlapChecker<'cx, 'tcx: 'cx> {
|
||||||
impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OverlapChecker<'cx, 'tcx> {
|
impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OverlapChecker<'cx, 'tcx> {
|
||||||
fn visit_item(&mut self, item: &'v hir::Item) {
|
fn visit_item(&mut self, item: &'v hir::Item) {
|
||||||
match item.node {
|
match item.node {
|
||||||
hir::ItemDefaultImpl(..) => {
|
hir::ItemAutoImpl(..) => {
|
||||||
// look for another default impl; note that due to the
|
// look for another auto impl; note that due to the
|
||||||
// general orphan/coherence rules, it must always be
|
// general orphan/coherence rules, it must always be
|
||||||
// in this crate.
|
// in this crate.
|
||||||
let impl_def_id = self.tcx.hir.local_def_id(item.id);
|
let impl_def_id = self.tcx.hir.local_def_id(item.id);
|
||||||
let trait_ref = self.tcx.impl_trait_ref(impl_def_id).unwrap();
|
let trait_ref = self.tcx.impl_trait_ref(impl_def_id).unwrap();
|
||||||
|
|
||||||
let prev_id = self.tcx.hir.trait_default_impl(trait_ref.def_id).unwrap();
|
let prev_id = self.tcx.hir.trait_auto_impl(trait_ref.def_id).unwrap();
|
||||||
if prev_id != item.id {
|
if prev_id != item.id {
|
||||||
let mut err = struct_span_err!(self.tcx.sess,
|
let mut err = struct_span_err!(self.tcx.sess,
|
||||||
self.tcx.span_of_impl(impl_def_id).unwrap(),
|
self.tcx.span_of_impl(impl_def_id).unwrap(),
|
||||||
E0521,
|
E0521,
|
||||||
"redundant default implementations of trait \
|
"redundant auto implementations of trait \
|
||||||
`{}`:",
|
`{}`:",
|
||||||
trait_ref);
|
trait_ref);
|
||||||
err.span_note(self.tcx
|
err.span_note(self.tcx
|
||||||
|
|
|
@ -84,7 +84,7 @@ impl<'cx, 'tcx, 'v> UnsafetyChecker<'cx, 'tcx> {
|
||||||
impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for UnsafetyChecker<'cx, 'tcx> {
|
impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for UnsafetyChecker<'cx, 'tcx> {
|
||||||
fn visit_item(&mut self, item: &'v hir::Item) {
|
fn visit_item(&mut self, item: &'v hir::Item) {
|
||||||
match item.node {
|
match item.node {
|
||||||
hir::ItemDefaultImpl(unsafety, _) => {
|
hir::ItemAutoImpl(unsafety, _) => {
|
||||||
self.check_unsafety_coherence(item, None, unsafety, hir::ImplPolarity::Positive);
|
self.check_unsafety_coherence(item, None, unsafety, hir::ImplPolarity::Positive);
|
||||||
}
|
}
|
||||||
hir::ItemImpl(unsafety, polarity, _, ref generics, ..) => {
|
hir::ItemImpl(unsafety, polarity, _, ref generics, ..) => {
|
||||||
|
|
|
@ -73,7 +73,7 @@ pub fn provide(providers: &mut Providers) {
|
||||||
impl_trait_ref,
|
impl_trait_ref,
|
||||||
impl_polarity,
|
impl_polarity,
|
||||||
is_foreign_item,
|
is_foreign_item,
|
||||||
is_default_impl,
|
is_auto_impl,
|
||||||
..*providers
|
..*providers
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -425,7 +425,7 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) {
|
||||||
tcx.predicates_of(def_id);
|
tcx.predicates_of(def_id);
|
||||||
convert_enum_variant_types(tcx, def_id, &enum_definition.variants);
|
convert_enum_variant_types(tcx, def_id, &enum_definition.variants);
|
||||||
},
|
},
|
||||||
hir::ItemDefaultImpl(..) => {
|
hir::ItemAutoImpl(..) => {
|
||||||
tcx.impl_trait_ref(def_id);
|
tcx.impl_trait_ref(def_id);
|
||||||
}
|
}
|
||||||
hir::ItemImpl(..) => {
|
hir::ItemImpl(..) => {
|
||||||
|
@ -730,11 +730,11 @@ fn trait_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
let def_path_hash = tcx.def_path_hash(def_id);
|
let def_path_hash = tcx.def_path_hash(def_id);
|
||||||
let has_default_impl = tcx.hir.trait_is_auto(def_id);
|
let has_auto_impl = tcx.hir.trait_is_auto(def_id);
|
||||||
let def = ty::TraitDef::new(def_id,
|
let def = ty::TraitDef::new(def_id,
|
||||||
unsafety,
|
unsafety,
|
||||||
paren_sugar,
|
paren_sugar,
|
||||||
has_default_impl,
|
has_auto_impl,
|
||||||
def_path_hash);
|
def_path_hash);
|
||||||
tcx.alloc_trait_def(def)
|
tcx.alloc_trait_def(def)
|
||||||
}
|
}
|
||||||
|
@ -1074,7 +1074,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
let substs = Substs::identity_for_item(tcx, def_id);
|
let substs = Substs::identity_for_item(tcx, def_id);
|
||||||
tcx.mk_adt(def, substs)
|
tcx.mk_adt(def, substs)
|
||||||
}
|
}
|
||||||
ItemDefaultImpl(..) |
|
ItemAutoImpl(..) |
|
||||||
ItemTrait(..) |
|
ItemTrait(..) |
|
||||||
ItemMod(..) |
|
ItemMod(..) |
|
||||||
ItemForeignMod(..) |
|
ItemForeignMod(..) |
|
||||||
|
@ -1223,7 +1223,7 @@ fn impl_trait_ref<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
|
|
||||||
let node_id = tcx.hir.as_local_node_id(def_id).unwrap();
|
let node_id = tcx.hir.as_local_node_id(def_id).unwrap();
|
||||||
match tcx.hir.expect_item(node_id).node {
|
match tcx.hir.expect_item(node_id).node {
|
||||||
hir::ItemDefaultImpl(_, ref ast_trait_ref) => {
|
hir::ItemAutoImpl(_, ref ast_trait_ref) => {
|
||||||
Some(AstConv::instantiate_mono_trait_ref(&icx,
|
Some(AstConv::instantiate_mono_trait_ref(&icx,
|
||||||
ast_trait_ref,
|
ast_trait_ref,
|
||||||
tcx.mk_self_type()))
|
tcx.mk_self_type()))
|
||||||
|
@ -1665,13 +1665,13 @@ fn is_foreign_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_default_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
fn is_auto_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
def_id: DefId)
|
def_id: DefId)
|
||||||
-> bool {
|
-> bool {
|
||||||
match tcx.hir.get_if_local(def_id) {
|
match tcx.hir.get_if_local(def_id) {
|
||||||
Some(hir_map::NodeItem(&hir::Item { node: hir::ItemDefaultImpl(..), .. }))
|
Some(hir_map::NodeItem(&hir::Item { node: hir::ItemAutoImpl(..), .. }))
|
||||||
=> true,
|
=> true,
|
||||||
Some(_) => false,
|
Some(_) => false,
|
||||||
_ => bug!("is_default_impl applied to non-local def-id {:?}", def_id)
|
_ => bug!("is_auto_impl applied to non-local def-id {:?}", def_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4669,7 +4669,7 @@ register_diagnostics! {
|
||||||
// E0372, // coherence not object safe
|
// E0372, // coherence not object safe
|
||||||
E0377, // the trait `CoerceUnsized` may only be implemented for a coercion
|
E0377, // the trait `CoerceUnsized` may only be implemented for a coercion
|
||||||
// between structures with the same definition
|
// between structures with the same definition
|
||||||
E0521, // redundant default implementations of trait
|
E0521, // redundant auto implementations of trait
|
||||||
E0533, // `{}` does not name a unit variant, unit struct or a constant
|
E0533, // `{}` does not name a unit variant, unit struct or a constant
|
||||||
// E0563, // cannot determine a type for this `impl Trait`: {} // removed in 6383de15
|
// E0563, // cannot determine a type for this `impl Trait`: {} // removed in 6383de15
|
||||||
E0564, // only named lifetimes are allowed in `impl Trait`,
|
E0564, // only named lifetimes are allowed in `impl Trait`,
|
||||||
|
|
|
@ -292,10 +292,10 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is a defaulted impl, then bail out early here
|
// If this is an auto impl, then bail out early here
|
||||||
if tcx.is_default_impl(did) {
|
if tcx.is_auto_impl(did) {
|
||||||
return ret.push(clean::Item {
|
return ret.push(clean::Item {
|
||||||
inner: clean::DefaultImplItem(clean::DefaultImpl {
|
inner: clean::AutoImplItem(clean::AutoImpl {
|
||||||
// FIXME: this should be decoded
|
// FIXME: this should be decoded
|
||||||
unsafety: hir::Unsafety::Normal,
|
unsafety: hir::Unsafety::Normal,
|
||||||
trait_: match associated_trait.as_ref().unwrap().clean(cx) {
|
trait_: match associated_trait.as_ref().unwrap().clean(cx) {
|
||||||
|
|
|
@ -425,7 +425,7 @@ pub enum ItemEnum {
|
||||||
PrimitiveItem(PrimitiveType),
|
PrimitiveItem(PrimitiveType),
|
||||||
AssociatedConstItem(Type, Option<String>),
|
AssociatedConstItem(Type, Option<String>),
|
||||||
AssociatedTypeItem(Vec<TyParamBound>, Option<Type>),
|
AssociatedTypeItem(Vec<TyParamBound>, Option<Type>),
|
||||||
DefaultImplItem(DefaultImpl),
|
AutoImplItem(AutoImpl),
|
||||||
/// An item that has been stripped by a rustdoc pass
|
/// An item that has been stripped by a rustdoc pass
|
||||||
StrippedItem(Box<ItemEnum>),
|
StrippedItem(Box<ItemEnum>),
|
||||||
}
|
}
|
||||||
|
@ -2733,12 +2733,12 @@ fn build_deref_target_impls(cx: &DocContext,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||||
pub struct DefaultImpl {
|
pub struct AutoImpl {
|
||||||
pub unsafety: hir::Unsafety,
|
pub unsafety: hir::Unsafety,
|
||||||
pub trait_: Type,
|
pub trait_: Type,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Clean<Item> for doctree::DefaultImpl {
|
impl Clean<Item> for doctree::AutoImpl {
|
||||||
fn clean(&self, cx: &DocContext) -> Item {
|
fn clean(&self, cx: &DocContext) -> Item {
|
||||||
Item {
|
Item {
|
||||||
name: None,
|
name: None,
|
||||||
|
@ -2748,7 +2748,7 @@ impl Clean<Item> for doctree::DefaultImpl {
|
||||||
visibility: Some(Public),
|
visibility: Some(Public),
|
||||||
stability: None,
|
stability: None,
|
||||||
deprecation: None,
|
deprecation: None,
|
||||||
inner: DefaultImplItem(DefaultImpl {
|
inner: AutoImplItem(AutoImpl {
|
||||||
unsafety: self.unsafety,
|
unsafety: self.unsafety,
|
||||||
trait_: self.trait_.clean(cx),
|
trait_: self.trait_.clean(cx),
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -44,7 +44,7 @@ pub struct Module {
|
||||||
pub stab: Option<attr::Stability>,
|
pub stab: Option<attr::Stability>,
|
||||||
pub depr: Option<attr::Deprecation>,
|
pub depr: Option<attr::Deprecation>,
|
||||||
pub impls: Vec<Impl>,
|
pub impls: Vec<Impl>,
|
||||||
pub def_traits: Vec<DefaultImpl>,
|
pub def_traits: Vec<AutoImpl>,
|
||||||
pub foreigns: Vec<hir::ForeignMod>,
|
pub foreigns: Vec<hir::ForeignMod>,
|
||||||
pub macros: Vec<Macro>,
|
pub macros: Vec<Macro>,
|
||||||
pub is_crate: bool,
|
pub is_crate: bool,
|
||||||
|
@ -227,7 +227,7 @@ pub struct Impl {
|
||||||
pub id: ast::NodeId,
|
pub id: ast::NodeId,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DefaultImpl {
|
pub struct AutoImpl {
|
||||||
pub unsafety: hir::Unsafety,
|
pub unsafety: hir::Unsafety,
|
||||||
pub trait_: hir::TraitRef,
|
pub trait_: hir::TraitRef,
|
||||||
pub id: ast::NodeId,
|
pub id: ast::NodeId,
|
||||||
|
|
|
@ -82,7 +82,7 @@ impl<'a> From<&'a clean::Item> for ItemType {
|
||||||
clean::PrimitiveItem(..) => ItemType::Primitive,
|
clean::PrimitiveItem(..) => ItemType::Primitive,
|
||||||
clean::AssociatedConstItem(..) => ItemType::AssociatedConst,
|
clean::AssociatedConstItem(..) => ItemType::AssociatedConst,
|
||||||
clean::AssociatedTypeItem(..) => ItemType::AssociatedType,
|
clean::AssociatedTypeItem(..) => ItemType::AssociatedType,
|
||||||
clean::DefaultImplItem(..) => ItemType::Impl,
|
clean::AutoImplItem(..) => ItemType::Impl,
|
||||||
clean::ForeignTypeItem => ItemType::ForeignType,
|
clean::ForeignTypeItem => ItemType::ForeignType,
|
||||||
clean::StrippedItem(..) => unreachable!(),
|
clean::StrippedItem(..) => unreachable!(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -1929,7 +1929,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
|
||||||
document(w, cx, item)?;
|
document(w, cx, item)?;
|
||||||
|
|
||||||
let mut indices = (0..items.len()).filter(|i| {
|
let mut indices = (0..items.len()).filter(|i| {
|
||||||
if let clean::DefaultImplItem(..) = items[*i].inner {
|
if let clean::AutoImplItem(..) = items[*i].inner {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
!items[*i].is_stripped()
|
!items[*i].is_stripped()
|
||||||
|
@ -3744,7 +3744,7 @@ fn sidebar_module(fmt: &mut fmt::Formatter, _it: &clean::Item,
|
||||||
ItemType::TyMethod, ItemType::Method, ItemType::StructField, ItemType::Variant,
|
ItemType::TyMethod, ItemType::Method, ItemType::StructField, ItemType::Variant,
|
||||||
ItemType::AssociatedType, ItemType::AssociatedConst, ItemType::ForeignType] {
|
ItemType::AssociatedType, ItemType::AssociatedConst, ItemType::ForeignType] {
|
||||||
if items.iter().any(|it| {
|
if items.iter().any(|it| {
|
||||||
if let clean::DefaultImplItem(..) = it.inner {
|
if let clean::AutoImplItem(..) = it.inner {
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
!it.is_stripped() && it.type_() == myty
|
!it.is_stripped() && it.type_() == myty
|
||||||
|
|
|
@ -116,7 +116,7 @@ impl<'a> fold::DocFolder for Stripper<'a> {
|
||||||
// handled in the `strip-priv-imports` pass
|
// handled in the `strip-priv-imports` pass
|
||||||
clean::ExternCrateItem(..) | clean::ImportItem(..) => {}
|
clean::ExternCrateItem(..) | clean::ImportItem(..) => {}
|
||||||
|
|
||||||
clean::DefaultImplItem(..) | clean::ImplItem(..) => {}
|
clean::AutoImplItem(..) | clean::ImplItem(..) => {}
|
||||||
|
|
||||||
// tymethods/macros have no control over privacy
|
// tymethods/macros have no control over privacy
|
||||||
clean::MacroItem(..) | clean::TyMethodItem(..) => {}
|
clean::MacroItem(..) | clean::TyMethodItem(..) => {}
|
||||||
|
|
|
@ -532,10 +532,10 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||||
om.impls.push(i);
|
om.impls.push(i);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
hir::ItemDefaultImpl(unsafety, ref trait_ref) => {
|
hir::ItemAutoImpl(unsafety, ref trait_ref) => {
|
||||||
// See comment above about ItemImpl.
|
// See comment above about ItemImpl.
|
||||||
if !self.inlining {
|
if !self.inlining {
|
||||||
let i = DefaultImpl {
|
let i = AutoImpl {
|
||||||
unsafety,
|
unsafety,
|
||||||
trait_: trait_ref.clone(),
|
trait_: trait_ref.clone(),
|
||||||
id: item.id,
|
id: item.id,
|
||||||
|
|
|
@ -1947,7 +1947,7 @@ pub enum ItemKind {
|
||||||
/// Auto trait implementation.
|
/// Auto trait implementation.
|
||||||
///
|
///
|
||||||
/// E.g. `impl Trait for .. {}` or `impl<T> Trait<T> for .. {}`
|
/// E.g. `impl Trait for .. {}` or `impl<T> Trait<T> for .. {}`
|
||||||
DefaultImpl(Unsafety, TraitRef),
|
AutoImpl(Unsafety, TraitRef),
|
||||||
/// An implementation.
|
/// An implementation.
|
||||||
///
|
///
|
||||||
/// E.g. `impl<A> Foo<A> { .. }` or `impl<A> Trait for Foo<A> { .. }`
|
/// E.g. `impl<A> Foo<A> { .. }` or `impl<A> Trait for Foo<A> { .. }`
|
||||||
|
@ -1986,7 +1986,7 @@ impl ItemKind {
|
||||||
ItemKind::Mac(..) |
|
ItemKind::Mac(..) |
|
||||||
ItemKind::MacroDef(..) |
|
ItemKind::MacroDef(..) |
|
||||||
ItemKind::Impl(..) |
|
ItemKind::Impl(..) |
|
||||||
ItemKind::DefaultImpl(..) => "item"
|
ItemKind::AutoImpl(..) => "item"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1357,10 +1357,10 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::ItemKind::DefaultImpl(..) => {
|
ast::ItemKind::AutoImpl(..) => {
|
||||||
gate_feature_post!(&self, optin_builtin_traits,
|
gate_feature_post!(&self, optin_builtin_traits,
|
||||||
i.span,
|
i.span,
|
||||||
"default trait implementations are experimental \
|
"auto trait implementations are experimental \
|
||||||
and possibly buggy");
|
and possibly buggy");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -908,8 +908,8 @@ pub fn noop_fold_item_kind<T: Folder>(i: ItemKind, folder: &mut T) -> ItemKind {
|
||||||
let generics = folder.fold_generics(generics);
|
let generics = folder.fold_generics(generics);
|
||||||
ItemKind::Union(folder.fold_variant_data(struct_def), generics)
|
ItemKind::Union(folder.fold_variant_data(struct_def), generics)
|
||||||
}
|
}
|
||||||
ItemKind::DefaultImpl(unsafety, ref trait_ref) => {
|
ItemKind::AutoImpl(unsafety, ref trait_ref) => {
|
||||||
ItemKind::DefaultImpl(unsafety, folder.fold_trait_ref((*trait_ref).clone()))
|
ItemKind::AutoImpl(unsafety, folder.fold_trait_ref((*trait_ref).clone()))
|
||||||
}
|
}
|
||||||
ItemKind::Impl(unsafety,
|
ItemKind::Impl(unsafety,
|
||||||
polarity,
|
polarity,
|
||||||
|
|
|
@ -5133,19 +5133,19 @@ impl<'a> Parser<'a> {
|
||||||
|
|
||||||
if opt_trait.is_some() && self.eat(&token::DotDot) {
|
if opt_trait.is_some() && self.eat(&token::DotDot) {
|
||||||
if generics.is_parameterized() {
|
if generics.is_parameterized() {
|
||||||
self.span_err(impl_span, "default trait implementations are not \
|
self.span_err(impl_span, "auto trait implementations are not \
|
||||||
allowed to have generics");
|
allowed to have generics");
|
||||||
}
|
}
|
||||||
|
|
||||||
if let ast::Defaultness::Default = defaultness {
|
if let ast::Defaultness::Default = defaultness {
|
||||||
self.span_err(impl_span, "`default impl` is not allowed for \
|
self.span_err(impl_span, "`default impl` is not allowed for \
|
||||||
default trait implementations");
|
auto trait implementations");
|
||||||
}
|
}
|
||||||
|
|
||||||
self.expect(&token::OpenDelim(token::Brace))?;
|
self.expect(&token::OpenDelim(token::Brace))?;
|
||||||
self.expect(&token::CloseDelim(token::Brace))?;
|
self.expect(&token::CloseDelim(token::Brace))?;
|
||||||
Ok((keywords::Invalid.ident(),
|
Ok((keywords::Invalid.ident(),
|
||||||
ItemKind::DefaultImpl(unsafety, opt_trait.unwrap()), None))
|
ItemKind::AutoImpl(unsafety, opt_trait.unwrap()), None))
|
||||||
} else {
|
} else {
|
||||||
if opt_trait.is_some() {
|
if opt_trait.is_some() {
|
||||||
ty = self.parse_ty()?;
|
ty = self.parse_ty()?;
|
||||||
|
|
|
@ -1287,7 +1287,7 @@ impl<'a> State<'a> {
|
||||||
self.head(&visibility_qualified(&item.vis, "union"))?;
|
self.head(&visibility_qualified(&item.vis, "union"))?;
|
||||||
self.print_struct(struct_def, generics, item.ident, item.span, true)?;
|
self.print_struct(struct_def, generics, item.ident, item.span, true)?;
|
||||||
}
|
}
|
||||||
ast::ItemKind::DefaultImpl(unsafety, ref trait_ref) => {
|
ast::ItemKind::AutoImpl(unsafety, ref trait_ref) => {
|
||||||
self.head("")?;
|
self.head("")?;
|
||||||
self.print_visibility(&item.vis)?;
|
self.print_visibility(&item.vis)?;
|
||||||
self.print_unsafety(unsafety)?;
|
self.print_unsafety(unsafety)?;
|
||||||
|
|
|
@ -281,7 +281,7 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
|
||||||
visitor.visit_generics(type_parameters);
|
visitor.visit_generics(type_parameters);
|
||||||
visitor.visit_enum_def(enum_definition, type_parameters, item.id, item.span)
|
visitor.visit_enum_def(enum_definition, type_parameters, item.id, item.span)
|
||||||
}
|
}
|
||||||
ItemKind::DefaultImpl(_, ref trait_ref) => {
|
ItemKind::AutoImpl(_, ref trait_ref) => {
|
||||||
visitor.visit_trait_ref(trait_ref)
|
visitor.visit_trait_ref(trait_ref)
|
||||||
}
|
}
|
||||||
ItemKind::Impl(_, _, _,
|
ItemKind::Impl(_, _, _,
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
trait MyTrait { fn foo() {} }
|
trait MyTrait { fn foo() {} }
|
||||||
|
|
||||||
impl MyTrait for .. {}
|
impl MyTrait for .. {}
|
||||||
//~^ ERROR redundant default implementations of trait `MyTrait`
|
//~^ ERROR redundant auto implementations of trait `MyTrait`
|
||||||
|
|
||||||
impl MyTrait for .. {}
|
impl MyTrait for .. {}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ trait DummyTrait {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DummyTrait for .. {}
|
impl DummyTrait for .. {}
|
||||||
//~^ ERROR default trait implementations are experimental and possibly buggy
|
//~^ ERROR auto trait implementations are experimental and possibly buggy
|
||||||
|
|
||||||
impl !DummyTrait for DummyStruct {}
|
impl !DummyTrait for DummyStruct {}
|
||||||
//~^ ERROR negative trait bounds are not yet fully implemented; use marker types for now
|
//~^ ERROR negative trait bounds are not yet fully implemented; use marker types for now
|
||||||
|
|
|
@ -14,6 +14,6 @@
|
||||||
trait Foo {}
|
trait Foo {}
|
||||||
|
|
||||||
default impl Foo for .. {}
|
default impl Foo for .. {}
|
||||||
//~^ ERROR `default impl` is not allowed for default trait implementations
|
//~^ ERROR `default impl` is not allowed for auto trait implementations
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
|
|
||||||
#![feature(optin_builtin_traits)]
|
#![feature(optin_builtin_traits)]
|
||||||
|
|
||||||
trait MyDefaultImpl {}
|
trait MyAutoImpl {}
|
||||||
|
|
||||||
impl<T> MyDefaultImpl for .. {}
|
impl<T> MyAutoImpl for .. {}
|
||||||
//~^ ERROR default trait implementations are not allowed to have generics
|
//~^ ERROR auto trait implementations are not allowed to have generics
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -249,7 +249,7 @@ trait TraitChangeMethodParametersOrder {
|
||||||
|
|
||||||
// Add default implementation to method -------------------------------------------
|
// Add default implementation to method -------------------------------------------
|
||||||
#[cfg(cfail1)]
|
#[cfg(cfail1)]
|
||||||
trait TraitAddMethodDefaultImplementation {
|
trait TraitAddMethodAutoImplementation {
|
||||||
fn method();
|
fn method();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ trait TraitAddMethodDefaultImplementation {
|
||||||
#[rustc_clean(label="Hir", cfg="cfail3")]
|
#[rustc_clean(label="Hir", cfg="cfail3")]
|
||||||
#[rustc_metadata_clean(cfg="cfail2")]
|
#[rustc_metadata_clean(cfg="cfail2")]
|
||||||
#[rustc_metadata_clean(cfg="cfail3")]
|
#[rustc_metadata_clean(cfg="cfail3")]
|
||||||
trait TraitAddMethodDefaultImplementation {
|
trait TraitAddMethodAutoImplementation {
|
||||||
#[rustc_dirty(label="Hir", cfg="cfail2")]
|
#[rustc_dirty(label="Hir", cfg="cfail2")]
|
||||||
#[rustc_clean(label="Hir", cfg="cfail3")]
|
#[rustc_clean(label="Hir", cfg="cfail3")]
|
||||||
#[rustc_metadata_dirty(cfg="cfail2")]
|
#[rustc_metadata_dirty(cfg="cfail2")]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue