Auto merge of #120393 - Urgau:rfc3373-non-local-defs, r=WaffleLapkin

Implement RFC 3373: Avoid non-local definitions in functions

This PR implements [RFC 3373: Avoid non-local definitions in functions](https://github.com/rust-lang/rust/issues/120363).
This commit is contained in:
bors 2024-02-25 19:11:06 +00:00
commit b8fb8907ba
20 changed files with 86 additions and 73 deletions

View file

@ -4,7 +4,7 @@
//@[disabled] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/undocumented_unsafe_blocks/disabled
#![warn(clippy::undocumented_unsafe_blocks, clippy::unnecessary_safety_comment)]
#![allow(deref_nullptr, clippy::let_unit_value, clippy::missing_safety_doc)]
#![allow(deref_nullptr, non_local_definitions, clippy::let_unit_value, clippy::missing_safety_doc)]
#![feature(lint_reasons)]
extern crate proc_macro_unsafe;

View file

@ -1,4 +1,4 @@
#![allow(clippy::needless_if)]
#![allow(non_local_definitions, clippy::needless_if)]
#![warn(clippy::bool_comparison)]
#![allow(clippy::non_canonical_partial_ord_impl)]

View file

@ -1,4 +1,4 @@
#![allow(clippy::needless_if)]
#![allow(non_local_definitions, clippy::needless_if)]
#![warn(clippy::bool_comparison)]
#![allow(clippy::non_canonical_partial_ord_impl)]

View file

@ -1,3 +1,5 @@
#![allow(non_local_definitions)]
const COUNT: usize = 2;
struct Thing;
trait Dummy {}

View file

@ -3,6 +3,7 @@
#![warn(clippy::use_self)]
#![allow(dead_code, clippy::let_with_type_underscore)]
#![allow(non_local_definitions)]
struct Foo;

View file

@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
#![warn(clippy::explicit_into_iter_loop)]
fn main() {

View file

@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
#![warn(clippy::explicit_into_iter_loop)]
fn main() {

View file

@ -1,5 +1,5 @@
error: it is more concise to loop over containers instead of using explicit iteration methods
--> $DIR/explicit_into_iter_loop.rs:9:18
--> $DIR/explicit_into_iter_loop.rs:10:18
|
LL | for _ in iterator.into_iter() {}
| ^^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `iterator`
@ -8,31 +8,31 @@ LL | for _ in iterator.into_iter() {}
= help: to override `-D warnings` add `#[allow(clippy::explicit_into_iter_loop)]`
error: it is more concise to loop over containers instead of using explicit iteration methods
--> $DIR/explicit_into_iter_loop.rs:22:14
--> $DIR/explicit_into_iter_loop.rs:23:14
|
LL | for _ in t.into_iter() {}
| ^^^^^^^^^^^^^ help: to write this more concisely, try: `&t`
error: it is more concise to loop over containers instead of using explicit iteration methods
--> $DIR/explicit_into_iter_loop.rs:25:14
--> $DIR/explicit_into_iter_loop.rs:26:14
|
LL | for _ in r.into_iter() {}
| ^^^^^^^^^^^^^ help: to write this more concisely, try: `r`
error: it is more concise to loop over containers instead of using explicit iteration methods
--> $DIR/explicit_into_iter_loop.rs:33:14
--> $DIR/explicit_into_iter_loop.rs:34:14
|
LL | for _ in mr.into_iter() {}
| ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&*mr`
error: it is more concise to loop over containers instead of using explicit iteration methods
--> $DIR/explicit_into_iter_loop.rs:45:14
--> $DIR/explicit_into_iter_loop.rs:46:14
|
LL | for _ in u.into_iter() {}
| ^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut u`
error: it is more concise to loop over containers instead of using explicit iteration methods
--> $DIR/explicit_into_iter_loop.rs:48:14
--> $DIR/explicit_into_iter_loop.rs:49:14
|
LL | for _ in mr.into_iter() {}
| ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut *mr`

View file

@ -5,7 +5,8 @@
clippy::needless_borrow,
clippy::deref_addrof,
clippy::unnecessary_mut_passed,
dead_code
dead_code,
non_local_definitions,
)]
use core::slice;

View file

@ -5,7 +5,8 @@
clippy::needless_borrow,
clippy::deref_addrof,
clippy::unnecessary_mut_passed,
dead_code
dead_code,
non_local_definitions,
)]
use core::slice;

View file

@ -1,5 +1,5 @@
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/explicit_iter_loop.rs:17:14
--> $DIR/explicit_iter_loop.rs:18:14
|
LL | for _ in vec.iter() {}
| ^^^^^^^^^^ help: to write this more concisely, try: `&vec`
@ -11,103 +11,103 @@ LL | #![deny(clippy::explicit_iter_loop)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/explicit_iter_loop.rs:18:14
--> $DIR/explicit_iter_loop.rs:19:14
|
LL | for _ in vec.iter_mut() {}
| ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut vec`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/explicit_iter_loop.rs:21:14
--> $DIR/explicit_iter_loop.rs:22:14
|
LL | for _ in rvec.iter() {}
| ^^^^^^^^^^^ help: to write this more concisely, try: `rvec`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/explicit_iter_loop.rs:30:14
--> $DIR/explicit_iter_loop.rs:31:14
|
LL | for _ in [1, 2, 3].iter() {}
| ^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[1, 2, 3]`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/explicit_iter_loop.rs:34:14
--> $DIR/explicit_iter_loop.rs:35:14
|
LL | for _ in [0; 32].iter() {}
| ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[0; 32]`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/explicit_iter_loop.rs:35:14
--> $DIR/explicit_iter_loop.rs:36:14
|
LL | for _ in [0; 33].iter() {}
| ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[0; 33]`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/explicit_iter_loop.rs:38:14
--> $DIR/explicit_iter_loop.rs:39:14
|
LL | for _ in ll.iter() {}
| ^^^^^^^^^ help: to write this more concisely, try: `&ll`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/explicit_iter_loop.rs:40:14
--> $DIR/explicit_iter_loop.rs:41:14
|
LL | for _ in rll.iter() {}
| ^^^^^^^^^^ help: to write this more concisely, try: `rll`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/explicit_iter_loop.rs:43:14
--> $DIR/explicit_iter_loop.rs:44:14
|
LL | for _ in vd.iter() {}
| ^^^^^^^^^ help: to write this more concisely, try: `&vd`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/explicit_iter_loop.rs:45:14
--> $DIR/explicit_iter_loop.rs:46:14
|
LL | for _ in rvd.iter() {}
| ^^^^^^^^^^ help: to write this more concisely, try: `rvd`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/explicit_iter_loop.rs:48:14
--> $DIR/explicit_iter_loop.rs:49:14
|
LL | for _ in bh.iter() {}
| ^^^^^^^^^ help: to write this more concisely, try: `&bh`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/explicit_iter_loop.rs:51:14
--> $DIR/explicit_iter_loop.rs:52:14
|
LL | for _ in hm.iter() {}
| ^^^^^^^^^ help: to write this more concisely, try: `&hm`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/explicit_iter_loop.rs:54:14
--> $DIR/explicit_iter_loop.rs:55:14
|
LL | for _ in bt.iter() {}
| ^^^^^^^^^ help: to write this more concisely, try: `&bt`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/explicit_iter_loop.rs:57:14
--> $DIR/explicit_iter_loop.rs:58:14
|
LL | for _ in hs.iter() {}
| ^^^^^^^^^ help: to write this more concisely, try: `&hs`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/explicit_iter_loop.rs:60:14
--> $DIR/explicit_iter_loop.rs:61:14
|
LL | for _ in bs.iter() {}
| ^^^^^^^^^ help: to write this more concisely, try: `&bs`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/explicit_iter_loop.rs:149:14
--> $DIR/explicit_iter_loop.rs:150:14
|
LL | for _ in x.iter() {}
| ^^^^^^^^ help: to write this more concisely, try: `&x`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/explicit_iter_loop.rs:150:14
--> $DIR/explicit_iter_loop.rs:151:14
|
LL | for _ in x.iter_mut() {}
| ^^^^^^^^^^^^ help: to write this more concisely, try: `&mut x`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/explicit_iter_loop.rs:153:14
--> $DIR/explicit_iter_loop.rs:154:14
|
LL | for _ in r.iter() {}
| ^^^^^^^^ help: to write this more concisely, try: `r`

View file

@ -1,5 +1,6 @@
#![feature(type_alias_impl_trait)]
#![warn(clippy::from_over_into)]
#![allow(non_local_definitions)]
#![allow(unused)]
// this should throw an error

View file

@ -1,5 +1,6 @@
#![feature(type_alias_impl_trait)]
#![warn(clippy::from_over_into)]
#![allow(non_local_definitions)]
#![allow(unused)]
// this should throw an error

View file

@ -1,5 +1,5 @@
error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
--> $DIR/from_over_into.rs:8:1
--> $DIR/from_over_into.rs:9:1
|
LL | impl Into<StringWrapper> for String {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -14,7 +14,7 @@ LL ~ StringWrapper(val)
|
error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
--> $DIR/from_over_into.rs:16:1
--> $DIR/from_over_into.rs:17:1
|
LL | impl Into<SelfType> for String {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -27,7 +27,7 @@ LL ~ SelfType(String::new())
|
error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
--> $DIR/from_over_into.rs:31:1
--> $DIR/from_over_into.rs:32:1
|
LL | impl Into<SelfKeywords> for X {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -42,7 +42,7 @@ LL ~ let _: X = val;
|
error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
--> $DIR/from_over_into.rs:43:1
--> $DIR/from_over_into.rs:44:1
|
LL | impl core::convert::Into<bool> for crate::ExplicitPaths {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -60,7 +60,7 @@ LL ~ val.0
|
error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
--> $DIR/from_over_into.rs:63:1
--> $DIR/from_over_into.rs:64:1
|
LL | impl Into<String> for PathInExpansion {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -74,7 +74,7 @@ LL ~ fn from(val: PathInExpansion) -> Self {
|
error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
--> $DIR/from_over_into.rs:85:5
--> $DIR/from_over_into.rs:86:5
|
LL | impl<T> Into<FromOverInto<T>> for Vec<T> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -87,7 +87,7 @@ LL ~ FromOverInto(val)
|
error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
--> $DIR/from_over_into.rs:95:5
--> $DIR/from_over_into.rs:96:5
|
LL | impl Into<()> for Hello {
| ^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
#![warn(clippy::manual_str_repeat)]
use std::borrow::Cow;

View file

@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
#![warn(clippy::manual_str_repeat)]
use std::borrow::Cow;

View file

@ -1,5 +1,5 @@
error: manual implementation of `str::repeat` using iterators
--> $DIR/manual_str_repeat.rs:7:21
--> $DIR/manual_str_repeat.rs:8:21
|
LL | let _: String = std::iter::repeat("test").take(10).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"test".repeat(10)`
@ -8,55 +8,55 @@ LL | let _: String = std::iter::repeat("test").take(10).collect();
= help: to override `-D warnings` add `#[allow(clippy::manual_str_repeat)]`
error: manual implementation of `str::repeat` using iterators
--> $DIR/manual_str_repeat.rs:8:21
--> $DIR/manual_str_repeat.rs:9:21
|
LL | let _: String = std::iter::repeat('x').take(10).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"x".repeat(10)`
error: manual implementation of `str::repeat` using iterators
--> $DIR/manual_str_repeat.rs:9:21
--> $DIR/manual_str_repeat.rs:10:21
|
LL | let _: String = std::iter::repeat('\'').take(10).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"'".repeat(10)`
error: manual implementation of `str::repeat` using iterators
--> $DIR/manual_str_repeat.rs:10:21
--> $DIR/manual_str_repeat.rs:11:21
|
LL | let _: String = std::iter::repeat('"').take(10).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"\"".repeat(10)`
error: manual implementation of `str::repeat` using iterators
--> $DIR/manual_str_repeat.rs:14:13
--> $DIR/manual_str_repeat.rs:15:13
|
LL | let _ = repeat(x).take(count + 2).collect::<String>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.repeat(count + 2)`
error: manual implementation of `str::repeat` using iterators
--> $DIR/manual_str_repeat.rs:23:21
--> $DIR/manual_str_repeat.rs:24:21
|
LL | let _: String = repeat(*x).take(count).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(*x).repeat(count)`
error: manual implementation of `str::repeat` using iterators
--> $DIR/manual_str_repeat.rs:32:21
--> $DIR/manual_str_repeat.rs:33:21
|
LL | let _: String = repeat(x).take(count).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.repeat(count)`
error: manual implementation of `str::repeat` using iterators
--> $DIR/manual_str_repeat.rs:44:21
--> $DIR/manual_str_repeat.rs:45:21
|
LL | let _: String = repeat(Cow::Borrowed("test")).take(count).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Cow::Borrowed("test").repeat(count)`
error: manual implementation of `str::repeat` using iterators
--> $DIR/manual_str_repeat.rs:47:21
--> $DIR/manual_str_repeat.rs:48:21
|
LL | let _: String = repeat(x).take(count).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.repeat(count)`
error: manual implementation of `str::repeat` using iterators
--> $DIR/manual_str_repeat.rs:62:21
--> $DIR/manual_str_repeat.rs:63:21
|
LL | let _: String = std::iter::repeat("test").take(10).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"test".repeat(10)`

View file

@ -1,6 +1,7 @@
#![feature(lint_reasons)]
#![allow(
unused,
non_local_definitions,
clippy::uninlined_format_args,
clippy::unnecessary_mut_passed,
clippy::unnecessary_to_owned,

View file

@ -1,6 +1,7 @@
#![feature(lint_reasons)]
#![allow(
unused,
non_local_definitions,
clippy::uninlined_format_args,
clippy::unnecessary_mut_passed,
clippy::unnecessary_to_owned,

View file

@ -1,5 +1,5 @@
error: this expression creates a reference which is immediately dereferenced by the compiler
--> $DIR/needless_borrow.rs:15:15
--> $DIR/needless_borrow.rs:16:15
|
LL | let _ = x(&&a); // warn
| ^^^ help: change this to: `&a`
@ -8,157 +8,157 @@ LL | let _ = x(&&a); // warn
= help: to override `-D warnings` add `#[allow(clippy::needless_borrow)]`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> $DIR/needless_borrow.rs:19:13
--> $DIR/needless_borrow.rs:20:13
|
LL | mut_ref(&mut &mut b); // warn
| ^^^^^^^^^^^ help: change this to: `&mut b`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> $DIR/needless_borrow.rs:31:13
--> $DIR/needless_borrow.rs:32:13
|
LL | &&a
| ^^^ help: change this to: `&a`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> $DIR/needless_borrow.rs:33:15
--> $DIR/needless_borrow.rs:34:15
|
LL | 46 => &&a,
| ^^^ help: change this to: `&a`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> $DIR/needless_borrow.rs:39:27
--> $DIR/needless_borrow.rs:40:27
|
LL | break &ref_a;
| ^^^^^^ help: change this to: `ref_a`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> $DIR/needless_borrow.rs:46:15
--> $DIR/needless_borrow.rs:47:15
|
LL | let _ = x(&&&a);
| ^^^^ help: change this to: `&a`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> $DIR/needless_borrow.rs:47:15
--> $DIR/needless_borrow.rs:48:15
|
LL | let _ = x(&mut &&a);
| ^^^^^^^^ help: change this to: `&a`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> $DIR/needless_borrow.rs:48:15
--> $DIR/needless_borrow.rs:49:15
|
LL | let _ = x(&&&mut b);
| ^^^^^^^^ help: change this to: `&mut b`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> $DIR/needless_borrow.rs:49:15
--> $DIR/needless_borrow.rs:50:15
|
LL | let _ = x(&&ref_a);
| ^^^^^^^ help: change this to: `ref_a`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> $DIR/needless_borrow.rs:52:11
--> $DIR/needless_borrow.rs:53:11
|
LL | x(&b);
| ^^ help: change this to: `b`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> $DIR/needless_borrow.rs:59:13
--> $DIR/needless_borrow.rs:60:13
|
LL | mut_ref(&mut x);
| ^^^^^^ help: change this to: `x`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> $DIR/needless_borrow.rs:60:13
--> $DIR/needless_borrow.rs:61:13
|
LL | mut_ref(&mut &mut x);
| ^^^^^^^^^^^ help: change this to: `x`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> $DIR/needless_borrow.rs:61:23
--> $DIR/needless_borrow.rs:62:23
|
LL | let y: &mut i32 = &mut x;
| ^^^^^^ help: change this to: `x`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> $DIR/needless_borrow.rs:62:23
--> $DIR/needless_borrow.rs:63:23
|
LL | let y: &mut i32 = &mut &mut x;
| ^^^^^^^^^^^ help: change this to: `x`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> $DIR/needless_borrow.rs:71:14
--> $DIR/needless_borrow.rs:72:14
|
LL | 0 => &mut x,
| ^^^^^^ help: change this to: `x`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> $DIR/needless_borrow.rs:77:14
--> $DIR/needless_borrow.rs:78:14
|
LL | 0 => &mut x,
| ^^^^^^ help: change this to: `x`
error: this expression borrows a value the compiler would automatically borrow
--> $DIR/needless_borrow.rs:89:13
--> $DIR/needless_borrow.rs:90:13
|
LL | let _ = (&x).0;
| ^^^^ help: change this to: `x`
error: this expression borrows a value the compiler would automatically borrow
--> $DIR/needless_borrow.rs:91:22
--> $DIR/needless_borrow.rs:92:22
|
LL | let _ = unsafe { (&*x).0 };
| ^^^^^ help: change this to: `(*x)`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> $DIR/needless_borrow.rs:101:5
--> $DIR/needless_borrow.rs:102:5
|
LL | (&&()).foo();
| ^^^^^^ help: change this to: `(&())`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> $DIR/needless_borrow.rs:110:5
--> $DIR/needless_borrow.rs:111:5
|
LL | (&&5).foo();
| ^^^^^ help: change this to: `(&5)`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> $DIR/needless_borrow.rs:136:23
--> $DIR/needless_borrow.rs:137:23
|
LL | let x: (&str,) = (&"",);
| ^^^ help: change this to: `""`
error: this expression borrows a value the compiler would automatically borrow
--> $DIR/needless_borrow.rs:178:13
--> $DIR/needless_borrow.rs:179:13
|
LL | (&self.f)()
| ^^^^^^^^^ help: change this to: `(self.f)`
error: this expression borrows a value the compiler would automatically borrow
--> $DIR/needless_borrow.rs:187:13
--> $DIR/needless_borrow.rs:188:13
|
LL | (&mut self.f)()
| ^^^^^^^^^^^^^ help: change this to: `(self.f)`
error: this expression borrows a value the compiler would automatically borrow
--> $DIR/needless_borrow.rs:224:22
--> $DIR/needless_borrow.rs:225:22
|
LL | let _ = &mut (&mut { x.u }).x;
| ^^^^^^^^^^^^^^ help: change this to: `{ x.u }`
error: this expression borrows a value the compiler would automatically borrow
--> $DIR/needless_borrow.rs:231:22
--> $DIR/needless_borrow.rs:232:22
|
LL | let _ = &mut (&mut { x.u }).x;
| ^^^^^^^^^^^^^^ help: change this to: `{ x.u }`
error: this expression borrows a value the compiler would automatically borrow
--> $DIR/needless_borrow.rs:235:22
--> $DIR/needless_borrow.rs:236:22
|
LL | let _ = &mut (&mut x.u).x;
| ^^^^^^^^^^ help: change this to: `x.u`
error: this expression borrows a value the compiler would automatically borrow
--> $DIR/needless_borrow.rs:236:22
--> $DIR/needless_borrow.rs:237:22
|
LL | let _ = &mut (&mut { x.u }).x;
| ^^^^^^^^^^^^^^ help: change this to: `{ x.u }`