-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
MIR borrowck: move span_label to borrowck_errors.rs
#44922
Conversation
… inside `borrowck_errors.rs`
…owed()` inside `borrowck_errors.rs`
…tween AST and MIR borrowck
(rust_highfive has picked a reviewer for you, use r? to override) |
@@ -57,12 +60,18 @@ fn main() { | |||
let mut s = "hello".to_string(); | |||
let rs = &mut s; | |||
println!("{}", f[&s]); | |||
//~^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable | |||
//[ast]~^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable | |||
//[mir]~^^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable (Ast) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use ~|
here instead of ~^^
f[&s] = 10; | ||
//~^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable | ||
//[ast]~^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable | ||
//[mir]~^^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable (Ast) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use ~|
here instead of ~^^
_iter.node = & //~ ERROR cannot assign to immutable field | ||
_iter.node = & //[ast]~ ERROR cannot assign to immutable field | ||
//[mir]~^ ERROR cannot assign to immutable field `_iter.node` (Ast) | ||
// FIXME Error for MIR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooh looks like a new mir-borrowck unsoundness bug we need to file
let s = Bar { | ||
x: 1, | ||
}; | ||
s[2] = 20; | ||
//~^ ERROR cannot assign to immutable indexed content | ||
//[ast]~^ ERROR cannot assign to immutable indexed content | ||
//[mir]~^^ ERROR cannot assign to immutable indexed content |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there no "(Ast)" suffix emitted here? If so, then it might be the case that the error being generated here is not the responsibility of mir-borrowck. (This is part of a broad category of things that need investigation, the cases where the emitted error is missing its "(Origin)" annotation and thus it is unclear which component is actually detecting the error when we run under -Z borrowck-mir
.
The refactoring looks fine to me. I had some nits that I noted above, but I don't think any of them are worth blocking landing this PR. |
@bors r+ |
📌 Commit d328d26 has been approved by |
MIR borrowck: move span_label to `borrowck_errors.rs` The calls to `span_label` are moved and factorized for: * E0503 (`cannot_use_when_mutably_borrowed()`) * E0506 (`cannot_assign_to_borrowed()`) Additionnally, the error E0594 (`cannot_assign_static()`) has been factorized between `check_loan.rs` and `borrowc_check.rs`. Part of #44596
💔 Test failed - status-appveyor |
@bors retry For the record @nagisa has previously pointed out that this may be evidence of a spurious test failure, see also #44906 (comment) |
r? @pnkfelix |
Spurious failure issue: #43402 |
@bors retry |
MIR borrowck: move span_label to `borrowck_errors.rs` The calls to `span_label` are moved and factorized for: * E0503 (`cannot_use_when_mutably_borrowed()`) * E0506 (`cannot_assign_to_borrowed()`) Additionnally, the error E0594 (`cannot_assign_static()`) has been factorized between `check_loan.rs` and `borrowc_check.rs`. Part of #44596
☀️ Test successful - status-appveyor, status-travis |
The calls to
span_label
are moved and factorized for:cannot_use_when_mutably_borrowed()
)cannot_assign_to_borrowed()
)Additionnally, the error E0594 (
cannot_assign_static()
) has been factorized betweencheck_loan.rs
andborrowc_check.rs
.Part of #44596