Auto merge of #54490 - wesleywiser:rewrite_it_in_mir, r=oli-obk
Rewrite the `UnconditionalRecursion` lint to use MIR Part of #51002 r? @eddyb
This commit is contained in:
commit
4bd4e4130e
14 changed files with 240 additions and 287 deletions
|
|
@ -7,8 +7,20 @@ LL | (&mut self).bar(); //~ ERROR cannot borrow
|
|||
| cannot borrow as mutable
|
||||
| try removing `&mut` here
|
||||
|
||||
warning: function cannot return without recursing
|
||||
--> $DIR/issue-31424.rs:22:5
|
||||
|
|
||||
LL | fn bar(self: &mut Self) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
|
||||
LL | //~^ WARN function cannot return without recursing
|
||||
LL | (&mut self).bar(); //~ ERROR cannot borrow
|
||||
| ----------------- recursive call site
|
||||
|
|
||||
= note: #[warn(unconditional_recursion)] on by default
|
||||
= help: a `loop` may express intention better if this is on purpose
|
||||
|
||||
error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable
|
||||
--> $DIR/issue-31424.rs:23:9
|
||||
--> $DIR/issue-31424.rs:24:9
|
||||
|
|
||||
LL | (&mut self).bar(); //~ ERROR cannot borrow
|
||||
| ^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ impl Struct {
|
|||
// In this case we could keep the suggestion, but to distinguish the
|
||||
// two cases is pretty hard. It's an obscure case anyway.
|
||||
fn bar(self: &mut Self) {
|
||||
//~^ WARN function cannot return without recursing
|
||||
(&mut self).bar(); //~ ERROR cannot borrow
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,8 +7,20 @@ LL | (&mut self).bar(); //~ ERROR cannot borrow
|
|||
| cannot reborrow mutably
|
||||
| try removing `&mut` here
|
||||
|
||||
warning: function cannot return without recursing
|
||||
--> $DIR/issue-31424.rs:22:5
|
||||
|
|
||||
LL | fn bar(self: &mut Self) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
|
||||
LL | //~^ WARN function cannot return without recursing
|
||||
LL | (&mut self).bar(); //~ ERROR cannot borrow
|
||||
| ----------------- recursive call site
|
||||
|
|
||||
= note: #[warn(unconditional_recursion)] on by default
|
||||
= help: a `loop` may express intention better if this is on purpose
|
||||
|
||||
error[E0596]: cannot borrow immutable argument `self` as mutable
|
||||
--> $DIR/issue-31424.rs:23:15
|
||||
--> $DIR/issue-31424.rs:24:15
|
||||
|
|
||||
LL | (&mut self).bar(); //~ ERROR cannot borrow
|
||||
| ^^^^ cannot borrow mutably
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ struct Struct;
|
|||
|
||||
impl Struct {
|
||||
fn bar(self: &mut Self) {
|
||||
//~^ WARN function cannot return without recursing
|
||||
(&mut self).bar();
|
||||
//~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable [E0596]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,17 @@
|
|||
warning: function cannot return without recursing
|
||||
--> $DIR/issue-51191.rs:16:5
|
||||
|
|
||||
LL | fn bar(self: &mut Self) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
|
||||
LL | //~^ WARN function cannot return without recursing
|
||||
LL | (&mut self).bar();
|
||||
| ----------------- recursive call site
|
||||
|
|
||||
= note: #[warn(unconditional_recursion)] on by default
|
||||
= help: a `loop` may express intention better if this is on purpose
|
||||
|
||||
error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable
|
||||
--> $DIR/issue-51191.rs:17:9
|
||||
--> $DIR/issue-51191.rs:18:9
|
||||
|
|
||||
LL | (&mut self).bar();
|
||||
| ^^^^^^^^^^^
|
||||
|
|
@ -8,7 +20,7 @@ LL | (&mut self).bar();
|
|||
| try removing `&mut` here
|
||||
|
||||
error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable
|
||||
--> $DIR/issue-51191.rs:22:9
|
||||
--> $DIR/issue-51191.rs:23:9
|
||||
|
|
||||
LL | fn imm(self) {
|
||||
| ---- help: consider changing this to be mutable: `mut self`
|
||||
|
|
@ -16,19 +28,19 @@ LL | (&mut self).bar();
|
|||
| ^^^^^^^^^^^ cannot borrow as mutable
|
||||
|
||||
error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable
|
||||
--> $DIR/issue-51191.rs:31:9
|
||||
--> $DIR/issue-51191.rs:32:9
|
||||
|
|
||||
LL | (&mut self).bar();
|
||||
| ^^^^^^^^^^^ cannot borrow as mutable
|
||||
|
||||
error[E0596]: cannot borrow data in a `&` reference as mutable
|
||||
--> $DIR/issue-51191.rs:31:9
|
||||
--> $DIR/issue-51191.rs:32:9
|
||||
|
|
||||
LL | (&mut self).bar();
|
||||
| ^^^^^^^^^^^ cannot borrow as mutable
|
||||
|
||||
error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable
|
||||
--> $DIR/issue-51191.rs:37:9
|
||||
--> $DIR/issue-51191.rs:38:9
|
||||
|
|
||||
LL | (&mut self).bar();
|
||||
| ^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -1,5 +1,17 @@
|
|||
warning: function cannot return without recursing
|
||||
--> $DIR/region-bound-on-closure-outlives-call.rs:11:1
|
||||
|
|
||||
LL | fn call_rec<F>(mut f: F) -> usize where F: FnMut(usize) -> usize {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
|
||||
LL | //~^ WARN function cannot return without recursing
|
||||
LL | (|x| f(x))(call_rec(f)) //~ ERROR cannot move out of `f`
|
||||
| ----------- recursive call site
|
||||
|
|
||||
= note: #[warn(unconditional_recursion)] on by default
|
||||
= help: a `loop` may express intention better if this is on purpose
|
||||
|
||||
error[E0505]: cannot move out of `f` because it is borrowed
|
||||
--> $DIR/region-bound-on-closure-outlives-call.rs:12:25
|
||||
--> $DIR/region-bound-on-closure-outlives-call.rs:13:25
|
||||
|
|
||||
LL | (|x| f(x))(call_rec(f)) //~ ERROR cannot move out of `f`
|
||||
| ---------- ^ move out of `f` occurs here
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn call_rec<F>(mut f: F) -> usize where F: FnMut(usize) -> usize {
|
||||
//~^ WARN function cannot return without recursing
|
||||
(|x| f(x))(call_rec(f)) //~ ERROR cannot move out of `f`
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,17 @@
|
|||
warning: function cannot return without recursing
|
||||
--> $DIR/region-bound-on-closure-outlives-call.rs:11:1
|
||||
|
|
||||
LL | fn call_rec<F>(mut f: F) -> usize where F: FnMut(usize) -> usize {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
|
||||
LL | //~^ WARN function cannot return without recursing
|
||||
LL | (|x| f(x))(call_rec(f)) //~ ERROR cannot move out of `f`
|
||||
| ----------- recursive call site
|
||||
|
|
||||
= note: #[warn(unconditional_recursion)] on by default
|
||||
= help: a `loop` may express intention better if this is on purpose
|
||||
|
||||
error[E0505]: cannot move out of `f` because it is borrowed
|
||||
--> $DIR/region-bound-on-closure-outlives-call.rs:12:25
|
||||
--> $DIR/region-bound-on-closure-outlives-call.rs:13:25
|
||||
|
|
||||
LL | (|x| f(x))(call_rec(f)) //~ ERROR cannot move out of `f`
|
||||
| --- ^ move out of `f` occurs here
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue