mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 06:51:58 +00:00
feedback
This commit is contained in:
parent
f980f813e1
commit
62acf7f96d
@ -371,14 +371,12 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b
|
|||||||
let param_env = tcx.param_env(item_def_id);
|
let param_env = tcx.param_env(item_def_id);
|
||||||
for field in fields {
|
for field in fields {
|
||||||
let field_ty = field.ty(tcx, substs);
|
let field_ty = field.ty(tcx, substs);
|
||||||
let (field_span, ty_span) =
|
|
||||||
// We are currently checking the type this field came from, so it must be local.
|
|
||||||
if let Node::Field(field) = tcx.hir().get_if_local(field.did).unwrap() {
|
|
||||||
(field.span, field.ty.span)
|
|
||||||
} else {
|
|
||||||
unreachable!("mir field has to correspond to hir field");
|
|
||||||
};
|
|
||||||
if field_ty.needs_drop(tcx, param_env) {
|
if field_ty.needs_drop(tcx, param_env) {
|
||||||
|
let (field_span, ty_span) = match tcx.hir().get_if_local(field.did) {
|
||||||
|
// We are currently checking the type this field came from, so it must be local.
|
||||||
|
Some(Node::Field(field)) => (field.span, field.ty.span),
|
||||||
|
_ => unreachable!("mir field has to correspond to hir field"),
|
||||||
|
};
|
||||||
struct_span_err!(
|
struct_span_err!(
|
||||||
tcx.sess,
|
tcx.sess,
|
||||||
field_span,
|
field_span,
|
||||||
@ -387,7 +385,10 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b
|
|||||||
)
|
)
|
||||||
.multipart_suggestion_verbose(
|
.multipart_suggestion_verbose(
|
||||||
"wrap the type with `std::mem::ManuallyDrop` and ensure it is manually dropped",
|
"wrap the type with `std::mem::ManuallyDrop` and ensure it is manually dropped",
|
||||||
vec![(ty_span, format!("std::mem::ManuallyDrop<{}>", field_ty))],
|
vec![
|
||||||
|
(ty_span.shrink_to_lo(), format!("std::mem::ManuallyDrop<")),
|
||||||
|
(ty_span.shrink_to_hi(), ">".into()),
|
||||||
|
],
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
|
@ -16,7 +16,7 @@ LL | a: String,
|
|||||||
help: wrap the type with `std::mem::ManuallyDrop` and ensure it is manually dropped
|
help: wrap the type with `std::mem::ManuallyDrop` and ensure it is manually dropped
|
||||||
|
|
|
|
||||||
LL | a: std::mem::ManuallyDrop<String>,
|
LL | a: std::mem::ManuallyDrop<String>,
|
||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| +++++++++++++++++++++++ +
|
||||||
|
|
||||||
error[E0740]: unions may not contain fields that need dropping
|
error[E0740]: unions may not contain fields that need dropping
|
||||||
--> $DIR/feature-gate-untagged_unions.rs:24:5
|
--> $DIR/feature-gate-untagged_unions.rs:24:5
|
||||||
@ -27,7 +27,7 @@ LL | a: T,
|
|||||||
help: wrap the type with `std::mem::ManuallyDrop` and ensure it is manually dropped
|
help: wrap the type with `std::mem::ManuallyDrop` and ensure it is manually dropped
|
||||||
|
|
|
|
||||||
LL | a: std::mem::ManuallyDrop<T>,
|
LL | a: std::mem::ManuallyDrop<T>,
|
||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~
|
| +++++++++++++++++++++++ +
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ LL | a: A,
|
|||||||
help: wrap the type with `std::mem::ManuallyDrop` and ensure it is manually dropped
|
help: wrap the type with `std::mem::ManuallyDrop` and ensure it is manually dropped
|
||||||
|
|
|
|
||||||
LL | a: std::mem::ManuallyDrop<A>,
|
LL | a: std::mem::ManuallyDrop<A>,
|
||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~
|
| +++++++++++++++++++++++ +
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ LL | bar: Bar,
|
|||||||
help: wrap the type with `std::mem::ManuallyDrop` and ensure it is manually dropped
|
help: wrap the type with `std::mem::ManuallyDrop` and ensure it is manually dropped
|
||||||
|
|
|
|
||||||
LL | bar: std::mem::ManuallyDrop<Bar>,
|
LL | bar: std::mem::ManuallyDrop<Bar>,
|
||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| +++++++++++++++++++++++ +
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ LL | a: String,
|
|||||||
help: wrap the type with `std::mem::ManuallyDrop` and ensure it is manually dropped
|
help: wrap the type with `std::mem::ManuallyDrop` and ensure it is manually dropped
|
||||||
|
|
|
|
||||||
LL | a: std::mem::ManuallyDrop<String>,
|
LL | a: std::mem::ManuallyDrop<String>,
|
||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| +++++++++++++++++++++++ +
|
||||||
|
|
||||||
error[E0740]: unions may not contain fields that need dropping
|
error[E0740]: unions may not contain fields that need dropping
|
||||||
--> $DIR/union-with-drop-fields.rs:19:5
|
--> $DIR/union-with-drop-fields.rs:19:5
|
||||||
@ -18,7 +18,7 @@ LL | a: S,
|
|||||||
help: wrap the type with `std::mem::ManuallyDrop` and ensure it is manually dropped
|
help: wrap the type with `std::mem::ManuallyDrop` and ensure it is manually dropped
|
||||||
|
|
|
|
||||||
LL | a: std::mem::ManuallyDrop<S>,
|
LL | a: std::mem::ManuallyDrop<S>,
|
||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~
|
| +++++++++++++++++++++++ +
|
||||||
|
|
||||||
error[E0740]: unions may not contain fields that need dropping
|
error[E0740]: unions may not contain fields that need dropping
|
||||||
--> $DIR/union-with-drop-fields.rs:24:5
|
--> $DIR/union-with-drop-fields.rs:24:5
|
||||||
@ -29,7 +29,7 @@ LL | a: T,
|
|||||||
help: wrap the type with `std::mem::ManuallyDrop` and ensure it is manually dropped
|
help: wrap the type with `std::mem::ManuallyDrop` and ensure it is manually dropped
|
||||||
|
|
|
|
||||||
LL | a: std::mem::ManuallyDrop<T>,
|
LL | a: std::mem::ManuallyDrop<T>,
|
||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~
|
| +++++++++++++++++++++++ +
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ LL | a: String,
|
|||||||
help: wrap the type with `std::mem::ManuallyDrop` and ensure it is manually dropped
|
help: wrap the type with `std::mem::ManuallyDrop` and ensure it is manually dropped
|
||||||
|
|
|
|
||||||
LL | a: std::mem::ManuallyDrop<String>,
|
LL | a: std::mem::ManuallyDrop<String>,
|
||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| +++++++++++++++++++++++ +
|
||||||
|
|
||||||
error[E0740]: unions may not contain fields that need dropping
|
error[E0740]: unions may not contain fields that need dropping
|
||||||
--> $DIR/union-with-drop-fields.rs:19:5
|
--> $DIR/union-with-drop-fields.rs:19:5
|
||||||
@ -18,7 +18,7 @@ LL | a: S,
|
|||||||
help: wrap the type with `std::mem::ManuallyDrop` and ensure it is manually dropped
|
help: wrap the type with `std::mem::ManuallyDrop` and ensure it is manually dropped
|
||||||
|
|
|
|
||||||
LL | a: std::mem::ManuallyDrop<S>,
|
LL | a: std::mem::ManuallyDrop<S>,
|
||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~
|
| +++++++++++++++++++++++ +
|
||||||
|
|
||||||
error[E0740]: unions may not contain fields that need dropping
|
error[E0740]: unions may not contain fields that need dropping
|
||||||
--> $DIR/union-with-drop-fields.rs:24:5
|
--> $DIR/union-with-drop-fields.rs:24:5
|
||||||
@ -29,7 +29,7 @@ LL | a: T,
|
|||||||
help: wrap the type with `std::mem::ManuallyDrop` and ensure it is manually dropped
|
help: wrap the type with `std::mem::ManuallyDrop` and ensure it is manually dropped
|
||||||
|
|
|
|
||||||
LL | a: std::mem::ManuallyDrop<T>,
|
LL | a: std::mem::ManuallyDrop<T>,
|
||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~
|
| +++++++++++++++++++++++ +
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user