diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 4910d63010c6e..46fc6e3047268 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -2495,12 +2495,8 @@ fn is_c_like_enum(item: &Item<'_>) -> bool { } } -// FIXME: Fix "Cannot determine resolution" error and remove built-in macros -// from this check. +// builtin macros will be checked in resolve fn check_invalid_crate_level_attr(tcx: TyCtxt<'_>, attrs: &[Attribute]) { - // Check for builtin attributes at the crate level - // which were unsuccessfully resolved due to cannot determine - // resolution for the attribute macro error. const ATTRS_TO_CHECK: &[Symbol] = &[ sym::macro_export, sym::repr, @@ -2509,11 +2505,6 @@ fn check_invalid_crate_level_attr(tcx: TyCtxt<'_>, attrs: &[Attribute]) { sym::start, sym::rustc_main, sym::unix_sigpipe, - sym::derive, - sym::test, - sym::test_case, - sym::global_allocator, - sym::bench, ]; for attr in attrs { diff --git a/compiler/rustc_resolve/messages.ftl b/compiler/rustc_resolve/messages.ftl index 272483d4a9876..9aa146f9c0c2e 100644 --- a/compiler/rustc_resolve/messages.ftl +++ b/compiler/rustc_resolve/messages.ftl @@ -151,6 +151,10 @@ resolve_invalid_asm_sym = .label = is a local variable .help = `sym` operands must refer to either a function or a static +resolve_invalid_attr_at_crate_level = + `{$name}` attribute cannot be used at crate level + .suggestion = perhaps you meant to use an outer attribute + resolve_is_not_directly_importable = `{$target}` is not directly importable .label = cannot be imported directly diff --git a/compiler/rustc_resolve/src/errors.rs b/compiler/rustc_resolve/src/errors.rs index 72ff959bbd632..ba602724422bd 100644 --- a/compiler/rustc_resolve/src/errors.rs +++ b/compiler/rustc_resolve/src/errors.rs @@ -771,3 +771,26 @@ pub(crate) struct IsNotDirectlyImportable { pub(crate) span: Span, pub(crate) target: Ident, } + +#[derive(Diagnostic)] +#[diag(resolve_invalid_attr_at_crate_level)] +pub struct InvalidAttrAtCrateLevel { + #[primary_span] + pub(crate) span: Span, + pub(crate) name: Symbol, + #[subdiagnostic] + pub(crate) sugg: InvalidAttrSugg, +} + +#[derive(Subdiagnostic)] +#[suggestion( + resolve_suggestion, + code = "", + applicability = "machine-applicable", + style = "verbose" +)] +pub(crate) struct InvalidAttrSugg { + #[primary_span] + pub(crate) span: Span, + pub(crate) name: Symbol, +} diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index d15e245868325..42ea0edb12710 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -1584,6 +1584,13 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { self.get_macro(res).is_some_and(|macro_data| macro_data.ext.builtin_name.is_some()) } + fn is_builtin(&mut self, res: Res) -> bool { + if self.is_builtin_macro(res) { + return true; + } + self.builtin_attrs_bindings.values().any(|b| b.res() == res) + } + fn macro_def(&self, mut ctxt: SyntaxContext) -> DefId { loop { match ctxt.outer_expn_data().macro_def_id { diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs index f8274e7d7d0df..b0b68146c5c7f 100644 --- a/compiler/rustc_resolve/src/macros.rs +++ b/compiler/rustc_resolve/src/macros.rs @@ -1,6 +1,8 @@ //! A bunch of methods and structures more or less related to resolving macros and //! interface provided by `Resolver` to macro expander. +use crate::ast::AttrStyle; +use crate::ast::Attribute; use crate::errors::{ self, AddAsNonDerive, CannotDetermineMacroResolution, CannotFindIdentInThisScope, MacroExpectedFound, RemoveSurroundingDerive, @@ -35,6 +37,7 @@ use rustc_span::edition::Edition; use rustc_span::hygiene::{self, ExpnData, ExpnKind, LocalExpnId}; use rustc_span::hygiene::{AstPass, MacroKind}; use rustc_span::symbol::{kw, sym, Ident, Symbol}; +use rustc_span::BytePos; use rustc_span::{Span, DUMMY_SP}; use std::cell::Cell; use std::mem; @@ -698,6 +701,35 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { res.map(|res| (self.get_macro(res).map(|macro_data| macro_data.ext.clone()), res)) } + fn report_invalid_crate_level_attr(&mut self, attrs: &[Attribute], name: Symbol) -> bool { + for attr in attrs.iter().filter(|attr| attr.style == AttrStyle::Inner) { + if attr.has_name(name) { + let tcx = self.tcx; + tcx.sess.emit_err(errors::InvalidAttrAtCrateLevel { + name, + span: attr.span, + sugg: errors::InvalidAttrSugg { + span: tcx + .sess + .source_map() + .span_to_snippet(attr.span) + .ok() + .filter(|src| src.starts_with("#![")) + .map(|_| { + attr.span + .with_lo(attr.span.lo() + BytePos(1)) + .with_hi(attr.span.lo() + BytePos(2)) + }) + .unwrap(), + name, + }, + }); + return true; + } + } + false + } + pub(crate) fn finalize_macro_resolutions(&mut self, krate: &Crate) { let check_consistency = |this: &mut Self, path: &[Segment], @@ -717,15 +749,28 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { // expanded into a dummy fragment for recovery during expansion. // Now, post-expansion, the resolution may succeed, but we can't change the // past and need to report an error. - // However, non-speculative `resolve_path` can successfully return private items + // Special cases: + // 1. non-speculative `resolve_path` can successfully return private items // even if speculative `resolve_path` returned nothing previously, so we skip this // less informative error if the privacy error is reported elsewhere. + // 2. issue #118455, unresolved top level attribute error didn't imported prelude and + // already have emitted an error, report builtin macro and attributes error by the way, + // so `check_invalid_crate_level_attr` in can ignore them. + + let is_builtin = res.opt_def_id().map_or(false, |_| this.is_builtin(res)); if this.privacy_errors.is_empty() { - this.tcx.sess.emit_err(CannotDetermineMacroResolution { - span, - kind: kind.descr(), - path: Segment::names_to_string(path), - }); + let mut fallback = !is_builtin; + if is_builtin && krate.id == ast::CRATE_NODE_ID { + fallback = + !this.report_invalid_crate_level_attr(&krate.attrs, path[0].ident.name); + } + if fallback && this.tcx.sess.has_errors().is_none() { + this.tcx.sess.emit_err(CannotDetermineMacroResolution { + span, + kind: kind.descr(), + path: Segment::names_to_string(path), + }); + } } } }; diff --git a/tests/ui/derives/issue-36617.rs b/tests/ui/derives/issue-36617.rs index 08f293d2ebb06..236ec7748cbdd 100644 --- a/tests/ui/derives/issue-36617.rs +++ b/tests/ui/derives/issue-36617.rs @@ -1,16 +1,16 @@ -#![derive(Copy)] //~ ERROR cannot determine resolution for the attribute macro `derive` +#![derive(Copy)] //~^ ERROR `derive` attribute cannot be used at crate level -#![test]//~ ERROR cannot determine resolution for the attribute macro `test` +#![test] //~^ ERROR `test` attribute cannot be used at crate level -#![test_case]//~ ERROR cannot determine resolution for the attribute macro `test_case` +#![test_case] //~^ ERROR `test_case` attribute cannot be used at crate level -#![bench]//~ ERROR cannot determine resolution for the attribute macro `bench` +#![bench] //~^ ERROR `bench` attribute cannot be used at crate level -#![global_allocator]//~ ERROR cannot determine resolution for the attribute macro `global_allocator` +#![global_allocator] //~^ ERROR `global_allocator` attribute cannot be used at crate level fn main() {} diff --git a/tests/ui/derives/issue-36617.stderr b/tests/ui/derives/issue-36617.stderr index 98be7963e5ef9..8bc98d9233269 100644 --- a/tests/ui/derives/issue-36617.stderr +++ b/tests/ui/derives/issue-36617.stderr @@ -1,51 +1,8 @@ -error: cannot determine resolution for the attribute macro `derive` - --> $DIR/issue-36617.rs:1:4 - | -LL | #![derive(Copy)] - | ^^^^^^ - | - = note: import resolution is stuck, try simplifying macro imports - -error: cannot determine resolution for the attribute macro `test` - --> $DIR/issue-36617.rs:4:4 - | -LL | #![test] - | ^^^^ - | - = note: import resolution is stuck, try simplifying macro imports - -error: cannot determine resolution for the attribute macro `test_case` - --> $DIR/issue-36617.rs:7:4 - | -LL | #![test_case] - | ^^^^^^^^^ - | - = note: import resolution is stuck, try simplifying macro imports - -error: cannot determine resolution for the attribute macro `bench` - --> $DIR/issue-36617.rs:10:4 - | -LL | #![bench] - | ^^^^^ - | - = note: import resolution is stuck, try simplifying macro imports - -error: cannot determine resolution for the attribute macro `global_allocator` - --> $DIR/issue-36617.rs:13:4 - | -LL | #![global_allocator] - | ^^^^^^^^^^^^^^^^ - | - = note: import resolution is stuck, try simplifying macro imports - error: `derive` attribute cannot be used at crate level --> $DIR/issue-36617.rs:1:1 | LL | #![derive(Copy)] | ^^^^^^^^^^^^^^^^ -... -LL | fn main() {} - | ---- the inner attribute doesn't annotate this function | help: perhaps you meant to use an outer attribute | @@ -58,9 +15,6 @@ error: `test` attribute cannot be used at crate level | LL | #![test] | ^^^^^^^^ -... -LL | fn main() {} - | ---- the inner attribute doesn't annotate this function | help: perhaps you meant to use an outer attribute | @@ -73,9 +27,6 @@ error: `test_case` attribute cannot be used at crate level | LL | #![test_case] | ^^^^^^^^^^^^^ -... -LL | fn main() {} - | ---- the inner attribute doesn't annotate this function | help: perhaps you meant to use an outer attribute | @@ -88,9 +39,6 @@ error: `bench` attribute cannot be used at crate level | LL | #![bench] | ^^^^^^^^^ -... -LL | fn main() {} - | ---- the inner attribute doesn't annotate this function | help: perhaps you meant to use an outer attribute | @@ -103,9 +51,6 @@ error: `global_allocator` attribute cannot be used at crate level | LL | #![global_allocator] | ^^^^^^^^^^^^^^^^^^^^ -... -LL | fn main() {} - | ---- the inner attribute doesn't annotate this function | help: perhaps you meant to use an outer attribute | @@ -113,5 +58,5 @@ LL - #![global_allocator] LL + #[global_allocator] | -error: aborting due to 10 previous errors +error: aborting due to 5 previous errors diff --git a/tests/ui/extenv/issue-55897.rs b/tests/ui/extenv/issue-55897.rs index b7533f41351da..b6500e5405933 100644 --- a/tests/ui/extenv/issue-55897.rs +++ b/tests/ui/extenv/issue-55897.rs @@ -4,7 +4,6 @@ mod unresolved_env { use env; //~ ERROR unresolved import `env` include!(concat!(env!("NON_EXISTENT"), "/data.rs")); - //~^ ERROR cannot determine resolution for the macro `env` } mod nonexistent_env { diff --git a/tests/ui/extenv/issue-55897.stderr b/tests/ui/extenv/issue-55897.stderr index 401db827813a9..2e8c05cca867f 100644 --- a/tests/ui/extenv/issue-55897.stderr +++ b/tests/ui/extenv/issue-55897.stderr @@ -1,5 +1,5 @@ error: environment variable `NON_EXISTENT` not defined at compile time - --> $DIR/issue-55897.rs:11:22 + --> $DIR/issue-55897.rs:10:22 | LL | include!(concat!(env!("NON_EXISTENT"), "/data.rs")); | ^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | include!(concat!(env!("NON_EXISTENT"), "/data.rs")); = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info) error: suffixes on string literals are invalid - --> $DIR/issue-55897.rs:16:22 + --> $DIR/issue-55897.rs:15:22 | LL | include!(concat!("NON_EXISTENT"suffix, "/data.rs")); | ^^^^^^^^^^^^^^^^^^^^ invalid suffix `suffix` @@ -33,14 +33,6 @@ help: consider importing this module instead LL | use std::env; | ~~~~~~~~ -error: cannot determine resolution for the macro `env` - --> $DIR/issue-55897.rs:6:22 - | -LL | include!(concat!(env!("NON_EXISTENT"), "/data.rs")); - | ^^^ - | - = note: import resolution is stuck, try simplifying macro imports - -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/feature-gates/issue-43106-gating-of-bench.rs b/tests/ui/feature-gates/issue-43106-gating-of-bench.rs index 796325b79af66..8ed77c7f35791 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-bench.rs +++ b/tests/ui/feature-gates/issue-43106-gating-of-bench.rs @@ -3,8 +3,6 @@ // handled in "weird places" when `--test` is passed. #![feature(custom_inner_attributes)] - -#![bench = "4100"] -//~^ ERROR cannot determine resolution for the attribute macro `bench` -//~^^ ERROR `bench` attribute cannot be used at crate level +#![bench = "4100"] +//~^ ERROR `bench` attribute cannot be used at crate level fn main() {} diff --git a/tests/ui/feature-gates/issue-43106-gating-of-bench.stderr b/tests/ui/feature-gates/issue-43106-gating-of-bench.stderr index 8270d46d492a9..df8513fded5eb 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-bench.stderr +++ b/tests/ui/feature-gates/issue-43106-gating-of-bench.stderr @@ -1,25 +1,14 @@ -error: cannot determine resolution for the attribute macro `bench` - --> $DIR/issue-43106-gating-of-bench.rs:7:4 - | -LL | #![bench = "4100"] - | ^^^^^ - | - = note: import resolution is stuck, try simplifying macro imports - error: `bench` attribute cannot be used at crate level - --> $DIR/issue-43106-gating-of-bench.rs:7:1 + --> $DIR/issue-43106-gating-of-bench.rs:6:1 | -LL | #![bench = "4100"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -... -LL | fn main() {} - | ---- the inner attribute doesn't annotate this function +LL | #![bench = "4100"] + | ^^^^^^^^^^^^^^^^^^ | help: perhaps you meant to use an outer attribute | -LL - #![bench = "4100"] -LL + #[bench = "4100"] +LL - #![bench = "4100"] +LL + #[bench = "4100"] | -error: aborting due to 2 previous errors +error: aborting due to 1 previous error diff --git a/tests/ui/feature-gates/issue-43106-gating-of-test.rs b/tests/ui/feature-gates/issue-43106-gating-of-test.rs index 39835c9268eef..21c586b51484a 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-test.rs +++ b/tests/ui/feature-gates/issue-43106-gating-of-test.rs @@ -1,7 +1,6 @@ // The non-crate level cases are in issue-43106-gating-of-builtin-attrs.rs. #![allow(soft_unstable)] -#![test = "4200"] -//~^ ERROR cannot determine resolution for the attribute macro `test` -//~^^ ERROR `test` attribute cannot be used at crate level +#![test = "4200"] +//~^ ERROR `test` attribute cannot be used at crate level fn main() {} diff --git a/tests/ui/feature-gates/issue-43106-gating-of-test.stderr b/tests/ui/feature-gates/issue-43106-gating-of-test.stderr index 922c9861aa3c1..0557a6e32ca17 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-test.stderr +++ b/tests/ui/feature-gates/issue-43106-gating-of-test.stderr @@ -1,25 +1,14 @@ -error: cannot determine resolution for the attribute macro `test` - --> $DIR/issue-43106-gating-of-test.rs:4:4 - | -LL | #![test = "4200"] - | ^^^^ - | - = note: import resolution is stuck, try simplifying macro imports - error: `test` attribute cannot be used at crate level --> $DIR/issue-43106-gating-of-test.rs:4:1 | -LL | #![test = "4200"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -... -LL | fn main() {} - | ---- the inner attribute doesn't annotate this function +LL | #![test = "4200"] + | ^^^^^^^^^^^^^^^^^ | help: perhaps you meant to use an outer attribute | -LL - #![test = "4200"] -LL + #[test = "4200"] +LL - #![test = "4200"] +LL + #[test = "4200"] | -error: aborting due to 2 previous errors +error: aborting due to 1 previous error diff --git a/tests/ui/imports/issue-28134.rs b/tests/ui/imports/issue-28134.rs index ef2a5d634a678..0cecdf7a0ec73 100644 --- a/tests/ui/imports/issue-28134.rs +++ b/tests/ui/imports/issue-28134.rs @@ -1,5 +1,5 @@ // compile-flags: --test #![allow(soft_unstable)] -#![test] //~ ERROR cannot determine resolution for the attribute macro `test` +#![test] //~^ ERROR 4:1: 4:9: `test` attribute cannot be used at crate level diff --git a/tests/ui/imports/issue-28134.stderr b/tests/ui/imports/issue-28134.stderr index 5315c2e9fee9c..e47aa15e87a94 100644 --- a/tests/ui/imports/issue-28134.stderr +++ b/tests/ui/imports/issue-28134.stderr @@ -1,11 +1,3 @@ -error: cannot determine resolution for the attribute macro `test` - --> $DIR/issue-28134.rs:4:4 - | -LL | #![test] - | ^^^^ - | - = note: import resolution is stuck, try simplifying macro imports - error: `test` attribute cannot be used at crate level --> $DIR/issue-28134.rs:4:1 | @@ -18,5 +10,5 @@ LL - #![test] LL + #[test] | -error: aborting due to 2 previous errors +error: aborting due to 1 previous error diff --git a/tests/ui/imports/issue-55457.rs b/tests/ui/imports/issue-55457.rs index c1f048897d9ea..fd08294025587 100644 --- a/tests/ui/imports/issue-55457.rs +++ b/tests/ui/imports/issue-55457.rs @@ -1,10 +1,9 @@ use NonExistent; //~ ERROR unresolved import `NonExistent` use non_existent::non_existent; //~ ERROR unresolved import `non_existent` -#[non_existent] //~ ERROR cannot determine resolution for the attribute macro `non_existent` -#[derive(NonExistent)] //~ ERROR cannot determine resolution for the derive macro `NonExistent` - //~| ERROR cannot determine resolution for the derive macro `NonExistent` - //~| ERROR cannot determine resolution for the derive macro `NonExistent` +#[non_existent] +#[derive(NonExistent)] + struct S; fn main() {} diff --git a/tests/ui/imports/issue-55457.stderr b/tests/ui/imports/issue-55457.stderr index 30d2373652b4c..09bb13a060478 100644 --- a/tests/ui/imports/issue-55457.stderr +++ b/tests/ui/imports/issue-55457.stderr @@ -15,40 +15,6 @@ LL | use non_existent::non_existent; | = help: consider adding `extern crate non_existent` to use the `non_existent` crate -error: cannot determine resolution for the derive macro `NonExistent` - --> $DIR/issue-55457.rs:5:10 - | -LL | #[derive(NonExistent)] - | ^^^^^^^^^^^ - | - = note: import resolution is stuck, try simplifying macro imports - -error: cannot determine resolution for the attribute macro `non_existent` - --> $DIR/issue-55457.rs:4:3 - | -LL | #[non_existent] - | ^^^^^^^^^^^^ - | - = note: import resolution is stuck, try simplifying macro imports - -error: cannot determine resolution for the derive macro `NonExistent` - --> $DIR/issue-55457.rs:5:10 - | -LL | #[derive(NonExistent)] - | ^^^^^^^^^^^ - | - = note: import resolution is stuck, try simplifying macro imports - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: cannot determine resolution for the derive macro `NonExistent` - --> $DIR/issue-55457.rs:5:10 - | -LL | #[derive(NonExistent)] - | ^^^^^^^^^^^ - | - = note: import resolution is stuck, try simplifying macro imports - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: aborting due to 6 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/imports/issue-59764.rs b/tests/ui/imports/issue-59764.rs index 09dee8c273268..91b3ddcd84d57 100644 --- a/tests/ui/imports/issue-59764.rs +++ b/tests/ui/imports/issue-59764.rs @@ -128,7 +128,6 @@ use issue_59764::foo::makro; //~^ ERROR unresolved import `issue_59764::foo::makro` [E0432] makro!(bar); -//~^ ERROR cannot determine resolution for the macro `makro` fn main() { bar(); diff --git a/tests/ui/imports/issue-59764.stderr b/tests/ui/imports/issue-59764.stderr index b969515e2f0e6..fe58eb97b8dbf 100644 --- a/tests/ui/imports/issue-59764.stderr +++ b/tests/ui/imports/issue-59764.stderr @@ -226,21 +226,13 @@ help: a macro with this name exists at the root of the crate LL | use issue_59764::makro; | ~~~~~~~~~~~~~~~~~~ -error: cannot determine resolution for the macro `makro` - --> $DIR/issue-59764.rs:130:1 - | -LL | makro!(bar); - | ^^^^^ - | - = note: import resolution is stuck, try simplifying macro imports - error[E0425]: cannot find function `bar` in this scope - --> $DIR/issue-59764.rs:134:5 + --> $DIR/issue-59764.rs:133:5 | LL | bar(); | ^^^ not found in this scope -error: aborting due to 18 previous errors +error: aborting due to 17 previous errors Some errors have detailed explanations: E0425, E0432. For more information about an error, try `rustc --explain E0425`. diff --git a/tests/ui/proc-macro/derive-helper-legacy-spurious.rs b/tests/ui/proc-macro/derive-helper-legacy-spurious.rs index 4a7e48eed46c3..b484b42e56672 100644 --- a/tests/ui/proc-macro/derive-helper-legacy-spurious.rs +++ b/tests/ui/proc-macro/derive-helper-legacy-spurious.rs @@ -5,7 +5,7 @@ #[macro_use] extern crate test_macros; -#[derive(Empty)] //~ ERROR cannot determine resolution for the attribute macro `derive` +#[derive(Empty)] #[empty_helper] //~ ERROR cannot find attribute `empty_helper` in this scope struct Foo {} diff --git a/tests/ui/proc-macro/derive-helper-legacy-spurious.stderr b/tests/ui/proc-macro/derive-helper-legacy-spurious.stderr index fd1ed8a3d0ff3..b34713b8ca68e 100644 --- a/tests/ui/proc-macro/derive-helper-legacy-spurious.stderr +++ b/tests/ui/proc-macro/derive-helper-legacy-spurious.stderr @@ -4,19 +4,11 @@ error: cannot find attribute `dummy` in this scope LL | #![dummy] | ^^^^^ -error: cannot determine resolution for the attribute macro `derive` - --> $DIR/derive-helper-legacy-spurious.rs:8:3 - | -LL | #[derive(Empty)] - | ^^^^^^ - | - = note: import resolution is stuck, try simplifying macro imports - error: cannot find attribute `empty_helper` in this scope --> $DIR/derive-helper-legacy-spurious.rs:9:3 | LL | #[empty_helper] | ^^^^^^^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/proc-macro/issue-118455-skip-err-builtin.rs b/tests/ui/proc-macro/issue-118455-skip-err-builtin.rs new file mode 100644 index 0000000000000..baef020612891 --- /dev/null +++ b/tests/ui/proc-macro/issue-118455-skip-err-builtin.rs @@ -0,0 +1,6 @@ +#![some_nonexistent_attribute] +//~^ ERROR cannot find attribute `some_nonexistent_attribute` in this scope +#[derive(Debug)] +pub struct SomeUserCode; + +fn main() {} diff --git a/tests/ui/proc-macro/issue-118455-skip-err-builtin.stderr b/tests/ui/proc-macro/issue-118455-skip-err-builtin.stderr new file mode 100644 index 0000000000000..fa8af87a3d019 --- /dev/null +++ b/tests/ui/proc-macro/issue-118455-skip-err-builtin.stderr @@ -0,0 +1,8 @@ +error: cannot find attribute `some_nonexistent_attribute` in this scope + --> $DIR/issue-118455-skip-err-builtin.rs:1:4 + | +LL | #![some_nonexistent_attribute] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/reserved/reserved-attr-on-macro.rs b/tests/ui/reserved/reserved-attr-on-macro.rs index 2630db0d09785..5c4657e0ec2e1 100644 --- a/tests/ui/reserved/reserved-attr-on-macro.rs +++ b/tests/ui/reserved/reserved-attr-on-macro.rs @@ -7,5 +7,5 @@ macro_rules! foo { } fn main() { - foo!(); //~ ERROR cannot determine resolution for the macro `foo` + foo!(); } diff --git a/tests/ui/reserved/reserved-attr-on-macro.stderr b/tests/ui/reserved/reserved-attr-on-macro.stderr index e55b58bef2855..066f72367b1a5 100644 --- a/tests/ui/reserved/reserved-attr-on-macro.stderr +++ b/tests/ui/reserved/reserved-attr-on-macro.stderr @@ -4,19 +4,11 @@ error: attributes starting with `rustc` are reserved for use by the `rustc` comp LL | #[rustc_attribute_should_be_reserved] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: cannot determine resolution for the macro `foo` - --> $DIR/reserved-attr-on-macro.rs:10:5 - | -LL | foo!(); - | ^^^ - | - = note: import resolution is stuck, try simplifying macro imports - error: cannot find attribute `rustc_attribute_should_be_reserved` in this scope --> $DIR/reserved-attr-on-macro.rs:1:3 | LL | #[rustc_attribute_should_be_reserved] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/rust-2018/issue-54006.rs b/tests/ui/rust-2018/issue-54006.rs index a7a4770fc02f9..6f929731c7674 100644 --- a/tests/ui/rust-2018/issue-54006.rs +++ b/tests/ui/rust-2018/issue-54006.rs @@ -8,6 +8,5 @@ use alloc::vec; pub fn foo() { let mut xs = vec![]; - //~^ ERROR cannot determine resolution for the macro `vec` xs.push(0); } diff --git a/tests/ui/rust-2018/issue-54006.stderr b/tests/ui/rust-2018/issue-54006.stderr index 1978138a68878..35d4c17d2c7f1 100644 --- a/tests/ui/rust-2018/issue-54006.stderr +++ b/tests/ui/rust-2018/issue-54006.stderr @@ -4,14 +4,6 @@ error[E0432]: unresolved import `alloc` LL | use alloc::vec; | ^^^^^ help: a similar path exists: `core::alloc` -error: cannot determine resolution for the macro `vec` - --> $DIR/issue-54006.rs:10:18 - | -LL | let mut xs = vec![]; - | ^^^ - | - = note: import resolution is stuck, try simplifying macro imports - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/span/issue-43927-non-ADT-derive.rs b/tests/ui/span/issue-43927-non-ADT-derive.rs index 935bfa001bfc6..e50ee36d7de95 100644 --- a/tests/ui/span/issue-43927-non-ADT-derive.rs +++ b/tests/ui/span/issue-43927-non-ADT-derive.rs @@ -1,6 +1,5 @@ #![derive(Debug, PartialEq, Eq)] // should be an outer attribute! -//~^ ERROR cannot determine resolution for the attribute macro `derive` -//~^^ ERROR `derive` attribute cannot be used at crate level +//~^ ERROR `derive` attribute cannot be used at crate level struct DerivedOn; fn main() {} diff --git a/tests/ui/span/issue-43927-non-ADT-derive.stderr b/tests/ui/span/issue-43927-non-ADT-derive.stderr index a22a4d2b40a8e..774c4206ea149 100644 --- a/tests/ui/span/issue-43927-non-ADT-derive.stderr +++ b/tests/ui/span/issue-43927-non-ADT-derive.stderr @@ -1,19 +1,8 @@ -error: cannot determine resolution for the attribute macro `derive` - --> $DIR/issue-43927-non-ADT-derive.rs:1:4 - | -LL | #![derive(Debug, PartialEq, Eq)] // should be an outer attribute! - | ^^^^^^ - | - = note: import resolution is stuck, try simplifying macro imports - error: `derive` attribute cannot be used at crate level --> $DIR/issue-43927-non-ADT-derive.rs:1:1 | LL | #![derive(Debug, PartialEq, Eq)] // should be an outer attribute! | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -... -LL | struct DerivedOn; - | --------- the inner attribute doesn't annotate this struct | help: perhaps you meant to use an outer attribute | @@ -21,5 +10,5 @@ LL - #![derive(Debug, PartialEq, Eq)] // should be an outer attribute! LL + #[derive(Debug, PartialEq, Eq)] // should be an outer attribute! | -error: aborting due to 2 previous errors +error: aborting due to 1 previous error