Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3e80697
Use links to edition guide for edition migrations
ehuss Dec 16, 2024
e40a494
Handle fndef rendering together with signature rendering
oli-obk Dec 15, 2024
9cfc105
Update books
rustbot Dec 16, 2024
bfb027a
rustc_borrowck: suggest_ampmut(): Just rename some variables
Enselic Dec 16, 2024
47b559d
rustc_borrowck: suggest_ampmut(): Inline unneeded local var
Enselic Dec 16, 2024
70a0dc1
rustc_borrowck: Suggest changing `&raw const` to `&raw mut` if applic…
Enselic Dec 16, 2024
2b7c0a8
add alignment info for test
mustartt Dec 16, 2024
62d5aaa
Adjust upvar.rs file path
spastorino Dec 11, 2024
93d599c
Fix names of adjust fns
spastorino Dec 11, 2024
ab6ad1a
Add a range argument to vec.extract_if
the8472 Nov 20, 2024
03f1b73
remove bounds from vec and linkedlist ExtractIf
the8472 Nov 20, 2024
fe52150
update uses of extract_if in the compiler
the8472 Nov 20, 2024
44790c4
remove obsolete comment and pub(super) visibility
the8472 Nov 20, 2024
bccbe70
Rename `rustc_mir_build::build` to `builder`
Zalathar Dec 16, 2024
c58219b
Explain why `build` was renamed to `builder`
Zalathar Dec 16, 2024
f10169c
Move `doc(keyword = "while")`.
nnethercote Dec 12, 2024
121e87b
Remove `rustc::existing_doc_keyword` lint.
nnethercote Dec 12, 2024
13ea18b
Rollup merge of #133265 - the8472:extract-if-ranges, r=cuviper
jhpratt Dec 17, 2024
d5b8fb4
Rollup merge of #134202 - nnethercote:rm-existing_doc_keyword, r=Guil…
jhpratt Dec 17, 2024
cdb61ba
Rollup merge of #134354 - oli-obk:push-nlrxswvpqnuk, r=compiler-errors
jhpratt Dec 17, 2024
cc5392a
Rollup merge of #134365 - Zalathar:builder, r=nnethercote
jhpratt Dec 17, 2024
c1a739a
Rollup merge of #134368 - ehuss:edition-links, r=jieyouxu
jhpratt Dec 17, 2024
36cafcd
Rollup merge of #134388 - rustbot:docs-update, r=ehuss
jhpratt Dec 17, 2024
70aa10a
Rollup merge of #134397 - Enselic:raw-mut, r=compiler-errors
jhpratt Dec 17, 2024
05c7711
Rollup merge of #134398 - mustartt:aix-alignment-test-fix, r=compiler…
jhpratt Dec 17, 2024
e780f52
Rollup merge of #134400 - spastorino:fix-some-comments, r=compiler-er…
jhpratt Dec 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1474,16 +1474,27 @@ fn suggest_ampmut<'tcx>(
// let x: &i32 = &'a 5;
// ^^ lifetime annotation not allowed
//
if let Some(assignment_rhs_span) = opt_assignment_rhs_span
&& let Ok(src) = tcx.sess.source_map().span_to_snippet(assignment_rhs_span)
&& let Some(stripped) = src.strip_prefix('&')
if let Some(rhs_span) = opt_assignment_rhs_span
&& let Ok(rhs_str) = tcx.sess.source_map().span_to_snippet(rhs_span)
&& let Some(rhs_str_no_amp) = rhs_str.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;
// Suggest changing `&raw const` to `&raw mut` if applicable.
if rhs_str_no_amp.trim_start().strip_prefix("raw const").is_some() {
let const_idx = rhs_str.find("const").unwrap() as u32;
let const_span = rhs_span
.with_lo(rhs_span.lo() + BytePos(const_idx))
.with_hi(rhs_span.lo() + BytePos(const_idx + "const".len() as u32));

return Some(AmpMutSugg {
has_sugg: true,
span: const_span,
suggestion: "mut".to_owned(),
additional: None,
});
}
let is_mut = if let Some(rest) = stripped.trim_start().strip_prefix("mut") {

// Figure out if rhs already is `&mut`.
let is_mut = if let Some(rest) = rhs_str_no_amp.trim_start().strip_prefix("mut") {
match rest.chars().next() {
// e.g. `&mut x`
Some(c) if c.is_whitespace() => true,
Expand All @@ -1500,9 +1511,8 @@ fn suggest_ampmut<'tcx>(
// if the reference is already mutable then there is nothing we can do
// here.
if !is_mut {
let span = assignment_rhs_span;
// shrink the span to just after the `&` in `&variable`
let span = span.with_lo(span.lo() + BytePos(1)).shrink_to_lo();
let span = rhs_span.with_lo(rhs_span.lo() + BytePos(1)).shrink_to_lo();

// FIXME(Ezrashaw): returning is bad because we still might want to
// update the annotated type, see #106857.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ 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 = &raw mut val;
| ~~~

error: aborting due to 1 previous error

Expand Down