about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-04-19 06:35:36 +0200
committerGitHub <noreply@github.com>2023-04-19 06:35:36 +0200
commitfdd2f4bde8452e806288f7aa8d42f10bdb4369c0 (patch)
tree76f08e259118127d7e086e94bfdfa65f410d6ccf
parente85b0267a47e136ac77c827f82d2277125fae426 (diff)
parent238756e45d88a603c143b89f7408717516a03e03 (diff)
downloadrust-fdd2f4bde8452e806288f7aa8d42f10bdb4369c0.tar.gz
rust-fdd2f4bde8452e806288f7aa8d42f10bdb4369c0.zip
Rollup merge of #110510 - bryangarza:issue-110467-safe-transmute, r=compiler-errors
Fix ICE for transmutability in candidate assembly

Don't skip transmutability check just because there may be generics in the ParamEnv.

Fixes #110467
-rw-r--r--compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs2
-rw-r--r--tests/ui/transmutability/issue-110467.rs17
2 files changed, 18 insertions, 1 deletions
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 1f5bbc178f7..a019d00461b 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 00000000000..358733b9832
--- /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<Src, Dst>()
+where
+    Dst: BikeshedIntrinsicFrom<Src, Context>,
+{
+}
+
+// The `T` here should not have any effect on checking
+// if transmutability is allowed or not.
+fn function_with_generic<T>() {
+    is_maybe_transmutable::<(), ()>();
+}