Do not abort compilation if expansion produces errors

Fix a number of uncovered deficiencies in diagnostics
This commit is contained in:
Vadim Petrochenkov 2018-12-16 20:23:27 +03:00
parent a5c52c72ae
commit fff01ccfa8
80 changed files with 543 additions and 172 deletions

View File

@ -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 {

View File

@ -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<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 @@ 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;

View 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 @@ 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<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 @@ 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() {

View File

@ -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: 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

View File

@ -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<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 @@ impl DummyResult {
}
}
/// 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 @@ impl<'a> ExtCtxt<'a> {
ecfg,
root_path: PathBuf::new(),
resolver,
resolve_err_count: 0,
current_expansion: ExpansionData {
mark: Mark::root(),
depth: 0,

View File

@ -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)

View File

@ -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);

View File

@ -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)`"),
};

View File

@ -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) {

View File

@ -1,2 +1,4 @@
#[cfg(foo(bar))] //~ ERROR invalid predicate `foo`
fn check() {}
fn main() {}

View File

@ -33,3 +33,5 @@ macro_rules! generate_s10 {
}
generate_s10!(concat!("nonexistent"));
fn main() {}

View 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]

View 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

View File

@ -11,4 +11,3 @@ LL | #[derive(Clone)]
| ^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors

View 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() {}

View 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`.

View 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() {}

View 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

View File

@ -10,3 +10,5 @@ mod one_async {
mod two_async {
produces_async_raw! {} // OK
}
fn main() {}

View 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() {}

View 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

View File

@ -10,3 +10,5 @@ mod one_async {
mod two_async {
produces_async_raw! {} // OK
}
fn main() {}

View File

@ -13,3 +13,5 @@ mod derive {
//~^ ERROR cannot find derive macro `x3300` in this scope
struct S;
}
fn main() {}

View File

@ -31,3 +31,5 @@ mod derive {
//~^ ERROR `derive` may only be applied to structs, enums and unions
impl S { }
}
fn main() {}

View File

@ -1,3 +1,5 @@
#![feature(intrinsics, lang_items, no_core)]
#![crate_type="rlib"]
#![no_core]

View File

@ -23,3 +23,5 @@ extern {
emits_nothing!();
//~^ ERROR macro invocations in `extern {}` blocks are experimental
}
fn main() {}

View 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() {}

View 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 `!`
}

View 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`.

View 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
}

View 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

View File

@ -1,3 +1,4 @@
fn main() {
concat!(test!()); //~ ERROR cannot find macro `test!` in this scope
//~| ERROR expected a literal
}

View 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

View 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() {}

View 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`.

View File

@ -2,3 +2,5 @@
Sync, //~ ERROR this unsafe trait should be implemented explicitly
Copy)]
enum Foo {}
fn main() {}

View 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() {}

View 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`.

View File

@ -1 +1,3 @@
#![derive(Copy)] //~ ERROR `derive` may only be applied to structs, enums and unions
fn main() {}

View File

@ -16,3 +16,5 @@ trait Tr2 {
#[derive(Debug)] //~ ERROR `derive` may only be applied to structs, enums and unions
type F;
}
fn main() {}

View File

@ -4,7 +4,7 @@ macro_rules! m {
}
}
trait Trait {}
trait Tr {}
m!(Tr);

View File

@ -9,5 +9,5 @@ mod foo {
}
fn main() {
bar!();
bar!(); //~ ERROR cannot find macro `bar!` in this scope
}

View 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`.

View File

@ -22,3 +22,4 @@ unsafe impl<#[cfg_attr(none, may_dangle)] T> Drop for M<T> {
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

View 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`.

View File

@ -22,3 +22,5 @@ pub trait Graph<'a> {
//~^ ERROR cannot infer
}
}
fn main() {}

View 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`.

View File

@ -2,6 +2,7 @@ macro_rules! e {
($inp:ident) => (
$nonexistent
//~^ ERROR unknown macro variable `nonexistent`
//~| ERROR cannot find value `nonexistent` in this scope
);
}

View 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`.

View File

@ -9,5 +9,6 @@ macro_rules! g {
}
fn main() {
let foo = 0;
g!(foo);
}

View File

@ -12,6 +12,8 @@ macro_rules! pong {
//~| ERROR expected one of
//~| ERROR expected one of
struct syntax;
fn main() {
pong!();
ping!();

View 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

View File

@ -13,3 +13,5 @@ struct Test3;
#[derive]
//~^ WARNING empty trait list
struct Test4;
fn main() {}

View File

@ -3,3 +3,5 @@
// error-pattern:cannot depend on a crate that needs a panic runtime
extern crate depends;
fn main() {}

View 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`.

View File

@ -14,5 +14,5 @@ mod foo {
}
fn main() {
let y: u32 = foo::x;
let y: u32 = foo::x; //~ ERROR static `x` is private
}

View 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`.

View 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;

View 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`.

View File

@ -7,3 +7,5 @@ extern crate lifetimes;
use lifetimes::*;
type A = single_quote_alone!(); //~ ERROR expected type, found `'`
fn main() {}

View File

@ -1,5 +1,7 @@
// aux-build:more-gates.rs
#![feature(decl_macro)]
extern crate more_gates as foo;
use foo::*;

View File

@ -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() {

View 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`.

View 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;

View 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]
| ^^^^^^^^^^^^
For more information about this error, try `rustc --explain E0658`.
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
Some errors occurred: E0658, E0659.
For more information about an error, try `rustc --explain E0658`.

View 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);

View 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`.

View 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`
}

View 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`.

View File

@ -7,6 +7,7 @@ mod foo {
struct Bar<'Self>;
//~^ ERROR lifetimes cannot use keyword names
//~| ERROR parameter `'Self` is never used
struct Foo;

View 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`.

View File

@ -5,3 +5,5 @@ mod foo {
#![foo] //~ ERROR is currently unknown to the compiler
//~| ERROR non-builtin inner attributes are unstable
}
fn main() {}

View 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
}

View 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
| ^^^^^^^^^
error: generic arguments in macro path
--> $DIR/macro-ty-params.rs:10:15
|
LL | m!(MyTrait<>); //~ 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
| ^^^^^
error: generic arguments in macro path
--> $DIR/macro-ty-params.rs:9:8
--> $DIR/macro-ty-params.rs:10:15
|
LL | foo::<>!(); //~ ERROR generic arguments in macro path
| ^^^^
error: aborting due to 4 previous errors
error: generic arguments in macro path
--> $DIR/macro-ty-params.rs:8:8
|
LL | m!(Default<>); //~ ERROR generic arguments in macro path
| ^^^^^^^^^
error: generic arguments in macro path
--> $DIR/macro-ty-params.rs:9:8
|
LL | m!(Default<>); //~ ERROR generic arguments in macro path
| ^^
error: aborting due to 4 previous errors

View 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

View 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`.

View 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() {}

View 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`.

View 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() {}

View 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`.