diff options
| author | bors <bors@rust-lang.org> | 2022-04-28 19:32:59 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-04-28 19:32:59 +0000 |
| commit | e85edd9a844b523a02dbd89f3c02cd13e4c9fe46 (patch) | |
| tree | 57b0e75d05f02f65722446e3cbf1f27439eab9aa /src | |
| parent | 1388b38c52d1ca9fbc80bf42fa007504fb0b1b41 (diff) | |
| parent | 2c1d58b8cc5c9638a85ee3033602bf2c9d1a35db (diff) | |
| download | rust-e85edd9a844b523a02dbd89f3c02cd13e4c9fe46.tar.gz rust-e85edd9a844b523a02dbd89f3c02cd13e4c9fe46.zip | |
Auto merge of #96528 - Dylan-DPC:rollup-iedbjli, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - #95312 (Ensure that `'_` and GAT yields errors) - #96405 (Migrate ambiguous plus diagnostic to the new derive macro) - #96409 (Recover suggestions to introduce named lifetime under NLL) - #96433 (rustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter`) - #96480 (Fixed grammatical error in example comment) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src')
26 files changed, 320 insertions, 58 deletions
diff --git a/src/librustdoc/clean/render_macro_matchers.rs b/src/librustdoc/clean/render_macro_matchers.rs index 58ca8869ea9..a9c0fe6f079 100644 --- a/src/librustdoc/clean/render_macro_matchers.rs +++ b/src/librustdoc/clean/render_macro_matchers.rs @@ -1,4 +1,4 @@ -use rustc_ast::token::{self, BinOpToken, DelimToken}; +use rustc_ast::token::{self, BinOpToken, Delimiter}; use rustc_ast::tokenstream::{TokenStream, TokenTree}; use rustc_ast_pretty::pprust::state::State as Printer; use rustc_ast_pretty::pprust::PrintState; @@ -104,11 +104,11 @@ fn print_tt(printer: &mut Printer<'_>, tt: &TokenTree) { let open_delim = printer.token_kind_to_string(&token::OpenDelim(*delim)); printer.word(open_delim); if !tts.is_empty() { - if *delim == DelimToken::Brace { + if *delim == Delimiter::Brace { printer.space(); } print_tts(printer, tts); - if *delim == DelimToken::Brace { + if *delim == Delimiter::Brace { printer.space(); } } @@ -162,9 +162,9 @@ fn print_tts(printer: &mut Printer<'_>, tts: &TokenStream) { (_, _) => (true, Other), }, TokenTree::Delimited(_, delim, _) => match (state, delim) { - (Dollar, DelimToken::Paren) => (false, DollarParen), - (Pound | PoundBang, DelimToken::Bracket) => (false, Other), - (Ident, DelimToken::Paren | DelimToken::Bracket) => (false, Other), + (Dollar, Delimiter::Parenthesis) => (false, DollarParen), + (Pound | PoundBang, Delimiter::Bracket) => (false, Other), + (Ident, Delimiter::Parenthesis | Delimiter::Bracket) => (false, Other), (_, _) => (true, Other), }, }; diff --git a/src/test/ui/generic-associated-types/issue-95305.rs b/src/test/ui/generic-associated-types/issue-95305.rs new file mode 100644 index 00000000000..9ead347984b --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-95305.rs @@ -0,0 +1,17 @@ +// It's not yet clear how '_ and GATs should interact. +// Forbid it for now but proper support might be added +// at some point in the future. + +#![feature(generic_associated_types)] + +trait Foo { + type Item<'a>; +} + +fn foo(x: &impl Foo<Item<'_> = u32>) { } + //~^ ERROR missing lifetime specifier + +fn bar(x: &impl for<'a> Foo<Item<'a> = &'_ u32>) { } + //~^ ERROR missing lifetime specifier + +fn main() {} diff --git a/src/test/ui/generic-associated-types/issue-95305.stderr b/src/test/ui/generic-associated-types/issue-95305.stderr new file mode 100644 index 00000000000..2b48378dc43 --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-95305.stderr @@ -0,0 +1,25 @@ +error[E0106]: missing lifetime specifier + --> $DIR/issue-95305.rs:11:26 + | +LL | fn foo(x: &impl Foo<Item<'_> = u32>) { } + | ^^ expected named lifetime parameter + | +help: consider introducing a named lifetime parameter + | +LL | fn foo<'a>(x: &impl Foo<Item<'a> = u32>) { } + | ++++ ~~ + +error[E0106]: missing lifetime specifier + --> $DIR/issue-95305.rs:14:41 + | +LL | fn bar(x: &impl for<'a> Foo<Item<'a> = &'_ u32>) { } + | ^^ expected named lifetime parameter + | +help: consider using the `'a` lifetime + | +LL | fn bar(x: &impl for<'a> Foo<Item<'a> = &'a u32>) { } + | ~~ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/lifetimes/issue-90170-elision-mismatch.nll.stderr b/src/test/ui/lifetimes/issue-90170-elision-mismatch.nll.stderr index a5bc7450bbf..48fb3fb4a22 100644 --- a/src/test/ui/lifetimes/issue-90170-elision-mismatch.nll.stderr +++ b/src/test/ui/lifetimes/issue-90170-elision-mismatch.nll.stderr @@ -6,6 +6,11 @@ LL | pub fn foo(x: &mut Vec<&u8>, y: &u8) { x.push(y); } | | | | | let's call the lifetime of this reference `'1` | let's call the lifetime of this reference `'2` + | +help: consider introducing a named lifetime parameter + | +LL | pub fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/issue-90170-elision-mismatch.rs:5:44 @@ -15,6 +20,11 @@ LL | pub fn foo2(x: &mut Vec<&'_ u8>, y: &u8) { x.push(y); } | | | | | let's call the lifetime of this reference `'1` | let's call the lifetime of this reference `'2` + | +help: consider introducing a named lifetime parameter + | +LL | pub fn foo2<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } + | ++++ ~~ ++ error: lifetime may not live long enough --> $DIR/issue-90170-elision-mismatch.rs:7:63 @@ -24,6 +34,11 @@ LL | pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&u8>, y: &u8) { x.push(y); } | | | | | let's call the lifetime of this reference `'1` | let's call the lifetime of this reference `'2` + | +help: consider introducing a named lifetime parameter + | +LL | pub fn foo3<'a>(_other: &'a [u8], x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } + | ++ ++ error: aborting due to 3 previous errors diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.nll.stderr index a94f9a79906..5a23f1e0e9d 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.nll.stderr @@ -7,6 +7,11 @@ LL | fn foo(&mut (ref mut v, w): &mut (&u8, &u8), x: &u8) { | let's call the lifetime of this reference `'2` LL | *v = x; | ^^^^^^ assignment requires that `'1` must outlive `'2` + | +help: consider introducing a named lifetime parameter + | +LL | fn foo<'a>(&mut (ref mut v, w): &mut (&'a u8, &u8), x: &'a u8) { + | ++++ ++ ++ error: aborting due to previous error diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.nll.stderr index 2ed4d6d4401..6ba130308a3 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.nll.stderr @@ -7,6 +7,11 @@ LL | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) { | let's call the lifetime of this reference `'2` LL | z.push((x,y)); | ^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2` + | +help: consider introducing a named lifetime parameter + | +LL | fn foo<'a>(z: &mut Vec<(&'a u8,&u8)>, (x, y): (&'a u8, &u8)) { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ex3-both-anon-regions-3.rs:2:5 @@ -17,6 +22,11 @@ LL | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) { | let's call the lifetime of this reference `'4` LL | z.push((x,y)); | ^^^^^^^^^^^^^ argument requires that `'3` must outlive `'4` + | +help: consider introducing a named lifetime parameter + | +LL | fn foo<'a>(z: &mut Vec<(&u8,&'a u8)>, (x, y): (&u8, &'a u8)) { + | ++++ ++ ++ error: aborting due to 2 previous errors diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.nll.stderr index 1a19e81f235..5601335d275 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.nll.stderr @@ -7,6 +7,11 @@ LL | fn foo<'a>(&self, x: &i32) -> &i32 { | let's call the lifetime of this reference `'2` LL | x | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn foo<'a>(&'a self, x: &'a i32) -> &i32 { + | ++ ++ error: aborting due to previous error diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.nll.stderr index 87b13dc1591..e221902c4a9 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.nll.stderr @@ -7,6 +7,11 @@ LL | fn foo<'a>(&self, x: &Foo) -> &Foo { | let's call the lifetime of this reference `'2` LL | if true { x } else { self } | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn foo<'a>(&'a self, x: &'a Foo) -> &Foo { + | ++ ++ error: aborting due to previous error diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.nll.stderr index 825c45b2434..a909c5fa823 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.nll.stderr @@ -7,6 +7,11 @@ LL | fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) { | let's call the lifetime of this reference `'2` LL | y.push(z); | ^^^^^^^^^ argument requires that `'1` must outlive `'2` + | +help: consider introducing a named lifetime parameter + | +LL | fn foo<'a>(x:fn(&u8, &u8), y: Vec<&'a u8>, z: &'a u8) { + | ++++ ++ ++ error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable --> $DIR/ex3-both-anon-regions-using-fn-items.rs:2:3 diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.nll.stderr index f3502674849..9661f1e5144 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.nll.stderr @@ -7,6 +7,11 @@ LL | fn foo(x: &mut Vec<&u8>, y: &u8) { | let's call the lifetime of this reference `'2` LL | x.push(y); | ^^^^^^^^^ argument requires that `'1` must outlive `'2` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { + | ++++ ++ ++ error: aborting due to previous error diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr index 78a828dde86..cce0a31bfbb 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr @@ -7,6 +7,11 @@ LL | fn foo(x:Box<dyn Fn(&u8, &u8)> , y: Vec<&u8>, z: &u8) { | let's call the lifetime of this reference `'2` LL | y.push(z); | ^^^^^^^^^ argument requires that `'1` must outlive `'2` + | +help: consider introducing a named lifetime parameter + | +LL | fn foo<'a>(x:Box<dyn Fn(&'a u8, &'a u8)> , y: Vec<&u8>, z: &u8) { + | ++++ ++ ++ error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:2:3 diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.nll.stderr index 6989acfa196..ec9fac0c288 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.nll.stderr @@ -7,6 +7,11 @@ LL | fn foo(x: &mut Vec<&u8>, y: &u8) { | let's call the lifetime of this reference `'2` LL | x.push(y); | ^^^^^^^^^ argument requires that `'1` must outlive `'2` + | +help: consider introducing a named lifetime parameter + | +LL | fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { + | ++++ ++ ++ error: aborting due to previous error diff --git a/src/test/ui/proc-macro/nodelim-groups.rs b/src/test/ui/proc-macro/nodelim-groups.rs index db2a879f405..ec301990281 100644 --- a/src/test/ui/proc-macro/nodelim-groups.rs +++ b/src/test/ui/proc-macro/nodelim-groups.rs @@ -3,7 +3,7 @@ // compile-flags: -Z span-debug // edition:2018 // -// Tests the pretty-printing behavior of inserting `NoDelim` groups +// Tests the pretty-printing behavior of inserting `Invisible`-delimited groups #![no_std] // Don't load unnecessary hygiene information from std extern crate std; diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch.nll.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch.nll.stderr index b06ebf70477..057146e7cb0 100644 --- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch.nll.stderr +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch.nll.stderr @@ -6,6 +6,11 @@ LL | fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } | | | | | let's call the lifetime of this reference `'1` | let's call the lifetime of this reference `'2` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn a<'a>(self: Pin<&'a Foo>, f: &'a Foo) -> &Foo { f } + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:14:69 @@ -15,6 +20,11 @@ LL | fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, | | | | | let's call the lifetime of this reference `'1` | let's call the lifetime of this reference `'2` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn c<'a>(self: Pin<&'a Self>, f: &'a Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:21:58 diff --git a/src/test/ui/self/elision/lt-ref-self.nll.stderr b/src/test/ui/self/elision/lt-ref-self.nll.stderr index 1934207527b..2e26c703b65 100644 --- a/src/test/ui/self/elision/lt-ref-self.nll.stderr +++ b/src/test/ui/self/elision/lt-ref-self.nll.stderr @@ -7,6 +7,11 @@ LL | fn ref_self(&self, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn ref_self<'a>(&'a self, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/lt-ref-self.rs:23:9 @@ -17,6 +22,11 @@ LL | fn ref_Self(self: &Self, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn ref_Self<'a>(self: &'a Self, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/lt-ref-self.rs:29:9 @@ -27,6 +37,11 @@ LL | fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_ref_Self<'a>(self: Box<&'a Self>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/lt-ref-self.rs:35:9 @@ -37,6 +52,11 @@ LL | fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn pin_ref_Self<'a>(self: Pin<&'a Self>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/lt-ref-self.rs:41:9 @@ -47,6 +67,11 @@ LL | fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_box_ref_Self<'a>(self: Box<Box<&'a Self>>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/lt-ref-self.rs:47:9 @@ -57,6 +82,11 @@ LL | fn box_pin_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_pin_Self<'a>(self: Box<Pin<&'a Self>>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: aborting due to 6 previous errors diff --git a/src/test/ui/self/elision/ref-mut-self.nll.stderr b/src/test/ui/self/elision/ref-mut-self.nll.stderr index f1f4d341b2b..fd4ecae3cfe 100644 --- a/src/test/ui/self/elision/ref-mut-self.nll.stderr +++ b/src/test/ui/self/elision/ref-mut-self.nll.stderr @@ -7,6 +7,11 @@ LL | fn ref_self(&mut self, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn ref_self<'a>(&'a mut self, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-self.rs:23:9 @@ -17,6 +22,11 @@ LL | fn ref_Self(self: &mut Self, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn ref_Self<'a>(self: &'a mut Self, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-self.rs:29:9 @@ -27,6 +37,11 @@ LL | fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_ref_Self<'a>(self: Box<&'a mut Self>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-self.rs:35:9 @@ -37,6 +52,11 @@ LL | fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn pin_ref_Self<'a>(self: Pin<&'a mut Self>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-self.rs:41:9 @@ -47,6 +67,11 @@ LL | fn box_box_ref_Self(self: Box<Box<&mut Self>>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_box_ref_Self<'a>(self: Box<Box<&'a mut Self>>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-self.rs:47:9 @@ -57,6 +82,11 @@ LL | fn box_pin_ref_Self(self: Box<Pin<&mut Self>>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_pin_ref_Self<'a>(self: Box<Pin<&'a mut Self>>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: aborting due to 6 previous errors diff --git a/src/test/ui/self/elision/ref-mut-struct.nll.stderr b/src/test/ui/self/elision/ref-mut-struct.nll.stderr index de7eb02d7a7..ede790c0611 100644 --- a/src/test/ui/self/elision/ref-mut-struct.nll.stderr +++ b/src/test/ui/self/elision/ref-mut-struct.nll.stderr @@ -7,6 +7,11 @@ LL | fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn ref_Struct<'a>(self: &'a mut Struct, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-struct.rs:21:9 @@ -17,6 +22,11 @@ LL | fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_ref_Struct<'a>(self: Box<&'a mut Struct>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-struct.rs:27:9 @@ -27,6 +37,11 @@ LL | fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn pin_ref_Struct<'a>(self: Pin<&'a mut Struct>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-struct.rs:33:9 @@ -37,6 +52,11 @@ LL | fn box_box_ref_Struct(self: Box<Box<&mut Struct>>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_box_ref_Struct<'a>(self: Box<Box<&'a mut Struct>>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-mut-struct.rs:39:9 @@ -47,6 +67,11 @@ LL | fn box_pin_ref_Struct(self: Box<Pin<&mut Struct>>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_pin_ref_Struct<'a>(self: Box<Pin<&'a mut Struct>>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: aborting due to 5 previous errors diff --git a/src/test/ui/self/elision/ref-self.nll.stderr b/src/test/ui/self/elision/ref-self.nll.stderr index f2b7b0ad019..c0efc35fa6c 100644 --- a/src/test/ui/self/elision/ref-self.nll.stderr +++ b/src/test/ui/self/elision/ref-self.nll.stderr @@ -7,6 +7,11 @@ LL | fn ref_self(&self, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn ref_self<'a>(&'a self, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self.rs:33:9 @@ -17,6 +22,11 @@ LL | fn ref_Self(self: &Self, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn ref_Self<'a>(self: &'a Self, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self.rs:39:9 @@ -27,6 +37,11 @@ LL | fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_ref_Self<'a>(self: Box<&'a Self>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self.rs:45:9 @@ -37,6 +52,11 @@ LL | fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn pin_ref_Self<'a>(self: Pin<&'a Self>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self.rs:51:9 @@ -47,6 +67,11 @@ LL | fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_box_ref_Self<'a>(self: Box<Box<&'a Self>>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self.rs:57:9 @@ -57,6 +82,11 @@ LL | fn box_pin_ref_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_pin_ref_Self<'a>(self: Box<Pin<&'a Self>>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-self.rs:63:9 @@ -67,6 +97,11 @@ LL | fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn wrap_ref_Self_Self<'a>(self: Wrap<&'a Self, Self>, f: &'a u8) -> &u8 { + | ++++ ++ ++ error: aborting due to 7 previous errors diff --git a/src/test/ui/self/elision/ref-struct.nll.stderr b/src/test/ui/self/elision/ref-struct.nll.stderr index 70453b0ddfc..226923f59ff 100644 --- a/src/test/ui/self/elision/ref-struct.nll.stderr +++ b/src/test/ui/self/elision/ref-struct.nll.stderr @@ -7,6 +7,11 @@ LL | fn ref_Struct(self: &Struct, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn ref_Struct<'a>(self: &'a Struct, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-struct.rs:21:9 @@ -17,6 +22,11 @@ LL | fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_ref_Struct<'a>(self: Box<&'a Struct>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-struct.rs:27:9 @@ -27,6 +37,11 @@ LL | fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn pin_ref_Struct<'a>(self: Pin<&'a Struct>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-struct.rs:33:9 @@ -37,6 +52,11 @@ LL | fn box_box_ref_Struct(self: Box<Box<&Struct>>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_box_ref_Struct<'a>(self: Box<Box<&'a Struct>>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: lifetime may not live long enough --> $DIR/ref-struct.rs:39:9 @@ -47,6 +67,11 @@ LL | fn box_pin_Struct(self: Box<Pin<&Struct>>, f: &u32) -> &u32 { | let's call the lifetime of this reference `'2` LL | f | ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` + | +help: consider introducing a named lifetime parameter and update trait if needed + | +LL | fn box_pin_Struct<'a>(self: Box<Pin<&'a Struct>>, f: &'a u32) -> &u32 { + | ++++ ++ ++ error: aborting due to 5 previous errors diff --git a/src/test/ui/underscore-lifetime/underscore-lifetime-elison-mismatch.nll.stderr b/src/test/ui/underscore-lifetime/underscore-lifetime-elison-mismatch.nll.stderr index 8e10242cb13..a4dece320ec 100644 --- a/src/test/ui/underscore-lifetime/underscore-lifetime-elison-mismatch.nll.stderr +++ b/src/test/ui/underscore-lifetime/underscore-lifetime-elison-mismatch.nll.stderr @@ -6,6 +6,11 @@ LL | fn foo(x: &mut Vec<&'_ u8>, y: &'_ u8) { x.push(y); } | | | | | let's call the lifetime of this reference `'1` | let's call the lifetime of this reference `'2` + | +help: consider introducing a named lifetime parameter + | +LL | fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8) { x.push(y); } + | ++++ ~~ ~~ error: aborting due to previous error diff --git a/src/tools/rustfmt/src/expr.rs b/src/tools/rustfmt/src/expr.rs index cd724373f4d..741f3350801 100644 --- a/src/tools/rustfmt/src/expr.rs +++ b/src/tools/rustfmt/src/expr.rs @@ -2,7 +2,7 @@ use std::borrow::Cow; use std::cmp::min; use itertools::Itertools; -use rustc_ast::token::{DelimToken, LitKind}; +use rustc_ast::token::{Delimiter, LitKind}; use rustc_ast::{ast, ptr}; use rustc_span::{BytePos, Span}; @@ -412,7 +412,7 @@ pub(crate) fn rewrite_array<'a, T: 'a + IntoOverflowableItem<'a>>( context: &'a RewriteContext<'_>, shape: Shape, force_separator_tactic: Option<SeparatorTactic>, - delim_token: Option<DelimToken>, + delim_token: Option<Delimiter>, ) -> Option<String> { overflow::rewrite_with_square_brackets( context, diff --git a/src/tools/rustfmt/src/macros.rs b/src/tools/rustfmt/src/macros.rs index 92606902c57..26c429eb94f 100644 --- a/src/tools/rustfmt/src/macros.rs +++ b/src/tools/rustfmt/src/macros.rs @@ -12,7 +12,7 @@ use std::collections::HashMap; use std::panic::{catch_unwind, AssertUnwindSafe}; -use rustc_ast::token::{BinOpToken, DelimToken, Token, TokenKind}; +use rustc_ast::token::{BinOpToken, Delimiter, Token, TokenKind}; use rustc_ast::tokenstream::{Cursor, Spacing, TokenStream, TokenTree}; use rustc_ast::{ast, ptr}; use rustc_ast_pretty::pprust; @@ -203,7 +203,7 @@ fn rewrite_macro_inner( let is_forced_bracket = FORCED_BRACKET_MACROS.contains(&¯o_name[..]); let style = if is_forced_bracket && !is_nested_macro { - DelimToken::Bracket + Delimiter::Bracket } else { original_style }; @@ -212,15 +212,15 @@ fn rewrite_macro_inner( let has_comment = contains_comment(context.snippet(mac.span())); if ts.is_empty() && !has_comment { return match style { - DelimToken::Paren if position == MacroPosition::Item => { + Delimiter::Parenthesis if position == MacroPosition::Item => { Some(format!("{}();", macro_name)) } - DelimToken::Bracket if position == MacroPosition::Item => { + Delimiter::Bracket if position == MacroPosition::Item => { Some(format!("{}[];", macro_name)) } - DelimToken::Paren => Some(format!("{}()", macro_name)), - DelimToken::Bracket => Some(format!("{}[]", macro_name)), - DelimToken::Brace => Some(format!("{} {{}}", macro_name)), + Delimiter::Parenthesis => Some(format!("{}()", macro_name)), + Delimiter::Bracket => Some(format!("{}[]", macro_name)), + Delimiter::Brace => Some(format!("{} {{}}", macro_name)), _ => unreachable!(), }; } @@ -260,7 +260,7 @@ fn rewrite_macro_inner( } match style { - DelimToken::Paren => { + Delimiter::Parenthesis => { // Handle special case: `vec!(expr; expr)` if vec_with_semi { handle_vec_semi(context, shape, arg_vec, macro_name, style) @@ -286,7 +286,7 @@ fn rewrite_macro_inner( }) } } - DelimToken::Bracket => { + Delimiter::Bracket => { // Handle special case: `vec![expr; expr]` if vec_with_semi { handle_vec_semi(context, shape, arg_vec, macro_name, style) @@ -323,7 +323,7 @@ fn rewrite_macro_inner( Some(format!("{}{}", rewrite, comma)) } } - DelimToken::Brace => { + Delimiter::Brace => { // For macro invocations with braces, always put a space between // the `macro_name!` and `{ /* macro_body */ }` but skip modifying // anything in between the braces (for now). @@ -342,11 +342,11 @@ fn handle_vec_semi( shape: Shape, arg_vec: Vec<MacroArg>, macro_name: String, - delim_token: DelimToken, + delim_token: Delimiter, ) -> Option<String> { let (left, right) = match delim_token { - DelimToken::Paren => ("(", ")"), - DelimToken::Bracket => ("[", "]"), + Delimiter::Parenthesis => ("(", ")"), + Delimiter::Bracket => ("[", "]"), _ => unreachable!(), }; @@ -528,7 +528,7 @@ enum MacroArgKind { /// e.g., `$($foo: expr),*` Repeat( /// `()`, `[]` or `{}`. - DelimToken, + Delimiter, /// Inner arguments inside delimiters. Vec<ParsedMacroArg>, /// Something after the closing delimiter and the repeat token, if available. @@ -537,7 +537,7 @@ enum MacroArgKind { Token, ), /// e.g., `[derive(Debug)]` - Delimited(DelimToken, Vec<ParsedMacroArg>), + Delimited(Delimiter, Vec<ParsedMacroArg>), /// A possible separator. e.g., `,` or `;`. Separator(String, String), /// Other random stuff that does not fit to other kinds. @@ -547,22 +547,22 @@ enum MacroArgKind { fn delim_token_to_str( context: &RewriteContext<'_>, - delim_token: DelimToken, + delim_token: Delimiter, shape: Shape, use_multiple_lines: bool, inner_is_empty: bool, ) -> (String, String) { let (lhs, rhs) = match delim_token { - DelimToken::Paren => ("(", ")"), - DelimToken::Bracket => ("[", "]"), - DelimToken::Brace => { + Delimiter::Parenthesis => ("(", ")"), + Delimiter::Bracket => ("[", "]"), + Delimiter::Brace => { if inner_is_empty || use_multiple_lines { ("{", "}") } else { ("{ ", " }") } } - DelimToken::NoDelim => unreachable!(), + Delimiter::Invisible => unreachable!(), }; if use_multiple_lines { let indent_str = shape.indent.to_string_with_newline(context.config); @@ -583,8 +583,8 @@ impl MacroArgKind { fn starts_with_brace(&self) -> bool { matches!( *self, - MacroArgKind::Repeat(DelimToken::Brace, _, _, _) - | MacroArgKind::Delimited(DelimToken::Brace, _) + MacroArgKind::Repeat(Delimiter::Brace, _, _, _) + | MacroArgKind::Delimited(Delimiter::Brace, _) ) } @@ -753,7 +753,7 @@ impl MacroArgParser { } } - fn add_delimited(&mut self, inner: Vec<ParsedMacroArg>, delim: DelimToken) { + fn add_delimited(&mut self, inner: Vec<ParsedMacroArg>, delim: Delimiter) { self.result.push(ParsedMacroArg { kind: MacroArgKind::Delimited(delim, inner), }); @@ -763,7 +763,7 @@ impl MacroArgParser { fn add_repeat( &mut self, inner: Vec<ParsedMacroArg>, - delim: DelimToken, + delim: Delimiter, iter: &mut Cursor, ) -> Option<()> { let mut buffer = String::new(); @@ -1083,18 +1083,18 @@ pub(crate) fn convert_try_mac( } } -pub(crate) fn macro_style(mac: &ast::MacCall, context: &RewriteContext<'_>) -> DelimToken { +pub(crate) fn macro_style(mac: &ast::MacCall, context: &RewriteContext<'_>) -> Delimiter { let snippet = context.snippet(mac.span()); let paren_pos = snippet.find_uncommented("(").unwrap_or(usize::max_value()); let bracket_pos = snippet.find_uncommented("[").unwrap_or(usize::max_value()); let brace_pos = snippet.find_uncommented("{").unwrap_or(usize::max_value()); if paren_pos < bracket_pos && paren_pos < brace_pos { - DelimToken::Paren + Delimiter::Parenthesis } else if bracket_pos < brace_pos { - DelimToken::Bracket + Delimiter::Bracket } else { - DelimToken::Brace + Delimiter::Brace } } @@ -1174,7 +1174,7 @@ struct Macro { // rather than clone them, if we can make the borrowing work out. struct MacroBranch { span: Span, - args_paren_kind: DelimToken, + args_paren_kind: Delimiter, args: TokenStream, body: Span, whole_body: Span, @@ -1188,7 +1188,7 @@ impl MacroBranch { multi_branch_style: bool, ) -> Option<String> { // Only attempt to format function-like macros. - if self.args_paren_kind != DelimToken::Paren { + if self.args_paren_kind != Delimiter::Parenthesis { // FIXME(#1539): implement for non-sugared macros. return None; } @@ -1350,18 +1350,18 @@ fn rewrite_macro_with_items( items: &[MacroArg], macro_name: &str, shape: Shape, - style: DelimToken, + style: Delimiter, position: MacroPosition, span: Span, ) -> Option<String> { let (opener, closer) = match style { - DelimToken::Paren => ("(", ")"), - DelimToken::Bracket => ("[", "]"), - DelimToken::Brace => (" {", "}"), + Delimiter::Parenthesis => ("(", ")"), + Delimiter::Bracket => ("[", "]"), + Delimiter::Brace => (" {", "}"), _ => return None, }; let trailing_semicolon = match style { - DelimToken::Paren | DelimToken::Bracket if position == MacroPosition::Item => ";", + Delimiter::Parenthesis | Delimiter::Bracket if position == MacroPosition::Item => ";", _ => "", }; diff --git a/src/tools/rustfmt/src/overflow.rs b/src/tools/rustfmt/src/overflow.rs index 80aed998d73..f115e7d0261 100644 --- a/src/tools/rustfmt/src/overflow.rs +++ b/src/tools/rustfmt/src/overflow.rs @@ -3,7 +3,7 @@ use std::cmp::min; use itertools::Itertools; -use rustc_ast::token::DelimToken; +use rustc_ast::token::Delimiter; use rustc_ast::{ast, ptr}; use rustc_span::Span; @@ -297,11 +297,11 @@ pub(crate) fn rewrite_with_square_brackets<'a, T: 'a + IntoOverflowableItem<'a>> shape: Shape, span: Span, force_separator_tactic: Option<SeparatorTactic>, - delim_token: Option<DelimToken>, + delim_token: Option<Delimiter>, ) -> Option<String> { let (lhs, rhs) = match delim_token { - Some(DelimToken::Paren) => ("(", ")"), - Some(DelimToken::Brace) => ("{", "}"), + Some(Delimiter::Parenthesis) => ("(", ")"), + Some(Delimiter::Brace) => ("{", "}"), _ => ("[", "]"), }; Context::new( diff --git a/src/tools/rustfmt/src/parse/macros/cfg_if.rs b/src/tools/rustfmt/src/parse/macros/cfg_if.rs index 306b6bb745e..09b3e32df31 100644 --- a/src/tools/rustfmt/src/parse/macros/cfg_if.rs +++ b/src/tools/rustfmt/src/parse/macros/cfg_if.rs @@ -1,7 +1,7 @@ use std::panic::{catch_unwind, AssertUnwindSafe}; use rustc_ast::ast; -use rustc_ast::token::{DelimToken, TokenKind}; +use rustc_ast::token::{Delimiter, TokenKind}; use rustc_parse::parser::ForceCollect; use rustc_span::symbol::kw; @@ -47,11 +47,11 @@ fn parse_cfg_if_inner<'a>( .map_err(|_| "Failed to parse attributes")?; } - if !parser.eat(&TokenKind::OpenDelim(DelimToken::Brace)) { + if !parser.eat(&TokenKind::OpenDelim(Delimiter::Brace)) { return Err("Expected an opening brace"); } - while parser.token != TokenKind::CloseDelim(DelimToken::Brace) + while parser.token != TokenKind::CloseDelim(Delimiter::Brace) && parser.token.kind != TokenKind::Eof { let item = match parser.parse_item(ForceCollect::No) { @@ -70,7 +70,7 @@ fn parse_cfg_if_inner<'a>( } } - if !parser.eat(&TokenKind::CloseDelim(DelimToken::Brace)) { + if !parser.eat(&TokenKind::CloseDelim(Delimiter::Brace)) { return Err("Expected a closing brace"); } diff --git a/src/tools/rustfmt/src/parse/macros/mod.rs b/src/tools/rustfmt/src/parse/macros/mod.rs index 3728f3a19b4..d4dbf21f8ca 100644 --- a/src/tools/rustfmt/src/parse/macros/mod.rs +++ b/src/tools/rustfmt/src/parse/macros/mod.rs @@ -1,4 +1,4 @@ -use rustc_ast::token::{DelimToken, TokenKind}; +use rustc_ast::token::{Delimiter, TokenKind}; use rustc_ast::tokenstream::TokenStream; use rustc_ast::{ast, ptr}; use rustc_parse::parser::{ForceCollect, Parser}; @@ -81,7 +81,7 @@ fn check_keyword<'a, 'b: 'a>(parser: &'a mut Parser<'b>) -> Option<MacroArg> { && parser.look_ahead(1, |t| { t.kind == TokenKind::Eof || t.kind == TokenKind::Comma - || t.kind == TokenKind::CloseDelim(DelimToken::NoDelim) + || t.kind == TokenKind::CloseDelim(Delimiter::Invisible) }) { parser.bump(); @@ -97,7 +97,7 @@ fn check_keyword<'a, 'b: 'a>(parser: &'a mut Parser<'b>) -> Option<MacroArg> { pub(crate) fn parse_macro_args( context: &RewriteContext<'_>, tokens: TokenStream, - style: DelimToken, + style: Delimiter, forced_bracket: bool, ) -> Option<ParsedMacroArgs> { let mut parser = build_parser(context, tokens); @@ -105,7 +105,7 @@ pub(crate) fn parse_macro_args( let mut vec_with_semi = false; let mut trailing_comma = false; - if DelimToken::Brace != style { + if Delimiter::Brace != style { loop { if let Some(arg) = check_keyword(&mut parser) { args.push(arg); diff --git a/src/tools/rustfmt/src/visitor.rs b/src/tools/rustfmt/src/visitor.rs index 1621eb406b1..f04fb2e0446 100644 --- a/src/tools/rustfmt/src/visitor.rs +++ b/src/tools/rustfmt/src/visitor.rs @@ -1,7 +1,7 @@ use std::cell::{Cell, RefCell}; use std::rc::Rc; -use rustc_ast::{ast, token::DelimToken, visit, AstLike}; +use rustc_ast::{ast, token::Delimiter, visit, AstLike}; use rustc_data_structures::sync::Lrc; use rustc_span::{symbol, BytePos, Pos, Span}; @@ -689,7 +689,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> { // with whitespace between the delimiters and trailing semi (i.e. `foo!(abc) ;`) // are formatted correctly. let (span, rewrite) = match macro_style(mac, &self.get_context()) { - DelimToken::Bracket | DelimToken::Paren if MacroPosition::Item == pos => { + Delimiter::Bracket | Delimiter::Parenthesis if MacroPosition::Item == pos => { let search_span = mk_sp(mac.span().hi(), self.snippet_provider.end_pos()); let hi = self.snippet_provider.span_before(search_span, ";"); let target_span = mk_sp(mac.span().lo(), hi + BytePos(1)); |
