-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not ICE when dereferencing non-Copy raw pointer
- Loading branch information
Showing
3 changed files
with
41 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// compile-flags:-Ztreat-err-as-bug=5 | ||
#[derive(Debug)] | ||
enum MyError { | ||
NotFound { key: Vec<u8> }, | ||
Err41, | ||
} | ||
|
||
impl std::error::Error for MyError {} | ||
|
||
impl std::fmt::Display for MyError { | ||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
match self { | ||
MyError::NotFound { key } => write!( | ||
f, | ||
"unknown error with code {}.", | ||
String::from_utf8(*key).unwrap() | ||
//~^ ERROR cannot move out of `*key` which is behind a shared reference | ||
), | ||
MyError::Err41 => write!(f, "Sit by a lake"), | ||
} | ||
} | ||
} | ||
fn main() { | ||
println!("Hello, world!"); | ||
} |
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,9 @@ | ||
error[E0507]: cannot move out of `*key` which is behind a shared reference | ||
--> $DIR/issue-52262.rs:16:35 | ||
| | ||
LL | String::from_utf8(*key).unwrap() | ||
| ^^^^ move occurs because `*key` has type `std::vec::Vec<u8>`, which does not implement the `Copy` trait | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0507`. |