Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpratt committed Jun 20, 2023
1 parent a1cd8c3 commit 8dc3b85
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 24 deletions.
5 changes: 0 additions & 5 deletions tests/ui/macros/auxiliary/proc_macro_sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ extern crate proc_macro;

use proc_macro::{quote, Span, TokenStream, TokenTree};

fn assert_same_span(a: Span, b: Span) {
assert_eq!(a.start(), b.start());
assert_eq!(a.end(), b.end());
}

// This macro generates a macro with the same macro definition as `manual_foo` in
// `same-sequence-span.rs` but with the same span for all sequences.
#[proc_macro]
Expand Down
7 changes: 3 additions & 4 deletions tests/ui/macros/same-sequence-span.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ LL | $(= $z:tt)*
error: `$x:expr` may be followed by `$y:tt`, which is not allowed for `expr` fragments
--> $DIR/same-sequence-span.rs:19:1
|
LL | | }
| |_________________________________^ not allowed after `expr` fragments
LL |
LL | proc_macro_sequence::make_foo!();
| ^-------------------------------
| |
| _in this macro invocation
| |
LL | |
LL | |
LL | | fn main() {}
| |_________________________________^ not allowed after `expr` fragments
|
= note: allowed there are: `=>`, `,` or `;`
= note: this error originates in the macro `proc_macro_sequence::make_foo` (in Nightly builds, run with -Z macro-backtrace for more info)
Expand Down
11 changes: 1 addition & 10 deletions tests/ui/proc-macro/auxiliary/api/cmp.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
use proc_macro::{LineColumn, Punct, Spacing};
use proc_macro::{Punct, Spacing};

pub fn test() {
test_line_column_ord();
test_punct_eq();
}

fn test_line_column_ord() {
let line0_column0 = LineColumn { line: 0, column: 0 };
let line0_column1 = LineColumn { line: 0, column: 1 };
let line1_column0 = LineColumn { line: 1, column: 0 };
assert!(line0_column0 < line0_column1);
assert!(line0_column1 < line1_column0);
}

fn test_punct_eq() {
let colon_alone = Punct::new(':', Spacing::Alone);
assert_eq!(colon_alone, ':');
Expand Down
5 changes: 2 additions & 3 deletions tests/ui/proc-macro/auxiliary/assert-span-pos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ pub fn assert_span_pos(input: TokenStream) -> TokenStream {
let line: usize = str1.parse().unwrap();
let col: usize = str2.parse().unwrap();

let sp1s = sp1.start();
if (line, col) != (sp1s.line, sp1s.column) {
if (line, col) != (sp1.line(), sp1.column()) {
let msg = format!("line/column mismatch: ({}, {}) != ({}, {})", line, col,
sp1s.line, sp1s.column);
sp1.line(), sp1.column());
sp1.error(msg).emit();
}

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/proc-macro/auxiliary/macro-only-syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// lossy string reparse hack (https://github.com/rust-lang/rust/issues/43081).

#![crate_type = "proc-macro"]
#![feature(proc_macro_span)]
#![feature(proc_macro_span, proc_macro_span_shrink)]

extern crate proc_macro;
use proc_macro::{token_stream, Delimiter, TokenStream, TokenTree};
Expand Down Expand Up @@ -81,7 +81,7 @@ fn expect_brace(tokens: &mut token_stream::IntoIter) -> token_stream::IntoIter {

fn check_useful_span(token: TokenTree, expected_filename: &str) {
let span = token.span();
assert!(span.start().column < span.end().column);
assert!(span.column() < span.end().column());

let source_path = span.source_file().path();
let filename = source_path.components().last().unwrap();
Expand Down

0 comments on commit 8dc3b85

Please sign in to comment.