diff options
Diffstat (limited to 'tests/ui/borrowck')
12 files changed, 72 insertions, 48 deletions
diff --git a/tests/ui/borrowck/already-borrowed-as-mutable-if-let-133941.stderr b/tests/ui/borrowck/already-borrowed-as-mutable-if-let-133941.stderr index bb21caccbaf..2f443797dfa 100644 --- a/tests/ui/borrowck/already-borrowed-as-mutable-if-let-133941.stderr +++ b/tests/ui/borrowck/already-borrowed-as-mutable-if-let-133941.stderr @@ -15,8 +15,9 @@ LL | } | help: consider using the `matches!` macro | -LL | while matches!(foo.f(), Some(_)) { - | ~~~~~~~~~~~~~~~~~~~~~~~~~~ +LL - while let Some(_) = foo.f() { +LL + while matches!(foo.f(), Some(_)) { + | error[E0499]: cannot borrow `foo` as mutable more than once at a time --> $DIR/already-borrowed-as-mutable-if-let-133941.rs:29:9 @@ -35,8 +36,9 @@ LL | } | help: consider using the `matches!` macro | -LL | if matches!(foo.f(), Some(_)) { - | ~~~~~~~~~~~~~~~~~~~~~~~~~~ +LL - if let Some(_) = foo.f() { +LL + if matches!(foo.f(), Some(_)) { + | error[E0499]: cannot borrow `foo` as mutable more than once at a time --> $DIR/already-borrowed-as-mutable-if-let-133941.rs:33:9 diff --git a/tests/ui/borrowck/borrowck-struct-update-with-dtor.stderr b/tests/ui/borrowck/borrowck-struct-update-with-dtor.stderr index bc11204acf2..d953ed2ad3e 100644 --- a/tests/ui/borrowck/borrowck-struct-update-with-dtor.stderr +++ b/tests/ui/borrowck/borrowck-struct-update-with-dtor.stderr @@ -33,8 +33,9 @@ LL | struct B; | ^^^^^^^^ help: if `B` implemented `Clone`, you could clone the value from the field instead of using the functional record update syntax | -LL | let _s2 = S { a: 2, b: s0.b.clone(), c: s0.c.clone() }; - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +LL - let _s2 = S { a: 2, ..s0 }; +LL + let _s2 = S { a: 2, b: s0.b.clone(), c: s0.c.clone() }; + | error[E0509]: cannot move out of type `S<B>`, which implements the `Drop` trait --> $DIR/borrowck-struct-update-with-dtor.rs:24:19 @@ -52,8 +53,9 @@ LL | struct B; | ^^^^^^^^ help: if `B` implemented `Clone`, you could clone the value from the field instead of using the functional record update syntax | -LL | let _s2 = S { a: 2, b: s0.b.clone(), c: s0.c.clone() }; - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +LL - let _s2 = S { a: 2, ..s0 }; +LL + let _s2 = S { a: 2, b: s0.b.clone(), c: s0.c.clone() }; + | error[E0509]: cannot move out of type `S<K>`, which implements the `Drop` trait --> $DIR/borrowck-struct-update-with-dtor.rs:29:19 @@ -99,8 +101,9 @@ LL | let _s2 = T { a: 2, ..s0 }; | help: clone the value from the field instead of using the functional record update syntax | -LL | let _s2 = T { a: 2, b: s0.b.clone() }; - | ~~~~~~~~~~~~~~~~~ +LL - let _s2 = T { a: 2, ..s0 }; +LL + let _s2 = T { a: 2, b: s0.b.clone() }; + | error[E0509]: cannot move out of type `T`, which implements the `Drop` trait --> $DIR/borrowck-struct-update-with-dtor.rs:42:19 @@ -113,8 +116,9 @@ LL | let _s2 = T { ..s0 }; | help: clone the value from the field instead of using the functional record update syntax | -LL | let _s2 = T { b: s0.b.clone(), ..s0 }; - | ~~~~~~~~~~~~~~~~~~~~~~~~~ +LL - let _s2 = T { ..s0 }; +LL + let _s2 = T { b: s0.b.clone(), ..s0 }; + | error[E0509]: cannot move out of type `T`, which implements the `Drop` trait --> $DIR/borrowck-struct-update-with-dtor.rs:47:32 diff --git a/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.stderr b/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.stderr index e4dfa6d7fba..1e3570fc855 100644 --- a/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.stderr +++ b/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.stderr @@ -9,8 +9,9 @@ LL | let sfoo: *mut Foo = &mut SFOO; = note: `#[warn(static_mut_refs)]` on by default help: use `&raw mut` instead to create a raw pointer | -LL | let sfoo: *mut Foo = &raw mut SFOO; - | ~~~~~~~~ +LL - let sfoo: *mut Foo = &mut SFOO; +LL + let sfoo: *mut Foo = &raw mut SFOO; + | warning: 1 warning emitted diff --git a/tests/ui/borrowck/index-mut-help.stderr b/tests/ui/borrowck/index-mut-help.stderr index c4c9c1c5313..6c3bd0df20b 100644 --- a/tests/ui/borrowck/index-mut-help.stderr +++ b/tests/ui/borrowck/index-mut-help.stderr @@ -7,8 +7,9 @@ LL | map["peter"].clear(); = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `HashMap<&str, String>` help: to modify a `HashMap<&str, String>` use `.get_mut()` | -LL | if let Some(val) = map.get_mut("peter") { val.clear(); }; - | ++++++++++++++++++ ~~~~~~~~~ ~~~~~~~ +++ +LL - map["peter"].clear(); +LL + if let Some(val) = map.get_mut("peter") { val.clear(); }; + | error[E0594]: cannot assign to data in an index of `HashMap<&str, String>` --> $DIR/index-mut-help.rs:11:5 @@ -19,12 +20,15 @@ LL | map["peter"] = "0".to_string(); = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `HashMap<&str, String>` help: use `.insert()` to insert a value into a `HashMap<&str, String>`, `.get_mut()` to modify it, or the entry API for more flexibility | -LL | map.insert("peter", "0".to_string()); - | ~~~~~~~~ ~ + -LL | if let Some(val) = map.get_mut("peter") { *val = "0".to_string(); }; - | ++++++++++++++++++ ~~~~~~~~~ ~~~~~~~~ +++ -LL | let val = map.entry("peter").or_insert("0".to_string()); - | +++++++++ ~~~~~~~ ~~~~~~~~~~~~ + +LL - map["peter"] = "0".to_string(); +LL + map.insert("peter", "0".to_string()); + | +LL - map["peter"] = "0".to_string(); +LL + if let Some(val) = map.get_mut("peter") { *val = "0".to_string(); }; + | +LL - map["peter"] = "0".to_string(); +LL + let val = map.entry("peter").or_insert("0".to_string()); + | error[E0596]: cannot borrow data in an index of `HashMap<&str, String>` as mutable --> $DIR/index-mut-help.rs:12:13 diff --git a/tests/ui/borrowck/issue-115259-suggest-iter-mut.stderr b/tests/ui/borrowck/issue-115259-suggest-iter-mut.stderr index 40ab2e61d6a..53b833e7c91 100644 --- a/tests/ui/borrowck/issue-115259-suggest-iter-mut.stderr +++ b/tests/ui/borrowck/issue-115259-suggest-iter-mut.stderr @@ -8,8 +8,9 @@ LL | self.layers.iter().fold(0, |result, mut layer| result + layer.proce | help: you may want to use `iter_mut` here | -LL | self.layers.iter_mut().fold(0, |result, mut layer| result + layer.process()) - | ~~~~~~~~ +LL - self.layers.iter().fold(0, |result, mut layer| result + layer.process()) +LL + self.layers.iter_mut().fold(0, |result, mut layer| result + layer.process()) + | error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/issue-62387-suggest-iter-mut-2.stderr b/tests/ui/borrowck/issue-62387-suggest-iter-mut-2.stderr index 466f19eb0ab..86d53012cf3 100644 --- a/tests/ui/borrowck/issue-62387-suggest-iter-mut-2.stderr +++ b/tests/ui/borrowck/issue-62387-suggest-iter-mut-2.stderr @@ -8,8 +8,9 @@ LL | vec.iter().flat_map(|container| container.things()).cloned().co | help: you may want to use `iter_mut` here | -LL | vec.iter_mut().flat_map(|container| container.things()).cloned().collect::<Vec<PathBuf>>(); - | ~~~~~~~~ +LL - vec.iter().flat_map(|container| container.things()).cloned().collect::<Vec<PathBuf>>(); +LL + vec.iter_mut().flat_map(|container| container.things()).cloned().collect::<Vec<PathBuf>>(); + | error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/issue-62387-suggest-iter-mut.stderr b/tests/ui/borrowck/issue-62387-suggest-iter-mut.stderr index fd58e433020..f0a17d76a67 100644 --- a/tests/ui/borrowck/issue-62387-suggest-iter-mut.stderr +++ b/tests/ui/borrowck/issue-62387-suggest-iter-mut.stderr @@ -8,8 +8,9 @@ LL | v.iter().for_each(|a| a.double()); | help: you may want to use `iter_mut` here | -LL | v.iter_mut().for_each(|a| a.double()); - | ~~~~~~~~ +LL - v.iter().for_each(|a| a.double()); +LL + v.iter_mut().for_each(|a| a.double()); + | error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference --> $DIR/issue-62387-suggest-iter-mut.rs:25:39 @@ -21,8 +22,9 @@ LL | v.iter().rev().rev().for_each(|a| a.double()); | help: you may want to use `iter_mut` here | -LL | v.iter_mut().rev().rev().for_each(|a| a.double()); - | ~~~~~~~~ +LL - v.iter().rev().rev().for_each(|a| a.double()); +LL + v.iter_mut().rev().rev().for_each(|a| a.double()); + | error: aborting due to 2 previous errors diff --git a/tests/ui/borrowck/issue-85765-closure.stderr b/tests/ui/borrowck/issue-85765-closure.stderr index 936ddd67bcd..fa4e5441508 100644 --- a/tests/ui/borrowck/issue-85765-closure.stderr +++ b/tests/ui/borrowck/issue-85765-closure.stderr @@ -6,8 +6,9 @@ LL | rofl.push(Vec::new()); | help: consider changing this binding's type | -LL | let rofl: &mut Vec<Vec<i32>> = &mut test; - | ~~~~~~~~~~~~~~~~~~ +LL - let rofl: &Vec<Vec<i32>> = &mut test; +LL + let rofl: &mut Vec<Vec<i32>> = &mut test; + | error[E0594]: cannot assign to `*r`, which is behind a `&` reference --> $DIR/issue-85765-closure.rs:13:9 @@ -28,8 +29,9 @@ LL | *x = 1; | help: consider changing this binding's type | -LL | let x: &mut usize = &mut{0}; - | ~~~~~~~~~~ +LL - let x: &usize = &mut{0}; +LL + let x: &mut usize = &mut{0}; + | error[E0594]: cannot assign to `*y`, which is behind a `&` reference --> $DIR/issue-85765-closure.rs:27:9 @@ -39,8 +41,9 @@ LL | *y = 1; | help: consider changing this binding's type | -LL | let y: &mut usize = &mut(0); - | ~~~~~~~~~~ +LL - let y: &usize = &mut(0); +LL + let y: &mut usize = &mut(0); + | error: aborting due to 4 previous errors diff --git a/tests/ui/borrowck/issue-85765.stderr b/tests/ui/borrowck/issue-85765.stderr index 57900bfb612..9354294f52b 100644 --- a/tests/ui/borrowck/issue-85765.stderr +++ b/tests/ui/borrowck/issue-85765.stderr @@ -6,8 +6,9 @@ LL | rofl.push(Vec::new()); | help: consider changing this binding's type | -LL | let rofl: &mut Vec<Vec<i32>> = &mut test; - | ~~~~~~~~~~~~~~~~~~ +LL - let rofl: &Vec<Vec<i32>> = &mut test; +LL + let rofl: &mut Vec<Vec<i32>> = &mut test; + | error[E0594]: cannot assign to `*r`, which is behind a `&` reference --> $DIR/issue-85765.rs:12:5 @@ -28,8 +29,9 @@ LL | *x = 1; | help: consider changing this binding's type | -LL | let x: &mut usize = &mut{0}; - | ~~~~~~~~~~ +LL - let x: &usize = &mut{0}; +LL + let x: &mut usize = &mut{0}; + | error[E0594]: cannot assign to `*y`, which is behind a `&` reference --> $DIR/issue-85765.rs:26:5 @@ -39,8 +41,9 @@ LL | *y = 1; | help: consider changing this binding's type | -LL | let y: &mut usize = &mut(0); - | ~~~~~~~~~~ +LL - let y: &usize = &mut(0); +LL + let y: &mut usize = &mut(0); + | error: aborting due to 4 previous errors diff --git a/tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.stderr b/tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.stderr index dbe834b6b78..9bcfbd33795 100644 --- a/tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.stderr +++ b/tests/ui/borrowck/no-invalid-mut-suggestion-for-raw-pointer-issue-127562.stderr @@ -6,8 +6,9 @@ LL | unsafe { *ptr = 3; } | help: consider changing this to be a mutable pointer | -LL | let ptr = &raw mut val; - | ~~~ +LL - let ptr = &raw const val; +LL + let ptr = &raw mut val; + | error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/suggest-lt-on-ty-alias-w-generics.stderr b/tests/ui/borrowck/suggest-lt-on-ty-alias-w-generics.stderr index 28b4b4aa290..98fb49824ae 100644 --- a/tests/ui/borrowck/suggest-lt-on-ty-alias-w-generics.stderr +++ b/tests/ui/borrowck/suggest-lt-on-ty-alias-w-generics.stderr @@ -12,8 +12,9 @@ LL | | }) | help: to declare that the trait object captures data from argument `x`, you can add a lifetime parameter `'a` in the type alias | -LL | type Lazy<'a, T> = Box<dyn Fn() -> T + 'a>; - | +++ ~~ +LL - type Lazy<T> = Box<dyn Fn() -> T + 'static>; +LL + type Lazy<'a, T> = Box<dyn Fn() -> T + 'a>; + | error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function --> $DIR/suggest-lt-on-ty-alias-w-generics.rs:4:14 diff --git a/tests/ui/borrowck/unmatched-arg-and-hir-arg-issue-126385.stderr b/tests/ui/borrowck/unmatched-arg-and-hir-arg-issue-126385.stderr index 0ae301b2090..a18c4e72719 100644 --- a/tests/ui/borrowck/unmatched-arg-and-hir-arg-issue-126385.stderr +++ b/tests/ui/borrowck/unmatched-arg-and-hir-arg-issue-126385.stderr @@ -16,8 +16,9 @@ LL | impl MyStruct<'_> { | ----------------- `Self` is on type `MyStruct` in this `impl` help: the `Self` type doesn't accept type parameters, use the concrete type's name `MyStruct` instead if you want to specify its type parameters | -LL | pub fn f(field: &[u32]) -> MyStruct<u32> { - | ~~~~~~~~ +LL - pub fn f(field: &[u32]) -> Self<u32> { +LL + pub fn f(field: &[u32]) -> MyStruct<u32> { + | error: lifetime may not live long enough --> $DIR/unmatched-arg-and-hir-arg-issue-126385.rs:10:9 |
