Auto merge of #55710 - kennytm:rollup, r=kennytm
Rollup of 11 pull requests Successful merges: - #55490 (resolve: Fix ICE in macro import error recovery) - #55597 (std: Enable usage of `thread_local!` through imports) - #55601 (Fix tracking issue numbers for some unstable features) - #55621 (Add precision for create_dir function) - #55644 (ci: Add Dockerfile for dist-powerpcspe-linux) - #55664 (Make "all possible cases" help message uniform with existing help messages) - #55689 (miri: binary_op_val -> binary_op_imm) - #55694 (Fixes #31076) - #55696 (NLL Diagnostic Review 3: Missing errors for borrows of union fields) - #55700 (Update ui tests with respect to NLL) - #55703 (Update `configure --help` (via configure.py) to reflect decoupling of debug+optimize)
This commit is contained in:
commit
f90aab7aa9
79 changed files with 774 additions and 409 deletions
|
|
@ -40,7 +40,7 @@ def v(*args):
|
|||
options.append(Option(*args, value=True))
|
||||
|
||||
|
||||
o("debug", "rust.debug", "debug mode; disables optimization unless `--enable-optimize` given")
|
||||
o("debug", "rust.debug", "enables debugging environment; does not affect optimization of bootstrapped code (use `--disable-optimize` for that)")
|
||||
o("docs", "build.docs", "build standard library documentation")
|
||||
o("compiler-docs", "build.compiler-docs", "build compiler documentation")
|
||||
o("optimize-tests", "rust.optimize-tests", "build tests with optimizations")
|
||||
|
|
|
|||
26
src/ci/docker/disabled/dist-powerpcspe-linux/Dockerfile
Normal file
26
src/ci/docker/disabled/dist-powerpcspe-linux/Dockerfile
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
FROM ubuntu:16.04
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
g++ \
|
||||
make \
|
||||
file \
|
||||
curl \
|
||||
ca-certificates \
|
||||
python2.7 \
|
||||
git \
|
||||
cmake \
|
||||
sudo \
|
||||
gdb \
|
||||
xz-utils \
|
||||
g++-powerpc-linux-gnuspe \
|
||||
libssl-dev \
|
||||
pkg-config
|
||||
|
||||
|
||||
COPY scripts/sccache.sh /scripts/
|
||||
RUN sh /scripts/sccache.sh
|
||||
|
||||
ENV HOSTS=powerpc-unknown-linux-gnuspe
|
||||
|
||||
ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
|
||||
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
|
||||
|
|
@ -291,10 +291,8 @@ fn has_allow_dead_code_or_lang_attr(tcx: TyCtxt<'_, '_, '_>,
|
|||
return true;
|
||||
}
|
||||
|
||||
// (To be) stable attribute for #[lang = "panic_impl"]
|
||||
if attr::contains_name(attrs, "panic_implementation") ||
|
||||
attr::contains_name(attrs, "panic_handler")
|
||||
{
|
||||
// Stable attribute for #[lang = "panic_impl"]
|
||||
if attr::contains_name(attrs, "panic_handler") {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -204,9 +204,7 @@ pub fn extract(attrs: &[ast::Attribute]) -> Option<(Symbol, Span)> {
|
|||
if let Some(value) = attribute.value_str() {
|
||||
return Some((value, attribute.span));
|
||||
}
|
||||
} else if attribute.check_name("panic_implementation") ||
|
||||
attribute.check_name("panic_handler")
|
||||
{
|
||||
} else if attribute.check_name("panic_handler") {
|
||||
return Some((Symbol::intern("panic_impl"), attribute.span))
|
||||
} else if attribute.check_name("alloc_error_handler") {
|
||||
return Some((Symbol::intern("oom"), attribute.span))
|
||||
|
|
|
|||
|
|
@ -506,25 +506,25 @@ pub enum BorrowKind {
|
|||
/// implicit closure bindings. It is needed when the closure is
|
||||
/// borrowing or mutating a mutable referent, e.g.:
|
||||
///
|
||||
/// let x: &mut isize = ...;
|
||||
/// let y = || *x += 5;
|
||||
/// let x: &mut isize = ...;
|
||||
/// let y = || *x += 5;
|
||||
///
|
||||
/// If we were to try to translate this closure into a more explicit
|
||||
/// form, we'd encounter an error with the code as written:
|
||||
///
|
||||
/// struct Env { x: & &mut isize }
|
||||
/// let x: &mut isize = ...;
|
||||
/// let y = (&mut Env { &x }, fn_ptr); // Closure is pair of env and fn
|
||||
/// fn fn_ptr(env: &mut Env) { **env.x += 5; }
|
||||
/// struct Env { x: & &mut isize }
|
||||
/// let x: &mut isize = ...;
|
||||
/// let y = (&mut Env { &x }, fn_ptr); // Closure is pair of env and fn
|
||||
/// fn fn_ptr(env: &mut Env) { **env.x += 5; }
|
||||
///
|
||||
/// This is then illegal because you cannot mutate an `&mut` found
|
||||
/// in an aliasable location. To solve, you'd have to translate with
|
||||
/// an `&mut` borrow:
|
||||
///
|
||||
/// struct Env { x: & &mut isize }
|
||||
/// let x: &mut isize = ...;
|
||||
/// let y = (&mut Env { &mut x }, fn_ptr); // changed from &x to &mut x
|
||||
/// fn fn_ptr(env: &mut Env) { **env.x += 5; }
|
||||
/// struct Env { x: & &mut isize }
|
||||
/// let x: &mut isize = ...;
|
||||
/// let y = (&mut Env { &mut x }, fn_ptr); // changed from &x to &mut x
|
||||
/// fn fn_ptr(env: &mut Env) { **env.x += 5; }
|
||||
///
|
||||
/// Now the assignment to `**env.x` is legal, but creating a
|
||||
/// mutable pointer to `x` is not because `x` is not mutable. We
|
||||
|
|
|
|||
|
|
@ -238,8 +238,8 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> {
|
|||
is non-empty",
|
||||
pat_ty));
|
||||
span_help!(&mut err, scrut.span,
|
||||
"Please ensure that all possible cases are being handled; \
|
||||
possibly adding wildcards or more match arms.");
|
||||
"ensure that all possible cases are being handled, \
|
||||
possibly by adding wildcards or more match arms");
|
||||
err.emit();
|
||||
}
|
||||
// If the type *is* uninhabited, it's vacuously exhaustive
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
|
|||
"unchecked_shr" => BinOp::Shr,
|
||||
_ => bug!("Already checked for int ops")
|
||||
};
|
||||
let (val, overflowed) = self.binary_op_val(bin_op, l, r)?;
|
||||
let (val, overflowed) = self.binary_op_imm(bin_op, l, r)?;
|
||||
if overflowed {
|
||||
let layout = self.layout_of(substs.type_at(0))?;
|
||||
let r_val = r.to_scalar()?.to_bits(layout.size)?;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
|
|||
right: ImmTy<'tcx, M::PointerTag>,
|
||||
dest: PlaceTy<'tcx, M::PointerTag>,
|
||||
) -> EvalResult<'tcx> {
|
||||
let (val, overflowed) = self.binary_op_val(op, left, right)?;
|
||||
let (val, overflowed) = self.binary_op_imm(op, left, right)?;
|
||||
let val = Immediate::ScalarPair(val.into(), Scalar::from_bool(overflowed).into());
|
||||
self.write_immediate(val, dest)
|
||||
}
|
||||
|
|
@ -42,7 +42,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
|
|||
right: ImmTy<'tcx, M::PointerTag>,
|
||||
dest: PlaceTy<'tcx, M::PointerTag>,
|
||||
) -> EvalResult<'tcx> {
|
||||
let (val, _overflowed) = self.binary_op_val(op, left, right)?;
|
||||
let (val, _overflowed) = self.binary_op_imm(op, left, right)?;
|
||||
self.write_scalar(val, dest)
|
||||
}
|
||||
}
|
||||
|
|
@ -283,9 +283,9 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
|
|||
}
|
||||
|
||||
/// Convenience wrapper that's useful when keeping the layout together with the
|
||||
/// value.
|
||||
/// immediate value.
|
||||
#[inline]
|
||||
pub fn binary_op_val(
|
||||
pub fn binary_op_imm(
|
||||
&self,
|
||||
bin_op: mir::BinOp,
|
||||
left: ImmTy<'tcx, M::PointerTag>,
|
||||
|
|
|
|||
|
|
@ -511,7 +511,7 @@ fn mono_item_visibility(
|
|||
//
|
||||
// * First is weak lang items. These are basically mechanisms for
|
||||
// libcore to forward-reference symbols defined later in crates like
|
||||
// the standard library or `#[panic_implementation]` definitions. The
|
||||
// the standard library or `#[panic_handler]` definitions. The
|
||||
// definition of these weak lang items needs to be referenceable by
|
||||
// libcore, so we're no longer a candidate for internalization.
|
||||
// Removal of these functions can't be done by LLVM but rather must be
|
||||
|
|
|
|||
|
|
@ -455,7 +455,7 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> {
|
|||
})?;
|
||||
trace!("const evaluating {:?} for {:?} and {:?}", op, left, right);
|
||||
let (val, overflow) = self.use_ecx(source_info, |this| {
|
||||
this.ecx.binary_op_val(op, l, r)
|
||||
this.ecx.binary_op_imm(op, l, r)
|
||||
})?;
|
||||
let val = if let Rvalue::CheckedBinaryOp(..) = *rvalue {
|
||||
Immediate::ScalarPair(
|
||||
|
|
|
|||
|
|
@ -449,6 +449,9 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
|
|||
return Err(Determinacy::Determined);
|
||||
}
|
||||
}
|
||||
Def::Err => {
|
||||
return Err(Determinacy::Determined);
|
||||
}
|
||||
_ => panic!("expected `Def::Macro` or `Def::NonMacroAttr`"),
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -289,8 +289,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
// Trait must have a method named `m_name` and it should not have
|
||||
// type parameters or early-bound regions.
|
||||
let tcx = self.tcx;
|
||||
let method_item =
|
||||
self.associated_item(trait_def_id, m_name, Namespace::Value).unwrap();
|
||||
let method_item = match self.associated_item(trait_def_id, m_name, Namespace::Value) {
|
||||
Some(method_item) => method_item,
|
||||
None => {
|
||||
tcx.sess.delay_span_bug(span,
|
||||
"operator trait does not have corresponding operator method");
|
||||
return None;
|
||||
}
|
||||
};
|
||||
let def_id = method_item.def_id;
|
||||
let generics = tcx.generics_of(def_id);
|
||||
assert_eq!(generics.params.len(), 0);
|
||||
|
|
|
|||
|
|
@ -1167,7 +1167,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
|
|||
}
|
||||
}
|
||||
|
||||
// Check that a function marked as `#[panic_implementation]` has signature `fn(&PanicInfo) -> !`
|
||||
// Check that a function marked as `#[panic_handler]` has signature `fn(&PanicInfo) -> !`
|
||||
if let Some(panic_impl_did) = fcx.tcx.lang_items().panic_impl() {
|
||||
if panic_impl_did == fcx.tcx.hir.local_def_id(fn_id) {
|
||||
if let Some(panic_info_did) = fcx.tcx.lang_items().panic_info() {
|
||||
|
|
|
|||
|
|
@ -1755,12 +1755,19 @@ pub fn canonicalize<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
|
|||
///
|
||||
/// [changes]: ../io/index.html#platform-specific-behavior
|
||||
///
|
||||
/// **NOTE**: If a parent of the given path doesn't exist, this function will
|
||||
/// return an error. To create a directory and all its missing parents at the
|
||||
/// same time, use the [`create_dir_all`] function.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// This function will return an error in the following situations, but is not
|
||||
/// limited to just these cases:
|
||||
///
|
||||
/// * User lacks permissions to create directory at `path`.
|
||||
/// * A parent of the given path doesn't exist. (To create a directory and all
|
||||
/// its missing parents at the same time, use the [`create_dir_all`]
|
||||
/// function.)
|
||||
/// * `path` already exists.
|
||||
///
|
||||
/// # Examples
|
||||
|
|
|
|||
|
|
@ -146,13 +146,13 @@ macro_rules! thread_local {
|
|||
|
||||
// process multiple declarations
|
||||
($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = $init:expr; $($rest:tt)*) => (
|
||||
__thread_local_inner!($(#[$attr])* $vis $name, $t, $init);
|
||||
thread_local!($($rest)*);
|
||||
$crate::__thread_local_inner!($(#[$attr])* $vis $name, $t, $init);
|
||||
$crate::thread_local!($($rest)*);
|
||||
);
|
||||
|
||||
// handle a single declaration
|
||||
($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = $init:expr) => (
|
||||
__thread_local_inner!($(#[$attr])* $vis $name, $t, $init);
|
||||
$crate::__thread_local_inner!($(#[$attr])* $vis $name, $t, $init);
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -202,7 +202,7 @@ macro_rules! __thread_local_inner {
|
|||
};
|
||||
($(#[$attr:meta])* $vis:vis $name:ident, $t:ty, $init:expr) => {
|
||||
$(#[$attr])* $vis const $name: $crate::thread::LocalKey<$t> =
|
||||
__thread_local_inner!(@key $(#[$attr])* $vis $name, $t, $init);
|
||||
$crate::__thread_local_inner!(@key $(#[$attr])* $vis $name, $t, $init);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -349,7 +349,7 @@ declare_features! (
|
|||
(active, abi_thiscall, "1.19.0", None, None),
|
||||
|
||||
// Allows a test to fail without failing the whole suite
|
||||
(active, allow_fail, "1.19.0", Some(42219), None),
|
||||
(active, allow_fail, "1.19.0", Some(46488), None),
|
||||
|
||||
// Allows unsized tuple coercion.
|
||||
(active, unsized_tuple_coercion, "1.20.0", Some(42877), None),
|
||||
|
|
@ -376,7 +376,7 @@ declare_features! (
|
|||
(active, non_exhaustive, "1.22.0", Some(44109), None),
|
||||
|
||||
// `crate` as visibility modifier, synonymous to `pub(crate)`
|
||||
(active, crate_visibility_modifier, "1.23.0", Some(45388), None),
|
||||
(active, crate_visibility_modifier, "1.23.0", Some(53120), None),
|
||||
|
||||
// extern types
|
||||
(active, extern_types, "1.23.0", Some(43467), None),
|
||||
|
|
@ -391,13 +391,13 @@ declare_features! (
|
|||
(active, generic_associated_types, "1.23.0", Some(44265), None),
|
||||
|
||||
// `extern` in paths
|
||||
(active, extern_in_paths, "1.23.0", Some(44660), None),
|
||||
(active, extern_in_paths, "1.23.0", Some(55600), None),
|
||||
|
||||
// Use `?` as the Kleene "at most one" operator
|
||||
(active, macro_at_most_once_rep, "1.25.0", Some(48075), None),
|
||||
|
||||
// Infer static outlives requirements; RFC 2093
|
||||
(active, infer_static_outlives_requirements, "1.26.0", Some(44493), None),
|
||||
(active, infer_static_outlives_requirements, "1.26.0", Some(54185), None),
|
||||
|
||||
// Multiple patterns with `|` in `if let` and `while let`
|
||||
(active, if_while_or_patterns, "1.26.0", Some(48215), None),
|
||||
|
|
@ -448,9 +448,6 @@ declare_features! (
|
|||
// Integer match exhaustiveness checking
|
||||
(active, exhaustive_integer_patterns, "1.30.0", Some(50907), None),
|
||||
|
||||
// RFC 2070: #[panic_implementation] / #[panic_handler]
|
||||
(active, panic_implementation, "1.28.0", Some(44489), None),
|
||||
|
||||
// #[doc(keyword = "...")]
|
||||
(active, doc_keyword, "1.28.0", Some(51315), None),
|
||||
|
||||
|
|
@ -466,7 +463,7 @@ declare_features! (
|
|||
(active, test_2018_feature, "1.31.0", Some(0), Some(Edition::Edition2018)),
|
||||
|
||||
// Support for arbitrary delimited token streams in non-macro attributes
|
||||
(active, unrestricted_attribute_tokens, "1.30.0", Some(44690), None),
|
||||
(active, unrestricted_attribute_tokens, "1.30.0", Some(55208), None),
|
||||
|
||||
// Allows `use x::y;` to resolve through `self::x`, not just `::x`
|
||||
(active, uniform_paths, "1.30.0", Some(53130), None),
|
||||
|
|
@ -503,7 +500,7 @@ declare_features! (
|
|||
(active, underscore_const_names, "1.31.0", Some(54912), None),
|
||||
|
||||
// `extern crate foo as bar;` puts `bar` into extern prelude.
|
||||
(active, extern_crate_item_prelude, "1.31.0", Some(54658), None),
|
||||
(active, extern_crate_item_prelude, "1.31.0", Some(55599), None),
|
||||
|
||||
// `reason = ` in lint attributes and `expect` lint attribute
|
||||
(active, lint_reasons, "1.31.0", Some(54503), None),
|
||||
|
|
@ -541,6 +538,8 @@ declare_features! (
|
|||
Some("subsumed by `#![feature(proc_macro_hygiene)]`")),
|
||||
(removed, proc_macro_gen, "1.27.0", Some(54727), None,
|
||||
Some("subsumed by `#![feature(proc_macro_hygiene)]`")),
|
||||
(removed, panic_implementation, "1.28.0", Some(44489), None,
|
||||
Some("subsumed by `#[panic_handler]`")),
|
||||
);
|
||||
|
||||
declare_features! (
|
||||
|
|
@ -1160,16 +1159,6 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG
|
|||
"infer 'static lifetime requirements",
|
||||
cfg_fn!(infer_static_outlives_requirements))),
|
||||
|
||||
// RFC 2070 (deprecated attribute name)
|
||||
("panic_implementation",
|
||||
Normal,
|
||||
Gated(Stability::Deprecated("https://github.com/rust-lang/rust/issues/44489\
|
||||
#issuecomment-415140224",
|
||||
Some("replace this attribute with `#[panic_handler]`")),
|
||||
"panic_implementation",
|
||||
"this attribute was renamed to `panic_handler`",
|
||||
cfg_fn!(panic_implementation))),
|
||||
|
||||
// RFC 2070
|
||||
("panic_handler", Normal, Ungated),
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@
|
|||
// except according to those terms.
|
||||
|
||||
#![crate_type = "cdylib"]
|
||||
|
||||
#![feature(panic_implementation)]
|
||||
#![no_std]
|
||||
|
||||
use core::panic::PanicInfo;
|
||||
|
|
@ -20,7 +18,7 @@ pub extern fn foo() {
|
|||
panic!()
|
||||
}
|
||||
|
||||
#[panic_implementation]
|
||||
#[panic_handler]
|
||||
fn panic(_info: &PanicInfo) -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,17 +8,11 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// compile-flags:-C panic=abort
|
||||
|
||||
#![deny(deprecated)]
|
||||
#![feature(panic_implementation)]
|
||||
#![no_std]
|
||||
|
||||
use core::panic::PanicInfo;
|
||||
extern crate std;
|
||||
|
||||
#[panic_implementation]
|
||||
fn panic(info: &PanicInfo) -> ! {
|
||||
loop {}
|
||||
std::thread_local!(static A: usize = 30);
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -20,6 +20,29 @@ LL | x.clone(); //~ ERROR: use of moved value
|
|||
|
|
||||
= note: move occurs because `x` has type `T`, which does not implement the `Copy` trait
|
||||
|
||||
error[E0505]: cannot move out of `x` because it is borrowed
|
||||
--> $DIR/binop-move-semantics.rs:31:5
|
||||
|
|
||||
LL | let m = &x;
|
||||
| -- borrow of `x` occurs here
|
||||
...
|
||||
LL | x //~ ERROR: cannot move out of `x` because it is borrowed
|
||||
| ^ move out of `x` occurs here
|
||||
...
|
||||
LL | use_mut(n); use_imm(m);
|
||||
| - borrow later used here
|
||||
|
||||
error[E0505]: cannot move out of `y` because it is borrowed
|
||||
--> $DIR/binop-move-semantics.rs:33:5
|
||||
|
|
||||
LL | let n = &mut y;
|
||||
| ------ borrow of `y` occurs here
|
||||
...
|
||||
LL | y; //~ ERROR: cannot move out of `y` because it is borrowed
|
||||
| ^ move out of `y` occurs here
|
||||
LL | use_mut(n); use_imm(m);
|
||||
| - borrow later used here
|
||||
|
||||
error[E0507]: cannot move out of borrowed content
|
||||
--> $DIR/binop-move-semantics.rs:40:5
|
||||
|
|
||||
|
|
@ -62,7 +85,7 @@ LL | | &mut f; //~ ERROR: cannot borrow `f` as mutable because it is also b
|
|||
| | immutable borrow later used here
|
||||
| mutable borrow occurs here
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
Some errors occurred: E0382, E0502, E0507.
|
||||
Some errors occurred: E0382, E0502, E0505, E0507.
|
||||
For more information about an error, try `rustc --explain E0382`.
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ fn move_borrowed<T: Add<Output=()>>(x: T, mut y: T) {
|
|||
x //~ ERROR: cannot move out of `x` because it is borrowed
|
||||
+
|
||||
y; //~ ERROR: cannot move out of `y` because it is borrowed
|
||||
use_mut(n); use_imm(m);
|
||||
}
|
||||
|
||||
fn illegal_dereference<T: Add<Output=()>>(mut x: T, y: T) {
|
||||
let m = &mut x;
|
||||
let n = &y;
|
||||
|
|
@ -40,8 +40,8 @@ fn illegal_dereference<T: Add<Output=()>>(mut x: T, y: T) {
|
|||
*m //~ ERROR: cannot move out of borrowed content
|
||||
+
|
||||
*n; //~ ERROR: cannot move out of borrowed content
|
||||
use_imm(n); use_mut(m);
|
||||
}
|
||||
|
||||
struct Foo;
|
||||
|
||||
impl<'a, 'b> Add<&'b Foo> for &'a mut Foo {
|
||||
|
|
@ -73,3 +73,6 @@ fn immut_plus_mut() {
|
|||
}
|
||||
|
||||
fn main() {}
|
||||
|
||||
fn use_mut<T>(_: &mut T) { }
|
||||
fn use_imm<T>(_: &T) { }
|
||||
|
|
|
|||
|
|
@ -1,15 +1,32 @@
|
|||
error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
|
||||
--> $DIR/borrowck-closures-mut-of-imm.rs:23:21
|
||||
--> $DIR/borrowck-closures-mut-of-imm.rs:23:25
|
||||
|
|
||||
LL | let c1 = || set(&mut *x);
|
||||
| ^^^^^^^ cannot borrow as mutable
|
||||
LL | let mut c1 = || set(&mut *x);
|
||||
| ^^^^^^^ cannot borrow as mutable
|
||||
|
||||
error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference
|
||||
--> $DIR/borrowck-closures-mut-of-imm.rs:25:21
|
||||
--> $DIR/borrowck-closures-mut-of-imm.rs:25:25
|
||||
|
|
||||
LL | let c2 = || set(&mut *x);
|
||||
| ^^^^^^^ cannot borrow as mutable
|
||||
LL | let mut c2 = || set(&mut *x);
|
||||
| ^^^^^^^ cannot borrow as mutable
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error[E0524]: two closures require unique access to `x` at the same time
|
||||
--> $DIR/borrowck-closures-mut-of-imm.rs:25:18
|
||||
|
|
||||
LL | let mut c1 = || set(&mut *x);
|
||||
| -- - first borrow occurs due to use of `x` in closure
|
||||
| |
|
||||
| first closure is constructed here
|
||||
LL | //~^ ERROR cannot borrow
|
||||
LL | let mut c2 = || set(&mut *x);
|
||||
| ^^ - second borrow occurs due to use of `x` in closure
|
||||
| |
|
||||
| second closure is constructed here
|
||||
...
|
||||
LL | c2(); c1();
|
||||
| -- first borrow later used here
|
||||
|
||||
For more information about this error, try `rustc --explain E0596`.
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors occurred: E0524, E0596.
|
||||
For more information about an error, try `rustc --explain E0524`.
|
||||
|
|
|
|||
|
|
@ -20,11 +20,12 @@ fn set(x: &mut isize) {
|
|||
}
|
||||
|
||||
fn a(x: &isize) {
|
||||
let c1 = || set(&mut *x);
|
||||
let mut c1 = || set(&mut *x);
|
||||
//~^ ERROR cannot borrow
|
||||
let c2 = || set(&mut *x);
|
||||
let mut c2 = || set(&mut *x);
|
||||
//~^ ERROR cannot borrow
|
||||
//~| ERROR two closures require unique access to `x` at the same time
|
||||
c2(); c1();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,30 +1,30 @@
|
|||
error[E0524]: two closures require unique access to `x` at the same time
|
||||
--> $DIR/borrowck-closures-mut-of-imm.rs:25:14
|
||||
--> $DIR/borrowck-closures-mut-of-imm.rs:25:18
|
||||
|
|
||||
LL | let c1 = || set(&mut *x);
|
||||
| -- - previous borrow occurs due to use of `x` in closure
|
||||
| |
|
||||
| first closure is constructed here
|
||||
LL | let mut c1 = || set(&mut *x);
|
||||
| -- - previous borrow occurs due to use of `x` in closure
|
||||
| |
|
||||
| first closure is constructed here
|
||||
LL | //~^ ERROR cannot borrow
|
||||
LL | let c2 = || set(&mut *x);
|
||||
| ^^ - borrow occurs due to use of `x` in closure
|
||||
| |
|
||||
| second closure is constructed here
|
||||
LL | let mut c2 = || set(&mut *x);
|
||||
| ^^ - borrow occurs due to use of `x` in closure
|
||||
| |
|
||||
| second closure is constructed here
|
||||
...
|
||||
LL | }
|
||||
| - borrow from first closure ends here
|
||||
|
||||
error[E0596]: cannot borrow immutable borrowed content `***x` as mutable
|
||||
--> $DIR/borrowck-closures-mut-of-imm.rs:23:26
|
||||
--> $DIR/borrowck-closures-mut-of-imm.rs:23:30
|
||||
|
|
||||
LL | let c1 = || set(&mut *x);
|
||||
| ^^ cannot borrow as mutable
|
||||
LL | let mut c1 = || set(&mut *x);
|
||||
| ^^ cannot borrow as mutable
|
||||
|
||||
error[E0596]: cannot borrow immutable borrowed content `***x` as mutable
|
||||
--> $DIR/borrowck-closures-mut-of-imm.rs:25:26
|
||||
--> $DIR/borrowck-closures-mut-of-imm.rs:25:30
|
||||
|
|
||||
LL | let c2 = || set(&mut *x);
|
||||
| ^^ cannot borrow as mutable
|
||||
LL | let mut c2 = || set(&mut *x);
|
||||
| ^^ cannot borrow as mutable
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
|||
18
src/test/ui/borrowck/borrowck-closures-mut-of-mut.nll.stderr
Normal file
18
src/test/ui/borrowck/borrowck-closures-mut-of-mut.nll.stderr
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
error[E0524]: two closures require unique access to `x` at the same time
|
||||
--> $DIR/borrowck-closures-mut-of-mut.rs:14:18
|
||||
|
|
||||
LL | let mut c1 = || set(&mut *x);
|
||||
| -- - first borrow occurs due to use of `x` in closure
|
||||
| |
|
||||
| first closure is constructed here
|
||||
LL | let mut c2 = || set(&mut *x);
|
||||
| ^^ - second borrow occurs due to use of `x` in closure
|
||||
| |
|
||||
| second closure is constructed here
|
||||
LL | //~^ ERROR two closures require unique access to `x` at the same time
|
||||
LL | c2(); c1();
|
||||
| -- first borrow later used here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0524`.
|
||||
20
src/test/ui/borrowck/borrowck-closures-mut-of-mut.rs
Normal file
20
src/test/ui/borrowck/borrowck-closures-mut-of-mut.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Tests that two closures cannot simultaneously both have mutable
|
||||
// access to the variable. Related to issue #6801.
|
||||
|
||||
fn get(x: &isize) -> isize {
|
||||
*x
|
||||
}
|
||||
|
||||
fn set(x: &mut isize) {
|
||||
*x = 4;
|
||||
}
|
||||
|
||||
fn a(x: &mut isize) {
|
||||
let mut c1 = || set(&mut *x);
|
||||
let mut c2 = || set(&mut *x);
|
||||
//~^ ERROR two closures require unique access to `x` at the same time
|
||||
c2(); c1();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
18
src/test/ui/borrowck/borrowck-closures-mut-of-mut.stderr
Normal file
18
src/test/ui/borrowck/borrowck-closures-mut-of-mut.stderr
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
error[E0524]: two closures require unique access to `x` at the same time
|
||||
--> $DIR/borrowck-closures-mut-of-mut.rs:14:18
|
||||
|
|
||||
LL | let mut c1 = || set(&mut *x);
|
||||
| -- - previous borrow occurs due to use of `x` in closure
|
||||
| |
|
||||
| first closure is constructed here
|
||||
LL | let mut c2 = || set(&mut *x);
|
||||
| ^^ - borrow occurs due to use of `x` in closure
|
||||
| |
|
||||
| second closure is constructed here
|
||||
...
|
||||
LL | }
|
||||
| - borrow from first closure ends here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0524`.
|
||||
|
|
@ -4,7 +4,7 @@ error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mu
|
|||
LL | let mut x = &mut v;
|
||||
| - mutable borrow occurs here
|
||||
...
|
||||
LL | borrow(&*v); //~ ERROR cannot borrow
|
||||
LL | borrow(&*v); //[ast]~ ERROR cannot borrow
|
||||
| ^^ immutable borrow occurs here
|
||||
LL | }
|
||||
LL | }
|
||||
|
|
@ -16,7 +16,7 @@ error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mu
|
|||
LL | let mut x = &mut v;
|
||||
| - mutable borrow occurs here
|
||||
LL | for _ in 0..3 {
|
||||
LL | borrow(&*v); //~ ERROR cannot borrow
|
||||
LL | borrow(&*v); //[ast]~ ERROR cannot borrow
|
||||
| ^^ immutable borrow occurs here
|
||||
...
|
||||
LL | }
|
||||
|
|
@ -25,7 +25,7 @@ LL | }
|
|||
error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable
|
||||
--> $DIR/borrowck-lend-flow-loop.rs:57:25
|
||||
|
|
||||
LL | borrow_mut(&mut *v); //~ ERROR cannot borrow
|
||||
LL | borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow
|
||||
| ^^ mutable borrow occurs here
|
||||
LL | _x = &v;
|
||||
| - immutable borrow occurs here
|
||||
|
|
@ -36,7 +36,7 @@ LL | }
|
|||
error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable
|
||||
--> $DIR/borrowck-lend-flow-loop.rs:69:25
|
||||
|
|
||||
LL | borrow_mut(&mut *v); //~ ERROR cannot borrow
|
||||
LL | borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow
|
||||
| ^^ mutable borrow occurs here
|
||||
LL | _x = &v;
|
||||
| - immutable borrow occurs here
|
||||
|
|
@ -50,7 +50,7 @@ error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immu
|
|||
LL | _x = &v;
|
||||
| - immutable borrow occurs here
|
||||
...
|
||||
LL | borrow_mut(&mut *v); //~ ERROR cannot borrow
|
||||
LL | borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow
|
||||
| ^^ mutable borrow occurs here
|
||||
LL | }
|
||||
| - immutable borrow ends here
|
||||
|
|
@ -61,7 +61,7 @@ error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immu
|
|||
LL | _x = &v;
|
||||
| - immutable borrow occurs here
|
||||
...
|
||||
LL | borrow_mut(&mut *v); //~ ERROR cannot borrow
|
||||
LL | borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow
|
||||
| ^^ mutable borrow occurs here
|
||||
LL | }
|
||||
| - immutable borrow ends here
|
||||
|
|
@ -69,19 +69,19 @@ LL | }
|
|||
error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mutable
|
||||
--> $DIR/borrowck-lend-flow-loop.rs:109:17
|
||||
|
|
||||
LL | borrow(&*v); //~ ERROR cannot borrow
|
||||
LL | borrow(&*v); //[ast]~ ERROR cannot borrow
|
||||
| ^^ immutable borrow occurs here
|
||||
LL | if cond2 {
|
||||
LL | x = &mut v; //~ ERROR cannot borrow
|
||||
...
|
||||
LL | x = &mut v; //[ast]~ ERROR cannot borrow
|
||||
| - mutable borrow occurs here
|
||||
...
|
||||
LL | }
|
||||
| - mutable borrow ends here
|
||||
|
||||
error[E0499]: cannot borrow `v` as mutable more than once at a time
|
||||
--> $DIR/borrowck-lend-flow-loop.rs:111:22
|
||||
--> $DIR/borrowck-lend-flow-loop.rs:112:22
|
||||
|
|
||||
LL | x = &mut v; //~ ERROR cannot borrow
|
||||
LL | x = &mut v; //[ast]~ ERROR cannot borrow
|
||||
| ^ mutable borrow starts here in previous iteration of loop
|
||||
...
|
||||
LL | }
|
||||
|
|
@ -4,9 +4,9 @@ error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mut
|
|||
LL | let mut x = &mut v;
|
||||
| ------ mutable borrow occurs here
|
||||
LL | for _ in 0..3 {
|
||||
LL | borrow(&*v); //~ ERROR cannot borrow
|
||||
LL | borrow(&*v); //[ast]~ ERROR cannot borrow
|
||||
| ^^^ immutable borrow occurs here
|
||||
LL | }
|
||||
...
|
||||
LL | *x = box 5;
|
||||
| -- mutable borrow used here, in later iteration of loop
|
||||
|
||||
|
|
@ -15,10 +15,10 @@ error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mut
|
|||
|
|
||||
LL | **x += 1;
|
||||
| -------- mutable borrow used here, in later iteration of loop
|
||||
LL | borrow(&*v); //~ ERROR cannot borrow
|
||||
LL | borrow(&*v); //[ast]~ ERROR cannot borrow
|
||||
| ^^^ immutable borrow occurs here
|
||||
LL | if cond2 {
|
||||
LL | x = &mut v; //~ ERROR cannot borrow
|
||||
...
|
||||
LL | x = &mut v; //[ast]~ ERROR cannot borrow
|
||||
| ------ mutable borrow occurs here
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
// revisions: ast nll
|
||||
|
||||
// Note: the borrowck analysis is currently flow-insensitive.
|
||||
// Therefore, some of these errors are marked as spurious and could be
|
||||
// corrected by a simple change to the analysis. The others are
|
||||
// either genuine or would require more advanced changes. The latter
|
||||
// cases are noted.
|
||||
// Since we are testing nll migration explicitly as a separate
|
||||
// revision, don't worry about the --compare-mode=nll on this test.
|
||||
|
||||
// ignore-compare-mode-nll
|
||||
|
||||
//[ast]compile-flags: -Z borrowck=ast
|
||||
//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows
|
||||
|
||||
// Note: the borrowck analysis was originally a flow-insensitive pass
|
||||
// over the AST. Therefore, some of these (AST) errors are marked as
|
||||
// spurious and are corrected by the flow-sensitive (NLL) analysis.
|
||||
// The others are either genuine or would require more advanced
|
||||
// changes. The latter cases are noted.
|
||||
|
||||
#![feature(box_syntax)]
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ fn loop_overarching_alias_mut() {
|
|||
let mut x = &mut v;
|
||||
**x += 1;
|
||||
loop {
|
||||
borrow(&*v); //~ ERROR cannot borrow
|
||||
borrow(&*v); //[ast]~ ERROR cannot borrow
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -42,11 +42,11 @@ fn block_overarching_alias_mut() {
|
|||
let mut v: Box<_> = box 3;
|
||||
let mut x = &mut v;
|
||||
for _ in 0..3 {
|
||||
borrow(&*v); //~ ERROR cannot borrow
|
||||
borrow(&*v); //[ast]~ ERROR cannot borrow
|
||||
//[nll]~^ ERROR cannot borrow
|
||||
}
|
||||
*x = box 5;
|
||||
}
|
||||
|
||||
fn loop_aliased_mut() {
|
||||
// In this instance, the borrow is carried through the loop.
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ fn loop_aliased_mut() {
|
|||
let mut w: Box<_> = box 4;
|
||||
let mut _x = &w;
|
||||
loop {
|
||||
borrow_mut(&mut *v); //~ ERROR cannot borrow
|
||||
borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow
|
||||
_x = &v;
|
||||
}
|
||||
}
|
||||
|
|
@ -66,7 +66,7 @@ fn while_aliased_mut() {
|
|||
let mut w: Box<_> = box 4;
|
||||
let mut _x = &w;
|
||||
while cond() {
|
||||
borrow_mut(&mut *v); //~ ERROR cannot borrow
|
||||
borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow
|
||||
_x = &v;
|
||||
}
|
||||
}
|
||||
|
|
@ -83,7 +83,7 @@ fn loop_aliased_mut_break() {
|
|||
_x = &v;
|
||||
break;
|
||||
}
|
||||
borrow_mut(&mut *v); //~ ERROR cannot borrow
|
||||
borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow
|
||||
}
|
||||
|
||||
fn while_aliased_mut_break() {
|
||||
|
|
@ -97,7 +97,7 @@ fn while_aliased_mut_break() {
|
|||
_x = &v;
|
||||
break;
|
||||
}
|
||||
borrow_mut(&mut *v); //~ ERROR cannot borrow
|
||||
borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow
|
||||
}
|
||||
|
||||
fn while_aliased_mut_cond(cond: bool, cond2: bool) {
|
||||
|
|
@ -106,13 +106,13 @@ fn while_aliased_mut_cond(cond: bool, cond2: bool) {
|
|||
let mut x = &mut w;
|
||||
while cond {
|
||||
**x += 1;
|
||||
borrow(&*v); //~ ERROR cannot borrow
|
||||
borrow(&*v); //[ast]~ ERROR cannot borrow
|
||||
//[nll]~^ ERROR cannot borrow
|
||||
if cond2 {
|
||||
x = &mut v; //~ ERROR cannot borrow
|
||||
x = &mut v; //[ast]~ ERROR cannot borrow
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn loop_break_pops_scopes<'r, F>(_v: &'r mut [usize], mut f: F) where
|
||||
F: FnMut(&'r mut usize) -> bool,
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,3 +1,13 @@
|
|||
error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-overloaded-call.rs:69:5
|
||||
|
|
||||
LL | let sp = &mut s;
|
||||
| ------ mutable borrow occurs here
|
||||
LL | s(3); //~ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable
|
||||
| ^ immutable borrow occurs here
|
||||
LL | use_mut(sp);
|
||||
| -- mutable borrow later used here
|
||||
|
||||
error[E0596]: cannot borrow `s` as mutable, as it is not declared as mutable
|
||||
--> $DIR/borrowck-overloaded-call.rs:77:5
|
||||
|
|
||||
|
|
@ -17,7 +27,7 @@ LL | s(" world".to_string()); //~ ERROR use of moved value: `s`
|
|||
|
|
||||
= note: move occurs because `s` has type `SFnOnce`, which does not implement the `Copy` trait
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors occurred: E0382, E0596.
|
||||
Some errors occurred: E0382, E0502, E0596.
|
||||
For more information about an error, try `rustc --explain E0382`.
|
||||
|
|
|
|||
|
|
@ -67,8 +67,8 @@ fn f() {
|
|||
};
|
||||
let sp = &mut s;
|
||||
s(3); //~ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable
|
||||
use_mut(sp);
|
||||
}
|
||||
|
||||
fn g() {
|
||||
let s = SFnMut {
|
||||
x: 1,
|
||||
|
|
@ -86,3 +86,5 @@ fn h() {
|
|||
}
|
||||
|
||||
fn main() {}
|
||||
|
||||
fn use_mut<T>(_: &mut T) { }
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ LL | let sp = &mut s;
|
|||
| - mutable borrow occurs here
|
||||
LL | s(3); //~ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable
|
||||
| ^ immutable borrow occurs here
|
||||
LL | use_mut(sp);
|
||||
LL | }
|
||||
| - mutable borrow ends here
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,27 @@
|
|||
error[E0505]: cannot move out of `s` because it is borrowed
|
||||
--> $DIR/borrowck-overloaded-index-move-index.rs:60:22
|
||||
|
|
||||
LL | let rs = &mut s;
|
||||
| ------ borrow of `s` occurs here
|
||||
LL |
|
||||
LL | println!("{}", f[s]);
|
||||
| ^ move out of `s` occurs here
|
||||
...
|
||||
LL | use_mut(rs);
|
||||
| -- borrow later used here
|
||||
|
||||
error[E0505]: cannot move out of `s` because it is borrowed
|
||||
--> $DIR/borrowck-overloaded-index-move-index.rs:63:7
|
||||
|
|
||||
LL | let rs = &mut s;
|
||||
| ------ borrow of `s` occurs here
|
||||
...
|
||||
LL | f[s] = 10;
|
||||
| ^ move out of `s` occurs here
|
||||
...
|
||||
LL | use_mut(rs);
|
||||
| -- borrow later used here
|
||||
|
||||
error[E0382]: use of moved value: `s`
|
||||
--> $DIR/borrowck-overloaded-index-move-index.rs:63:7
|
||||
|
|
||||
|
|
@ -9,6 +33,7 @@ LL | f[s] = 10;
|
|||
|
|
||||
= note: move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait
|
||||
|
||||
error: aborting due to previous error
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0382`.
|
||||
Some errors occurred: E0382, E0505.
|
||||
For more information about an error, try `rustc --explain E0382`.
|
||||
|
|
|
|||
|
|
@ -71,4 +71,8 @@ fn main() {
|
|||
let _j = &i;
|
||||
println!("{}", s[i]); // no error, i is copy
|
||||
println!("{}", s[i]);
|
||||
|
||||
use_mut(rs);
|
||||
}
|
||||
|
||||
fn use_mut<T>(_: &mut T) { }
|
||||
|
|
|
|||
|
|
@ -1,3 +1,107 @@
|
|||
error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time
|
||||
--> $DIR/borrowck-reborrow-from-mut.rs:23:17
|
||||
|
|
||||
LL | let _bar1 = &mut foo.bar1;
|
||||
| ------------- first mutable borrow occurs here
|
||||
LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow
|
||||
| ^^^^^^^^^^^^^ second mutable borrow occurs here
|
||||
LL | use_mut(_bar1);
|
||||
| ----- first borrow later used here
|
||||
|
||||
error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-reborrow-from-mut.rs:28:17
|
||||
|
|
||||
LL | let _bar1 = &mut foo.bar1;
|
||||
| ------------- mutable borrow occurs here
|
||||
LL | let _bar2 = &foo.bar1; //~ ERROR cannot borrow
|
||||
| ^^^^^^^^^ immutable borrow occurs here
|
||||
LL | use_mut(_bar1);
|
||||
| ----- mutable borrow later used here
|
||||
|
||||
error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-reborrow-from-mut.rs:33:17
|
||||
|
|
||||
LL | let _bar1 = &foo.bar1;
|
||||
| --------- immutable borrow occurs here
|
||||
LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow
|
||||
| ^^^^^^^^^^^^^ mutable borrow occurs here
|
||||
LL | use_imm(_bar1);
|
||||
| ----- immutable borrow later used here
|
||||
|
||||
error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time
|
||||
--> $DIR/borrowck-reborrow-from-mut.rs:55:21
|
||||
|
|
||||
LL | let _bar1 = &mut foo.bar1;
|
||||
| ------------- first mutable borrow occurs here
|
||||
LL | match *foo {
|
||||
LL | Foo { bar1: ref mut _bar1, bar2: _ } => {}
|
||||
| ^^^^^^^^^^^^^ second mutable borrow occurs here
|
||||
...
|
||||
LL | use_mut(_bar1);
|
||||
| ----- first borrow later used here
|
||||
|
||||
error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-reborrow-from-mut.rs:62:17
|
||||
|
|
||||
LL | let _bar1 = &mut foo.bar1.int1;
|
||||
| ------------------ mutable borrow occurs here
|
||||
LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow
|
||||
| ^^^^^^^^^ immutable borrow occurs here
|
||||
LL | let _foo2 = &*foo; //~ ERROR cannot borrow
|
||||
LL | use_mut(_bar1);
|
||||
| ----- mutable borrow later used here
|
||||
|
||||
error[E0502]: cannot borrow `*foo` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-reborrow-from-mut.rs:63:17
|
||||
|
|
||||
LL | let _bar1 = &mut foo.bar1.int1;
|
||||
| ------------------ mutable borrow occurs here
|
||||
LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow
|
||||
LL | let _foo2 = &*foo; //~ ERROR cannot borrow
|
||||
| ^^^^^ immutable borrow occurs here
|
||||
LL | use_mut(_bar1);
|
||||
| ----- mutable borrow later used here
|
||||
|
||||
error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time
|
||||
--> $DIR/borrowck-reborrow-from-mut.rs:68:17
|
||||
|
|
||||
LL | let _bar1 = &mut foo.bar1.int1;
|
||||
| ------------------ first mutable borrow occurs here
|
||||
LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow
|
||||
| ^^^^^^^^^^^^^ second mutable borrow occurs here
|
||||
LL | use_mut(_bar1);
|
||||
| ----- first borrow later used here
|
||||
|
||||
error[E0499]: cannot borrow `*foo` as mutable more than once at a time
|
||||
--> $DIR/borrowck-reborrow-from-mut.rs:73:17
|
||||
|
|
||||
LL | let _bar1 = &mut foo.bar1.int1;
|
||||
| ------------------ first mutable borrow occurs here
|
||||
LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow
|
||||
| ^^^^^^^^^ second mutable borrow occurs here
|
||||
LL | use_mut(_bar1);
|
||||
| ----- first borrow later used here
|
||||
|
||||
error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-reborrow-from-mut.rs:78:17
|
||||
|
|
||||
LL | let _bar1 = &foo.bar1.int1;
|
||||
| -------------- immutable borrow occurs here
|
||||
LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow
|
||||
| ^^^^^^^^^^^^^ mutable borrow occurs here
|
||||
LL | use_imm(_bar1);
|
||||
| ----- immutable borrow later used here
|
||||
|
||||
error[E0502]: cannot borrow `*foo` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-reborrow-from-mut.rs:83:17
|
||||
|
|
||||
LL | let _bar1 = &foo.bar1.int1;
|
||||
| -------------- immutable borrow occurs here
|
||||
LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow
|
||||
| ^^^^^^^^^ mutable borrow occurs here
|
||||
LL | use_imm(_bar1);
|
||||
| ----- immutable borrow later used here
|
||||
|
||||
error[E0596]: cannot borrow `foo.bar1` as mutable, as it is behind a `&` reference
|
||||
--> $DIR/borrowck-reborrow-from-mut.rs:98:17
|
||||
|
|
||||
|
|
@ -6,6 +110,7 @@ LL | fn borrow_mut_from_imm(foo: &Foo) {
|
|||
LL | let _bar1 = &mut foo.bar1; //~ ERROR cannot borrow
|
||||
| ^^^^^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be borrowed as mutable
|
||||
|
||||
error: aborting due to previous error
|
||||
error: aborting due to 11 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0596`.
|
||||
Some errors occurred: E0499, E0502, E0596.
|
||||
For more information about an error, try `rustc --explain E0499`.
|
||||
|
|
|
|||
|
|
@ -21,79 +21,79 @@ struct Bar {
|
|||
fn borrow_same_field_twice_mut_mut(foo: &mut Foo) {
|
||||
let _bar1 = &mut foo.bar1;
|
||||
let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow
|
||||
use_mut(_bar1);
|
||||
}
|
||||
|
||||
fn borrow_same_field_twice_mut_imm(foo: &mut Foo) {
|
||||
let _bar1 = &mut foo.bar1;
|
||||
let _bar2 = &foo.bar1; //~ ERROR cannot borrow
|
||||
use_mut(_bar1);
|
||||
}
|
||||
|
||||
fn borrow_same_field_twice_imm_mut(foo: &mut Foo) {
|
||||
let _bar1 = &foo.bar1;
|
||||
let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow
|
||||
use_imm(_bar1);
|
||||
}
|
||||
|
||||
fn borrow_same_field_twice_imm_imm(foo: &mut Foo) {
|
||||
let _bar1 = &foo.bar1;
|
||||
let _bar2 = &foo.bar1;
|
||||
use_imm(_bar1);
|
||||
}
|
||||
|
||||
fn borrow_both_mut(foo: &mut Foo) {
|
||||
let _bar1 = &mut foo.bar1;
|
||||
let _bar2 = &mut foo.bar2;
|
||||
use_mut(_bar1);
|
||||
}
|
||||
|
||||
fn borrow_both_mut_pattern(foo: &mut Foo) {
|
||||
match *foo {
|
||||
Foo { bar1: ref mut _bar1, bar2: ref mut _bar2 } => {}
|
||||
Foo { bar1: ref mut _bar1, bar2: ref mut _bar2 } =>
|
||||
{ use_mut(_bar1); use_mut(_bar2); }
|
||||
}
|
||||
}
|
||||
|
||||
fn borrow_var_and_pattern(foo: &mut Foo) {
|
||||
let _bar1 = &mut foo.bar1;
|
||||
match *foo {
|
||||
Foo { bar1: ref mut _bar1, bar2: _ } => {}
|
||||
//~^ ERROR cannot borrow
|
||||
}
|
||||
use_mut(_bar1);
|
||||
}
|
||||
|
||||
fn borrow_mut_and_base_imm(foo: &mut Foo) {
|
||||
let _bar1 = &mut foo.bar1.int1;
|
||||
let _foo1 = &foo.bar1; //~ ERROR cannot borrow
|
||||
let _foo2 = &*foo; //~ ERROR cannot borrow
|
||||
use_mut(_bar1);
|
||||
}
|
||||
|
||||
fn borrow_mut_and_base_mut(foo: &mut Foo) {
|
||||
let _bar1 = &mut foo.bar1.int1;
|
||||
let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow
|
||||
use_mut(_bar1);
|
||||
}
|
||||
|
||||
fn borrow_mut_and_base_mut2(foo: &mut Foo) {
|
||||
let _bar1 = &mut foo.bar1.int1;
|
||||
let _foo2 = &mut *foo; //~ ERROR cannot borrow
|
||||
use_mut(_bar1);
|
||||
}
|
||||
|
||||
fn borrow_imm_and_base_mut(foo: &mut Foo) {
|
||||
let _bar1 = &foo.bar1.int1;
|
||||
let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow
|
||||
use_imm(_bar1);
|
||||
}
|
||||
|
||||
fn borrow_imm_and_base_mut2(foo: &mut Foo) {
|
||||
let _bar1 = &foo.bar1.int1;
|
||||
let _foo2 = &mut *foo; //~ ERROR cannot borrow
|
||||
use_imm(_bar1);
|
||||
}
|
||||
|
||||
fn borrow_imm_and_base_imm(foo: &mut Foo) {
|
||||
let _bar1 = &foo.bar1.int1;
|
||||
let _foo1 = &foo.bar1;
|
||||
let _foo2 = &*foo;
|
||||
use_imm(_bar1);
|
||||
}
|
||||
|
||||
fn borrow_mut_and_imm(foo: &mut Foo) {
|
||||
let _bar1 = &mut foo.bar1;
|
||||
let _foo1 = &foo.bar2;
|
||||
use_mut(_bar1);
|
||||
}
|
||||
|
||||
fn borrow_mut_from_imm(foo: &Foo) {
|
||||
let _bar1 = &mut foo.bar1; //~ ERROR cannot borrow
|
||||
}
|
||||
|
|
@ -101,6 +101,9 @@ fn borrow_mut_from_imm(foo: &Foo) {
|
|||
fn borrow_long_path_both_mut(foo: &mut Foo) {
|
||||
let _bar1 = &mut foo.bar1.int1;
|
||||
let _foo1 = &mut foo.bar2.int2;
|
||||
use_mut(_bar1);
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
||||
fn use_mut<T>(_: &mut T) { }
|
||||
fn use_imm<T>(_: &T) { }
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ LL | let _bar1 = &mut foo.bar1;
|
|||
| -------- first mutable borrow occurs here
|
||||
LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow
|
||||
| ^^^^^^^^ second mutable borrow occurs here
|
||||
LL | use_mut(_bar1);
|
||||
LL | }
|
||||
| - first borrow ends here
|
||||
|
||||
|
|
@ -15,6 +16,7 @@ LL | let _bar1 = &mut foo.bar1;
|
|||
| -------- mutable borrow occurs here
|
||||
LL | let _bar2 = &foo.bar1; //~ ERROR cannot borrow
|
||||
| ^^^^^^^^ immutable borrow occurs here
|
||||
LL | use_mut(_bar1);
|
||||
LL | }
|
||||
| - mutable borrow ends here
|
||||
|
||||
|
|
@ -25,6 +27,7 @@ LL | let _bar1 = &foo.bar1;
|
|||
| -------- immutable borrow occurs here
|
||||
LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow
|
||||
| ^^^^^^^^ mutable borrow occurs here
|
||||
LL | use_imm(_bar1);
|
||||
LL | }
|
||||
| - immutable borrow ends here
|
||||
|
||||
|
|
@ -47,7 +50,7 @@ LL | let _bar1 = &mut foo.bar1.int1;
|
|||
| ------------- mutable borrow occurs here
|
||||
LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow
|
||||
| ^^^^^^^^ immutable borrow occurs here
|
||||
LL | let _foo2 = &*foo; //~ ERROR cannot borrow
|
||||
...
|
||||
LL | }
|
||||
| - mutable borrow ends here
|
||||
|
||||
|
|
@ -59,6 +62,7 @@ LL | let _bar1 = &mut foo.bar1.int1;
|
|||
LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow
|
||||
LL | let _foo2 = &*foo; //~ ERROR cannot borrow
|
||||
| ^^^^ immutable borrow occurs here
|
||||
LL | use_mut(_bar1);
|
||||
LL | }
|
||||
| - mutable borrow ends here
|
||||
|
||||
|
|
@ -69,6 +73,7 @@ LL | let _bar1 = &mut foo.bar1.int1;
|
|||
| ------------- first mutable borrow occurs here
|
||||
LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow
|
||||
| ^^^^^^^^ second mutable borrow occurs here
|
||||
LL | use_mut(_bar1);
|
||||
LL | }
|
||||
| - first borrow ends here
|
||||
|
||||
|
|
@ -79,6 +84,7 @@ LL | let _bar1 = &mut foo.bar1.int1;
|
|||
| ------------- first mutable borrow occurs here
|
||||
LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow
|
||||
| ^^^^ second mutable borrow occurs here
|
||||
LL | use_mut(_bar1);
|
||||
LL | }
|
||||
| - first borrow ends here
|
||||
|
||||
|
|
@ -89,6 +95,7 @@ LL | let _bar1 = &foo.bar1.int1;
|
|||
| ------------- immutable borrow occurs here
|
||||
LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow
|
||||
| ^^^^^^^^ mutable borrow occurs here
|
||||
LL | use_imm(_bar1);
|
||||
LL | }
|
||||
| - immutable borrow ends here
|
||||
|
||||
|
|
@ -99,6 +106,7 @@ LL | let _bar1 = &foo.bar1.int1;
|
|||
| ------------- immutable borrow occurs here
|
||||
LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow
|
||||
| ^^^^ mutable borrow occurs here
|
||||
LL | use_imm(_bar1);
|
||||
LL | }
|
||||
| - immutable borrow ends here
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,13 @@
|
|||
error[E0502]: cannot borrow `f` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-unboxed-closures.rs:13:5
|
||||
|
|
||||
LL | let g = &mut f;
|
||||
| ------ mutable borrow occurs here
|
||||
LL | f(1, 2); //~ ERROR cannot borrow `f` as immutable
|
||||
| ^ immutable borrow occurs here
|
||||
LL | use_mut(g);
|
||||
| - mutable borrow later used here
|
||||
|
||||
error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable
|
||||
--> $DIR/borrowck-unboxed-closures.rs:17:5
|
||||
|
|
||||
|
|
@ -16,7 +26,7 @@ LL | f(1, 2); //~ ERROR use of moved value
|
|||
|
|
||||
= note: move occurs because `f` has type `F`, which does not implement the `Copy` trait
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors occurred: E0382, E0596.
|
||||
Some errors occurred: E0382, E0502, E0596.
|
||||
For more information about an error, try `rustc --explain E0382`.
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
fn a<F:Fn(isize, isize) -> isize>(mut f: F) {
|
||||
let g = &mut f;
|
||||
f(1, 2); //~ ERROR cannot borrow `f` as immutable
|
||||
use_mut(g);
|
||||
}
|
||||
|
||||
fn b<F:FnMut(isize, isize) -> isize>(f: F) {
|
||||
f(1, 2); //~ ERROR cannot borrow immutable argument
|
||||
}
|
||||
|
|
@ -23,3 +23,5 @@ fn c<F:FnOnce(isize, isize) -> isize>(f: F) {
|
|||
}
|
||||
|
||||
fn main() {}
|
||||
|
||||
fn use_mut<T>(_: &mut T) { }
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ LL | let g = &mut f;
|
|||
| - mutable borrow occurs here
|
||||
LL | f(1, 2); //~ ERROR cannot borrow `f` as immutable
|
||||
| ^ immutable borrow occurs here
|
||||
LL | use_mut(g);
|
||||
LL | }
|
||||
| - mutable borrow ends here
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
error[E0509]: cannot move out of type `S`, which implements the `Drop` trait
|
||||
--> $DIR/overlapping_spans.rs:20:11
|
||||
|
|
||||
LL | match (S {f:"foo".to_string()}) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here
|
||||
LL | S {f:_s} => {} //~ ERROR cannot move out
|
||||
| -- data moved here
|
||||
|
|
||||
note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait
|
||||
--> $DIR/overlapping_spans.rs:21:14
|
||||
|
|
||||
LL | S {f:_s} => {} //~ ERROR cannot move out
|
||||
| ^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0509`.
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Foo { }
|
||||
|
||||
struct S {f:String}
|
||||
impl Drop for S {
|
||||
fn drop(&mut self) { println!("{}", self.f); }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
match (S {f:"foo".to_string()}) {
|
||||
S {f:_s} => {} //~ ERROR cannot move out
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
error[E0509]: cannot move out of type `S`, which implements the `Drop` trait
|
||||
--> $DIR/overlapping_spans.rs:21:9
|
||||
|
|
||||
LL | S {f:_s} => {} //~ ERROR cannot move out
|
||||
| ^^^^^--^
|
||||
| | |
|
||||
| | hint: to prevent move, use `ref _s` or `ref mut _s`
|
||||
| cannot move out of here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0509`.
|
||||
|
|
@ -32,7 +32,7 @@ LL | }
|
|||
= note: values in a scope are dropped in the opposite order they are created
|
||||
|
||||
error[E0597]: `c_shortest` does not live long enough
|
||||
--> $DIR/dropck-eyepatch-extern-crate.rs:49:20
|
||||
--> $DIR/dropck-eyepatch-extern-crate.rs:50:20
|
||||
|
|
||||
LL | dr = Dr("dr", &c_shortest);
|
||||
| ^^^^^^^^^^ borrowed value does not live long enough
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
// The behavior of AST-borrowck and NLL explcitly differ here due to
|
||||
// NLL's increased precision; so we use revisions and do not worry
|
||||
// about the --compare-mode=nll on this test.
|
||||
|
||||
// revisions: ast nll
|
||||
//[ast]compile-flags: -Z borrowck=ast
|
||||
//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows
|
||||
|
||||
// ignore-compare-mode-nll
|
||||
|
||||
// aux-build:dropck_eyepatch_extern_crate.rs
|
||||
|
||||
|
|
@ -39,29 +39,32 @@ fn main() { #![rustc_error] // rust-lang/rust#49855
|
|||
|
||||
// Error: destructor order imprecisely modelled
|
||||
dt = Dt("dt", &c);
|
||||
//~^ ERROR `c` does not live long enough
|
||||
//[ast]~^ ERROR `c` does not live long enough
|
||||
dr = Dr("dr", &c);
|
||||
//~^ ERROR `c` does not live long enough
|
||||
//[ast]~^ ERROR `c` does not live long enough
|
||||
|
||||
// Error: `c_shortest` dies too soon for the references in dtors to be valid.
|
||||
dt = Dt("dt", &c_shortest);
|
||||
//~^ ERROR `c_shortest` does not live long enough
|
||||
//[ast]~^ ERROR `c_shortest` does not live long enough
|
||||
//[nll]~^^ ERROR `c_shortest` does not live long enough
|
||||
dr = Dr("dr", &c_shortest);
|
||||
//~^ ERROR `c_shortest` does not live long enough
|
||||
|
||||
//[ast]~^ ERROR `c_shortest` does not live long enough
|
||||
// No error: Drop impl asserts .1 (A and &'a _) are not accessed
|
||||
pt = Pt("pt", &c_shortest, &c_long);
|
||||
pr = Pr("pr", &c_shortest, &c_long);
|
||||
|
||||
// Error: Drop impl's assertion does not apply to `B` nor `&'b _`
|
||||
pt = Pt("pt", &c_long, &c_shortest);
|
||||
//~^ ERROR `c_shortest` does not live long enough
|
||||
//[ast]~^ ERROR `c_shortest` does not live long enough
|
||||
pr = Pr("pr", &c_long, &c_shortest);
|
||||
//~^ ERROR `c_shortest` does not live long enough
|
||||
//[ast]~^ ERROR `c_shortest` does not live long enough
|
||||
|
||||
// No error: St and Sr have no destructor.
|
||||
st = St("st", &c_shortest);
|
||||
sr = Sr("sr", &c_shortest);
|
||||
|
||||
println!("{:?}", (dt.0, dr.0, pt.0, pr.0, st.0, sr.0));
|
||||
use_imm(sr.1); use_imm(st.1); use_imm(pr.1); use_imm(pt.1); use_imm(dr.1); use_imm(dt.1);
|
||||
}
|
||||
|
||||
fn use_imm<T>(_: &T) { }
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ LL | }
|
|||
= note: values in a scope are dropped in the opposite order they are created
|
||||
|
||||
error[E0597]: `c_shortest` does not live long enough
|
||||
--> $DIR/dropck-eyepatch-reorder.rs:66:20
|
||||
--> $DIR/dropck-eyepatch-reorder.rs:67:20
|
||||
|
|
||||
LL | dr = Dr("dr", &c_shortest);
|
||||
| ^^^^^^^^^^ borrowed value does not live long enough
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
// The behavior of AST-borrowck and NLL explcitly differ here due to
|
||||
// NLL's increased precision; so we use revisions and do not worry
|
||||
// about the --compare-mode=nll on this test.
|
||||
|
||||
// revisions: ast nll
|
||||
//[ast]compile-flags: -Z borrowck=ast
|
||||
//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows
|
||||
|
||||
// ignore-compare-mode-nll
|
||||
|
||||
#![feature(dropck_eyepatch, rustc_attrs)]
|
||||
|
||||
|
|
@ -56,29 +56,32 @@ fn main() { #![rustc_error] // rust-lang/rust#49855
|
|||
|
||||
// Error: destructor order imprecisely modelled
|
||||
dt = Dt("dt", &c);
|
||||
//~^ ERROR `c` does not live long enough
|
||||
//[ast]~^ ERROR `c` does not live long enough
|
||||
dr = Dr("dr", &c);
|
||||
//~^ ERROR `c` does not live long enough
|
||||
//[ast]~^ ERROR `c` does not live long enough
|
||||
|
||||
// Error: `c_shortest` dies too soon for the references in dtors to be valid.
|
||||
dt = Dt("dt", &c_shortest);
|
||||
//~^ ERROR `c_shortest` does not live long enough
|
||||
//[ast]~^ ERROR `c_shortest` does not live long enough
|
||||
//[nll]~^^ ERROR `c_shortest` does not live long enough
|
||||
dr = Dr("dr", &c_shortest);
|
||||
//~^ ERROR `c_shortest` does not live long enough
|
||||
|
||||
//[ast]~^ ERROR `c_shortest` does not live long enough
|
||||
// No error: Drop impl asserts .1 (A and &'a _) are not accessed
|
||||
pt = Pt("pt", &c_shortest, &c_long);
|
||||
pr = Pr("pr", &c_shortest, &c_long);
|
||||
|
||||
// Error: Drop impl's assertion does not apply to `B` nor `&'b _`
|
||||
pt = Pt("pt", &c_long, &c_shortest);
|
||||
//~^ ERROR `c_shortest` does not live long enough
|
||||
//[ast]~^ ERROR `c_shortest` does not live long enough
|
||||
pr = Pr("pr", &c_long, &c_shortest);
|
||||
//~^ ERROR `c_shortest` does not live long enough
|
||||
//[ast]~^ ERROR `c_shortest` does not live long enough
|
||||
|
||||
// No error: St and Sr have no destructor.
|
||||
st = St("st", &c_shortest);
|
||||
sr = Sr("sr", &c_shortest);
|
||||
|
||||
println!("{:?}", (dt.0, dr.0, pt.0, pr.0, st.0, sr.0));
|
||||
use_imm(sr.1); use_imm(st.1); use_imm(pr.1); use_imm(pt.1); use_imm(dr.1); use_imm(dt.1);
|
||||
}
|
||||
|
||||
fn use_imm<T>(_: &T) { }
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ LL | }
|
|||
= note: values in a scope are dropped in the opposite order they are created
|
||||
|
||||
error[E0597]: `c_shortest` does not live long enough
|
||||
--> $DIR/dropck-eyepatch.rs:89:20
|
||||
--> $DIR/dropck-eyepatch.rs:90:20
|
||||
|
|
||||
LL | dr = Dr("dr", &c_shortest);
|
||||
| ^^^^^^^^^^ borrowed value does not live long enough
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
// The behavior of AST-borrowck and NLL explcitly differ here due to
|
||||
// NLL's increased precision; so we use revisions and do not worry
|
||||
// about the --compare-mode=nll on this test.
|
||||
|
||||
// revisions: ast nll
|
||||
//[ast]compile-flags: -Z borrowck=ast
|
||||
//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows
|
||||
|
||||
// ignore-compare-mode-nll
|
||||
|
||||
#![feature(dropck_eyepatch, rustc_attrs)]
|
||||
|
||||
|
|
@ -79,16 +79,16 @@ fn main() { #![rustc_error] // rust-lang/rust#49855
|
|||
|
||||
// Error: destructor order imprecisely modelled
|
||||
dt = Dt("dt", &c);
|
||||
//~^ ERROR `c` does not live long enough
|
||||
//[ast]~^ ERROR `c` does not live long enough
|
||||
dr = Dr("dr", &c);
|
||||
//~^ ERROR `c` does not live long enough
|
||||
//[ast]~^ ERROR `c` does not live long enough
|
||||
|
||||
// Error: `c_shortest` dies too soon for the references in dtors to be valid.
|
||||
dt = Dt("dt", &c_shortest);
|
||||
//~^ ERROR `c_shortest` does not live long enough
|
||||
//[ast]~^ ERROR `c_shortest` does not live long enough
|
||||
//[nll]~^^ ERROR `c_shortest` does not live long enough
|
||||
dr = Dr("dr", &c_shortest);
|
||||
//~^ ERROR `c_shortest` does not live long enough
|
||||
|
||||
//[ast]~^ ERROR `c_shortest` does not live long enough
|
||||
|
||||
// No error: Drop impl asserts .1 (A and &'a _) are not accessed
|
||||
pt = Pt("pt", &c_shortest, &c_long);
|
||||
|
|
@ -96,13 +96,16 @@ fn main() { #![rustc_error] // rust-lang/rust#49855
|
|||
|
||||
// Error: Drop impl's assertion does not apply to `B` nor `&'b _`
|
||||
pt = Pt("pt", &c_long, &c_shortest);
|
||||
//~^ ERROR `c_shortest` does not live long enough
|
||||
//[ast]~^ ERROR `c_shortest` does not live long enough
|
||||
pr = Pr("pr", &c_long, &c_shortest);
|
||||
//~^ ERROR `c_shortest` does not live long enough
|
||||
//[ast]~^ ERROR `c_shortest` does not live long enough
|
||||
|
||||
// No error: St and Sr have no destructor.
|
||||
st = St("st", &c_shortest);
|
||||
sr = Sr("sr", &c_shortest);
|
||||
|
||||
println!("{:?}", (dt.0, dr.0, pt.0, pr.0, st.0, sr.0));
|
||||
use_imm(sr.1); use_imm(st.1); use_imm(pr.1); use_imm(pt.1); use_imm(dr.1); use_imm(dt.1);
|
||||
}
|
||||
|
||||
fn use_imm<T>(_: &T) { }
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error[E0004]: non-exhaustive patterns: type std::option::Option<i32> is non-empt
|
|||
LL | match x { } //~ ERROR E0004
|
||||
| ^
|
||||
|
|
||||
help: Please ensure that all possible cases are being handled; possibly adding wildcards or more match arms.
|
||||
help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
||||
--> $DIR/E0004-2.rs:14:11
|
||||
|
|
||||
LL | match x { } //~ ERROR E0004
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0658]: allow_fail attribute is currently unstable (see issue #42219)
|
||||
error[E0658]: allow_fail attribute is currently unstable (see issue #46488)
|
||||
--> $DIR/feature-gate-allow_fail.rs:13:1
|
||||
|
|
||||
LL | #[allow_fail] //~ ERROR allow_fail attribute is currently unstable
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0658]: `crate` visibility modifier is experimental (see issue #45388)
|
||||
error[E0658]: `crate` visibility modifier is experimental (see issue #53120)
|
||||
--> $DIR/feature-gate-crate_visibility_modifier.rs:11:1
|
||||
|
|
||||
LL | crate struct Bender { //~ ERROR `crate` visibility modifier is experimental
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #54658)
|
||||
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
|
||||
--> $DIR/feature-gate-extern_crate_item_prelude.rs:26:9
|
||||
|
|
||||
LL | use alloc;
|
||||
|
|
@ -6,7 +6,7 @@ LL | use alloc;
|
|||
|
|
||||
= help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #54658)
|
||||
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
|
||||
--> $DIR/feature-gate-extern_crate_item_prelude.rs:28:9
|
||||
|
|
||||
LL | use alloc::boxed;
|
||||
|
|
@ -14,7 +14,7 @@ LL | use alloc::boxed;
|
|||
|
|
||||
= help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #54658)
|
||||
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
|
||||
--> $DIR/feature-gate-extern_crate_item_prelude.rs:33:11
|
||||
|
|
||||
LL | use ::alloc;
|
||||
|
|
@ -22,7 +22,7 @@ LL | use ::alloc;
|
|||
|
|
||||
= help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #54658)
|
||||
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
|
||||
--> $DIR/feature-gate-extern_crate_item_prelude.rs:35:11
|
||||
|
|
||||
LL | use ::alloc::boxed;
|
||||
|
|
@ -30,7 +30,7 @@ LL | use ::alloc::boxed;
|
|||
|
|
||||
= help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #54658)
|
||||
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
|
||||
--> $DIR/feature-gate-extern_crate_item_prelude.rs:9:17
|
||||
|
|
||||
LL | let v = alloc::vec![0];
|
||||
|
|
@ -38,7 +38,7 @@ LL | let v = alloc::vec![0];
|
|||
|
|
||||
= help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #54658)
|
||||
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
|
||||
--> $DIR/feature-gate-extern_crate_item_prelude.rs:11:18
|
||||
|
|
||||
LL | type A = alloc::boxed::Box<u8>;
|
||||
|
|
@ -46,7 +46,7 @@ LL | type A = alloc::boxed::Box<u8>;
|
|||
|
|
||||
= help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #54658)
|
||||
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
|
||||
--> $DIR/feature-gate-extern_crate_item_prelude.rs:18:19
|
||||
|
|
||||
LL | let v = ::alloc::vec![0];
|
||||
|
|
@ -54,7 +54,7 @@ LL | let v = ::alloc::vec![0];
|
|||
|
|
||||
= help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #54658)
|
||||
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
|
||||
--> $DIR/feature-gate-extern_crate_item_prelude.rs:20:20
|
||||
|
|
||||
LL | type A = ::alloc::boxed::Box<u8>;
|
||||
|
|
@ -62,7 +62,7 @@ LL | type A = ::alloc::boxed::Box<u8>;
|
|||
|
|
||||
= help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #54658)
|
||||
error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #55599)
|
||||
--> $DIR/feature-gate-extern_crate_item_prelude.rs:42:14
|
||||
|
|
||||
LL | type A = core::boxed::Box<u8>;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0658]: `extern` in paths is experimental (see issue #44660)
|
||||
error[E0658]: `extern` in paths is experimental (see issue #55600)
|
||||
--> $DIR/feature-gate-extern_in_paths.rs:14:13
|
||||
|
|
||||
LL | let _ = extern::std::vec::Vec::new(); //~ ERROR `extern` in paths is experimental
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
error: compilation successful
|
||||
--> $DIR/feature-gate-nll.rs:13:1
|
||||
|
|
||||
LL | / fn main() { #![rustc_error] // rust-lang/rust#49855
|
||||
LL | | let mut x = 33;
|
||||
LL | |
|
||||
LL | | let p = &x;
|
||||
LL | | x = 22; //~ ERROR cannot assign to `x` because it is borrowed [E0506]
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
#![feature(rustc_attrs)]
|
||||
// This is a test checking that if you do not opt into NLL then you
|
||||
// should not get the effects of NLL applied to the test.
|
||||
|
||||
// Don't use 2018 edition, since that turns on NLL (migration mode).
|
||||
// edition:2015
|
||||
|
||||
// Don't use compare-mode=nll, since that turns on NLL.
|
||||
// ignore-compare-mode-nll
|
||||
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
fn main() { #![rustc_error] // rust-lang/rust#49855
|
||||
fn main() {
|
||||
let mut x = 33;
|
||||
|
||||
let p = &x;
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// compile-flags:-C panic=abort
|
||||
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use core::panic::PanicInfo;
|
||||
|
||||
#[panic_implementation] //~ ERROR this attribute was renamed to `panic_handler` (see issue #44489)
|
||||
fn panic(info: &PanicInfo) -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
error[E0658]: this attribute was renamed to `panic_handler` (see issue #44489)
|
||||
--> $DIR/feature-gate-panic-implementation.rs:18:1
|
||||
|
|
||||
LL | #[panic_implementation] //~ ERROR this attribute was renamed to `panic_handler` (see issue #44489)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(panic_implementation)] to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
8
src/test/ui/imports/issue-55457.rs
Normal file
8
src/test/ui/imports/issue-55457.rs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
use NonExistent; //~ ERROR unresolved import `NonExistent`
|
||||
use non_existent::non_existent; //~ ERROR unresolved import `non_existent`
|
||||
|
||||
#[non_existent] //~ ERROR cannot determine resolution for the attribute macro `non_existent`
|
||||
#[derive(NonExistent)] //~ ERROR cannot determine resolution for the derive macro `NonExistent`
|
||||
struct S;
|
||||
|
||||
fn main() {}
|
||||
31
src/test/ui/imports/issue-55457.stderr
Normal file
31
src/test/ui/imports/issue-55457.stderr
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
error[E0432]: unresolved import `NonExistent`
|
||||
--> $DIR/issue-55457.rs:1:5
|
||||
|
|
||||
LL | use NonExistent; //~ ERROR unresolved import `NonExistent`
|
||||
| ^^^^^^^^^^^ no `NonExistent` in the root. Did you mean to use `non_existent`?
|
||||
|
||||
error[E0432]: unresolved import `non_existent`
|
||||
--> $DIR/issue-55457.rs:2:5
|
||||
|
|
||||
LL | use non_existent::non_existent; //~ ERROR unresolved import `non_existent`
|
||||
| ^^^^^^^^^^^^ Maybe a missing `extern crate non_existent;`?
|
||||
|
||||
error: cannot determine resolution for the derive macro `NonExistent`
|
||||
--> $DIR/issue-55457.rs:5:10
|
||||
|
|
||||
LL | #[derive(NonExistent)] //~ ERROR cannot determine resolution for the derive macro `NonExistent`
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: import resolution is stuck, try simplifying macro imports
|
||||
|
||||
error: cannot determine resolution for the attribute macro `non_existent`
|
||||
--> $DIR/issue-55457.rs:4:3
|
||||
|
|
||||
LL | #[non_existent] //~ ERROR cannot determine resolution for the attribute macro `non_existent`
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: import resolution is stuck, try simplifying macro imports
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0432`.
|
||||
|
|
@ -16,7 +16,7 @@ LL | let (c, d) = (&mut foo.a, &foo.b);
|
|||
| ----- ^^^^^ immutable borrow occurs here (via `foo.b`)
|
||||
| |
|
||||
| mutable borrow occurs here (via `foo.a`)
|
||||
LL | //~^ ERROR cannot borrow `foo` (via `foo.b`) as immutable
|
||||
...
|
||||
LL | }
|
||||
| - mutable borrow ends here
|
||||
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
error: compilation successful
|
||||
--> $DIR/issue-17263.rs:15:1
|
||||
|
|
||||
LL | / fn main() { #![rustc_error] // rust-lang/rust#49855
|
||||
LL | / fn main() { //[nll]~ ERROR compilation successful
|
||||
LL | | let mut x: Box<_> = box Foo { a: 1, b: 2 };
|
||||
LL | | let (a, b) = (&mut x.a, &mut x.b);
|
||||
LL | | //~^ ERROR cannot borrow `x` (via `x.b`) as mutable more than once at a time
|
||||
LL | | //[ast]~^ ERROR cannot borrow `x` (via `x.b`) as mutable more than once at a time
|
||||
... |
|
||||
LL | | //~^ ERROR cannot borrow `foo` (via `foo.b`) as immutable
|
||||
LL | | use_mut(a);
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
|
|
|
|||
|
|
@ -1,23 +1,35 @@
|
|||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
// This checks diagnostic quality for cases where AST-borrowck treated
|
||||
// `Box<T>` as other types (see rust-lang/rfcs#130). NLL again treats
|
||||
// `Box<T>` specially. We capture the differences via revisions.
|
||||
|
||||
// revisions: ast nll
|
||||
//[ast]compile-flags: -Z borrowck=ast
|
||||
//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows
|
||||
|
||||
// don't worry about the --compare-mode=nll on this test.
|
||||
// ignore-compare-mode-nll
|
||||
#![feature(box_syntax, rustc_attrs)]
|
||||
|
||||
struct Foo { a: isize, b: isize }
|
||||
|
||||
fn main() { #![rustc_error] // rust-lang/rust#49855
|
||||
#[rustc_error] // rust-lang/rust#49855
|
||||
fn main() { //[nll]~ ERROR compilation successful
|
||||
let mut x: Box<_> = box Foo { a: 1, b: 2 };
|
||||
let (a, b) = (&mut x.a, &mut x.b);
|
||||
//~^ ERROR cannot borrow `x` (via `x.b`) as mutable more than once at a time
|
||||
//[ast]~^ ERROR cannot borrow `x` (via `x.b`) as mutable more than once at a time
|
||||
|
||||
let mut foo: Box<_> = box Foo { a: 1, b: 2 };
|
||||
let (c, d) = (&mut foo.a, &foo.b);
|
||||
//~^ ERROR cannot borrow `foo` (via `foo.b`) as immutable
|
||||
//[ast]~^ ERROR cannot borrow `foo` (via `foo.b`) as immutable
|
||||
|
||||
// We explicitly use the references created above to illustrate
|
||||
// that NLL is accepting this code *not* because of artificially
|
||||
// short lifetimes, but rather because it understands that all the
|
||||
// references are of disjoint parts of memory.
|
||||
use_imm(d);
|
||||
use_mut(c);
|
||||
use_mut(b);
|
||||
use_mut(a);
|
||||
}
|
||||
|
||||
fn use_mut<T>(_: &mut T) { }
|
||||
fn use_imm<T>(_: &T) { }
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error[E0004]: non-exhaustive patterns: type () is non-empty
|
|||
LL | match () { } //~ ERROR non-exhaustive
|
||||
| ^^
|
||||
|
|
||||
help: Please ensure that all possible cases are being handled; possibly adding wildcards or more match arms.
|
||||
help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
||||
--> $DIR/issue-3096-1.rs:12:11
|
||||
|
|
||||
LL | match () { } //~ ERROR non-exhaustive
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ error[E0004]: non-exhaustive patterns: type *const bottom is non-empty
|
|||
LL | match x { } //~ ERROR non-exhaustive patterns
|
||||
| ^
|
||||
|
|
||||
help: Please ensure that all possible cases are being handled; possibly adding wildcards or more match arms.
|
||||
help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
||||
--> $DIR/issue-3096-2.rs:15:11
|
||||
|
|
||||
LL | match x { } //~ ERROR non-exhaustive patterns
|
||||
|
|
|
|||
17
src/test/ui/issues/issue-31076.rs
Normal file
17
src/test/ui/issues/issue-31076.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#![feature(no_core, lang_items)]
|
||||
#![no_core]
|
||||
|
||||
#[lang="sized"]
|
||||
trait Sized {}
|
||||
|
||||
#[lang="add"]
|
||||
trait Add<T> {}
|
||||
|
||||
impl Add<i32> for i32 {}
|
||||
|
||||
fn main() {
|
||||
let x = 5 + 6;
|
||||
//~^ ERROR binary operation `+` cannot be applied to type `{integer}`
|
||||
let y = 5i32 + 6i32;
|
||||
//~^ ERROR binary operation `+` cannot be applied to type `i32`
|
||||
}
|
||||
19
src/test/ui/issues/issue-31076.stderr
Normal file
19
src/test/ui/issues/issue-31076.stderr
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
error[E0369]: binary operation `+` cannot be applied to type `{integer}`
|
||||
--> $DIR/issue-31076.rs:13:13
|
||||
|
|
||||
LL | let x = 5 + 6;
|
||||
| ^^^^^
|
||||
|
|
||||
= note: an implementation of `std::ops::Add` might be missing for `{integer}`
|
||||
|
||||
error[E0369]: binary operation `+` cannot be applied to type `i32`
|
||||
--> $DIR/issue-31076.rs:15:13
|
||||
|
|
||||
LL | let y = 5i32 + 6i32;
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: an implementation of `std::ops::Add` might be missing for `i32`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0369`.
|
||||
|
|
@ -3,9 +3,9 @@ error[E0597]: `line` does not live long enough
|
|||
|
|
||||
LL | let v: Vec<&str> = line.split_whitespace().collect();
|
||||
| ^^^^ borrowed value does not live long enough
|
||||
LL | //~^ ERROR `line` does not live long enough
|
||||
LL | println!("accumulator before add_assign {:?}", acc.map);
|
||||
| ------- borrow used here, in later iteration of loop
|
||||
...
|
||||
LL | acc += cnt2;
|
||||
| --- borrow used here, in later iteration of loop
|
||||
...
|
||||
LL | }
|
||||
| - `line` dropped here while still borrowed
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ pub fn panics() {
|
|||
for line in vec!["123456789".to_string(), "12345678".to_string()] {
|
||||
let v: Vec<&str> = line.split_whitespace().collect();
|
||||
//~^ ERROR `line` does not live long enough
|
||||
println!("accumulator before add_assign {:?}", acc.map);
|
||||
// println!("accumulator before add_assign {:?}", acc.map);
|
||||
let mut map = HashMap::new();
|
||||
for str_ref in v {
|
||||
let e = map.entry(str_ref);
|
||||
|
|
@ -53,7 +53,7 @@ pub fn panics() {
|
|||
}
|
||||
let cnt2 = Counter{map};
|
||||
acc += cnt2;
|
||||
println!("accumulator after add_assign {:?}", acc.map);
|
||||
// println!("accumulator after add_assign {:?}", acc.map);
|
||||
// line gets dropped here but references are kept in acc.map
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
error: use of deprecated attribute `panic_implementation`: this attribute was renamed to `panic_handler`. See https://github.com/rust-lang/rust/issues/44489#issuecomment-415140224
|
||||
--> $DIR/panic-implementation-deprecated.rs:19:1
|
||||
|
|
||||
LL | #[panic_implementation]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: replace this attribute with `#[panic_handler]`
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/panic-implementation-deprecated.rs:13:9
|
||||
|
|
||||
LL | #![deny(deprecated)]
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -14,6 +14,16 @@ LL | fn deref_extend_mut_field1(x: &Own<Point>) -> &mut isize {
|
|||
LL | &mut x.y //~ ERROR cannot borrow
|
||||
| ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
|
||||
|
||||
error[E0499]: cannot borrow `*x` as mutable more than once at a time
|
||||
--> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:88:19
|
||||
|
|
||||
LL | let _x = &mut x.x;
|
||||
| - first mutable borrow occurs here
|
||||
LL | let _y = &mut x.y; //~ ERROR cannot borrow
|
||||
| ^ second mutable borrow occurs here
|
||||
LL | use_mut(_x);
|
||||
| -- first borrow later used here
|
||||
|
||||
error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
|
||||
--> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:98:5
|
||||
|
|
||||
|
|
@ -30,6 +40,16 @@ LL | fn assign_field2<'a>(x: &'a Own<Point>) {
|
|||
LL | x.y = 3; //~ ERROR cannot borrow
|
||||
| ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
|
||||
|
||||
error[E0499]: cannot borrow `*x` as mutable more than once at a time
|
||||
--> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:111:5
|
||||
|
|
||||
LL | let _p: &mut Point = &mut **x;
|
||||
| -- first mutable borrow occurs here
|
||||
LL | x.y = 3; //~ ERROR cannot borrow
|
||||
| ^ second mutable borrow occurs here
|
||||
LL | use_mut(_p);
|
||||
| -- first borrow later used here
|
||||
|
||||
error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
|
||||
--> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:119:5
|
||||
|
|
||||
|
|
@ -62,6 +82,7 @@ LL | fn assign_method2<'a>(x: &'a Own<Point>) {
|
|||
LL | *x.y_mut() = 3; //~ ERROR cannot borrow
|
||||
| ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0596`.
|
||||
Some errors occurred: E0499, E0596.
|
||||
For more information about an error, try `rustc --explain E0499`.
|
||||
|
|
|
|||
|
|
@ -86,8 +86,8 @@ fn deref_extend_mut_field3(x: &mut Own<Point>) {
|
|||
|
||||
let _x = &mut x.x;
|
||||
let _y = &mut x.y; //~ ERROR cannot borrow
|
||||
use_mut(_x);
|
||||
}
|
||||
|
||||
fn deref_extend_mut_field4<'a>(x: &'a mut Own<Point>) {
|
||||
let p = &mut **x;
|
||||
let _x = &mut p.x;
|
||||
|
|
@ -109,8 +109,8 @@ fn assign_field3<'a>(x: &'a mut Own<Point>) {
|
|||
fn assign_field4<'a>(x: &'a mut Own<Point>) {
|
||||
let _p: &mut Point = &mut **x;
|
||||
x.y = 3; //~ ERROR cannot borrow
|
||||
use_mut(_p);
|
||||
}
|
||||
|
||||
fn deref_imm_method(x: Own<Point>) {
|
||||
let __isize = x.get();
|
||||
}
|
||||
|
|
@ -148,3 +148,5 @@ fn assign_method3<'a>(x: &'a mut Own<Point>) {
|
|||
}
|
||||
|
||||
pub fn main() {}
|
||||
|
||||
fn use_mut<T>(_: &mut T) {}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ LL | let _x = &mut x.x;
|
|||
| - first mutable borrow occurs here
|
||||
LL | let _y = &mut x.y; //~ ERROR cannot borrow
|
||||
| ^ second mutable borrow occurs here
|
||||
LL | use_mut(_x);
|
||||
LL | }
|
||||
| - first borrow ends here
|
||||
|
||||
|
|
@ -47,6 +48,7 @@ LL | let _p: &mut Point = &mut **x;
|
|||
| -- first mutable borrow occurs here
|
||||
LL | x.y = 3; //~ ERROR cannot borrow
|
||||
| ^ second mutable borrow occurs here
|
||||
LL | use_mut(_p);
|
||||
LL | }
|
||||
| - first borrow ends here
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ error[E0004]: non-exhaustive patterns: type &Void is non-empty
|
|||
LL | let _ = match x {}; //~ ERROR non-exhaustive
|
||||
| ^
|
||||
|
|
||||
help: Please ensure that all possible cases are being handled; possibly adding wildcards or more match arms.
|
||||
help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
||||
--> $DIR/uninhabited-matches-feature-gated.rs:20:19
|
||||
|
|
||||
LL | let _ = match x {}; //~ ERROR non-exhaustive
|
||||
|
|
@ -22,7 +22,7 @@ error[E0004]: non-exhaustive patterns: type (Void,) is non-empty
|
|||
LL | let _ = match x {}; //~ ERROR non-exhaustive
|
||||
| ^
|
||||
|
|
||||
help: Please ensure that all possible cases are being handled; possibly adding wildcards or more match arms.
|
||||
help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
||||
--> $DIR/uninhabited-matches-feature-gated.rs:23:19
|
||||
|
|
||||
LL | let _ = match x {}; //~ ERROR non-exhaustive
|
||||
|
|
@ -34,7 +34,7 @@ error[E0004]: non-exhaustive patterns: type [Void; 1] is non-empty
|
|||
LL | let _ = match x {}; //~ ERROR non-exhaustive
|
||||
| ^
|
||||
|
|
||||
help: Please ensure that all possible cases are being handled; possibly adding wildcards or more match arms.
|
||||
help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
|
||||
--> $DIR/uninhabited-matches-feature-gated.rs:26:19
|
||||
|
|
||||
LL | let _ = match x {}; //~ ERROR non-exhaustive
|
||||
|
|
|
|||
|
|
@ -1,33 +1,64 @@
|
|||
error[E0502]: cannot borrow `u.y` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/union-borrow-move-parent-sibling.rs:25:13
|
||||
|
|
||||
LL | let a = &mut u.x.0;
|
||||
| ---------- mutable borrow occurs here
|
||||
LL | let b = &u.y; //~ ERROR cannot borrow `u.y`
|
||||
| ^^^^ immutable borrow occurs here
|
||||
LL | use_borrow(a);
|
||||
| - mutable borrow later used here
|
||||
|
||||
error[E0382]: use of moved value: `u`
|
||||
--> $DIR/union-borrow-move-parent-sibling.rs:29:13
|
||||
--> $DIR/union-borrow-move-parent-sibling.rs:32:13
|
||||
|
|
||||
LL | let a = u.x.0;
|
||||
| ----- value moved here
|
||||
LL | let a = u.y; //~ ERROR use of moved value: `u.y`
|
||||
LL | let b = u.y; //~ ERROR use of moved value: `u.y`
|
||||
| ^^^ value used here after move
|
||||
|
|
||||
= note: move occurs because `u` has type `U`, which does not implement the `Copy` trait
|
||||
|
||||
error[E0502]: cannot borrow `u.y` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/union-borrow-move-parent-sibling.rs:38:13
|
||||
|
|
||||
LL | let a = &mut (u.x.0).0;
|
||||
| -------------- mutable borrow occurs here
|
||||
LL | let b = &u.y; //~ ERROR cannot borrow `u.y`
|
||||
| ^^^^ immutable borrow occurs here
|
||||
LL | use_borrow(a);
|
||||
| - mutable borrow later used here
|
||||
|
||||
error[E0382]: use of moved value: `u`
|
||||
--> $DIR/union-borrow-move-parent-sibling.rs:41:13
|
||||
--> $DIR/union-borrow-move-parent-sibling.rs:45:13
|
||||
|
|
||||
LL | let a = (u.x.0).0;
|
||||
| --------- value moved here
|
||||
LL | let a = u.y; //~ ERROR use of moved value: `u.y`
|
||||
LL | let b = u.y; //~ ERROR use of moved value: `u.y`
|
||||
| ^^^ value used here after move
|
||||
|
|
||||
= note: move occurs because `u` has type `U`, which does not implement the `Copy` trait
|
||||
|
||||
error[E0502]: cannot borrow `u.x` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/union-borrow-move-parent-sibling.rs:51:13
|
||||
|
|
||||
LL | let a = &mut *u.y;
|
||||
| --------- mutable borrow occurs here
|
||||
LL | let b = &u.x; //~ ERROR cannot borrow `u` (via `u.x`)
|
||||
| ^^^^ immutable borrow occurs here
|
||||
LL | use_borrow(a);
|
||||
| - mutable borrow later used here
|
||||
|
||||
error[E0382]: use of moved value: `u`
|
||||
--> $DIR/union-borrow-move-parent-sibling.rs:53:13
|
||||
--> $DIR/union-borrow-move-parent-sibling.rs:58:13
|
||||
|
|
||||
LL | let a = *u.y;
|
||||
| ---- value moved here
|
||||
LL | let a = u.x; //~ ERROR use of moved value: `u.x`
|
||||
LL | let b = u.x; //~ ERROR use of moved value: `u.x`
|
||||
| ^^^ value used here after move
|
||||
|
|
||||
= note: move occurs because `u` has type `U`, which does not implement the `Copy` trait
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0382`.
|
||||
Some errors occurred: E0382, E0502.
|
||||
For more information about an error, try `rustc --explain E0382`.
|
||||
|
|
|
|||
|
|
@ -17,40 +17,45 @@ union U {
|
|||
y: Box<Vec<u8>>,
|
||||
}
|
||||
|
||||
fn use_borrow<T>(_: &T) {}
|
||||
|
||||
unsafe fn parent_sibling_borrow() {
|
||||
let mut u = U { x: ((Vec::new(), Vec::new()), Vec::new()) };
|
||||
let a = &mut u.x.0;
|
||||
let a = &u.y; //~ ERROR cannot borrow `u.y`
|
||||
let b = &u.y; //~ ERROR cannot borrow `u.y`
|
||||
use_borrow(a);
|
||||
}
|
||||
|
||||
unsafe fn parent_sibling_move() {
|
||||
let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) };
|
||||
let a = u.x.0;
|
||||
let a = u.y; //~ ERROR use of moved value: `u.y`
|
||||
let b = u.y; //~ ERROR use of moved value: `u.y`
|
||||
}
|
||||
|
||||
unsafe fn grandparent_sibling_borrow() {
|
||||
let mut u = U { x: ((Vec::new(), Vec::new()), Vec::new()) };
|
||||
let a = &mut (u.x.0).0;
|
||||
let a = &u.y; //~ ERROR cannot borrow `u.y`
|
||||
let b = &u.y; //~ ERROR cannot borrow `u.y`
|
||||
use_borrow(a);
|
||||
}
|
||||
|
||||
unsafe fn grandparent_sibling_move() {
|
||||
let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) };
|
||||
let a = (u.x.0).0;
|
||||
let a = u.y; //~ ERROR use of moved value: `u.y`
|
||||
let b = u.y; //~ ERROR use of moved value: `u.y`
|
||||
}
|
||||
|
||||
unsafe fn deref_sibling_borrow() {
|
||||
let mut u = U { y: Box::default() };
|
||||
let a = &mut *u.y;
|
||||
let a = &u.x; //~ ERROR cannot borrow `u` (via `u.x`)
|
||||
let b = &u.x; //~ ERROR cannot borrow `u` (via `u.x`)
|
||||
use_borrow(a);
|
||||
}
|
||||
|
||||
unsafe fn deref_sibling_move() {
|
||||
let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) };
|
||||
let a = *u.y;
|
||||
let a = u.x; //~ ERROR use of moved value: `u.x`
|
||||
let b = u.x; //~ ERROR use of moved value: `u.x`
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,59 +1,62 @@
|
|||
error[E0502]: cannot borrow `u.y` as immutable because `u.x.0` is also borrowed as mutable
|
||||
--> $DIR/union-borrow-move-parent-sibling.rs:23:14
|
||||
--> $DIR/union-borrow-move-parent-sibling.rs:25:14
|
||||
|
|
||||
LL | let a = &mut u.x.0;
|
||||
| ----- mutable borrow occurs here
|
||||
LL | let a = &u.y; //~ ERROR cannot borrow `u.y`
|
||||
LL | let b = &u.y; //~ ERROR cannot borrow `u.y`
|
||||
| ^^^ immutable borrow occurs here
|
||||
LL | use_borrow(a);
|
||||
LL | }
|
||||
| - mutable borrow ends here
|
||||
|
||||
error[E0382]: use of moved value: `u.y`
|
||||
--> $DIR/union-borrow-move-parent-sibling.rs:29:9
|
||||
--> $DIR/union-borrow-move-parent-sibling.rs:32:9
|
||||
|
|
||||
LL | let a = u.x.0;
|
||||
| - value moved here
|
||||
LL | let a = u.y; //~ ERROR use of moved value: `u.y`
|
||||
LL | let b = u.y; //~ ERROR use of moved value: `u.y`
|
||||
| ^ value used here after move
|
||||
|
|
||||
= note: move occurs because `u.y` has type `[type error]`, which does not implement the `Copy` trait
|
||||
|
||||
error[E0502]: cannot borrow `u.y` as immutable because `u.x.0.0` is also borrowed as mutable
|
||||
--> $DIR/union-borrow-move-parent-sibling.rs:35:14
|
||||
--> $DIR/union-borrow-move-parent-sibling.rs:38:14
|
||||
|
|
||||
LL | let a = &mut (u.x.0).0;
|
||||
| --------- mutable borrow occurs here
|
||||
LL | let a = &u.y; //~ ERROR cannot borrow `u.y`
|
||||
LL | let b = &u.y; //~ ERROR cannot borrow `u.y`
|
||||
| ^^^ immutable borrow occurs here
|
||||
LL | use_borrow(a);
|
||||
LL | }
|
||||
| - mutable borrow ends here
|
||||
|
||||
error[E0382]: use of moved value: `u.y`
|
||||
--> $DIR/union-borrow-move-parent-sibling.rs:41:9
|
||||
--> $DIR/union-borrow-move-parent-sibling.rs:45:9
|
||||
|
|
||||
LL | let a = (u.x.0).0;
|
||||
| - value moved here
|
||||
LL | let a = u.y; //~ ERROR use of moved value: `u.y`
|
||||
LL | let b = u.y; //~ ERROR use of moved value: `u.y`
|
||||
| ^ value used here after move
|
||||
|
|
||||
= note: move occurs because `u.y` has type `[type error]`, which does not implement the `Copy` trait
|
||||
|
||||
error[E0502]: cannot borrow `u` (via `u.x`) as immutable because `u` is also borrowed as mutable (via `*u.y`)
|
||||
--> $DIR/union-borrow-move-parent-sibling.rs:47:14
|
||||
--> $DIR/union-borrow-move-parent-sibling.rs:51:14
|
||||
|
|
||||
LL | let a = &mut *u.y;
|
||||
| ---- mutable borrow occurs here (via `*u.y`)
|
||||
LL | let a = &u.x; //~ ERROR cannot borrow `u` (via `u.x`)
|
||||
LL | let b = &u.x; //~ ERROR cannot borrow `u` (via `u.x`)
|
||||
| ^^^ immutable borrow occurs here (via `u.x`)
|
||||
LL | use_borrow(a);
|
||||
LL | }
|
||||
| - mutable borrow ends here
|
||||
|
||||
error[E0382]: use of moved value: `u.x`
|
||||
--> $DIR/union-borrow-move-parent-sibling.rs:53:9
|
||||
--> $DIR/union-borrow-move-parent-sibling.rs:58:9
|
||||
|
|
||||
LL | let a = *u.y;
|
||||
| - value moved here
|
||||
LL | let a = u.x; //~ ERROR use of moved value: `u.x`
|
||||
LL | let b = u.x; //~ ERROR use of moved value: `u.x`
|
||||
| ^ value used here after move
|
||||
|
|
||||
= note: move occurs because `u.x` has type `[type error]`, which does not implement the `Copy` trait
|
||||
|
|
|
|||
|
|
@ -9,6 +9,29 @@ LL | x.clone(); //~ ERROR: use of moved value
|
|||
|
|
||||
= note: move occurs because `x` has type `T`, which does not implement the `Copy` trait
|
||||
|
||||
error[E0505]: cannot move out of `x` because it is borrowed
|
||||
--> $DIR/unop-move-semantics.rs:25:6
|
||||
|
|
||||
LL | let m = &x;
|
||||
| -- borrow of `x` occurs here
|
||||
...
|
||||
LL | !x; //~ ERROR: cannot move out of `x` because it is borrowed
|
||||
| ^ move out of `x` occurs here
|
||||
...
|
||||
LL | use_mut(n); use_imm(m);
|
||||
| - borrow later used here
|
||||
|
||||
error[E0505]: cannot move out of `y` because it is borrowed
|
||||
--> $DIR/unop-move-semantics.rs:27:6
|
||||
|
|
||||
LL | let n = &mut y;
|
||||
| ------ borrow of `y` occurs here
|
||||
...
|
||||
LL | !y; //~ ERROR: cannot move out of `y` because it is borrowed
|
||||
| ^ move out of `y` occurs here
|
||||
LL | use_mut(n); use_imm(m);
|
||||
| - borrow later used here
|
||||
|
||||
error[E0507]: cannot move out of borrowed content
|
||||
--> $DIR/unop-move-semantics.rs:34:6
|
||||
|
|
||||
|
|
@ -21,7 +44,7 @@ error[E0507]: cannot move out of borrowed content
|
|||
LL | !*n; //~ ERROR: cannot move out of borrowed content
|
||||
| ^^ cannot move out of borrowed content
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
Some errors occurred: E0382, E0507.
|
||||
Some errors occurred: E0382, E0505, E0507.
|
||||
For more information about an error, try `rustc --explain E0382`.
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ fn move_borrowed<T: Not<Output=T>>(x: T, mut y: T) {
|
|||
!x; //~ ERROR: cannot move out of `x` because it is borrowed
|
||||
|
||||
!y; //~ ERROR: cannot move out of `y` because it is borrowed
|
||||
use_mut(n); use_imm(m);
|
||||
}
|
||||
|
||||
fn illegal_dereference<T: Not<Output=T>>(mut x: T, y: T) {
|
||||
let m = &mut x;
|
||||
let n = &y;
|
||||
|
|
@ -34,6 +34,9 @@ fn illegal_dereference<T: Not<Output=T>>(mut x: T, y: T) {
|
|||
!*m; //~ ERROR: cannot move out of borrowed content
|
||||
|
||||
!*n; //~ ERROR: cannot move out of borrowed content
|
||||
use_imm(n); use_mut(m);
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
||||
fn use_mut<T>(_: &mut T) { }
|
||||
fn use_imm<T>(_: &T) { }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue