tcx.sess,
field_span,
E0740,
- "unions may not contain fields that need dropping"
+ "unions cannot contain fields that may need dropping"
+ )
+ .note(
+ "a type is guaranteed not to need dropping \
+ when it implements `Copy`, or when it is the special `ManuallyDrop<_>` type",
)
.multipart_suggestion_verbose(
- "wrap the type with `std::mem::ManuallyDrop` and ensure it is manually dropped",
+ "when the type does not implement `Copy`, \
+ wrap it inside a `ManuallyDrop<_>` and ensure it is manually dropped",
vec![
- (ty_span.shrink_to_lo(), format!("std::mem::ManuallyDrop<")),
+ (ty_span.shrink_to_lo(), "std::mem::ManuallyDrop<".into()),
(ty_span.shrink_to_hi(), ">".into()),
],
Applicability::MaybeIncorrect,
}
}
- if let ItemKind::OpaqueTy(hir::OpaqueTy { origin: hir::OpaqueTyOrigin::FnReturn(..), .. }) =
- item.kind
+ if let ItemKind::OpaqueTy(hir::OpaqueTy {
+ origin: hir::OpaqueTyOrigin::AsyncFn(..) | hir::OpaqueTyOrigin::FnReturn(..),
+ ..
+ }) = item.kind
{
let mut visitor = ProhibitOpaqueVisitor {
opaque_identity_ty: tcx.mk_opaque(
if let Some(ty) = prohibit_opaque.break_value() {
visitor.visit_item(&item);
+ let is_async = match item.kind {
+ ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) => {
+ matches!(origin, hir::OpaqueTyOrigin::AsyncFn(..))
+ }
+ _ => unreachable!(),
+ };
let mut err = struct_span_err!(
tcx.sess,
span,
E0760,
- "`impl Trait` return type cannot contain a projection or `Self` that references lifetimes from \
+ "`{}` return type cannot contain a projection or `Self` that references lifetimes from \
a parent scope",
+ if is_async { "async fn" } else { "impl Trait" },
);
for (span, name) in visitor.selftys {