diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-10-08 23:31:28 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-08 23:31:28 +0200 |
| commit | ff51611c42d160f95a01d556045d32f0539d8989 (patch) | |
| tree | 8d6c88672d85193d1a53f3a72c703f886b501071 /src/librustc | |
| parent | 4a6304fb05f60e32fcca21eee44cb8bf442cc0b4 (diff) | |
| parent | d0eea6ff6dbdab88ddbcf0ce2dcbbfd456678e39 (diff) | |
| download | rust-ff51611c42d160f95a01d556045d32f0539d8989.tar.gz rust-ff51611c42d160f95a01d556045d32f0539d8989.zip | |
Rollup merge of #65213 - estebank:peel-drop-temps, r=Centril
Ignore `ExprKind::DropTemps` for some ref suggestions Introduce `Expr::peel_drop_temps()` to ignore `ExprKind::DropTemps` for suggestions that depend on the `ExprKind` for accuracy.
Diffstat (limited to 'src/librustc')
| -rw-r--r-- | src/librustc/hir/mod.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 30b05036688..1f792ecc2da 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -1548,6 +1548,19 @@ impl Expr { } } } + + /// If `Self.kind` is `ExprKind::DropTemps(expr)`, drill down until we get a non-`DropTemps` + /// `Expr`. This is used in suggestions to ignore this `ExprKind` as it is semantically + /// silent, only signaling the ownership system. By doing this, suggestions that check the + /// `ExprKind` of any given `Expr` for presentation don't have to care about `DropTemps` + /// beyond remembering to call this function before doing analysis on it. + pub fn peel_drop_temps(&self) -> &Self { + let mut expr = self; + while let ExprKind::DropTemps(inner) = &expr.kind { + expr = inner; + } + expr + } } impl fmt::Debug for Expr { |
