mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-21 19:33:16 +00:00
Run check_match
and check_liveness
when MIR is built instead of having an explicit phase for them
This commit is contained in:
parent
5bb58a68de
commit
334423263a
@ -761,27 +761,6 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
|
||||
// passes are timed inside typeck
|
||||
rustc_hir_analysis::check_crate(tcx)?;
|
||||
|
||||
sess.time("misc_checking_2", || {
|
||||
parallel!(
|
||||
{
|
||||
sess.time("match_checking", || {
|
||||
tcx.hir().par_body_owners(|def_id| tcx.ensure().check_match(def_id))
|
||||
});
|
||||
},
|
||||
{
|
||||
sess.time("liveness_checking", || {
|
||||
tcx.hir().par_body_owners(|def_id| {
|
||||
// this must run before MIR dump, because
|
||||
// "not all control paths return a value" is reported here.
|
||||
//
|
||||
// maybe move the check to a MIR pass?
|
||||
tcx.ensure().check_liveness(def_id);
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
sess.time("MIR_borrow_checking", || {
|
||||
tcx.hir().par_body_owners(|def_id| tcx.ensure().mir_borrowck(def_id));
|
||||
});
|
||||
|
@ -51,6 +51,13 @@ fn mir_build(tcx: TyCtxt<'_>, def: LocalDefId) -> Body<'_> {
|
||||
// of `mir_build`, so now we can steal it
|
||||
let thir = thir.steal();
|
||||
|
||||
tcx.ensure().check_match(def);
|
||||
// this must run before MIR dump, because
|
||||
// "not all control paths return a value" is reported here.
|
||||
//
|
||||
// maybe move the check to a MIR pass?
|
||||
tcx.ensure().check_liveness(def);
|
||||
|
||||
match thir.body_type {
|
||||
thir::BodyTy::Fn(fn_sig) => construct_fn(tcx, def, &thir, expr, fn_sig),
|
||||
thir::BodyTy::Const(ty) => construct_const(tcx, def, &thir, expr, ty),
|
||||
|
@ -98,6 +98,7 @@ use rustc_middle::ty::query::Providers;
|
||||
use rustc_middle::ty::{self, RootVariableMinCaptureList, Ty, TyCtxt};
|
||||
use rustc_session::lint;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
use rustc_span::DUMMY_SP;
|
||||
use rustc_span::{BytePos, Span};
|
||||
|
||||
use std::collections::VecDeque;
|
||||
@ -586,8 +587,13 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn assigned_on_exit(&self, ln: LiveNode, var: Variable) -> bool {
|
||||
let successor = self.successors[ln].unwrap();
|
||||
self.assigned_on_entry(successor, var)
|
||||
match self.successors[ln] {
|
||||
Some(successor) => self.assigned_on_entry(successor, var),
|
||||
None => {
|
||||
self.ir.tcx.sess.delay_span_bug(DUMMY_SP, "no successor");
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn write_vars<F>(&self, wr: &mut dyn Write, mut test: F) -> io::Result<()>
|
||||
|
@ -7,10 +7,10 @@ promoted[0] in FOO: &[&i32; 1] = {
|
||||
let mut _3: *const i32; // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43
|
||||
|
||||
bb0: {
|
||||
_3 = const {alloc2: *const i32}; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43
|
||||
_3 = const {alloc3: *const i32}; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43
|
||||
// mir::Constant
|
||||
// + span: $DIR/const_promotion_extern_static.rs:13:42: 13:43
|
||||
// + literal: Const { ty: *const i32, val: Value(Scalar(alloc2)) }
|
||||
// + literal: Const { ty: *const i32, val: Value(Scalar(alloc3)) }
|
||||
_2 = &(*_3); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:41: +0:43
|
||||
_1 = [move _2]; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:46
|
||||
_0 = &_1; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55
|
||||
@ -18,4 +18,4 @@ promoted[0] in FOO: &[&i32; 1] = {
|
||||
}
|
||||
}
|
||||
|
||||
alloc2 (extern static: X)
|
||||
alloc3 (extern static: X)
|
||||
|
@ -18,11 +18,11 @@
|
||||
- StorageLive(_3); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:46
|
||||
- StorageLive(_4); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:32: +0:45
|
||||
- StorageLive(_5); // scope 1 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43
|
||||
- _5 = const {alloc2: *const i32}; // scope 1 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43
|
||||
- _5 = const {alloc3: *const i32}; // scope 1 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43
|
||||
+ _6 = const _; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55
|
||||
// mir::Constant
|
||||
- // + span: $DIR/const_promotion_extern_static.rs:13:42: 13:43
|
||||
- // + literal: Const { ty: *const i32, val: Value(Scalar(alloc2)) }
|
||||
- // + literal: Const { ty: *const i32, val: Value(Scalar(alloc3)) }
|
||||
- _4 = &(*_5); // scope 1 at $DIR/const_promotion_extern_static.rs:+0:41: +0:43
|
||||
- _3 = [move _4]; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:46
|
||||
- _2 = &_3; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55
|
||||
@ -50,5 +50,5 @@
|
||||
}
|
||||
}
|
||||
-
|
||||
- alloc2 (extern static: X)
|
||||
- alloc3 (extern static: X)
|
||||
|
||||
|
@ -1,19 +1,3 @@
|
||||
error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:36:9
|
||||
|
|
||||
LL | ref foo @ [.., ref mut bar] => (),
|
||||
| ^^^^^^^ ----------- value is mutably borrowed by `bar` here
|
||||
| |
|
||||
| value is borrowed by `foo` here
|
||||
|
||||
error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:120:9
|
||||
|
|
||||
LL | ref foo @ Some(box ref mut s) => (),
|
||||
| ^^^^^^^ --------- value is mutably borrowed by `s` here
|
||||
| |
|
||||
| value is borrowed by `foo` here
|
||||
|
||||
error[E0382]: borrow of moved value: `x`
|
||||
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:18:5
|
||||
|
|
||||
@ -43,6 +27,14 @@ LL | &x;
|
||||
LL | drop(r);
|
||||
| - mutable borrow later used here
|
||||
|
||||
error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:36:9
|
||||
|
|
||||
LL | ref foo @ [.., ref mut bar] => (),
|
||||
| ^^^^^^^ ----------- value is mutably borrowed by `bar` here
|
||||
| |
|
||||
| value is borrowed by `foo` here
|
||||
|
||||
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:50:5
|
||||
|
|
||||
@ -120,6 +112,14 @@ LL | &mut x;
|
||||
LL | drop(r);
|
||||
| - immutable borrow later used here
|
||||
|
||||
error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:120:9
|
||||
|
|
||||
LL | ref foo @ Some(box ref mut s) => (),
|
||||
| ^^^^^^^ --------- value is mutably borrowed by `s` here
|
||||
| |
|
||||
| value is borrowed by `foo` here
|
||||
|
||||
error[E0382]: borrow of moved value: `x`
|
||||
--> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:134:5
|
||||
|
|
||||
|
@ -1,17 +1,3 @@
|
||||
error[E0004]: non-exhaustive patterns: type `u8` is non-empty
|
||||
--> $DIR/pattern-matching-should-fail.rs:67:23
|
||||
|
|
||||
LL | let c1 = || match x { };
|
||||
| ^
|
||||
|
|
||||
= note: the matched value is of type `u8`
|
||||
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
|
||||
|
|
||||
LL ~ let c1 = || match x {
|
||||
LL + _ => todo!(),
|
||||
LL ~ };
|
||||
|
|
||||
|
||||
error[E0381]: used binding `x` isn't initialized
|
||||
--> $DIR/pattern-matching-should-fail.rs:8:23
|
||||
|
|
||||
@ -69,6 +55,20 @@ LL | let t: !;
|
||||
LL | match t { };
|
||||
| ^ `t` used here but it isn't initialized
|
||||
|
||||
error[E0004]: non-exhaustive patterns: type `u8` is non-empty
|
||||
--> $DIR/pattern-matching-should-fail.rs:67:23
|
||||
|
|
||||
LL | let c1 = || match x { };
|
||||
| ^
|
||||
|
|
||||
= note: the matched value is of type `u8`
|
||||
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
|
||||
|
|
||||
LL ~ let c1 = || match x {
|
||||
LL + _ => todo!(),
|
||||
LL ~ };
|
||||
|
|
||||
|
||||
error[E0381]: used binding `x` isn't initialized
|
||||
--> $DIR/pattern-matching-should-fail.rs:67:23
|
||||
|
|
||||
|
@ -12,12 +12,6 @@ error[E0170]: pattern binding `Foo` is named the same as one of the variants of
|
||||
LL | let Foo = foo::Foo::Foo;
|
||||
| ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo`
|
||||
|
||||
error[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `foo::Foo`
|
||||
--> $DIR/lint-uppercase-variables.rs:33:17
|
||||
|
|
||||
LL | fn in_param(Foo: foo::Foo) {}
|
||||
| ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo`
|
||||
|
||||
warning: unused variable: `Foo`
|
||||
--> $DIR/lint-uppercase-variables.rs:22:9
|
||||
|
|
||||
@ -37,6 +31,12 @@ warning: unused variable: `Foo`
|
||||
LL | let Foo = foo::Foo::Foo;
|
||||
| ^^^ help: if this is intentional, prefix it with an underscore: `_Foo`
|
||||
|
||||
error[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `foo::Foo`
|
||||
--> $DIR/lint-uppercase-variables.rs:33:17
|
||||
|
|
||||
LL | fn in_param(Foo: foo::Foo) {}
|
||||
| ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo`
|
||||
|
||||
warning: unused variable: `Foo`
|
||||
--> $DIR/lint-uppercase-variables.rs:33:17
|
||||
|
|
||||
|
@ -1,15 +1,3 @@
|
||||
error: unused variable: `this_is_my_function`
|
||||
--> $DIR/expect_nested_lint_levels.rs:48:9
|
||||
|
|
||||
LL | let this_is_my_function = 3;
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_this_is_my_function`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/expect_nested_lint_levels.rs:45:10
|
||||
|
|
||||
LL | #[forbid(unused_variables)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: variable does not need to be mutable
|
||||
--> $DIR/expect_nested_lint_levels.rs:36:13
|
||||
|
|
||||
@ -25,6 +13,18 @@ note: the lint level is defined here
|
||||
LL | unused_mut,
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: unused variable: `this_is_my_function`
|
||||
--> $DIR/expect_nested_lint_levels.rs:48:9
|
||||
|
|
||||
LL | let this_is_my_function = 3;
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_this_is_my_function`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/expect_nested_lint_levels.rs:45:10
|
||||
|
|
||||
LL | #[forbid(unused_variables)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: this lint expectation is unfulfilled
|
||||
--> $DIR/expect_nested_lint_levels.rs:7:5
|
||||
|
|
||||
|
@ -12,12 +12,6 @@ warning: unused variable: `fox_name`
|
||||
LL | let fox_name = "Sir Nibbles";
|
||||
| ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_fox_name`
|
||||
|
||||
warning: unused variable: `this_should_fulfill_the_expectation`
|
||||
--> $DIR/force_warn_expected_lints_fulfilled.rs:43:9
|
||||
|
|
||||
LL | let this_should_fulfill_the_expectation = "The `#[allow]` has no power here";
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_this_should_fulfill_the_expectation`
|
||||
|
||||
warning: variable does not need to be mutable
|
||||
--> $DIR/force_warn_expected_lints_fulfilled.rs:32:9
|
||||
|
|
||||
@ -28,6 +22,12 @@ LL | let mut what_does_the_fox_say = "*ding* *deng* *dung*";
|
||||
|
|
||||
= note: requested on the command line with `--force-warn unused-mut`
|
||||
|
||||
warning: unused variable: `this_should_fulfill_the_expectation`
|
||||
--> $DIR/force_warn_expected_lints_fulfilled.rs:43:9
|
||||
|
|
||||
LL | let this_should_fulfill_the_expectation = "The `#[allow]` has no power here";
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_this_should_fulfill_the_expectation`
|
||||
|
||||
warning: denote infinite loops with `loop { ... }`
|
||||
--> $DIR/force_warn_expected_lints_fulfilled.rs:10:5
|
||||
|
|
||||
|
@ -10,18 +10,18 @@ note: the lint level is defined here
|
||||
LL | #![deny(unused_variables)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unused variable: `b`
|
||||
--> $DIR/lint-unused-variables.rs:14:5
|
||||
|
|
||||
LL | b: i32,
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_b`
|
||||
|
||||
error: unused variable: `a`
|
||||
--> $DIR/lint-unused-variables.rs:22:9
|
||||
|
|
||||
LL | a: i32,
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
||||
|
||||
error: unused variable: `b`
|
||||
--> $DIR/lint-unused-variables.rs:14:5
|
||||
|
|
||||
LL | b: i32,
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_b`
|
||||
|
||||
error: unused variable: `b`
|
||||
--> $DIR/lint-unused-variables.rs:29:9
|
||||
|
|
||||
|
@ -1,10 +1,9 @@
|
||||
warning: variable `a` is assigned to, but never used
|
||||
--> $DIR/liveness-consts.rs:7:13
|
||||
warning: unused variable: `e`
|
||||
--> $DIR/liveness-consts.rs:24:13
|
||||
|
|
||||
LL | let mut a = 0;
|
||||
| ^
|
||||
LL | let e = 1;
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_e`
|
||||
|
|
||||
= note: consider using `_a` instead
|
||||
note: the lint level is defined here
|
||||
--> $DIR/liveness-consts.rs:2:9
|
||||
|
|
||||
@ -12,21 +11,6 @@ LL | #![warn(unused)]
|
||||
| ^^^^^^
|
||||
= note: `#[warn(unused_variables)]` implied by `#[warn(unused)]`
|
||||
|
||||
warning: value assigned to `b` is never read
|
||||
--> $DIR/liveness-consts.rs:17:5
|
||||
|
|
||||
LL | b += 1;
|
||||
| ^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
= note: `#[warn(unused_assignments)]` implied by `#[warn(unused)]`
|
||||
|
||||
warning: unused variable: `e`
|
||||
--> $DIR/liveness-consts.rs:24:13
|
||||
|
|
||||
LL | let e = 1;
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_e`
|
||||
|
||||
warning: unused variable: `s`
|
||||
--> $DIR/liveness-consts.rs:33:24
|
||||
|
|
||||
@ -39,6 +23,29 @@ warning: unused variable: `z`
|
||||
LL | pub fn f(x: [u8; { let s = 17; 100 }]) -> [u8; { let z = 18; 100 }] {
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_z`
|
||||
|
||||
warning: unused variable: `z`
|
||||
--> $DIR/liveness-consts.rs:60:13
|
||||
|
|
||||
LL | let z = 42;
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_z`
|
||||
|
||||
warning: variable `a` is assigned to, but never used
|
||||
--> $DIR/liveness-consts.rs:7:13
|
||||
|
|
||||
LL | let mut a = 0;
|
||||
| ^
|
||||
|
|
||||
= note: consider using `_a` instead
|
||||
|
||||
warning: value assigned to `b` is never read
|
||||
--> $DIR/liveness-consts.rs:17:5
|
||||
|
|
||||
LL | b += 1;
|
||||
| ^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
= note: `#[warn(unused_assignments)]` implied by `#[warn(unused)]`
|
||||
|
||||
warning: value assigned to `t` is never read
|
||||
--> $DIR/liveness-consts.rs:42:9
|
||||
|
|
||||
@ -53,11 +60,5 @@ warning: unused variable: `w`
|
||||
LL | let w = 10;
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_w`
|
||||
|
||||
warning: unused variable: `z`
|
||||
--> $DIR/liveness-consts.rs:60:13
|
||||
|
|
||||
LL | let z = 42;
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_z`
|
||||
|
||||
warning: 8 warnings emitted
|
||||
|
||||
|
@ -54,14 +54,6 @@ LL | ref mut a @ box ref b => {
|
||||
| |
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:54:11
|
||||
|
|
||||
LL | fn f5(ref mut a @ box ref b: Box<NC>) {
|
||||
| ^^^^^^^^^ ----- value is borrowed by `b` here
|
||||
| |
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error[E0382]: borrow of moved value
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:31:9
|
||||
|
|
||||
@ -120,6 +112,14 @@ LL | ref mut a @ box ref b => {
|
||||
LL | drop(b);
|
||||
| - immutable borrow later used here
|
||||
|
||||
error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:54:11
|
||||
|
|
||||
LL | fn f5(ref mut a @ box ref b: Box<NC>) {
|
||||
| ^^^^^^^^^ ----- value is borrowed by `b` here
|
||||
| |
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error[E0502]: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-at-and-box.rs:54:11
|
||||
|
|
||||
|
@ -286,78 +286,6 @@ help: borrow this binding in the pattern to avoid moving the value
|
||||
LL | ref mut a @ Some([ref b, ref mut c]) => {}
|
||||
| +++
|
||||
|
||||
error: borrow of moved value
|
||||
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:11:11
|
||||
|
|
||||
LL | fn f1(a @ ref b: U) {}
|
||||
| ^ ----- value borrowed here after move
|
||||
| |
|
||||
| value moved into `a` here
|
||||
| move occurs because `a` has type `U` which does not implement the `Copy` trait
|
||||
|
|
||||
help: borrow this binding in the pattern to avoid moving the value
|
||||
|
|
||||
LL | fn f1(ref a @ ref b: U) {}
|
||||
| +++
|
||||
|
||||
error: borrow of moved value
|
||||
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:11
|
||||
|
|
||||
LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {}
|
||||
| ^^^^^ ----- ----- value borrowed here after move
|
||||
| | |
|
||||
| | value borrowed here after move
|
||||
| value moved into `a` here
|
||||
| move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait
|
||||
|
|
||||
help: borrow this binding in the pattern to avoid moving the value
|
||||
|
|
||||
LL | fn f2(ref mut a @ (b @ ref c, mut d @ ref e): (U, U)) {}
|
||||
| +++
|
||||
|
||||
error: borrow of moved value
|
||||
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:20
|
||||
|
|
||||
LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {}
|
||||
| ^ ----- value borrowed here after move
|
||||
| |
|
||||
| value moved into `b` here
|
||||
| move occurs because `b` has type `U` which does not implement the `Copy` trait
|
||||
|
|
||||
help: borrow this binding in the pattern to avoid moving the value
|
||||
|
|
||||
LL | fn f2(mut a @ (ref b @ ref c, mut d @ ref e): (U, U)) {}
|
||||
| +++
|
||||
|
||||
error: borrow of moved value
|
||||
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:31
|
||||
|
|
||||
LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {}
|
||||
| ^^^^^ ----- value borrowed here after move
|
||||
| |
|
||||
| value moved into `d` here
|
||||
| move occurs because `d` has type `U` which does not implement the `Copy` trait
|
||||
|
|
||||
help: borrow this binding in the pattern to avoid moving the value
|
||||
|
|
||||
LL | fn f2(mut a @ (b @ ref c, ref mut d @ ref e): (U, U)) {}
|
||||
| +++
|
||||
|
||||
error: borrow of moved value
|
||||
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:19:11
|
||||
|
|
||||
LL | fn f3(a @ [ref mut b, ref c]: [U; 2]) {}
|
||||
| ^ --------- ----- value borrowed here after move
|
||||
| | |
|
||||
| | value borrowed here after move
|
||||
| value moved into `a` here
|
||||
| move occurs because `a` has type `[U; 2]` which does not implement the `Copy` trait
|
||||
|
|
||||
help: borrow this binding in the pattern to avoid moving the value
|
||||
|
|
||||
LL | fn f3(ref a @ [ref mut b, ref c]: [U; 2]) {}
|
||||
| +++
|
||||
|
||||
error[E0382]: use of partially moved value
|
||||
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:9
|
||||
|
|
||||
@ -447,6 +375,63 @@ LL | mut a @ Some([ref b, ref mut c]) => {}
|
||||
| |
|
||||
| value moved here
|
||||
|
||||
error: borrow of moved value
|
||||
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:11:11
|
||||
|
|
||||
LL | fn f1(a @ ref b: U) {}
|
||||
| ^ ----- value borrowed here after move
|
||||
| |
|
||||
| value moved into `a` here
|
||||
| move occurs because `a` has type `U` which does not implement the `Copy` trait
|
||||
|
|
||||
help: borrow this binding in the pattern to avoid moving the value
|
||||
|
|
||||
LL | fn f1(ref a @ ref b: U) {}
|
||||
| +++
|
||||
|
||||
error: borrow of moved value
|
||||
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:11
|
||||
|
|
||||
LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {}
|
||||
| ^^^^^ ----- ----- value borrowed here after move
|
||||
| | |
|
||||
| | value borrowed here after move
|
||||
| value moved into `a` here
|
||||
| move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait
|
||||
|
|
||||
help: borrow this binding in the pattern to avoid moving the value
|
||||
|
|
||||
LL | fn f2(ref mut a @ (b @ ref c, mut d @ ref e): (U, U)) {}
|
||||
| +++
|
||||
|
||||
error: borrow of moved value
|
||||
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:20
|
||||
|
|
||||
LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {}
|
||||
| ^ ----- value borrowed here after move
|
||||
| |
|
||||
| value moved into `b` here
|
||||
| move occurs because `b` has type `U` which does not implement the `Copy` trait
|
||||
|
|
||||
help: borrow this binding in the pattern to avoid moving the value
|
||||
|
|
||||
LL | fn f2(mut a @ (ref b @ ref c, mut d @ ref e): (U, U)) {}
|
||||
| +++
|
||||
|
||||
error: borrow of moved value
|
||||
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:31
|
||||
|
|
||||
LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {}
|
||||
| ^^^^^ ----- value borrowed here after move
|
||||
| |
|
||||
| value moved into `d` here
|
||||
| move occurs because `d` has type `U` which does not implement the `Copy` trait
|
||||
|
|
||||
help: borrow this binding in the pattern to avoid moving the value
|
||||
|
|
||||
LL | fn f2(mut a @ (b @ ref c, ref mut d @ ref e): (U, U)) {}
|
||||
| +++
|
||||
|
||||
error[E0382]: use of partially moved value
|
||||
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:11
|
||||
|
|
||||
@ -457,6 +442,21 @@ LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {}
|
||||
|
|
||||
= note: partial move occurs because value has type `U`, which does not implement the `Copy` trait
|
||||
|
||||
error: borrow of moved value
|
||||
--> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:19:11
|
||||
|
|
||||
LL | fn f3(a @ [ref mut b, ref c]: [U; 2]) {}
|
||||
| ^ --------- ----- value borrowed here after move
|
||||
| | |
|
||||
| | value borrowed here after move
|
||||
| value moved into `a` here
|
||||
| move occurs because `a` has type `[U; 2]` which does not implement the `Copy` trait
|
||||
|
|
||||
help: borrow this binding in the pattern to avoid moving the value
|
||||
|
|
||||
LL | fn f3(ref a @ [ref mut b, ref c]: [U; 2]) {}
|
||||
| +++
|
||||
|
||||
error: aborting due to 33 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0382`.
|
||||
|
@ -166,48 +166,6 @@ LL | ref mut a @ Some([b, mut c]) => {}
|
||||
| | value is moved into `b` here
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:11:11
|
||||
|
|
||||
LL | fn f1(ref a @ b: U) {}
|
||||
| ^^^^^ - value is moved into `b` here
|
||||
| |
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:14:11
|
||||
|
|
||||
LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {}
|
||||
| ^^^^^ ----- - value is moved into `e` here
|
||||
| | |
|
||||
| | value is moved into `c` here
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:14:20
|
||||
|
|
||||
LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {}
|
||||
| ^^^^^ ----- value is moved into `c` here
|
||||
| |
|
||||
| value is borrowed by `b` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:14:35
|
||||
|
|
||||
LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {}
|
||||
| ^^^^^ - value is moved into `e` here
|
||||
| |
|
||||
| value is borrowed by `d` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:20:11
|
||||
|
|
||||
LL | fn f3(ref mut a @ [b, mut c]: [U; 2]) {}
|
||||
| ^^^^^^^^^ - ----- value is moved into `c` here
|
||||
| | |
|
||||
| | value is moved into `b` here
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error[E0382]: borrow of partially moved value
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:30:9
|
||||
|
|
||||
@ -306,6 +264,14 @@ help: borrow this binding in the pattern to avoid moving the value
|
||||
LL | ref a @ Some((ref b @ mut c, ref d @ ref e)) => {}
|
||||
| +++
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:11:11
|
||||
|
|
||||
LL | fn f1(ref a @ b: U) {}
|
||||
| ^^^^^ - value is moved into `b` here
|
||||
| |
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error[E0382]: borrow of moved value
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:11:11
|
||||
|
|
||||
@ -315,6 +281,31 @@ LL | fn f1(ref a @ b: U) {}
|
||||
| value borrowed here after move
|
||||
| move occurs because value has type `U`, which does not implement the `Copy` trait
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:14:11
|
||||
|
|
||||
LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {}
|
||||
| ^^^^^ ----- - value is moved into `e` here
|
||||
| | |
|
||||
| | value is moved into `c` here
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:14:20
|
||||
|
|
||||
LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {}
|
||||
| ^^^^^ ----- value is moved into `c` here
|
||||
| |
|
||||
| value is borrowed by `b` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:14:35
|
||||
|
|
||||
LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {}
|
||||
| ^^^^^ - value is moved into `e` here
|
||||
| |
|
||||
| value is borrowed by `d` here
|
||||
|
||||
error[E0382]: borrow of moved value
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:14:20
|
||||
|
|
||||
@ -335,6 +326,15 @@ LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {}
|
||||
|
|
||||
= note: move occurs because value has type `U`, which does not implement the `Copy` trait
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:20:11
|
||||
|
|
||||
LL | fn f3(ref mut a @ [b, mut c]: [U; 2]) {}
|
||||
| ^^^^^^^^^ - ----- value is moved into `c` here
|
||||
| | |
|
||||
| | value is moved into `b` here
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error[E0382]: borrow of partially moved value
|
||||
--> $DIR/borrowck-pat-by-move-and-ref.rs:20:11
|
||||
|
|
||||
|
@ -221,47 +221,6 @@ LL | let ref mut a @ (ref b, ref c) = (U, U);
|
||||
| | value is borrowed by `b` here
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:22:11
|
||||
|
|
||||
LL | fn f1(ref a @ ref mut b: U) {}
|
||||
| ^^^^^ --------- value is mutably borrowed by `b` here
|
||||
| |
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:24:11
|
||||
|
|
||||
LL | fn f2(ref mut a @ ref b: U) {}
|
||||
| ^^^^^^^^^ ----- value is borrowed by `b` here
|
||||
| |
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:26:11
|
||||
|
|
||||
LL | fn f3(ref a @ [ref b, ref mut mid @ .., ref c]: [U; 4]) {}
|
||||
| ^^^^^ ----------- value is mutably borrowed by `mid` here
|
||||
| |
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:28:22
|
||||
|
|
||||
LL | fn f4_also_moved(ref a @ ref mut b @ c: U) {}
|
||||
| ^^^^^ --------- - value is moved into `c` here
|
||||
| | |
|
||||
| | value is mutably borrowed by `b` here
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:28:30
|
||||
|
|
||||
LL | fn f4_also_moved(ref a @ ref mut b @ c: U) {}
|
||||
| ^^^^^^^^^ - value is moved into `c` here
|
||||
| |
|
||||
| value is mutably borrowed by `b` here
|
||||
|
||||
error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:8:31
|
||||
|
|
||||
@ -398,6 +357,47 @@ LL |
|
||||
LL | *b = U;
|
||||
| ------ mutable borrow later used here
|
||||
|
||||
error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:22:11
|
||||
|
|
||||
LL | fn f1(ref a @ ref mut b: U) {}
|
||||
| ^^^^^ --------- value is mutably borrowed by `b` here
|
||||
| |
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as immutable because it is also borrowed as mutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:24:11
|
||||
|
|
||||
LL | fn f2(ref mut a @ ref b: U) {}
|
||||
| ^^^^^^^^^ ----- value is borrowed by `b` here
|
||||
| |
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:26:11
|
||||
|
|
||||
LL | fn f3(ref a @ [ref b, ref mut mid @ .., ref c]: [U; 4]) {}
|
||||
| ^^^^^ ----------- value is mutably borrowed by `mid` here
|
||||
| |
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as mutable because it is also borrowed as immutable
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:28:22
|
||||
|
|
||||
LL | fn f4_also_moved(ref a @ ref mut b @ c: U) {}
|
||||
| ^^^^^ --------- - value is moved into `c` here
|
||||
| | |
|
||||
| | value is mutably borrowed by `b` here
|
||||
| value is borrowed by `a` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:28:30
|
||||
|
|
||||
LL | fn f4_also_moved(ref a @ ref mut b @ c: U) {}
|
||||
| ^^^^^^^^^ - value is moved into `c` here
|
||||
| |
|
||||
| value is mutably borrowed by `b` here
|
||||
|
||||
error[E0382]: borrow of moved value
|
||||
--> $DIR/borrowck-pat-ref-mut-and-ref.rs:28:30
|
||||
|
|
||||
|
@ -194,50 +194,6 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
||||
| |
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:8:11
|
||||
|
|
||||
LL | fn f1(ref mut a @ ref mut b: U) {}
|
||||
| ^^^^^^^^^ --------- value is mutably borrowed by `b` here
|
||||
| |
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:10:11
|
||||
|
|
||||
LL | fn f2(ref mut a @ ref mut b: U) {}
|
||||
| ^^^^^^^^^ --------- value is mutably borrowed by `b` here
|
||||
| |
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:13:9
|
||||
|
|
||||
LL | ref mut a @ [
|
||||
| ^^^^^^^^^ value is mutably borrowed by `a` here
|
||||
LL |
|
||||
LL | [ref b @ .., _],
|
||||
| ----- value is borrowed by `b` here
|
||||
LL | [_, ref mut mid @ ..],
|
||||
| ----------- value is mutably borrowed by `mid` here
|
||||
|
||||
error: cannot borrow value as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:21:22
|
||||
|
|
||||
LL | fn f4_also_moved(ref mut a @ ref mut b @ c: U) {}
|
||||
| ^^^^^^^^^ --------- - value is moved into `c` here
|
||||
| | |
|
||||
| | value is mutably borrowed by `b` here
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:21:34
|
||||
|
|
||||
LL | fn f4_also_moved(ref mut a @ ref mut b @ c: U) {}
|
||||
| ^^^^^^^^^ - value is moved into `c` here
|
||||
| |
|
||||
| value is mutably borrowed by `b` here
|
||||
|
||||
error[E0499]: cannot borrow value as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:29:9
|
||||
|
|
||||
@ -304,6 +260,50 @@ LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
|
||||
LL | drop(a);
|
||||
| - first borrow later used here
|
||||
|
||||
error: cannot borrow value as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:8:11
|
||||
|
|
||||
LL | fn f1(ref mut a @ ref mut b: U) {}
|
||||
| ^^^^^^^^^ --------- value is mutably borrowed by `b` here
|
||||
| |
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:10:11
|
||||
|
|
||||
LL | fn f2(ref mut a @ ref mut b: U) {}
|
||||
| ^^^^^^^^^ --------- value is mutably borrowed by `b` here
|
||||
| |
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error: cannot borrow value as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:13:9
|
||||
|
|
||||
LL | ref mut a @ [
|
||||
| ^^^^^^^^^ value is mutably borrowed by `a` here
|
||||
LL |
|
||||
LL | [ref b @ .., _],
|
||||
| ----- value is borrowed by `b` here
|
||||
LL | [_, ref mut mid @ ..],
|
||||
| ----------- value is mutably borrowed by `mid` here
|
||||
|
||||
error: cannot borrow value as mutable more than once at a time
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:21:22
|
||||
|
|
||||
LL | fn f4_also_moved(ref mut a @ ref mut b @ c: U) {}
|
||||
| ^^^^^^^^^ --------- - value is moved into `c` here
|
||||
| | |
|
||||
| | value is mutably borrowed by `b` here
|
||||
| value is mutably borrowed by `a` here
|
||||
|
||||
error: cannot move out of value because it is borrowed
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:21:34
|
||||
|
|
||||
LL | fn f4_also_moved(ref mut a @ ref mut b @ c: U) {}
|
||||
| ^^^^^^^^^ - value is moved into `c` here
|
||||
| |
|
||||
| value is mutably borrowed by `b` here
|
||||
|
||||
error[E0382]: borrow of moved value
|
||||
--> $DIR/borrowck-pat-ref-mut-twice.rs:21:34
|
||||
|
|
||||
|
@ -10,6 +10,12 @@ note: the lint level is defined here
|
||||
LL | #![deny(unused_variables)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unused variable: `a`
|
||||
--> $DIR/param-attrs-cfg.rs:41:27
|
||||
|
|
||||
LL | #[cfg(something)] a: i32,
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
||||
|
||||
error: unused variable: `b`
|
||||
--> $DIR/param-attrs-cfg.rs:30:23
|
||||
|
|
||||
@ -22,12 +28,6 @@ error: unused variable: `c`
|
||||
LL | #[cfg_attr(nothing, cfg(nothing))] c: i32,
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_c`
|
||||
|
||||
error: unused variable: `a`
|
||||
--> $DIR/param-attrs-cfg.rs:41:27
|
||||
|
|
||||
LL | #[cfg(something)] a: i32,
|
||||
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
||||
|
||||
error: unused variable: `b`
|
||||
--> $DIR/param-attrs-cfg.rs:48:27
|
||||
|
|
||||
|
Loading…
Reference in New Issue
Block a user