Skip to content

Commit 15b1daa

Browse files
committed
Add UI test for rust-lang#100199
1 parent fc83a0c commit 15b1daa

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// force-host
2+
// no-prefer-dynamic
3+
4+
#![crate_type = "proc-macro"]
5+
#![feature(proc_macro_quote)]
6+
7+
extern crate proc_macro;
8+
9+
use proc_macro::{quote, Ident, Span, TokenStream, TokenTree};
10+
11+
#[proc_macro_attribute]
12+
pub fn struct_with_bound(_: TokenStream, _: TokenStream) -> TokenStream {
13+
let crate_ident = TokenTree::Ident(Ident::new("crate", Span::call_site()));
14+
let trait_ident = TokenTree::Ident(Ident::new("MyTrait", Span::call_site()));
15+
quote!(
16+
struct Foo<T: $crate_ident::$trait_ident> {}
17+
)
18+
}

src/test/ui/macros/issue-100199.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#[issue_100199::struct_with_bound] //~ ERROR cannot find trait `MyTrait` in the crate root
2+
struct Foo {}
3+
// The above must be on the first line so that it's span points to pos 0.
4+
// This used to trigger an ICE because the diagnostic emitter would get
5+
// an unexpected dummy span (lo == 0 == hi) while attempting to print a
6+
// suggestion.
7+
8+
// aux-build: issue-100199.rs
9+
10+
extern crate issue_100199;
11+
12+
mod traits {
13+
pub trait MyTrait {}
14+
}
15+
16+
fn main() {}
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0405]: cannot find trait `MyTrait` in the crate root
2+
--> $DIR/issue-100199.rs:1:1
3+
|
4+
LL | #[issue_100199::struct_with_bound]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in the crate root
6+
|
7+
= note: this error originates in the attribute macro `issue_100199::struct_with_bound` (in Nightly builds, run with -Z macro-backtrace for more info)
8+
help: consider importing this trait
9+
|
10+
LL | use traits::MyTrait;
11+
|
12+
13+
error: aborting due to previous error
14+
15+
For more information about this error, try `rustc --explain E0405`.

0 commit comments

Comments
 (0)