-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #47124 - estebank:loan-paths, r=nikomatsakis
Reword reason for move note On move errors, when encountering an enum variant, be more ambiguous and do not refer to the type on the cause note, to avoid referring to `(maybe as std::prelude::v1::Some).0`, and instead refer to `the value`. Sidesteps part of the problem with #41962: ``` error[E0382]: use of partially moved value: `maybe` --> file.rs:5:30 | 5 | if let Some(thing) = maybe { | ----- ^^^^^ value used here after move | | | value moved here = note: move occurs because the value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait error[E0382]: use of moved value: `(maybe as std::prelude::v1::Some).0` --> file.rs:5:21 | 5 | if let Some(thing) = maybe { | ^^^^^ value moved here in previous iteration of loop = note: move occurs because the value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait error: aborting due to 2 previous errors ``` Previous discussion: #44360 r? @arielb1
- Loading branch information
Showing
6 changed files
with
104 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// 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: -Z borrowck=compare | ||
|
||
pub fn main(){ | ||
let maybe = Some(vec![true, true]); | ||
|
||
loop { | ||
if let Some(thing) = maybe { | ||
//~^ ERROR use of partially moved value: `maybe` (Ast) [E0382] | ||
//~| ERROR use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast) [E0382] | ||
//~| ERROR use of moved value: `maybe` (Mir) [E0382] | ||
//~| ERROR use of moved value: `maybe.0` (Mir) [E0382] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
error[E0382]: use of partially moved value: `maybe` (Ast) | ||
--> $DIR/issue-41962.rs:17:30 | ||
| | ||
17 | if let Some(thing) = maybe { | ||
| ----- ^^^^^ value used here after move | ||
| | | ||
| value moved here | ||
| | ||
= note: move occurs because the value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait | ||
|
||
error[E0382]: use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast) | ||
--> $DIR/issue-41962.rs:17:21 | ||
| | ||
17 | if let Some(thing) = maybe { | ||
| ^^^^^ value moved here in previous iteration of loop | ||
| | ||
= note: move occurs because the value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait | ||
|
||
error[E0382]: use of moved value: `maybe` (Mir) | ||
--> $DIR/issue-41962.rs:17:16 | ||
| | ||
17 | if let Some(thing) = maybe { | ||
| ^^^^^-----^ | ||
| | | | ||
| | value moved here | ||
| value used here after move | ||
| | ||
= note: move occurs because `maybe` has type `std::option::Option<std::vec::Vec<bool>>`, which does not implement the `Copy` trait | ||
|
||
error[E0382]: use of moved value: `maybe.0` (Mir) | ||
--> $DIR/issue-41962.rs:17:21 | ||
| | ||
17 | if let Some(thing) = maybe { | ||
| ^^^^^ value moved here in previous iteration of loop | ||
| | ||
= note: move occurs because `maybe.0` has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait | ||
|
||
error: aborting due to 4 previous errors | ||
|