From a5c52c72ae3c1d8b3896756541b115a1d5ea94b7 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Mon, 17 Dec 2018 04:57:32 +0300 Subject: [PATCH 1/7] AST/HIR: Introduce `ExprKind::Err` for better error recovery in the front-end --- src/librustc/cfg/construct.rs | 3 ++- src/librustc/hir/intravisit.rs | 1 + src/librustc/hir/lowering.rs | 2 ++ src/librustc/hir/mod.rs | 7 ++++++- src/librustc/hir/print.rs | 9 ++++++++- src/librustc/ich/impls_hir.rs | 3 ++- src/librustc/middle/expr_use_visitor.rs | 3 ++- src/librustc/middle/liveness.rs | 6 ++++-- src/librustc/middle/mem_categorization.rs | 2 +- src/librustc_mir/hair/cx/expr.rs | 1 + src/librustc_passes/rvalue_promotion.rs | 3 ++- src/librustc_typeck/check/mod.rs | 3 +++ src/libsyntax/ast.rs | 4 ++++ src/libsyntax/fold.rs | 1 + src/libsyntax/print/pprust.rs | 9 ++++++++- src/libsyntax/util/parser.rs | 4 +++- src/libsyntax/visit.rs | 1 + 17 files changed, 51 insertions(+), 11 deletions(-) diff --git a/src/librustc/cfg/construct.rs b/src/librustc/cfg/construct.rs index b6d3b6665be2a..978d20ea94789 100644 --- a/src/librustc/cfg/construct.rs +++ b/src/librustc/cfg/construct.rs @@ -392,7 +392,8 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { hir::ExprKind::Closure(..) | hir::ExprKind::Lit(..) | - hir::ExprKind::Path(_) => { + hir::ExprKind::Path(_) | + hir::ExprKind::Err => { self.straightline(expr, pred, None::.iter()) } } diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 17b001a5ce8ac..2f0a95445a886 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -1099,6 +1099,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) { ExprKind::Yield(ref subexpression) => { visitor.visit_expr(subexpression); } + ExprKind::Err => {} } } diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 039b525c8644a..59b9f83c242ec 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -4117,6 +4117,8 @@ impl<'a> LoweringContext<'a> { hir::ExprKind::Yield(P(expr)) } + ExprKind::Err => hir::ExprKind::Err, + // Desugar `ExprIfLet` // from: `if let = []` ExprKind::IfLet(ref pats, ref sub_expr, ref body, ref else_opt) => { diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 30817433823a8..601d310fc3a21 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -1362,6 +1362,7 @@ impl Expr { ExprKind::Struct(..) => ExprPrecedence::Struct, ExprKind::Repeat(..) => ExprPrecedence::Repeat, ExprKind::Yield(..) => ExprPrecedence::Yield, + ExprKind::Err => ExprPrecedence::Err, } } @@ -1412,7 +1413,8 @@ impl Expr { ExprKind::AddrOf(..) | ExprKind::Binary(..) | ExprKind::Yield(..) | - ExprKind::Cast(..) => { + ExprKind::Cast(..) | + ExprKind::Err => { false } } @@ -1525,6 +1527,9 @@ pub enum ExprKind { /// A suspension point for generators. This is `yield ` in Rust. Yield(P), + + /// Placeholder for an expression that wasn't syntactically well formed in some way. + Err, } /// Optionally `Self`-qualified value/type path or associated extension. diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index 9c869998d54f4..e19da011be1d6 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -430,7 +430,9 @@ impl<'a> State<'a> { self.s.word("_")?; } hir::TyKind::Err => { - self.s.word("?")?; + self.popen()?; + self.s.word("/*ERROR*/")?; + self.pclose()?; } } self.end() @@ -1540,6 +1542,11 @@ impl<'a> State<'a> { self.word_space("yield")?; self.print_expr_maybe_paren(&expr, parser::PREC_JUMP)?; } + hir::ExprKind::Err => { + self.popen()?; + self.s.word("/*ERROR*/")?; + self.pclose()?; + } } self.ann.post(self, AnnNode::Expr(expr))?; self.end() diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index f5d6827e89b49..006f11d51e400 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -592,7 +592,8 @@ impl_stable_hash_for!(enum hir::ExprKind { InlineAsm(asm, inputs, outputs), Struct(path, fields, base), Repeat(val, times), - Yield(val) + Yield(val), + Err }); impl_stable_hash_for!(enum hir::LocalSource { diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index e6035d42f06cf..f9bcbb3222955 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -479,7 +479,8 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { } hir::ExprKind::Continue(..) | - hir::ExprKind::Lit(..) => {} + hir::ExprKind::Lit(..) | + hir::ExprKind::Err => {} hir::ExprKind::Loop(ref blk, _, _) => { self.walk_block(&blk); diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 4b75840263eb1..a78cf1a471b4b 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -515,6 +515,7 @@ fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) { hir::ExprKind::Box(..) | hir::ExprKind::Yield(..) | hir::ExprKind::Type(..) | + hir::ExprKind::Err | hir::ExprKind::Path(hir::QPath::TypeRelative(..)) => { intravisit::walk_expr(ir, expr); } @@ -1254,7 +1255,8 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { self.propagate_through_exprs(inputs, succ) } - hir::ExprKind::Lit(..) | hir::ExprKind::Path(hir::QPath::TypeRelative(..)) => { + hir::ExprKind::Lit(..) | hir::ExprKind::Err | + hir::ExprKind::Path(hir::QPath::TypeRelative(..)) => { succ } @@ -1521,7 +1523,7 @@ fn check_expr<'a, 'tcx>(this: &mut Liveness<'a, 'tcx>, expr: &'tcx Expr) { hir::ExprKind::Block(..) | hir::ExprKind::AddrOf(..) | hir::ExprKind::Struct(..) | hir::ExprKind::Repeat(..) | hir::ExprKind::Closure(..) | hir::ExprKind::Path(_) | hir::ExprKind::Yield(..) | - hir::ExprKind::Box(..) | hir::ExprKind::Type(..) => { + hir::ExprKind::Box(..) | hir::ExprKind::Type(..) | hir::ExprKind::Err => { intravisit::walk_expr(this, expr); } } diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index f32d7c54afe59..207382d5e1f45 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -687,7 +687,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { hir::ExprKind::Block(..) | hir::ExprKind::Loop(..) | hir::ExprKind::Match(..) | hir::ExprKind::Lit(..) | hir::ExprKind::Break(..) | hir::ExprKind::Continue(..) | hir::ExprKind::Struct(..) | hir::ExprKind::Repeat(..) | - hir::ExprKind::InlineAsm(..) | hir::ExprKind::Box(..) => { + hir::ExprKind::InlineAsm(..) | hir::ExprKind::Box(..) | hir::ExprKind::Err => { Ok(self.cat_rvalue_node(expr.hir_id, expr.span, expr_ty)) } } diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index 46d666cd81de2..23cfd18ef5d4c 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -780,6 +780,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, hir::ExprKind::Tup(ref fields) => ExprKind::Tuple { fields: fields.to_ref() }, hir::ExprKind::Yield(ref v) => ExprKind::Yield { value: v.to_ref() }, + hir::ExprKind::Err => unreachable!(), }; Expr { diff --git a/src/librustc_passes/rvalue_promotion.rs b/src/librustc_passes/rvalue_promotion.rs index 2fa046a698a67..f0b559f80a28c 100644 --- a/src/librustc_passes/rvalue_promotion.rs +++ b/src/librustc_passes/rvalue_promotion.rs @@ -449,7 +449,8 @@ fn check_expr_kind<'a, 'tcx>( struct_result } - hir::ExprKind::Lit(_) => Promotable, + hir::ExprKind::Lit(_) | + hir::ExprKind::Err => Promotable, hir::ExprKind::AddrOf(_, ref expr) | hir::ExprKind::Repeat(ref expr, _) => { diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 15a9ba99fa711..0cfe06451a7d7 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4513,6 +4513,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } tcx.mk_unit() } + hir::ExprKind::Err => { + tcx.types.err + } } } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 7e228d8d7cfad..f0e567f9cd651 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1001,6 +1001,7 @@ impl Expr { ExprKind::Paren(..) => ExprPrecedence::Paren, ExprKind::Try(..) => ExprPrecedence::Try, ExprKind::Yield(..) => ExprPrecedence::Yield, + ExprKind::Err => ExprPrecedence::Err, } } } @@ -1160,6 +1161,9 @@ pub enum ExprKind { /// A `yield`, with an optional value to be yielded. Yield(Option>), + + /// Placeholder for an expression that wasn't syntactically well formed in some way. + Err, } /// The explicit `Self` type in a "qualified path". The actual diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 0abc74c231464..b8990264c5df5 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -1367,6 +1367,7 @@ pub fn noop_fold_expr(Expr {id, node, span, attrs}: Expr, folder: &mu ExprKind::Yield(ex) => ExprKind::Yield(ex.map(|x| folder.fold_expr(x))), ExprKind::Try(ex) => ExprKind::Try(folder.fold_expr(ex)), ExprKind::TryBlock(body) => ExprKind::TryBlock(folder.fold_block(body)), + ExprKind::Err => ExprKind::Err, }, id: folder.new_id(id), span: folder.new_span(span), diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 931e91e9c7907..2ad3d3a6d6487 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1093,7 +1093,9 @@ impl<'a> State<'a> { self.s.word("_")?; } ast::TyKind::Err => { - self.s.word("?")?; + self.popen()?; + self.s.word("/*ERROR*/")?; + self.pclose()?; } ast::TyKind::ImplicitSelf => { self.s.word("Self")?; @@ -2391,6 +2393,11 @@ impl<'a> State<'a> { self.s.space()?; self.print_block_with_attrs(blk, attrs)? } + ast::ExprKind::Err => { + self.popen()?; + self.s.word("/*ERROR*/")?; + self.pclose()? + } } self.ann.post(self, AnnNode::Expr(expr))?; self.end() diff --git a/src/libsyntax/util/parser.rs b/src/libsyntax/util/parser.rs index 52390fa5b1d81..89d4e53b8d140 100644 --- a/src/libsyntax/util/parser.rs +++ b/src/libsyntax/util/parser.rs @@ -267,6 +267,7 @@ pub enum ExprPrecedence { TryBlock, Struct, Async, + Err, } impl ExprPrecedence { @@ -325,7 +326,8 @@ impl ExprPrecedence { ExprPrecedence::Block | ExprPrecedence::TryBlock | ExprPrecedence::Async | - ExprPrecedence::Struct => PREC_PAREN, + ExprPrecedence::Struct | + ExprPrecedence::Err => PREC_PAREN, } } } diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 43f8a13609e7b..156546bbba94a 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -802,6 +802,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) { ExprKind::TryBlock(ref body) => { visitor.visit_block(body) } + ExprKind::Err => {} } visitor.visit_expr_post(expression) From fff01ccfa805ccef67827bf1ea84e21d61d13e6f Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 16 Dec 2018 20:23:27 +0300 Subject: [PATCH 2/7] Do not abort compilation if expansion produces errors Fix a number of uncovered deficiencies in diagnostics --- src/librustc_driver/driver.rs | 10 --- src/librustc_passes/ast_validation.rs | 30 ------- src/librustc_resolve/lib.rs | 7 +- src/librustc_resolve/macros.rs | 31 +++++-- src/libsyntax/ext/base.rs | 9 +- src/libsyntax/ext/expand.rs | 16 ++-- src/libsyntax/feature_gate.rs | 19 ++-- src/libsyntax_ext/deriving/default.rs | 4 +- src/libsyntax_ext/format.rs | 4 +- .../cfg-attr-invalid-predicate.rs | 2 + .../cfg-attr-syntax-validation.rs | 2 + .../auxiliary/extern_macro_crate.rs | 2 +- .../derive-on-trait-item-or-impl-item.rs | 2 + .../derive-on-trait-item-or-impl-item.stderr | 1 - src/test/ui/did_you_mean/issue-40396.rs | 19 +++- src/test/ui/did_you_mean/issue-40396.stderr | 87 +++++++++++++++++-- .../edition-keywords-2015-2015-parsing.rs | 6 ++ .../edition-keywords-2015-2015-parsing.stderr | 1 - .../edition-keywords-2015-2018-expansion.rs | 2 + .../edition-keywords-2015-2018-parsing.rs | 6 ++ .../edition-keywords-2015-2018-parsing.stderr | 1 - .../edition-keywords-2018-2018-expansion.rs | 2 + .../issue-43106-gating-of-derive-2.rs | 2 + .../issue-43106-gating-of-derive.rs | 2 + .../feature-gate-cfg-target-has-atomic.rs | 2 + .../feature-gate-macros_in_extern.rs | 2 + .../feature-gates/feature-gate-rustc-attrs.rs | 4 +- src/test/ui/issues/issue-10536.rs | 7 +- src/test/ui/issues/issue-10536.stderr | 25 +++++- src/test/ui/issues/issue-11692-1.rs | 1 + src/test/ui/issues/issue-11692-1.stderr | 8 +- src/test/ui/issues/issue-11692-2.rs | 1 + src/test/ui/issues/issue-11692-2.stderr | 10 ++- src/test/ui/issues/issue-32950.rs | 1 + src/test/ui/issues/issue-32950.stderr | 9 +- src/test/ui/issues/issue-33571.rs | 2 + src/test/ui/issues/issue-35677.rs | 2 + src/test/ui/issues/issue-35677.stderr | 9 +- src/test/ui/issues/issue-36617.rs | 2 + src/test/ui/issues/issue-43023.rs | 2 + src/test/ui/issues/issue-46438.rs | 2 +- src/test/ui/issues/issue-49074.rs | 2 +- src/test/ui/issues/issue-49074.stderr | 10 ++- src/test/ui/issues/issue-51279.rs | 1 + src/test/ui/issues/issue-51279.stderr | 11 ++- src/test/ui/issues/issue-55796.rs | 2 + src/test/ui/issues/issue-55796.stderr | 9 +- src/test/ui/issues/issue-6596-1.rs | 1 + src/test/ui/issues/issue-6596-1.stderr | 12 ++- src/test/ui/issues/issue-6596-2.rs | 1 + src/test/ui/macro_backtrace/main.rs | 2 + .../macros/macro-comma-behavior.core.stderr | 8 +- .../ui/malformed/malformed-derive-entry.rs | 2 + .../runtime-depend-on-needs-runtime.rs | 2 + .../runtime-depend-on-needs-runtime.stderr | 7 +- src/test/ui/parser/macro/pub-item-macro.rs | 2 +- .../ui/parser/macro/pub-item-macro.stderr | 9 +- src/test/ui/proc-macro/issue-41211.rs | 1 + src/test/ui/proc-macro/issue-41211.stderr | 8 +- src/test/ui/proc-macro/lifetimes.rs | 2 + src/test/ui/proc-macro/more-gates.rs | 2 + src/test/ui/proc-macro/parent-source-spans.rs | 3 + .../ui/proc-macro/parent-source-spans.stderr | 30 ++++++- .../ui/proc-macro/proc-macro-attributes.rs | 9 +- .../proc-macro/proc-macro-attributes.stderr | 79 ++++++++++++++++- src/test/ui/quote-with-interpolated.rs | 7 +- src/test/ui/quote-with-interpolated.stderr | 33 ++++++- .../ui/reserved/reserved-attr-on-macro.rs | 5 +- .../ui/reserved/reserved-attr-on-macro.stderr | 12 ++- src/test/ui/self/self_type_keyword.rs | 1 + src/test/ui/self/self_type_keyword.stderr | 11 ++- src/test/ui/span/issue-36530.rs | 2 + src/test/ui/span/macro-ty-params.rs | 4 +- src/test/ui/span/macro-ty-params.stderr | 17 ++-- src/test/ui/span/visibility-ty-params.rs | 1 + src/test/ui/span/visibility-ty-params.stderr | 11 ++- .../ui/tuple/tuple-struct-fields/test2.rs | 4 +- .../ui/tuple/tuple-struct-fields/test2.stderr | 11 ++- .../ui/tuple/tuple-struct-fields/test3.rs | 4 +- .../ui/tuple/tuple-struct-fields/test3.stderr | 11 ++- 80 files changed, 538 insertions(+), 167 deletions(-) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index f19ca5ed030ab..62dc8691e65df 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -987,7 +987,6 @@ where }; let mut ecx = ExtCtxt::new(&sess.parse_sess, cfg, &mut resolver); - let err_count = ecx.parse_sess.span_diagnostic.err_count(); // Expand macros now! let krate = time(sess, "expand crate", || { @@ -1013,9 +1012,6 @@ where let msg = "missing fragment specifier"; sess.buffer_lint(lint, ast::CRATE_NODE_ID, span, msg); } - if ecx.parse_sess.span_diagnostic.err_count() - ecx.resolve_err_count > err_count { - ecx.parse_sess.span_diagnostic.abort_if_errors(); - } if cfg!(windows) { env::set_var("PATH", &old_path); } @@ -1119,12 +1115,6 @@ where }) })?; - // Unresolved macros might be due to mistyped `#[macro_use]`, - // so abort after checking for unknown attributes. (#49074) - if resolver.found_unresolved_macro { - sess.diagnostic().abort_if_errors(); - } - // Lower ast -> hir. // First, we need to collect the dep_graph. let dep_graph = match future_dep_graph { diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index ce5db51dfb590..584f0ba0449e1 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -278,25 +278,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> { visit::walk_ty(self, ty) } - fn visit_use_tree(&mut self, use_tree: &'a UseTree, id: NodeId, _nested: bool) { - // Check if the path in this `use` is not generic, such as `use foo::bar;` While this - // can't happen normally thanks to the parser, a generic might sneak in if the `use` is - // built using a macro. - // - // macro_use foo { - // ($p:path) => { use $p; } - // } - // foo!(bar::baz); - use_tree.prefix.segments.iter().find(|segment| { - segment.args.is_some() - }).map(|segment| { - self.err_handler().span_err(segment.args.as_ref().unwrap().span(), - "generic arguments in import path"); - }); - - visit::walk_use_tree(self, use_tree, id); - } - fn visit_label(&mut self, label: &'a Label) { self.check_label(label.ident); visit::walk_label(self, label); @@ -433,17 +414,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> { visit::walk_foreign_item(self, fi) } - fn visit_vis(&mut self, vis: &'a Visibility) { - if let VisibilityKind::Restricted { ref path, .. } = vis.node { - path.segments.iter().find(|segment| segment.args.is_some()).map(|segment| { - self.err_handler().span_err(segment.args.as_ref().unwrap().span(), - "generic arguments in visibility path"); - }); - } - - visit::walk_vis(self, vis) - } - fn visit_generics(&mut self, generics: &'a Generics) { let mut seen_non_lifetime_param = false; let mut seen_default = None; diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index cc9c6d8c516be..0db6dbafb6cc6 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -1576,7 +1576,6 @@ pub struct Resolver<'a> { macro_map: FxHashMap>, macro_defs: FxHashMap, local_macro_def_scopes: FxHashMap>, - pub found_unresolved_macro: bool, /// List of crate local macros that we need to warn about as being unused. /// Right now this only includes macro_rules! macros, and macros 2.0. @@ -1911,7 +1910,6 @@ impl<'a> Resolver<'a> { name_already_seen: FxHashMap::default(), potentially_unused_imports: Vec::new(), struct_constructors: Default::default(), - found_unresolved_macro: false, unused_macros: FxHashSet::default(), current_type_ascription: Vec::new(), injected_crate: None, @@ -2024,8 +2022,10 @@ impl<'a> Resolver<'a> { record_used_id: Option, path_span: Span) -> Option> { - let record_used = record_used_id.is_some(); assert!(ns == TypeNS || ns == ValueNS); + if ident.name == keywords::Invalid.name() { + return Some(LexicalScopeBinding::Def(Def::Err)); + } if ns == TypeNS { ident.span = if ident.name == keywords::SelfUpper.name() { // FIXME(jseyfried) improve `Self` hygiene @@ -2038,6 +2038,7 @@ impl<'a> Resolver<'a> { } // Walk backwards up the ribs in scope. + let record_used = record_used_id.is_some(); let mut module = self.graph_root; for i in (0 .. self.ribs[ns].len()).rev() { if let Some(def) = self.ribs[ns][i].bindings.get(&ident).cloned() { diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 98c6773cec323..9c0c8a6016fe5 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -182,7 +182,14 @@ impl<'a> base::Resolver for Resolver<'a> { }; let parent_scope = self.invoc_parent_scope(invoc_id, derives_in_scope); - let (def, ext) = self.resolve_macro_to_def(path, kind, &parent_scope, true, force)?; + let (def, ext) = match self.resolve_macro_to_def(path, kind, &parent_scope, true, force) { + Ok((def, ext)) => (def, ext), + Err(Determinacy::Determined) if kind == MacroKind::Attr => { + // Replace unresolved attributes with used inert attributes for better recovery. + return Ok(Some(self.get_macro(Def::NonMacroAttr(NonMacroAttrKind::Tool)))); + } + Err(determinacy) => return Err(determinacy), + }; if let Def::Macro(def_id, _) = def { if after_derive { @@ -337,7 +344,6 @@ impl<'a> Resolver<'a> { } PathResult::Indeterminate if !force => return Err(Determinacy::Undetermined), PathResult::NonModule(..) | PathResult::Indeterminate | PathResult::Failed(..) => { - self.found_unresolved_macro = true; Err(Determinacy::Determined) } PathResult::Module(..) => unreachable!(), @@ -353,10 +359,8 @@ impl<'a> Resolver<'a> { let binding = self.early_resolve_ident_in_lexical_scope( path[0].ident, ScopeSet::Macro(kind), parent_scope, false, force, path_span ); - match binding { - Ok(..) => {} - Err(Determinacy::Determined) => self.found_unresolved_macro = true, - Err(Determinacy::Undetermined) => return Err(Determinacy::Undetermined), + if let Err(Determinacy::Undetermined) = binding { + return Err(Determinacy::Undetermined); } if trace { @@ -858,14 +862,23 @@ impl<'a> Resolver<'a> { pub fn finalize_current_module_macro_resolutions(&mut self) { let module = self.current_module; - let check_consistency = |this: &mut Self, path: &[Segment], span, - kind: MacroKind, initial_def, def| { + let check_consistency = |this: &mut Self, path: &[Segment], span, kind: MacroKind, + initial_def: Option, def: Def| { if let Some(initial_def) = initial_def { if def != initial_def && def != Def::Err && this.ambiguity_errors.is_empty() { // Make sure compilation does not succeed if preferred macro resolution // has changed after the macro had been expanded. In theory all such // situations should be reported as ambiguity errors, so this is a bug. - span_bug!(span, "inconsistent resolution for a macro"); + if initial_def == Def::NonMacroAttr(NonMacroAttrKind::Custom) { + // Yeah, legacy custom attributes are implemented using forced resolution + // (which is a best effort error recovery tool, basically), so we can't + // promise their resolution won't change later. + let msg = format!("inconsistent resolution for a macro: first {}, then {}", + initial_def.kind_name(), def.kind_name()); + this.session.span_err(span, &msg); + } else { + span_bug!(span, "inconsistent resolution for a macro"); + } } } else { // It's possible that the macro was unresolved (indeterminate) and silently diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index d576397c942c1..84aa57d7d86e6 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -2,7 +2,7 @@ pub use self::SyntaxExtension::*; use ast::{self, Attribute, Name, PatKind, MetaItem}; use attr::HasAttrs; -use source_map::{self, SourceMap, Spanned, respan}; +use source_map::{SourceMap, Spanned, respan}; use syntax_pos::{Span, MultiSpan, DUMMY_SP}; use edition::Edition; use errors::{DiagnosticBuilder, DiagnosticId}; @@ -481,7 +481,7 @@ impl DummyResult { pub fn raw_expr(sp: Span) -> P { P(ast::Expr { id: ast::DUMMY_NODE_ID, - node: ast::ExprKind::Lit(source_map::respan(sp, ast::LitKind::Bool(false))), + node: ast::ExprKind::Err, span: sp, attrs: ThinVec::new(), }) @@ -496,10 +496,11 @@ impl DummyResult { } } + /// A plain dummy type. pub fn raw_ty(sp: Span) -> P { P(ast::Ty { id: ast::DUMMY_NODE_ID, - node: ast::TyKind::Infer, + node: ast::TyKind::Err, span: sp }) } @@ -796,7 +797,6 @@ pub struct ExtCtxt<'a> { pub ecfg: expand::ExpansionConfig<'a>, pub root_path: PathBuf, pub resolver: &'a mut dyn Resolver, - pub resolve_err_count: usize, pub current_expansion: ExpansionData, pub expansions: FxHashMap>, } @@ -811,7 +811,6 @@ impl<'a> ExtCtxt<'a> { ecfg, root_path: PathBuf::new(), resolver, - resolve_err_count: 0, current_expansion: ExpansionData { mark: Mark::root(), depth: 0, diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 55012bb7f5a15..f8f1e83077028 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -344,8 +344,10 @@ impl<'a, 'b> MacroExpander<'a, 'b> { // FIXME(jseyfried): Refactor out the following logic let (expanded_fragment, new_invocations) = if let Some(ext) = ext { if let Some(ext) = ext { - let dummy = invoc.fragment_kind.dummy(invoc.span()).unwrap(); - let fragment = self.expand_invoc(invoc, &*ext).unwrap_or(dummy); + let (invoc_fragment_kind, invoc_span) = (invoc.fragment_kind, invoc.span()); + let fragment = self.expand_invoc(invoc, &*ext).unwrap_or_else(|| { + invoc_fragment_kind.dummy(invoc_span).unwrap() + }); self.collect_invocations(fragment, &[]) } else if let InvocationKind::Attr { attr: None, traits, item, .. } = invoc.kind { if !item.derive_allowed() { @@ -431,9 +433,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { fn resolve_imports(&mut self) { if self.monotonic { - let err_count = self.cx.parse_sess.span_diagnostic.err_count(); self.cx.resolver.resolve_imports(); - self.cx.resolve_err_count += self.cx.parse_sess.span_diagnostic.err_count() - err_count; } } @@ -457,11 +457,9 @@ impl<'a, 'b> MacroExpander<'a, 'b> { }; if self.monotonic { - let err_count = self.cx.parse_sess.span_diagnostic.err_count(); - let mark = self.cx.current_expansion.mark; - self.cx.resolver.visit_ast_fragment_with_placeholders(mark, &fragment_with_placeholders, - derives); - self.cx.resolve_err_count += self.cx.parse_sess.span_diagnostic.err_count() - err_count; + self.cx.resolver.visit_ast_fragment_with_placeholders( + self.cx.current_expansion.mark, &fragment_with_placeholders, derives + ); } (fragment_with_placeholders, invocations) diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 62269a8f163b4..70df403d0c2ea 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -1272,16 +1272,15 @@ impl<'a> Context<'a> { return; } } - if name.starts_with("rustc_") { - gate_feature!(self, rustc_attrs, attr.span, - "unless otherwise specified, attributes \ - with the prefix `rustc_` \ - are reserved for internal compiler diagnostics"); - } else if !attr::is_known(attr) { - // Only run the custom attribute lint during regular feature gate - // checking. Macro gating runs before the plugin attributes are - // registered, so we skip this in that case. - if !is_macro { + if !attr::is_known(attr) { + if name.starts_with("rustc_") { + let msg = "unless otherwise specified, attributes with the prefix `rustc_` \ + are reserved for internal compiler diagnostics"; + gate_feature!(self, rustc_attrs, attr.span, msg); + } else if !is_macro { + // Only run the custom attribute lint during regular feature gate + // checking. Macro gating runs before the plugin attributes are + // registered, so we skip this in that case. let msg = format!("The attribute `{}` is currently unknown to the compiler and \ may have meaning added to it in the future", attr.path); gate_feature!(self, custom_attribute, attr.span, &msg); diff --git a/src/libsyntax_ext/deriving/default.rs b/src/libsyntax_ext/deriving/default.rs index c26c4bb627400..771a559b37ccf 100644 --- a/src/libsyntax_ext/deriving/default.rs +++ b/src/libsyntax_ext/deriving/default.rs @@ -3,7 +3,7 @@ use deriving::generic::*; use deriving::generic::ty::*; use syntax::ast::{Expr, MetaItem}; -use syntax::ext::base::{Annotatable, ExtCtxt}; +use syntax::ext::base::{Annotatable, DummyResult, ExtCtxt}; use syntax::ext::build::AstBuilder; use syntax::ptr::P; use syntax::symbol::Symbol; @@ -69,7 +69,7 @@ fn default_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructur span_err!(cx, trait_span, E0665, "`Default` cannot be derived for enums, only structs"); // let compilation continue - cx.expr_usize(trait_span, 0) + DummyResult::raw_expr(trait_span) } _ => cx.span_bug(trait_span, "Non-static method in `derive(Default)`"), }; diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 220765fd8c732..c6f427e63cd8d 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -666,7 +666,7 @@ impl<'a, 'b> Context<'a, 'b> { "X" => "UpperHex", _ => { ecx.span_err(sp, &format!("unknown format trait `{}`", *tyname)); - "Dummy" + return DummyResult::raw_expr(sp); } } } @@ -713,7 +713,7 @@ pub fn expand_format_args_nl<'cx>( sp, feature_gate::GateIssue::Language, feature_gate::EXPLAIN_FORMAT_ARGS_NL); - return base::DummyResult::expr(sp); + return DummyResult::expr(sp); } sp = sp.apply_mark(ecx.current_expansion.mark); match parse_args(ecx, sp, tts) { diff --git a/src/test/ui/conditional-compilation/cfg-attr-invalid-predicate.rs b/src/test/ui/conditional-compilation/cfg-attr-invalid-predicate.rs index 9d8842eee81c6..496d196c94ae5 100644 --- a/src/test/ui/conditional-compilation/cfg-attr-invalid-predicate.rs +++ b/src/test/ui/conditional-compilation/cfg-attr-invalid-predicate.rs @@ -1,2 +1,4 @@ #[cfg(foo(bar))] //~ ERROR invalid predicate `foo` +fn check() {} + fn main() {} diff --git a/src/test/ui/conditional-compilation/cfg-attr-syntax-validation.rs b/src/test/ui/conditional-compilation/cfg-attr-syntax-validation.rs index 83e162e08712f..c7e1b4435e49b 100644 --- a/src/test/ui/conditional-compilation/cfg-attr-syntax-validation.rs +++ b/src/test/ui/conditional-compilation/cfg-attr-syntax-validation.rs @@ -33,3 +33,5 @@ macro_rules! generate_s10 { } generate_s10!(concat!("nonexistent")); + +fn main() {} diff --git a/src/test/ui/cross/cross-crate-macro-backtrace/auxiliary/extern_macro_crate.rs b/src/test/ui/cross/cross-crate-macro-backtrace/auxiliary/extern_macro_crate.rs index 7c9ecb5d6214e..fbda3dbe9481f 100644 --- a/src/test/ui/cross/cross-crate-macro-backtrace/auxiliary/extern_macro_crate.rs +++ b/src/test/ui/cross/cross-crate-macro-backtrace/auxiliary/extern_macro_crate.rs @@ -4,7 +4,7 @@ pub fn print(_args: std::fmt::Arguments) {} #[macro_export] macro_rules! myprint { - ($($arg:tt)*) => (print(format_args!($($arg)*))); + ($($arg:tt)*) => ($crate::print(format_args!($($arg)*))); } #[macro_export] diff --git a/src/test/ui/derives/derive-on-trait-item-or-impl-item.rs b/src/test/ui/derives/derive-on-trait-item-or-impl-item.rs index 2530e75111bfb..b847000a81d80 100644 --- a/src/test/ui/derives/derive-on-trait-item-or-impl-item.rs +++ b/src/test/ui/derives/derive-on-trait-item-or-impl-item.rs @@ -4,6 +4,8 @@ trait Foo { type Bar; } +struct Bar; + impl Bar { #[derive(Clone)] //~^ ERROR `derive` may only be applied to structs, enums and unions diff --git a/src/test/ui/derives/derive-on-trait-item-or-impl-item.stderr b/src/test/ui/derives/derive-on-trait-item-or-impl-item.stderr index dd7af8304147e..0088add7e7f6e 100644 --- a/src/test/ui/derives/derive-on-trait-item-or-impl-item.stderr +++ b/src/test/ui/derives/derive-on-trait-item-or-impl-item.stderr @@ -11,4 +11,3 @@ LL | #[derive(Clone)] | ^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors - diff --git a/src/test/ui/did_you_mean/issue-40396.rs b/src/test/ui/did_you_mean/issue-40396.rs index 978b5d144833e..63eec50c2d29f 100644 --- a/src/test/ui/did_you_mean/issue-40396.rs +++ b/src/test/ui/did_you_mean/issue-40396.rs @@ -1,14 +1,27 @@ fn foo() { - println!("{:?}", (0..13).collect>()); //~ ERROR chained comparison + (0..13).collect>(); + //~^ ERROR chained comparison + //~| ERROR expected value, found struct `Vec` + //~| ERROR expected value, found builtin type `i32` + //~| ERROR attempted to take value of method `collect` } fn bar() { - println!("{:?}", Vec::new()); //~ ERROR chained comparison + Vec::new(); + //~^ ERROR chained comparison + //~| ERROR expected value, found struct `Vec` + //~| ERROR expected value, found builtin type `i32` + //~| ERROR cannot find function `new` in the crate root } fn qux() { - println!("{:?}", (0..13).collect()); //~ ERROR chained comparison + (0..13).collect(); //~^ ERROR chained comparison + //~| ERROR chained comparison + //~| ERROR expected value, found struct `Vec` + //~| ERROR expected value, found builtin type `i32` + //~| ERROR attempted to take value of method `collect` + //~| ERROR mismatched types } fn main() {} diff --git a/src/test/ui/did_you_mean/issue-40396.stderr b/src/test/ui/did_you_mean/issue-40396.stderr index 3b086d8d4d088..33884bbfecfcc 100644 --- a/src/test/ui/did_you_mean/issue-40396.stderr +++ b/src/test/ui/did_you_mean/issue-40396.stderr @@ -1,8 +1,8 @@ error: chained comparison operators require parentheses --> $DIR/issue-40396.rs:2:37 | -LL | println!("{:?}", (0..13).collect>()); //~ ERROR chained comparison - | ^^^^^^^^ +LL | (0..13).collect>(); + | ^^^^^^^^ | = help: use `::<...>` instead of `<...>` if you meant to specify type arguments = help: or use `(...)` if you meant to specify fn arguments @@ -10,8 +10,8 @@ LL | println!("{:?}", (0..13).collect>()); //~ ERROR chained compar error: chained comparison operators require parentheses --> $DIR/issue-40396.rs:6:25 | -LL | println!("{:?}", Vec::new()); //~ ERROR chained comparison - | ^^^^^^^ +LL | Vec::new(); + | ^^^^^^^ | = help: use `::<...>` instead of `<...>` if you meant to specify type arguments = help: or use `(...)` if you meant to specify fn arguments @@ -19,8 +19,8 @@ LL | println!("{:?}", Vec::new()); //~ ERROR chained comparison error: chained comparison operators require parentheses --> $DIR/issue-40396.rs:10:37 | -LL | println!("{:?}", (0..13).collect()); //~ ERROR chained comparison - | ^^^^^^^^ +LL | (0..13).collect(); + | ^^^^^^^^ | = help: use `::<...>` instead of `<...>` if you meant to specify type arguments = help: or use `(...)` if you meant to specify fn arguments @@ -28,11 +28,80 @@ LL | println!("{:?}", (0..13).collect()); //~ ERROR chained compari error: chained comparison operators require parentheses --> $DIR/issue-40396.rs:10:41 | -LL | println!("{:?}", (0..13).collect()); //~ ERROR chained comparison - | ^^^^^^ +LL | (0..13).collect(); + | ^^^^^^ | = help: use `::<...>` instead of `<...>` if you meant to specify type arguments = help: or use `(...)` if you meant to specify fn arguments -error: aborting due to 4 previous errors +error[E0423]: expected value, found struct `Vec` + --> $DIR/issue-40396.rs:12:21 + | +LL | (0..13).collect>(); + | ^^^ did you mean `Vec { /* fields */ }`? + +error[E0423]: expected value, found builtin type `i32` + --> $DIR/issue-40396.rs:12:25 + | +LL | (0..13).collect>(); + | ^^^ not a value + +error[E0423]: expected value, found struct `Vec` + --> $DIR/issue-40396.rs:20:5 + | +LL | Vec::new(); + | ^^^ did you mean `Vec { /* fields */ }`? + +error[E0423]: expected value, found builtin type `i32` + --> $DIR/issue-40396.rs:20:9 + | +LL | Vec::new(); + | ^^^ not a value + +error[E0425]: cannot find function `new` in the crate root + --> $DIR/issue-40396.rs:20:15 + | +LL | Vec::new(); + | ^^^ not found in the crate root + +error[E0423]: expected value, found struct `Vec` + --> $DIR/issue-40396.rs:28:21 + | +LL | (0..13).collect(); + | ^^^ did you mean `Vec { /* fields */ }`? + +error[E0423]: expected value, found builtin type `i32` + --> $DIR/issue-40396.rs:28:25 + | +LL | (0..13).collect(); + | ^^^ not a value + +error[E0615]: attempted to take value of method `collect` on type `std::ops::Range<{integer}>` + --> $DIR/issue-40396.rs:12:13 + | +LL | (0..13).collect>(); + | ^^^^^^^ + | + = help: maybe a `()` to call it is missing? + +error[E0615]: attempted to take value of method `collect` on type `std::ops::Range<{integer}>` + --> $DIR/issue-40396.rs:28:13 + | +LL | (0..13).collect(); + | ^^^^^^^ + | + = help: maybe a `()` to call it is missing? + +error[E0308]: mismatched types + --> $DIR/issue-40396.rs:28:29 + | +LL | (0..13).collect(); + | ^^ expected bool, found () + | + = note: expected type `bool` + found type `()` + +error: aborting due to 14 previous errors +Some errors occurred: E0308, E0423, E0425, E0615. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/editions/edition-keywords-2015-2015-parsing.rs b/src/test/ui/editions/edition-keywords-2015-2015-parsing.rs index e65eed0a0e6d0..d1752a7ec71dd 100644 --- a/src/test/ui/editions/edition-keywords-2015-2015-parsing.rs +++ b/src/test/ui/editions/edition-keywords-2015-2015-parsing.rs @@ -4,6 +4,10 @@ #[macro_use] extern crate edition_kw_macro_2015; +mod module { + pub fn async() {} +} + pub fn check_async() { let mut async = 1; // OK let mut r#async = 1; // OK @@ -18,3 +22,5 @@ pub fn check_async() { module::async(); // OK module::r#async(); // OK } + +fn main() {} diff --git a/src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr b/src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr index 377e8ae082548..06901ad6ef0ee 100644 --- a/src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr +++ b/src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr @@ -11,4 +11,3 @@ LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the t | ^^^^^ no rules expected this token in macro call error: aborting due to 2 previous errors - diff --git a/src/test/ui/editions/edition-keywords-2015-2018-expansion.rs b/src/test/ui/editions/edition-keywords-2015-2018-expansion.rs index 8aafeefa56ce1..2684c8e00b2e1 100644 --- a/src/test/ui/editions/edition-keywords-2015-2018-expansion.rs +++ b/src/test/ui/editions/edition-keywords-2015-2018-expansion.rs @@ -10,3 +10,5 @@ mod one_async { mod two_async { produces_async_raw! {} // OK } + +fn main() {} diff --git a/src/test/ui/editions/edition-keywords-2015-2018-parsing.rs b/src/test/ui/editions/edition-keywords-2015-2018-parsing.rs index 767396031297e..44455f43856c6 100644 --- a/src/test/ui/editions/edition-keywords-2015-2018-parsing.rs +++ b/src/test/ui/editions/edition-keywords-2015-2018-parsing.rs @@ -4,6 +4,10 @@ #[macro_use] extern crate edition_kw_macro_2018; +mod module { + pub fn async() {} +} + pub fn check_async() { let mut async = 1; // OK let mut r#async = 1; // OK @@ -18,3 +22,5 @@ pub fn check_async() { module::async(); // OK module::r#async(); // OK } + +fn main() {} diff --git a/src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr b/src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr index c6e4d01a64964..98fa249394081 100644 --- a/src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr +++ b/src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr @@ -11,4 +11,3 @@ LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the t | ^^^^^ no rules expected this token in macro call error: aborting due to 2 previous errors - diff --git a/src/test/ui/editions/edition-keywords-2018-2018-expansion.rs b/src/test/ui/editions/edition-keywords-2018-2018-expansion.rs index 2db0a2dde2ed0..6f766550d4734 100644 --- a/src/test/ui/editions/edition-keywords-2018-2018-expansion.rs +++ b/src/test/ui/editions/edition-keywords-2018-2018-expansion.rs @@ -10,3 +10,5 @@ mod one_async { mod two_async { produces_async_raw! {} // OK } + +fn main() {} diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-derive-2.rs b/src/test/ui/feature-gate/issue-43106-gating-of-derive-2.rs index 352f56f7aca99..5f276f6b65ebc 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-derive-2.rs +++ b/src/test/ui/feature-gate/issue-43106-gating-of-derive-2.rs @@ -13,3 +13,5 @@ mod derive { //~^ ERROR cannot find derive macro `x3300` in this scope struct S; } + +fn main() {} diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-derive.rs b/src/test/ui/feature-gate/issue-43106-gating-of-derive.rs index 8bac49816ad9f..1397412988491 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-derive.rs +++ b/src/test/ui/feature-gate/issue-43106-gating-of-derive.rs @@ -31,3 +31,5 @@ mod derive { //~^ ERROR `derive` may only be applied to structs, enums and unions impl S { } } + +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.rs b/src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.rs index 1786ec246abe2..db1a7dad06bc3 100644 --- a/src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.rs +++ b/src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.rs @@ -1,3 +1,5 @@ +#![feature(intrinsics, lang_items, no_core)] + #![crate_type="rlib"] #![no_core] diff --git a/src/test/ui/feature-gates/feature-gate-macros_in_extern.rs b/src/test/ui/feature-gates/feature-gate-macros_in_extern.rs index 8f8147a742395..125af64fef05c 100644 --- a/src/test/ui/feature-gates/feature-gate-macros_in_extern.rs +++ b/src/test/ui/feature-gates/feature-gate-macros_in_extern.rs @@ -23,3 +23,5 @@ extern { emits_nothing!(); //~^ ERROR macro invocations in `extern {}` blocks are experimental } + +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-rustc-attrs.rs b/src/test/ui/feature-gates/feature-gate-rustc-attrs.rs index 993daca075613..5ec413cc71de0 100644 --- a/src/test/ui/feature-gates/feature-gate-rustc-attrs.rs +++ b/src/test/ui/feature-gates/feature-gate-rustc-attrs.rs @@ -1,8 +1,6 @@ -// ignore-tidy-linelength - // Test that `#[rustc_*]` attributes are gated by `rustc_attrs` feature gate. #[rustc_foo] -//~^ ERROR unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics +//~^ ERROR unless otherwise specified, attributes with the prefix `rustc_` are reserved fn main() {} diff --git a/src/test/ui/issues/issue-10536.rs b/src/test/ui/issues/issue-10536.rs index f8695caca5b61..a2df2913afb91 100644 --- a/src/test/ui/issues/issue-10536.rs +++ b/src/test/ui/issues/issue-10536.rs @@ -1,8 +1,6 @@ // We only want to assert that this doesn't ICE, we don't particularly care // about whether it nor it fails to compile. -// error-pattern: - macro_rules! foo{ () => {{ macro_rules! bar{() => (())} @@ -15,9 +13,12 @@ pub fn main() { assert!({one! two()}); //~^ ERROR macros that expand to items must either be surrounded with braces or followed by a + //~| ERROR cannot find macro `one!` in this scope + //~| ERROR mismatched types // regardless of whether nested macro_rules works, the following should at // least throw a conventional error. assert!({one! two}); - //~^ ERROR expected + //~^ ERROR expected `(` or `{`, found `}` + //~| ERROR cannot apply unary operator `!` to type `!` } diff --git a/src/test/ui/issues/issue-10536.stderr b/src/test/ui/issues/issue-10536.stderr index bc542ce35c0ab..6b2424d3a45dd 100644 --- a/src/test/ui/issues/issue-10536.stderr +++ b/src/test/ui/issues/issue-10536.stderr @@ -10,5 +10,28 @@ error: expected `(` or `{`, found `}` LL | assert!({one! two}); | ^ expected `(` or `{` -error: aborting due to 2 previous errors +error: cannot find macro `one!` in this scope + --> $DIR/issue-10536.rs:24:14 + | +LL | assert!({one! two()}); + | ^^^ + +error[E0308]: mismatched types + --> $DIR/issue-10536.rs:24:13 + | +LL | assert!({one! two()}); + | ^^^^^^^^^^^^ expected bool, found () + | + = note: expected type `bool` + found type `()` + +error[E0600]: cannot apply unary operator `!` to type `!` + --> $DIR/issue-10536.rs:31:5 + | +LL | assert!({one! two}); + | ^^^^^^^^^^^^^^^^^^^^ cannot apply unary operator `!` + +error: aborting due to 5 previous errors +Some errors occurred: E0308, E0600. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/issues/issue-11692-1.rs b/src/test/ui/issues/issue-11692-1.rs index eae555ad83cfd..2277778040292 100644 --- a/src/test/ui/issues/issue-11692-1.rs +++ b/src/test/ui/issues/issue-11692-1.rs @@ -1,4 +1,5 @@ fn main() { print!(testo!()); //~^ ERROR: format argument must be a string literal + //~| ERROR: cannot find macro `testo!` in this scope } diff --git a/src/test/ui/issues/issue-11692-1.stderr b/src/test/ui/issues/issue-11692-1.stderr index 1173e056321dd..e0c4642ea60f1 100644 --- a/src/test/ui/issues/issue-11692-1.stderr +++ b/src/test/ui/issues/issue-11692-1.stderr @@ -8,5 +8,11 @@ help: you might be missing a string literal to format with LL | print!("{}", testo!()); | ^^^^^ -error: aborting due to previous error +error: cannot find macro `testo!` in this scope + --> $DIR/issue-11692-1.rs:12:12 + | +LL | print!(testo!()); + | ^^^^^ + +error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-11692-2.rs b/src/test/ui/issues/issue-11692-2.rs index 61be284d7320e..6103931657342 100644 --- a/src/test/ui/issues/issue-11692-2.rs +++ b/src/test/ui/issues/issue-11692-2.rs @@ -1,3 +1,4 @@ fn main() { concat!(test!()); //~ ERROR cannot find macro `test!` in this scope + //~| ERROR expected a literal } diff --git a/src/test/ui/issues/issue-11692-2.stderr b/src/test/ui/issues/issue-11692-2.stderr index 5d4467080f149..16cf7b0dca7e1 100644 --- a/src/test/ui/issues/issue-11692-2.stderr +++ b/src/test/ui/issues/issue-11692-2.stderr @@ -1,8 +1,16 @@ +error: expected a literal + --> $DIR/issue-11692-2.rs:12:13 + | +LL | concat!(test!()); //~ ERROR cannot find macro `test!` in this scope + | ^^^^^^^ + | + = note: only literals (like `"foo"`, `42` and `3.14`) can be passed to `concat!()` + error: cannot find macro `test!` in this scope --> $DIR/issue-11692-2.rs:2:13 | LL | concat!(test!()); //~ ERROR cannot find macro `test!` in this scope | ^^^^ -error: aborting due to previous error +error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-32950.rs b/src/test/ui/issues/issue-32950.rs index dc5b063ada4bf..27d68a11c1f16 100644 --- a/src/test/ui/issues/issue-32950.rs +++ b/src/test/ui/issues/issue-32950.rs @@ -3,6 +3,7 @@ #[derive(Debug)] struct Baz( concat_idents!(Foo, Bar) //~ ERROR `derive` cannot be used on items with type macros + //~^ ERROR cannot find type `FooBar` in this scope ); fn main() {} diff --git a/src/test/ui/issues/issue-32950.stderr b/src/test/ui/issues/issue-32950.stderr index e8e3347af2e1e..af148cbb5c692 100644 --- a/src/test/ui/issues/issue-32950.stderr +++ b/src/test/ui/issues/issue-32950.stderr @@ -4,5 +4,12 @@ error: `derive` cannot be used on items with type macros LL | concat_idents!(Foo, Bar) //~ ERROR `derive` cannot be used on items with type macros | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +error[E0412]: cannot find type `FooBar` in this scope + --> $DIR/issue-32950.rs:15:5 + | +LL | concat_idents!(Foo, Bar) //~ ERROR `derive` cannot be used on items with type macros + | ^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0412`. diff --git a/src/test/ui/issues/issue-33571.rs b/src/test/ui/issues/issue-33571.rs index 5f9c514addbde..223bbc3ff5e21 100644 --- a/src/test/ui/issues/issue-33571.rs +++ b/src/test/ui/issues/issue-33571.rs @@ -2,3 +2,5 @@ Sync, //~ ERROR this unsafe trait should be implemented explicitly Copy)] enum Foo {} + +fn main() {} diff --git a/src/test/ui/issues/issue-35677.rs b/src/test/ui/issues/issue-35677.rs index 46d3f7e4af00b..71e2125ffd2cc 100644 --- a/src/test/ui/issues/issue-35677.rs +++ b/src/test/ui/issues/issue-35677.rs @@ -3,3 +3,5 @@ fn intersect_map(this: &mut HashMap, other: HashMap) -> bool { this.drain() //~^ ERROR no method named } + +fn main() {} diff --git a/src/test/ui/issues/issue-35677.stderr b/src/test/ui/issues/issue-35677.stderr index dca096b93f5f3..61ddb75b3b52c 100644 --- a/src/test/ui/issues/issue-35677.stderr +++ b/src/test/ui/issues/issue-35677.stderr @@ -1,7 +1,3 @@ -error[E0601]: `main` function not found in crate `issue_35677` - | - = note: consider adding a `main` function to `$DIR/issue-35677.rs` - error[E0599]: no method named `drain` found for type `&mut std::collections::HashMap` in the current scope --> $DIR/issue-35677.rs:3:10 | @@ -12,7 +8,6 @@ LL | this.drain() `K : std::cmp::Eq` `K : std::hash::Hash` -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors occurred: E0599, E0601. -For more information about an error, try `rustc --explain E0599`. +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/issues/issue-36617.rs b/src/test/ui/issues/issue-36617.rs index 846efac41c856..87092689a281d 100644 --- a/src/test/ui/issues/issue-36617.rs +++ b/src/test/ui/issues/issue-36617.rs @@ -1 +1,3 @@ #![derive(Copy)] //~ ERROR `derive` may only be applied to structs, enums and unions + +fn main() {} diff --git a/src/test/ui/issues/issue-43023.rs b/src/test/ui/issues/issue-43023.rs index 32bd66f5a939c..072243d881ca6 100644 --- a/src/test/ui/issues/issue-43023.rs +++ b/src/test/ui/issues/issue-43023.rs @@ -16,3 +16,5 @@ trait Tr2 { #[derive(Debug)] //~ ERROR `derive` may only be applied to structs, enums and unions type F; } + +fn main() {} diff --git a/src/test/ui/issues/issue-46438.rs b/src/test/ui/issues/issue-46438.rs index a16c4c31d81c4..d78b958463fcb 100644 --- a/src/test/ui/issues/issue-46438.rs +++ b/src/test/ui/issues/issue-46438.rs @@ -4,7 +4,7 @@ macro_rules! m { } } -trait Trait {} +trait Tr {} m!(Tr); diff --git a/src/test/ui/issues/issue-49074.rs b/src/test/ui/issues/issue-49074.rs index dbd96e96191e1..ad66e421c6b9d 100644 --- a/src/test/ui/issues/issue-49074.rs +++ b/src/test/ui/issues/issue-49074.rs @@ -9,5 +9,5 @@ mod foo { } fn main() { - bar!(); + bar!(); //~ ERROR cannot find macro `bar!` in this scope } diff --git a/src/test/ui/issues/issue-49074.stderr b/src/test/ui/issues/issue-49074.stderr index 8de4d081413b1..6b5e979082e93 100644 --- a/src/test/ui/issues/issue-49074.stderr +++ b/src/test/ui/issues/issue-49074.stderr @@ -6,6 +6,14 @@ LL | #[marco_use] // typo | = help: add #![feature(custom_attribute)] to the crate attributes to enable -error: aborting due to previous error +error: cannot find macro `bar!` in this scope + --> $DIR/issue-49074.rs:22:4 + | +LL | bar!(); //~ ERROR cannot find macro `bar!` in this scope + | ^^^ + | + = help: have you added the `#[macro_use]` on the module/import? + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/issues/issue-51279.rs b/src/test/ui/issues/issue-51279.rs index caef23043cba3..ad5438fbd46cb 100644 --- a/src/test/ui/issues/issue-51279.rs +++ b/src/test/ui/issues/issue-51279.rs @@ -22,3 +22,4 @@ unsafe impl<#[cfg_attr(none, may_dangle)] T> Drop for M { type Z<#[ignored] 'a, #[cfg(none)] T> = X<'a, T>; //~^ ERROR #[cfg] cannot be applied on a generic parameter +//~| ERROR attribute `ignored` is currently unknown to the compiler diff --git a/src/test/ui/issues/issue-51279.stderr b/src/test/ui/issues/issue-51279.stderr index 89786f72e182e..33afac39865ad 100644 --- a/src/test/ui/issues/issue-51279.stderr +++ b/src/test/ui/issues/issue-51279.stderr @@ -46,5 +46,14 @@ error: #[cfg] cannot be applied on a generic parameter LL | type Z<#[ignored] 'a, #[cfg(none)] T> = X<'a, T>; | ^^^^^^^^^^^^ -error: aborting due to 8 previous errors +error[E0658]: The attribute `ignored` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) + --> $DIR/issue-51279.rs:33:8 + | +LL | type Z<#[ignored] 'a, #[cfg(none)] T> = X<'a, T>; + | ^^^^^^^^^^ + | + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error: aborting due to 9 previous errors +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/issues/issue-55796.rs b/src/test/ui/issues/issue-55796.rs index a172f6a7bfad1..efdea5c9b1e16 100644 --- a/src/test/ui/issues/issue-55796.rs +++ b/src/test/ui/issues/issue-55796.rs @@ -22,3 +22,5 @@ pub trait Graph<'a> { //~^ ERROR cannot infer } } + +fn main() {} diff --git a/src/test/ui/issues/issue-55796.stderr b/src/test/ui/issues/issue-55796.stderr index f8ca0727efb7e..c05f8b85d0e98 100644 --- a/src/test/ui/issues/issue-55796.stderr +++ b/src/test/ui/issues/issue-55796.stderr @@ -1,7 +1,3 @@ -error[E0601]: `main` function not found in crate `issue_55796` - | - = note: consider adding a `main` function to `$DIR/issue-55796.rs` - error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements --> $DIR/issue-55796.rs:16:9 | @@ -44,7 +40,6 @@ LL | Box::new(self.in_edges(u).map(|e| e.target())) expected std::boxed::Box<(dyn std::iter::Iterator>::Node> + 'static)> found std::boxed::Box>::Node>> -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors occurred: E0495, E0601. -For more information about an error, try `rustc --explain E0495`. +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/issues/issue-6596-1.rs b/src/test/ui/issues/issue-6596-1.rs index 5da54451346a5..6a5986c355e1c 100644 --- a/src/test/ui/issues/issue-6596-1.rs +++ b/src/test/ui/issues/issue-6596-1.rs @@ -2,6 +2,7 @@ macro_rules! e { ($inp:ident) => ( $nonexistent //~^ ERROR unknown macro variable `nonexistent` + //~| ERROR cannot find value `nonexistent` in this scope ); } diff --git a/src/test/ui/issues/issue-6596-1.stderr b/src/test/ui/issues/issue-6596-1.stderr index 2a4ece2f2425f..face872591456 100644 --- a/src/test/ui/issues/issue-6596-1.stderr +++ b/src/test/ui/issues/issue-6596-1.stderr @@ -7,5 +7,15 @@ LL | $nonexistent LL | e!(foo); | -------- in this macro invocation -error: aborting due to previous error +error[E0425]: cannot find value `nonexistent` in this scope + --> $DIR/issue-6596-1.rs:14:9 + | +LL | $nonexistent + | ^^^^^^^^^^^^ not found in this scope +... +LL | e!(foo); + | -------- in this macro invocation + +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/issues/issue-6596-2.rs b/src/test/ui/issues/issue-6596-2.rs index 056a720bc5c6e..4ff7cfe386553 100644 --- a/src/test/ui/issues/issue-6596-2.rs +++ b/src/test/ui/issues/issue-6596-2.rs @@ -9,5 +9,6 @@ macro_rules! g { } fn main() { + let foo = 0; g!(foo); } diff --git a/src/test/ui/macro_backtrace/main.rs b/src/test/ui/macro_backtrace/main.rs index fd2f1b7a286ac..2c11ce56f8b83 100644 --- a/src/test/ui/macro_backtrace/main.rs +++ b/src/test/ui/macro_backtrace/main.rs @@ -12,6 +12,8 @@ macro_rules! pong { //~| ERROR expected one of //~| ERROR expected one of +struct syntax; + fn main() { pong!(); ping!(); diff --git a/src/test/ui/macros/macro-comma-behavior.core.stderr b/src/test/ui/macros/macro-comma-behavior.core.stderr index b3988717b372d..7a4b9278e0a61 100644 --- a/src/test/ui/macros/macro-comma-behavior.core.stderr +++ b/src/test/ui/macros/macro-comma-behavior.core.stderr @@ -40,5 +40,11 @@ error: 1 positional argument in format string, but no arguments were given LL | write!(f, "{}",)?; | ^^ -error: aborting due to 7 previous errors +error: `#[panic_handler]` function required, but not found + +error: language item required, but not found: `eh_personality` + +error: language item required, but not found: `eh_unwind_resume` + +error: aborting due to 10 previous errors diff --git a/src/test/ui/malformed/malformed-derive-entry.rs b/src/test/ui/malformed/malformed-derive-entry.rs index 5978258b5d8da..2c8ebc497728b 100644 --- a/src/test/ui/malformed/malformed-derive-entry.rs +++ b/src/test/ui/malformed/malformed-derive-entry.rs @@ -13,3 +13,5 @@ struct Test3; #[derive] //~^ WARNING empty trait list struct Test4; + +fn main() {} diff --git a/src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.rs b/src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.rs index 60f8684968fe0..866c5b2e34bbd 100644 --- a/src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.rs +++ b/src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.rs @@ -3,3 +3,5 @@ // error-pattern:cannot depend on a crate that needs a panic runtime extern crate depends; + +fn main() {} diff --git a/src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.stderr b/src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.stderr index 0e68c9b806d1d..27e27dda5effe 100644 --- a/src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.stderr +++ b/src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.stderr @@ -1,9 +1,4 @@ error: the crate `depends` cannot depend on a crate that needs a panic runtime, but it depends on `needs_panic_runtime` -error[E0601]: `main` function not found in crate `runtime_depend_on_needs_runtime` - | - = note: consider adding a `main` function to `$DIR/runtime-depend-on-needs-runtime.rs` +error: aborting due to previous error -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0601`. diff --git a/src/test/ui/parser/macro/pub-item-macro.rs b/src/test/ui/parser/macro/pub-item-macro.rs index 7bab86539827a..bae90227c62f4 100644 --- a/src/test/ui/parser/macro/pub-item-macro.rs +++ b/src/test/ui/parser/macro/pub-item-macro.rs @@ -14,5 +14,5 @@ mod foo { } fn main() { - let y: u32 = foo::x; + let y: u32 = foo::x; //~ ERROR static `x` is private } diff --git a/src/test/ui/parser/macro/pub-item-macro.stderr b/src/test/ui/parser/macro/pub-item-macro.stderr index a801986ed4e34..fb7a1fce54955 100644 --- a/src/test/ui/parser/macro/pub-item-macro.stderr +++ b/src/test/ui/parser/macro/pub-item-macro.stderr @@ -9,5 +9,12 @@ LL | pub_x!(); | = help: try adjusting the macro to put `pub` inside the invocation -error: aborting due to previous error +error[E0603]: static `x` is private + --> $DIR/pub-item-macro.rs:27:23 + | +LL | let y: u32 = foo::x; //~ ERROR static `x` is private + | ^ + +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/proc-macro/issue-41211.rs b/src/test/ui/proc-macro/issue-41211.rs index 50678818bf8bc..0b082f4818f1b 100644 --- a/src/test/ui/proc-macro/issue-41211.rs +++ b/src/test/ui/proc-macro/issue-41211.rs @@ -7,6 +7,7 @@ #![emit_unchanged] //~^ ERROR attribute `emit_unchanged` is currently unknown to the compiler +//~| ERROR inconsistent resolution for a macro: first custom attribute, then attribute macro extern crate issue_41211; use issue_41211::emit_unchanged; diff --git a/src/test/ui/proc-macro/issue-41211.stderr b/src/test/ui/proc-macro/issue-41211.stderr index 41f51aea6fcfb..2c702c7871d05 100644 --- a/src/test/ui/proc-macro/issue-41211.stderr +++ b/src/test/ui/proc-macro/issue-41211.stderr @@ -6,6 +6,12 @@ LL | #![emit_unchanged] | = help: add #![feature(custom_attribute)] to the crate attributes to enable -error: aborting due to previous error +error: inconsistent resolution for a macro: first custom attribute, then attribute macro + --> $DIR/issue-41211.rs:18:4 + | +LL | #![emit_unchanged] + | ^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/proc-macro/lifetimes.rs b/src/test/ui/proc-macro/lifetimes.rs index 44700ca447ddc..d0dd1b4603b16 100644 --- a/src/test/ui/proc-macro/lifetimes.rs +++ b/src/test/ui/proc-macro/lifetimes.rs @@ -7,3 +7,5 @@ extern crate lifetimes; use lifetimes::*; type A = single_quote_alone!(); //~ ERROR expected type, found `'` + +fn main() {} diff --git a/src/test/ui/proc-macro/more-gates.rs b/src/test/ui/proc-macro/more-gates.rs index e3fb96b90edef..b870b438a6540 100644 --- a/src/test/ui/proc-macro/more-gates.rs +++ b/src/test/ui/proc-macro/more-gates.rs @@ -1,5 +1,7 @@ // aux-build:more-gates.rs +#![feature(decl_macro)] + extern crate more_gates as foo; use foo::*; diff --git a/src/test/ui/proc-macro/parent-source-spans.rs b/src/test/ui/proc-macro/parent-source-spans.rs index 2e12c34b99b1b..799f1de586ed4 100644 --- a/src/test/ui/proc-macro/parent-source-spans.rs +++ b/src/test/ui/proc-macro/parent-source-spans.rs @@ -28,6 +28,9 @@ macro three($($tokens:tt)*) { macro four($($tokens:tt)*) { parent_source_spans!($($tokens)*); + //~^ ERROR cannot find value `ok` in this scope + //~| ERROR cannot find value `ok` in this scope + //~| ERROR cannot find value `ok` in this scope } fn main() { diff --git a/src/test/ui/proc-macro/parent-source-spans.stderr b/src/test/ui/proc-macro/parent-source-spans.stderr index c39d4c19eb500..2d9ebff88cb66 100644 --- a/src/test/ui/proc-macro/parent-source-spans.stderr +++ b/src/test/ui/proc-macro/parent-source-spans.stderr @@ -124,5 +124,33 @@ error: second source: "hop" LL | three!("hip", "hop"); | ^^^^^ -error: aborting due to 18 previous errors +error[E0425]: cannot find value `ok` in this scope + --> $DIR/parent-source-spans.rs:40:5 + | +LL | parent_source_spans!($($tokens)*); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ did you mean `Ok`? +... +LL | one!("hello", "world"); + | ----------------------- in this macro invocation + +error[E0425]: cannot find value `ok` in this scope + --> $DIR/parent-source-spans.rs:40:5 + | +LL | parent_source_spans!($($tokens)*); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ did you mean `Ok`? +... +LL | two!("yay", "rust"); + | -------------------- in this macro invocation + +error[E0425]: cannot find value `ok` in this scope + --> $DIR/parent-source-spans.rs:40:5 + | +LL | parent_source_spans!($($tokens)*); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ did you mean `Ok`? +... +LL | three!("hip", "hop"); + | --------------------- in this macro invocation + +error: aborting due to 21 previous errors +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/proc-macro/proc-macro-attributes.rs b/src/test/ui/proc-macro/proc-macro-attributes.rs index e05828209adb7..1cc824e943c75 100644 --- a/src/test/ui/proc-macro/proc-macro-attributes.rs +++ b/src/test/ui/proc-macro/proc-macro-attributes.rs @@ -3,11 +3,12 @@ #[macro_use] extern crate derive_b; -#[B] +#[B] //~ ERROR `B` is ambiguous #[C] //~ ERROR attribute `C` is currently unknown to the compiler -#[B(D)] -#[B(E = "foo")] -#[B(arbitrary tokens)] +#[B(D)] //~ ERROR `B` is ambiguous +#[B(E = "foo")] //~ ERROR `B` is ambiguous +#[B(arbitrary tokens)] //~ ERROR `B` is ambiguous + //~^ ERROR expected one of `(`, `)`, `,`, `::`, or `=`, found `tokens` #[derive(B)] struct B; diff --git a/src/test/ui/proc-macro/proc-macro-attributes.stderr b/src/test/ui/proc-macro/proc-macro-attributes.stderr index ecdc55588514a..8b87e482282bd 100644 --- a/src/test/ui/proc-macro/proc-macro-attributes.stderr +++ b/src/test/ui/proc-macro/proc-macro-attributes.stderr @@ -6,6 +6,81 @@ LL | #[C] //~ ERROR attribute `C` is currently unknown to the compiler | = help: add #![feature(custom_attribute)] to the crate attributes to enable -error: aborting due to previous error +error[E0659]: `B` is ambiguous (derive helper attribute vs any other name) + --> $DIR/proc-macro-attributes.rs:16:3 + | +LL | #[B] //~ ERROR `B` is ambiguous + | ^ ambiguous name + | +note: `B` could refer to the derive helper attribute defined here + --> $DIR/proc-macro-attributes.rs:22:10 + | +LL | #[derive(B)] + | ^ +note: `B` could also refer to the derive macro imported here + --> $DIR/proc-macro-attributes.rs:13:1 + | +LL | #[macro_use] + | ^^^^^^^^^^^^ + +error[E0659]: `B` is ambiguous (derive helper attribute vs any other name) + --> $DIR/proc-macro-attributes.rs:18:3 + | +LL | #[B(D)] //~ ERROR `B` is ambiguous + | ^ ambiguous name + | +note: `B` could refer to the derive helper attribute defined here + --> $DIR/proc-macro-attributes.rs:22:10 + | +LL | #[derive(B)] + | ^ +note: `B` could also refer to the derive macro imported here + --> $DIR/proc-macro-attributes.rs:13:1 + | +LL | #[macro_use] + | ^^^^^^^^^^^^ + +error[E0659]: `B` is ambiguous (derive helper attribute vs any other name) + --> $DIR/proc-macro-attributes.rs:19:3 + | +LL | #[B(E = "foo")] //~ ERROR `B` is ambiguous + | ^ ambiguous name + | +note: `B` could refer to the derive helper attribute defined here + --> $DIR/proc-macro-attributes.rs:22:10 + | +LL | #[derive(B)] + | ^ +note: `B` could also refer to the derive macro imported here + --> $DIR/proc-macro-attributes.rs:13:1 + | +LL | #[macro_use] + | ^^^^^^^^^^^^ + +error[E0659]: `B` is ambiguous (derive helper attribute vs any other name) + --> $DIR/proc-macro-attributes.rs:20:3 + | +LL | #[B(arbitrary tokens)] //~ ERROR `B` is ambiguous + | ^ ambiguous name + | +note: `B` could refer to the derive helper attribute defined here + --> $DIR/proc-macro-attributes.rs:22:10 + | +LL | #[derive(B)] + | ^ +note: `B` could also refer to the derive macro imported here + --> $DIR/proc-macro-attributes.rs:13:1 + | +LL | #[macro_use] + | ^^^^^^^^^^^^ + +error: expected one of `(`, `)`, `,`, `::`, or `=`, found `tokens` + --> $DIR/proc-macro-attributes.rs:20:15 + | +LL | #[B(arbitrary tokens)] //~ ERROR `B` is ambiguous + | ^^^^^^ expected one of `(`, `)`, `,`, `::`, or `=` here + +error: aborting due to 6 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors occurred: E0658, E0659. +For more information about an error, try `rustc --explain E0658`. diff --git a/src/test/ui/quote-with-interpolated.rs b/src/test/ui/quote-with-interpolated.rs index dd79d2b3e4a6e..b948226652b45 100644 --- a/src/test/ui/quote-with-interpolated.rs +++ b/src/test/ui/quote-with-interpolated.rs @@ -2,7 +2,12 @@ fn main() { macro_rules! foo { ($bar:expr) => { - quote_expr!(cx, $bar) //~ ERROR quote! with interpolated token + quote_expr!(cx, $bar) + //~^ ERROR quote! with interpolated token + //~| ERROR failed to resolve: maybe a missing `extern crate syntax;`? + //~| ERROR failed to resolve: maybe a missing `extern crate syntax;`? + //~| ERROR cannot find value `cx` in this scope + //~| ERROR cannot find function `new_parser_from_tts` in this scope } } foo!(bar); diff --git a/src/test/ui/quote-with-interpolated.stderr b/src/test/ui/quote-with-interpolated.stderr index 89f4db0ad3c15..3c582286662af 100644 --- a/src/test/ui/quote-with-interpolated.stderr +++ b/src/test/ui/quote-with-interpolated.stderr @@ -1,11 +1,40 @@ error: quote! with interpolated token --> $DIR/quote-with-interpolated.rs:5:29 | -LL | quote_expr!(cx, $bar) //~ ERROR quote! with interpolated token +LL | quote_expr!(cx, $bar) | ^^^^ ... LL | foo!(bar); | ---------- in this macro invocation -error: aborting due to previous error +error[E0433]: failed to resolve: maybe a missing `extern crate syntax;`? + --> $DIR/quote-with-interpolated.rs:15:13 + | +LL | quote_expr!(cx, $bar) + | ^^^^^^^^^^^^^^^^^^^^^ maybe a missing `extern crate syntax;`? + +error[E0433]: failed to resolve: maybe a missing `extern crate syntax;`? + --> $DIR/quote-with-interpolated.rs:15:29 + | +LL | quote_expr!(cx, $bar) + | ^^^^ maybe a missing `extern crate syntax;`? + +error[E0425]: cannot find value `cx` in this scope + --> $DIR/quote-with-interpolated.rs:15:25 + | +LL | quote_expr!(cx, $bar) + | ^^ not found in this scope +... +LL | foo!(bar); + | ---------- in this macro invocation + +error[E0425]: cannot find function `new_parser_from_tts` in this scope + --> $DIR/quote-with-interpolated.rs:15:13 + | +LL | quote_expr!(cx, $bar) + | ^^^^^^^^^^^^^^^^^^^^^ not found in this scope + +error: aborting due to 5 previous errors +Some errors occurred: E0425, E0433. +For more information about an error, try `rustc --explain E0425`. diff --git a/src/test/ui/reserved/reserved-attr-on-macro.rs b/src/test/ui/reserved/reserved-attr-on-macro.rs index 0b00d711036ff..96c63ba4db8c9 100644 --- a/src/test/ui/reserved/reserved-attr-on-macro.rs +++ b/src/test/ui/reserved/reserved-attr-on-macro.rs @@ -1,8 +1,9 @@ -#[rustc_attribute_should_be_reserved] //~ ERROR attributes with the prefix `rustc_` are reserved +#[rustc_attribute_should_be_reserved] +//~^ ERROR unless otherwise specified, attributes with the prefix `rustc_` are reserved macro_rules! foo { () => (()); } fn main() { - foo!(); + foo!(); //~ ERROR cannot determine resolution for the macro `foo` } diff --git a/src/test/ui/reserved/reserved-attr-on-macro.stderr b/src/test/ui/reserved/reserved-attr-on-macro.stderr index 0d7fa70772282..4f1c0e1aa7074 100644 --- a/src/test/ui/reserved/reserved-attr-on-macro.stderr +++ b/src/test/ui/reserved/reserved-attr-on-macro.stderr @@ -1,11 +1,19 @@ error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics (see issue #29642) --> $DIR/reserved-attr-on-macro.rs:1:3 | -LL | #[rustc_attribute_should_be_reserved] //~ ERROR attributes with the prefix `rustc_` are reserved +LL | #[rustc_attribute_should_be_reserved] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(rustc_attrs)] to the crate attributes to enable -error: aborting due to previous error +error: cannot determine resolution for the macro `foo` + --> $DIR/reserved-attr-on-macro.rs:18:5 + | +LL | foo!(); //~ ERROR cannot determine resolution for the macro `foo` + | ^^^ + | + = note: import resolution is stuck, try simplifying macro imports + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/self/self_type_keyword.rs b/src/test/ui/self/self_type_keyword.rs index 742318d1e959d..4a1681e4e2b8a 100644 --- a/src/test/ui/self/self_type_keyword.rs +++ b/src/test/ui/self/self_type_keyword.rs @@ -7,6 +7,7 @@ mod foo { struct Bar<'Self>; //~^ ERROR lifetimes cannot use keyword names +//~| ERROR parameter `'Self` is never used struct Foo; diff --git a/src/test/ui/self/self_type_keyword.stderr b/src/test/ui/self/self_type_keyword.stderr index 3b095b7841839..1981e23c88a1c 100644 --- a/src/test/ui/self/self_type_keyword.stderr +++ b/src/test/ui/self/self_type_keyword.stderr @@ -58,5 +58,14 @@ error: cannot find macro `Self!` in this scope LL | Self!() => (), | ^^^^ -error: aborting due to 10 previous errors +error[E0392]: parameter `'Self` is never used + --> $DIR/self_type_keyword.rs:18:12 + | +LL | struct Bar<'Self>; + | ^^^^^ unused type parameter + | + = help: consider removing `'Self` or using a marker such as `std::marker::PhantomData` + +error: aborting due to 11 previous errors +For more information about this error, try `rustc --explain E0392`. diff --git a/src/test/ui/span/issue-36530.rs b/src/test/ui/span/issue-36530.rs index 663e52075195b..e11be9e17f20d 100644 --- a/src/test/ui/span/issue-36530.rs +++ b/src/test/ui/span/issue-36530.rs @@ -5,3 +5,5 @@ mod foo { #![foo] //~ ERROR is currently unknown to the compiler //~| ERROR non-builtin inner attributes are unstable } + +fn main() {} diff --git a/src/test/ui/span/macro-ty-params.rs b/src/test/ui/span/macro-ty-params.rs index f36574e2b3d3d..b077d590915cb 100644 --- a/src/test/ui/span/macro-ty-params.rs +++ b/src/test/ui/span/macro-ty-params.rs @@ -4,9 +4,11 @@ macro_rules! m { } } +macro_rules! foo { () => () } + fn main() { foo::!(); //~ ERROR generic arguments in macro path foo::<>!(); //~ ERROR generic arguments in macro path - m!(MyTrait<>); //~ ERROR generic arguments in macro path + m!(Default<>); //~ ERROR generic arguments in macro path //~^ ERROR unexpected generic arguments in path } diff --git a/src/test/ui/span/macro-ty-params.stderr b/src/test/ui/span/macro-ty-params.stderr index 79ae4a7e784c9..c1dcc513f3a0a 100644 --- a/src/test/ui/span/macro-ty-params.stderr +++ b/src/test/ui/span/macro-ty-params.stderr @@ -1,26 +1,25 @@ error: unexpected generic arguments in path --> $DIR/macro-ty-params.rs:10:8 | -LL | m!(MyTrait<>); //~ ERROR generic arguments in macro path - | ^^^^^^^^^ +LL | foo::!(); //~ ERROR generic arguments in macro path + | ^^^^^ error: generic arguments in macro path --> $DIR/macro-ty-params.rs:10:15 | -LL | m!(MyTrait<>); //~ ERROR generic arguments in macro path - | ^^ +LL | foo::<>!(); //~ ERROR generic arguments in macro path + | ^^^^ error: generic arguments in macro path --> $DIR/macro-ty-params.rs:8:8 | -LL | foo::!(); //~ ERROR generic arguments in macro path - | ^^^^^ +LL | m!(Default<>); //~ ERROR generic arguments in macro path + | ^^^^^^^^^ error: generic arguments in macro path --> $DIR/macro-ty-params.rs:9:8 | -LL | foo::<>!(); //~ ERROR generic arguments in macro path - | ^^^^ +LL | m!(Default<>); //~ ERROR generic arguments in macro path + | ^^ error: aborting due to 4 previous errors - diff --git a/src/test/ui/span/visibility-ty-params.rs b/src/test/ui/span/visibility-ty-params.rs index a9aaabad95cee..d77febe0aa22b 100644 --- a/src/test/ui/span/visibility-ty-params.rs +++ b/src/test/ui/span/visibility-ty-params.rs @@ -4,6 +4,7 @@ macro_rules! m { struct S(T); m!{ S } //~ ERROR unexpected generic arguments in path + //~| ERROR expected module, found struct `S` mod m { m!{ m<> } //~ ERROR unexpected generic arguments in path diff --git a/src/test/ui/span/visibility-ty-params.stderr b/src/test/ui/span/visibility-ty-params.stderr index 52b8042ba454f..9a11eea6532b2 100644 --- a/src/test/ui/span/visibility-ty-params.stderr +++ b/src/test/ui/span/visibility-ty-params.stderr @@ -10,5 +10,14 @@ error: unexpected generic arguments in path LL | m!{ m<> } //~ ERROR unexpected generic arguments in path | ^^^ -error: aborting due to 2 previous errors +error[E0577]: expected module, found struct `S` + --> $DIR/visibility-ty-params.rs:16:5 + | +LL | m!{ S } //~ ERROR unexpected generic arguments in path + | -^^^^ + | | + | did you mean `m`? + +error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0577`. diff --git a/src/test/ui/tuple/tuple-struct-fields/test2.rs b/src/test/ui/tuple/tuple-struct-fields/test2.rs index 7c8e9bbb23c28..fc0f78b12c9f7 100644 --- a/src/test/ui/tuple/tuple-struct-fields/test2.rs +++ b/src/test/ui/tuple/tuple-struct-fields/test2.rs @@ -8,5 +8,7 @@ macro_rules! define_struct { } mod foo { - define_struct! { (foo) } + define_struct! { (foo) } //~ ERROR cannot find type `foo` in this scope } + +fn main() {} diff --git a/src/test/ui/tuple/tuple-struct-fields/test2.stderr b/src/test/ui/tuple/tuple-struct-fields/test2.stderr index 9aba84046a1a7..baca625b0bde5 100644 --- a/src/test/ui/tuple/tuple-struct-fields/test2.stderr +++ b/src/test/ui/tuple/tuple-struct-fields/test2.stderr @@ -4,8 +4,15 @@ error: expected one of `)` or `,`, found `(` LL | struct S3(pub $t ()); | ^ expected one of `)` or `,` here ... -LL | define_struct! { (foo) } +LL | define_struct! { (foo) } //~ ERROR cannot find type `foo` in this scope | ------------------------ in this macro invocation -error: aborting due to previous error +error[E0412]: cannot find type `foo` in this scope + --> $DIR/test2.rs:21:23 + | +LL | define_struct! { (foo) } //~ ERROR cannot find type `foo` in this scope + | ^^^ not found in this scope + +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0412`. diff --git a/src/test/ui/tuple/tuple-struct-fields/test3.rs b/src/test/ui/tuple/tuple-struct-fields/test3.rs index 8d7c7c35caff9..6b8534b452411 100644 --- a/src/test/ui/tuple/tuple-struct-fields/test3.rs +++ b/src/test/ui/tuple/tuple-struct-fields/test3.rs @@ -8,5 +8,7 @@ macro_rules! define_struct { } mod foo { - define_struct! { foo } + define_struct! { foo } //~ ERROR cannot find type `foo` in this scope } + +fn main() {} diff --git a/src/test/ui/tuple/tuple-struct-fields/test3.stderr b/src/test/ui/tuple/tuple-struct-fields/test3.stderr index fc71354a9d640..2da34fff53da6 100644 --- a/src/test/ui/tuple/tuple-struct-fields/test3.stderr +++ b/src/test/ui/tuple/tuple-struct-fields/test3.stderr @@ -4,8 +4,15 @@ error: expected one of `)` or `,`, found `(` LL | struct S3(pub($t) ()); | ^ expected one of `)` or `,` here ... -LL | define_struct! { foo } +LL | define_struct! { foo } //~ ERROR cannot find type `foo` in this scope | ---------------------- in this macro invocation -error: aborting due to previous error +error[E0412]: cannot find type `foo` in this scope + --> $DIR/test3.rs:21:22 + | +LL | define_struct! { foo } //~ ERROR cannot find type `foo` in this scope + | ^^^ not found in this scope + +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0412`. From 4ac592516f0627778ac4aaee52acd7d7591e5cb3 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Thu, 20 Dec 2018 02:33:56 +0300 Subject: [PATCH 3/7] Get rid of `Block::recovered` --- src/librustc/hir/lowering.rs | 3 --- src/librustc/hir/mod.rs | 5 ----- src/librustc/ich/impls_hir.rs | 1 - src/librustc_driver/pretty.rs | 6 ++---- src/librustc_typeck/check/mod.rs | 7 +------ src/libsyntax/ast.rs | 1 - src/libsyntax/ext/build.rs | 1 - src/libsyntax/fold.rs | 3 +-- src/libsyntax/parse/parser.rs | 12 ++++++------ src/libsyntax_ext/deriving/mod.rs | 1 - src/test/run-pass-fulldeps/pprust-expr-roundtrip.rs | 1 - src/test/ui/issues/issue-10536.rs | 1 - src/test/ui/issues/issue-10536.stderr | 11 ++--------- 13 files changed, 12 insertions(+), 41 deletions(-) diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 59b9f83c242ec..32514caff876c 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -2709,7 +2709,6 @@ impl<'a> LoweringContext<'a> { rules: self.lower_block_check_mode(&b.rules), span: b.span, targeted_by_break, - recovered: b.recovered, }) } @@ -3781,7 +3780,6 @@ impl<'a> LoweringContext<'a> { rules: hir::DefaultBlock, span, targeted_by_break: false, - recovered: blk.recovered, }); P(self.expr_block(blk, ThinVec::new())) } @@ -4823,7 +4821,6 @@ impl<'a> LoweringContext<'a> { rules: hir::DefaultBlock, span, targeted_by_break: false, - recovered: false, } } diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 601d310fc3a21..56144129ef4c2 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -807,11 +807,6 @@ pub struct Block { /// break out of this block early. /// Used by `'label: {}` blocks and by `catch` statements. pub targeted_by_break: bool, - /// If true, don't emit return value type errors as the parser had - /// to recover from a parse error so this block will not have an - /// appropriate type. A parse error will have been emitted so the - /// compilation will never succeed if this is true. - pub recovered: bool, } #[derive(Clone, RustcEncodable, RustcDecodable)] diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index 006f11d51e400..bf9efb54b600f 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -410,7 +410,6 @@ impl_stable_hash_for!(struct hir::Block { rules, span, targeted_by_break, - recovered, }); impl_stable_hash_for!(struct hir::Pat { diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index 6a455be726861..a9ec99358c1b2 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -741,7 +741,6 @@ impl<'a> fold::Folder for ReplaceBodyWithLoop<'a> { fn fold_block(&mut self, b: P) -> P { fn stmt_to_block(rules: ast::BlockCheckMode, - recovered: bool, s: Option, sess: &Session) -> ast::Block { ast::Block { @@ -749,7 +748,6 @@ impl<'a> fold::Folder for ReplaceBodyWithLoop<'a> { rules, id: sess.next_node_id(), span: syntax_pos::DUMMY_SP, - recovered, } } @@ -768,7 +766,7 @@ impl<'a> fold::Folder for ReplaceBodyWithLoop<'a> { } } - let empty_block = stmt_to_block(BlockCheckMode::Default, false, None, self.sess); + let empty_block = stmt_to_block(BlockCheckMode::Default, None, self.sess); let loop_expr = P(ast::Expr { node: ast::ExprKind::Loop(P(empty_block), None), id: self.sess.next_node_id(), @@ -809,7 +807,7 @@ impl<'a> fold::Folder for ReplaceBodyWithLoop<'a> { old_blocks.push(new_block); } - stmt_to_block(b.rules, b.recovered, Some(loop_stmt), self.sess) + stmt_to_block(b.rules, Some(loop_stmt), self.sess) } else { //push `loop {}` onto the end of our fresh block and yield that new_block.stmts.push(loop_stmt); diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 0cfe06451a7d7..b3c24be108da7 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4772,12 +4772,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // // #41425 -- label the implicit `()` as being the // "found type" here, rather than the "expected type". - // - // #44579 -- if the block was recovered during parsing, - // the type would be nonsensical and it is not worth it - // to perform the type check, so we avoid generating the - // diagnostic output. - if !self.diverges.get().always() && !blk.recovered { + if !self.diverges.get().always() { coerce.coerce_forced_unit(self, &self.misc(blk.span), &mut |err| { if let Some(expected_ty) = expected.only_has_type(self) { self.consider_hint_about_removing_semicolon(blk, diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index f0e567f9cd651..e3a8980a975c1 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -444,7 +444,6 @@ pub struct Block { /// Distinguishes between `unsafe { ... }` and `{ ... }` pub rules: BlockCheckMode, pub span: Span, - pub recovered: bool, } #[derive(Clone, RustcEncodable, RustcDecodable)] diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 15faae5391668..a8eec1a74dd2b 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -587,7 +587,6 @@ impl<'a> AstBuilder for ExtCtxt<'a> { id: ast::DUMMY_NODE_ID, rules: BlockCheckMode::Default, span, - recovered: false, }) } diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index b8990264c5df5..8ac103856dcd1 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -892,12 +892,11 @@ fn noop_fold_bounds(bounds: GenericBounds, folder: &mut T) } pub fn noop_fold_block(b: P, folder: &mut T) -> P { - b.map(|Block {id, stmts, rules, span, recovered}| Block { + b.map(|Block {id, stmts, rules, span}| Block { id: folder.new_id(id), stmts: stmts.move_flat_map(|s| folder.fold_stmt(s).into_iter()), rules, span: folder.new_span(span), - recovered, }) } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index e6f0d8712223b..d68a6546f4865 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -32,6 +32,7 @@ use ast::{UseTree, UseTreeKind}; use ast::{BinOpKind, UnOp}; use ast::{RangeEnd, RangeSyntax}; use {ast, attr}; +use ext::base::DummyResult; use source_map::{self, SourceMap, Spanned, respan}; use syntax_pos::{self, Span, MultiSpan, BytePos, FileName}; use errors::{self, Applicability, DiagnosticBuilder, DiagnosticId}; @@ -4966,16 +4967,16 @@ impl<'a> Parser<'a> { /// Precondition: already parsed the '{'. fn parse_block_tail(&mut self, lo: Span, s: BlockCheckMode) -> PResult<'a, P> { let mut stmts = vec![]; - let mut recovered = false; - while !self.eat(&token::CloseDelim(token::Brace)) { let stmt = match self.parse_full_stmt(false) { Err(mut err) => { err.emit(); self.recover_stmt_(SemiColonMode::Ignore, BlockMode::Ignore); - self.eat(&token::CloseDelim(token::Brace)); - recovered = true; - break; + Some(Stmt { + id: ast::DUMMY_NODE_ID, + node: StmtKind::Expr(DummyResult::raw_expr(self.span)), + span: self.span, + }) } Ok(stmt) => stmt, }; @@ -4993,7 +4994,6 @@ impl<'a> Parser<'a> { id: ast::DUMMY_NODE_ID, rules: s, span: lo.to(self.prev_span), - recovered, })) } diff --git a/src/libsyntax_ext/deriving/mod.rs b/src/libsyntax_ext/deriving/mod.rs index 85b864dee532f..7548d43f18444 100644 --- a/src/libsyntax_ext/deriving/mod.rs +++ b/src/libsyntax_ext/deriving/mod.rs @@ -153,6 +153,5 @@ fn call_intrinsic(cx: &ExtCtxt, id: ast::DUMMY_NODE_ID, rules: ast::BlockCheckMode::Unsafe(ast::CompilerGenerated), span, - recovered: false, })) } diff --git a/src/test/run-pass-fulldeps/pprust-expr-roundtrip.rs b/src/test/run-pass-fulldeps/pprust-expr-roundtrip.rs index f99b5e5196354..ce3b03efd2604 100644 --- a/src/test/run-pass-fulldeps/pprust-expr-roundtrip.rs +++ b/src/test/run-pass-fulldeps/pprust-expr-roundtrip.rs @@ -105,7 +105,6 @@ fn iter_exprs(depth: usize, f: &mut FnMut(P)) { id: DUMMY_NODE_ID, rules: BlockCheckMode::Default, span: DUMMY_SP, - recovered: false, }); iter_exprs(depth - 1, &mut |e| g(ExprKind::If(e, block.clone(), None))); }, diff --git a/src/test/ui/issues/issue-10536.rs b/src/test/ui/issues/issue-10536.rs index a2df2913afb91..95c8c2b0585b6 100644 --- a/src/test/ui/issues/issue-10536.rs +++ b/src/test/ui/issues/issue-10536.rs @@ -20,5 +20,4 @@ pub fn main() { // least throw a conventional error. assert!({one! two}); //~^ ERROR expected `(` or `{`, found `}` - //~| ERROR cannot apply unary operator `!` to type `!` } diff --git a/src/test/ui/issues/issue-10536.stderr b/src/test/ui/issues/issue-10536.stderr index 6b2424d3a45dd..0b6c357b9206b 100644 --- a/src/test/ui/issues/issue-10536.stderr +++ b/src/test/ui/issues/issue-10536.stderr @@ -25,13 +25,6 @@ LL | assert!({one! two()}); = note: expected type `bool` found type `()` -error[E0600]: cannot apply unary operator `!` to type `!` - --> $DIR/issue-10536.rs:31:5 - | -LL | assert!({one! two}); - | ^^^^^^^^^^^^^^^^^^^^ cannot apply unary operator `!` - -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors -Some errors occurred: E0308, E0600. -For more information about an error, try `rustc --explain E0308`. +For more information about this error, try `rustc --explain E0308`. From b99fb2f5445fa5a791cca7601c7d609aaf708304 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Thu, 20 Dec 2018 03:57:48 +0300 Subject: [PATCH 4/7] Fix `trace_macros` and `log_syntax` --- src/libsyntax/ext/base.rs | 30 ++++++++++++++++----------- src/libsyntax/parse/parser.rs | 2 +- src/libsyntax_ext/deriving/default.rs | 2 +- src/libsyntax_ext/format.rs | 6 +++--- src/libsyntax_ext/log_syntax.rs | 2 +- src/libsyntax_ext/trace_macros.rs | 2 +- 6 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 84aa57d7d86e6..1efe0b3478db7 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -456,7 +456,8 @@ impl MacResult for MacEager { #[derive(Copy, Clone)] pub struct DummyResult { expr_only: bool, - span: Span + is_error: bool, + span: Span, } impl DummyResult { @@ -464,8 +465,13 @@ impl DummyResult { /// /// Use this as a return value after hitting any errors and /// calling `span_err`. - pub fn any(sp: Span) -> Box { - Box::new(DummyResult { expr_only: false, span: sp }) + pub fn any(span: Span) -> Box { + Box::new(DummyResult { expr_only: false, is_error: true, span }) + } + + /// Same as `any`, but must be a valid fragment, not error. + pub fn any_valid(span: Span) -> Box { + Box::new(DummyResult { expr_only: false, is_error: false, span }) } /// Create a default MacResult that can only be an expression. @@ -473,15 +479,15 @@ impl DummyResult { /// Use this for macros that must expand to an expression, so even /// if an error is encountered internally, the user will receive /// an error that they also used it in the wrong place. - pub fn expr(sp: Span) -> Box { - Box::new(DummyResult { expr_only: true, span: sp }) + pub fn expr(span: Span) -> Box { + Box::new(DummyResult { expr_only: true, is_error: true, span }) } /// A plain dummy expression. - pub fn raw_expr(sp: Span) -> P { + pub fn raw_expr(sp: Span, is_error: bool) -> P { P(ast::Expr { id: ast::DUMMY_NODE_ID, - node: ast::ExprKind::Err, + node: if is_error { ast::ExprKind::Err } else { ast::ExprKind::Tup(Vec::new()) }, span: sp, attrs: ThinVec::new(), }) @@ -497,10 +503,10 @@ impl DummyResult { } /// A plain dummy type. - pub fn raw_ty(sp: Span) -> P { + pub fn raw_ty(sp: Span, is_error: bool) -> P { P(ast::Ty { id: ast::DUMMY_NODE_ID, - node: ast::TyKind::Err, + node: if is_error { ast::TyKind::Err } else { ast::TyKind::Tup(Vec::new()) }, span: sp }) } @@ -508,7 +514,7 @@ impl DummyResult { impl MacResult for DummyResult { fn make_expr(self: Box) -> Option> { - Some(DummyResult::raw_expr(self.span)) + Some(DummyResult::raw_expr(self.span, self.is_error)) } fn make_pat(self: Box) -> Option> { @@ -551,13 +557,13 @@ impl MacResult for DummyResult { fn make_stmts(self: Box) -> Option> { Some(smallvec![ast::Stmt { id: ast::DUMMY_NODE_ID, - node: ast::StmtKind::Expr(DummyResult::raw_expr(self.span)), + node: ast::StmtKind::Expr(DummyResult::raw_expr(self.span, self.is_error)), span: self.span, }]) } fn make_ty(self: Box) -> Option> { - Some(DummyResult::raw_ty(self.span)) + Some(DummyResult::raw_ty(self.span, self.is_error)) } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index d68a6546f4865..11d570072cd63 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4974,7 +4974,7 @@ impl<'a> Parser<'a> { self.recover_stmt_(SemiColonMode::Ignore, BlockMode::Ignore); Some(Stmt { id: ast::DUMMY_NODE_ID, - node: StmtKind::Expr(DummyResult::raw_expr(self.span)), + node: StmtKind::Expr(DummyResult::raw_expr(self.span, true)), span: self.span, }) } diff --git a/src/libsyntax_ext/deriving/default.rs b/src/libsyntax_ext/deriving/default.rs index 771a559b37ccf..32d02bec7989b 100644 --- a/src/libsyntax_ext/deriving/default.rs +++ b/src/libsyntax_ext/deriving/default.rs @@ -69,7 +69,7 @@ fn default_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructur span_err!(cx, trait_span, E0665, "`Default` cannot be derived for enums, only structs"); // let compilation continue - DummyResult::raw_expr(trait_span) + DummyResult::raw_expr(trait_span, true) } _ => cx.span_bug(trait_span, "Non-static method in `derive(Default)`"), }; diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index c6f427e63cd8d..1051650348037 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -666,7 +666,7 @@ impl<'a, 'b> Context<'a, 'b> { "X" => "UpperHex", _ => { ecx.span_err(sp, &format!("unknown format trait `{}`", *tyname)); - return DummyResult::raw_expr(sp); + return DummyResult::raw_expr(sp, true); } } } @@ -761,7 +761,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, Applicability::MaybeIncorrect, ); err.emit(); - return DummyResult::raw_expr(sp); + return DummyResult::raw_expr(sp, true); } }; @@ -857,7 +857,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, e.span_label(sp, label); } e.emit(); - return DummyResult::raw_expr(sp); + return DummyResult::raw_expr(sp, true); } let arg_spans = parser.arg_places.iter() diff --git a/src/libsyntax_ext/log_syntax.rs b/src/libsyntax_ext/log_syntax.rs index 5f24ed81cddb9..f6bb1285c5353 100644 --- a/src/libsyntax_ext/log_syntax.rs +++ b/src/libsyntax_ext/log_syntax.rs @@ -20,5 +20,5 @@ pub fn expand_syntax_ext<'cx>(cx: &'cx mut base::ExtCtxt, println!("{}", print::pprust::tts_to_string(tts)); // any so that `log_syntax` can be invoked as an expression and item. - base::DummyResult::any(sp) + base::DummyResult::any_valid(sp) } diff --git a/src/libsyntax_ext/trace_macros.rs b/src/libsyntax_ext/trace_macros.rs index f17c6de19d967..b20da5af09a82 100644 --- a/src/libsyntax_ext/trace_macros.rs +++ b/src/libsyntax_ext/trace_macros.rs @@ -28,5 +28,5 @@ pub fn expand_trace_macros(cx: &mut ExtCtxt, _ => cx.span_err(sp, "trace_macros! accepts only `true` or `false`"), } - base::DummyResult::any(sp) + base::DummyResult::any_valid(sp) } From 15cefe4b2a65bb2a4febcd353cb37b90dfafa4f1 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 21 Dec 2018 01:47:03 +0300 Subject: [PATCH 5/7] Make sure feature gate errors are recoverable --- src/librustc/lint/levels.rs | 6 ++-- src/librustc_typeck/collect.rs | 1 - src/libsyntax/ext/expand.rs | 1 - src/libsyntax_ext/asm.rs | 1 - src/libsyntax_ext/concat_idents.rs | 1 - src/libsyntax_ext/format.rs | 1 - src/libsyntax_ext/global_asm.rs | 1 - src/libsyntax_ext/log_syntax.rs | 1 - src/libsyntax_ext/test_case.rs | 2 -- src/libsyntax_ext/trace_macros.rs | 1 - .../ui/feature-gates/feature-gate-asm2.rs | 2 +- .../ui/feature-gates/feature-gate-asm2.stderr | 4 +-- .../feature-gate-concat_idents2.rs | 1 + .../feature-gate-concat_idents2.stderr | 11 ++++-- .../feature-gate-log_syntax.stdout | 1 + .../feature-gates/feature-gate-log_syntax2.rs | 2 +- .../feature-gate-log_syntax2.stderr | 4 +-- .../feature-gate-log_syntax2.stdout | 1 + src/test/ui/trace_macros-gate.rs | 12 ++----- src/test/ui/trace_macros-gate.stderr | 36 +++++-------------- 20 files changed, 32 insertions(+), 58 deletions(-) create mode 100644 src/test/ui/feature-gates/feature-gate-log_syntax.stdout create mode 100644 src/test/ui/feature-gates/feature-gate-log_syntax2.stdout diff --git a/src/librustc/lint/levels.rs b/src/librustc/lint/levels.rs index 363ee9fa76588..1ae12fec50661 100644 --- a/src/librustc/lint/levels.rs +++ b/src/librustc/lint/levels.rs @@ -222,14 +222,13 @@ impl<'a> LintLevelsBuilder<'a> { match item.node { ast::MetaItemKind::Word => {} // actual lint names handled later ast::MetaItemKind::NameValue(ref name_value) => { - let gate_reasons = !self.sess.features_untracked().lint_reasons; if item.ident == "reason" { // found reason, reslice meta list to exclude it metas = &metas[0..metas.len()-1]; // FIXME (#55112): issue unused-attributes lint if we thereby // don't have any lint names (`#[level(reason = "foo")]`) if let ast::LitKind::Str(rationale, _) = name_value.node { - if gate_reasons { + if !self.sess.features_untracked().lint_reasons { feature_gate::emit_feature_err( &self.sess.parse_sess, "lint_reasons", @@ -237,9 +236,8 @@ impl<'a> LintLevelsBuilder<'a> { feature_gate::GateIssue::Language, "lint reasons are experimental" ); - } else { - reason = Some(rationale); } + reason = Some(rationale); } else { let mut err = bad_attr(name_value.span); err.help("reason must be a string literal"); diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index a46309c5ea14f..54dfc57bac674 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -2210,7 +2210,6 @@ fn from_target_feature( feature_gate::GateIssue::Language, &format!("the target feature `{}` is currently unstable", feature), ); - return None; } Some(Symbol::intern(feature)) })); diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index f8f1e83077028..3863778fe72af 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -722,7 +722,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> { emit_feature_err(this.cx.parse_sess, &*feature.as_str(), span, GateIssue::Library(Some(issue)), &explain); this.cx.trace_macros_diag(); - return Err(kind.dummy(span)); } } diff --git a/src/libsyntax_ext/asm.rs b/src/libsyntax_ext/asm.rs index b781e0203e45a..a8f3c40db609c 100644 --- a/src/libsyntax_ext/asm.rs +++ b/src/libsyntax_ext/asm.rs @@ -49,7 +49,6 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp, feature_gate::GateIssue::Language, feature_gate::EXPLAIN_ASM); - return DummyResult::expr(sp); } // Split the tts before the first colon, to avoid `asm!("x": y)` being diff --git a/src/libsyntax_ext/concat_idents.rs b/src/libsyntax_ext/concat_idents.rs index e2375c6cc19c1..9c49a59678fdb 100644 --- a/src/libsyntax_ext/concat_idents.rs +++ b/src/libsyntax_ext/concat_idents.rs @@ -20,7 +20,6 @@ pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt, sp, feature_gate::GateIssue::Language, feature_gate::EXPLAIN_CONCAT_IDENTS); - return base::DummyResult::expr(sp); } if tts.is_empty() { diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 1051650348037..9d29e2b0fb69a 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -713,7 +713,6 @@ pub fn expand_format_args_nl<'cx>( sp, feature_gate::GateIssue::Language, feature_gate::EXPLAIN_FORMAT_ARGS_NL); - return DummyResult::expr(sp); } sp = sp.apply_mark(ecx.current_expansion.mark); match parse_args(ecx, sp, tts) { diff --git a/src/libsyntax_ext/global_asm.rs b/src/libsyntax_ext/global_asm.rs index 16b7ac178bee3..a58c267ab4fae 100644 --- a/src/libsyntax_ext/global_asm.rs +++ b/src/libsyntax_ext/global_asm.rs @@ -29,7 +29,6 @@ pub fn expand_global_asm<'cx>(cx: &'cx mut ExtCtxt, sp, feature_gate::GateIssue::Language, feature_gate::EXPLAIN_GLOBAL_ASM); - return DummyResult::any(sp); } let mut p = cx.new_parser_from_tts(tts); diff --git a/src/libsyntax_ext/log_syntax.rs b/src/libsyntax_ext/log_syntax.rs index f6bb1285c5353..a143186b9451f 100644 --- a/src/libsyntax_ext/log_syntax.rs +++ b/src/libsyntax_ext/log_syntax.rs @@ -14,7 +14,6 @@ pub fn expand_syntax_ext<'cx>(cx: &'cx mut base::ExtCtxt, sp, feature_gate::GateIssue::Language, feature_gate::EXPLAIN_LOG_SYNTAX); - return base::DummyResult::any(sp); } println!("{}", print::pprust::tts_to_string(tts)); diff --git a/src/libsyntax_ext/test_case.rs b/src/libsyntax_ext/test_case.rs index c467370eed317..04e33671872f5 100644 --- a/src/libsyntax_ext/test_case.rs +++ b/src/libsyntax_ext/test_case.rs @@ -31,8 +31,6 @@ pub fn expand( attr_sp, feature_gate::GateIssue::Language, feature_gate::EXPLAIN_CUSTOM_TEST_FRAMEWORKS); - - return vec![anno_item]; } if !ecx.ecfg.should_test { return vec![]; } diff --git a/src/libsyntax_ext/trace_macros.rs b/src/libsyntax_ext/trace_macros.rs index b20da5af09a82..638d7b5568bfb 100644 --- a/src/libsyntax_ext/trace_macros.rs +++ b/src/libsyntax_ext/trace_macros.rs @@ -15,7 +15,6 @@ pub fn expand_trace_macros(cx: &mut ExtCtxt, sp, feature_gate::GateIssue::Language, feature_gate::EXPLAIN_TRACE_MACROS); - return base::DummyResult::any(sp); } match (tt.len(), tt.first()) { diff --git a/src/test/ui/feature-gates/feature-gate-asm2.rs b/src/test/ui/feature-gates/feature-gate-asm2.rs index b842cba8a7d59..259b0a14e5c9b 100644 --- a/src/test/ui/feature-gates/feature-gate-asm2.rs +++ b/src/test/ui/feature-gates/feature-gate-asm2.rs @@ -2,6 +2,6 @@ fn main() { unsafe { - println!("{}", asm!("")); //~ ERROR inline assembly is not stable + println!("{:?}", asm!("")); //~ ERROR inline assembly is not stable } } diff --git a/src/test/ui/feature-gates/feature-gate-asm2.stderr b/src/test/ui/feature-gates/feature-gate-asm2.stderr index aadedc887071d..65c267a76959a 100644 --- a/src/test/ui/feature-gates/feature-gate-asm2.stderr +++ b/src/test/ui/feature-gates/feature-gate-asm2.stderr @@ -1,8 +1,8 @@ error[E0658]: inline assembly is not stable enough for use and is subject to change (see issue #29722) --> $DIR/feature-gate-asm2.rs:5:24 | -LL | println!("{}", asm!("")); //~ ERROR inline assembly is not stable - | ^^^^^^^^ +LL | println!("{:?}", asm!("")); //~ ERROR inline assembly is not stable + | ^^^^^^^^ | = help: add #![feature(asm)] to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-concat_idents2.rs b/src/test/ui/feature-gates/feature-gate-concat_idents2.rs index 659e962650128..0cc6c577e8d5e 100644 --- a/src/test/ui/feature-gates/feature-gate-concat_idents2.rs +++ b/src/test/ui/feature-gates/feature-gate-concat_idents2.rs @@ -2,4 +2,5 @@ fn main() { concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough + //~| ERROR cannot find value `ab` in this scope } diff --git a/src/test/ui/feature-gates/feature-gate-concat_idents2.stderr b/src/test/ui/feature-gates/feature-gate-concat_idents2.stderr index 23c2e2976451d..eb648cbd56f11 100644 --- a/src/test/ui/feature-gates/feature-gate-concat_idents2.stderr +++ b/src/test/ui/feature-gates/feature-gate-concat_idents2.stderr @@ -6,6 +6,13 @@ LL | concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough | = help: add #![feature(concat_idents)] to the crate attributes to enable -error: aborting due to previous error +error[E0425]: cannot find value `ab` in this scope + --> $DIR/feature-gate-concat_idents2.rs:14:5 + | +LL | concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough + | ^^^^^^^^^^^^^^^^^^^^^ not found in this scope + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors occurred: E0425, E0658. +For more information about an error, try `rustc --explain E0425`. diff --git a/src/test/ui/feature-gates/feature-gate-log_syntax.stdout b/src/test/ui/feature-gates/feature-gate-log_syntax.stdout new file mode 100644 index 0000000000000..8b137891791fe --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-log_syntax.stdout @@ -0,0 +1 @@ + diff --git a/src/test/ui/feature-gates/feature-gate-log_syntax2.rs b/src/test/ui/feature-gates/feature-gate-log_syntax2.rs index 95baea6f7e484..a3906dcc16e1c 100644 --- a/src/test/ui/feature-gates/feature-gate-log_syntax2.rs +++ b/src/test/ui/feature-gates/feature-gate-log_syntax2.rs @@ -1,5 +1,5 @@ // gate-test-log_syntax fn main() { - println!("{}", log_syntax!()); //~ ERROR `log_syntax!` is not stable + println!("{:?}", log_syntax!()); //~ ERROR `log_syntax!` is not stable } diff --git a/src/test/ui/feature-gates/feature-gate-log_syntax2.stderr b/src/test/ui/feature-gates/feature-gate-log_syntax2.stderr index 7f65794e5debd..9ed3bbf7b7588 100644 --- a/src/test/ui/feature-gates/feature-gate-log_syntax2.stderr +++ b/src/test/ui/feature-gates/feature-gate-log_syntax2.stderr @@ -1,8 +1,8 @@ error[E0658]: `log_syntax!` is not stable enough for use and is subject to change (see issue #29598) --> $DIR/feature-gate-log_syntax2.rs:4:20 | -LL | println!("{}", log_syntax!()); //~ ERROR `log_syntax!` is not stable - | ^^^^^^^^^^^^^ +LL | println!("{:?}", log_syntax!()); //~ ERROR `log_syntax!` is not stable + | ^^^^^^^^^^^^^ | = help: add #![feature(log_syntax)] to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-log_syntax2.stdout b/src/test/ui/feature-gates/feature-gate-log_syntax2.stdout new file mode 100644 index 0000000000000..8b137891791fe --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-log_syntax2.stdout @@ -0,0 +1 @@ + diff --git a/src/test/ui/trace_macros-gate.rs b/src/test/ui/trace_macros-gate.rs index d32ada5abc9db..c9af04741ac77 100644 --- a/src/test/ui/trace_macros-gate.rs +++ b/src/test/ui/trace_macros-gate.rs @@ -2,15 +2,9 @@ fn main() { trace_macros!(); //~ ERROR `trace_macros` is not stable - trace_macros!(1); //~ ERROR `trace_macros` is not stable - trace_macros!(ident); //~ ERROR `trace_macros` is not stable - trace_macros!(for); //~ ERROR `trace_macros` is not stable - trace_macros!(true,); //~ ERROR `trace_macros` is not stable - trace_macros!(false 1); //~ ERROR `trace_macros` is not stable - - // Errors are signalled early for the above, before expansion. - // See trace_macros-gate2 and trace_macros-gate3. for examples - // of the below being caught. + //~| ERROR trace_macros! accepts only `true` or `false` + trace_macros!(true); //~ ERROR `trace_macros` is not stable + trace_macros!(false); //~ ERROR `trace_macros` is not stable macro_rules! expando { ($x: ident) => { trace_macros!($x) } //~ ERROR `trace_macros` is not stable diff --git a/src/test/ui/trace_macros-gate.stderr b/src/test/ui/trace_macros-gate.stderr index 1f7d8e898b60f..a411fae8bcb61 100644 --- a/src/test/ui/trace_macros-gate.stderr +++ b/src/test/ui/trace_macros-gate.stderr @@ -6,48 +6,30 @@ LL | trace_macros!(); //~ ERROR `trace_macros` is not stable | = help: add #![feature(trace_macros)] to the crate attributes to enable -error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598) - --> $DIR/trace_macros-gate.rs:5:5 - | -LL | trace_macros!(1); //~ ERROR `trace_macros` is not stable - | ^^^^^^^^^^^^^^^^^ +error: trace_macros! accepts only `true` or `false` + --> $DIR/trace_macros-gate.rs:14:5 | - = help: add #![feature(trace_macros)] to the crate attributes to enable +LL | trace_macros!(); //~ ERROR `trace_macros` is not stable + | ^^^^^^^^^^^^^^^^ error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598) --> $DIR/trace_macros-gate.rs:6:5 | -LL | trace_macros!(ident); //~ ERROR `trace_macros` is not stable - | ^^^^^^^^^^^^^^^^^^^^^ +LL | trace_macros!(true); //~ ERROR `trace_macros` is not stable + | ^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(trace_macros)] to the crate attributes to enable error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598) --> $DIR/trace_macros-gate.rs:7:5 | -LL | trace_macros!(for); //~ ERROR `trace_macros` is not stable - | ^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(trace_macros)] to the crate attributes to enable - -error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598) - --> $DIR/trace_macros-gate.rs:8:5 - | -LL | trace_macros!(true,); //~ ERROR `trace_macros` is not stable +LL | trace_macros!(false); //~ ERROR `trace_macros` is not stable | ^^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(trace_macros)] to the crate attributes to enable error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598) - --> $DIR/trace_macros-gate.rs:9:5 - | -LL | trace_macros!(false 1); //~ ERROR `trace_macros` is not stable - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(trace_macros)] to the crate attributes to enable - -error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598) - --> $DIR/trace_macros-gate.rs:16:26 + --> $DIR/trace_macros-gate.rs:20:26 | LL | ($x: ident) => { trace_macros!($x) } //~ ERROR `trace_macros` is not stable | ^^^^^^^^^^^^^^^^^ @@ -57,6 +39,6 @@ LL | expando!(true); | = help: add #![feature(trace_macros)] to the crate attributes to enable -error: aborting due to 7 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0658`. From 37af04ff8d784969882296c0fb74aa3e68624873 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 21 Dec 2018 02:58:55 +0300 Subject: [PATCH 6/7] Address review comments and CI failures --- src/librustc_resolve/macros.rs | 2 +- src/libsyntax/parse/parser.rs | 1 + .../auxiliary/depends.rs | 0 .../auxiliary/needs-panic-runtime.rs | 0 .../runtime-depend-on-needs-runtime.rs | 0 .../runtime-depend-on-needs-runtime.stderr | 0 src/test/ui/issues/issue-6596-1.rs | 1 - src/test/ui/issues/issue-6596-1.stderr | 12 +----------- src/test/ui/issues/issue-6596-2.rs | 1 - src/test/ui/issues/issue-6596-2.stderr | 12 +----------- src/test/ui/macros/macro-comma-behavior.core.stderr | 5 +---- src/test/ui/macros/macro-comma-behavior.rs | 2 ++ src/test/ui/macros/macro-comma-behavior.std.stderr | 1 - 13 files changed, 7 insertions(+), 30 deletions(-) rename src/test/{ui/panic-runtime => compile-fail}/auxiliary/depends.rs (100%) rename src/test/{ui/panic-runtime => compile-fail}/auxiliary/needs-panic-runtime.rs (100%) rename src/test/{ui/panic-runtime => compile-fail}/runtime-depend-on-needs-runtime.rs (100%) rename src/test/{ui/panic-runtime => compile-fail}/runtime-depend-on-needs-runtime.stderr (100%) diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 9c0c8a6016fe5..182dcfe4098bb 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -186,7 +186,7 @@ impl<'a> base::Resolver for Resolver<'a> { Ok((def, ext)) => (def, ext), Err(Determinacy::Determined) if kind == MacroKind::Attr => { // Replace unresolved attributes with used inert attributes for better recovery. - return Ok(Some(self.get_macro(Def::NonMacroAttr(NonMacroAttrKind::Tool)))); + return Ok(Some(Lrc::new(SyntaxExtension::NonMacroAttr { mark_used: true }))); } Err(determinacy) => return Err(determinacy), }; diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 11d570072cd63..52da8a072c751 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2871,6 +2871,7 @@ impl<'a> Parser<'a> { let mut err = self.fatal(&format!("unknown macro variable `{}`", name)); err.span_label(self.span, "unknown macro variable"); err.emit(); + self.bump(); return } token::Interpolated(ref nt) => { diff --git a/src/test/ui/panic-runtime/auxiliary/depends.rs b/src/test/compile-fail/auxiliary/depends.rs similarity index 100% rename from src/test/ui/panic-runtime/auxiliary/depends.rs rename to src/test/compile-fail/auxiliary/depends.rs diff --git a/src/test/ui/panic-runtime/auxiliary/needs-panic-runtime.rs b/src/test/compile-fail/auxiliary/needs-panic-runtime.rs similarity index 100% rename from src/test/ui/panic-runtime/auxiliary/needs-panic-runtime.rs rename to src/test/compile-fail/auxiliary/needs-panic-runtime.rs diff --git a/src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.rs b/src/test/compile-fail/runtime-depend-on-needs-runtime.rs similarity index 100% rename from src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.rs rename to src/test/compile-fail/runtime-depend-on-needs-runtime.rs diff --git a/src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.stderr b/src/test/compile-fail/runtime-depend-on-needs-runtime.stderr similarity index 100% rename from src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.stderr rename to src/test/compile-fail/runtime-depend-on-needs-runtime.stderr diff --git a/src/test/ui/issues/issue-6596-1.rs b/src/test/ui/issues/issue-6596-1.rs index 6a5986c355e1c..5da54451346a5 100644 --- a/src/test/ui/issues/issue-6596-1.rs +++ b/src/test/ui/issues/issue-6596-1.rs @@ -2,7 +2,6 @@ macro_rules! e { ($inp:ident) => ( $nonexistent //~^ ERROR unknown macro variable `nonexistent` - //~| ERROR cannot find value `nonexistent` in this scope ); } diff --git a/src/test/ui/issues/issue-6596-1.stderr b/src/test/ui/issues/issue-6596-1.stderr index face872591456..2a4ece2f2425f 100644 --- a/src/test/ui/issues/issue-6596-1.stderr +++ b/src/test/ui/issues/issue-6596-1.stderr @@ -7,15 +7,5 @@ LL | $nonexistent LL | e!(foo); | -------- in this macro invocation -error[E0425]: cannot find value `nonexistent` in this scope - --> $DIR/issue-6596-1.rs:14:9 - | -LL | $nonexistent - | ^^^^^^^^^^^^ not found in this scope -... -LL | e!(foo); - | -------- in this macro invocation - -error: aborting due to 2 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/issues/issue-6596-2.rs b/src/test/ui/issues/issue-6596-2.rs index 4ff7cfe386553..b19700efe5ad3 100644 --- a/src/test/ui/issues/issue-6596-2.rs +++ b/src/test/ui/issues/issue-6596-2.rs @@ -4,7 +4,6 @@ macro_rules! g { ($inp:ident) => ( { $inp $nonexistent } //~^ ERROR unknown macro variable `nonexistent` - //~| ERROR expected one of ); } diff --git a/src/test/ui/issues/issue-6596-2.stderr b/src/test/ui/issues/issue-6596-2.stderr index 99decd177ef61..3e707ba6fffee 100644 --- a/src/test/ui/issues/issue-6596-2.stderr +++ b/src/test/ui/issues/issue-6596-2.stderr @@ -7,14 +7,4 @@ LL | { $inp $nonexistent } LL | g!(foo); | -------- in this macro invocation -error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `nonexistent` - --> $DIR/issue-6596-2.rs:5:16 - | -LL | { $inp $nonexistent } - | ^^^^^^^^^^^^ expected one of 8 possible tokens here -... -LL | g!(foo); - | -------- in this macro invocation - -error: aborting due to 2 previous errors - +error: aborting due to previous error diff --git a/src/test/ui/macros/macro-comma-behavior.core.stderr b/src/test/ui/macros/macro-comma-behavior.core.stderr index 7a4b9278e0a61..cd752352aefcb 100644 --- a/src/test/ui/macros/macro-comma-behavior.core.stderr +++ b/src/test/ui/macros/macro-comma-behavior.core.stderr @@ -44,7 +44,4 @@ error: `#[panic_handler]` function required, but not found error: language item required, but not found: `eh_personality` -error: language item required, but not found: `eh_unwind_resume` - -error: aborting due to 10 previous errors - +error: aborting due to 9 previous errors diff --git a/src/test/ui/macros/macro-comma-behavior.rs b/src/test/ui/macros/macro-comma-behavior.rs index 7bd4cb0d2e7ca..46b93edca3ab8 100644 --- a/src/test/ui/macros/macro-comma-behavior.rs +++ b/src/test/ui/macros/macro-comma-behavior.rs @@ -3,10 +3,12 @@ // compile-flags: -C debug_assertions=yes // revisions: std core +#![feature(lang_items)] #![cfg_attr(core, no_std)] #[cfg(std)] use std::fmt; #[cfg(core)] use core::fmt; +#[cfg(core)] #[lang = "eh_unwind_resume"] fn eh_unwind_resume() {} // (see documentation of the similarly-named test in run-pass) fn to_format_or_not_to_format() { diff --git a/src/test/ui/macros/macro-comma-behavior.std.stderr b/src/test/ui/macros/macro-comma-behavior.std.stderr index 8759d4efae615..e56ed40e024bf 100644 --- a/src/test/ui/macros/macro-comma-behavior.std.stderr +++ b/src/test/ui/macros/macro-comma-behavior.std.stderr @@ -59,4 +59,3 @@ LL | write!(f, "{}",)?; | ^^ error: aborting due to 10 previous errors - From bc16edeb28e38e5bbed8828fb6314b1cc5151235 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Thu, 27 Dec 2018 03:07:00 +0300 Subject: [PATCH 7/7] Fix rebase and more CI failures --- .../derive-on-trait-item-or-impl-item.stderr | 3 +- src/test/ui/did_you_mean/issue-40396.stderr | 28 +++++++-------- .../edition-keywords-2015-2015-parsing.stderr | 5 +-- .../edition-keywords-2015-2018-parsing.stderr | 5 +-- .../ui/feature-gates/feature-gate-asm2.stderr | 2 +- .../feature-gate-cfg-target-has-atomic.stderr | 36 +++++++++---------- .../feature-gate-concat_idents2.stderr | 2 +- .../feature-gate-log_syntax2.stderr | 2 +- .../feature-gate-rustc-attrs.stderr | 2 +- src/test/ui/issues/issue-10536.stderr | 6 ++-- src/test/ui/issues/issue-11692-1.stderr | 2 +- src/test/ui/issues/issue-11692-2.stderr | 2 +- src/test/ui/issues/issue-32950.stderr | 2 +- src/test/ui/issues/issue-49074.stderr | 2 +- src/test/ui/issues/issue-51279.stderr | 2 +- src/test/ui/issues/issue-6596-2.stderr | 1 + src/test/ui/macro_backtrace/main.rs | 1 + .../macros/macro-comma-behavior.core.stderr | 19 +++++----- src/test/ui/macros/macro-comma-behavior.rs | 2 ++ .../ui/macros/macro-comma-behavior.std.stderr | 21 +++++------ .../ui/parser/macro/pub-item-macro.stderr | 2 +- src/test/ui/proc-macro/issue-41211.stderr | 2 +- src/test/ui/proc-macro/more-gates.stderr | 10 +++--- .../ui/proc-macro/parent-source-spans.stderr | 30 ++++++++-------- .../proc-macro/proc-macro-attributes.stderr | 26 +++++++------- src/test/ui/quote-with-interpolated.stderr | 8 ++--- .../ui/reserved/reserved-attr-on-macro.stderr | 2 +- src/test/ui/self/self_type_keyword.stderr | 18 +++++----- src/test/ui/span/macro-ty-params.stderr | 11 +++--- src/test/ui/span/visibility-ty-params.stderr | 4 +-- src/test/ui/trace_macros-gate.stderr | 4 +-- .../ui/tuple/tuple-struct-fields/test2.stderr | 2 +- .../ui/tuple/tuple-struct-fields/test3.stderr | 2 +- 33 files changed, 136 insertions(+), 130 deletions(-) diff --git a/src/test/ui/derives/derive-on-trait-item-or-impl-item.stderr b/src/test/ui/derives/derive-on-trait-item-or-impl-item.stderr index 0088add7e7f6e..b3aa886cd4926 100644 --- a/src/test/ui/derives/derive-on-trait-item-or-impl-item.stderr +++ b/src/test/ui/derives/derive-on-trait-item-or-impl-item.stderr @@ -5,9 +5,10 @@ LL | #[derive(Clone)] | ^^^^^^^^^^^^^^^^ error: `derive` may only be applied to structs, enums and unions - --> $DIR/derive-on-trait-item-or-impl-item.rs:8:5 + --> $DIR/derive-on-trait-item-or-impl-item.rs:10:5 | LL | #[derive(Clone)] | ^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors + diff --git a/src/test/ui/did_you_mean/issue-40396.stderr b/src/test/ui/did_you_mean/issue-40396.stderr index 33884bbfecfcc..3f6886bc3f699 100644 --- a/src/test/ui/did_you_mean/issue-40396.stderr +++ b/src/test/ui/did_you_mean/issue-40396.stderr @@ -1,5 +1,5 @@ error: chained comparison operators require parentheses - --> $DIR/issue-40396.rs:2:37 + --> $DIR/issue-40396.rs:2:20 | LL | (0..13).collect>(); | ^^^^^^^^ @@ -8,7 +8,7 @@ LL | (0..13).collect>(); = help: or use `(...)` if you meant to specify fn arguments error: chained comparison operators require parentheses - --> $DIR/issue-40396.rs:6:25 + --> $DIR/issue-40396.rs:10:8 | LL | Vec::new(); | ^^^^^^^ @@ -17,7 +17,7 @@ LL | Vec::new(); = help: or use `(...)` if you meant to specify fn arguments error: chained comparison operators require parentheses - --> $DIR/issue-40396.rs:10:37 + --> $DIR/issue-40396.rs:18:20 | LL | (0..13).collect(); | ^^^^^^^^ @@ -26,7 +26,7 @@ LL | (0..13).collect(); = help: or use `(...)` if you meant to specify fn arguments error: chained comparison operators require parentheses - --> $DIR/issue-40396.rs:10:41 + --> $DIR/issue-40396.rs:18:24 | LL | (0..13).collect(); | ^^^^^^ @@ -35,49 +35,49 @@ LL | (0..13).collect(); = help: or use `(...)` if you meant to specify fn arguments error[E0423]: expected value, found struct `Vec` - --> $DIR/issue-40396.rs:12:21 + --> $DIR/issue-40396.rs:2:21 | LL | (0..13).collect>(); | ^^^ did you mean `Vec { /* fields */ }`? error[E0423]: expected value, found builtin type `i32` - --> $DIR/issue-40396.rs:12:25 + --> $DIR/issue-40396.rs:2:25 | LL | (0..13).collect>(); | ^^^ not a value error[E0423]: expected value, found struct `Vec` - --> $DIR/issue-40396.rs:20:5 + --> $DIR/issue-40396.rs:10:5 | LL | Vec::new(); | ^^^ did you mean `Vec { /* fields */ }`? error[E0423]: expected value, found builtin type `i32` - --> $DIR/issue-40396.rs:20:9 + --> $DIR/issue-40396.rs:10:9 | LL | Vec::new(); | ^^^ not a value error[E0425]: cannot find function `new` in the crate root - --> $DIR/issue-40396.rs:20:15 + --> $DIR/issue-40396.rs:10:15 | LL | Vec::new(); | ^^^ not found in the crate root error[E0423]: expected value, found struct `Vec` - --> $DIR/issue-40396.rs:28:21 + --> $DIR/issue-40396.rs:18:21 | LL | (0..13).collect(); | ^^^ did you mean `Vec { /* fields */ }`? error[E0423]: expected value, found builtin type `i32` - --> $DIR/issue-40396.rs:28:25 + --> $DIR/issue-40396.rs:18:25 | LL | (0..13).collect(); | ^^^ not a value error[E0615]: attempted to take value of method `collect` on type `std::ops::Range<{integer}>` - --> $DIR/issue-40396.rs:12:13 + --> $DIR/issue-40396.rs:2:13 | LL | (0..13).collect>(); | ^^^^^^^ @@ -85,7 +85,7 @@ LL | (0..13).collect>(); = help: maybe a `()` to call it is missing? error[E0615]: attempted to take value of method `collect` on type `std::ops::Range<{integer}>` - --> $DIR/issue-40396.rs:28:13 + --> $DIR/issue-40396.rs:18:13 | LL | (0..13).collect(); | ^^^^^^^ @@ -93,7 +93,7 @@ LL | (0..13).collect(); = help: maybe a `()` to call it is missing? error[E0308]: mismatched types - --> $DIR/issue-40396.rs:28:29 + --> $DIR/issue-40396.rs:18:29 | LL | (0..13).collect(); | ^^ expected bool, found () diff --git a/src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr b/src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr index 06901ad6ef0ee..f2a9da71ca56b 100644 --- a/src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr +++ b/src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr @@ -1,13 +1,14 @@ error: no rules expected the token `r#async` - --> $DIR/edition-keywords-2015-2015-parsing.rs:12:31 + --> $DIR/edition-keywords-2015-2015-parsing.rs:16:31 | LL | r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async` | ^^^^^^^ no rules expected this token in macro call error: no rules expected the token `async` - --> $DIR/edition-keywords-2015-2015-parsing.rs:13:35 + --> $DIR/edition-keywords-2015-2015-parsing.rs:17:35 | LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async` | ^^^^^ no rules expected this token in macro call error: aborting due to 2 previous errors + diff --git a/src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr b/src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr index 98fa249394081..fbb3b8bc75690 100644 --- a/src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr +++ b/src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr @@ -1,13 +1,14 @@ error: no rules expected the token `r#async` - --> $DIR/edition-keywords-2015-2018-parsing.rs:12:31 + --> $DIR/edition-keywords-2015-2018-parsing.rs:16:31 | LL | r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async` | ^^^^^^^ no rules expected this token in macro call error: no rules expected the token `async` - --> $DIR/edition-keywords-2015-2018-parsing.rs:13:35 + --> $DIR/edition-keywords-2015-2018-parsing.rs:17:35 | LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async` | ^^^^^ no rules expected this token in macro call error: aborting due to 2 previous errors + diff --git a/src/test/ui/feature-gates/feature-gate-asm2.stderr b/src/test/ui/feature-gates/feature-gate-asm2.stderr index 65c267a76959a..fc4aa57718ce3 100644 --- a/src/test/ui/feature-gates/feature-gate-asm2.stderr +++ b/src/test/ui/feature-gates/feature-gate-asm2.stderr @@ -1,5 +1,5 @@ error[E0658]: inline assembly is not stable enough for use and is subject to change (see issue #29722) - --> $DIR/feature-gate-asm2.rs:5:24 + --> $DIR/feature-gate-asm2.rs:5:26 | LL | println!("{:?}", asm!("")); //~ ERROR inline assembly is not stable | ^^^^^^^^ diff --git a/src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.stderr b/src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.stderr index e096f3a1def18..a2d5669bcdcbe 100644 --- a/src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.stderr +++ b/src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.stderr @@ -1,5 +1,5 @@ error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:13:7 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:15:7 | LL | #[cfg(target_has_atomic = "8")] | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | #[cfg(target_has_atomic = "8")] = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:19:7 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:21:7 | LL | #[cfg(target_has_atomic = "8")] | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | #[cfg(target_has_atomic = "8")] = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:24:7 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:26:7 | LL | #[cfg(target_has_atomic = "16")] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | #[cfg(target_has_atomic = "16")] = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:29:7 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:31:7 | LL | #[cfg(target_has_atomic = "16")] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | #[cfg(target_has_atomic = "16")] = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:34:7 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:36:7 | LL | #[cfg(target_has_atomic = "32")] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -39,7 +39,7 @@ LL | #[cfg(target_has_atomic = "32")] = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:39:7 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:41:7 | LL | #[cfg(target_has_atomic = "32")] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -47,7 +47,7 @@ LL | #[cfg(target_has_atomic = "32")] = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:44:7 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:46:7 | LL | #[cfg(target_has_atomic = "64")] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -55,7 +55,7 @@ LL | #[cfg(target_has_atomic = "64")] = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:49:7 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:51:7 | LL | #[cfg(target_has_atomic = "64")] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -63,7 +63,7 @@ LL | #[cfg(target_has_atomic = "64")] = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:54:7 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:56:7 | LL | #[cfg(target_has_atomic = "128")] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -71,7 +71,7 @@ LL | #[cfg(target_has_atomic = "128")] = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:59:7 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:61:7 | LL | #[cfg(target_has_atomic = "128")] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -79,7 +79,7 @@ LL | #[cfg(target_has_atomic = "128")] = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:64:7 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:66:7 | LL | #[cfg(target_has_atomic = "ptr")] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -87,7 +87,7 @@ LL | #[cfg(target_has_atomic = "ptr")] = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:69:7 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:71:7 | LL | #[cfg(target_has_atomic = "ptr")] | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -95,7 +95,7 @@ LL | #[cfg(target_has_atomic = "ptr")] = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:76:10 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:78:10 | LL | cfg!(target_has_atomic = "8"); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -103,7 +103,7 @@ LL | cfg!(target_has_atomic = "8"); = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:78:10 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:80:10 | LL | cfg!(target_has_atomic = "16"); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -111,7 +111,7 @@ LL | cfg!(target_has_atomic = "16"); = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:80:10 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:82:10 | LL | cfg!(target_has_atomic = "32"); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -119,7 +119,7 @@ LL | cfg!(target_has_atomic = "32"); = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:82:10 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:84:10 | LL | cfg!(target_has_atomic = "64"); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -127,7 +127,7 @@ LL | cfg!(target_has_atomic = "64"); = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:84:10 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:86:10 | LL | cfg!(target_has_atomic = "128"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -135,7 +135,7 @@ LL | cfg!(target_has_atomic = "128"); = help: add #![feature(cfg_target_has_atomic)] to the crate attributes to enable error[E0658]: `cfg(target_has_atomic)` is experimental and subject to change (see issue #32976) - --> $DIR/feature-gate-cfg-target-has-atomic.rs:86:10 + --> $DIR/feature-gate-cfg-target-has-atomic.rs:88:10 | LL | cfg!(target_has_atomic = "ptr"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/feature-gates/feature-gate-concat_idents2.stderr b/src/test/ui/feature-gates/feature-gate-concat_idents2.stderr index eb648cbd56f11..cae409019f7a6 100644 --- a/src/test/ui/feature-gates/feature-gate-concat_idents2.stderr +++ b/src/test/ui/feature-gates/feature-gate-concat_idents2.stderr @@ -7,7 +7,7 @@ LL | concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough = help: add #![feature(concat_idents)] to the crate attributes to enable error[E0425]: cannot find value `ab` in this scope - --> $DIR/feature-gate-concat_idents2.rs:14:5 + --> $DIR/feature-gate-concat_idents2.rs:4:5 | LL | concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough | ^^^^^^^^^^^^^^^^^^^^^ not found in this scope diff --git a/src/test/ui/feature-gates/feature-gate-log_syntax2.stderr b/src/test/ui/feature-gates/feature-gate-log_syntax2.stderr index 9ed3bbf7b7588..bdcd922c6e1e4 100644 --- a/src/test/ui/feature-gates/feature-gate-log_syntax2.stderr +++ b/src/test/ui/feature-gates/feature-gate-log_syntax2.stderr @@ -1,5 +1,5 @@ error[E0658]: `log_syntax!` is not stable enough for use and is subject to change (see issue #29598) - --> $DIR/feature-gate-log_syntax2.rs:4:20 + --> $DIR/feature-gate-log_syntax2.rs:4:22 | LL | println!("{:?}", log_syntax!()); //~ ERROR `log_syntax!` is not stable | ^^^^^^^^^^^^^ diff --git a/src/test/ui/feature-gates/feature-gate-rustc-attrs.stderr b/src/test/ui/feature-gates/feature-gate-rustc-attrs.stderr index 1d742c2fa9e5d..40e6d6d925679 100644 --- a/src/test/ui/feature-gates/feature-gate-rustc-attrs.stderr +++ b/src/test/ui/feature-gates/feature-gate-rustc-attrs.stderr @@ -1,5 +1,5 @@ error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics (see issue #29642) - --> $DIR/feature-gate-rustc-attrs.rs:5:3 + --> $DIR/feature-gate-rustc-attrs.rs:3:3 | LL | #[rustc_foo] | ^^^^^^^^^ diff --git a/src/test/ui/issues/issue-10536.stderr b/src/test/ui/issues/issue-10536.stderr index 0b6c357b9206b..d5caf777cd45e 100644 --- a/src/test/ui/issues/issue-10536.stderr +++ b/src/test/ui/issues/issue-10536.stderr @@ -1,5 +1,5 @@ error: macros that expand to items must either be surrounded with braces or followed by a semicolon - --> $DIR/issue-10536.rs:16:22 + --> $DIR/issue-10536.rs:14:22 | LL | assert!({one! two()}); | ^^ @@ -11,13 +11,13 @@ LL | assert!({one! two}); | ^ expected `(` or `{` error: cannot find macro `one!` in this scope - --> $DIR/issue-10536.rs:24:14 + --> $DIR/issue-10536.rs:14:14 | LL | assert!({one! two()}); | ^^^ error[E0308]: mismatched types - --> $DIR/issue-10536.rs:24:13 + --> $DIR/issue-10536.rs:14:13 | LL | assert!({one! two()}); | ^^^^^^^^^^^^ expected bool, found () diff --git a/src/test/ui/issues/issue-11692-1.stderr b/src/test/ui/issues/issue-11692-1.stderr index e0c4642ea60f1..f4cc825803a3b 100644 --- a/src/test/ui/issues/issue-11692-1.stderr +++ b/src/test/ui/issues/issue-11692-1.stderr @@ -9,7 +9,7 @@ LL | print!("{}", testo!()); | ^^^^^ error: cannot find macro `testo!` in this scope - --> $DIR/issue-11692-1.rs:12:12 + --> $DIR/issue-11692-1.rs:2:12 | LL | print!(testo!()); | ^^^^^ diff --git a/src/test/ui/issues/issue-11692-2.stderr b/src/test/ui/issues/issue-11692-2.stderr index 16cf7b0dca7e1..848415435a78b 100644 --- a/src/test/ui/issues/issue-11692-2.stderr +++ b/src/test/ui/issues/issue-11692-2.stderr @@ -1,5 +1,5 @@ error: expected a literal - --> $DIR/issue-11692-2.rs:12:13 + --> $DIR/issue-11692-2.rs:2:13 | LL | concat!(test!()); //~ ERROR cannot find macro `test!` in this scope | ^^^^^^^ diff --git a/src/test/ui/issues/issue-32950.stderr b/src/test/ui/issues/issue-32950.stderr index af148cbb5c692..13aed4a1756b3 100644 --- a/src/test/ui/issues/issue-32950.stderr +++ b/src/test/ui/issues/issue-32950.stderr @@ -5,7 +5,7 @@ LL | concat_idents!(Foo, Bar) //~ ERROR `derive` cannot be used on items wit | ^^^^^^^^^^^^^^^^^^^^^^^^ error[E0412]: cannot find type `FooBar` in this scope - --> $DIR/issue-32950.rs:15:5 + --> $DIR/issue-32950.rs:5:5 | LL | concat_idents!(Foo, Bar) //~ ERROR `derive` cannot be used on items with type macros | ^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope diff --git a/src/test/ui/issues/issue-49074.stderr b/src/test/ui/issues/issue-49074.stderr index 6b5e979082e93..d4648270f2d30 100644 --- a/src/test/ui/issues/issue-49074.stderr +++ b/src/test/ui/issues/issue-49074.stderr @@ -7,7 +7,7 @@ LL | #[marco_use] // typo = help: add #![feature(custom_attribute)] to the crate attributes to enable error: cannot find macro `bar!` in this scope - --> $DIR/issue-49074.rs:22:4 + --> $DIR/issue-49074.rs:12:4 | LL | bar!(); //~ ERROR cannot find macro `bar!` in this scope | ^^^ diff --git a/src/test/ui/issues/issue-51279.stderr b/src/test/ui/issues/issue-51279.stderr index 33afac39865ad..1706e98e83b63 100644 --- a/src/test/ui/issues/issue-51279.stderr +++ b/src/test/ui/issues/issue-51279.stderr @@ -47,7 +47,7 @@ LL | type Z<#[ignored] 'a, #[cfg(none)] T> = X<'a, T>; | ^^^^^^^^^^^^ error[E0658]: The attribute `ignored` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) - --> $DIR/issue-51279.rs:33:8 + --> $DIR/issue-51279.rs:23:8 | LL | type Z<#[ignored] 'a, #[cfg(none)] T> = X<'a, T>; | ^^^^^^^^^^ diff --git a/src/test/ui/issues/issue-6596-2.stderr b/src/test/ui/issues/issue-6596-2.stderr index 3e707ba6fffee..20fbe0fab0112 100644 --- a/src/test/ui/issues/issue-6596-2.stderr +++ b/src/test/ui/issues/issue-6596-2.stderr @@ -8,3 +8,4 @@ LL | g!(foo); | -------- in this macro invocation error: aborting due to previous error + diff --git a/src/test/ui/macro_backtrace/main.rs b/src/test/ui/macro_backtrace/main.rs index 2c11ce56f8b83..8fcd497f87b78 100644 --- a/src/test/ui/macro_backtrace/main.rs +++ b/src/test/ui/macro_backtrace/main.rs @@ -12,6 +12,7 @@ macro_rules! pong { //~| ERROR expected one of //~| ERROR expected one of +#[allow(non_camel_case_types)] struct syntax; fn main() { diff --git a/src/test/ui/macros/macro-comma-behavior.core.stderr b/src/test/ui/macros/macro-comma-behavior.core.stderr index cd752352aefcb..dd0cac659fd31 100644 --- a/src/test/ui/macros/macro-comma-behavior.core.stderr +++ b/src/test/ui/macros/macro-comma-behavior.core.stderr @@ -1,47 +1,44 @@ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:17:23 + --> $DIR/macro-comma-behavior.rs:21:23 | LL | assert_eq!(1, 1, "{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:20:23 + --> $DIR/macro-comma-behavior.rs:24:23 | LL | assert_ne!(1, 2, "{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:26:29 + --> $DIR/macro-comma-behavior.rs:30:29 | LL | debug_assert_eq!(1, 1, "{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:29:29 + --> $DIR/macro-comma-behavior.rs:33:29 | LL | debug_assert_ne!(1, 2, "{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:50:19 + --> $DIR/macro-comma-behavior.rs:54:19 | LL | format_args!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:68:21 + --> $DIR/macro-comma-behavior.rs:72:21 | LL | unimplemented!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:77:24 + --> $DIR/macro-comma-behavior.rs:81:24 | LL | write!(f, "{}",)?; | ^^ -error: `#[panic_handler]` function required, but not found +error: aborting due to 7 previous errors -error: language item required, but not found: `eh_personality` - -error: aborting due to 9 previous errors diff --git a/src/test/ui/macros/macro-comma-behavior.rs b/src/test/ui/macros/macro-comma-behavior.rs index 46b93edca3ab8..006319aa9f5b2 100644 --- a/src/test/ui/macros/macro-comma-behavior.rs +++ b/src/test/ui/macros/macro-comma-behavior.rs @@ -8,7 +8,9 @@ #[cfg(std)] use std::fmt; #[cfg(core)] use core::fmt; +#[cfg(core)] #[lang = "eh_personality"] fn eh_personality() {} #[cfg(core)] #[lang = "eh_unwind_resume"] fn eh_unwind_resume() {} +#[cfg(core)] #[lang = "panic_impl"] fn panic_impl(panic: &core::panic::PanicInfo) -> ! { loop {} } // (see documentation of the similarly-named test in run-pass) fn to_format_or_not_to_format() { diff --git a/src/test/ui/macros/macro-comma-behavior.std.stderr b/src/test/ui/macros/macro-comma-behavior.std.stderr index e56ed40e024bf..4372d89fbf522 100644 --- a/src/test/ui/macros/macro-comma-behavior.std.stderr +++ b/src/test/ui/macros/macro-comma-behavior.std.stderr @@ -1,61 +1,62 @@ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:17:23 + --> $DIR/macro-comma-behavior.rs:21:23 | LL | assert_eq!(1, 1, "{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:20:23 + --> $DIR/macro-comma-behavior.rs:24:23 | LL | assert_ne!(1, 2, "{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:26:29 + --> $DIR/macro-comma-behavior.rs:30:29 | LL | debug_assert_eq!(1, 1, "{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:29:29 + --> $DIR/macro-comma-behavior.rs:33:29 | LL | debug_assert_ne!(1, 2, "{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:34:18 + --> $DIR/macro-comma-behavior.rs:38:18 | LL | eprint!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:46:18 + --> $DIR/macro-comma-behavior.rs:50:18 | LL | format!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:50:19 + --> $DIR/macro-comma-behavior.rs:54:19 | LL | format_args!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:57:17 + --> $DIR/macro-comma-behavior.rs:61:17 | LL | print!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:68:21 + --> $DIR/macro-comma-behavior.rs:72:21 | LL | unimplemented!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:77:24 + --> $DIR/macro-comma-behavior.rs:81:24 | LL | write!(f, "{}",)?; | ^^ error: aborting due to 10 previous errors + diff --git a/src/test/ui/parser/macro/pub-item-macro.stderr b/src/test/ui/parser/macro/pub-item-macro.stderr index fb7a1fce54955..a624d574c456f 100644 --- a/src/test/ui/parser/macro/pub-item-macro.stderr +++ b/src/test/ui/parser/macro/pub-item-macro.stderr @@ -10,7 +10,7 @@ LL | pub_x!(); = help: try adjusting the macro to put `pub` inside the invocation error[E0603]: static `x` is private - --> $DIR/pub-item-macro.rs:27:23 + --> $DIR/pub-item-macro.rs:17:23 | LL | let y: u32 = foo::x; //~ ERROR static `x` is private | ^ diff --git a/src/test/ui/proc-macro/issue-41211.stderr b/src/test/ui/proc-macro/issue-41211.stderr index 2c702c7871d05..f75481e4829bf 100644 --- a/src/test/ui/proc-macro/issue-41211.stderr +++ b/src/test/ui/proc-macro/issue-41211.stderr @@ -7,7 +7,7 @@ LL | #![emit_unchanged] = help: add #![feature(custom_attribute)] to the crate attributes to enable error: inconsistent resolution for a macro: first custom attribute, then attribute macro - --> $DIR/issue-41211.rs:18:4 + --> $DIR/issue-41211.rs:8:4 | LL | #![emit_unchanged] | ^^^^^^^^^^^^^^ diff --git a/src/test/ui/proc-macro/more-gates.stderr b/src/test/ui/proc-macro/more-gates.stderr index b17b0bcb11097..21e75027e4879 100644 --- a/src/test/ui/proc-macro/more-gates.stderr +++ b/src/test/ui/proc-macro/more-gates.stderr @@ -1,5 +1,5 @@ error[E0658]: procedural macros cannot expand to macro definitions (see issue #54727) - --> $DIR/more-gates.rs:7:1 + --> $DIR/more-gates.rs:9:1 | LL | #[attr2mac1] | ^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | #[attr2mac1] = help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable error[E0658]: procedural macros cannot expand to macro definitions (see issue #54727) - --> $DIR/more-gates.rs:10:1 + --> $DIR/more-gates.rs:12:1 | LL | #[attr2mac2] | ^^^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | #[attr2mac2] = help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable error[E0658]: procedural macros cannot expand to macro definitions (see issue #54727) - --> $DIR/more-gates.rs:14:1 + --> $DIR/more-gates.rs:16:1 | LL | mac2mac1!(); //~ ERROR: cannot expand to macro definitions | ^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | mac2mac1!(); //~ ERROR: cannot expand to macro definitions = help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable error[E0658]: procedural macros cannot expand to macro definitions (see issue #54727) - --> $DIR/more-gates.rs:15:1 + --> $DIR/more-gates.rs:17:1 | LL | mac2mac2!(); //~ ERROR: cannot expand to macro definitions | ^^^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | mac2mac2!(); //~ ERROR: cannot expand to macro definitions = help: add #![feature(proc_macro_hygiene)] to the crate attributes to enable error[E0658]: procedural macros cannot expand to macro definitions (see issue #54727) - --> $DIR/more-gates.rs:17:1 + --> $DIR/more-gates.rs:19:1 | LL | tricky!(); | ^^^^^^^^^^ diff --git a/src/test/ui/proc-macro/parent-source-spans.stderr b/src/test/ui/proc-macro/parent-source-spans.stderr index 2d9ebff88cb66..a8ee325b41de5 100644 --- a/src/test/ui/proc-macro/parent-source-spans.stderr +++ b/src/test/ui/proc-macro/parent-source-spans.stderr @@ -35,25 +35,25 @@ LL | one!("hello", "world"); | ----------------------- in this macro invocation error: first grandparent: "hello" - --> $DIR/parent-source-spans.rs:34:5 + --> $DIR/parent-source-spans.rs:37:5 | LL | one!("hello", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^ error: second grandparent: "world" - --> $DIR/parent-source-spans.rs:34:5 + --> $DIR/parent-source-spans.rs:37:5 | LL | one!("hello", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^ error: first source: "hello" - --> $DIR/parent-source-spans.rs:34:5 + --> $DIR/parent-source-spans.rs:37:5 | LL | one!("hello", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^ error: second source: "world" - --> $DIR/parent-source-spans.rs:34:5 + --> $DIR/parent-source-spans.rs:37:5 | LL | one!("hello", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -77,55 +77,55 @@ LL | two!("yay", "rust"); | -------------------- in this macro invocation error: first parent: "yay" - --> $DIR/parent-source-spans.rs:40:5 + --> $DIR/parent-source-spans.rs:43:5 | LL | two!("yay", "rust"); | ^^^^^^^^^^^^^^^^^^^^ error: second parent: "rust" - --> $DIR/parent-source-spans.rs:40:5 + --> $DIR/parent-source-spans.rs:43:5 | LL | two!("yay", "rust"); | ^^^^^^^^^^^^^^^^^^^^ error: first source: "yay" - --> $DIR/parent-source-spans.rs:40:5 + --> $DIR/parent-source-spans.rs:43:5 | LL | two!("yay", "rust"); | ^^^^^^^^^^^^^^^^^^^^ error: second source: "rust" - --> $DIR/parent-source-spans.rs:40:5 + --> $DIR/parent-source-spans.rs:43:5 | LL | two!("yay", "rust"); | ^^^^^^^^^^^^^^^^^^^^ error: first final: "hip" - --> $DIR/parent-source-spans.rs:46:12 + --> $DIR/parent-source-spans.rs:49:12 | LL | three!("hip", "hop"); | ^^^^^ error: second final: "hop" - --> $DIR/parent-source-spans.rs:46:19 + --> $DIR/parent-source-spans.rs:49:19 | LL | three!("hip", "hop"); | ^^^^^ error: first source: "hip" - --> $DIR/parent-source-spans.rs:46:12 + --> $DIR/parent-source-spans.rs:49:12 | LL | three!("hip", "hop"); | ^^^^^ error: second source: "hop" - --> $DIR/parent-source-spans.rs:46:19 + --> $DIR/parent-source-spans.rs:49:19 | LL | three!("hip", "hop"); | ^^^^^ error[E0425]: cannot find value `ok` in this scope - --> $DIR/parent-source-spans.rs:40:5 + --> $DIR/parent-source-spans.rs:30:5 | LL | parent_source_spans!($($tokens)*); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ did you mean `Ok`? @@ -134,7 +134,7 @@ LL | one!("hello", "world"); | ----------------------- in this macro invocation error[E0425]: cannot find value `ok` in this scope - --> $DIR/parent-source-spans.rs:40:5 + --> $DIR/parent-source-spans.rs:30:5 | LL | parent_source_spans!($($tokens)*); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ did you mean `Ok`? @@ -143,7 +143,7 @@ LL | two!("yay", "rust"); | -------------------- in this macro invocation error[E0425]: cannot find value `ok` in this scope - --> $DIR/parent-source-spans.rs:40:5 + --> $DIR/parent-source-spans.rs:30:5 | LL | parent_source_spans!($($tokens)*); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ did you mean `Ok`? diff --git a/src/test/ui/proc-macro/proc-macro-attributes.stderr b/src/test/ui/proc-macro/proc-macro-attributes.stderr index 8b87e482282bd..7ac44c9354dd5 100644 --- a/src/test/ui/proc-macro/proc-macro-attributes.stderr +++ b/src/test/ui/proc-macro/proc-macro-attributes.stderr @@ -7,75 +7,75 @@ LL | #[C] //~ ERROR attribute `C` is currently unknown to the compiler = help: add #![feature(custom_attribute)] to the crate attributes to enable error[E0659]: `B` is ambiguous (derive helper attribute vs any other name) - --> $DIR/proc-macro-attributes.rs:16:3 + --> $DIR/proc-macro-attributes.rs:6:3 | LL | #[B] //~ ERROR `B` is ambiguous | ^ ambiguous name | note: `B` could refer to the derive helper attribute defined here - --> $DIR/proc-macro-attributes.rs:22:10 + --> $DIR/proc-macro-attributes.rs:12:10 | LL | #[derive(B)] | ^ note: `B` could also refer to the derive macro imported here - --> $DIR/proc-macro-attributes.rs:13:1 + --> $DIR/proc-macro-attributes.rs:3:1 | LL | #[macro_use] | ^^^^^^^^^^^^ error[E0659]: `B` is ambiguous (derive helper attribute vs any other name) - --> $DIR/proc-macro-attributes.rs:18:3 + --> $DIR/proc-macro-attributes.rs:8:3 | LL | #[B(D)] //~ ERROR `B` is ambiguous | ^ ambiguous name | note: `B` could refer to the derive helper attribute defined here - --> $DIR/proc-macro-attributes.rs:22:10 + --> $DIR/proc-macro-attributes.rs:12:10 | LL | #[derive(B)] | ^ note: `B` could also refer to the derive macro imported here - --> $DIR/proc-macro-attributes.rs:13:1 + --> $DIR/proc-macro-attributes.rs:3:1 | LL | #[macro_use] | ^^^^^^^^^^^^ error[E0659]: `B` is ambiguous (derive helper attribute vs any other name) - --> $DIR/proc-macro-attributes.rs:19:3 + --> $DIR/proc-macro-attributes.rs:9:3 | LL | #[B(E = "foo")] //~ ERROR `B` is ambiguous | ^ ambiguous name | note: `B` could refer to the derive helper attribute defined here - --> $DIR/proc-macro-attributes.rs:22:10 + --> $DIR/proc-macro-attributes.rs:12:10 | LL | #[derive(B)] | ^ note: `B` could also refer to the derive macro imported here - --> $DIR/proc-macro-attributes.rs:13:1 + --> $DIR/proc-macro-attributes.rs:3:1 | LL | #[macro_use] | ^^^^^^^^^^^^ error[E0659]: `B` is ambiguous (derive helper attribute vs any other name) - --> $DIR/proc-macro-attributes.rs:20:3 + --> $DIR/proc-macro-attributes.rs:10:3 | LL | #[B(arbitrary tokens)] //~ ERROR `B` is ambiguous | ^ ambiguous name | note: `B` could refer to the derive helper attribute defined here - --> $DIR/proc-macro-attributes.rs:22:10 + --> $DIR/proc-macro-attributes.rs:12:10 | LL | #[derive(B)] | ^ note: `B` could also refer to the derive macro imported here - --> $DIR/proc-macro-attributes.rs:13:1 + --> $DIR/proc-macro-attributes.rs:3:1 | LL | #[macro_use] | ^^^^^^^^^^^^ error: expected one of `(`, `)`, `,`, `::`, or `=`, found `tokens` - --> $DIR/proc-macro-attributes.rs:20:15 + --> $DIR/proc-macro-attributes.rs:10:15 | LL | #[B(arbitrary tokens)] //~ ERROR `B` is ambiguous | ^^^^^^ expected one of `(`, `)`, `,`, `::`, or `=` here diff --git a/src/test/ui/quote-with-interpolated.stderr b/src/test/ui/quote-with-interpolated.stderr index 3c582286662af..96feff949bfc9 100644 --- a/src/test/ui/quote-with-interpolated.stderr +++ b/src/test/ui/quote-with-interpolated.stderr @@ -8,19 +8,19 @@ LL | foo!(bar); | ---------- in this macro invocation error[E0433]: failed to resolve: maybe a missing `extern crate syntax;`? - --> $DIR/quote-with-interpolated.rs:15:13 + --> $DIR/quote-with-interpolated.rs:5:13 | LL | quote_expr!(cx, $bar) | ^^^^^^^^^^^^^^^^^^^^^ maybe a missing `extern crate syntax;`? error[E0433]: failed to resolve: maybe a missing `extern crate syntax;`? - --> $DIR/quote-with-interpolated.rs:15:29 + --> $DIR/quote-with-interpolated.rs:5:29 | LL | quote_expr!(cx, $bar) | ^^^^ maybe a missing `extern crate syntax;`? error[E0425]: cannot find value `cx` in this scope - --> $DIR/quote-with-interpolated.rs:15:25 + --> $DIR/quote-with-interpolated.rs:5:25 | LL | quote_expr!(cx, $bar) | ^^ not found in this scope @@ -29,7 +29,7 @@ LL | foo!(bar); | ---------- in this macro invocation error[E0425]: cannot find function `new_parser_from_tts` in this scope - --> $DIR/quote-with-interpolated.rs:15:13 + --> $DIR/quote-with-interpolated.rs:5:13 | LL | quote_expr!(cx, $bar) | ^^^^^^^^^^^^^^^^^^^^^ not found in this scope diff --git a/src/test/ui/reserved/reserved-attr-on-macro.stderr b/src/test/ui/reserved/reserved-attr-on-macro.stderr index 4f1c0e1aa7074..46d3478b62841 100644 --- a/src/test/ui/reserved/reserved-attr-on-macro.stderr +++ b/src/test/ui/reserved/reserved-attr-on-macro.stderr @@ -7,7 +7,7 @@ LL | #[rustc_attribute_should_be_reserved] = help: add #![feature(rustc_attrs)] to the crate attributes to enable error: cannot determine resolution for the macro `foo` - --> $DIR/reserved-attr-on-macro.rs:18:5 + --> $DIR/reserved-attr-on-macro.rs:8:5 | LL | foo!(); //~ ERROR cannot determine resolution for the macro `foo` | ^^^ diff --git a/src/test/ui/self/self_type_keyword.stderr b/src/test/ui/self/self_type_keyword.stderr index 1981e23c88a1c..f75377a220b49 100644 --- a/src/test/ui/self/self_type_keyword.stderr +++ b/src/test/ui/self/self_type_keyword.stderr @@ -5,43 +5,43 @@ LL | struct Self; | ^^^^ expected identifier, found keyword error: expected identifier, found keyword `Self` - --> $DIR/self_type_keyword.rs:15:13 + --> $DIR/self_type_keyword.rs:16:13 | LL | ref Self => (), | ^^^^ expected identifier, found keyword error: expected identifier, found keyword `Self` - --> $DIR/self_type_keyword.rs:17:13 + --> $DIR/self_type_keyword.rs:18:13 | LL | mut Self => (), | ^^^^ expected identifier, found keyword error: expected identifier, found keyword `Self` - --> $DIR/self_type_keyword.rs:19:17 + --> $DIR/self_type_keyword.rs:20:17 | LL | ref mut Self => (), | ^^^^ expected identifier, found keyword error: expected identifier, found keyword `Self` - --> $DIR/self_type_keyword.rs:23:15 + --> $DIR/self_type_keyword.rs:24:15 | LL | Foo { Self } => (), | ^^^^ expected identifier, found keyword error: expected identifier, found keyword `Self` - --> $DIR/self_type_keyword.rs:29:26 + --> $DIR/self_type_keyword.rs:30:26 | LL | extern crate core as Self; | ^^^^ expected identifier, found keyword error: expected identifier, found keyword `Self` - --> $DIR/self_type_keyword.rs:34:32 + --> $DIR/self_type_keyword.rs:35:32 | LL | use std::option::Option as Self; | ^^^^ expected identifier, found keyword error: expected identifier, found keyword `Self` - --> $DIR/self_type_keyword.rs:39:11 + --> $DIR/self_type_keyword.rs:40:11 | LL | trait Self {} | ^^^^ expected identifier, found keyword @@ -53,13 +53,13 @@ LL | struct Bar<'Self>; | ^^^^^ error: cannot find macro `Self!` in this scope - --> $DIR/self_type_keyword.rs:21:9 + --> $DIR/self_type_keyword.rs:22:9 | LL | Self!() => (), | ^^^^ error[E0392]: parameter `'Self` is never used - --> $DIR/self_type_keyword.rs:18:12 + --> $DIR/self_type_keyword.rs:8:12 | LL | struct Bar<'Self>; | ^^^^^ unused type parameter diff --git a/src/test/ui/span/macro-ty-params.stderr b/src/test/ui/span/macro-ty-params.stderr index c1dcc513f3a0a..23fdde06e8f9d 100644 --- a/src/test/ui/span/macro-ty-params.stderr +++ b/src/test/ui/span/macro-ty-params.stderr @@ -1,25 +1,26 @@ -error: unexpected generic arguments in path +error: generic arguments in macro path --> $DIR/macro-ty-params.rs:10:8 | LL | foo::!(); //~ ERROR generic arguments in macro path | ^^^^^ error: generic arguments in macro path - --> $DIR/macro-ty-params.rs:10:15 + --> $DIR/macro-ty-params.rs:11:8 | LL | foo::<>!(); //~ ERROR generic arguments in macro path | ^^^^ -error: generic arguments in macro path - --> $DIR/macro-ty-params.rs:8:8 +error: unexpected generic arguments in path + --> $DIR/macro-ty-params.rs:12:8 | LL | m!(Default<>); //~ ERROR generic arguments in macro path | ^^^^^^^^^ error: generic arguments in macro path - --> $DIR/macro-ty-params.rs:9:8 + --> $DIR/macro-ty-params.rs:12:15 | LL | m!(Default<>); //~ ERROR generic arguments in macro path | ^^ error: aborting due to 4 previous errors + diff --git a/src/test/ui/span/visibility-ty-params.stderr b/src/test/ui/span/visibility-ty-params.stderr index 9a11eea6532b2..1fb54df15704b 100644 --- a/src/test/ui/span/visibility-ty-params.stderr +++ b/src/test/ui/span/visibility-ty-params.stderr @@ -5,13 +5,13 @@ LL | m!{ S } //~ ERROR unexpected generic arguments in path | ^^^^^ error: unexpected generic arguments in path - --> $DIR/visibility-ty-params.rs:9:9 + --> $DIR/visibility-ty-params.rs:10:9 | LL | m!{ m<> } //~ ERROR unexpected generic arguments in path | ^^^ error[E0577]: expected module, found struct `S` - --> $DIR/visibility-ty-params.rs:16:5 + --> $DIR/visibility-ty-params.rs:6:5 | LL | m!{ S } //~ ERROR unexpected generic arguments in path | -^^^^ diff --git a/src/test/ui/trace_macros-gate.stderr b/src/test/ui/trace_macros-gate.stderr index a411fae8bcb61..4831aa158dbc8 100644 --- a/src/test/ui/trace_macros-gate.stderr +++ b/src/test/ui/trace_macros-gate.stderr @@ -7,7 +7,7 @@ LL | trace_macros!(); //~ ERROR `trace_macros` is not stable = help: add #![feature(trace_macros)] to the crate attributes to enable error: trace_macros! accepts only `true` or `false` - --> $DIR/trace_macros-gate.rs:14:5 + --> $DIR/trace_macros-gate.rs:4:5 | LL | trace_macros!(); //~ ERROR `trace_macros` is not stable | ^^^^^^^^^^^^^^^^ @@ -29,7 +29,7 @@ LL | trace_macros!(false); //~ ERROR `trace_macros` is not stable = help: add #![feature(trace_macros)] to the crate attributes to enable error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598) - --> $DIR/trace_macros-gate.rs:20:26 + --> $DIR/trace_macros-gate.rs:10:26 | LL | ($x: ident) => { trace_macros!($x) } //~ ERROR `trace_macros` is not stable | ^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/tuple/tuple-struct-fields/test2.stderr b/src/test/ui/tuple/tuple-struct-fields/test2.stderr index baca625b0bde5..80f0ddc0e4fcd 100644 --- a/src/test/ui/tuple/tuple-struct-fields/test2.stderr +++ b/src/test/ui/tuple/tuple-struct-fields/test2.stderr @@ -8,7 +8,7 @@ LL | define_struct! { (foo) } //~ ERROR cannot find type `foo` in this scope | ------------------------ in this macro invocation error[E0412]: cannot find type `foo` in this scope - --> $DIR/test2.rs:21:23 + --> $DIR/test2.rs:11:23 | LL | define_struct! { (foo) } //~ ERROR cannot find type `foo` in this scope | ^^^ not found in this scope diff --git a/src/test/ui/tuple/tuple-struct-fields/test3.stderr b/src/test/ui/tuple/tuple-struct-fields/test3.stderr index 2da34fff53da6..fbc01744fe445 100644 --- a/src/test/ui/tuple/tuple-struct-fields/test3.stderr +++ b/src/test/ui/tuple/tuple-struct-fields/test3.stderr @@ -8,7 +8,7 @@ LL | define_struct! { foo } //~ ERROR cannot find type `foo` in this scope | ---------------------- in this macro invocation error[E0412]: cannot find type `foo` in this scope - --> $DIR/test3.rs:21:22 + --> $DIR/test3.rs:11:22 | LL | define_struct! { foo } //~ ERROR cannot find type `foo` in this scope | ^^^ not found in this scope