Skip to content

Commit 2d2c6f2

Browse files
committed
rustc_borrowck: Stop suggesting the invalid syntax &mut raw const
A legitimate suggestion would be to change from &raw const val to &raw mut val But until we have figured out how to make that happen we should at least stop suggesting invalid syntax.
1 parent d7fa8ee commit 2d2c6f2

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,11 @@ fn suggest_ampmut<'tcx>(
14551455
&& let Ok(src) = tcx.sess.source_map().span_to_snippet(assignment_rhs_span)
14561456
&& let Some(stripped) = src.strip_prefix('&')
14571457
{
1458+
let is_raw_ref = stripped.trim_start().starts_with("raw ");
1459+
// We don't support raw refs yet
1460+
if is_raw_ref {
1461+
return None;
1462+
}
14581463
let is_mut = if let Some(rest) = stripped.trim_start().strip_prefix("mut") {
14591464
match rest.chars().next() {
14601465
// e.g. `&mut x`

tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.stderr

-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ error[E0594]: cannot assign to `*ptr`, which is behind a `*const` pointer
33
|
44
LL | unsafe { *ptr = 3; }
55
| ^^^^^^^^ `ptr` is a `*const` pointer, so the data it refers to cannot be written
6-
|
7-
help: consider changing this to be a mutable pointer
8-
|
9-
LL | let ptr = &mut raw const val;
10-
| +++
116

127
error: aborting due to 1 previous error
138

0 commit comments

Comments
 (0)