-
Notifications
You must be signed in to change notification settings - Fork 12.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix diag span errors for bad_placeholder
- Loading branch information
1 parent
8fdb0a9
commit 949ee62
Showing
3 changed files
with
156 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#![allow(dead_code)] | ||
#![allow(unused_variables)] | ||
macro_rules! Tuple { | ||
{ $A:ty,$B:ty } => { ($A, $B) } | ||
} | ||
|
||
fn main() { | ||
let x: Tuple!(i32, i32) = (1, 2); | ||
} | ||
|
||
fn issue_36540() { | ||
let _ = 0; | ||
macro_rules! m { | ||
() => { | ||
_ | ||
//~^ ERROR in expressions | ||
//~| ERROR in expressions | ||
//~| ERROR the placeholder `_` is not allowed | ||
//~| ERROR the placeholder `_` is not allowed | ||
//~| ERROR the placeholder `_` is not allowed | ||
//~| ERROR the placeholder `_` is not allowed | ||
}; | ||
} | ||
struct S<T = m!()>(m!(), T) | ||
where | ||
T: Trait<m!()>; | ||
|
||
let x: m!() = m!(); | ||
std::cell::Cell::<m!()>::new(m!()); | ||
impl<T> std::ops::Index<m!()> for dyn Trait<(m!(), T)> | ||
where | ||
T: Trait<m!()>, | ||
{ | ||
type Output = m!(); | ||
fn index(&self, i: m!()) -> &m!() { | ||
unimplemented!() | ||
} | ||
} | ||
} | ||
|
||
trait Trait<T> {} | ||
impl Trait<i32> for i32 {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
error: in expressions, `_` can only be used on the left-hand side of an assignment | ||
--> $DIR/issue-116502-span-error.rs:15:13 | ||
| | ||
LL | _ | ||
| ^ `_` not allowed here | ||
... | ||
LL | let x: m!() = m!(); | ||
| ---- in this macro invocation | ||
| | ||
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: in expressions, `_` can only be used on the left-hand side of an assignment | ||
--> $DIR/issue-116502-span-error.rs:15:13 | ||
| | ||
LL | _ | ||
| ^ `_` not allowed here | ||
... | ||
LL | std::cell::Cell::<m!()>::new(m!()); | ||
| ---- in this macro invocation | ||
| | ||
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs | ||
--> $DIR/issue-116502-span-error.rs:15:13 | ||
| | ||
LL | _ | ||
| ^ | ||
| | | ||
| not allowed in type signatures | ||
| not allowed in type signatures | ||
| not allowed in type signatures | ||
... | ||
LL | struct S<T = m!()>(m!(), T) | ||
| ---------- ---- in this macro invocation | ||
| | | | ||
| | in this macro invocation | ||
| help: use type parameters instead: `<U>` | ||
LL | where | ||
LL | T: Trait<m!()>; | ||
| ---- in this macro invocation | ||
| | ||
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for implementations | ||
--> $DIR/issue-116502-span-error.rs:15:13 | ||
| | ||
LL | _ | ||
| ^ | ||
| | | ||
| not allowed in type signatures | ||
| not allowed in type signatures | ||
| not allowed in type signatures | ||
... | ||
LL | impl<T> std::ops::Index<m!()> for dyn Trait<(m!(), T)> | ||
| - ---- ---- in this macro invocation | ||
| | | | ||
| | in this macro invocation | ||
| help: use type parameters instead: `, U` | ||
LL | where | ||
LL | T: Trait<m!()>, | ||
| ---- in this macro invocation | ||
| | ||
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types | ||
--> $DIR/issue-116502-span-error.rs:15:13 | ||
| | ||
LL | _ | ||
| ^ not allowed in type signatures | ||
... | ||
LL | type Output = m!(); | ||
| ---- in this macro invocation | ||
| | ||
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions | ||
--> $DIR/issue-116502-span-error.rs:15:13 | ||
| | ||
LL | _ | ||
| ^ | ||
| | | ||
| not allowed in type signatures | ||
| not allowed in type signatures | ||
... | ||
LL | fn index(&self, i: m!()) -> &m!() { | ||
| ---- ---- in this macro invocation | ||
| | | ||
| in this macro invocation | ||
| | ||
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
help: use type parameters instead | ||
| | ||
LL ~ T | ||
LL | | ||
... | ||
LL | type Output = m!(); | ||
LL ~ fn index<T>(&self, i: m!()) -> &m!() { | ||
| | ||
help: try replacing `_` with the type in the corresponding trait method signature | ||
| | ||
LL | {type error} | ||
| | ||
|
||
error: aborting due to 6 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0121`. |