diff options
| author | Benjamin Schulz <benjamin.schulz@sap.com> | 2025-06-04 19:03:18 +0200 |
|---|---|---|
| committer | Ben Schulz <benshu@benshu.de> | 2025-07-01 08:56:20 +0200 |
| commit | 7d6764a45bd05913e7f34a8fbba12bf384b0269a (patch) | |
| tree | a8cded24fae860122e99287b103464e88bf440ef /compiler/rustc_ast/src/ast.rs | |
| parent | e61dd437f33b5a640e67dc3628397689c664c17f (diff) | |
| download | rust-7d6764a45bd05913e7f34a8fbba12bf384b0269a.tar.gz rust-7d6764a45bd05913e7f34a8fbba12bf384b0269a.zip | |
Detect more cases of unused_parens around types
Diffstat (limited to 'compiler/rustc_ast/src/ast.rs')
| -rw-r--r-- | compiler/rustc_ast/src/ast.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index d9272986a7e..329fa723b1c 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -1391,6 +1391,7 @@ impl Expr { path.clone(), TraitBoundModifiers::NONE, self.span, + Parens::No, ))), _ => None, } @@ -3360,6 +3361,13 @@ pub struct TraitRef { pub ref_id: NodeId, } +/// Whether enclosing parentheses are present or not. +#[derive(Clone, Encodable, Decodable, Debug)] +pub enum Parens { + Yes, + No, +} + #[derive(Clone, Encodable, Decodable, Debug)] pub struct PolyTraitRef { /// The `'a` in `for<'a> Foo<&'a T>`. @@ -3372,6 +3380,10 @@ pub struct PolyTraitRef { pub trait_ref: TraitRef, pub span: Span, + + /// When `Yes`, the first and last character of `span` are an opening + /// and a closing paren respectively. + pub parens: Parens, } impl PolyTraitRef { @@ -3380,12 +3392,14 @@ impl PolyTraitRef { path: Path, modifiers: TraitBoundModifiers, span: Span, + parens: Parens, ) -> Self { PolyTraitRef { bound_generic_params: generic_params, modifiers, trait_ref: TraitRef { path, ref_id: DUMMY_NODE_ID }, span, + parens, } } } |
