get_mut_span_in_struct_field uses span.between
This commit is contained in:
parent
97bf7b934e
commit
e57307560e
2 changed files with 7 additions and 9 deletions
|
@ -237,7 +237,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
span,
|
span,
|
||||||
"consider changing this to be mutable",
|
"consider changing this to be mutable",
|
||||||
"mut ".into(),
|
" mut ".into(),
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1059,12 +1059,12 @@ fn is_closure_or_generator(ty: Ty<'_>) -> bool {
|
||||||
ty.is_closure() || ty.is_generator()
|
ty.is_closure() || ty.is_generator()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Given a field that needs to be mutuable, returns a span where the mut could go.
|
/// Given a field that needs to be mutable, returns a span where the " mut " could go.
|
||||||
/// This function expects the local to be a reference to a struct in order to produce a span.
|
/// This function expects the local to be a reference to a struct in order to produce a span.
|
||||||
///
|
///
|
||||||
/// ```text
|
/// ```text
|
||||||
/// LL | s: &'a String
|
/// LL | s: &'a String
|
||||||
/// | ^ returns a span pointing here
|
/// | ^^^ returns a span taking up the space here
|
||||||
/// ```
|
/// ```
|
||||||
fn get_mut_span_in_struct_field<'tcx>(
|
fn get_mut_span_in_struct_field<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
|
@ -1081,12 +1081,10 @@ fn get_mut_span_in_struct_field<'tcx>(
|
||||||
// Now we're dealing with the actual struct that we're going to suggest a change to,
|
// Now we're dealing with the actual struct that we're going to suggest a change to,
|
||||||
// we can expect a field that is an immutable reference to a type.
|
// we can expect a field that is an immutable reference to a type.
|
||||||
if let hir::Node::Field(field) = node {
|
if let hir::Node::Field(field) = node {
|
||||||
if let hir::TyKind::Rptr(lifetime, hir::MutTy { mutbl: hir::Mutability::Not, .. }) =
|
if let hir::TyKind::Rptr(lifetime, hir::MutTy { mutbl: hir::Mutability::Not, ty }) =
|
||||||
field.ty.kind
|
field.ty.kind
|
||||||
{
|
{
|
||||||
return Some(
|
return Some(lifetime.span.between(ty.span));
|
||||||
lifetime.span.with_hi(lifetime.span.hi() + BytePos(1)).shrink_to_hi(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue