diff options
| author | bors <bors@rust-lang.org> | 2022-05-24 10:25:13 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-05-24 10:25:13 +0000 |
| commit | b2eba058e6e1c698723e47074561a30b50b5fa7a (patch) | |
| tree | cbdaf274005b5100ae9e9b6a0bf1ed59674ca392 /compiler/rustc_parse/src | |
| parent | 43d9f3859e0204e764161ee085a360274b5f3e9a (diff) | |
| parent | 8227e69018279353bd17ee3ca227e22ce6c03783 (diff) | |
| download | rust-b2eba058e6e1c698723e47074561a30b50b5fa7a.tar.gz rust-b2eba058e6e1c698723e47074561a30b50b5fa7a.zip | |
Auto merge of #97121 - pvdrz:do-subdiagnostics-later, r=davidtwco
Avoid double binding of subdiagnostics inside `#[derive(SessionDiagnostic)]` r? `@davidtwco`
Diffstat (limited to 'compiler/rustc_parse/src')
| -rw-r--r-- | compiler/rustc_parse/src/parser/diagnostics.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 69e12063cc1..c9da58aae5c 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -254,23 +254,23 @@ struct AmbiguousPlus { #[derive(SessionDiagnostic)] #[error(code = "E0178", slug = "parser-maybe-recover-from-bad-type-plus")] -struct BadTypePlus<'a> { +struct BadTypePlus { pub ty: String, #[primary_span] pub span: Span, #[subdiagnostic] - pub sub: BadTypePlusSub<'a>, + pub sub: BadTypePlusSub, } -#[derive(SessionSubdiagnostic, Clone, Copy)] -pub enum BadTypePlusSub<'a> { +#[derive(SessionSubdiagnostic)] +pub enum BadTypePlusSub { #[suggestion( slug = "parser-add-paren", code = "{sum_with_parens}", applicability = "machine-applicable" )] AddParen { - sum_with_parens: &'a str, + sum_with_parens: String, #[primary_span] span: Span, }, @@ -1289,11 +1289,9 @@ impl<'a> Parser<'a> { let bounds = self.parse_generic_bounds(None)?; let sum_span = ty.span.to(self.prev_token.span); - let sum_with_parens: String; - let sub = match ty.kind { TyKind::Rptr(ref lifetime, ref mut_ty) => { - sum_with_parens = pprust::to_string(|s| { + let sum_with_parens = pprust::to_string(|s| { s.s.word("&"); s.print_opt_lifetime(lifetime); s.print_mutability(mut_ty.mutbl, false); @@ -1303,7 +1301,7 @@ impl<'a> Parser<'a> { s.pclose() }); - BadTypePlusSub::AddParen { sum_with_parens: &sum_with_parens, span: sum_span } + BadTypePlusSub::AddParen { sum_with_parens, span: sum_span } } TyKind::Ptr(..) | TyKind::BareFn(..) => BadTypePlusSub::ForgotParen { span: sum_span }, _ => BadTypePlusSub::ExpectPath { span: sum_span }, |
