Reword the short diagnostic for E0509
Saying that a type *implements* a trait is much more idiomatic than saying it *defines* the trait.
This commit is contained in:
parent
0c5d651d0b
commit
e575d19acc
6 changed files with 13 additions and 11 deletions
|
@ -152,7 +152,7 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||||
ty::TyEnum(def, _) if def.has_dtor() => {
|
ty::TyEnum(def, _) if def.has_dtor() => {
|
||||||
let mut err = struct_span_err!(bccx, move_from.span, E0509,
|
let mut err = struct_span_err!(bccx, move_from.span, E0509,
|
||||||
"cannot move out of type `{}`, \
|
"cannot move out of type `{}`, \
|
||||||
which defines the `Drop` trait",
|
which implements the `Drop` trait",
|
||||||
b.ty);
|
b.ty);
|
||||||
err.span_label(move_from.span, &format!("cannot move out of here"));
|
err.span_label(move_from.span, &format!("cannot move out of here"));
|
||||||
err
|
err
|
||||||
|
|
|
@ -37,7 +37,7 @@ impl Drop for S {
|
||||||
|
|
||||||
fn move_in_match() {
|
fn move_in_match() {
|
||||||
match (S {f: "foo".to_string(), g: "bar".to_string()}) {
|
match (S {f: "foo".to_string(), g: "bar".to_string()}) {
|
||||||
S { //~ ERROR cannot move out of type `S`, which defines the `Drop` trait
|
S { //~ ERROR cannot move out of type `S`, which implements the `Drop` trait
|
||||||
//~| cannot move out of here
|
//~| cannot move out of here
|
||||||
f: _s, //~ NOTE to prevent move
|
f: _s, //~ NOTE to prevent move
|
||||||
g: _t //~ NOTE and here
|
g: _t //~ NOTE and here
|
||||||
|
|
|
@ -16,17 +16,17 @@ impl Drop for S {
|
||||||
fn move_in_match() {
|
fn move_in_match() {
|
||||||
match (S {f:"foo".to_string()}) {
|
match (S {f:"foo".to_string()}) {
|
||||||
S {f:_s} => {}
|
S {f:_s} => {}
|
||||||
//~^ ERROR cannot move out of type `S`, which defines the `Drop` trait
|
//~^ ERROR cannot move out of type `S`, which implements the `Drop` trait
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn move_in_let() {
|
fn move_in_let() {
|
||||||
let S {f:_s} = S {f:"foo".to_string()};
|
let S {f:_s} = S {f:"foo".to_string()};
|
||||||
//~^ ERROR cannot move out of type `S`, which defines the `Drop` trait
|
//~^ ERROR cannot move out of type `S`, which implements the `Drop` trait
|
||||||
}
|
}
|
||||||
|
|
||||||
fn move_in_fn_arg(S {f:_s}: S) {
|
fn move_in_fn_arg(S {f:_s}: S) {
|
||||||
//~^ ERROR cannot move out of type `S`, which defines the `Drop` trait
|
//~^ ERROR cannot move out of type `S`, which implements the `Drop` trait
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -16,17 +16,17 @@ impl Drop for S {
|
||||||
fn move_in_match() {
|
fn move_in_match() {
|
||||||
match S("foo".to_string()) {
|
match S("foo".to_string()) {
|
||||||
S(_s) => {}
|
S(_s) => {}
|
||||||
//~^ ERROR cannot move out of type `S`, which defines the `Drop` trait
|
//~^ ERROR cannot move out of type `S`, which implements the `Drop` trait
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn move_in_let() {
|
fn move_in_let() {
|
||||||
let S(_s) = S("foo".to_string());
|
let S(_s) = S("foo".to_string());
|
||||||
//~^ ERROR cannot move out of type `S`, which defines the `Drop` trait
|
//~^ ERROR cannot move out of type `S`, which implements the `Drop` trait
|
||||||
}
|
}
|
||||||
|
|
||||||
fn move_in_fn_arg(S(_s): S) {
|
fn move_in_fn_arg(S(_s): S) {
|
||||||
//~^ ERROR cannot move out of type `S`, which defines the `Drop` trait
|
//~^ ERROR cannot move out of type `S`, which implements the `Drop` trait
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -19,11 +19,13 @@ struct T { a: isize, mv: Box<isize> }
|
||||||
impl Drop for T { fn drop(&mut self) { } }
|
impl Drop for T { fn drop(&mut self) { } }
|
||||||
|
|
||||||
fn f(s0:S) {
|
fn f(s0:S) {
|
||||||
let _s2 = S{a: 2, ..s0}; //~error: cannot move out of type `S`, which defines the `Drop` trait
|
let _s2 = S{a: 2, ..s0};
|
||||||
|
//~^ error: cannot move out of type `S`, which implements the `Drop` trait
|
||||||
}
|
}
|
||||||
|
|
||||||
fn g(s0:T) {
|
fn g(s0:T) {
|
||||||
let _s2 = T{a: 2, ..s0}; //~error: cannot move out of type `T`, which defines the `Drop` trait
|
let _s2 = T{a: 2, ..s0};
|
||||||
|
//~^ error: cannot move out of type `T`, which implements the `Drop` trait
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() { }
|
fn main() { }
|
||||||
|
|
|
@ -23,6 +23,6 @@ fn main() {
|
||||||
|
|
||||||
match x {
|
match x {
|
||||||
X { x: y } => println!("contents: {}", y)
|
X { x: y } => println!("contents: {}", y)
|
||||||
//~^ ERROR cannot move out of type `X`, which defines the `Drop` trait
|
//~^ ERROR cannot move out of type `X`, which implements the `Drop` trait
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue