]> git.lizzy.rs Git - rust.git/commitdiff
Do not abort compilation if expansion produces errors
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Sun, 16 Dec 2018 17:23:27 +0000 (20:23 +0300)
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Thu, 27 Dec 2018 12:51:36 +0000 (15:51 +0300)
Fix a number of uncovered deficiencies in diagnostics

80 files changed:
src/librustc_driver/driver.rs
src/librustc_passes/ast_validation.rs
src/librustc_resolve/lib.rs
src/librustc_resolve/macros.rs
src/libsyntax/ext/base.rs
src/libsyntax/ext/expand.rs
src/libsyntax/feature_gate.rs
src/libsyntax_ext/deriving/default.rs
src/libsyntax_ext/format.rs
src/test/ui/conditional-compilation/cfg-attr-invalid-predicate.rs
src/test/ui/conditional-compilation/cfg-attr-syntax-validation.rs
src/test/ui/cross/cross-crate-macro-backtrace/auxiliary/extern_macro_crate.rs
src/test/ui/derives/derive-on-trait-item-or-impl-item.rs
src/test/ui/derives/derive-on-trait-item-or-impl-item.stderr
src/test/ui/did_you_mean/issue-40396.rs
src/test/ui/did_you_mean/issue-40396.stderr
src/test/ui/editions/edition-keywords-2015-2015-parsing.rs
src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr
src/test/ui/editions/edition-keywords-2015-2018-expansion.rs
src/test/ui/editions/edition-keywords-2015-2018-parsing.rs
src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr
src/test/ui/editions/edition-keywords-2018-2018-expansion.rs
src/test/ui/feature-gate/issue-43106-gating-of-derive-2.rs
src/test/ui/feature-gate/issue-43106-gating-of-derive.rs
src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.rs
src/test/ui/feature-gates/feature-gate-macros_in_extern.rs
src/test/ui/feature-gates/feature-gate-rustc-attrs.rs
src/test/ui/issues/issue-10536.rs
src/test/ui/issues/issue-10536.stderr
src/test/ui/issues/issue-11692-1.rs
src/test/ui/issues/issue-11692-1.stderr
src/test/ui/issues/issue-11692-2.rs
src/test/ui/issues/issue-11692-2.stderr
src/test/ui/issues/issue-32950.rs
src/test/ui/issues/issue-32950.stderr
src/test/ui/issues/issue-33571.rs
src/test/ui/issues/issue-35677.rs
src/test/ui/issues/issue-35677.stderr
src/test/ui/issues/issue-36617.rs
src/test/ui/issues/issue-43023.rs
src/test/ui/issues/issue-46438.rs
src/test/ui/issues/issue-49074.rs
src/test/ui/issues/issue-49074.stderr
src/test/ui/issues/issue-51279.rs
src/test/ui/issues/issue-51279.stderr
src/test/ui/issues/issue-55796.rs
src/test/ui/issues/issue-55796.stderr
src/test/ui/issues/issue-6596-1.rs
src/test/ui/issues/issue-6596-1.stderr
src/test/ui/issues/issue-6596-2.rs
src/test/ui/macro_backtrace/main.rs
src/test/ui/macros/macro-comma-behavior.core.stderr
src/test/ui/malformed/malformed-derive-entry.rs
src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.rs
src/test/ui/panic-runtime/runtime-depend-on-needs-runtime.stderr
src/test/ui/parser/macro/pub-item-macro.rs
src/test/ui/parser/macro/pub-item-macro.stderr
src/test/ui/proc-macro/issue-41211.rs
src/test/ui/proc-macro/issue-41211.stderr
src/test/ui/proc-macro/lifetimes.rs
src/test/ui/proc-macro/more-gates.rs
src/test/ui/proc-macro/parent-source-spans.rs
src/test/ui/proc-macro/parent-source-spans.stderr
src/test/ui/proc-macro/proc-macro-attributes.rs
src/test/ui/proc-macro/proc-macro-attributes.stderr
src/test/ui/quote-with-interpolated.rs
src/test/ui/quote-with-interpolated.stderr
src/test/ui/reserved/reserved-attr-on-macro.rs
src/test/ui/reserved/reserved-attr-on-macro.stderr
src/test/ui/self/self_type_keyword.rs
src/test/ui/self/self_type_keyword.stderr
src/test/ui/span/issue-36530.rs
src/test/ui/span/macro-ty-params.rs
src/test/ui/span/macro-ty-params.stderr
src/test/ui/span/visibility-ty-params.rs
src/test/ui/span/visibility-ty-params.stderr
src/test/ui/tuple/tuple-struct-fields/test2.rs
src/test/ui/tuple/tuple-struct-fields/test2.stderr
src/test/ui/tuple/tuple-struct-fields/test3.rs
src/test/ui/tuple/tuple-struct-fields/test3.stderr

index f19ca5ed030ab3a8d6209f92a6ac9462d3a18c27..62dc8691e65df8ef8112e5e02383ab29c28314b6 100644 (file)
@@ -987,7 +987,6 @@ pub fn phase_2_configure_and_expand_inner<'a, F>(
         };
 
         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 @@ pub fn phase_2_configure_and_expand_inner<'a, F>(
             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 @@ pub fn phase_2_configure_and_expand_inner<'a, F>(
         })
     })?;
 
-    // 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 {
index ce5db51dfb59068924bf743477cadf41ce8a7835..584f0ba0449e1213f007ad7658aaf27bcfbe75f7 100644 (file)
@@ -278,25 +278,6 @@ fn visit_ty(&mut self, ty: &'a Ty) {
         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<T>;` 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<T>);
-        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 @@ fn visit_foreign_item(&mut self, fi: &'a ForeignItem) {
         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;
index cc9c6d8c516be07f884febce7fad5ce340779b6b..0db6dbafb6cc6c54e31eaa29355a9c5f133bd0a5 100644 (file)
@@ -1576,7 +1576,6 @@ pub struct Resolver<'a> {
     macro_map: FxHashMap<DefId, Lrc<SyntaxExtension>>,
     macro_defs: FxHashMap<Mark, DefId>,
     local_macro_def_scopes: FxHashMap<NodeId, Module<'a>>,
-    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 @@ pub fn new(session: &'a Session,
             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 @@ fn resolve_ident_in_lexical_scope(&mut self,
                                       record_used_id: Option<NodeId>,
                                       path_span: Span)
                                       -> Option<LexicalScopeBinding<'a>> {
-        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 @@ fn resolve_ident_in_lexical_scope(&mut self,
         }
 
         // 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() {
index 98c6773cec323d6307122458cad753a40f0a8e65..9c0c8a6016fe5d2076907fb8d2338433b0d7e5da 100644 (file)
@@ -182,7 +182,14 @@ fn resolve_macro_invocation(&mut self, invoc: &Invocation, invoc_id: Mark, force
         };
 
         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 @@ pub fn resolve_macro_to_def_inner(
                 }
                 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 @@ pub fn resolve_macro_to_def_inner(
             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 @@ struct Flags: u8 {
     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: 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
index d576397c942c18ef3979f5922649dfc85f4b44c0..84aa57d7d86e6f845b28719e5dcafd9fec1f254d 100644 (file)
@@ -2,7 +2,7 @@
 
 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 @@ pub fn expr(sp: Span) -> Box<dyn MacResult+'static> {
     pub fn raw_expr(sp: Span) -> P<ast::Expr> {
         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 @@ pub fn raw_pat(sp: Span) -> ast::Pat {
         }
     }
 
+    /// A plain dummy type.
     pub fn raw_ty(sp: Span) -> P<ast::Ty> {
         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<Span, Vec<String>>,
 }
@@ -811,7 +811,6 @@ pub fn new(parse_sess: &'a parse::ParseSess,
             ecfg,
             root_path: PathBuf::new(),
             resolver,
-            resolve_err_count: 0,
             current_expansion: ExpansionData {
                 mark: Mark::root(),
                 depth: 0,
index 55012bb7f5a150b92ae4c4f7f9092b3baefece65..f8f1e830770282318afb3ce65598ddebf6b81ce1 100644 (file)
@@ -344,8 +344,10 @@ fn expand_fragment(&mut self, input_fragment: AstFragment) -> AstFragment {
             // 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 @@ fn expand_fragment(&mut self, input_fragment: AstFragment) -> AstFragment {
 
     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 @@ fn collect_invocations(&mut self, fragment: AstFragment, derives: &[Mark])
         };
 
         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)
index 62269a8f163b4e70f78e5bcfcceea0e915b42c7f..70df403d0c2ea8e019c4682b4998c70f87668bfe 100644 (file)
@@ -1272,16 +1272,15 @@ fn check_attribute(&self, attr: &ast::Attribute, is_macro: bool) {
                 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);
index c26c4bb6274005a4236c76940442435f1326a04b..771a559b37ccfc832ab4d039082886944cfe435a 100644 (file)
@@ -3,7 +3,7 @@
 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)`"),
     };
index 220765fd8c732c17e9c99c7c391fe3056e4a7c15..c6f427e63cd8da3257135a70b5fa4766b78019a9 100644 (file)
@@ -666,7 +666,7 @@ fn format_arg(ecx: &ExtCtxt,
                     "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) {
index 9d8842eee81c69dbe84f6c395cdba8fb163a978d..496d196c94ae57cbfe107f45964b8990ea00b855 100644 (file)
@@ -1,2 +1,4 @@
 #[cfg(foo(bar))] //~ ERROR invalid predicate `foo`
+fn check() {}
+
 fn main() {}
index 83e162e08712fd5f087f0102213e219c0ec9d91e..c7e1b4435e49baa43834db82683cd571f1387aec 100644 (file)
@@ -33,3 +33,5 @@ macro_rules! generate_s10 {
 }
 
 generate_s10!(concat!("nonexistent"));
+
+fn main() {}
index 7c9ecb5d6214e9c15ec9443af771f606bd1597c0..fbda3dbe9481f43ee53e2c15111f876be9b930bc 100644 (file)
@@ -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]
index 2530e75111bfbbf2f9da2de2141bf1173f26b55d..b847000a81d80089c9d3bc98a1c043b4494d0962 100644 (file)
@@ -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
index dd7af8304147e5e87fe214496007ac852a4317fd..0088add7e7f6e444e5b2ca8d9e70939625254f40 100644 (file)
@@ -11,4 +11,3 @@ LL |     #[derive(Clone)]
    |     ^^^^^^^^^^^^^^^^
 
 error: aborting due to 2 previous errors
-
index 978b5d144833e8c9512ae3bad2a49d190f94551e..63eec50c2d29f06b37c849bd10bdacc6e23c9ab6 100644 (file)
@@ -1,14 +1,27 @@
 fn foo() {
-    println!("{:?}", (0..13).collect<Vec<i32>>()); //~ ERROR chained comparison
+    (0..13).collect<Vec<i32>>();
+    //~^ 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<i32>::new()); //~ ERROR chained comparison
+    Vec<i32>::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<Vec<i32>()); //~ ERROR chained comparison
+    (0..13).collect<Vec<i32>();
     //~^ 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() {}
index 3b086d8d4d08862f255ff26bd6600e77ac2482b4..33884bbfecfcc8a07b965b2fe943e2d3267f3d6f 100644 (file)
@@ -1,8 +1,8 @@
 error: chained comparison operators require parentheses
   --> $DIR/issue-40396.rs:2:37
    |
-LL |     println!("{:?}", (0..13).collect<Vec<i32>>()); //~ ERROR chained comparison
-   |                                     ^^^^^^^^
+LL |     (0..13).collect<Vec<i32>>();
+   |                    ^^^^^^^^
    |
    = 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<Vec<i32>>()); //~ ERROR chained compar
 error: chained comparison operators require parentheses
   --> $DIR/issue-40396.rs:6:25
    |
-LL |     println!("{:?}", Vec<i32>::new()); //~ ERROR chained comparison
-   |                         ^^^^^^^
+LL |     Vec<i32>::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<i32>::new()); //~ ERROR chained comparison
 error: chained comparison operators require parentheses
   --> $DIR/issue-40396.rs:10:37
    |
-LL |     println!("{:?}", (0..13).collect<Vec<i32>()); //~ ERROR chained comparison
-   |                                     ^^^^^^^^
+LL |     (0..13).collect<Vec<i32>();
+   |                    ^^^^^^^^
    |
    = 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<Vec<i32>()); //~ ERROR chained compari
 error: chained comparison operators require parentheses
   --> $DIR/issue-40396.rs:10:41
    |
-LL |     println!("{:?}", (0..13).collect<Vec<i32>()); //~ ERROR chained comparison
-   |                                         ^^^^^^
+LL |     (0..13).collect<Vec<i32>();
+   |                        ^^^^^^
    |
    = 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<Vec<i32>>();
+   |                     ^^^ did you mean `Vec { /* fields */ }`?
+
+error[E0423]: expected value, found builtin type `i32`
+  --> $DIR/issue-40396.rs:12:25
+   |
+LL |     (0..13).collect<Vec<i32>>();
+   |                         ^^^ not a value
+
+error[E0423]: expected value, found struct `Vec`
+  --> $DIR/issue-40396.rs:20:5
+   |
+LL |     Vec<i32>::new();
+   |     ^^^ did you mean `Vec { /* fields */ }`?
+
+error[E0423]: expected value, found builtin type `i32`
+  --> $DIR/issue-40396.rs:20:9
+   |
+LL |     Vec<i32>::new();
+   |         ^^^ not a value
+
+error[E0425]: cannot find function `new` in the crate root
+  --> $DIR/issue-40396.rs:20:15
+   |
+LL |     Vec<i32>::new();
+   |               ^^^ not found in the crate root
+
+error[E0423]: expected value, found struct `Vec`
+  --> $DIR/issue-40396.rs:28:21
+   |
+LL |     (0..13).collect<Vec<i32>();
+   |                     ^^^ did you mean `Vec { /* fields */ }`?
+
+error[E0423]: expected value, found builtin type `i32`
+  --> $DIR/issue-40396.rs:28:25
+   |
+LL |     (0..13).collect<Vec<i32>();
+   |                         ^^^ 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<Vec<i32>>();
+   |             ^^^^^^^
+   |
+   = 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<Vec<i32>();
+   |             ^^^^^^^
+   |
+   = help: maybe a `()` to call it is missing?
+
+error[E0308]: mismatched types
+  --> $DIR/issue-40396.rs:28:29
+   |
+LL |     (0..13).collect<Vec<i32>();
+   |                             ^^ 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`.
index e65eed0a0e6d0cd3caa23e6527a959a2d3cc677e..d1752a7ec71ddcb6ef2220fba8252577eed6d975 100644 (file)
@@ -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() {}
index 377e8ae08254849fcef51fb5d97ec3cbc8b22946..06901ad6ef0eeaaee9b033c2bfec5528d5124745 100644 (file)
@@ -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
-
index 8aafeefa56ce1c9d4af8824ee1eaeae55ac322fc..2684c8e00b2e11d762f25b6809f9169512114a8f 100644 (file)
@@ -10,3 +10,5 @@ mod one_async {
 mod two_async {
     produces_async_raw! {} // OK
 }
+
+fn main() {}
index 767396031297e8d656179de9013d6f7001467c4b..44455f43856c6347a8677c7291921349193e6a94 100644 (file)
@@ -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() {}
index c6e4d01a64964c57fe0832a1e5fce71ca3d1c91f..98fa249394081ef7e882792e8ae9ead84b63012c 100644 (file)
@@ -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
-
index 2db0a2dde2ed0316fd106b5d0c4eee8a5c3ca676..6f766550d47341356abdf839d70db44e729e4a1e 100644 (file)
@@ -10,3 +10,5 @@ mod one_async {
 mod two_async {
     produces_async_raw! {} // OK
 }
+
+fn main() {}
index 352f56f7aca99cdc73b14c97c5b6d33806db3ae1..5f276f6b65ebcf23792086ef54320faef1800f4f 100644 (file)
@@ -13,3 +13,5 @@ enum E { }
     //~^ ERROR cannot find derive macro `x3300` in this scope
     struct S;
 }
+
+fn main() {}
index 8bac49816ad9f1abc2fd9d510e71efd3f82b70a5..1397412988491afd703781f1d1e0fdaf62cc309c 100644 (file)
@@ -31,3 +31,5 @@ enum E { }
     //~^ ERROR `derive` may only be applied to structs, enums and unions
     impl S { }
 }
+
+fn main() {}
index 1786ec246abe23b99427d87c89f602faf5631437..db1a7dad06bc36e129835175c2e2a5442a2cd34d 100644 (file)
@@ -1,3 +1,5 @@
+#![feature(intrinsics, lang_items, no_core)]
+
 #![crate_type="rlib"]
 #![no_core]
 
index 8f8147a74239592091e167c88fbaee526584769b..125af64fef05c7bb99dea8969773eb7806588037 100644 (file)
@@ -23,3 +23,5 @@ macro_rules! emits_nothing(
     emits_nothing!();
     //~^ ERROR macro invocations in `extern {}` blocks are experimental
 }
+
+fn main() {}
index 993daca075613a466bb58201ac7ac2ae0233d771..5ec413cc71de0b26cab7e75dece06d26e3a7a8ec 100644 (file)
@@ -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() {}
index f8695caca5b619bbaa9654a010adc87b38e4cfc2..a2df2913afb9169104f5e4db658802fa01e8c7b2 100644 (file)
@@ -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 `!`
 }
index bc542ce35c0ab841c8ca1bc6fe486a0b53bd4905..6b2424d3a45dd7ace71feef44ca5a3a44ab515d5 100644 (file)
@@ -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`.
index eae555ad83cfdd8ce9004ab2188da5e9bd31de63..2277778040292092af60a1ae95766b1716967e51 100644 (file)
@@ -1,4 +1,5 @@
 fn main() {
     print!(testo!());
     //~^ ERROR: format argument must be a string literal
+    //~| ERROR: cannot find macro `testo!` in this scope
 }
index 1173e056321ddd24329604f5fbda301bef04815c..e0c4642ea60f17038e2a17e1c63e8a0f436cd879 100644 (file)
@@ -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
 
index 61be284d7320eeaf3c82e17350ae38dc5922ac96..6103931657342d77511e1c9e231f18c4b5983e00 100644 (file)
@@ -1,3 +1,4 @@
 fn main() {
     concat!(test!()); //~ ERROR cannot find macro `test!` in this scope
+                      //~| ERROR expected a literal
 }
index 5d4467080f149dce9f0927179dea34f8d268cec0..16cf7b0dca7e137f1fd2f7968ebaf5fcb8338ede 100644 (file)
@@ -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
 
index dc5b063ada4bf7dc436d96b74be071a180cd4e5e..27d68a11c1f160d6e456c2c6d9ba3691d6d7e766 100644 (file)
@@ -3,6 +3,7 @@
 #[derive(Debug)]
 struct Baz<T>(
     concat_idents!(Foo, Bar) //~ ERROR `derive` cannot be used on items with type macros
+                             //~^ ERROR cannot find type `FooBar` in this scope
 );
 
 fn main() {}
index e8e3347af2e1e4cb26ed2659305cf9fd2ef04519..af148cbb5c6925904e3c5520e142bc0f10f38004 100644 (file)
@@ -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`.
index 5f9c514addbde7687bf6f6c658ca41ba63912446..223bbc3ff5e2190f35519ca5b3ee1665fe1f9fbc 100644 (file)
@@ -2,3 +2,5 @@
          Sync, //~ ERROR this unsafe trait should be implemented explicitly
          Copy)]
 enum Foo {}
+
+fn main() {}
index 46d3f7e4af00b0f0b7e2683bdfcd917243a34556..71e2125ffd2ccc7d992f8f8797721480882286e8 100644 (file)
@@ -3,3 +3,5 @@ fn intersect_map<K, V>(this: &mut HashMap<K, V>, other: HashMap<K, V>) -> bool {
     this.drain()
     //~^ ERROR no method named
 }
+
+fn main() {}
index dca096b93f5f3f27a48783b4adce9d5257637d57..61ddb75b3b52c3a8203e191594bd3232c10d7004 100644 (file)
@@ -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<K, V>` 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`.
index 846efac41c8563121fc3ff4fd97c916b551aaf7d..87092689a281d418b15cc6f63c7635b645187ad0 100644 (file)
@@ -1 +1,3 @@
 #![derive(Copy)] //~ ERROR `derive` may only be applied to structs, enums and unions
+
+fn main() {}
index 32bd66f5a939cd08632a1b49c3d02431da6ef4e9..072243d881ca68f1507b631ef6f47cfb532f035f 100644 (file)
@@ -16,3 +16,5 @@ trait Tr2 {
     #[derive(Debug)] //~ ERROR `derive` may only be applied to structs, enums and unions
     type F;
 }
+
+fn main() {}
index a16c4c31d81c4593facd604992c8470d13c59a9f..d78b958463fcb8e14e253ee91d468541fe5738e8 100644 (file)
@@ -4,7 +4,7 @@ impl $my_type for u8 {}
     }
 }
 
-trait Trait {}
+trait Tr {}
 
 m!(Tr);
 
index dbd96e96191e12991a01f24107c34a1e86637dda..ad66e421c6b9de848382eb619323ba1eac75f26e 100644 (file)
@@ -9,5 +9,5 @@ macro_rules! bar {
 }
 
 fn main() {
-   bar!();
+   bar!(); //~ ERROR cannot find macro `bar!` in this scope
 }
index 8de4d081413b1c9dda58642593b208be967406eb..6b5e979082e93986863f52927cc2b2ec920bd55b 100644 (file)
@@ -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`.
index caef23043cba3e807a94479bd79fd4a9dfc4d662..ad5438fbd46cbd80e6aea86762ed55444ae69af0 100644 (file)
@@ -22,3 +22,4 @@ fn drop(&mut self) {}
 
 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
index 89786f72e182e6193d39b62b7a2049620a4f8d34..33afac39865ad257809f9660248dfce5074cf1ea 100644 (file)
@@ -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`.
index a172f6a7bfad140c4d70b216953fa7a5fe2aa2e6..efdea5c9b1e16e44c2cd536a99f12ab4f641aa78 100644 (file)
@@ -22,3 +22,5 @@ fn in_neighbors(&'a self, u: &Self::Node) -> Box<Iterator<Item = Self::Node>> {
 //~^ ERROR cannot infer
     }
 }
+
+fn main() {}
index f8ca0727efb7efd24d5a84a6f35e3d2282ec4daf..c05f8b85d0e989c16ca92b2c2887be8b7ca75972 100644 (file)
@@ -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<Item=<Self as Graph<'a>>::Node> + 'static)>
               found std::boxed::Box<dyn std::iter::Iterator<Item=<Self as Graph<'a>>::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`.
index 5da54451346a54acebdc8c7c001160c81e176206..6a5986c355e1cd64283ce187b147c5fd7ffeaf71 100644 (file)
@@ -2,6 +2,7 @@ macro_rules! e {
     ($inp:ident) => (
         $nonexistent
         //~^ ERROR unknown macro variable `nonexistent`
+        //~| ERROR cannot find value `nonexistent` in this scope
     );
 }
 
index 2a4ece2f2425f9f272fe2c5ef7a7ae6686f0d9bc..face872591456ca528327643fc2a986cb6a9df47 100644 (file)
@@ -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`.
index 056a720bc5c6ecd1d8b8021934e5f2c3b5383d7e..4ff7cfe386553f1d4d19881b684eb6a68e79708c 100644 (file)
@@ -9,5 +9,6 @@ macro_rules! g {
 }
 
 fn main() {
+    let foo = 0;
     g!(foo);
 }
index fd2f1b7a286ac2d076faf178b50cd8eb61a38e8b..2c11ce56f8b838b66ea508a78b2b248cb2c1ba2e 100644 (file)
@@ -12,6 +12,8 @@ macro_rules! pong {
 //~| ERROR expected one of
 //~| ERROR expected one of
 
+struct syntax;
+
 fn main() {
     pong!();
     ping!();
index b3988717b372d3bd8d5f7761e5903e8a74bc0c09..7a4b9278e0a610b871c073f9a590b62a3a38d652 100644 (file)
@@ -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
 
index 5978258b5d8da26f3b58791044beccdce86c7041..2c8ebc497728b73a5ee6be3d35ec5c09a111ab0b 100644 (file)
@@ -13,3 +13,5 @@
 #[derive]
 //~^ WARNING empty trait list
 struct Test4;
+
+fn main() {}
index 60f8684968fe0fa04053acd54c300d8179de6a4f..866c5b2e34bbd01071509b4eb14bbcc8a0d31ff6 100644 (file)
@@ -3,3 +3,5 @@
 // error-pattern:cannot depend on a crate that needs a panic runtime
 
 extern crate depends;
+
+fn main() {}
index 0e68c9b806d1d67bd76b2da69a2f51c417851292..27e27dda5effe256ea9513fe3f5ac8c22c2a870a 100644 (file)
@@ -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`.
index 7bab86539827a432385194973624b645b92ad425..bae90227c62f405d3b1bae2a7eddf36539d2ddd4 100644 (file)
@@ -14,5 +14,5 @@ mod foo {
 }
 
 fn main() {
-    let y: u32 = foo::x;
+    let y: u32 = foo::x; //~ ERROR static `x` is private
 }
index a801986ed4e34a2633a56dae8f7914462c1d2b23..fb7a1fce54955b14b62543be7c47a32880410675 100644 (file)
@@ -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`.
index 50678818bf8bc0fa78f4e9d816c80feb700db3ab..0b082f4818f1b53fa32f72cc1e13df96ec721cd3 100644 (file)
@@ -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;
 
index 41f51aea6fcfbe48c5c17655f2c2680f59f1e382..2c702c7871d0578572bfe67b125546dad817c86f 100644 (file)
@@ -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`.
index 44700ca447ddccb6ef1b3144284bedf90d207f1d..d0dd1b4603b168b4409fe05738794eeb66c77bc1 100644 (file)
@@ -7,3 +7,5 @@
 use lifetimes::*;
 
 type A = single_quote_alone!(); //~ ERROR expected type, found `'`
+
+fn main() {}
index e3fb96b90edeff2051da7dca1f375c6b31050c21..b870b438a65406101839550ab906fca5a9123ad3 100644 (file)
@@ -1,5 +1,7 @@
 // aux-build:more-gates.rs
 
+#![feature(decl_macro)]
+
 extern crate more_gates as foo;
 
 use foo::*;
index 2e12c34b99b1b1df65ce32604f19ed85d82c3232..799f1de586ed4d10774eed84c4f4b89563f25902 100644 (file)
@@ -28,6 +28,9 @@
 
 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() {
index c39d4c19eb500e647bb504280df909a3ad65dbf2..2d9ebff88cb668d56551db40808c69ce49bf9ac1 100644 (file)
@@ -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`.
index e05828209adb77aa007b10bd97a38c47903ffe1a..1cc824e943c75b7ce14848ded7fd7eaf8a4e987d 100644 (file)
@@ -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;
 
index ecdc55588514a63e5e63f9ee377d8f42a1567a74..8b87e482282bd6c936e2508c233d6bbcbfdc4a02 100644 (file)
@@ -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`.
index dd79d2b3e4a6ebb42c80e5c19b22d24b9204f72c..b948226652b45fbca46b0d6c0394f8be685218c8 100644 (file)
@@ -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);
index 89f4db0ad3c1570b69f61252818b69018afddbab..3c582286662afccc38cbf1f302e9a985aef9786a 100644 (file)
@@ -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`.
index 0b00d711036ff3bff7cd7c3effca456495fcb4f6..96c63ba4db8c9dfb0879a0a8023c340f3e34a7a9 100644 (file)
@@ -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`
 }
index 0d7fa70772282e3d74d2ca2c338d91f903677f1e..4f1c0e1aa707416bb5d92e62b489b2060bca00c4 100644 (file)
@@ -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`.
index 742318d1e959dd5159623e789bc49215fff5eefd..4a1681e4e2b8a83b1a496ca9fe0009698453154a 100644 (file)
@@ -7,6 +7,7 @@ mod foo {
 
 struct Bar<'Self>;
 //~^ ERROR lifetimes cannot use keyword names
+//~| ERROR parameter `'Self` is never used
 
 struct Foo;
 
index 3b095b7841839dda2d6810e067fcb8b19cf31d17..1981e23c88a1c809f47a0c46861436dcd3e5e13a 100644 (file)
@@ -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`.
index 663e52075195bd1bb5f8ba032adf544403b9c7d0..e11be9e17f20de30acda43f1f865b4149f6a968b 100644 (file)
@@ -5,3 +5,5 @@ mod foo {
     #![foo] //~ ERROR is currently unknown to the compiler
             //~| ERROR non-builtin inner attributes are unstable
 }
+
+fn main() {}
index f36574e2b3d3d0ecfff7e89826e403aa4466581d..b077d590915cb04932847f11f934fad105f84cad 100644 (file)
@@ -4,9 +4,11 @@ macro_rules! m {
     }
 }
 
+macro_rules! foo { () => () }
+
 fn main() {
     foo::<T>!(); //~ 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
 }
index 79ae4a7e784c90497a69a5a038c694200542f2b6..c1dcc513f3a0a948075a24a175379ec0bcf6d88e 100644 (file)
@@ -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::<T>!(); //~ 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::<T>!(); //~ 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
-
index a9aaabad95ceea6ee8a54d7188acb8903f6dfcea..d77febe0aa22bb1eaf0c77eb17e7a980029deaee 100644 (file)
@@ -4,6 +4,7 @@ macro_rules! m {
 
 struct S<T>(T);
 m!{ S<u8> } //~ ERROR unexpected generic arguments in path
+            //~| ERROR expected module, found struct `S`
 
 mod m {
     m!{ m<> } //~ ERROR unexpected generic arguments in path
index 52b8042ba454f34257bfcdcbc1479ae2279b6001..9a11eea6532b2d9f918635cdd3a4412a85af5ca4 100644 (file)
@@ -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<u8> } //~ 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`.
index 7c8e9bbb23c2834ec37072c57605d6ad36166778..fc0f78b12c9f7fe6f668518d0eaa9577f600cf14 100644 (file)
@@ -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() {}
index 9aba84046a1a73b6b04d75d2069a2a45e6146f05..baca625b0bde5d1f508322f487a1f14b790985c4 100644 (file)
@@ -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`.
index 8d7c7c35caff94a1fc052f23af3a53cb12bbbfdd..6b8534b452411eb5bdd42f900f8e17b9fb4a4867 100644 (file)
@@ -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() {}
index fc71354a9d640ba5dcef8322b5811e7fcd74a376..2da34fff53da63997158b131c51713cdc6a5eb34 100644 (file)
@@ -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`.