Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion compiler/rustc_middle/src/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1630,6 +1630,9 @@ impl<'tcx> Ty<'tcx> {
TyKind::Coroutine(def_id, args) => {
Some(args.as_coroutine().variant_range(*def_id, tcx))
}
TyKind::UnsafeBinder(bound_ty) => {
tcx.instantiate_bound_regions_with_erased((*bound_ty).into()).variant_range(tcx)
}
_ => None,
}
}
Expand All @@ -1651,6 +1654,9 @@ impl<'tcx> Ty<'tcx> {
TyKind::Coroutine(def_id, args) => {
Some(args.as_coroutine().discriminant_for_variant(*def_id, tcx, variant_index))
}
TyKind::UnsafeBinder(bound_ty) => tcx
.instantiate_bound_regions_with_erased((*bound_ty).into())
.discriminant_for_variant(tcx, variant_index),
_ => None,
}
}
Expand All @@ -1669,6 +1675,9 @@ impl<'tcx> Ty<'tcx> {
}

ty::Pat(ty, _) => ty.discriminant_ty(tcx),
ty::UnsafeBinder(bound_ty) => {
tcx.instantiate_bound_regions_with_erased((*bound_ty).into()).discriminant_ty(tcx)
}

ty::Bool
| ty::Char
Expand All @@ -1690,7 +1699,6 @@ impl<'tcx> Ty<'tcx> {
| ty::CoroutineWitness(..)
| ty::Never
| ty::Tuple(_)
| ty::UnsafeBinder(_)
| ty::Error(_)
| ty::Infer(IntVar(_) | FloatVar(_)) => tcx.types.u8,

Expand Down
11 changes: 11 additions & 0 deletions tests/ui/unsafe-binders/discriminant-for-variant.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#![feature(unsafe_binders)]

const None: Option<unsafe<> Option<Box<dyn Send>>> = None;
//~^ ERROR the trait bound `Box<(dyn Send + 'static)>: Copy` is not satisfied
//~| ERROR the trait bound `Box<(dyn Send + 'static)>: Copy` is not satisfied

fn main() {
match None {
_ => {}
}
}
19 changes: 19 additions & 0 deletions tests/ui/unsafe-binders/discriminant-for-variant.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0277]: the trait bound `Box<(dyn Send + 'static)>: Copy` is not satisfied
--> $DIR/discriminant-for-variant.rs:3:13
|
LL | const None: Option<unsafe<> Option<Box<dyn Send>>> = None;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `Box<(dyn Send + 'static)>`
|
= note: required for `Option<Box<(dyn Send + 'static)>>` to implement `Copy`

error[E0277]: the trait bound `Box<(dyn Send + 'static)>: Copy` is not satisfied
--> $DIR/discriminant-for-variant.rs:3:54
|
LL | const None: Option<unsafe<> Option<Box<dyn Send>>> = None;
| ^^^^ the trait `Copy` is not implemented for `Box<(dyn Send + 'static)>`
|
= note: required for `Option<Box<(dyn Send + 'static)>>` to implement `Copy`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.
Loading