Skip to content

Commit

Permalink
rustc_borrowck: Stop suggesting &mut raw const
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Enselic committed Dec 13, 2024
1 parent de19608 commit f1baf80
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 5 additions & 0 deletions compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1455,6 +1455,11 @@ fn suggest_ampmut<'tcx>(
&& let Ok(src) = tcx.sess.source_map().span_to_snippet(assignment_rhs_span)
&& let Some(stripped) = src.strip_prefix('&')
{
let is_raw_ref = stripped.trim_start().starts_with("raw ");
// We don't support raw refs yet
if is_raw_ref {
return None;
}
let is_mut = if let Some(rest) = stripped.trim_start().strip_prefix("mut") {
match rest.chars().next() {
// e.g. `&mut x`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ error[E0594]: cannot assign to `*ptr`, which is behind a `*const` pointer
|
LL | unsafe { *ptr = 3; }
| ^^^^^^^^ `ptr` is a `*const` pointer, so the data it refers to cannot be written
|
help: consider changing this to be a mutable pointer
|
LL | let ptr = &mut raw const val;
| +++

error: aborting due to 1 previous error

Expand Down

0 comments on commit f1baf80

Please sign in to comment.