Auto merge of #46106 - est31:master, r=nikomatsakis
Add a MIR-borrowck-only output mode Removes the `-Z borrowck-mir` flag in favour of a `-Z borrowck=mode` flag where mode can be `mir`, `ast`, or `compare`. * The `ast` mode represents the current default, passing `-Z borrowck=ast` is equivalent to not passing it at all. * The `compare` mode outputs both the output of the MIR borrow checker and the AST borrow checker, each error with `(Ast)` and `(Mir)` appended. This mode has the same behaviour as `-Z borrowck-mir` had before this commit. * The `mir` mode only outputs the results of the MIR borrow checker, while suppressing the errors of the ast borrow checker The PR also updates the tests to use the new flags. closes #46097
This commit is contained in:
commit
827cb0d61e
62 changed files with 354 additions and 373 deletions
|
@ -362,6 +362,9 @@ top_level_options!(
|
||||||
|
|
||||||
debugging_opts: DebuggingOptions [TRACKED],
|
debugging_opts: DebuggingOptions [TRACKED],
|
||||||
prints: Vec<PrintRequest> [UNTRACKED],
|
prints: Vec<PrintRequest> [UNTRACKED],
|
||||||
|
// Determines which borrow checker(s) to run. This is the parsed, sanitized
|
||||||
|
// version of `debugging_opts.borrowck`, which is just a plain string.
|
||||||
|
borrowck_mode: BorrowckMode [UNTRACKED],
|
||||||
cg: CodegenOptions [TRACKED],
|
cg: CodegenOptions [TRACKED],
|
||||||
// FIXME(mw): We track this for now but it actually doesn't make too
|
// FIXME(mw): We track this for now but it actually doesn't make too
|
||||||
// much sense: The value of this option can stay the same
|
// much sense: The value of this option can stay the same
|
||||||
|
@ -401,6 +404,32 @@ pub enum PrintRequest {
|
||||||
NativeStaticLibs,
|
NativeStaticLibs,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
pub enum BorrowckMode {
|
||||||
|
Ast,
|
||||||
|
Mir,
|
||||||
|
Compare,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BorrowckMode {
|
||||||
|
/// Should we emit the AST-based borrow checker errors?
|
||||||
|
pub fn use_ast(self) -> bool {
|
||||||
|
match self {
|
||||||
|
BorrowckMode::Ast => true,
|
||||||
|
BorrowckMode::Compare => true,
|
||||||
|
BorrowckMode::Mir => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// Should we emit the MIR-based borrow checker errors?
|
||||||
|
pub fn use_mir(self) -> bool {
|
||||||
|
match self {
|
||||||
|
BorrowckMode::Ast => false,
|
||||||
|
BorrowckMode::Compare => true,
|
||||||
|
BorrowckMode::Mir => true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub enum Input {
|
pub enum Input {
|
||||||
/// Load source from file
|
/// Load source from file
|
||||||
File(PathBuf),
|
File(PathBuf),
|
||||||
|
@ -526,6 +555,7 @@ pub fn basic_options() -> Options {
|
||||||
incremental: None,
|
incremental: None,
|
||||||
debugging_opts: basic_debugging_options(),
|
debugging_opts: basic_debugging_options(),
|
||||||
prints: Vec::new(),
|
prints: Vec::new(),
|
||||||
|
borrowck_mode: BorrowckMode::Ast,
|
||||||
cg: basic_codegen_options(),
|
cg: basic_codegen_options(),
|
||||||
error_format: ErrorOutputType::default(),
|
error_format: ErrorOutputType::default(),
|
||||||
externs: Externs(BTreeMap::new()),
|
externs: Externs(BTreeMap::new()),
|
||||||
|
@ -973,8 +1003,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
|
||||||
"make unnamed regions display as '# (where # is some non-ident unique id)"),
|
"make unnamed regions display as '# (where # is some non-ident unique id)"),
|
||||||
emit_end_regions: bool = (false, parse_bool, [UNTRACKED],
|
emit_end_regions: bool = (false, parse_bool, [UNTRACKED],
|
||||||
"emit EndRegion as part of MIR; enable transforms that solely process EndRegion"),
|
"emit EndRegion as part of MIR; enable transforms that solely process EndRegion"),
|
||||||
borrowck_mir: bool = (false, parse_bool, [UNTRACKED],
|
borrowck: Option<String> = (None, parse_opt_string, [UNTRACKED],
|
||||||
"implicitly treat functions as if they have `#[rustc_mir_borrowck]` attribute"),
|
"select which borrowck is used (`ast`, `mir`, or `compare`)"),
|
||||||
time_passes: bool = (false, parse_bool, [UNTRACKED],
|
time_passes: bool = (false, parse_bool, [UNTRACKED],
|
||||||
"measure time of each rustc pass"),
|
"measure time of each rustc pass"),
|
||||||
count_llvm_insns: bool = (false, parse_bool,
|
count_llvm_insns: bool = (false, parse_bool,
|
||||||
|
@ -1743,6 +1773,15 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
let borrowck_mode = match debugging_opts.borrowck.as_ref().map(|s| &s[..]) {
|
||||||
|
None | Some("ast") => BorrowckMode::Ast,
|
||||||
|
Some("mir") => BorrowckMode::Mir,
|
||||||
|
Some("compare") => BorrowckMode::Compare,
|
||||||
|
Some(m) => {
|
||||||
|
early_error(error_format, &format!("unknown borrowck mode `{}`", m))
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
if !cg.remark.is_empty() && debuginfo == NoDebugInfo {
|
if !cg.remark.is_empty() && debuginfo == NoDebugInfo {
|
||||||
early_warn(error_format, "-C remark will not show source locations without \
|
early_warn(error_format, "-C remark will not show source locations without \
|
||||||
--debuginfo");
|
--debuginfo");
|
||||||
|
@ -1784,6 +1823,7 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
|
||||||
incremental,
|
incremental,
|
||||||
debugging_opts,
|
debugging_opts,
|
||||||
prints,
|
prints,
|
||||||
|
borrowck_mode,
|
||||||
cg,
|
cg,
|
||||||
error_format,
|
error_format,
|
||||||
externs: Externs(externs),
|
externs: Externs(externs),
|
||||||
|
|
|
@ -416,7 +416,7 @@ impl Session {
|
||||||
pub fn emit_end_regions(&self) -> bool {
|
pub fn emit_end_regions(&self) -> bool {
|
||||||
self.opts.debugging_opts.emit_end_regions ||
|
self.opts.debugging_opts.emit_end_regions ||
|
||||||
(self.opts.debugging_opts.mir_emit_validate > 0) ||
|
(self.opts.debugging_opts.mir_emit_validate > 0) ||
|
||||||
self.opts.debugging_opts.borrowck_mir
|
self.opts.borrowck_mode.use_mir()
|
||||||
}
|
}
|
||||||
pub fn lto(&self) -> bool {
|
pub fn lto(&self) -> bool {
|
||||||
self.opts.cg.lto || self.target.target.options.requires_lto
|
self.opts.cg.lto || self.target.target.options.requires_lto
|
||||||
|
|
|
@ -269,6 +269,17 @@ impl<'b, 'tcx: 'b> BorrowckErrors for BorrowckCtxt<'b, 'tcx> {
|
||||||
{
|
{
|
||||||
self.tcx.sess.struct_span_err(sp, msg)
|
self.tcx.sess.struct_span_err(sp, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn cancel_if_wrong_origin<'a>(&'a self,
|
||||||
|
mut diag: DiagnosticBuilder<'a>,
|
||||||
|
o: Origin)
|
||||||
|
-> DiagnosticBuilder<'a>
|
||||||
|
{
|
||||||
|
if !o.should_emit_errors(self.tcx.sess.opts.borrowck_mode) {
|
||||||
|
self.tcx.sess.diagnostic().cancel(&mut diag);
|
||||||
|
}
|
||||||
|
diag
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -54,7 +54,7 @@ fn mir_borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
|
||||||
|
|
||||||
if {
|
if {
|
||||||
!tcx.has_attr(def_id, "rustc_mir_borrowck") &&
|
!tcx.has_attr(def_id, "rustc_mir_borrowck") &&
|
||||||
!tcx.sess.opts.debugging_opts.borrowck_mir &&
|
!tcx.sess.opts.borrowck_mode.use_mir() &&
|
||||||
!tcx.sess.opts.debugging_opts.nll
|
!tcx.sess.opts.debugging_opts.nll
|
||||||
} {
|
} {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use rustc::ty::{self, TyCtxt};
|
use rustc::ty::{self, TyCtxt};
|
||||||
|
use rustc::session::config::BorrowckMode;
|
||||||
use rustc_errors::{DiagnosticBuilder, DiagnosticId};
|
use rustc_errors::{DiagnosticBuilder, DiagnosticId};
|
||||||
use syntax_pos::{MultiSpan, Span};
|
use syntax_pos::{MultiSpan, Span};
|
||||||
|
|
||||||
|
@ -19,20 +20,34 @@ pub enum Origin { Ast, Mir }
|
||||||
|
|
||||||
impl fmt::Display for Origin {
|
impl fmt::Display for Origin {
|
||||||
fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match *self {
|
// If the user passed `-Z borrowck=compare`, then include
|
||||||
Origin::Mir => write!(w, " (Mir)"),
|
// origin info as part of the error report,
|
||||||
Origin::Ast => ty::tls::with_opt(|opt_tcx| {
|
// otherwise
|
||||||
// If user passed `-Z borrowck-mir`, then include an
|
let display_origin = ty::tls::with_opt(|opt_tcx| {
|
||||||
// AST origin as part of the error report
|
if let Some(tcx) = opt_tcx {
|
||||||
if let Some(tcx) = opt_tcx {
|
tcx.sess.opts.borrowck_mode == BorrowckMode::Compare
|
||||||
if tcx.sess.opts.debugging_opts.borrowck_mir {
|
} else {
|
||||||
return write!(w, " (Ast)");
|
false
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
// otherwise, do not include the origin (i.e., print
|
if display_origin {
|
||||||
// nothing at all)
|
match *self {
|
||||||
Ok(())
|
Origin::Mir => write!(w, " (Mir)"),
|
||||||
}),
|
Origin::Ast => write!(w, " (Ast)"),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Print no origin info
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Origin {
|
||||||
|
/// Whether we should emit errors for the origin in the given mode
|
||||||
|
pub fn should_emit_errors(self, mode: BorrowckMode) -> bool {
|
||||||
|
match self {
|
||||||
|
Origin::Ast => mode.use_ast(),
|
||||||
|
Origin::Mir => mode.use_mir(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,12 +64,23 @@ pub trait BorrowckErrors {
|
||||||
msg: &str)
|
msg: &str)
|
||||||
-> DiagnosticBuilder<'a>;
|
-> DiagnosticBuilder<'a>;
|
||||||
|
|
||||||
|
/// Cancels the given error if we shouldn't emit errors for a given
|
||||||
|
/// origin in the current mode.
|
||||||
|
///
|
||||||
|
/// Always make sure that the error gets passed through this function
|
||||||
|
/// before you return it.
|
||||||
|
fn cancel_if_wrong_origin<'a>(&'a self,
|
||||||
|
diag: DiagnosticBuilder<'a>,
|
||||||
|
o: Origin)
|
||||||
|
-> DiagnosticBuilder<'a>;
|
||||||
|
|
||||||
fn cannot_move_when_borrowed(&self, span: Span, desc: &str, o: Origin)
|
fn cannot_move_when_borrowed(&self, span: Span, desc: &str, o: Origin)
|
||||||
-> DiagnosticBuilder
|
-> DiagnosticBuilder
|
||||||
{
|
{
|
||||||
struct_span_err!(self, span, E0505,
|
let err = struct_span_err!(self, span, E0505,
|
||||||
"cannot move out of `{}` because it is borrowed{OGN}",
|
"cannot move out of `{}` because it is borrowed{OGN}",
|
||||||
desc, OGN=o)
|
desc, OGN=o);
|
||||||
|
self.cancel_if_wrong_origin(err, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cannot_use_when_mutably_borrowed(&self,
|
fn cannot_use_when_mutably_borrowed(&self,
|
||||||
|
@ -72,7 +98,7 @@ pub trait BorrowckErrors {
|
||||||
err.span_label(borrow_span, format!("borrow of `{}` occurs here", borrow_desc));
|
err.span_label(borrow_span, format!("borrow of `{}` occurs here", borrow_desc));
|
||||||
err.span_label(span, format!("use of borrowed `{}`", borrow_desc));
|
err.span_label(span, format!("use of borrowed `{}`", borrow_desc));
|
||||||
|
|
||||||
err
|
self.cancel_if_wrong_origin(err, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cannot_act_on_uninitialized_variable(&self,
|
fn cannot_act_on_uninitialized_variable(&self,
|
||||||
|
@ -82,9 +108,10 @@ pub trait BorrowckErrors {
|
||||||
o: Origin)
|
o: Origin)
|
||||||
-> DiagnosticBuilder
|
-> DiagnosticBuilder
|
||||||
{
|
{
|
||||||
struct_span_err!(self, span, E0381,
|
let err = struct_span_err!(self, span, E0381,
|
||||||
"{} of possibly uninitialized variable: `{}`{OGN}",
|
"{} of possibly uninitialized variable: `{}`{OGN}",
|
||||||
verb, desc, OGN=o)
|
verb, desc, OGN=o);
|
||||||
|
self.cancel_if_wrong_origin(err, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cannot_mutably_borrow_multiply(&self,
|
fn cannot_mutably_borrow_multiply(&self,
|
||||||
|
@ -118,7 +145,7 @@ pub trait BorrowckErrors {
|
||||||
err.span_label(old_load_end_span, "first borrow ends here");
|
err.span_label(old_load_end_span, "first borrow ends here");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err
|
self.cancel_if_wrong_origin(err, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cannot_uniquely_borrow_by_two_closures(&self,
|
fn cannot_uniquely_borrow_by_two_closures(&self,
|
||||||
|
@ -143,7 +170,7 @@ pub trait BorrowckErrors {
|
||||||
old_load_end_span,
|
old_load_end_span,
|
||||||
"borrow from first closure ends here");
|
"borrow from first closure ends here");
|
||||||
}
|
}
|
||||||
err
|
self.cancel_if_wrong_origin(err, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cannot_uniquely_borrow_by_one_closure(&self,
|
fn cannot_uniquely_borrow_by_one_closure(&self,
|
||||||
|
@ -167,7 +194,7 @@ pub trait BorrowckErrors {
|
||||||
if let Some(previous_end_span) = previous_end_span {
|
if let Some(previous_end_span) = previous_end_span {
|
||||||
err.span_label(previous_end_span, "borrow ends here");
|
err.span_label(previous_end_span, "borrow ends here");
|
||||||
}
|
}
|
||||||
err
|
self.cancel_if_wrong_origin(err, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cannot_reborrow_already_uniquely_borrowed(&self,
|
fn cannot_reborrow_already_uniquely_borrowed(&self,
|
||||||
|
@ -192,7 +219,7 @@ pub trait BorrowckErrors {
|
||||||
if let Some(previous_end_span) = previous_end_span {
|
if let Some(previous_end_span) = previous_end_span {
|
||||||
err.span_label(previous_end_span, "borrow from closure ends here");
|
err.span_label(previous_end_span, "borrow from closure ends here");
|
||||||
}
|
}
|
||||||
err
|
self.cancel_if_wrong_origin(err, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cannot_reborrow_already_borrowed(&self,
|
fn cannot_reborrow_already_borrowed(&self,
|
||||||
|
@ -216,7 +243,7 @@ pub trait BorrowckErrors {
|
||||||
if let Some(old_load_end_span) = old_load_end_span {
|
if let Some(old_load_end_span) = old_load_end_span {
|
||||||
err.span_label(old_load_end_span, format!("{} borrow ends here", kind_old));
|
err.span_label(old_load_end_span, format!("{} borrow ends here", kind_old));
|
||||||
}
|
}
|
||||||
err
|
self.cancel_if_wrong_origin(err, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cannot_assign_to_borrowed(&self, span: Span, borrow_span: Span, desc: &str, o: Origin)
|
fn cannot_assign_to_borrowed(&self, span: Span, borrow_span: Span, desc: &str, o: Origin)
|
||||||
|
@ -229,30 +256,35 @@ pub trait BorrowckErrors {
|
||||||
err.span_label(borrow_span, format!("borrow of `{}` occurs here", desc));
|
err.span_label(borrow_span, format!("borrow of `{}` occurs here", desc));
|
||||||
err.span_label(span, format!("assignment to borrowed `{}` occurs here", desc));
|
err.span_label(span, format!("assignment to borrowed `{}` occurs here", desc));
|
||||||
|
|
||||||
err
|
self.cancel_if_wrong_origin(err, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cannot_move_into_closure(&self, span: Span, desc: &str, o: Origin)
|
fn cannot_move_into_closure(&self, span: Span, desc: &str, o: Origin)
|
||||||
-> DiagnosticBuilder
|
-> DiagnosticBuilder
|
||||||
{
|
{
|
||||||
struct_span_err!(self, span, E0504,
|
let err = struct_span_err!(self, span, E0504,
|
||||||
"cannot move `{}` into closure because it is borrowed{OGN}",
|
"cannot move `{}` into closure because it is borrowed{OGN}",
|
||||||
desc, OGN=o)
|
desc, OGN=o);
|
||||||
|
|
||||||
|
self.cancel_if_wrong_origin(err, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cannot_reassign_immutable(&self, span: Span, desc: &str, o: Origin)
|
fn cannot_reassign_immutable(&self, span: Span, desc: &str, o: Origin)
|
||||||
-> DiagnosticBuilder
|
-> DiagnosticBuilder
|
||||||
{
|
{
|
||||||
struct_span_err!(self, span, E0384,
|
let err = struct_span_err!(self, span, E0384,
|
||||||
"cannot assign twice to immutable variable `{}`{OGN}",
|
"cannot assign twice to immutable variable `{}`{OGN}",
|
||||||
desc, OGN=o)
|
desc, OGN=o);
|
||||||
|
|
||||||
|
self.cancel_if_wrong_origin(err, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cannot_assign(&self, span: Span, desc: &str, o: Origin) -> DiagnosticBuilder
|
fn cannot_assign(&self, span: Span, desc: &str, o: Origin) -> DiagnosticBuilder
|
||||||
{
|
{
|
||||||
struct_span_err!(self, span, E0594,
|
let err = struct_span_err!(self, span, E0594,
|
||||||
"cannot assign to {}{OGN}",
|
"cannot assign to {}{OGN}",
|
||||||
desc, OGN=o)
|
desc, OGN=o);
|
||||||
|
self.cancel_if_wrong_origin(err, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cannot_assign_static(&self, span: Span, desc: &str, o: Origin)
|
fn cannot_assign_static(&self, span: Span, desc: &str, o: Origin)
|
||||||
|
@ -270,7 +302,8 @@ pub trait BorrowckErrors {
|
||||||
err.span_label(
|
err.span_label(
|
||||||
move_from_span,
|
move_from_span,
|
||||||
format!("cannot move out of {}", move_from_desc));
|
format!("cannot move out of {}", move_from_desc));
|
||||||
err
|
|
||||||
|
self.cancel_if_wrong_origin(err, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cannot_move_out_of_interior_noncopy(&self,
|
fn cannot_move_out_of_interior_noncopy(&self,
|
||||||
|
@ -290,7 +323,8 @@ pub trait BorrowckErrors {
|
||||||
a non-copy {}{OGN}",
|
a non-copy {}{OGN}",
|
||||||
ty, type_name, OGN=o);
|
ty, type_name, OGN=o);
|
||||||
err.span_label(move_from_span, "cannot move out of here");
|
err.span_label(move_from_span, "cannot move out of here");
|
||||||
err
|
|
||||||
|
self.cancel_if_wrong_origin(err, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cannot_move_out_of_interior_of_drop(&self,
|
fn cannot_move_out_of_interior_of_drop(&self,
|
||||||
|
@ -304,7 +338,8 @@ pub trait BorrowckErrors {
|
||||||
which implements the `Drop` trait{OGN}",
|
which implements the `Drop` trait{OGN}",
|
||||||
container_ty, OGN=o);
|
container_ty, OGN=o);
|
||||||
err.span_label(move_from_span, "cannot move out of here");
|
err.span_label(move_from_span, "cannot move out of here");
|
||||||
err
|
|
||||||
|
self.cancel_if_wrong_origin(err, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cannot_act_on_moved_value(&self,
|
fn cannot_act_on_moved_value(&self,
|
||||||
|
@ -318,7 +353,8 @@ pub trait BorrowckErrors {
|
||||||
let err = struct_span_err!(self, use_span, E0382,
|
let err = struct_span_err!(self, use_span, E0382,
|
||||||
"{} of {}moved value: `{}`{OGN}",
|
"{} of {}moved value: `{}`{OGN}",
|
||||||
verb, optional_adverb_for_moved, moved_path, OGN=o);
|
verb, optional_adverb_for_moved, moved_path, OGN=o);
|
||||||
err
|
|
||||||
|
self.cancel_if_wrong_origin(err, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cannot_partially_reinit_an_uninit_struct(&self,
|
fn cannot_partially_reinit_an_uninit_struct(&self,
|
||||||
|
@ -332,7 +368,8 @@ pub trait BorrowckErrors {
|
||||||
E0383,
|
E0383,
|
||||||
"partial reinitialization of uninitialized structure `{}`{OGN}",
|
"partial reinitialization of uninitialized structure `{}`{OGN}",
|
||||||
uninit_path, OGN=o);
|
uninit_path, OGN=o);
|
||||||
err
|
|
||||||
|
self.cancel_if_wrong_origin(err, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn closure_cannot_assign_to_borrowed(&self,
|
fn closure_cannot_assign_to_borrowed(&self,
|
||||||
|
@ -343,7 +380,8 @@ pub trait BorrowckErrors {
|
||||||
{
|
{
|
||||||
let err = struct_span_err!(self, span, E0595, "closure cannot assign to {}{OGN}",
|
let err = struct_span_err!(self, span, E0595, "closure cannot assign to {}{OGN}",
|
||||||
descr, OGN=o);
|
descr, OGN=o);
|
||||||
err
|
|
||||||
|
self.cancel_if_wrong_origin(err, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cannot_borrow_path_as_mutable(&self,
|
fn cannot_borrow_path_as_mutable(&self,
|
||||||
|
@ -354,7 +392,8 @@ pub trait BorrowckErrors {
|
||||||
{
|
{
|
||||||
let err = struct_span_err!(self, span, E0596, "cannot borrow {} as mutable{OGN}",
|
let err = struct_span_err!(self, span, E0596, "cannot borrow {} as mutable{OGN}",
|
||||||
path, OGN=o);
|
path, OGN=o);
|
||||||
err
|
|
||||||
|
self.cancel_if_wrong_origin(err, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cannot_borrow_across_generator_yield(&self,
|
fn cannot_borrow_across_generator_yield(&self,
|
||||||
|
@ -369,7 +408,8 @@ pub trait BorrowckErrors {
|
||||||
"borrow may still be in use when generator yields{OGN}",
|
"borrow may still be in use when generator yields{OGN}",
|
||||||
OGN=o);
|
OGN=o);
|
||||||
err.span_label(yield_span, "possible yield occurs here");
|
err.span_label(yield_span, "possible yield occurs here");
|
||||||
err
|
|
||||||
|
self.cancel_if_wrong_origin(err, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn path_does_not_live_long_enough(&self,
|
fn path_does_not_live_long_enough(&self,
|
||||||
|
@ -380,7 +420,8 @@ pub trait BorrowckErrors {
|
||||||
{
|
{
|
||||||
let err = struct_span_err!(self, span, E0597, "{} does not live long enough{OGN}",
|
let err = struct_span_err!(self, span, E0597, "{} does not live long enough{OGN}",
|
||||||
path, OGN=o);
|
path, OGN=o);
|
||||||
err
|
|
||||||
|
self.cancel_if_wrong_origin(err, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lifetime_too_short_for_reborrow(&self,
|
fn lifetime_too_short_for_reborrow(&self,
|
||||||
|
@ -393,7 +434,8 @@ pub trait BorrowckErrors {
|
||||||
"lifetime of {} is too short to guarantee \
|
"lifetime of {} is too short to guarantee \
|
||||||
its contents can be safely reborrowed{OGN}",
|
its contents can be safely reborrowed{OGN}",
|
||||||
path, OGN=o);
|
path, OGN=o);
|
||||||
err
|
|
||||||
|
self.cancel_if_wrong_origin(err, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cannot_act_on_capture_in_sharable_fn(&self,
|
fn cannot_act_on_capture_in_sharable_fn(&self,
|
||||||
|
@ -408,7 +450,8 @@ pub trait BorrowckErrors {
|
||||||
"{} in a captured outer variable in an `Fn` closure{OGN}",
|
"{} in a captured outer variable in an `Fn` closure{OGN}",
|
||||||
bad_thing, OGN=o);
|
bad_thing, OGN=o);
|
||||||
err.span_help(help_span, help_msg);
|
err.span_help(help_span, help_msg);
|
||||||
err
|
|
||||||
|
self.cancel_if_wrong_origin(err, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cannot_assign_into_immutable_reference(&self,
|
fn cannot_assign_into_immutable_reference(&self,
|
||||||
|
@ -420,7 +463,8 @@ pub trait BorrowckErrors {
|
||||||
let mut err = struct_span_err!(self, span, E0389, "{} in a `&` reference{OGN}",
|
let mut err = struct_span_err!(self, span, E0389, "{} in a `&` reference{OGN}",
|
||||||
bad_thing, OGN=o);
|
bad_thing, OGN=o);
|
||||||
err.span_label(span, "assignment into an immutable reference");
|
err.span_label(span, "assignment into an immutable reference");
|
||||||
err
|
|
||||||
|
self.cancel_if_wrong_origin(err, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cannot_capture_in_long_lived_closure(&self,
|
fn cannot_capture_in_long_lived_closure(&self,
|
||||||
|
@ -437,7 +481,8 @@ pub trait BorrowckErrors {
|
||||||
borrowed_path, OGN=o);
|
borrowed_path, OGN=o);
|
||||||
err.span_label(capture_span, format!("{} is borrowed here", borrowed_path))
|
err.span_label(capture_span, format!("{} is borrowed here", borrowed_path))
|
||||||
.span_label(closure_span, format!("may outlive borrowed value {}", borrowed_path));
|
.span_label(closure_span, format!("may outlive borrowed value {}", borrowed_path));
|
||||||
err
|
|
||||||
|
self.cancel_if_wrong_origin(err, o)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,4 +503,15 @@ impl<'b, 'gcx, 'tcx> BorrowckErrors for TyCtxt<'b, 'gcx, 'tcx> {
|
||||||
{
|
{
|
||||||
self.sess.struct_span_err(sp, msg)
|
self.sess.struct_span_err(sp, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn cancel_if_wrong_origin<'a>(&'a self,
|
||||||
|
mut diag: DiagnosticBuilder<'a>,
|
||||||
|
o: Origin)
|
||||||
|
-> DiagnosticBuilder<'a>
|
||||||
|
{
|
||||||
|
if !o.should_emit_errors(self.sess.opts.borrowck_mode) {
|
||||||
|
self.sess.diagnostic().cancel(&mut diag);
|
||||||
|
}
|
||||||
|
diag
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
struct FancyNum {
|
struct FancyNum {
|
||||||
num: u8,
|
num: u8,
|
||||||
|
@ -19,8 +19,7 @@ fn main() {
|
||||||
let mut fancy_num = FancyNum { num: 5 };
|
let mut fancy_num = FancyNum { num: 5 };
|
||||||
let fancy_ref = &fancy_num;
|
let fancy_ref = &fancy_num;
|
||||||
fancy_num = FancyNum { num: 6 }; //[ast]~ ERROR E0506
|
fancy_num = FancyNum { num: 6 }; //[ast]~ ERROR E0506
|
||||||
//[mir]~^ ERROR (Mir) [E0506]
|
//[mir]~^ ERROR [E0506]
|
||||||
//[mir]~| ERROR (Ast) [E0506]
|
|
||||||
|
|
||||||
println!("Num: {}, Ref: {}", fancy_num.num, fancy_ref.num);
|
println!("Num: {}, Ref: {}", fancy_num.num, fancy_ref.num);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,13 +9,12 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Zborrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
struct NonCopy;
|
struct NonCopy;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let array = [NonCopy; 1];
|
let array = [NonCopy; 1];
|
||||||
let _value = array[0]; //[ast]~ ERROR E0508
|
let _value = array[0]; //[ast]~ ERROR [E0508]
|
||||||
//[mir]~^ ERROR (Ast) [E0508]
|
//[mir]~^ ERROR [E0508]
|
||||||
//[mir]~| ERROR (Mir) [E0508]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,12 +9,11 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
static NUM: i32 = 18;
|
static NUM: i32 = 18;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
NUM = 20; //[ast]~ ERROR E0594
|
NUM = 20; //[ast]~ ERROR E0594
|
||||||
//[mir]~^ ERROR cannot assign to immutable static item (Ast)
|
//[mir]~^ ERROR cannot assign to immutable static item
|
||||||
//[mir]~| ERROR cannot assign to immutable static item `NUM` (Mir)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,10 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = 1;
|
let x = 1;
|
||||||
let y = &mut x; //[ast]~ ERROR [E0596]
|
let y = &mut x; //[ast]~ ERROR [E0596]
|
||||||
//[mir]~^ ERROR (Ast) [E0596]
|
//[mir]~^ ERROR [E0596]
|
||||||
//[mir]~| ERROR (Mir) [E0596]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
static static_x : i32 = 1;
|
static static_x : i32 = 1;
|
||||||
static mut static_x_mut : i32 = 1;
|
static mut static_x_mut : i32 = 1;
|
||||||
|
@ -20,15 +20,13 @@ fn main() {
|
||||||
|
|
||||||
{ // borrow of local
|
{ // borrow of local
|
||||||
let _y1 = &mut x; //[ast]~ ERROR [E0596]
|
let _y1 = &mut x; //[ast]~ ERROR [E0596]
|
||||||
//[mir]~^ ERROR (Ast) [E0596]
|
//[mir]~^ ERROR [E0596]
|
||||||
//[mir]~| ERROR (Mir) [E0596]
|
|
||||||
let _y2 = &mut x_mut; // No error
|
let _y2 = &mut x_mut; // No error
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // borrow of static
|
{ // borrow of static
|
||||||
let _y1 = &mut static_x; //[ast]~ ERROR [E0596]
|
let _y1 = &mut static_x; //[ast]~ ERROR [E0596]
|
||||||
//[mir]~^ ERROR (Ast) [E0596]
|
//[mir]~^ ERROR [E0596]
|
||||||
//[mir]~| ERROR (Mir) [E0596]
|
|
||||||
unsafe { let _y2 = &mut static_x_mut; } // No error
|
unsafe { let _y2 = &mut static_x_mut; } // No error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,8 +35,7 @@ fn main() {
|
||||||
let mut box_x_mut = Box::new(1);
|
let mut box_x_mut = Box::new(1);
|
||||||
|
|
||||||
let _y1 = &mut *box_x; //[ast]~ ERROR [E0596]
|
let _y1 = &mut *box_x; //[ast]~ ERROR [E0596]
|
||||||
//[mir]~^ ERROR (Ast) [E0596]
|
//[mir]~^ ERROR [E0596]
|
||||||
//[mir]~| ERROR (Mir) [E0596]
|
|
||||||
let _y2 = &mut *box_x_mut; // No error
|
let _y2 = &mut *box_x_mut; // No error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,8 +44,7 @@ fn main() {
|
||||||
let ref_x_mut = &mut x_mut;
|
let ref_x_mut = &mut x_mut;
|
||||||
|
|
||||||
let _y1 = &mut *ref_x; //[ast]~ ERROR [E0596]
|
let _y1 = &mut *ref_x; //[ast]~ ERROR [E0596]
|
||||||
//[mir]~^ ERROR (Ast) [E0596]
|
//[mir]~^ ERROR [E0596]
|
||||||
//[mir]~| ERROR (Mir) [E0596]
|
|
||||||
let _y2 = &mut *ref_x_mut; // No error
|
let _y2 = &mut *ref_x_mut; // No error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,8 +54,7 @@ fn main() {
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let _y1 = &mut *ptr_x; //[ast]~ ERROR [E0596]
|
let _y1 = &mut *ptr_x; //[ast]~ ERROR [E0596]
|
||||||
//[mir]~^ ERROR (Ast) [E0596]
|
//[mir]~^ ERROR [E0596]
|
||||||
//[mir]~| ERROR (Mir) [E0596]
|
|
||||||
let _y2 = &mut *ptr_mut_x; // No error
|
let _y2 = &mut *ptr_mut_x; // No error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,8 +64,7 @@ fn main() {
|
||||||
let mut foo = Foo { f: &mut x_mut, g: &x };
|
let mut foo = Foo { f: &mut x_mut, g: &x };
|
||||||
let foo_ref = &foo;
|
let foo_ref = &foo;
|
||||||
let _y = &mut *foo_ref.f; //[ast]~ ERROR [E0389]
|
let _y = &mut *foo_ref.f; //[ast]~ ERROR [E0389]
|
||||||
//[mir]~^ ERROR (Ast) [E0389]
|
//[mir]~^ ERROR [E0596]
|
||||||
//[mir]~| ERROR (Mir) [E0596]
|
// FIXME: Wrong error in MIR
|
||||||
// FIXME: Wrong error in MIR
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
struct point { x: isize, y: isize }
|
struct point { x: isize, y: isize }
|
||||||
|
|
||||||
|
@ -21,8 +21,7 @@ fn a() {
|
||||||
// inherently mutable; since `p` was made immutable, `p.x` is now
|
// inherently mutable; since `p` was made immutable, `p.x` is now
|
||||||
// immutable. Otherwise the type of &_q.x (&isize) would be wrong.
|
// immutable. Otherwise the type of &_q.x (&isize) would be wrong.
|
||||||
p.x = 5; //[ast]~ ERROR cannot assign to `p.x`
|
p.x = 5; //[ast]~ ERROR cannot assign to `p.x`
|
||||||
//[mir]~^ ERROR cannot assign to `p.x` because it is borrowed (Ast)
|
//[mir]~^ ERROR cannot assign to `p.x` because it is borrowed
|
||||||
//[mir]~| ERROR cannot assign to `p.x` because it is borrowed (Mir)
|
|
||||||
q.x;
|
q.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,8 +32,7 @@ fn c() {
|
||||||
let mut p = point {x: 3, y: 4};
|
let mut p = point {x: 3, y: 4};
|
||||||
let q = &p.y;
|
let q = &p.y;
|
||||||
p = point {x: 5, y: 7};//[ast]~ ERROR cannot assign to `p`
|
p = point {x: 5, y: 7};//[ast]~ ERROR cannot assign to `p`
|
||||||
//[mir]~^ ERROR cannot assign to `p` because it is borrowed (Ast)
|
//[mir]~^ ERROR cannot assign to `p` because it is borrowed
|
||||||
//[mir]~| ERROR cannot assign to `p` because it is borrowed (Mir)
|
|
||||||
p.x; // silence warning
|
p.x; // silence warning
|
||||||
*q; // stretch loan
|
*q; // stretch loan
|
||||||
}
|
}
|
||||||
|
@ -46,8 +44,7 @@ fn d() {
|
||||||
let mut p = point {x: 3, y: 4};
|
let mut p = point {x: 3, y: 4};
|
||||||
let q = &p.y;
|
let q = &p.y;
|
||||||
p.y = 5; //[ast]~ ERROR cannot assign to `p.y`
|
p.y = 5; //[ast]~ ERROR cannot assign to `p.y`
|
||||||
//[mir]~^ ERROR cannot assign to `p.y` because it is borrowed (Ast)
|
//[mir]~^ ERROR cannot assign to `p.y` because it is borrowed
|
||||||
//[mir]~| ERROR cannot assign to `p.y` because it is borrowed (Mir)
|
|
||||||
*q;
|
*q;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,12 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
static foo: isize = 5;
|
static foo: isize = 5;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// assigning to various global constants
|
// assigning to various global constants
|
||||||
foo = 6; //[ast]~ ERROR cannot assign to immutable static item
|
foo = 6; //[ast]~ ERROR cannot assign to immutable static item
|
||||||
//[mir]~^ ERROR cannot assign to immutable static item (Ast)
|
//[mir]~^ ERROR cannot assign to immutable static item `foo`
|
||||||
//[mir]~| ERROR cannot assign to immutable static item `foo` (Mir)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
// ignore-tidy-linelength
|
// ignore-tidy-linelength
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
#![feature(box_syntax)]
|
#![feature(box_syntax)]
|
||||||
|
|
||||||
|
@ -29,48 +29,42 @@ fn a() {
|
||||||
let mut x = 3;
|
let mut x = 3;
|
||||||
let c1 = || x = 4;
|
let c1 = || x = 4;
|
||||||
let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x`
|
let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x`
|
||||||
//[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable (Ast)
|
//[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable
|
||||||
//[mir]~| ERROR cannot borrow `x` as immutable because it is also borrowed as mutable (Mir)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn b() {
|
fn b() {
|
||||||
let mut x = 3;
|
let mut x = 3;
|
||||||
let c1 = || set(&mut x);
|
let c1 = || set(&mut x);
|
||||||
let c2 = || get(&x); //[ast]~ ERROR cannot borrow `x`
|
let c2 = || get(&x); //[ast]~ ERROR cannot borrow `x`
|
||||||
//[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable (Ast)
|
//[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable
|
||||||
//[mir]~| ERROR cannot borrow `x` as immutable because it is also borrowed as mutable (Mir)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn c() {
|
fn c() {
|
||||||
let mut x = 3;
|
let mut x = 3;
|
||||||
let c1 = || set(&mut x);
|
let c1 = || set(&mut x);
|
||||||
let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x`
|
let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x`
|
||||||
//[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable (Ast)
|
//[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable
|
||||||
//[mir]~| ERROR cannot borrow `x` as immutable because it is also borrowed as mutable (Mir)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn d() {
|
fn d() {
|
||||||
let mut x = 3;
|
let mut x = 3;
|
||||||
let c2 = || x * 5;
|
let c2 = || x * 5;
|
||||||
x = 5; //[ast]~ ERROR cannot assign
|
x = 5; //[ast]~ ERROR cannot assign
|
||||||
//[mir]~^ ERROR cannot assign to `x` because it is borrowed (Ast)
|
//[mir]~^ ERROR cannot assign to `x` because it is borrowed
|
||||||
//[mir]~| ERROR cannot assign to `x` because it is borrowed (Mir)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn e() {
|
fn e() {
|
||||||
let mut x = 3;
|
let mut x = 3;
|
||||||
let c1 = || get(&x);
|
let c1 = || get(&x);
|
||||||
x = 5; //[ast]~ ERROR cannot assign
|
x = 5; //[ast]~ ERROR cannot assign
|
||||||
//[mir]~^ ERROR cannot assign to `x` because it is borrowed (Ast)
|
//[mir]~^ ERROR cannot assign to `x` because it is borrowed
|
||||||
//[mir]~| ERROR cannot assign to `x` because it is borrowed (Mir)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn f() {
|
fn f() {
|
||||||
let mut x: Box<_> = box 3;
|
let mut x: Box<_> = box 3;
|
||||||
let c1 = || get(&*x);
|
let c1 = || get(&*x);
|
||||||
*x = 5; //[ast]~ ERROR cannot assign
|
*x = 5; //[ast]~ ERROR cannot assign to `*x`
|
||||||
//[mir]~^ ERROR cannot assign to `*x` because it is borrowed (Ast)
|
//[mir]~^ ERROR cannot assign to `*x` because it is borrowed
|
||||||
//[mir]~| ERROR cannot assign to `*x` because it is borrowed (Mir)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn g() {
|
fn g() {
|
||||||
|
@ -81,8 +75,7 @@ fn g() {
|
||||||
let mut x: Box<_> = box Foo { f: box 3 };
|
let mut x: Box<_> = box Foo { f: box 3 };
|
||||||
let c1 = || get(&*x.f);
|
let c1 = || get(&*x.f);
|
||||||
*x.f = 5; //[ast]~ ERROR cannot assign to `*x.f`
|
*x.f = 5; //[ast]~ ERROR cannot assign to `*x.f`
|
||||||
//[mir]~^ ERROR cannot assign to `*x.f` because it is borrowed (Ast)
|
//[mir]~^ ERROR cannot assign to `*x.f` because it is borrowed
|
||||||
//[mir]~| ERROR cannot assign to `*x.f` because it is borrowed (Mir)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn h() {
|
fn h() {
|
||||||
|
@ -93,8 +86,7 @@ fn h() {
|
||||||
let mut x: Box<_> = box Foo { f: box 3 };
|
let mut x: Box<_> = box Foo { f: box 3 };
|
||||||
let c1 = || get(&*x.f);
|
let c1 = || get(&*x.f);
|
||||||
let c2 = || *x.f = 5; //[ast]~ ERROR cannot borrow `x` as mutable
|
let c2 = || *x.f = 5; //[ast]~ ERROR cannot borrow `x` as mutable
|
||||||
//[mir]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable (Ast)
|
//[mir]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable
|
||||||
//[mir]~| ERROR cannot borrow `x` as mutable because it is also borrowed as immutable (Mir)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
// ignore-tidy-linelength
|
// ignore-tidy-linelength
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
#![feature(slice_patterns)]
|
#![feature(slice_patterns)]
|
||||||
#![feature(advanced_slice_patterns)]
|
#![feature(advanced_slice_patterns)]
|
||||||
|
@ -52,24 +52,21 @@ fn main() {
|
||||||
let mut f = Foo { x: 22 };
|
let mut f = Foo { x: 22 };
|
||||||
let _x = f.x();
|
let _x = f.x();
|
||||||
f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed
|
f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed
|
||||||
//[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed (Ast)
|
//[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed
|
||||||
//[mir]~| ERROR cannot use `f.x` because it was mutably borrowed (Mir)
|
|
||||||
}
|
}
|
||||||
// Local and field from tuple-struct
|
// Local and field from tuple-struct
|
||||||
{
|
{
|
||||||
let mut g = Bar(22);
|
let mut g = Bar(22);
|
||||||
let _0 = g.x();
|
let _0 = g.x();
|
||||||
g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed
|
g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed
|
||||||
//[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed (Ast)
|
//[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed
|
||||||
//[mir]~| ERROR cannot use `g.0` because it was mutably borrowed (Mir)
|
|
||||||
}
|
}
|
||||||
// Local and field from tuple
|
// Local and field from tuple
|
||||||
{
|
{
|
||||||
let mut h = (22, 23);
|
let mut h = (22, 23);
|
||||||
let _0 = &mut h.0;
|
let _0 = &mut h.0;
|
||||||
h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed
|
h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed
|
||||||
//[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed (Ast)
|
//[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed
|
||||||
//[mir]~| ERROR cannot use `h.0` because it was mutably borrowed (Mir)
|
|
||||||
}
|
}
|
||||||
// Local and field from enum
|
// Local and field from enum
|
||||||
{
|
{
|
||||||
|
@ -78,8 +75,7 @@ fn main() {
|
||||||
match e {
|
match e {
|
||||||
Baz::X(value) => value
|
Baz::X(value) => value
|
||||||
//[ast]~^ ERROR cannot use `e.0` because it was mutably borrowed
|
//[ast]~^ ERROR cannot use `e.0` because it was mutably borrowed
|
||||||
//[mir]~^^ ERROR cannot use `e.0` because it was mutably borrowed (Ast)
|
//[mir]~^^ ERROR cannot use `e.0` because it was mutably borrowed
|
||||||
//[mir]~| ERROR cannot use `e.0` because it was mutably borrowed (Mir)
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// Local and field from union
|
// Local and field from union
|
||||||
|
@ -87,32 +83,28 @@ fn main() {
|
||||||
let mut u = U { b: 0 };
|
let mut u = U { b: 0 };
|
||||||
let _ra = &mut u.a;
|
let _ra = &mut u.a;
|
||||||
u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed
|
u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed
|
||||||
//[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed (Ast)
|
//[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed
|
||||||
//[mir]~| ERROR cannot use `u.a` because it was mutably borrowed (Mir)
|
|
||||||
}
|
}
|
||||||
// Deref and field from struct
|
// Deref and field from struct
|
||||||
{
|
{
|
||||||
let mut f = Box::new(Foo { x: 22 });
|
let mut f = Box::new(Foo { x: 22 });
|
||||||
let _x = f.x();
|
let _x = f.x();
|
||||||
f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed
|
f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed
|
||||||
//[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed (Ast)
|
//[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed
|
||||||
//[mir]~| ERROR cannot use `f.x` because it was mutably borrowed (Mir)
|
|
||||||
}
|
}
|
||||||
// Deref and field from tuple-struct
|
// Deref and field from tuple-struct
|
||||||
{
|
{
|
||||||
let mut g = Box::new(Bar(22));
|
let mut g = Box::new(Bar(22));
|
||||||
let _0 = g.x();
|
let _0 = g.x();
|
||||||
g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed
|
g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed
|
||||||
//[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed (Ast)
|
//[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed
|
||||||
//[mir]~| ERROR cannot use `g.0` because it was mutably borrowed (Mir)
|
|
||||||
}
|
}
|
||||||
// Deref and field from tuple
|
// Deref and field from tuple
|
||||||
{
|
{
|
||||||
let mut h = Box::new((22, 23));
|
let mut h = Box::new((22, 23));
|
||||||
let _0 = &mut h.0;
|
let _0 = &mut h.0;
|
||||||
h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed
|
h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed
|
||||||
//[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed (Ast)
|
//[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed
|
||||||
//[mir]~| ERROR cannot use `h.0` because it was mutably borrowed (Mir)
|
|
||||||
}
|
}
|
||||||
// Deref and field from enum
|
// Deref and field from enum
|
||||||
{
|
{
|
||||||
|
@ -121,8 +113,7 @@ fn main() {
|
||||||
match *e {
|
match *e {
|
||||||
Baz::X(value) => value
|
Baz::X(value) => value
|
||||||
//[ast]~^ ERROR cannot use `e.0` because it was mutably borrowed
|
//[ast]~^ ERROR cannot use `e.0` because it was mutably borrowed
|
||||||
//[mir]~^^ ERROR cannot use `e.0` because it was mutably borrowed (Ast)
|
//[mir]~^^ ERROR cannot use `e.0` because it was mutably borrowed
|
||||||
//[mir]~| ERROR cannot use `e.0` because it was mutably borrowed (Mir)
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// Deref and field from union
|
// Deref and field from union
|
||||||
|
@ -130,8 +121,7 @@ fn main() {
|
||||||
let mut u = Box::new(U { b: 0 });
|
let mut u = Box::new(U { b: 0 });
|
||||||
let _ra = &mut u.a;
|
let _ra = &mut u.a;
|
||||||
u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed
|
u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed
|
||||||
//[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed (Ast)
|
//[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed
|
||||||
//[mir]~| ERROR cannot use `u.a` because it was mutably borrowed (Mir)
|
|
||||||
}
|
}
|
||||||
// Constant index
|
// Constant index
|
||||||
{
|
{
|
||||||
|
@ -140,29 +130,25 @@ fn main() {
|
||||||
match v {
|
match v {
|
||||||
&[x, _, .., _, _] => println!("{}", x),
|
&[x, _, .., _, _] => println!("{}", x),
|
||||||
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
|
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
|
||||||
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed (Ast)
|
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed
|
||||||
//[mir]~| ERROR cannot use `v[..]` because it was mutably borrowed (Mir)
|
|
||||||
_ => panic!("other case"),
|
_ => panic!("other case"),
|
||||||
}
|
}
|
||||||
match v {
|
match v {
|
||||||
&[_, x, .., _, _] => println!("{}", x),
|
&[_, x, .., _, _] => println!("{}", x),
|
||||||
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
|
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
|
||||||
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed (Ast)
|
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed
|
||||||
//[mir]~| ERROR cannot use `v[..]` because it was mutably borrowed (Mir)
|
|
||||||
_ => panic!("other case"),
|
_ => panic!("other case"),
|
||||||
}
|
}
|
||||||
match v {
|
match v {
|
||||||
&[_, _, .., x, _] => println!("{}", x),
|
&[_, _, .., x, _] => println!("{}", x),
|
||||||
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
|
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
|
||||||
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed (Ast)
|
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed
|
||||||
//[mir]~| ERROR cannot use `v[..]` because it was mutably borrowed (Mir)
|
|
||||||
_ => panic!("other case"),
|
_ => panic!("other case"),
|
||||||
}
|
}
|
||||||
match v {
|
match v {
|
||||||
&[_, _, .., _, x] => println!("{}", x),
|
&[_, _, .., _, x] => println!("{}", x),
|
||||||
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
|
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
|
||||||
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed (Ast)
|
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed
|
||||||
//[mir]~| ERROR cannot use `v[..]` because it was mutably borrowed (Mir)
|
|
||||||
_ => panic!("other case"),
|
_ => panic!("other case"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,29 +159,25 @@ fn main() {
|
||||||
match v {
|
match v {
|
||||||
&[x..] => println!("{:?}", x),
|
&[x..] => println!("{:?}", x),
|
||||||
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
|
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
|
||||||
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed (Ast)
|
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed
|
||||||
//[mir]~| ERROR cannot use `v[..]` because it was mutably borrowed (Mir)
|
|
||||||
_ => panic!("other case"),
|
_ => panic!("other case"),
|
||||||
}
|
}
|
||||||
match v {
|
match v {
|
||||||
&[_, x..] => println!("{:?}", x),
|
&[_, x..] => println!("{:?}", x),
|
||||||
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
|
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
|
||||||
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed (Ast)
|
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed
|
||||||
//[mir]~| ERROR cannot use `v[..]` because it was mutably borrowed (Mir)
|
|
||||||
_ => panic!("other case"),
|
_ => panic!("other case"),
|
||||||
}
|
}
|
||||||
match v {
|
match v {
|
||||||
&[x.., _] => println!("{:?}", x),
|
&[x.., _] => println!("{:?}", x),
|
||||||
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
|
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
|
||||||
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed (Ast)
|
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed
|
||||||
//[mir]~| ERROR cannot use `v[..]` because it was mutably borrowed (Mir)
|
|
||||||
_ => panic!("other case"),
|
_ => panic!("other case"),
|
||||||
}
|
}
|
||||||
match v {
|
match v {
|
||||||
&[_, x.., _] => println!("{:?}", x),
|
&[_, x.., _] => println!("{:?}", x),
|
||||||
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
|
//[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed
|
||||||
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed (Ast)
|
//[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed
|
||||||
//[mir]~| ERROR cannot use `v[..]` because it was mutably borrowed (Mir)
|
|
||||||
_ => panic!("other case"),
|
_ => panic!("other case"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,14 +190,12 @@ fn main() {
|
||||||
match e {
|
match e {
|
||||||
E::A(ref ax) =>
|
E::A(ref ax) =>
|
||||||
//[ast]~^ ERROR cannot borrow `e.0` as immutable because `e` is also borrowed as mutable
|
//[ast]~^ ERROR cannot borrow `e.0` as immutable because `e` is also borrowed as mutable
|
||||||
//[mir]~^^ ERROR cannot borrow `e.0` as immutable because `e` is also borrowed as mutable (Ast)
|
//[mir]~^^ ERROR cannot borrow `e.0` as immutable because it is also borrowed as mutable
|
||||||
//[mir]~| ERROR cannot borrow `e.0` as immutable because it is also borrowed as mutable (Mir)
|
//[mir]~| ERROR cannot use `e` because it was mutably borrowed
|
||||||
//[mir]~| ERROR cannot use `e` because it was mutably borrowed (Mir)
|
|
||||||
println!("e.ax: {:?}", ax),
|
println!("e.ax: {:?}", ax),
|
||||||
E::B { x: ref bx } =>
|
E::B { x: ref bx } =>
|
||||||
//[ast]~^ ERROR cannot borrow `e.x` as immutable because `e` is also borrowed as mutable
|
//[ast]~^ ERROR cannot borrow `e.x` as immutable because `e` is also borrowed as mutable
|
||||||
//[mir]~^^ ERROR cannot borrow `e.x` as immutable because `e` is also borrowed as mutable (Ast)
|
//[mir]~^^ ERROR cannot borrow `e.x` as immutable because it is also borrowed as mutable
|
||||||
//[mir]~| ERROR cannot borrow `e.x` as immutable because it is also borrowed as mutable (Mir)
|
|
||||||
println!("e.bx: {:?}", bx),
|
println!("e.bx: {:?}", bx),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,16 +208,14 @@ fn main() {
|
||||||
match s {
|
match s {
|
||||||
S { y: (ref y0, _), .. } =>
|
S { y: (ref y0, _), .. } =>
|
||||||
//[ast]~^ ERROR cannot borrow `s.y.0` as immutable because `s` is also borrowed as mutable
|
//[ast]~^ ERROR cannot borrow `s.y.0` as immutable because `s` is also borrowed as mutable
|
||||||
//[mir]~^^ ERROR cannot borrow `s.y.0` as immutable because `s` is also borrowed as mutable (Ast)
|
//[mir]~^^ ERROR cannot borrow `s.y.0` as immutable because it is also borrowed as mutable
|
||||||
//[mir]~| ERROR cannot borrow `s.y.0` as immutable because it is also borrowed as mutable (Mir)
|
|
||||||
println!("y0: {:?}", y0),
|
println!("y0: {:?}", y0),
|
||||||
_ => panic!("other case"),
|
_ => panic!("other case"),
|
||||||
}
|
}
|
||||||
match s {
|
match s {
|
||||||
S { x: F { y: ref x0, .. }, .. } =>
|
S { x: F { y: ref x0, .. }, .. } =>
|
||||||
//[ast]~^ ERROR cannot borrow `s.x.y` as immutable because `s` is also borrowed as mutable
|
//[ast]~^ ERROR cannot borrow `s.x.y` as immutable because `s` is also borrowed as mutable
|
||||||
//[mir]~^^ ERROR cannot borrow `s.x.y` as immutable because `s` is also borrowed as mutable (Ast)
|
//[mir]~^^ ERROR cannot borrow `s.x.y` as immutable because it is also borrowed as mutable
|
||||||
//[mir]~| ERROR cannot borrow `s.x.y` as immutable because it is also borrowed as mutable (Mir)
|
|
||||||
println!("x0: {:?}", x0),
|
println!("x0: {:?}", x0),
|
||||||
_ => panic!("other case"),
|
_ => panic!("other case"),
|
||||||
}
|
}
|
||||||
|
@ -252,7 +230,7 @@ fn main() {
|
||||||
fn bump<'a>(mut block: &mut Block<'a>) {
|
fn bump<'a>(mut block: &mut Block<'a>) {
|
||||||
let x = &mut block;
|
let x = &mut block;
|
||||||
let p: &'a u8 = &*block.current;
|
let p: &'a u8 = &*block.current;
|
||||||
//[mir]~^ ERROR cannot borrow `*block.current` as immutable because it is also borrowed as mutable (Mir)
|
//[mir]~^ ERROR cannot borrow `*block.current` as immutable because it is also borrowed as mutable
|
||||||
// No errors in AST because of issue rust#38899
|
// No errors in AST because of issue rust#38899
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -266,7 +244,7 @@ fn main() {
|
||||||
unsafe fn bump2(mut block: *mut Block2) {
|
unsafe fn bump2(mut block: *mut Block2) {
|
||||||
let x = &mut block;
|
let x = &mut block;
|
||||||
let p : *const u8 = &*(*block).current;
|
let p : *const u8 = &*(*block).current;
|
||||||
//[mir]~^ ERROR cannot borrow `*block.current` as immutable because it is also borrowed as mutable (Mir)
|
//[mir]~^ ERROR cannot borrow `*block.current` as immutable because it is also borrowed as mutable
|
||||||
// No errors in AST because of issue rust#38899
|
// No errors in AST because of issue rust#38899
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -277,9 +255,8 @@ fn main() {
|
||||||
let _v = &mut v;
|
let _v = &mut v;
|
||||||
v[0].y;
|
v[0].y;
|
||||||
//[ast]~^ ERROR cannot use `v[..].y` because it was mutably borrowed
|
//[ast]~^ ERROR cannot use `v[..].y` because it was mutably borrowed
|
||||||
//[mir]~^^ ERROR cannot use `v[..].y` because it was mutably borrowed (Ast)
|
//[mir]~^^ ERROR cannot use `v[..].y` because it was mutably borrowed
|
||||||
//[mir]~| ERROR cannot use `v[..].y` because it was mutably borrowed (Mir)
|
//[mir]~| ERROR cannot use `*v` because it was mutably borrowed
|
||||||
//[mir]~| ERROR cannot use `*v` because it was mutably borrowed (Mir)
|
|
||||||
}
|
}
|
||||||
// Field of constant index
|
// Field of constant index
|
||||||
{
|
{
|
||||||
|
@ -288,7 +265,7 @@ fn main() {
|
||||||
let _v = &mut v;
|
let _v = &mut v;
|
||||||
match v {
|
match v {
|
||||||
&[_, F {x: ref xf, ..}] => println!("{}", xf),
|
&[_, F {x: ref xf, ..}] => println!("{}", xf),
|
||||||
//[mir]~^ ERROR cannot borrow `v[..].x` as immutable because it is also borrowed as mutable (Mir)
|
//[mir]~^ ERROR cannot borrow `v[..].x` as immutable because it is also borrowed as mutable
|
||||||
// No errors in AST
|
// No errors in AST
|
||||||
_ => panic!("other case")
|
_ => panic!("other case")
|
||||||
}
|
}
|
||||||
|
@ -299,8 +276,7 @@ fn main() {
|
||||||
|| {
|
|| {
|
||||||
let y = &mut x;
|
let y = &mut x;
|
||||||
&mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time
|
&mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time
|
||||||
//[mir]~^ ERROR cannot borrow `**x` as mutable more than once at a time (Ast)
|
//[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time
|
||||||
//[mir]~| ERROR cannot borrow `x` as mutable more than once at a time (Mir)
|
|
||||||
*y = 1;
|
*y = 1;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -311,8 +287,7 @@ fn main() {
|
||||||
|| {
|
|| {
|
||||||
let y = &mut x;
|
let y = &mut x;
|
||||||
&mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time
|
&mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time
|
||||||
//[mir]~^ ERROR cannot borrow `**x` as mutable more than once at a time (Ast)
|
//[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time
|
||||||
//[mir]~| ERROR cannot borrow `x` as mutable more than once at a time (Mir)
|
|
||||||
*y = 1;
|
*y = 1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -322,8 +297,7 @@ fn main() {
|
||||||
let c = || {
|
let c = || {
|
||||||
drop(x);
|
drop(x);
|
||||||
drop(x); //[ast]~ ERROR use of moved value: `x`
|
drop(x); //[ast]~ ERROR use of moved value: `x`
|
||||||
//[mir]~^ ERROR use of moved value: `x` (Ast)
|
//[mir]~^ ERROR use of moved value: `x`
|
||||||
//[mir]~| ERROR use of moved value: `x` (Mir)
|
|
||||||
};
|
};
|
||||||
c();
|
c();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
//compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
fn foo(_:String) {}
|
fn foo(_:String) {}
|
||||||
|
|
||||||
|
@ -19,6 +19,6 @@ fn main()
|
||||||
match Some(42) {
|
match Some(42) {
|
||||||
Some(_) if { drop(my_str); false } => {}
|
Some(_) if { drop(my_str); false } => {}
|
||||||
Some(_) => {}
|
Some(_) => {}
|
||||||
None => { foo(my_str); } //~ ERROR (Mir) [E0382]
|
None => { foo(my_str); } //~ ERROR [E0382]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
// Check that we check fns appearing in constant declarations.
|
// Check that we check fns appearing in constant declarations.
|
||||||
// Issue #22382.
|
// Issue #22382.
|
||||||
|
@ -17,8 +17,7 @@
|
||||||
const MOVE: fn(&String) -> String = {
|
const MOVE: fn(&String) -> String = {
|
||||||
fn broken(x: &String) -> String {
|
fn broken(x: &String) -> String {
|
||||||
return *x //[ast]~ ERROR cannot move out of borrowed content [E0507]
|
return *x //[ast]~ ERROR cannot move out of borrowed content [E0507]
|
||||||
//[mir]~^ ERROR (Ast) [E0507]
|
//[mir]~^ ERROR [E0507]
|
||||||
//[mir]~| ERROR (Mir) [E0507]
|
|
||||||
}
|
}
|
||||||
broken
|
broken
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut _a = 3;
|
let mut _a = 3;
|
||||||
|
@ -17,7 +17,6 @@ fn main() {
|
||||||
{
|
{
|
||||||
let _c = &*_b;
|
let _c = &*_b;
|
||||||
_a = 4; //[ast]~ ERROR cannot assign to `_a`
|
_a = 4; //[ast]~ ERROR cannot assign to `_a`
|
||||||
//[mir]~^ ERROR cannot assign to `_a` because it is borrowed (Ast)
|
//[mir]~^ ERROR cannot assign to `_a` because it is borrowed
|
||||||
//[mir]~| ERROR cannot assign to `_a` because it is borrowed (Mir)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct point {
|
struct point {
|
||||||
|
@ -21,7 +21,6 @@ fn main() {
|
||||||
let mut origin: point;
|
let mut origin: point;
|
||||||
origin = point {x: 10,.. origin};
|
origin = point {x: 10,.. origin};
|
||||||
//[ast]~^ ERROR use of possibly uninitialized variable: `origin.y` [E0381]
|
//[ast]~^ ERROR use of possibly uninitialized variable: `origin.y` [E0381]
|
||||||
//[mir]~^^ ERROR (Ast) [E0381]
|
//[mir]~^^ ERROR [E0381]
|
||||||
//[mir]~| ERROR (Mir) [E0381]
|
|
||||||
origin.clone();
|
origin.clone();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(unused_assignments)]
|
#![allow(unused_assignments)]
|
||||||
|
@ -26,8 +26,7 @@ fn separate_arms() {
|
||||||
}
|
}
|
||||||
Some(ref __isize) => {
|
Some(ref __isize) => {
|
||||||
x = Some(1); //[ast]~ ERROR cannot assign
|
x = Some(1); //[ast]~ ERROR cannot assign
|
||||||
//[mir]~^ ERROR cannot assign to `x` because it is borrowed (Ast)
|
//[mir]~^ ERROR cannot assign to `x` because it is borrowed
|
||||||
//[mir]~| ERROR cannot assign to `x` because it is borrowed (Mir)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
x.clone(); // just to prevent liveness warnings
|
x.clone(); // just to prevent liveness warnings
|
||||||
|
|
|
@ -9,12 +9,11 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
fn cplusplus_mode(x: isize) -> &'static isize {
|
fn cplusplus_mode(x: isize) -> &'static isize {
|
||||||
&x //[ast]~ ERROR `x` does not live long enough
|
&x //[ast]~ ERROR `x` does not live long enough
|
||||||
//[mir]~^ ERROR `x` does not live long enough (Ast)
|
//[mir]~^ ERROR borrowed value does not live long enough
|
||||||
//[mir]~| ERROR borrowed value does not live long enough (Mir)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
enum Foo {
|
enum Foo {
|
||||||
A(i32),
|
A(i32),
|
||||||
|
@ -20,11 +20,10 @@ fn match_enum() {
|
||||||
let mut foo = Foo::B;
|
let mut foo = Foo::B;
|
||||||
let p = &mut foo;
|
let p = &mut foo;
|
||||||
let _ = match foo {
|
let _ = match foo {
|
||||||
Foo::B => 1, //[mir]~ ERROR (Mir) [E0503]
|
Foo::B => 1, //[mir]~ ERROR [E0503]
|
||||||
_ => 2,
|
_ => 2,
|
||||||
Foo::A(x) => x //[ast]~ ERROR [E0503]
|
Foo::A(x) => x //[ast]~ ERROR [E0503]
|
||||||
//[mir]~^ ERROR (Ast) [E0503]
|
//[mir]~^ ERROR [E0503]
|
||||||
//[mir]~| ERROR (Mir) [E0503]
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,11 +32,9 @@ fn main() {
|
||||||
let mut x = 1;
|
let mut x = 1;
|
||||||
let _x = &mut x;
|
let _x = &mut x;
|
||||||
let _ = match x {
|
let _ = match x {
|
||||||
x => x + 1, //[ast]~ ERROR E0503
|
x => x + 1, //[ast]~ ERROR [E0503]
|
||||||
//[mir]~^ ERROR (Mir) [E0503]
|
//[mir]~^ ERROR [E0503]
|
||||||
//[mir]~| ERROR (Ast) [E0503]
|
|
||||||
y => y + 2, //[ast]~ ERROR [E0503]
|
y => y + 2, //[ast]~ ERROR [E0503]
|
||||||
//[mir]~^ ERROR (Mir) [E0503]
|
//[mir]~^ ERROR [E0503]
|
||||||
//[mir]~| ERROR (Ast) [E0503]
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Zemit-end-regions -Zborrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
// Test that immutable pattern bindings cannot be reassigned.
|
// Test that immutable pattern bindings cannot be reassigned.
|
||||||
|
|
||||||
|
@ -27,40 +27,35 @@ pub fn main() {
|
||||||
match 1 {
|
match 1 {
|
||||||
x => {
|
x => {
|
||||||
x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
|
x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
|
||||||
//[mir]~^ ERROR (Mir) [E0384]
|
//[mir]~^ ERROR [E0384]
|
||||||
//[mir]~| ERROR (Ast) [E0384]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
match E::Foo(1) {
|
match E::Foo(1) {
|
||||||
E::Foo(x) => {
|
E::Foo(x) => {
|
||||||
x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
|
x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
|
||||||
//[mir]~^ ERROR (Mir) [E0384]
|
//[mir]~^ ERROR [E0384]
|
||||||
//[mir]~| ERROR (Ast) [E0384]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
match (S { bar: 1 }) {
|
match (S { bar: 1 }) {
|
||||||
S { bar: x } => {
|
S { bar: x } => {
|
||||||
x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
|
x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
|
||||||
//[mir]~^ ERROR (Mir) [E0384]
|
//[mir]~^ ERROR [E0384]
|
||||||
//[mir]~| ERROR (Ast) [E0384]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
match (1,) {
|
match (1,) {
|
||||||
(x,) => {
|
(x,) => {
|
||||||
x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
|
x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
|
||||||
//[mir]~^ ERROR (Mir) [E0384]
|
//[mir]~^ ERROR [E0384]
|
||||||
//[mir]~| ERROR (Ast) [E0384]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
match [1,2,3] {
|
match [1,2,3] {
|
||||||
[x,_,_] => {
|
[x,_,_] => {
|
||||||
x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
|
x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x`
|
||||||
//[mir]~^ ERROR (Mir) [E0384]
|
//[mir]~^ ERROR [E0384]
|
||||||
//[mir]~| ERROR (Ast) [E0384]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,27 +9,24 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
fn with<F>(f: F) where F: FnOnce(&String) {}
|
fn with<F>(f: F) where F: FnOnce(&String) {}
|
||||||
|
|
||||||
fn arg_item(&_x: &String) {}
|
fn arg_item(&_x: &String) {}
|
||||||
//[ast]~^ ERROR cannot move out of borrowed content [E0507]
|
//[ast]~^ ERROR cannot move out of borrowed content [E0507]
|
||||||
//[mir]~^^ ERROR (Ast) [E0507]
|
//[mir]~^^ ERROR [E0507]
|
||||||
//[mir]~| ERROR (Mir) [E0507]
|
|
||||||
|
|
||||||
fn arg_closure() {
|
fn arg_closure() {
|
||||||
with(|&_x| ())
|
with(|&_x| ())
|
||||||
//[ast]~^ ERROR cannot move out of borrowed content [E0507]
|
//[ast]~^ ERROR cannot move out of borrowed content [E0507]
|
||||||
//[mir]~^^ ERROR (Ast) [E0507]
|
//[mir]~^^ ERROR [E0507]
|
||||||
//[mir]~| ERROR (Mir) [E0507]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn let_pat() {
|
fn let_pat() {
|
||||||
let &_x = &"hi".to_string();
|
let &_x = &"hi".to_string();
|
||||||
//[ast]~^ ERROR cannot move out of borrowed content [E0507]
|
//[ast]~^ ERROR cannot move out of borrowed content [E0507]
|
||||||
//[mir]~^^ ERROR (Ast) [E0507]
|
//[mir]~^^ ERROR [E0507]
|
||||||
//[mir]~| ERROR (Mir) [E0507]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {}
|
pub fn main() {}
|
||||||
|
|
|
@ -9,13 +9,12 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let _x = Rc::new(vec![1, 2]).into_iter();
|
let _x = Rc::new(vec![1, 2]).into_iter();
|
||||||
//[ast]~^ ERROR cannot move out of borrowed content [E0507]
|
//[ast]~^ ERROR cannot move out of borrowed content [E0507]
|
||||||
//[mir]~^^ ERROR (Ast) [E0507]
|
//[mir]~^^ ERROR [E0507]
|
||||||
//[mir]~| ERROR (Mir) [E0507]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
// Ensure that moves out of static items is forbidden
|
// Ensure that moves out of static items is forbidden
|
||||||
|
|
||||||
|
@ -26,6 +26,5 @@ fn test(f: Foo) {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
test(BAR); //[ast]~ ERROR cannot move out of static item [E0507]
|
test(BAR); //[ast]~ ERROR cannot move out of static item [E0507]
|
||||||
//[mir]~^ ERROR (Ast) [E0507]
|
//[mir]~^ ERROR [E0507]
|
||||||
//[mir]~| ERROR (Mir) [E0507]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
struct S {f:String}
|
struct S {f:String}
|
||||||
impl Drop for S {
|
impl Drop for S {
|
||||||
|
@ -20,22 +20,19 @@ fn move_in_match() {
|
||||||
match (S {f:"foo".to_string()}) {
|
match (S {f:"foo".to_string()}) {
|
||||||
S {f:_s} => {}
|
S {f:_s} => {}
|
||||||
//[ast]~^ ERROR cannot move out of type `S`, which implements the `Drop` trait [E0509]
|
//[ast]~^ ERROR cannot move out of type `S`, which implements the `Drop` trait [E0509]
|
||||||
//[mir]~^^ ERROR (Ast) [E0509]
|
//[mir]~^^ ERROR [E0509]
|
||||||
//[mir]~| ERROR (Mir) [E0509]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn move_in_let() {
|
fn move_in_let() {
|
||||||
let S {f:_s} = S {f:"foo".to_string()};
|
let S {f:_s} = S {f:"foo".to_string()};
|
||||||
//[ast]~^ ERROR cannot move out of type `S`, which implements the `Drop` trait [E0509]
|
//[ast]~^ ERROR cannot move out of type `S`, which implements the `Drop` trait [E0509]
|
||||||
//[mir]~^^ ERROR (Ast) [E0509]
|
//[mir]~^^ ERROR [E0509]
|
||||||
//[mir]~| ERROR (Mir) [E0509]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn move_in_fn_arg(S {f:_s}: S) {
|
fn move_in_fn_arg(S {f:_s}: S) {
|
||||||
//[ast]~^ ERROR cannot move out of type `S`, which implements the `Drop` trait [E0509]
|
//[ast]~^ ERROR cannot move out of type `S`, which implements the `Drop` trait [E0509]
|
||||||
//[mir]~^^ ERROR (Ast) [E0509]
|
//[mir]~^^ ERROR [E0509]
|
||||||
//[mir]~| ERROR (Mir) [E0509]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// down to O(n) errors (for n problem lines), instead of O(n^2) errors.
|
// down to O(n) errors (for n problem lines), instead of O(n^2) errors.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut x = 1;
|
let mut x = 1;
|
||||||
|
@ -21,18 +21,15 @@ fn main() {
|
||||||
loop {
|
loop {
|
||||||
match 1 {
|
match 1 {
|
||||||
1 => { addr = &mut x; } //[ast]~ ERROR [E0499]
|
1 => { addr = &mut x; } //[ast]~ ERROR [E0499]
|
||||||
//[mir]~^ ERROR (Ast) [E0499]
|
//[mir]~^ ERROR [E0499]
|
||||||
//[mir]~| ERROR (Mir) [E0499]
|
|
||||||
2 => { addr = &mut x; } //[ast]~ ERROR [E0499]
|
2 => { addr = &mut x; } //[ast]~ ERROR [E0499]
|
||||||
//[mir]~^ ERROR (Ast) [E0499]
|
//[mir]~^ ERROR [E0506]
|
||||||
//[mir]~| ERROR (Mir) [E0506]
|
//[mir]~| ERROR [E0499]
|
||||||
//[mir]~| ERROR (Mir) [E0499]
|
//[mir]~| ERROR [E0499]
|
||||||
//[mir]~| ERROR (Mir) [E0499]
|
|
||||||
_ => { addr = &mut x; } //[ast]~ ERROR [E0499]
|
_ => { addr = &mut x; } //[ast]~ ERROR [E0499]
|
||||||
//[mir]~^ ERROR (Ast) [E0499]
|
//[mir]~^ ERROR [E0506]
|
||||||
//[mir]~| ERROR (Mir) [E0506]
|
//[mir]~| ERROR [E0499]
|
||||||
//[mir]~| ERROR (Mir) [E0499]
|
//[mir]~| ERROR [E0499]
|
||||||
//[mir]~| ERROR (Mir) [E0499]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
// here is rather subtle. Issue #20232.
|
// here is rather subtle. Issue #20232.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
use std::ops::{Deref, Index};
|
use std::ops::{Deref, Index};
|
||||||
|
|
||||||
|
@ -43,8 +43,7 @@ fn main() {
|
||||||
let i = &v[0].f;
|
let i = &v[0].f;
|
||||||
v = MyVec { x: MyPtr { x: Foo { f: 23 } } };
|
v = MyVec { x: MyPtr { x: Foo { f: 23 } } };
|
||||||
//[ast]~^ ERROR cannot assign to `v`
|
//[ast]~^ ERROR cannot assign to `v`
|
||||||
//[mir]~^^ ERROR cannot assign to `v` because it is borrowed (Ast)
|
//[mir]~^^ ERROR cannot assign to `v` because it is borrowed
|
||||||
//[mir]~| ERROR cannot assign to `v` because it is borrowed (Mir)
|
|
||||||
read(*i);
|
read(*i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
use std::ops::{Index, IndexMut};
|
use std::ops::{Index, IndexMut};
|
||||||
|
|
||||||
|
@ -61,17 +61,14 @@ fn main() {
|
||||||
let rs = &mut s;
|
let rs = &mut s;
|
||||||
println!("{}", f[&s]);
|
println!("{}", f[&s]);
|
||||||
//[ast]~^ 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]~| ERROR cannot borrow `s` as immutable because it is also borrowed as mutable (Mir)
|
|
||||||
f[&s] = 10;
|
f[&s] = 10;
|
||||||
//[ast]~^ 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]~| ERROR cannot borrow `s` as immutable because it is also borrowed as mutable (Mir)
|
|
||||||
let s = Bar {
|
let s = Bar {
|
||||||
x: 1,
|
x: 1,
|
||||||
};
|
};
|
||||||
s[2] = 20;
|
s[2] = 20;
|
||||||
//[ast]~^ ERROR cannot assign to immutable indexed content
|
//[ast]~^ ERROR cannot assign to immutable indexed content
|
||||||
//[mir]~^^ ERROR cannot assign to immutable indexed content
|
|
||||||
// FIXME Error for MIR
|
// FIXME Error for MIR
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut x: Option<isize> = None;
|
let mut x: Option<isize> = None;
|
||||||
|
@ -21,8 +21,7 @@ fn main() {
|
||||||
Some(ref i) => {
|
Some(ref i) => {
|
||||||
// But on this branch, `i` is an outstanding borrow
|
// But on this branch, `i` is an outstanding borrow
|
||||||
x = Some(*i+1); //[ast]~ ERROR cannot assign to `x`
|
x = Some(*i+1); //[ast]~ ERROR cannot assign to `x`
|
||||||
//[mir]~^ ERROR cannot assign to `x` because it is borrowed (Ast)
|
//[mir]~^ ERROR cannot assign to `x` because it is borrowed
|
||||||
//[mir]~| ERROR cannot assign to `x` because it is borrowed (Mir)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
x.clone(); // just to prevent liveness warnings
|
x.clone(); // just to prevent liveness warnings
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// compile-flags: -Z emit-end-regions -Z borrowck-mir
|
// compile-flags: -Z borrowck=compare
|
||||||
|
|
||||||
fn ok() {
|
fn ok() {
|
||||||
loop {
|
loop {
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
// Issue 4691: Ensure that functional-struct-update can only copy, not
|
// Issue 4691: Ensure that functional-struct-update can only copy, not
|
||||||
// move, when the struct implements Drop.
|
// move, when the struct implements Drop.
|
||||||
|
@ -24,15 +24,13 @@ impl Drop for T { fn drop(&mut self) { } }
|
||||||
fn f(s0:S) {
|
fn f(s0:S) {
|
||||||
let _s2 = S{a: 2, ..s0};
|
let _s2 = S{a: 2, ..s0};
|
||||||
//[ast]~^ error: cannot move out of type `S`, which implements the `Drop` trait
|
//[ast]~^ error: cannot move out of type `S`, which implements the `Drop` trait
|
||||||
//[mir]~^^ ERROR (Ast) [E0509]
|
//[mir]~^^ ERROR [E0509]
|
||||||
//[mir]~| ERROR (Mir) [E0509]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn g(s0:T) {
|
fn g(s0:T) {
|
||||||
let _s2 = T{a: 2, ..s0};
|
let _s2 = T{a: 2, ..s0};
|
||||||
//[ast]~^ error: cannot move out of type `T`, which implements the `Drop` trait
|
//[ast]~^ error: cannot move out of type `T`, which implements the `Drop` trait
|
||||||
//[mir]~^^ ERROR (Ast) [E0509]
|
//[mir]~^^ ERROR [E0509]
|
||||||
//[mir]~| ERROR (Mir) [E0509]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() { }
|
fn main() { }
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
#![feature(thread_local)]
|
#![feature(thread_local)]
|
||||||
|
|
||||||
|
@ -19,6 +19,5 @@ static FOO: u8 = 3;
|
||||||
fn assert_static(_t: &'static u8) {}
|
fn assert_static(_t: &'static u8) {}
|
||||||
fn main() {
|
fn main() {
|
||||||
assert_static(&FOO); //[ast]~ ERROR [E0597]
|
assert_static(&FOO); //[ast]~ ERROR [E0597]
|
||||||
//[mir]~^ ERROR (Ast) [E0597]
|
//[mir]~^ ERROR [E0597]
|
||||||
//[mir]~| ERROR (Mir) [E0597]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,13 +10,12 @@
|
||||||
|
|
||||||
// ignore-tidy-linelength
|
// ignore-tidy-linelength
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
fn foo(x: Box<isize>) -> isize {
|
fn foo(x: Box<isize>) -> isize {
|
||||||
let y = &*x;
|
let y = &*x;
|
||||||
free(x); //[ast]~ ERROR cannot move out of `x` because it is borrowed
|
free(x); //[ast]~ ERROR cannot move out of `x` because it is borrowed
|
||||||
//[mir]~^ ERROR cannot move out of `x` because it is borrowed (Ast)
|
//[mir]~^ ERROR cannot move out of `x` because it is borrowed
|
||||||
//[mir]~| ERROR cannot move out of `x` because it is borrowed (Mir)
|
|
||||||
*y
|
*y
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
// Check that do not allow access to fields of uninitialized or moved
|
// Check that do not allow access to fields of uninitialized or moved
|
||||||
// structs.
|
// structs.
|
||||||
|
@ -32,18 +32,15 @@ impl Line { fn consume(self) { } }
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut a: Point;
|
let mut a: Point;
|
||||||
let _ = a.x + 1; //[ast]~ ERROR use of possibly uninitialized variable: `a.x`
|
let _ = a.x + 1; //[ast]~ ERROR use of possibly uninitialized variable: `a.x`
|
||||||
//[mir]~^ ERROR [E0381]
|
//[mir]~^ ERROR [E0381]
|
||||||
//[mir]~| ERROR (Mir) [E0381]
|
|
||||||
|
|
||||||
let mut line1 = Line::default();
|
let mut line1 = Line::default();
|
||||||
let _moved = line1.origin;
|
let _moved = line1.origin;
|
||||||
let _ = line1.origin.x + 1; //[ast]~ ERROR use of collaterally moved value: `line1.origin.x`
|
let _ = line1.origin.x + 1; //[ast]~ ERROR use of collaterally moved value: `line1.origin.x`
|
||||||
//[mir]~^ [E0382]
|
//[mir]~^ [E0382]
|
||||||
//[mir]~| (Mir) [E0382]
|
|
||||||
|
|
||||||
let mut line2 = Line::default();
|
let mut line2 = Line::default();
|
||||||
let _moved = (line2.origin, line2.middle);
|
let _moved = (line2.origin, line2.middle);
|
||||||
line2.consume(); //[ast]~ ERROR use of partially moved value: `line2` [E0382]
|
line2.consume(); //[ast]~ ERROR use of partially moved value: `line2` [E0382]
|
||||||
//[mir]~^ [E0382]
|
//[mir]~^ [E0382]
|
||||||
//[mir]~| (Mir) [E0382]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
struct S<X, Y> {
|
struct S<X, Y> {
|
||||||
x: X,
|
x: X,
|
||||||
|
@ -19,42 +19,35 @@ struct S<X, Y> {
|
||||||
fn main() {
|
fn main() {
|
||||||
let x: &&Box<i32>;
|
let x: &&Box<i32>;
|
||||||
let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381]
|
let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381]
|
||||||
//[mir]~^ (Ast) [E0381]
|
//[mir]~^ [E0381]
|
||||||
//[mir]~| (Mir) [E0381]
|
|
||||||
|
|
||||||
let x: &&S<i32, i32>;
|
let x: &&S<i32, i32>;
|
||||||
let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381]
|
let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381]
|
||||||
//[mir]~^ (Ast) [E0381]
|
//[mir]~^ [E0381]
|
||||||
//[mir]~| (Mir) [E0381]
|
|
||||||
|
|
||||||
let x: &&i32;
|
let x: &&i32;
|
||||||
let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381]
|
let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381]
|
||||||
//[mir]~^ (Ast) [E0381]
|
//[mir]~^ [E0381]
|
||||||
//[mir]~| (Mir) [E0381]
|
|
||||||
|
|
||||||
|
|
||||||
let mut a: S<i32, i32>;
|
let mut a: S<i32, i32>;
|
||||||
a.x = 0;
|
a.x = 0;
|
||||||
let _b = &a.x; //[ast]~ ERROR use of possibly uninitialized variable: `a.x` [E0381]
|
let _b = &a.x; //[ast]~ ERROR use of possibly uninitialized variable: `a.x` [E0381]
|
||||||
//[mir]~^ ERROR (Ast) [E0381]
|
|
||||||
// (deliberately *not* an error under MIR-borrowck)
|
// (deliberately *not* an error under MIR-borrowck)
|
||||||
|
|
||||||
let mut a: S<&&i32, &&i32>;
|
let mut a: S<&&i32, &&i32>;
|
||||||
a.x = &&0;
|
a.x = &&0;
|
||||||
let _b = &**a.x; //[ast]~ ERROR use of possibly uninitialized variable: `**a.x` [E0381]
|
let _b = &**a.x; //[ast]~ ERROR use of possibly uninitialized variable: `**a.x` [E0381]
|
||||||
//[mir]~^ ERROR (Ast) [E0381]
|
|
||||||
// (deliberately *not* an error under MIR-borrowck)
|
// (deliberately *not* an error under MIR-borrowck)
|
||||||
|
|
||||||
|
|
||||||
let mut a: S<i32, i32>;
|
let mut a: S<i32, i32>;
|
||||||
a.x = 0;
|
a.x = 0;
|
||||||
let _b = &a.y; //[ast]~ ERROR use of possibly uninitialized variable: `a.y` [E0381]
|
let _b = &a.y; //[ast]~ ERROR use of possibly uninitialized variable: `a.y` [E0381]
|
||||||
//[mir]~^ ERROR (Ast) [E0381]
|
//[mir]~^ ERROR [E0381]
|
||||||
//[mir]~| ERROR (Mir) [E0381]
|
|
||||||
|
|
||||||
let mut a: S<&&i32, &&i32>;
|
let mut a: S<&&i32, &&i32>;
|
||||||
a.x = &&0;
|
a.x = &&0;
|
||||||
let _b = &**a.y; //[ast]~ ERROR use of possibly uninitialized variable: `**a.y` [E0381]
|
let _b = &**a.y; //[ast]~ ERROR use of possibly uninitialized variable: `**a.y` [E0381]
|
||||||
//[mir]~^ ERROR (Ast) [E0381]
|
//[mir]~^ ERROR [E0381]
|
||||||
//[mir]~| ERROR (Mir) [E0381]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
// ignore-tidy-linelength
|
// ignore-tidy-linelength
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
union U {
|
union U {
|
||||||
|
@ -33,14 +33,12 @@ fn main() {
|
||||||
{
|
{
|
||||||
let ra = &u.a;
|
let ra = &u.a;
|
||||||
let rma = &mut u.a; //[ast]~ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable
|
let rma = &mut u.a; //[ast]~ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable
|
||||||
//[mir]~^ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable (Ast)
|
//[mir]~^ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable
|
||||||
//[mir]~| ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable (Mir)
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
let ra = &u.a;
|
let ra = &u.a;
|
||||||
u.a = 1; //[ast]~ ERROR cannot assign to `u.a` because it is borrowed
|
u.a = 1; //[ast]~ ERROR cannot assign to `u.a` because it is borrowed
|
||||||
//[mir]~^ ERROR cannot assign to `u.a` because it is borrowed (Ast)
|
//[mir]~^ ERROR cannot assign to `u.a` because it is borrowed
|
||||||
//[mir]~| ERROR cannot assign to `u.a` because it is borrowed (Mir)
|
|
||||||
}
|
}
|
||||||
// Imm borrow, other field
|
// Imm borrow, other field
|
||||||
{
|
{
|
||||||
|
@ -54,63 +52,53 @@ fn main() {
|
||||||
{
|
{
|
||||||
let ra = &u.a;
|
let ra = &u.a;
|
||||||
let rmb = &mut u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as mutable because `u` is also borrowed as immutable (via `u.a`)
|
let rmb = &mut u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as mutable because `u` is also borrowed as immutable (via `u.a`)
|
||||||
//[mir]~^ ERROR cannot borrow `u` (via `u.b`) as mutable because `u` is also borrowed as immutable (via `u.a`) (Ast)
|
|
||||||
// FIXME Error for MIR (needs support for union)
|
// FIXME Error for MIR (needs support for union)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
let ra = &u.a;
|
let ra = &u.a;
|
||||||
u.b = 1; //[ast]~ ERROR cannot assign to `u.b` because it is borrowed
|
u.b = 1; //[ast]~ ERROR cannot assign to `u.b` because it is borrowed
|
||||||
//[mir]~^ ERROR cannot assign to `u.b` because it is borrowed (Ast)
|
|
||||||
// FIXME Error for MIR (needs support for union)
|
// FIXME Error for MIR (needs support for union)
|
||||||
}
|
}
|
||||||
// Mut borrow, same field
|
// Mut borrow, same field
|
||||||
{
|
{
|
||||||
let rma = &mut u.a;
|
let rma = &mut u.a;
|
||||||
let ra = &u.a; //[ast]~ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable
|
let ra = &u.a; //[ast]~ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable
|
||||||
//[mir]~^ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable (Ast)
|
//[mir]~^ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable
|
||||||
//[mir]~| ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable (Mir)
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
let ra = &mut u.a;
|
let ra = &mut u.a;
|
||||||
let a = u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed
|
let a = u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed
|
||||||
//[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed (Ast)
|
//[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed
|
||||||
//[mir]~| ERROR cannot use `u.a` because it was mutably borrowed (Mir)
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
let rma = &mut u.a;
|
let rma = &mut u.a;
|
||||||
let rma2 = &mut u.a; //[ast]~ ERROR cannot borrow `u.a` as mutable more than once at a time
|
let rma2 = &mut u.a; //[ast]~ ERROR cannot borrow `u.a` as mutable more than once at a time
|
||||||
//[mir]~^ ERROR cannot borrow `u.a` as mutable more than once at a time (Ast)
|
//[mir]~^ ERROR cannot borrow `u.a` as mutable more than once at a time
|
||||||
//[mir]~| ERROR cannot borrow `u.a` as mutable more than once at a time (Mir)
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
let rma = &mut u.a;
|
let rma = &mut u.a;
|
||||||
u.a = 1; //[ast]~ ERROR cannot assign to `u.a` because it is borrowed
|
u.a = 1; //[ast]~ ERROR cannot assign to `u.a` because it is borrowed
|
||||||
//[mir]~^ ERROR cannot assign to `u.a` because it is borrowed (Ast)
|
//[mir]~^ ERROR cannot assign to `u.a` because it is borrowed
|
||||||
//[mir]~| ERROR cannot assign to `u.a` because it is borrowed (Mir)
|
|
||||||
}
|
}
|
||||||
// Mut borrow, other field
|
// Mut borrow, other field
|
||||||
{
|
{
|
||||||
let rma = &mut u.a;
|
let rma = &mut u.a;
|
||||||
let rb = &u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as immutable because `u` is also borrowed as mutable (via `u.a`)
|
let rb = &u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as immutable because `u` is also borrowed as mutable (via `u.a`)
|
||||||
//[mir]~^ ERROR cannot borrow `u` (via `u.b`) as immutable because `u` is also borrowed as mutable (via `u.a`) (Ast)
|
|
||||||
// FIXME Error for MIR (needs support for union)
|
// FIXME Error for MIR (needs support for union)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
let ra = &mut u.a;
|
let ra = &mut u.a;
|
||||||
let b = u.b; //[ast]~ ERROR cannot use `u.b` because it was mutably borrowed
|
let b = u.b; //[ast]~ ERROR cannot use `u.b` because it was mutably borrowed
|
||||||
//[mir]~^ ERROR cannot use `u.b` because it was mutably borrowed (Ast)
|
|
||||||
// FIXME Error for MIR (needs support for union)
|
// FIXME Error for MIR (needs support for union)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
let rma = &mut u.a;
|
let rma = &mut u.a;
|
||||||
let rmb2 = &mut u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as mutable more than once at a time
|
let rmb2 = &mut u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as mutable more than once at a time
|
||||||
//[mir]~^ ERROR cannot borrow `u` (via `u.b`) as mutable more than once at a time (Ast)
|
|
||||||
// FIXME Error for MIR (needs support for union)
|
// FIXME Error for MIR (needs support for union)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
let rma = &mut u.a;
|
let rma = &mut u.a;
|
||||||
u.b = 1; //[ast]~ ERROR cannot assign to `u.b` because it is borrowed
|
u.b = 1; //[ast]~ ERROR cannot assign to `u.b` because it is borrowed
|
||||||
//[mir]~^ ERROR cannot assign to `u.b` because it is borrowed (Ast)
|
|
||||||
// FIXME Error for MIR (needs support for union)
|
// FIXME Error for MIR (needs support for union)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,18 +9,16 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
fn test() {
|
fn test() {
|
||||||
let w: &mut [isize];
|
let w: &mut [isize];
|
||||||
w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381]
|
w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381]
|
||||||
//[mir]~^ ERROR (Ast) [E0381]
|
//[mir]~^ ERROR [E0381]
|
||||||
//[mir]~| ERROR (Mir) [E0381]
|
|
||||||
|
|
||||||
let mut w: &mut [isize];
|
let mut w: &mut [isize];
|
||||||
w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381]
|
w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381]
|
||||||
//[mir]~^ ERROR (Ast) [E0381]
|
//[mir]~^ ERROR [E0381]
|
||||||
//[mir]~| ERROR (Mir) [E0381]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() { test(); }
|
fn main() { test(); }
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
// Variation on `borrowck-use-uninitialized-in-cast` in which we do a
|
// Variation on `borrowck-use-uninitialized-in-cast` in which we do a
|
||||||
// trait cast from an uninitialized source. Issue #20791.
|
// trait cast from an uninitialized source. Issue #20791.
|
||||||
|
@ -20,6 +20,5 @@ impl Foo for i32 { }
|
||||||
fn main() {
|
fn main() {
|
||||||
let x: &i32;
|
let x: &i32;
|
||||||
let y = x as *const Foo; //[ast]~ ERROR use of possibly uninitialized variable: `*x`
|
let y = x as *const Foo; //[ast]~ ERROR use of possibly uninitialized variable: `*x`
|
||||||
//[mir]~^ ERROR (Ast) [E0381]
|
//[mir]~^ ERROR [E0381]
|
||||||
//[mir]~| ERROR (Mir) [E0381]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
// Check that we detect unused values that are cast to other things.
|
// Check that we detect unused values that are cast to other things.
|
||||||
// The problem was specified to casting to `*`, as creating unsafe
|
// The problem was specified to casting to `*`, as creating unsafe
|
||||||
|
@ -18,6 +18,5 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
let x: &i32;
|
let x: &i32;
|
||||||
let y = x as *const i32; //[ast]~ ERROR use of possibly uninitialized variable: `*x` [E0381]
|
let y = x as *const i32; //[ast]~ ERROR use of possibly uninitialized variable: `*x` [E0381]
|
||||||
//[mir]~^ ERROR (Ast) [E0381]
|
//[mir]~^ ERROR [E0381]
|
||||||
//[mir]~| ERROR (Mir) [E0381]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast cmp
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[cmp]compile-flags: -Z borrowck=compare
|
||||||
|
|
||||||
#![feature(slice_patterns)]
|
#![feature(slice_patterns)]
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ fn main() {
|
||||||
};
|
};
|
||||||
println!("t[0]: {}", t[0]);
|
println!("t[0]: {}", t[0]);
|
||||||
a[2] = 0; //[ast]~ ERROR cannot assign to `a[..]` because it is borrowed
|
a[2] = 0; //[ast]~ ERROR cannot assign to `a[..]` because it is borrowed
|
||||||
//[mir]~^ ERROR cannot assign to `a[..]` because it is borrowed (Ast)
|
//[cmp]~^ ERROR cannot assign to `a[..]` because it is borrowed (Ast)
|
||||||
// FIXME Error for MIR (error missed)
|
// FIXME Error for MIR (error missed)
|
||||||
println!("t[0]: {}", t[0]);
|
println!("t[0]: {}", t[0]);
|
||||||
t[0];
|
t[0];
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
// Regression test for #38520. Check that moves of `Foo` are not
|
// Regression test for #38520. Check that moves of `Foo` are not
|
||||||
// permitted as `Foo` is not copy (even in a static/const
|
// permitted as `Foo` is not copy (even in a static/const
|
||||||
|
@ -25,11 +25,9 @@ const fn get(x: Foo) -> usize {
|
||||||
|
|
||||||
const X: Foo = Foo(22);
|
const X: Foo = Foo(22);
|
||||||
static Y: usize = get(*&X); //[ast]~ ERROR E0507
|
static Y: usize = get(*&X); //[ast]~ ERROR E0507
|
||||||
//[mir]~^ ERROR (Ast) [E0507]
|
//[mir]~^ ERROR [E0507]
|
||||||
//[mir]~| ERROR (Mir) [E0507]
|
|
||||||
const Z: usize = get(*&X); //[ast]~ ERROR E0507
|
const Z: usize = get(*&X); //[ast]~ ERROR E0507
|
||||||
//[mir]~^ ERROR (Ast) [E0507]
|
//[mir]~^ ERROR [E0507]
|
||||||
//[mir]~| ERROR (Mir) [E0507]
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
fn borrow_mut<T>(x: &mut T) -> &mut T { x }
|
fn borrow_mut<T>(x: &mut T) -> &mut T { x }
|
||||||
fn borrow<T>(x: &T) -> &T { x }
|
fn borrow<T>(x: &T) -> &T { x }
|
||||||
|
@ -21,8 +21,7 @@ fn double_mut_borrow<T>(x: &mut Box<T>) {
|
||||||
let y = borrow_mut(x);
|
let y = borrow_mut(x);
|
||||||
let z = borrow_mut(x);
|
let z = borrow_mut(x);
|
||||||
//[ast]~^ ERROR cannot borrow `*x` as mutable more than once at a time
|
//[ast]~^ ERROR cannot borrow `*x` as mutable more than once at a time
|
||||||
//[mir]~^^ ERROR cannot borrow `*x` as mutable more than once at a time (Ast)
|
//[mir]~^^ ERROR cannot borrow `*x` as mutable more than once at a time
|
||||||
//[mir]~| ERROR cannot borrow `*x` as mutable more than once at a time (Mir)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn double_imm_borrow(x: &mut Box<i32>) {
|
fn double_imm_borrow(x: &mut Box<i32>) {
|
||||||
|
@ -30,22 +29,19 @@ fn double_imm_borrow(x: &mut Box<i32>) {
|
||||||
let z = borrow(x);
|
let z = borrow(x);
|
||||||
**x += 1;
|
**x += 1;
|
||||||
//[ast]~^ ERROR cannot assign to `**x` because it is borrowed
|
//[ast]~^ ERROR cannot assign to `**x` because it is borrowed
|
||||||
//[mir]~^^ ERROR cannot assign to `**x` because it is borrowed (Ast)
|
//[mir]~^^ ERROR cannot assign to `**x` because it is borrowed
|
||||||
//[mir]~| ERROR cannot assign to `**x` because it is borrowed (Mir)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn double_mut_borrow2<T>(x: &mut Box<T>) {
|
fn double_mut_borrow2<T>(x: &mut Box<T>) {
|
||||||
borrow_mut2(x, x);
|
borrow_mut2(x, x);
|
||||||
//[ast]~^ ERROR cannot borrow `*x` as mutable more than once at a time
|
//[ast]~^ ERROR cannot borrow `*x` as mutable more than once at a time
|
||||||
//[mir]~^^ ERROR cannot borrow `*x` as mutable more than once at a time (Ast)
|
//[mir]~^^ ERROR cannot borrow `*x` as mutable more than once at a time
|
||||||
//[mir]~| ERROR cannot borrow `*x` as mutable more than once at a time (Mir)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn double_borrow2<T>(x: &mut Box<T>) {
|
fn double_borrow2<T>(x: &mut Box<T>) {
|
||||||
borrow2(x, x);
|
borrow2(x, x);
|
||||||
//[ast]~^ ERROR cannot borrow `*x` as immutable because it is also borrowed as mutable
|
//[ast]~^ ERROR cannot borrow `*x` as immutable because it is also borrowed as mutable
|
||||||
//[mir]~^^ ERROR cannot borrow `*x` as immutable because it is also borrowed as mutable (Ast)
|
//[mir]~^^ ERROR cannot borrow `*x` as immutable because it is also borrowed as mutable
|
||||||
//[mir]~| ERROR cannot borrow `*x` as immutable because it is also borrowed as mutable (Mir)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {}
|
pub fn main() {}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// of the output to the region of the input.
|
// of the output to the region of the input.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
trait FnLike<A,R> {
|
trait FnLike<A,R> {
|
||||||
fn call(&self, arg: A) -> R;
|
fn call(&self, arg: A) -> R;
|
||||||
|
@ -25,8 +25,7 @@ fn call_repeatedly<F>(f: F)
|
||||||
let mut x = 3;
|
let mut x = 3;
|
||||||
let y = f.call(&x);
|
let y = f.call(&x);
|
||||||
x = 5; //[ast]~ ERROR cannot assign
|
x = 5; //[ast]~ ERROR cannot assign
|
||||||
//[mir]~^ ERROR cannot assign to `x` because it is borrowed (Ast)
|
//[mir]~^ ERROR cannot assign to `x` because it is borrowed
|
||||||
//[mir]~| ERROR cannot assign to `x` because it is borrowed (Mir)
|
|
||||||
|
|
||||||
// Result is not stored: can re-assign `x`
|
// Result is not stored: can re-assign `x`
|
||||||
let mut x = 3;
|
let mut x = 3;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
enum Sexpression {
|
enum Sexpression {
|
||||||
Num(()),
|
Num(()),
|
||||||
|
@ -20,15 +20,13 @@ fn causes_ice(mut l: &mut Sexpression) {
|
||||||
loop { match l {
|
loop { match l {
|
||||||
&mut Sexpression::Num(ref mut n) => {},
|
&mut Sexpression::Num(ref mut n) => {},
|
||||||
&mut Sexpression::Cons(ref mut expr) => { //[ast]~ ERROR [E0499]
|
&mut Sexpression::Cons(ref mut expr) => { //[ast]~ ERROR [E0499]
|
||||||
//[mir]~^ ERROR (Ast) [E0499]
|
//[mir]~^ ERROR [E0506]
|
||||||
//[mir]~| ERROR (Mir) [E0506]
|
//[mir]~| ERROR [E0499]
|
||||||
//[mir]~| ERROR (Mir) [E0499]
|
|
||||||
l = &mut **expr; //[ast]~ ERROR [E0506]
|
l = &mut **expr; //[ast]~ ERROR [E0506]
|
||||||
//[mir]~^ ERROR (Ast) [E0506]
|
//[mir]~^ ERROR [E0506]
|
||||||
//[mir]~| ERROR (Mir) [E0506]
|
//[mir]~| ERROR [E0506]
|
||||||
//[mir]~| ERROR (Mir) [E0506]
|
//[mir]~| ERROR [E0499]
|
||||||
//[mir]~| ERROR (Mir) [E0499]
|
//[mir]~| ERROR [E0499]
|
||||||
//[mir]~| ERROR (Mir) [E0499]
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
|
||||||
|
@ -23,11 +23,7 @@ fn main() {
|
||||||
//[ast]~| NOTE temporary value dropped here while still borrowed
|
//[ast]~| NOTE temporary value dropped here while still borrowed
|
||||||
//[ast]~| NOTE temporary value created here
|
//[ast]~| NOTE temporary value created here
|
||||||
//[ast]~| NOTE consider using a `let` binding to increase its lifetime
|
//[ast]~| NOTE consider using a `let` binding to increase its lifetime
|
||||||
//[mir]~^^^^^ ERROR borrowed value does not live long enough (Ast) [E0597]
|
//[mir]~^^^^^ ERROR borrowed value does not live long enough [E0597]
|
||||||
//[mir]~| NOTE temporary value dropped here while still borrowed
|
|
||||||
//[mir]~| NOTE temporary value created here
|
|
||||||
//[mir]~| NOTE consider using a `let` binding to increase its lifetime
|
|
||||||
//[mir]~| ERROR borrowed value does not live long enough (Mir) [E0597]
|
|
||||||
//[mir]~| NOTE temporary value dropped here while still borrowed
|
//[mir]~| NOTE temporary value dropped here while still borrowed
|
||||||
//[mir]~| NOTE temporary value created here
|
//[mir]~| NOTE temporary value created here
|
||||||
//[mir]~| NOTE consider using a `let` binding to increase its lifetime
|
//[mir]~| NOTE consider using a `let` binding to increase its lifetime
|
||||||
|
@ -35,4 +31,3 @@ fn main() {
|
||||||
}
|
}
|
||||||
//[ast]~^ NOTE temporary value needs to live until here
|
//[ast]~^ NOTE temporary value needs to live until here
|
||||||
//[mir]~^^ NOTE temporary value needs to live until here
|
//[mir]~^^ NOTE temporary value needs to live until here
|
||||||
//[mir]~| NOTE temporary value needs to live until here
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=compare
|
||||||
|
|
||||||
struct TrieMapIterator<'a> {
|
struct TrieMapIterator<'a> {
|
||||||
node: &'a usize
|
node: &'a usize
|
||||||
|
@ -18,7 +18,7 @@ struct TrieMapIterator<'a> {
|
||||||
fn main() {
|
fn main() {
|
||||||
let a = 5;
|
let a = 5;
|
||||||
let _iter = TrieMapIterator{node: &a};
|
let _iter = TrieMapIterator{node: &a};
|
||||||
_iter.node = & //[ast]~ ERROR cannot assign to immutable field
|
_iter.node = & //[ast]~ ERROR cannot assign to immutable field `_iter.node`
|
||||||
//[mir]~^ ERROR cannot assign to immutable field `_iter.node` (Ast)
|
//[mir]~^ ERROR cannot assign to immutable field `_iter.node` (Ast)
|
||||||
// FIXME Error for MIR
|
// FIXME Error for MIR
|
||||||
panic!()
|
panic!()
|
||||||
|
|
|
@ -9,15 +9,14 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let foo = &mut 1;
|
let foo = &mut 1;
|
||||||
|
|
||||||
let &mut x = foo;
|
let &mut x = foo;
|
||||||
x += 1; //[ast]~ ERROR cannot assign twice to immutable variable
|
x += 1; //[ast]~ ERROR cannot assign twice to immutable variable
|
||||||
//[mir]~^ ERROR cannot assign twice to immutable variable `x` (Ast)
|
//[mir]~^ ERROR cannot assign twice to immutable variable `x`
|
||||||
//[mir]~| ERROR cannot assign twice to immutable variable `x` (Mir)
|
|
||||||
|
|
||||||
// explicitly mut-ify internals
|
// explicitly mut-ify internals
|
||||||
let &mut mut x = foo;
|
let &mut mut x = foo;
|
||||||
|
@ -26,6 +25,5 @@ fn main() {
|
||||||
// check borrowing is detected successfully
|
// check borrowing is detected successfully
|
||||||
let &mut ref x = foo;
|
let &mut ref x = foo;
|
||||||
*foo += 1; //[ast]~ ERROR cannot assign to `*foo` because it is borrowed
|
*foo += 1; //[ast]~ ERROR cannot assign to `*foo` because it is borrowed
|
||||||
//[mir]~^ ERROR cannot assign to `*foo` because it is borrowed (Ast)
|
//[mir]~^ ERROR cannot assign to `*foo` because it is borrowed
|
||||||
//[mir]~| ERROR cannot assign to `*foo` because it is borrowed (Mir)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
// compile-flags:-Zborrowck-mir -Znll
|
// compile-flags:-Zborrowck=compare -Znll
|
||||||
|
|
||||||
#![allow(warnings)]
|
#![allow(warnings)]
|
||||||
#![feature(rustc_attrs)]
|
#![feature(rustc_attrs)]
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
// compile-flags:-Zborrowck-mir -Znll
|
// compile-flags:-Zborrowck=compare -Znll
|
||||||
|
|
||||||
#![allow(warnings)]
|
#![allow(warnings)]
|
||||||
#![feature(rustc_attrs)]
|
#![feature(rustc_attrs)]
|
||||||
|
|
|
@ -7,8 +7,9 @@
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
//revisions: ast mir
|
//revisions: ast mir
|
||||||
//[mir] compile-flags: -Z emit-end-regions -Z borrowck-mir -Z nll
|
//[mir] compile-flags: -Z borrowck=mir -Z nll
|
||||||
|
|
||||||
#![allow(unused_assignments)]
|
#![allow(unused_assignments)]
|
||||||
|
|
||||||
|
@ -18,10 +19,9 @@ fn foo() {
|
||||||
let mut x = 22;
|
let mut x = 22;
|
||||||
let wrapper = Wrap { w: &mut x };
|
let wrapper = Wrap { w: &mut x };
|
||||||
x += 1; //[ast]~ ERROR cannot assign to `x` because it is borrowed [E0506]
|
x += 1; //[ast]~ ERROR cannot assign to `x` because it is borrowed [E0506]
|
||||||
//[mir]~^ ERROR cannot assign to `x` because it is borrowed (Ast) [E0506]
|
//[mir]~^ ERROR cannot assign to `x` because it is borrowed [E0506]
|
||||||
//[mir]~^^ ERROR cannot assign to `x` because it is borrowed (Mir) [E0506]
|
//[mir]~^^ ERROR cannot use `x` because it was mutably borrowed [E0503]
|
||||||
//[mir]~^^^ ERROR cannot use `x` because it was mutably borrowed (Mir) [E0503]
|
|
||||||
*wrapper.w += 1;
|
*wrapper.w += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() { }
|
fn main() { }
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// in the type of `p` includes the points after `&v[0]` up to (but not
|
// in the type of `p` includes the points after `&v[0]` up to (but not
|
||||||
// including) the call to `use_x`. The `else` branch is not included.
|
// including) the call to `use_x`. The `else` branch is not included.
|
||||||
|
|
||||||
// compile-flags:-Zborrowck-mir -Znll
|
// compile-flags:-Zborrowck=compare -Znll
|
||||||
|
|
||||||
#![allow(warnings)]
|
#![allow(warnings)]
|
||||||
#![feature(rustc_attrs)]
|
#![feature(rustc_attrs)]
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// in the type of `p` includes the points after `&v[0]` up to (but not
|
// in the type of `p` includes the points after `&v[0]` up to (but not
|
||||||
// including) the call to `use_x`. The `else` branch is not included.
|
// including) the call to `use_x`. The `else` branch is not included.
|
||||||
|
|
||||||
// compile-flags:-Zborrowck-mir -Znll
|
// compile-flags:-Zborrowck=compare -Znll
|
||||||
|
|
||||||
#![allow(warnings)]
|
#![allow(warnings)]
|
||||||
#![feature(rustc_attrs)]
|
#![feature(rustc_attrs)]
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let a0 = 0;
|
let a0 = 0;
|
||||||
|
@ -18,8 +18,7 @@ fn main() {
|
||||||
match (&a1,) {
|
match (&a1,) {
|
||||||
(&ref b0,) => {
|
(&ref b0,) => {
|
||||||
a1 = &f; //[ast]~ ERROR cannot assign
|
a1 = &f; //[ast]~ ERROR cannot assign
|
||||||
//[mir]~^ ERROR cannot assign to `a1` because it is borrowed (Ast)
|
//[mir]~^ ERROR cannot assign to `a1` because it is borrowed
|
||||||
//[mir]~| ERROR cannot assign to `a1` because it is borrowed (Mir)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// compile-flags: -Z identify_regions -Z span_free_formats -Z emit-end-regions
|
// compile-flags: -Z identify_regions -Z span_free_formats -Z emit-end-regions
|
||||||
// ignore-tidy-linelength
|
|
||||||
|
|
||||||
// Unwinding should EndRegion for in-scope borrows: Borrowing via by-ref closure.
|
// Unwinding should EndRegion for in-scope borrows: Borrowing via by-ref closure.
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// compile-flags: -Z emit-end-regions -Z borrowck-mir
|
// compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
fn guard() -> bool {
|
fn guard() -> bool {
|
||||||
false
|
false
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
// error-pattern:panic 1
|
// error-pattern:panic 1
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = 2;
|
let x = 2;
|
||||||
|
|
|
@ -10,9 +10,8 @@
|
||||||
|
|
||||||
// Test taken from #45641 (https://github.com/rust-lang/rust/issues/45641)
|
// Test taken from #45641 (https://github.com/rust-lang/rust/issues/45641)
|
||||||
|
|
||||||
// ignore-tidy-linelength
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
static mut Y: u32 = 0;
|
static mut Y: u32 = 0;
|
||||||
|
|
||||||
|
@ -20,4 +19,4 @@ unsafe fn should_ok() {
|
||||||
Y = 1;
|
Y = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// revisions: ast mir
|
// revisions: ast mir
|
||||||
//[mir]compile-flags: -Z emit-end-regions -Z borrowck-mir
|
//[mir]compile-flags: -Z borrowck=mir
|
||||||
|
|
||||||
// Test file taken from issue 45129 (https://github.com/rust-lang/rust/issues/45129)
|
// Test file taken from issue 45129 (https://github.com/rust-lang/rust/issues/45129)
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// access to the variable, whether that mutable access be used
|
// access to the variable, whether that mutable access be used
|
||||||
// for direct assignment or for taking mutable ref. Issue #6801.
|
// for direct assignment or for taking mutable ref. Issue #6801.
|
||||||
|
|
||||||
// compile-flags: -Z emit-end-regions -Z borrowck-mir
|
// compile-flags: -Z borrowck=compare
|
||||||
|
|
||||||
#![feature(box_syntax)]
|
#![feature(box_syntax)]
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
// compile-flags: -Z borrowck-mir -Z emit-end-regions
|
// compile-flags: -Z borrowck=compare
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut x = Box::new(0);
|
let mut x = Box::new(0);
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// a variety of errors from the older, AST-based machinery (notably
|
// a variety of errors from the older, AST-based machinery (notably
|
||||||
// borrowck), and then we get the NLL error at the end.
|
// borrowck), and then we get the NLL error at the end.
|
||||||
|
|
||||||
// compile-flags:-Znll -Zborrowck-mir
|
// compile-flags:-Znll -Zborrowck=compare
|
||||||
|
|
||||||
struct Map {
|
struct Map {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue