Skip to content

Rollup of 9 pull requests #61198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
274b7e4
Suggest borrowing for loop head on move error
estebank May 25, 2019
0b7d4fa
Rename "Associated*" to "Assoc*"
agnxy May 19, 2019
fd19989
Fix spelling in release notes
aristocles-deploy May 25, 2019
72145ea
MaybeUninit doctest: remove unnecessary type ascription
RalfJung May 25, 2019
9d82826
add test checking that Vec push/pop does not invalidate pointers
RalfJung May 25, 2019
428ab7e
shadow as_ptr as as_mut_ptr in Vec to avoid going through Deref
RalfJung May 25, 2019
a5e9d82
Auto-derive Encode and Decode implementations
fabric-and-ink May 25, 2019
9bfbbd2
Add additional trace statements to the const propagator
wesleywiser May 25, 2019
9765418
Tweak `self` arg not as first argument of a method diagnostic
estebank May 23, 2019
d1364d5
Move some methods to `diagnostics.rs` away from `parser.rs`
estebank May 23, 2019
4e68ddc
review comments: move back some methods and clean up wording
estebank May 23, 2019
e6aa4b8
Add comment to explain why we change the layout for Projection
spastorino May 25, 2019
f1fd063
Rollup merge of #60955 - agnxy:rename-assoc, r=oli-obk,Centril
Centril May 25, 2019
e6e0aff
Rollup merge of #61087 - estebank:parsepalooza, r=Centril
Centril May 25, 2019
f9818b7
Rollup merge of #61114 - RalfJung:vec, r=Gankro
Centril May 25, 2019
22c95b6
Rollup merge of #61144 - estebank:issue-61108, r=matthewjasper
Centril May 25, 2019
f405a25
Rollup merge of #61149 - vishalsodani:master, r=Centril
Centril May 25, 2019
1756efe
Rollup merge of #61161 - RalfJung:maybe-uninit, r=Centril
Centril May 25, 2019
fdd6d0d
Rollup merge of #61173 - fabric-and-ink:minor-cleanup, r=varkor
Centril May 25, 2019
6f52767
Rollup merge of #61184 - wesleywiser:const_prop_tracing, r=oli-obk
Centril May 25, 2019
c2877ca
Rollup merge of #61193 - spastorino:add-comment, r=RalfJung
Centril May 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename "Associated*" to "Assoc*"
We are going to uniform the terminology of all associated items.
Methods that may or may not have `self` are called "associated
functions". Because `AssociatedFn` is a bit long, we rename `Associated`
to `Assoc`.
  • Loading branch information
agnxy committed May 25, 2019
commit 0b7d4fa4a84653f81ed63f8491dd8cc1dd67037e
18 changes: 9 additions & 9 deletions src/librustc/hir/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ pub enum DefKind {
TyAlias,
ForeignTy,
TraitAlias,
AssociatedTy,
AssocTy,
/// `existential type Foo: Bar;`
AssociatedExistential,
AssocExistential,
TyParam,

// Value namespace
Expand All @@ -74,7 +74,7 @@ pub enum DefKind {
/// Refers to the struct or enum variant's constructor.
Ctor(CtorOf, CtorKind),
Method,
AssociatedConst,
AssocConst,

// Macro namespace
Macro(MacroKind),
Expand All @@ -99,14 +99,14 @@ impl DefKind {
DefKind::Existential => "existential type",
DefKind::TyAlias => "type alias",
DefKind::TraitAlias => "trait alias",
DefKind::AssociatedTy => "associated type",
DefKind::AssociatedExistential => "associated existential type",
DefKind::AssocTy => "associated type",
DefKind::AssocExistential => "associated existential type",
DefKind::Union => "union",
DefKind::Trait => "trait",
DefKind::ForeignTy => "foreign type",
DefKind::Method => "method",
DefKind::Const => "constant",
DefKind::AssociatedConst => "associated constant",
DefKind::AssocConst => "associated constant",
DefKind::TyParam => "type parameter",
DefKind::ConstParam => "const parameter",
DefKind::Macro(macro_kind) => macro_kind.descr(),
Expand All @@ -116,9 +116,9 @@ impl DefKind {
/// An English article for the def.
pub fn article(&self) -> &'static str {
match *self {
DefKind::AssociatedTy
| DefKind::AssociatedConst
| DefKind::AssociatedExistential
DefKind::AssocTy
| DefKind::AssocConst
| DefKind::AssocExistential
| DefKind::Enum
| DefKind::Existential => "an",
DefKind::Macro(macro_kind) => macro_kind.article(),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/hir/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ pub trait Visitor<'v> : Sized {
fn visit_vis(&mut self, vis: &'v Visibility) {
walk_vis(self, vis)
}
fn visit_associated_item_kind(&mut self, kind: &'v AssociatedItemKind) {
fn visit_associated_item_kind(&mut self, kind: &'v AssocItemKind) {
walk_associated_item_kind(self, kind);
}
fn visit_defaultness(&mut self, defaultness: &'v Defaultness) {
Expand Down Expand Up @@ -1120,7 +1120,7 @@ pub fn walk_vis<'v, V: Visitor<'v>>(visitor: &mut V, vis: &'v Visibility) {
}
}

pub fn walk_associated_item_kind<'v, V: Visitor<'v>>(_: &mut V, _: &'v AssociatedItemKind) {
pub fn walk_associated_item_kind<'v, V: Visitor<'v>>(_: &mut V, _: &'v AssocItemKind) {
// No visitable content here: this fn exists so you can call it if
// the right thing to do, should content be added in the future,
// would be to walk it.
Expand Down
20 changes: 10 additions & 10 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1862,7 +1862,7 @@ impl<'a> LoweringContext<'a> {
index: this.def_key(def_id).parent.expect("missing parent"),
};
let type_def_id = match partial_res.base_res() {
Res::Def(DefKind::AssociatedTy, def_id) if i + 2 == proj_start => {
Res::Def(DefKind::AssocTy, def_id) if i + 2 == proj_start => {
Some(parent_def_id(self, def_id))
}
Res::Def(DefKind::Variant, def_id) if i + 1 == proj_start => {
Expand All @@ -1884,8 +1884,8 @@ impl<'a> LoweringContext<'a> {
if i + 1 == proj_start => ParenthesizedGenericArgs::Ok,
// `a::b::Trait(Args)::TraitItem`
Res::Def(DefKind::Method, _)
| Res::Def(DefKind::AssociatedConst, _)
| Res::Def(DefKind::AssociatedTy, _)
| Res::Def(DefKind::AssocConst, _)
| Res::Def(DefKind::AssocTy, _)
if i + 2 == proj_start =>
{
ParenthesizedGenericArgs::Ok
Expand Down Expand Up @@ -3591,13 +3591,13 @@ impl<'a> LoweringContext<'a> {
fn lower_trait_item_ref(&mut self, i: &TraitItem) -> hir::TraitItemRef {
let (kind, has_default) = match i.node {
TraitItemKind::Const(_, ref default) => {
(hir::AssociatedItemKind::Const, default.is_some())
(hir::AssocItemKind::Const, default.is_some())
}
TraitItemKind::Type(_, ref default) => {
(hir::AssociatedItemKind::Type, default.is_some())
(hir::AssocItemKind::Type, default.is_some())
}
TraitItemKind::Method(ref sig, ref default) => (
hir::AssociatedItemKind::Method {
hir::AssocItemKind::Method {
has_self: sig.decl.has_self(),
},
default.is_some(),
Expand Down Expand Up @@ -3697,10 +3697,10 @@ impl<'a> LoweringContext<'a> {
vis: self.lower_visibility(&i.vis, Some(i.id)),
defaultness: self.lower_defaultness(i.defaultness, true /* [1] */),
kind: match i.node {
ImplItemKind::Const(..) => hir::AssociatedItemKind::Const,
ImplItemKind::Type(..) => hir::AssociatedItemKind::Type,
ImplItemKind::Existential(..) => hir::AssociatedItemKind::Existential,
ImplItemKind::Method(ref sig, _) => hir::AssociatedItemKind::Method {
ImplItemKind::Const(..) => hir::AssocItemKind::Const,
ImplItemKind::Type(..) => hir::AssocItemKind::Type,
ImplItemKind::Existential(..) => hir::AssocItemKind::Existential,
ImplItemKind::Method(ref sig, _) => hir::AssocItemKind::Method {
has_self: sig.decl.has_self(),
},
ImplItemKind::Macro(..) => unimplemented!(),
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,17 +337,17 @@ impl<'hir> Map<'hir> {
}
Node::TraitItem(item) => {
match item.node {
TraitItemKind::Const(..) => DefKind::AssociatedConst,
TraitItemKind::Const(..) => DefKind::AssocConst,
TraitItemKind::Method(..) => DefKind::Method,
TraitItemKind::Type(..) => DefKind::AssociatedTy,
TraitItemKind::Type(..) => DefKind::AssocTy,
}
}
Node::ImplItem(item) => {
match item.node {
ImplItemKind::Const(..) => DefKind::AssociatedConst,
ImplItemKind::Const(..) => DefKind::AssocConst,
ImplItemKind::Method(..) => DefKind::Method,
ImplItemKind::Type(..) => DefKind::AssociatedTy,
ImplItemKind::Existential(..) => DefKind::AssociatedExistential,
ImplItemKind::Type(..) => DefKind::AssocTy,
ImplItemKind::Existential(..) => DefKind::AssocExistential,
}
}
Node::Variant(_) => DefKind::Variant,
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2422,7 +2422,7 @@ pub struct TraitItemRef {
pub id: TraitItemId,
#[stable_hasher(project(name))]
pub ident: Ident,
pub kind: AssociatedItemKind,
pub kind: AssocItemKind,
pub span: Span,
pub defaultness: Defaultness,
}
Expand All @@ -2438,14 +2438,14 @@ pub struct ImplItemRef {
pub id: ImplItemId,
#[stable_hasher(project(name))]
pub ident: Ident,
pub kind: AssociatedItemKind,
pub kind: AssocItemKind,
pub span: Span,
pub vis: Visibility,
pub defaultness: Defaultness,
}

#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable)]
pub enum AssociatedItemKind {
pub enum AssocItemKind {
Const,
Method { has_self: bool },
Type,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
fn handle_res(&mut self, res: Res) {
match res {
Res::Def(DefKind::Const, _)
| Res::Def(DefKind::AssociatedConst, _)
| Res::Def(DefKind::AssocConst, _)
| Res::Def(DefKind::TyAlias, _) => {
self.check_def_id(res.def_id());
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/expr_use_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
| Res::Def(DefKind::Ctor(..), _)
| Res::Def(DefKind::Union, _)
| Res::Def(DefKind::TyAlias, _)
| Res::Def(DefKind::AssociatedTy, _)
| Res::Def(DefKind::AssocTy, _)
| Res::SelfTy(..) => {
debug!("struct cmt_pat={:?} pat={:?}", cmt_pat, pat);
delegate.matched_pat(pat, &cmt_pat, match_mode);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/mem_categorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
Res::Def(DefKind::Ctor(..), _)
| Res::Def(DefKind::Const, _)
| Res::Def(DefKind::ConstParam, _)
| Res::Def(DefKind::AssociatedConst, _)
| Res::Def(DefKind::AssocConst, _)
| Res::Def(DefKind::Fn, _)
| Res::Def(DefKind::Method, _)
| Res::SelfCtor(..) => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/reachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> {
// If this path leads to a constant, then we need to
// recurse into the constant to continue finding
// items that are reachable.
Res::Def(DefKind::Const, _) | Res::Def(DefKind::AssociatedConst, _) => {
Res::Def(DefKind::Const, _) | Res::Def(DefKind::AssocConst, _) => {
self.worklist.push(hir_id);
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/resolve_lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1924,7 +1924,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
}
};
let type_def_id = match res {
Res::Def(DefKind::AssociatedTy, def_id)
Res::Def(DefKind::AssocTy, def_id)
if depth == 1 => Some(parent_def_id(self, def_id)),
Res::Def(DefKind::Variant, def_id)
if depth == 0 => Some(parent_def_id(self, def_id)),
Expand Down Expand Up @@ -2112,7 +2112,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
};

let has_self = match assoc_item_kind {
Some(hir::AssociatedItemKind::Method { has_self }) => has_self,
Some(hir::AssocItemKind::Method { has_self }) => has_self,
_ => false,
};

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
// Check if `def_id` is a trait method.
match self.def_kind(def_id) {
Some(DefKind::Method) |
Some(DefKind::AssociatedTy) |
Some(DefKind::AssociatedConst) => {
Some(DefKind::AssocTy) |
Some(DefKind::AssocConst) => {
if let ty::TraitContainer(trait_def_id) = self.associated_item(def_id).container {
// Trait methods do not declare visibility (even
// for visibility info in cstore). Use containing
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ rustc_queries! {
query associated_item_def_ids(_: DefId) -> &'tcx [DefId] {}

/// Maps from a trait item to the trait item "descriptor".
query associated_item(_: DefId) -> ty::AssociatedItem {}
query associated_item(_: DefId) -> ty::AssocItem {}

query impl_trait_ref(_: DefId) -> Option<ty::TraitRef<'tcx>> {}
query impl_polarity(_: DefId) -> hir::ImplPolarity {}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ fn vtable_methods<'a, 'tcx>(
tcx.arena.alloc_from_iter(
supertraits(tcx, trait_ref).flat_map(move |trait_ref| {
let trait_methods = tcx.associated_items(trait_ref.def_id())
.filter(|item| item.kind == ty::AssociatedKind::Method);
.filter(|item| item.kind == ty::AssocKind::Method);

// Now list each method's DefId and InternalSubsts (for within its trait).
// If the method can never be called from this object, produce None.
Expand Down
20 changes: 10 additions & 10 deletions src/librustc/traits/object_safety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub enum ObjectSafetyViolation {
Method(ast::Name, MethodViolationCode),

/// Associated const.
AssociatedConst(ast::Name),
AssocConst(ast::Name),
}

impl ObjectSafetyViolation {
Expand All @@ -58,7 +58,7 @@ impl ObjectSafetyViolation {
format!("method `{}` has generic type parameters", name).into(),
ObjectSafetyViolation::Method(name, MethodViolationCode::UndispatchableReceiver) =>
format!("method `{}`'s receiver cannot be dispatched on", name).into(),
ObjectSafetyViolation::AssociatedConst(name) =>
ObjectSafetyViolation::AssocConst(name) =>
format!("the trait cannot contain associated consts like `{}`", name).into(),
}
}
Expand Down Expand Up @@ -119,7 +119,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
{
// Check methods for violations.
let mut violations: Vec<_> = self.associated_items(trait_def_id)
.filter(|item| item.kind == ty::AssociatedKind::Method)
.filter(|item| item.kind == ty::AssocKind::Method)
.filter_map(|item|
self.object_safety_violation_for_method(trait_def_id, &item)
.map(|code| ObjectSafetyViolation::Method(item.ident.name, code))
Expand Down Expand Up @@ -151,8 +151,8 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
}

violations.extend(self.associated_items(trait_def_id)
.filter(|item| item.kind == ty::AssociatedKind::Const)
.map(|item| ObjectSafetyViolation::AssociatedConst(item.ident.name)));
.filter(|item| item.kind == ty::AssocKind::Const)
.map(|item| ObjectSafetyViolation::AssocConst(item.ident.name)));

debug!("object_safety_violations_for_trait(trait_def_id={:?}) = {:?}",
trait_def_id,
Expand Down Expand Up @@ -251,7 +251,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
/// Returns `Some(_)` if this method makes the containing trait not object safe.
fn object_safety_violation_for_method(self,
trait_def_id: DefId,
method: &ty::AssociatedItem)
method: &ty::AssocItem)
-> Option<MethodViolationCode>
{
debug!("object_safety_violation_for_method({:?}, {:?})", trait_def_id, method);
Expand All @@ -270,7 +270,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
/// otherwise ensure that they cannot be used when `Self=Trait`.
pub fn is_vtable_safe_method(self,
trait_def_id: DefId,
method: &ty::AssociatedItem)
method: &ty::AssocItem)
-> bool
{
debug!("is_vtable_safe_method({:?}, {:?})", trait_def_id, method);
Expand All @@ -291,7 +291,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
/// `Self:Sized`.
fn virtual_call_violation_for_method(self,
trait_def_id: DefId,
method: &ty::AssociatedItem)
method: &ty::AssocItem)
-> Option<MethodViolationCode>
{
// The method's first parameter must be named `self`
Expand Down Expand Up @@ -439,7 +439,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
self.associated_items(super_trait_ref.def_id())
.map(move |item| (super_trait_ref, item))
})
.filter(|(_, item)| item.kind == ty::AssociatedKind::Type)
.filter(|(_, item)| item.kind == ty::AssocKind::Type)
.collect::<Vec<_>>();

// existential predicates need to be in a specific order
Expand Down Expand Up @@ -520,7 +520,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
#[allow(dead_code)]
fn receiver_is_dispatchable(
self,
method: &ty::AssociatedItem,
method: &ty::AssocItem,
receiver_ty: Ty<'tcx>,
) -> bool {
debug!("receiver_is_dispatchable: method = {:?}, receiver_ty = {:?}", method, receiver_ty);
Expand Down
Loading