Skip to content
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

Rollup of 10 pull requests #69724

Closed
wants to merge 29 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
515446c
Make error message clearer about creating new module
kornelski Feb 27, 2020
96b3261
Apply rustfmt :(
kornelski Mar 1, 2020
7b6f5ed
`delay_span_bug` when codegen cannot select obligation
estebank Mar 1, 2020
98c7ed6
DefKind::Method -> DefKind::AssocFn
mark-i-m Mar 3, 2020
3aeb9f0
rename TraitItemKind::Method -> Fn
mark-i-m Mar 3, 2020
c745b4a
Add explanation for E0380
GuillaumeGomez Mar 4, 2020
6db7e34
use integer assoc consts instead of methods
RalfJung Mar 4, 2020
f0c3cf2
cover some more nearby cases
RalfJung Mar 4, 2020
8ea676e
Update books
ehuss Mar 2, 2020
0e1cd59
Toolstate: remove redundant beta-week check.
ehuss Mar 4, 2020
a6d8c9c
more toolstate comments
RalfJung Mar 4, 2020
a41f1f1
Further clarifications and comments on toolstate operation.
ehuss Mar 4, 2020
729d49d
Update macros.rs: fix documentation typo.
fables-tales Mar 4, 2020
07168f9
Don't use .ok() before unwrapping via .expect() on a Result.
matthiaskrgr Mar 4, 2020
569676b
Use .map() to modify data inside Options instead of using .and_then(|…
matthiaskrgr Mar 4, 2020
38f5db7
Use .as_deref() instead of .as_ref().map(Deref::deref) (clippy::optio…
matthiaskrgr Mar 4, 2020
d8d2004
Don't use "if let" bindings to only check a value and not actually bi…
matthiaskrgr Mar 4, 2020
27becb2
ast: `Mac`/`Macro` -> `MacCall`
petrochenkov Feb 29, 2020
80ed505
Use single-char patter on {ends,starts}_with and remove clone on copy…
matthiaskrgr Mar 4, 2020
91d521e
Rollup merge of #69520 - kornelski:e69492, r=cramertj
JohnTitor Mar 5, 2020
33f4285
Rollup merge of #69589 - petrochenkov:maccall, r=Centril
JohnTitor Mar 5, 2020
e067bf4
Rollup merge of #69614 - estebank:ice-age, r=davidtwco
JohnTitor Mar 5, 2020
c2e496d
Rollup merge of #69641 - ehuss:update-books, r=ehuss
JohnTitor Mar 5, 2020
210d693
Rollup merge of #69674 - mark-i-m:assoc-fn, r=Centril
JohnTitor Mar 5, 2020
c9f7758
Rollup merge of #69697 - GuillaumeGomez:explanation-e0380, r=Dylan-DPC
JohnTitor Mar 5, 2020
2ef7c86
Rollup merge of #69698 - RalfJung:int_assoc, r=davidtwco
JohnTitor Mar 5, 2020
18d3c36
Rollup merge of #69705 - ehuss:toolstate-remove-redundant-beta, r=Mar…
JohnTitor Mar 5, 2020
e15d393
Rollup merge of #69711 - penelopezone:patch-1, r=steveklabnik
JohnTitor Mar 5, 2020
5089e11
Rollup merge of #69713 - matthiaskrgr:more_cleanup, r=cramertj
JohnTitor Mar 5, 2020
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
ast: Mac/Macro -> MacCall
petrochenkov committed Mar 4, 2020
commit 27becb2f427329646acac9d4dad225ce97843cbf
40 changes: 20 additions & 20 deletions src/librustc_ast/ast.rs
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
//! - [`Generics`], [`GenericParam`], [`WhereClause`]: Metadata associated with generic parameters.
//! - [`EnumDef`] and [`Variant`]: Enum declaration.
//! - [`Lit`] and [`LitKind`]: Literal expressions.
//! - [`MacroDef`], [`MacStmtStyle`], [`Mac`], [`MacDelimeter`]: Macro definition and invocation.
//! - [`MacroDef`], [`MacStmtStyle`], [`MacCall`], [`MacDelimeter`]: Macro definition and invocation.
//! - [`Attribute`]: Metadata associated with item.
//! - [`UnOp`], [`UnOpKind`], [`BinOp`], [`BinOpKind`]: Unary and binary operators.
@@ -512,7 +512,7 @@ impl Pat {
TyKind::Path(None, Path::from_ident(*ident))
}
PatKind::Path(qself, path) => TyKind::Path(qself.clone(), path.clone()),
PatKind::Mac(mac) => TyKind::Mac(mac.clone()),
PatKind::MacCall(mac) => TyKind::MacCall(mac.clone()),
// `&mut? P` can be reinterpreted as `&mut? T` where `T` is `P` reparsed as a type.
PatKind::Ref(pat, mutbl) => {
pat.to_ty().map(|ty| TyKind::Rptr(None, MutTy { ty, mutbl: *mutbl }))?
@@ -566,7 +566,7 @@ impl Pat {
| PatKind::Range(..)
| PatKind::Ident(..)
| PatKind::Path(..)
| PatKind::Mac(_) => {}
| PatKind::MacCall(_) => {}
}
}

@@ -681,7 +681,7 @@ pub enum PatKind {
Paren(P<Pat>),

/// A macro pattern; pre-expansion.
Mac(Mac),
MacCall(MacCall),
}

#[derive(
@@ -880,9 +880,9 @@ impl Stmt {
pub fn add_trailing_semicolon(mut self) -> Self {
self.kind = match self.kind {
StmtKind::Expr(expr) => StmtKind::Semi(expr),
StmtKind::Mac(mac) => {
StmtKind::Mac(mac.map(|(mac, _style, attrs)| (mac, MacStmtStyle::Semicolon, attrs)))
}
StmtKind::MacCall(mac) => StmtKind::MacCall(
mac.map(|(mac, _style, attrs)| (mac, MacStmtStyle::Semicolon, attrs)),
),
kind => kind,
};
self
@@ -916,7 +916,7 @@ pub enum StmtKind {
/// Just a trailing semi-colon.
Empty,
/// Macro.
Mac(P<(Mac, MacStmtStyle, AttrVec)>),
MacCall(P<(MacCall, MacStmtStyle, AttrVec)>),
}

#[derive(Clone, Copy, PartialEq, RustcEncodable, RustcDecodable, Debug)]
@@ -1056,7 +1056,7 @@ impl Expr {
let kind = match &self.kind {
// Trivial conversions.
ExprKind::Path(qself, path) => TyKind::Path(qself.clone(), path.clone()),
ExprKind::Mac(mac) => TyKind::Mac(mac.clone()),
ExprKind::MacCall(mac) => TyKind::MacCall(mac.clone()),

ExprKind::Paren(expr) => expr.to_ty().map(TyKind::Paren)?,

@@ -1126,7 +1126,7 @@ impl Expr {
ExprKind::Continue(..) => ExprPrecedence::Continue,
ExprKind::Ret(..) => ExprPrecedence::Ret,
ExprKind::InlineAsm(..) => ExprPrecedence::InlineAsm,
ExprKind::Mac(..) => ExprPrecedence::Mac,
ExprKind::MacCall(..) => ExprPrecedence::Mac,
ExprKind::Struct(..) => ExprPrecedence::Struct,
ExprKind::Repeat(..) => ExprPrecedence::Repeat,
ExprKind::Paren(..) => ExprPrecedence::Paren,
@@ -1258,7 +1258,7 @@ pub enum ExprKind {
InlineAsm(P<InlineAsm>),

/// A macro invocation; pre-expansion.
Mac(Mac),
MacCall(MacCall),

/// A struct literal expression.
///
@@ -1344,13 +1344,13 @@ pub enum Movability {
/// Represents a macro invocation. The `path` indicates which macro
/// is being invoked, and the `args` are arguments passed to it.
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Mac {
pub struct MacCall {
pub path: Path,
pub args: P<MacArgs>,
pub prior_type_ascription: Option<(Span, bool)>,
}

impl Mac {
impl MacCall {
pub fn span(&self) -> Span {
self.path.span.to(self.args.span().unwrap_or(self.path.span))
}
@@ -1880,7 +1880,7 @@ pub enum TyKind {
/// Inferred type of a `self` or `&self` argument in a method.
ImplicitSelf,
/// A macro in the type position.
Mac(Mac),
MacCall(MacCall),
/// Placeholder for a kind that has failed to be defined.
Err,
/// Placeholder for a `va_list`.
@@ -2573,7 +2573,7 @@ pub enum ItemKind {
/// A macro invocation.
///
/// E.g., `foo!(..)`.
Mac(Mac),
MacCall(MacCall),

/// A macro definition.
MacroDef(MacroDef),
@@ -2585,7 +2585,7 @@ impl ItemKind {
match self {
Use(..) | Static(..) | Const(..) | Fn(..) | Mod(..) | GlobalAsm(..) | TyAlias(..)
| Struct(..) | Union(..) | Trait(..) | TraitAlias(..) | MacroDef(..) => "a",
ExternCrate(..) | ForeignMod(..) | Mac(..) | Enum(..) | Impl { .. } => "an",
ExternCrate(..) | ForeignMod(..) | MacCall(..) | Enum(..) | Impl { .. } => "an",
}
}

@@ -2605,7 +2605,7 @@ impl ItemKind {
ItemKind::Union(..) => "union",
ItemKind::Trait(..) => "trait",
ItemKind::TraitAlias(..) => "trait alias",
ItemKind::Mac(..) => "item macro invocation",
ItemKind::MacCall(..) => "item macro invocation",
ItemKind::MacroDef(..) => "macro definition",
ItemKind::Impl { .. } => "implementation",
}
@@ -2658,14 +2658,14 @@ pub enum AssocItemKind {
/// A type.
TyAlias(Defaultness, Generics, GenericBounds, Option<P<Ty>>),
/// A macro expanding to items.
Macro(Mac),
MacCall(MacCall),
}

impl AssocItemKind {
pub fn defaultness(&self) -> Defaultness {
match *self {
Self::Const(def, ..) | Self::Fn(def, ..) | Self::TyAlias(def, ..) => def,
Self::Macro(..) | Self::Static(..) => Defaultness::Final,
Self::MacCall(..) | Self::Static(..) => Defaultness::Final,
}
}
}
@@ -2677,7 +2677,7 @@ impl IntoItemKind for AssocItemKind {
AssocItemKind::Static(a, b, c) => ItemKind::Static(a, b, c),
AssocItemKind::Fn(a, b, c, d) => ItemKind::Fn(a, b, c, d),
AssocItemKind::TyAlias(a, b, c, d) => ItemKind::TyAlias(a, b, c, d),
AssocItemKind::Macro(a) => ItemKind::Mac(a),
AssocItemKind::MacCall(a) => ItemKind::MacCall(a),
}
}
}
4 changes: 2 additions & 2 deletions src/librustc_ast/attr/mod.rs
Original file line number Diff line number Diff line change
@@ -676,7 +676,7 @@ impl HasAttrs for StmtKind {
StmtKind::Local(ref local) => local.attrs(),
StmtKind::Expr(ref expr) | StmtKind::Semi(ref expr) => expr.attrs(),
StmtKind::Empty | StmtKind::Item(..) => &[],
StmtKind::Mac(ref mac) => {
StmtKind::MacCall(ref mac) => {
let (_, _, ref attrs) = **mac;
attrs.attrs()
}
@@ -688,7 +688,7 @@ impl HasAttrs for StmtKind {
StmtKind::Local(local) => local.visit_attrs(f),
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.visit_attrs(f),
StmtKind::Empty | StmtKind::Item(..) => {}
StmtKind::Mac(mac) => {
StmtKind::MacCall(mac) => {
let (_mac, _style, attrs) = mac.deref_mut();
attrs.visit_attrs(f);
}
20 changes: 10 additions & 10 deletions src/librustc_ast/mut_visit.rs
Original file line number Diff line number Diff line change
@@ -202,7 +202,7 @@ pub trait MutVisitor: Sized {
noop_visit_local(l, self);
}

fn visit_mac(&mut self, _mac: &mut Mac) {
fn visit_mac(&mut self, _mac: &mut MacCall) {
panic!("visit_mac disabled by default");
// N.B., see note about macros above. If you really want a visitor that
// works on macros, use this definition in your trait impl:
@@ -482,7 +482,7 @@ pub fn noop_visit_ty<T: MutVisitor>(ty: &mut P<Ty>, vis: &mut T) {
vis.visit_id(id);
visit_vec(bounds, |bound| vis.visit_param_bound(bound));
}
TyKind::Mac(mac) => vis.visit_mac(mac),
TyKind::MacCall(mac) => vis.visit_mac(mac),
}
vis.visit_span(span);
}
@@ -584,8 +584,8 @@ pub fn noop_visit_attribute<T: MutVisitor>(attr: &mut Attribute, vis: &mut T) {
vis.visit_span(span);
}

pub fn noop_visit_mac<T: MutVisitor>(mac: &mut Mac, vis: &mut T) {
let Mac { path, args, prior_type_ascription: _ } = mac;
pub fn noop_visit_mac<T: MutVisitor>(mac: &mut MacCall, vis: &mut T) {
let MacCall { path, args, prior_type_ascription: _ } = mac;
vis.visit_path(path);
visit_mac_args(args, vis);
}
@@ -926,7 +926,7 @@ pub fn noop_visit_item_kind<T: MutVisitor>(kind: &mut ItemKind, vis: &mut T) {
vis.visit_generics(generics);
visit_bounds(bounds, vis);
}
ItemKind::Mac(m) => vis.visit_mac(m),
ItemKind::MacCall(m) => vis.visit_mac(m),
ItemKind::MacroDef(def) => vis.visit_macro_def(def),
}
}
@@ -968,7 +968,7 @@ pub fn walk_nested_item(
visit_bounds(bounds, visitor);
visit_opt(ty, |ty| visitor.visit_ty(ty));
}
AssocItemKind::Macro(mac) => visitor.visit_mac(mac),
AssocItemKind::MacCall(mac) => visitor.visit_mac(mac),
}
visitor.visit_span(span);
}
@@ -1073,7 +1073,7 @@ pub fn noop_visit_pat<T: MutVisitor>(pat: &mut P<Pat>, vis: &mut T) {
visit_vec(elems, |elem| vis.visit_pat(elem))
}
PatKind::Paren(inner) => vis.visit_pat(inner),
PatKind::Mac(mac) => vis.visit_mac(mac),
PatKind::MacCall(mac) => vis.visit_mac(mac),
}
vis.visit_span(span);
}
@@ -1210,7 +1210,7 @@ pub fn noop_visit_expr<T: MutVisitor>(Expr { kind, id, span, attrs }: &mut Expr,
}
visit_vec(inputs, |(_c, expr)| vis.visit_expr(expr));
}
ExprKind::Mac(mac) => vis.visit_mac(mac),
ExprKind::MacCall(mac) => vis.visit_mac(mac),
ExprKind::Struct(path, fields, expr) => {
vis.visit_path(path);
fields.flat_map_in_place(|field| vis.flat_map_field(field));
@@ -1266,11 +1266,11 @@ pub fn noop_flat_map_stmt_kind<T: MutVisitor>(
StmtKind::Expr(expr) => vis.filter_map_expr(expr).into_iter().map(StmtKind::Expr).collect(),
StmtKind::Semi(expr) => vis.filter_map_expr(expr).into_iter().map(StmtKind::Semi).collect(),
StmtKind::Empty => smallvec![StmtKind::Empty],
StmtKind::Mac(mut mac) => {
StmtKind::MacCall(mut mac) => {
let (mac_, _semi, attrs) = mac.deref_mut();
vis.visit_mac(mac_);
visit_thin_attrs(attrs, vis);
smallvec![StmtKind::Mac(mac)]
smallvec![StmtKind::MacCall(mac)]
}
}
}
16 changes: 8 additions & 8 deletions src/librustc_ast/visit.rs
Original file line number Diff line number Diff line change
@@ -168,7 +168,7 @@ pub trait Visitor<'ast>: Sized {
fn visit_lifetime(&mut self, lifetime: &'ast Lifetime) {
walk_lifetime(self, lifetime)
}
fn visit_mac(&mut self, _mac: &'ast Mac) {
fn visit_mac(&mut self, _mac: &'ast MacCall) {
panic!("visit_mac disabled by default");
// N.B., see note about macros above.
// if you really want a visitor that
@@ -350,7 +350,7 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
visitor.visit_generics(generics);
walk_list!(visitor, visit_param_bound, bounds);
}
ItemKind::Mac(ref mac) => visitor.visit_mac(mac),
ItemKind::MacCall(ref mac) => visitor.visit_mac(mac),
ItemKind::MacroDef(ref ts) => visitor.visit_mac_def(ts, item.id),
}
walk_list!(visitor, visit_attribute, &item.attrs);
@@ -418,7 +418,7 @@ pub fn walk_ty<'a, V: Visitor<'a>>(visitor: &mut V, typ: &'a Ty) {
}
TyKind::Typeof(ref expression) => visitor.visit_anon_const(expression),
TyKind::Infer | TyKind::ImplicitSelf | TyKind::Err => {}
TyKind::Mac(ref mac) => visitor.visit_mac(mac),
TyKind::MacCall(ref mac) => visitor.visit_mac(mac),
TyKind::Never | TyKind::CVarArgs => {}
}
}
@@ -521,7 +521,7 @@ pub fn walk_pat<'a, V: Visitor<'a>>(visitor: &mut V, pattern: &'a Pat) {
PatKind::Tuple(ref elems) | PatKind::Slice(ref elems) | PatKind::Or(ref elems) => {
walk_list!(visitor, visit_pat, elems);
}
PatKind::Mac(ref mac) => visitor.visit_mac(mac),
PatKind::MacCall(ref mac) => visitor.visit_mac(mac),
}
}

@@ -642,7 +642,7 @@ fn walk_nested_item<'a, V: Visitor<'a>>(
walk_list!(visitor, visit_param_bound, bounds);
walk_list!(visitor, visit_ty, ty);
}
AssocItemKind::Macro(mac) => {
AssocItemKind::MacCall(mac) => {
visitor.visit_mac(mac);
}
}
@@ -671,7 +671,7 @@ pub fn walk_stmt<'a, V: Visitor<'a>>(visitor: &mut V, statement: &'a Stmt) {
StmtKind::Item(ref item) => visitor.visit_item(item),
StmtKind::Expr(ref expr) | StmtKind::Semi(ref expr) => visitor.visit_expr(expr),
StmtKind::Empty => {}
StmtKind::Mac(ref mac) => {
StmtKind::MacCall(ref mac) => {
let (ref mac, _, ref attrs) = **mac;
visitor.visit_mac(mac);
for attr in attrs.iter() {
@@ -681,7 +681,7 @@ pub fn walk_stmt<'a, V: Visitor<'a>>(visitor: &mut V, statement: &'a Stmt) {
}
}

pub fn walk_mac<'a, V: Visitor<'a>>(visitor: &mut V, mac: &'a Mac) {
pub fn walk_mac<'a, V: Visitor<'a>>(visitor: &mut V, mac: &'a MacCall) {
visitor.visit_path(&mac.path, DUMMY_NODE_ID);
}

@@ -803,7 +803,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
ExprKind::Ret(ref optional_expression) => {
walk_list!(visitor, visit_expr, optional_expression);
}
ExprKind::Mac(ref mac) => visitor.visit_mac(mac),
ExprKind::MacCall(ref mac) => visitor.visit_mac(mac),
ExprKind::Paren(ref subexpression) => visitor.visit_expr(subexpression),
ExprKind::InlineAsm(ref ia) => {
for &(_, ref input) in &ia.inputs {
2 changes: 1 addition & 1 deletion src/librustc_ast_lowering/expr.rs
Original file line number Diff line number Diff line change
@@ -198,7 +198,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
return self.lower_expr_for(e, pat, head, body, opt_label);
}
ExprKind::Try(ref sub_expr) => self.lower_expr_try(e.span, sub_expr),
ExprKind::Mac(_) => panic!("Shouldn't exist here"),
ExprKind::MacCall(_) => panic!("Shouldn't exist here"),
};

hir::Expr {
12 changes: 6 additions & 6 deletions src/librustc_ast_lowering/item.rs
Original file line number Diff line number Diff line change
@@ -426,7 +426,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
self.lower_generics(generics, ImplTraitContext::disallowed()),
self.lower_param_bounds(bounds, ImplTraitContext::disallowed()),
),
ItemKind::MacroDef(..) | ItemKind::Mac(..) => {
ItemKind::MacroDef(..) | ItemKind::MacCall(..) => {
bug!("`TyMac` should have been expanded by now")
}
}
@@ -681,7 +681,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
hir::ForeignItemKind::Static(ty, Mutability::Not)
}
ForeignItemKind::TyAlias(..) => hir::ForeignItemKind::Type,
ForeignItemKind::Macro(_) => panic!("macro shouldn't exist here"),
ForeignItemKind::MacCall(_) => panic!("macro shouldn't exist here"),
},
vis: self.lower_visibility(&i.vis, None),
span: i.span,
@@ -785,7 +785,7 @@ impl<'hir> LoweringContext<'_, 'hir> {

(generics, kind)
}
AssocItemKind::Macro(..) => bug!("macro item shouldn't exist at this point"),
AssocItemKind::MacCall(..) => bug!("macro item shouldn't exist at this point"),
};

hir::TraitItem {
@@ -808,7 +808,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
AssocItemKind::Fn(_, sig, _, default) => {
(hir::AssocItemKind::Method { has_self: sig.decl.has_self() }, default.is_some())
}
AssocItemKind::Macro(..) => unimplemented!(),
AssocItemKind::MacCall(..) => unimplemented!(),
};
let id = hir::TraitItemId { hir_id: self.lower_node_id(i.id) };
let defaultness = hir::Defaultness::Default { has_value: has_default };
@@ -867,7 +867,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
};
(generics, kind)
}
AssocItemKind::Macro(..) => bug!("`TyMac` should have been expanded by now"),
AssocItemKind::MacCall(..) => bug!("`TyMac` should have been expanded by now"),
};

hir::ImplItem {
@@ -903,7 +903,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
AssocItemKind::Fn(_, sig, ..) => {
hir::AssocItemKind::Method { has_self: sig.decl.has_self() }
}
AssocItemKind::Macro(..) => unimplemented!(),
AssocItemKind::MacCall(..) => unimplemented!(),
},
}

Loading