Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -2832,6 +2832,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
trait_predicate: ty::PolyTraitPredicate<'tcx>,
root_obligation: &PredicateObligation<'tcx>,
) -> (PredicateObligation<'tcx>, ty::PolyTraitPredicate<'tcx>) {
if obligation.predicate.has_non_region_param() || obligation.has_non_region_infer() {
return (obligation.clone(), trait_predicate);
}

let ocx = ObligationCtxt::new(self);
let normalized_predicate = self.tcx.erase_and_anonymize_regions(
self.tcx.instantiate_bound_regions_with_erased(trait_predicate),
Expand Down
11 changes: 11 additions & 0 deletions tests/ui/transmutability/generic-transmute-from-regression.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//! Regression test for: <https://github.com/rust-lang/rust/issues/153755>
#![feature(transmutability)]

fn foo<T, U>(x: T) -> U {
unsafe {
std::mem::TransmuteFrom::transmute(x)
//~^ ERROR: the trait bound `U: TransmuteFrom<T, _>` is not satisfied [E0277]
}
}

fn main() {}
11 changes: 11 additions & 0 deletions tests/ui/transmutability/generic-transmute-from-regression.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error[E0277]: the trait bound `U: TransmuteFrom<T, _>` is not satisfied
--> $DIR/generic-transmute-from-regression.rs:6:44
|
LL | std::mem::TransmuteFrom::transmute(x)
| ---------------------------------- ^ the nightly-only, unstable trait `TransmuteFrom<T, _>` is not implemented for `U`
| |
| required by a bound introduced by this call

error: aborting due to 1 previous error

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