-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// revisions: ast mir | ||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir | ||
|
||
static NUM: i32 = 18; | ||
|
||
fn main() { | ||
NUM = 20; //[ast]~ ERROR E0594 | ||
//[mir]~^ ERROR cannot assign to immutable static item (Ast) | ||
//[mir]~| ERROR cannot assign to immutable static item `NUM` (Mir) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,9 @@ | |
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// revisions: ast mir | ||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir | ||
|
||
use std::ops::{Index, IndexMut}; | ||
|
||
struct Foo { | ||
|
@@ -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) | ||
//[mir]~| ERROR cannot borrow `s` as immutable because it is also borrowed as mutable (Mir) | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. you can use |
||
//[mir]~| ERROR cannot borrow `s` as immutable because it is also borrowed as mutable (Mir) | ||
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 commentThe 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 |
||
// FIXME Error for MIR | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,13 +8,18 @@ | |
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// revisions: ast mir | ||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir | ||
|
||
struct TrieMapIterator<'a> { | ||
node: &'a usize | ||
} | ||
|
||
fn main() { | ||
let a = 5; | ||
let _iter = TrieMapIterator{node: &a}; | ||
_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 commentThe 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 |
||
panic!() | ||
} |
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~^^