From 238756e45d88a603c143b89f7408717516a03e03 Mon Sep 17 00:00:00 2001 From: Bryan Garza <1396101+bryangarza@users.noreply.github.com> Date: Tue, 18 Apr 2023 16:31:05 -0700 Subject: [PATCH] Fix ICE for transmutability in candidate assembly Don't skip transmutability check just because there may be generics in the ParamEnv. Fixes #110467 --- .../src/traits/select/candidate_assembly.rs | 2 +- tests/ui/transmutability/issue-110467.rs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/ui/transmutability/issue-110467.rs diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs index 1f5bbc178f7d7..a019d00461be1 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -775,7 +775,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { obligation: &TraitObligation<'tcx>, candidates: &mut SelectionCandidateSet<'tcx>, ) { - if obligation.has_non_region_param() { + if obligation.predicate.has_non_region_param() { return; } diff --git a/tests/ui/transmutability/issue-110467.rs b/tests/ui/transmutability/issue-110467.rs new file mode 100644 index 0000000000000..358733b9832c2 --- /dev/null +++ b/tests/ui/transmutability/issue-110467.rs @@ -0,0 +1,17 @@ +// check-pass +#![crate_type = "lib"] +#![feature(transmutability)] +use std::mem::BikeshedIntrinsicFrom; +pub struct Context; + +pub fn is_maybe_transmutable() +where + Dst: BikeshedIntrinsicFrom, +{ +} + +// The `T` here should not have any effect on checking +// if transmutability is allowed or not. +fn function_with_generic() { + is_maybe_transmutable::<(), ()>(); +}