about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-08-13 00:05:53 +0000
committerbors <bors@rust-lang.org>2023-08-13 00:05:53 +0000
commit49af618ef94182deafa1d7ee4f2f539869d1d2f2 (patch)
treec0c3cae913d7fe33d2dea9ca6f1d965630575c37
parent28eb857b9504bd05bbed0cf8af8e825fbdbb1fa1 (diff)
parentbb76fde73482efa3f2bba1e8bc0d35ad962f83dd (diff)
downloadrust-49af618ef94182deafa1d7ee4f2f539869d1d2f2.tar.gz
rust-49af618ef94182deafa1d7ee4f2f539869d1d2f2.zip
Auto merge of #114739 - lcnr:int-infer-impls, r=compiler-errors
remove builtin `Copy` and `Clone` impl for float and int infer

it's only change is whether `{integer}: Copy` is ambiguous, this has the following properties

- these goals get proven earlier, potentially resulting in slightly better perf
- it causes inconsistent behavior and ICE if there do not exist impls for all integers, causing issues when using `#[no_core]`
- it means `Clone` has user-facing differences from other traits from `core` with the new solver because it can potentially guide inference there
- it's just very sus™ to have a builtin impl which applies during type inference but not afterwards
-rw-r--r--compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs6
-rw-r--r--compiler/rustc_trait_selection/src/traits/select/mod.rs7
2 files changed, 4 insertions, 9 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs b/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs
index b882ec254e3..c47767101a4 100644
--- a/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs
+++ b/compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs
@@ -161,14 +161,12 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_copy_clone_trait<'tcx>(
     ty: Ty<'tcx>,
 ) -> Result<Vec<Ty<'tcx>>, NoSolution> {
     match *ty.kind() {
-        ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
-        | ty::FnDef(..)
-        | ty::FnPtr(_)
-        | ty::Error(_) => Ok(vec![]),
+        ty::FnDef(..) | ty::FnPtr(_) | ty::Error(_) => Ok(vec![]),
 
         // Implementations are provided in core
         ty::Uint(_)
         | ty::Int(_)
+        | ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
         | ty::Bool
         | ty::Float(_)
         | ty::Char
diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs
index 4371b6c1239..47533f62e9d 100644
--- a/compiler/rustc_trait_selection/src/traits/select/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs
@@ -2118,14 +2118,11 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
         use self::BuiltinImplConditions::{Ambiguous, None, Where};
 
         match *self_ty.kind() {
-            ty::Infer(ty::IntVar(_))
-            | ty::Infer(ty::FloatVar(_))
-            | ty::FnDef(..)
-            | ty::FnPtr(_)
-            | ty::Error(_) => Where(ty::Binder::dummy(Vec::new())),
+            ty::FnDef(..) | ty::FnPtr(_) | ty::Error(_) => Where(ty::Binder::dummy(Vec::new())),
 
             ty::Uint(_)
             | ty::Int(_)
+            | ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
             | ty::Bool
             | ty::Float(_)
             | ty::Char