Rollup merge of #72306 - Aaron1011:feature/turbo-spacing, r=petrochenkov
Break tokens before checking if they are 'probably equal' Fixes #68489 Fixes #70987 When checking two `TokenStreams` to see if they are 'probably equal', we ignore the `IsJoint` information associated with each `TokenTree`. However, the `IsJoint` information determines whether adjacent tokens will be 'glued' (if possible) when construction the `TokenStream` - e.g. `[Gt Gt]` can be 'glued' to `BinOp(Shr)`. Since we are ignoring the `IsJoint` information, 'glued' and 'unglued' tokens are equivalent for determining if two `TokenStreams` are 'probably equal'. Therefore, we need to 'unglue' all tokens in the stream to avoid false negatives (which cause us to throw out the cached tokens, losing span information).
This commit is contained in:
commit
62d4e9eedd
5 changed files with 113 additions and 4 deletions
16
src/test/ui/proc-macro/break-token-spans.rs
Normal file
16
src/test/ui/proc-macro/break-token-spans.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// aux-build:test-macros.rs
|
||||
// Regression test for issues #68489 and #70987
|
||||
// Tests that we properly break tokens in `probably_equal_for_proc_macro`
|
||||
// See #72306
|
||||
//
|
||||
// Note that the weird spacing in this example is critical
|
||||
// for testing the issue.
|
||||
|
||||
extern crate test_macros;
|
||||
|
||||
#[test_macros::recollect_attr]
|
||||
fn repro() {
|
||||
f :: < Vec < _ > > ( ) ; //~ ERROR cannot find
|
||||
let a: Option<Option<u8>>= true; //~ ERROR mismatched
|
||||
}
|
||||
fn main() {}
|
||||
21
src/test/ui/proc-macro/break-token-spans.stderr
Normal file
21
src/test/ui/proc-macro/break-token-spans.stderr
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
error[E0425]: cannot find function `f` in this scope
|
||||
--> $DIR/break-token-spans.rs:13:5
|
||||
|
|
||||
LL | f :: < Vec < _ > > ( ) ;
|
||||
| ^ not found in this scope
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/break-token-spans.rs:14:32
|
||||
|
|
||||
LL | let a: Option<Option<u8>>= true;
|
||||
| ------------------ ^^^^ expected enum `std::option::Option`, found `bool`
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected enum `std::option::Option<std::option::Option<u8>>`
|
||||
found type `bool`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0308, E0425.
|
||||
For more information about an error, try `rustc --explain E0308`.
|
||||
|
|
@ -16,6 +16,7 @@ pub struct Qux<T>(T);
|
|||
|
||||
#[dom_struct]
|
||||
pub struct Foo {
|
||||
//~^ ERROR trait objects without an explicit `dyn` are deprecated [bare_trait_objects]
|
||||
qux: Qux<Qux<Baz>>,
|
||||
bar: Box<Bar>,
|
||||
//~^ ERROR trait objects without an explicit `dyn` are deprecated [bare_trait_objects]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: trait objects without an explicit `dyn` are deprecated
|
||||
--> $DIR/issue-61963.rs:20:14
|
||||
--> $DIR/issue-61963.rs:21:14
|
||||
|
|
||||
LL | bar: Box<Bar>,
|
||||
| ^^^ help: use `dyn`: `dyn Bar`
|
||||
|
|
@ -10,5 +10,11 @@ note: the lint level is defined here
|
|||
LL | #![deny(bare_trait_objects)]
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
error: trait objects without an explicit `dyn` are deprecated
|
||||
--> $DIR/issue-61963.rs:18:1
|
||||
|
|
||||
LL | pub struct Foo {
|
||||
| ^^^ help: use `dyn`: `dyn pub`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue