Rollup merge of #106927 - Ezrashaw:e0606-make-machine-applicable, r=estebank
make `CastError::NeedsDeref` create a `MachineApplicable` suggestion Fixes #106903 Simple impl for the linked issue. I also made some other small changes: - `CastError::ErrorGuaranteed` now owns an actual `ErrorGuaranteed`. This better enforces the static guarantees of `ErrorGuaranteed`. - `CastError::NeedDeref` code simplified a bit, we now just suggest the `*`, instead of the whole expression as well.
This commit is contained in:
commit
1a878df2b8
6 changed files with 64 additions and 33 deletions
|
@ -1787,6 +1787,14 @@ impl Expr<'_> {
|
|||
expr
|
||||
}
|
||||
|
||||
pub fn peel_borrows(&self) -> &Self {
|
||||
let mut expr = self;
|
||||
while let ExprKind::AddrOf(.., inner) = &expr.kind {
|
||||
expr = inner;
|
||||
}
|
||||
expr
|
||||
}
|
||||
|
||||
pub fn can_have_side_effects(&self) -> bool {
|
||||
match self.peel_drop_temps().kind {
|
||||
ExprKind::Path(_) | ExprKind::Lit(_) => false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue