[] SuperPredicatesOfItem(DefId),
[] TraitDefOfItem(DefId),
[] AdtDefOfItem(DefId),
- [] IsDefaultImpl(DefId),
+ [] IsAutoImpl(DefId),
[] ImplTraitRef(DefId),
[] ImplPolarity(DefId),
[] ClosureKind(DefId),
// 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)
}
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,
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(),
bodies: self.bodies,
body_ids,
trait_impls: self.trait_impls,
- trait_default_impl: self.trait_default_impl,
+ trait_auto_impl: self.trait_auto_impl,
}
}
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,
impl_items: _,
bodies: _,
trait_impls: _,
- trait_default_impl: _,
+ trait_auto_impl: _,
body_ids: _,
} = *krate;
// 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(..) =>
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
ItemUnion(..) => "union",
ItemTrait(..) => "trait",
ItemImpl(..) => "impl",
- ItemDefaultImpl(..) => "default impl",
+ ItemAutoImpl(..) => "default impl",
};
format!("{} {}{}", item_str, path_str(), id_str)
}
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
/// 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,
ItemUnion(..) => "union",
ItemTrait(..) => "trait",
ItemImpl(..) |
- ItemDefaultImpl(..) => "item",
+ ItemAutoImpl(..) => "item",
}
}
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)?;
hir::ItemForeignMod(..) |
hir::ItemGlobalAsm(..) |
hir::ItemMod(..) |
- hir::ItemDefaultImpl(..) |
+ hir::ItemAutoImpl(..) |
hir::ItemTrait(..) |
hir::ItemImpl(..) |
hir::ItemTy(..) |
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)
});
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);
}
}
hir::ItemStruct(..) |
hir::ItemUnion(..) |
hir::ItemTrait(..) |
- hir::ItemDefaultImpl(..) |
+ hir::ItemAutoImpl(..) |
hir::ItemImpl(..) => self.tcx.sess.codemap().def_span(item.span),
_ => item.span,
};
hir::ItemMod(..) | hir::ItemForeignMod(..) |
hir::ItemImpl(..) | hir::ItemTrait(..) |
hir::ItemStruct(..) | hir::ItemEnum(..) |
- hir::ItemUnion(..) | hir::ItemDefaultImpl(..) |
+ hir::ItemUnion(..) | hir::ItemAutoImpl(..) |
hir::ItemGlobalAsm(..) => {}
}
}
hir::ItemExternCrate(_) |
hir::ItemUse(..) |
hir::ItemMod(..) |
- hir::ItemDefaultImpl(..) |
+ hir::ItemAutoImpl(..) |
hir::ItemForeignMod(..) |
hir::ItemGlobalAsm(..) => {
// These sorts of items have no lifetime parameters at all.
/// 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
}
#[derive(Clone)]
-pub struct VtableDefaultImplData<N> {
+pub struct VtableAutoImplData<N> {
pub trait_def_id: DefId,
pub nested: Vec<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,
&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,
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(),
}),
// 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!(
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
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};
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.
}
}
ImplCandidate(def_id) => ImplCandidate(def_id),
- DefaultImplCandidate(def_id) => DefaultImplCandidate(def_id),
+ AutoImplCandidate(def_id) => AutoImplCandidate(def_id),
ProjectionCandidate => ProjectionCandidate,
FnPointerCandidate => FnPointerCandidate,
ObjectCandidate => ObjectCandidate,
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
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)
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
// 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()))
}
}
}
match other.candidate {
ObjectCandidate |
ParamCandidate(_) | ProjectionCandidate => match victim.candidate {
- DefaultImplCandidate(..) => {
+ AutoImplCandidate(..) => {
bug!(
"default implementations shouldn't be recorded \
when there are other valid candidates");
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) => {
///
/// 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(
obligations.extend(trait_obligations);
- debug!("vtable_default_impl: obligations={:?}", obligations);
+ debug!("vtable_auto_impl: obligations={:?}", obligations);
- VtableDefaultImplData {
+ VtableAutoImplData {
trait_def_id,
nested: obligations
}
super::VtableImpl(ref v) =>
write!(f, "{:?}", v),
- super::VtableDefaultImpl(ref t) =>
+ super::VtableAutoImpl(ref t) =>
write!(f, "{:?}", t),
super::VtableClosure(ref d) =>
}
}
-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)
}
})
})
}
- traits::VtableDefaultImpl(t) => Some(traits::VtableDefaultImpl(t)),
+ traits::VtableAutoImpl(t) => Some(traits::VtableAutoImpl(t)),
traits::VtableGenerator(traits::VtableGeneratorData {
closure_def_id,
substs,
}
}
-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),
}
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))
}
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),
None
}
}
- traits::VtableDefaultImpl(..) | traits::VtableParam(..) => None
+ traits::VtableAutoImpl(..) | traits::VtableParam(..) => None
}
}
// 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
/// 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.
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!()); }
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> {
/// 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.
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,
}
}
hir::ItemUnion(..) |
hir::ItemTrait(..) |
hir::ItemImpl(..) |
- hir::ItemDefaultImpl(..) => None,
+ hir::ItemAutoImpl(..) => None,
hir::ItemMod(ref m) => search_mod(this, m, idx, names),
};
#[derive(PartialEq)]
pub enum MethodLateContext {
- TraitDefaultImpl,
+ TraitAutoImpl,
TraitImpl,
PlainImpl,
}
let def_id = cx.tcx.hir.local_def_id(id);
let item = cx.tcx.associated_item(def_id);
match item.container {
- ty::TraitContainer(..) => MethodLateContext::TraitDefaultImpl,
+ ty::TraitContainer(..) => MethodLateContext::TraitAutoImpl,
ty::ImplContainer(cid) => {
match cx.tcx.impl_trait_ref(cid) {
Some(_) => MethodLateContext::TraitImpl,
MethodLateContext::PlainImpl => {
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))
}
_ => (),
inherent_impls => { Rc::new(cdata.get_inherent_implementations_for_type(def_id.index)) }
is_const_fn => { cdata.is_const_fn(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) }
def_span => { cdata.get_span(def_id.index, &tcx.sess) }
lookup_stability => {
EntryKind::ForeignMod |
EntryKind::Impl(_) |
- EntryKind::DefaultImpl(_) |
+ EntryKind::AutoImpl(_) |
EntryKind::Field |
EntryKind::Generator(_) |
EntryKind::Closure(_) => return None,
ty::TraitDef::new(self.local_def_id(item_id),
data.unsafety,
data.paren_sugar,
- data.has_default_impl,
+ data.has_auto_impl,
self.def_path_table.def_path_hash(item_id))
}
continue;
}
EntryKind::Impl(_) |
- EntryKind::DefaultImpl(_) => continue,
+ EntryKind::AutoImpl(_) => continue,
_ => {}
}
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 {
- EntryKind::DefaultImpl(_) => true,
+ EntryKind::AutoImpl(_) => true,
_ => false,
}
}
ctor_sig: None,
}), repr_options)
}
- hir::ItemDefaultImpl(..) => {
+ hir::ItemAutoImpl(..) => {
let data = ImplData {
polarity: hir::ImplPolarity::Positive,
defaultness: hir::Defaultness::Final,
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, ..) => {
let trait_ref = tcx.impl_trait_ref(def_id);
let data = TraitData {
unsafety: trait_def.unsafety,
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)),
};
hir::ItemGlobalAsm(..) |
hir::ItemExternCrate(..) |
hir::ItemUse(..) |
- hir::ItemDefaultImpl(..) |
+ hir::ItemAutoImpl(..) |
hir::ItemTy(..) => {
// no sub-item recording needed in these cases
}
Generator(Lazy<GeneratorData<'tcx>>),
Trait(Lazy<TraitData<'tcx>>),
Impl(Lazy<ImplData<'tcx>>),
- DefaultImpl(Lazy<ImplData<'tcx>>),
+ AutoImpl(Lazy<ImplData<'tcx>>),
Method(Lazy<MethodData<'tcx>>),
AssociatedType(AssociatedContainer),
AssociatedConst(AssociatedContainer, u8),
EntryKind::Trait(ref trait_data) => {
trait_data.hash_stable(hcx, hasher);
}
- EntryKind::DefaultImpl(ref impl_data) |
+ EntryKind::AutoImpl(ref impl_data) |
EntryKind::Impl(ref impl_data) => {
impl_data.hash_stable(hcx, hasher);
}
pub struct TraitData<'tcx> {
pub unsafety: hir::Unsafety,
pub paren_sugar: bool,
- pub has_default_impl: bool,
+ pub has_auto_impl: bool,
pub super_predicates: Lazy<ty::GenericPredicates<'tcx>>,
}
impl_stable_hash_for!(struct TraitData<'tcx> {
unsafety,
paren_sugar,
- has_default_impl,
+ has_auto_impl,
super_predicates
});
item.span,
Some("place qualifiers on individual impl items instead"));
}
- ItemKind::DefaultImpl(..) => {
+ ItemKind::AutoImpl(..) => {
self.invalid_visibility(&item.vis, item.span, None);
}
ItemKind::ForeignMod(..) => {
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))
}
- hir::ItemDefaultImpl(..) => {
+ hir::ItemAutoImpl(..) => {
let def_id = self.tcx.hir.local_def_id(item.id);
self.impl_trait_level(def_id)
}
}
hir::ItemUse(..) | hir::ItemStatic(..) | hir::ItemConst(..) |
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
// Reexports are handled in visit_mod
hir::ItemUse(..) => {}
// The interface is empty
- hir::ItemDefaultImpl(..) => {}
+ hir::ItemAutoImpl(..) => {}
// The interface is empty
hir::ItemGlobalAsm(..) => {}
// Visit everything
}
}
// The interface is empty
- hir::ItemDefaultImpl(..) => {}
+ hir::ItemAutoImpl(..) => {}
// An inherent impl is public when its type is public
// Subitems of inherent impls have their own publicity
hir::ItemImpl(.., None, _, ref impl_item_refs) => {
self.insert_field_names(item_def_id, field_names);
}
- ItemKind::DefaultImpl(..) | ItemKind::Impl(..) => {}
+ ItemKind::AutoImpl(..) | ItemKind::Impl(..) => {}
ItemKind::Trait(..) => {
let def_id = self.definitions.local_def_id(item.id);
|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, _| {
// Resolve type arguments in trait path
visit::walk_trait_ref(this, trait_ref);
Ok(sig)
}
- ast::ItemKind::DefaultImpl(unsafety, ref trait_ref) => {
+ ast::ItemKind::AutoImpl(unsafety, ref trait_ref) => {
let mut text = String::new();
if unsafety == ast::Unsafety::Unsafe {
text.push_str("unsafe ");
hir::ItemUse(..) |
hir::ItemForeignMod(..) |
hir::ItemTy(..) |
- hir::ItemDefaultImpl(..) |
+ hir::ItemAutoImpl(..) |
hir::ItemTrait(..) |
hir::ItemMod(..) => {
// Nothing to do, just keep recursing...
// 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();
- 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);
}
}
fn check_trait(&mut self, item: &hir::Item) {
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);
}
unsafety::check(tcx);
orphan::check(tcx);
- overlap::check_default_impls(tcx);
+ overlap::check_auto_impls(tcx);
// these queries are executed for side-effects (error reporting):
tcx.crate_inherent_impls(LOCAL_CRATE);
// This final impl is legal according to the orpan
// rules, but it invalidates the reasoning from
// `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_def_id,
- self.tcx.trait_has_default_impl(trait_def_id));
- if self.tcx.trait_has_default_impl(trait_def_id) &&
+ self.tcx.trait_has_auto_impl(trait_def_id));
+ if self.tcx.trait_has_auto_impl(trait_def_id) &&
!trait_def_id.is_local() {
let self_ty = trait_ref.self_ty();
let opt_self_def_id = match self_ty.sty {
}
}
}
- hir::ItemDefaultImpl(_, ref item_trait_ref) => {
+ hir::ItemAutoImpl(_, ref item_trait_ref) => {
// "Trait" impl
debug!("coherence2::orphan check: default trait impl {}",
self.tcx.hir.node_to_string(item.id));
use rustc::hir;
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 };
// this secondary walk specifically checks for some other cases,
impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OverlapChecker<'cx, 'tcx> {
fn visit_item(&mut self, item: &'v hir::Item) {
match item.node {
- hir::ItemDefaultImpl(..) => {
- // look for another default impl; note that due to the
+ hir::ItemAutoImpl(..) => {
+ // look for another auto impl; note that due to the
// general orphan/coherence rules, it must always be
// in this crate.
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 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 {
let mut err = struct_span_err!(self.tcx.sess,
self.tcx.span_of_impl(impl_def_id).unwrap(),
E0521,
- "redundant default implementations of trait \
+ "redundant auto implementations of trait \
`{}`:",
trait_ref);
err.span_note(self.tcx
impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for UnsafetyChecker<'cx, 'tcx> {
fn visit_item(&mut self, item: &'v hir::Item) {
match item.node {
- hir::ItemDefaultImpl(unsafety, _) => {
+ hir::ItemAutoImpl(unsafety, _) => {
self.check_unsafety_coherence(item, None, unsafety, hir::ImplPolarity::Positive);
}
hir::ItemImpl(unsafety, polarity, _, ref generics, ..) => {
impl_trait_ref,
impl_polarity,
is_foreign_item,
- is_default_impl,
+ is_auto_impl,
..*providers
};
}
tcx.predicates_of(def_id);
convert_enum_variant_types(tcx, def_id, &enum_definition.variants);
},
- hir::ItemDefaultImpl(..) => {
+ hir::ItemAutoImpl(..) => {
tcx.impl_trait_ref(def_id);
}
hir::ItemImpl(..) => {
}
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,
unsafety,
paren_sugar,
- has_default_impl,
+ has_auto_impl,
def_path_hash);
tcx.alloc_trait_def(def)
}
let substs = Substs::identity_for_item(tcx, def_id);
tcx.mk_adt(def, substs)
}
- ItemDefaultImpl(..) |
+ ItemAutoImpl(..) |
ItemTrait(..) |
ItemMod(..) |
ItemForeignMod(..) |
let node_id = tcx.hir.as_local_node_id(def_id).unwrap();
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,
ast_trait_ref,
tcx.mk_self_type()))
}
}
-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)
-> bool {
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,
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)
}
}
// E0372, // coherence not object safe
E0377, // the trait `CoerceUnsized` may only be implemented for a coercion
// 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
// E0563, // cannot determine a type for this `impl Trait`: {} // removed in 6383de15
E0564, // only named lifetimes are allowed in `impl Trait`,
}
}
- // If this is a defaulted impl, then bail out early here
- if tcx.is_default_impl(did) {
+ // If this is an auto impl, then bail out early here
+ if tcx.is_auto_impl(did) {
return ret.push(clean::Item {
- inner: clean::DefaultImplItem(clean::DefaultImpl {
+ inner: clean::AutoImplItem(clean::AutoImpl {
// FIXME: this should be decoded
unsafety: hir::Unsafety::Normal,
trait_: match associated_trait.as_ref().unwrap().clean(cx) {
PrimitiveItem(PrimitiveType),
AssociatedConstItem(Type, Option<String>),
AssociatedTypeItem(Vec<TyParamBound>, Option<Type>),
- DefaultImplItem(DefaultImpl),
+ AutoImplItem(AutoImpl),
/// An item that has been stripped by a rustdoc pass
StrippedItem(Box<ItemEnum>),
}
}
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
-pub struct DefaultImpl {
+pub struct AutoImpl {
pub unsafety: hir::Unsafety,
pub trait_: Type,
}
-impl Clean<Item> for doctree::DefaultImpl {
+impl Clean<Item> for doctree::AutoImpl {
fn clean(&self, cx: &DocContext) -> Item {
Item {
name: None,
visibility: Some(Public),
stability: None,
deprecation: None,
- inner: DefaultImplItem(DefaultImpl {
+ inner: AutoImplItem(AutoImpl {
unsafety: self.unsafety,
trait_: self.trait_.clean(cx),
}),
pub stab: Option<attr::Stability>,
pub depr: Option<attr::Deprecation>,
pub impls: Vec<Impl>,
- pub def_traits: Vec<DefaultImpl>,
+ pub def_traits: Vec<AutoImpl>,
pub foreigns: Vec<hir::ForeignMod>,
pub macros: Vec<Macro>,
pub is_crate: bool,
pub id: ast::NodeId,
}
-pub struct DefaultImpl {
+pub struct AutoImpl {
pub unsafety: hir::Unsafety,
pub trait_: hir::TraitRef,
pub id: ast::NodeId,
clean::PrimitiveItem(..) => ItemType::Primitive,
clean::AssociatedConstItem(..) => ItemType::AssociatedConst,
clean::AssociatedTypeItem(..) => ItemType::AssociatedType,
- clean::DefaultImplItem(..) => ItemType::Impl,
+ clean::AutoImplItem(..) => ItemType::Impl,
clean::ForeignTypeItem => ItemType::ForeignType,
clean::StrippedItem(..) => unreachable!(),
}
document(w, cx, item)?;
let mut indices = (0..items.len()).filter(|i| {
- if let clean::DefaultImplItem(..) = items[*i].inner {
+ if let clean::AutoImplItem(..) = items[*i].inner {
return false;
}
!items[*i].is_stripped()
ItemType::TyMethod, ItemType::Method, ItemType::StructField, ItemType::Variant,
ItemType::AssociatedType, ItemType::AssociatedConst, ItemType::ForeignType] {
if items.iter().any(|it| {
- if let clean::DefaultImplItem(..) = it.inner {
+ if let clean::AutoImplItem(..) = it.inner {
false
} else {
!it.is_stripped() && it.type_() == myty
// handled in the `strip-priv-imports` pass
clean::ExternCrateItem(..) | clean::ImportItem(..) => {}
- clean::DefaultImplItem(..) | clean::ImplItem(..) => {}
+ clean::AutoImplItem(..) | clean::ImplItem(..) => {}
// tymethods/macros have no control over privacy
clean::MacroItem(..) | clean::TyMethodItem(..) => {}
om.impls.push(i);
}
},
- hir::ItemDefaultImpl(unsafety, ref trait_ref) => {
+ hir::ItemAutoImpl(unsafety, ref trait_ref) => {
// See comment above about ItemImpl.
if !self.inlining {
- let i = DefaultImpl {
+ let i = AutoImpl {
unsafety,
trait_: trait_ref.clone(),
id: item.id,
/// Auto trait implementation.
///
/// E.g. `impl Trait for .. {}` or `impl<T> Trait<T> for .. {}`
- DefaultImpl(Unsafety, TraitRef),
+ AutoImpl(Unsafety, TraitRef),
/// An implementation.
///
/// E.g. `impl<A> Foo<A> { .. }` or `impl<A> Trait for Foo<A> { .. }`
ItemKind::Mac(..) |
ItemKind::MacroDef(..) |
ItemKind::Impl(..) |
- ItemKind::DefaultImpl(..) => "item"
+ ItemKind::AutoImpl(..) => "item"
}
}
}
}
}
- ast::ItemKind::DefaultImpl(..) => {
+ ast::ItemKind::AutoImpl(..) => {
gate_feature_post!(&self, optin_builtin_traits,
i.span,
- "default trait implementations are experimental \
+ "auto trait implementations are experimental \
and possibly buggy");
}
let generics = folder.fold_generics(generics);
ItemKind::Union(folder.fold_variant_data(struct_def), generics)
}
- ItemKind::DefaultImpl(unsafety, ref trait_ref) => {
- ItemKind::DefaultImpl(unsafety, folder.fold_trait_ref((*trait_ref).clone()))
+ ItemKind::AutoImpl(unsafety, ref trait_ref) => {
+ ItemKind::AutoImpl(unsafety, folder.fold_trait_ref((*trait_ref).clone()))
}
ItemKind::Impl(unsafety,
polarity,
if opt_trait.is_some() && self.eat(&token::DotDot) {
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");
}
if let ast::Defaultness::Default = defaultness {
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::CloseDelim(token::Brace))?;
Ok((keywords::Invalid.ident(),
- ItemKind::DefaultImpl(unsafety, opt_trait.unwrap()), None))
+ ItemKind::AutoImpl(unsafety, opt_trait.unwrap()), None))
} else {
if opt_trait.is_some() {
ty = self.parse_ty()?;
self.head(&visibility_qualified(&item.vis, "union"))?;
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.print_visibility(&item.vis)?;
self.print_unsafety(unsafety)?;
visitor.visit_generics(type_parameters);
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)
}
ItemKind::Impl(_, _, _,
trait MyTrait { fn foo() {} }
impl MyTrait for .. {}
-//~^ ERROR redundant default implementations of trait `MyTrait`
+//~^ ERROR redundant auto implementations of trait `MyTrait`
impl MyTrait 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 {}
//~^ ERROR negative trait bounds are not yet fully implemented; use marker types for now
trait Foo {}
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() {}
#![feature(optin_builtin_traits)]
-trait MyDefaultImpl {}
+trait MyAutoImpl {}
-impl<T> MyDefaultImpl for .. {}
-//~^ ERROR default trait implementations are not allowed to have generics
+impl<T> MyAutoImpl for .. {}
+//~^ ERROR auto trait implementations are not allowed to have generics
fn main() {}
// Add default implementation to method -------------------------------------------
#[cfg(cfail1)]
-trait TraitAddMethodDefaultImplementation {
+trait TraitAddMethodAutoImplementation {
fn method();
}
#[rustc_clean(label="Hir", cfg="cfail3")]
#[rustc_metadata_clean(cfg="cfail2")]
#[rustc_metadata_clean(cfg="cfail3")]
-trait TraitAddMethodDefaultImplementation {
+trait TraitAddMethodAutoImplementation {
#[rustc_dirty(label="Hir", cfg="cfail2")]
#[rustc_clean(label="Hir", cfg="cfail3")]
#[rustc_metadata_dirty(cfg="cfail2")]