Checks for unknown attributes before aborting

...due to unresolved macros.
This commit is contained in:
Shotaro Yamada 2018-03-16 16:53:40 +09:00
parent a7170b0412
commit 4be3e96b80
3 changed files with 49 additions and 4 deletions

View File

@ -877,10 +877,6 @@ pub fn phase_2_configure_and_expand_inner<'a, F>(sess: &'a Session,
Ok(())
})?;
if resolver.found_unresolved_macro {
sess.parse_sess.span_diagnostic.abort_if_errors();
}
// Needs to go *after* expansion to be able to check the results of macro expansion.
time(sess, "complete gated feature checking", || {
sess.track_errors(|| {
@ -892,6 +888,12 @@ pub fn phase_2_configure_and_expand_inner<'a, F>(sess: &'a Session,
})
})?;
// Unresolved macros might be due to mistyped `#[macro_use]`,
// so abort after checking for unknown attributes. (#49074)
if resolver.found_unresolved_macro {
sess.parse_sess.span_diagnostic.abort_if_errors();
}
// Lower ast -> hir.
// First, we need to collect the dep_graph.
let dep_graph = match future_dep_graph {

View File

@ -0,0 +1,24 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Check that unknown attribute error is shown even if there are unresolved macros.
#[marco_use] // typo
//~^ ERROR The attribute `marco_use` is currently unknown to the compiler
mod foo {
macro_rules! bar {
() => ();
}
}
fn main() {
bar!();
//~^ ERROR cannot find macro `bar!`
}

View File

@ -0,0 +1,19 @@
error: cannot find macro `bar!` in this scope
--> $DIR/issue-49074.rs:22:4
|
LL | bar!();
| ^^^
|
= help: have you added the `#[macro_use]` on the module/import?
error[E0658]: The attribute `marco_use` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> $DIR/issue-49074.rs:13:1
|
LL | #[marco_use] // typo
| ^^^^^^^^^^^^
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.