Rollup merge of #83634 - JohnTitor:proc-macro-ice, r=varkor
Do not emit the advanced diagnostics on macros Fixes #83510
This commit is contained in:
commit
2c55bacfbf
4 changed files with 71 additions and 1 deletions
|
@ -456,12 +456,14 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let is_macro = base_span.from_expansion() && base_span.desugaring_kind().is_none();
|
||||||
if !self.type_ascription_suggestion(&mut err, base_span) {
|
if !self.type_ascription_suggestion(&mut err, base_span) {
|
||||||
let mut fallback = false;
|
let mut fallback = false;
|
||||||
if let (
|
if let (
|
||||||
PathSource::Trait(AliasPossibility::Maybe),
|
PathSource::Trait(AliasPossibility::Maybe),
|
||||||
Some(Res::Def(DefKind::Struct | DefKind::Enum | DefKind::Union, _)),
|
Some(Res::Def(DefKind::Struct | DefKind::Enum | DefKind::Union, _)),
|
||||||
) = (source, res)
|
false,
|
||||||
|
) = (source, res, is_macro)
|
||||||
{
|
{
|
||||||
if let Some(bounds @ [_, .., _]) = self.diagnostic_metadata.current_trait_object {
|
if let Some(bounds @ [_, .., _]) = self.diagnostic_metadata.current_trait_object {
|
||||||
fallback = true;
|
fallback = true;
|
||||||
|
|
19
src/test/ui/proc-macro/auxiliary/issue-83510.rs
Normal file
19
src/test/ui/proc-macro/auxiliary/issue-83510.rs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
// force-host
|
||||||
|
// no-prefer-dynamic
|
||||||
|
|
||||||
|
#![crate_type = "proc-macro"]
|
||||||
|
|
||||||
|
extern crate proc_macro;
|
||||||
|
|
||||||
|
use proc_macro::TokenStream;
|
||||||
|
|
||||||
|
#[proc_macro]
|
||||||
|
pub fn dance_like_you_want_to_ice(_: TokenStream) -> TokenStream {
|
||||||
|
r#"
|
||||||
|
impl Foo {
|
||||||
|
type Bar = Box<()> + Baz;
|
||||||
|
}
|
||||||
|
"#
|
||||||
|
.parse()
|
||||||
|
.unwrap()
|
||||||
|
}
|
11
src/test/ui/proc-macro/issue-83510.rs
Normal file
11
src/test/ui/proc-macro/issue-83510.rs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
// aux-build: issue-83510.rs
|
||||||
|
|
||||||
|
extern crate issue_83510;
|
||||||
|
|
||||||
|
issue_83510::dance_like_you_want_to_ice!();
|
||||||
|
//~^ ERROR: cannot find type `Foo` in this scope
|
||||||
|
//~| ERROR: expected trait, found struct `Box`
|
||||||
|
//~| ERROR: cannot find trait `Baz` in this scope
|
||||||
|
//~| ERROR: inherent associated types are unstable
|
||||||
|
|
||||||
|
fn main() {}
|
38
src/test/ui/proc-macro/issue-83510.stderr
Normal file
38
src/test/ui/proc-macro/issue-83510.stderr
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
error[E0412]: cannot find type `Foo` in this scope
|
||||||
|
--> $DIR/issue-83510.rs:5:1
|
||||||
|
|
|
||||||
|
LL | issue_83510::dance_like_you_want_to_ice!();
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
|
||||||
|
|
|
||||||
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
|
error[E0404]: expected trait, found struct `Box`
|
||||||
|
--> $DIR/issue-83510.rs:5:1
|
||||||
|
|
|
||||||
|
LL | issue_83510::dance_like_you_want_to_ice!();
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a trait
|
||||||
|
|
|
||||||
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
|
error[E0405]: cannot find trait `Baz` in this scope
|
||||||
|
--> $DIR/issue-83510.rs:5:1
|
||||||
|
|
|
||||||
|
LL | issue_83510::dance_like_you_want_to_ice!();
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
|
||||||
|
|
|
||||||
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
|
error[E0658]: inherent associated types are unstable
|
||||||
|
--> $DIR/issue-83510.rs:5:1
|
||||||
|
|
|
||||||
|
LL | issue_83510::dance_like_you_want_to_ice!();
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #8995 <https://github.com/rust-lang/rust/issues/8995> for more information
|
||||||
|
= help: add `#![feature(inherent_associated_types)]` to the crate attributes to enable
|
||||||
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
Some errors have detailed explanations: E0404, E0405, E0412, E0658.
|
||||||
|
For more information about an error, try `rustc --explain E0404`.
|
Loading…
Add table
Add a link
Reference in a new issue