-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #55971 - SergioBenitez:skip-non-semantic, r=alexcrichton
Ignore non-semantic tokens for 'probably_eq' streams. Improves the situation in #43081 by skipping typically non-semantic tokens when checking for 'probably_eq'. r? @alexcrichton
- Loading branch information
Showing
5 changed files
with
141 additions
and
6 deletions.
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
12 changes: 12 additions & 0 deletions
12
src/test/ui-fulldeps/proc-macro/auxiliary/span-preservation.rs
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,12 @@ | ||
// no-prefer-dynamic | ||
|
||
#![crate_type = "proc-macro"] | ||
|
||
extern crate proc_macro; | ||
|
||
use proc_macro::TokenStream; | ||
|
||
#[proc_macro_attribute] | ||
pub fn foo(_: TokenStream, input: TokenStream) -> TokenStream { | ||
input.into_iter().collect() | ||
} |
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,51 @@ | ||
// aux-build:span-preservation.rs | ||
|
||
// For each of these, we should get the appropriate type mismatch error message, | ||
// and the function should be echoed. | ||
|
||
extern crate span_preservation as foo; | ||
|
||
use foo::foo; | ||
|
||
#[foo] | ||
fn a() { | ||
let x: usize = "hello";;;;; | ||
} | ||
|
||
#[foo] | ||
fn b(x: Option<isize>) -> usize { | ||
match x { | ||
Some(x) => { return x }, | ||
None => 10 | ||
} | ||
} | ||
|
||
#[foo] | ||
fn c() { | ||
struct Foo { | ||
a: usize | ||
} | ||
|
||
struct Bar { | ||
a: usize, | ||
b: usize | ||
} | ||
|
||
let x = Foo { a: 10isize }; | ||
let y = Foo { a: 10, b: 10isize }; | ||
} | ||
|
||
// FIXME: This doesn't work at the moment. See the one below. The pretty-printer | ||
// injects a "C" between `extern` and `fn` which causes a "probably_eq" | ||
// `TokenStream` mismatch. The lack of `"C"` should be preserved in the AST. | ||
#[foo] | ||
extern fn bar() { | ||
0 | ||
} | ||
|
||
#[foo] | ||
extern "C" fn baz() { | ||
0 | ||
} | ||
|
||
fn main() {} |
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,49 @@ | ||
error[E0308]: mismatched types | ||
| | ||
= note: expected type `()` | ||
found type `{integer}` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/span-preservation.rs:12:20 | ||
| | ||
LL | let x: usize = "hello";;;;; | ||
| ^^^^^^^ expected usize, found reference | ||
| | ||
= note: expected type `usize` | ||
found type `&'static str` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/span-preservation.rs:18:29 | ||
| | ||
LL | Some(x) => { return x }, | ||
| ^ expected usize, found isize | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/span-preservation.rs:34:22 | ||
| | ||
LL | let x = Foo { a: 10isize }; | ||
| ^^^^^^^ expected usize, found isize | ||
|
||
error[E0560]: struct `c::Foo` has no field named `b` | ||
--> $DIR/span-preservation.rs:35:26 | ||
| | ||
LL | let y = Foo { a: 10, b: 10isize }; | ||
| ^ `c::Foo` does not have this field | ||
| | ||
= note: available fields are: `a` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/span-preservation.rs:48:5 | ||
| | ||
LL | extern "C" fn baz() { | ||
| - possibly return type missing here? | ||
LL | 0 | ||
| ^ expected (), found integral variable | ||
| | ||
= note: expected type `()` | ||
found type `{integer}` | ||
|
||
error: aborting due to 6 previous errors | ||
|
||
Some errors occurred: E0308, E0560. | ||
For more information about an error, try `rustc --explain E0308`. |