diff options
| author | bors <bors@rust-lang.org> | 2022-09-06 03:16:29 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-09-06 03:16:29 +0000 |
| commit | 6c358c67d4d39b1b4dbbcee89e96ec748d771e9e (patch) | |
| tree | 0b408a0a95a82676690a365e92530600e2a78874 /compiler/rustc_save_analysis | |
| parent | 56b27110e7f72ea01312d99f1b1e0577431cbbd0 (diff) | |
| parent | 9ea82d57e296efd6dfc0cb0a6c4c09f4111c123d (diff) | |
| download | rust-6c358c67d4d39b1b4dbbcee89e96ec748d771e9e.tar.gz rust-6c358c67d4d39b1b4dbbcee89e96ec748d771e9e.zip | |
Auto merge of #101241 - camsteffen:refactor-binding-annotations, r=cjgillot
`BindingAnnotation` refactor
* `ast::BindingMode` is deleted and replaced with `hir::BindingAnnotation` (which is moved to `ast`)
* `BindingAnnotation` is changed from an enum to a tuple struct e.g. `BindingAnnotation(ByRef::No, Mutability::Mut)`
* Associated constants added for convenience `BindingAnnotation::{NONE, REF, MUT, REF_MUT}`
One goal is to make it more clear that `BindingAnnotation` merely represents syntax `ref mut` and not the actual binding mode. This was especially confusing since we had `ast::BindingMode`->`hir::BindingAnnotation`->`thir::BindingMode`.
I wish there were more symmetry between `ByRef` and `Mutability` (variant) naming (maybe `Mutable::Yes`?), and I also don't love how long the name `BindingAnnotation` is, but this seems like the best compromise. Ideas welcome.
Diffstat (limited to 'compiler/rustc_save_analysis')
| -rw-r--r-- | compiler/rustc_save_analysis/src/lib.rs | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/compiler/rustc_save_analysis/src/lib.rs b/compiler/rustc_save_analysis/src/lib.rs index c58ccde4390..89bca39512f 100644 --- a/compiler/rustc_save_analysis/src/lib.rs +++ b/compiler/rustc_save_analysis/src/lib.rs @@ -866,23 +866,12 @@ impl<'l> Visitor<'l> for PathCollector<'l> { hir::PatKind::TupleStruct(ref path, ..) | hir::PatKind::Path(ref path) => { self.collected_paths.push((p.hir_id, path)); } - hir::PatKind::Binding(bm, _, ident, _) => { + hir::PatKind::Binding(hir::BindingAnnotation(_, mutbl), _, ident, _) => { debug!( "PathCollector, visit ident in pat {}: {:?} {:?}", ident, p.span, ident.span ); - let immut = match bm { - // Even if the ref is mut, you can't change the ref, only - // the data pointed at, so showing the initialising expression - // is still worthwhile. - hir::BindingAnnotation::Unannotated | hir::BindingAnnotation::Ref => { - hir::Mutability::Not - } - hir::BindingAnnotation::Mutable | hir::BindingAnnotation::RefMut => { - hir::Mutability::Mut - } - }; - self.collected_idents.push((p.hir_id, ident, immut)); + self.collected_idents.push((p.hir_id, ident, mutbl)); } _ => {} } |
