diff options
| author | Luqman Aden <me@luqman.ca> | 2022-08-07 13:55:36 -0700 |
|---|---|---|
| committer | Luqman Aden <me@luqman.ca> | 2022-08-07 14:01:04 -0700 |
| commit | 15b1daaca3fd4020d7a93cff14507b9104ec6d02 (patch) | |
| tree | 9cdf293748b03347745b4ebdaa18b526f145c880 /src | |
| parent | fc83a0cb57eaad7104cc8861ba354fc76da79684 (diff) | |
| download | rust-15b1daaca3fd4020d7a93cff14507b9104ec6d02.tar.gz rust-15b1daaca3fd4020d7a93cff14507b9104ec6d02.zip | |
Add UI test for #100199
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/macros/auxiliary/issue-100199.rs | 18 | ||||
| -rw-r--r-- | src/test/ui/macros/issue-100199.rs | 16 | ||||
| -rw-r--r-- | src/test/ui/macros/issue-100199.stderr | 15 |
3 files changed, 49 insertions, 0 deletions
diff --git a/src/test/ui/macros/auxiliary/issue-100199.rs b/src/test/ui/macros/auxiliary/issue-100199.rs new file mode 100644 index 00000000000..9e190b542db --- /dev/null +++ b/src/test/ui/macros/auxiliary/issue-100199.rs @@ -0,0 +1,18 @@ +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] +#![feature(proc_macro_quote)] + +extern crate proc_macro; + +use proc_macro::{quote, Ident, Span, TokenStream, TokenTree}; + +#[proc_macro_attribute] +pub fn struct_with_bound(_: TokenStream, _: TokenStream) -> TokenStream { + let crate_ident = TokenTree::Ident(Ident::new("crate", Span::call_site())); + let trait_ident = TokenTree::Ident(Ident::new("MyTrait", Span::call_site())); + quote!( + struct Foo<T: $crate_ident::$trait_ident> {} + ) +} diff --git a/src/test/ui/macros/issue-100199.rs b/src/test/ui/macros/issue-100199.rs new file mode 100644 index 00000000000..6e50afa0759 --- /dev/null +++ b/src/test/ui/macros/issue-100199.rs @@ -0,0 +1,16 @@ +#[issue_100199::struct_with_bound] //~ ERROR cannot find trait `MyTrait` in the crate root +struct Foo {} +// The above must be on the first line so that it's span points to pos 0. +// This used to trigger an ICE because the diagnostic emitter would get +// an unexpected dummy span (lo == 0 == hi) while attempting to print a +// suggestion. + +// aux-build: issue-100199.rs + +extern crate issue_100199; + +mod traits { + pub trait MyTrait {} +} + +fn main() {} diff --git a/src/test/ui/macros/issue-100199.stderr b/src/test/ui/macros/issue-100199.stderr new file mode 100644 index 00000000000..2cb45dc1247 --- /dev/null +++ b/src/test/ui/macros/issue-100199.stderr @@ -0,0 +1,15 @@ +error[E0405]: cannot find trait `MyTrait` in the crate root + --> $DIR/issue-100199.rs:1:1 + | +LL | #[issue_100199::struct_with_bound] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in the crate root + | + = note: this error originates in the attribute macro `issue_100199::struct_with_bound` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider importing this trait + | +LL | use traits::MyTrait; + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0405`. |
