-
-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1236 from CAD97/cursor-cmp
Implement `PartialOrd` for `Cursor`
- Loading branch information
Showing
3 changed files
with
60 additions
and
4 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
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,32 @@ | ||
use proc_macro2::{Delimiter, Group}; | ||
use quote::quote; | ||
|
||
#[test] | ||
fn main() { | ||
// Okay. Rustc allows top-level `static` with no value syntactically, but | ||
// not semantically. Syn parses as Item::Verbatim. | ||
let tokens = quote!( | ||
pub static FOO: usize; | ||
pub static BAR: usize; | ||
); | ||
let file = syn::parse2::<syn::File>(tokens).unwrap(); | ||
println!("{:#?}", file); | ||
|
||
// Okay. | ||
let inner = Group::new( | ||
Delimiter::None, | ||
quote!(static FOO: usize = 0; pub static BAR: usize = 0), | ||
); | ||
let tokens = quote!(pub #inner;); | ||
let file = syn::parse2::<syn::File>(tokens).unwrap(); | ||
println!("{:#?}", file); | ||
|
||
// Parser crash. | ||
let inner = Group::new( | ||
Delimiter::None, | ||
quote!(static FOO: usize; pub static BAR: usize), | ||
); | ||
let tokens = quote!(pub #inner;); | ||
let file = syn::parse2::<syn::File>(tokens).unwrap(); | ||
println!("{:#?}", file); | ||
} |