fix help message for modification to &T created by &{t}
This commit is contained in:
parent
70f74719a9
commit
70f282d469
3 changed files with 40 additions and 10 deletions
|
@ -119,9 +119,9 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
&& !self.upvars.is_empty()
|
||||
{
|
||||
item_msg = format!("`{}`", access_place_desc.unwrap());
|
||||
debug_assert!(
|
||||
self.body.local_decls[ty::CAPTURE_STRUCT_LOCAL].ty.is_region_ptr()
|
||||
);
|
||||
debug_assert!(self.body.local_decls[ty::CAPTURE_STRUCT_LOCAL]
|
||||
.ty
|
||||
.is_region_ptr());
|
||||
debug_assert!(is_closure_or_generator(
|
||||
Place::ty_from(
|
||||
the_place_err.local,
|
||||
|
@ -905,6 +905,8 @@ fn suggest_ampmut<'tcx>(
|
|||
Some(c) if c.is_whitespace() => true,
|
||||
// e.g. `&mut(x)`
|
||||
Some('(') => true,
|
||||
// e.g. `&mut{x}`
|
||||
Some('{') => true,
|
||||
// e.g. `&mutablevar`
|
||||
_ => false,
|
||||
}
|
||||
|
@ -912,9 +914,7 @@ fn suggest_ampmut<'tcx>(
|
|||
false
|
||||
}
|
||||
};
|
||||
if let (true, Some(ws_pos)) =
|
||||
(src.starts_with("&'"), src.find(|c: char| -> bool { c.is_whitespace() }))
|
||||
{
|
||||
if let (true, Some(ws_pos)) = (src.starts_with("&'"), src.find(char::is_whitespace)) {
|
||||
let lt_name = &src[1..ws_pos];
|
||||
let ty = src[ws_pos..].trim_start();
|
||||
if !is_mutbl(ty) {
|
||||
|
@ -940,9 +940,7 @@ fn suggest_ampmut<'tcx>(
|
|||
};
|
||||
|
||||
if let Ok(src) = tcx.sess.source_map().span_to_snippet(highlight_span) {
|
||||
if let (true, Some(ws_pos)) =
|
||||
(src.starts_with("&'"), src.find(|c: char| -> bool { c.is_whitespace() }))
|
||||
{
|
||||
if let (true, Some(ws_pos)) = (src.starts_with("&'"), src.find(char::is_whitespace)) {
|
||||
let lt_name = &src[1..ws_pos];
|
||||
let ty = &src[ws_pos..];
|
||||
return (highlight_span, format!("&{} mut{}", lt_name, ty));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue