提交 1662daa2 编写于 作者: C csmoe 提交者: ashtneoi

lint with ref_span

上级 4e5d2288
......@@ -1209,14 +1209,12 @@ fn note_immutability_blame(&self,
let let_span = self.tcx.hir.span(node_id);
match self.local_binding_mode(node_id) {
ty::BindByReference(..) => {
let snippet = self.tcx.sess.codemap().span_to_snippet(let_span);
if let Ok(snippet) = snippet {
let ref_span = self.tcx.sess.codemap().span_until_whitespace(let_span);
if let Ok(_) = self.tcx.sess.codemap().span_to_snippet(let_span) {
db.span_label(
let_span,
format!("consider changing this to `{}`",
snippet.replacen("ref ", "ref mut ", 1))
);
}
ref_span,
format!("consider changing this to `{}`", "ref mut"));
};
}
ty::BindByValue(..) => {
if let (Some(local_ty), is_implicit_self) = self.local_ty(node_id) {
......
......@@ -2,7 +2,7 @@ error[E0594]: cannot assign to immutable borrowed content `*my_ref`
--> $DIR/issue-51244.rs:13:5
|
LL | let ref my_ref @ _ = 0;
| -------------- consider changing this to `ref mut my_ref @ _`
| --- consider changing this to `ref mut`
LL | *my_ref = 0;
| ^^^^^^^^^^^ cannot borrow as mutable
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册