Recover from incorrect replacement of & for types and expressions - #162376
Recover from incorrect replacement of & for types and expressions#162376KevinA-cpu wants to merge 1 commit into
& for types and expressions#162376Conversation
|
The parser was modified, potentially altering the grammar of (stable) Rust cc @fmease |
|
r? @nnethercote rustbot has assigned @nnethercote. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
- Suggest from `T&` to `&T` - Suggest from `mut&` to `&mut` - Suggest from `mut &'a u8` to `&'a mut u8` - Suggest from `expr&` to `&expr` - Suggest from `expr &mut` to `&mut expr` Guards: - check for may_recover() to avoid breaking macros - can_begin_type/can_begin_expr to avoid breaking `u8 & u8` and tests/ui/consts/closure-type-error-during-const-eval-66706.rs - Binary/Cast guards are in-place to prevent making wrong suggestions in complicated `lhs` Does not touch the following areas: - const& T: overlapping with open issue 146122 - i32&&: C++'s T&& is an rvalue reference and Rust doesn't have the same thing currently - u8 &mut - x as u8&
bba988b to
bea1b70
Compare
There was a problem hiding this comment.
We're in an expression context here, so "reference types" isn't correct terminology. You're looking for "borrow expression".
However, stepping back, expr& is not a thing in C/C++, so I'm not so sure if it's worth trying to recover from it. Do you think that anybody is really going to accidentally type expr& when they meant &expr? Re. expr &mut I'm 99.9% confident nobody has ever written that by accident.
There was a problem hiding this comment.
I'm wondering whether we should say &mut /* Type */ instead to make it crystal clear what is a placeholder and what isn't.
There was a problem hiding this comment.
Thanks for making sure this is well-tested. However, personally I think it's a tinge excessive for such a niche recovery 🤷
|
r? @fmease |
|
☔ The latest upstream changes (presumably #162269) made this pull request unmergeable. Please resolve the merge conflicts by rebasing. |
T&to&Tmut&to&mutmut &'a u8to&'a mut u8expr&to&exprexpr &mutto&mut exprGuards:
u8 & u8and tests/ui/consts/closure-type-error-during-const-eval-66706.rslhsDoes not touch the following areas:
#101487