-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Remove mutable_borrow_reservation_conflict lint and allow the code pattern #96268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2345,40 +2345,6 @@ declare_lint! { | |
}; | ||
} | ||
|
||
declare_lint! { | ||
/// The `mutable_borrow_reservation_conflict` lint detects the reservation | ||
/// of a two-phased borrow that conflicts with other shared borrows. | ||
/// | ||
/// ### Example | ||
/// | ||
/// ```rust | ||
/// let mut v = vec![0, 1, 2]; | ||
/// let shared = &v; | ||
/// v.push(shared.len()); | ||
/// ``` | ||
/// | ||
/// {{produces}} | ||
/// | ||
/// ### Explanation | ||
/// | ||
/// This is a [future-incompatible] lint to transition this to a hard error | ||
/// in the future. See [issue #59159] for a complete description of the | ||
/// problem, and some possible solutions. | ||
/// | ||
/// [issue #59159]: https://github.com/rust-lang/rust/issues/59159 | ||
/// [future-incompatible]: ../index.md#future-incompatible-lints | ||
pub MUTABLE_BORROW_RESERVATION_CONFLICT, | ||
Warn, | ||
"reservation of a two-phased borrow conflicts with other shared borrows", | ||
@future_incompatible = FutureIncompatibleInfo { | ||
reason: FutureIncompatibilityReason::Custom( | ||
"this borrowing pattern was not meant to be accepted, \ | ||
and may become a hard error in the future" | ||
), | ||
reference: "issue #59159 <https://github.com/rust-lang/rust/issues/59159>", | ||
}; | ||
} | ||
|
||
declare_lint! { | ||
/// The `soft_unstable` lint detects unstable features that were | ||
/// unintentionally allowed on stable. | ||
|
@@ -3179,7 +3145,6 @@ declare_lint_pass! { | |
META_VARIABLE_MISUSE, | ||
DEPRECATED_IN_FUTURE, | ||
AMBIGUOUS_ASSOCIATED_ITEMS, | ||
MUTABLE_BORROW_RESERVATION_CONFLICT, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we don't normally remove these altogether but rather move them to some list of deprecated lints ... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It gets registered as removed here: https://github.com/rust-lang/rust/pull/96268/files#diff-cfb1d20a5949dd50b9769edb62eaf10a0de66734637fe71d35bdcf8fb06d767bR494 |
||
INDIRECT_STRUCTURAL_MATCH, | ||
POINTER_STRUCTURAL_MATCH, | ||
NONTRIVIAL_STRUCTURAL_MATCH, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable | ||
--> $DIR/two-phase-reservation-sharing-interference-2.rs:19:5 | ||
| | ||
LL | let shared = &v; | ||
| -- immutable borrow occurs here | ||
LL | | ||
LL | v.extend(shared); | ||
| ^^------^^^^^^^^ | ||
| | | | ||
| | immutable borrow later used by call | ||
| mutable borrow occurs here | ||
|
||
error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable | ||
--> $DIR/two-phase-reservation-sharing-interference-2.rs:27:5 | ||
| | ||
LL | v.extend(&v); | ||
| ^^------^--^ | ||
| | | | | ||
| | | immutable borrow occurs here | ||
| | immutable borrow later used by call | ||
| mutable borrow occurs here | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0502`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable | ||
--> $DIR/two-phase-reservation-sharing-interference-2.rs:19:5 | ||
| | ||
LL | let shared = &v; | ||
| -- immutable borrow occurs here | ||
LL | | ||
LL | v.extend(shared); | ||
| ^^------^^^^^^^^ | ||
| | | | ||
| | immutable borrow later used by call | ||
| mutable borrow occurs here | ||
|
||
error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable | ||
--> $DIR/two-phase-reservation-sharing-interference-2.rs:27:5 | ||
| | ||
LL | v.extend(&v); | ||
| ^^------^--^ | ||
| | | | | ||
| | | immutable borrow occurs here | ||
| | immutable borrow later used by call | ||
| mutable borrow occurs here | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0502`. |
Uh oh!
There was an error while loading. Please reload this page.