Skip to content

Commit 49af618

Browse files
committed
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
2 parents 28eb857 + bb76fde commit 49af618

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,12 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_copy_clone_trait<'tcx>(
161161
ty: Ty<'tcx>,
162162
) -> Result<Vec<Ty<'tcx>>, NoSolution> {
163163
match *ty.kind() {
164-
ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
165-
| ty::FnDef(..)
166-
| ty::FnPtr(_)
167-
| ty::Error(_) => Ok(vec![]),
164+
ty::FnDef(..) | ty::FnPtr(_) | ty::Error(_) => Ok(vec![]),
168165

169166
// Implementations are provided in core
170167
ty::Uint(_)
171168
| ty::Int(_)
169+
| ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
172170
| ty::Bool
173171
| ty::Float(_)
174172
| ty::Char

compiler/rustc_trait_selection/src/traits/select/mod.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -2118,14 +2118,11 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
21182118
use self::BuiltinImplConditions::{Ambiguous, None, Where};
21192119

21202120
match *self_ty.kind() {
2121-
ty::Infer(ty::IntVar(_))
2122-
| ty::Infer(ty::FloatVar(_))
2123-
| ty::FnDef(..)
2124-
| ty::FnPtr(_)
2125-
| ty::Error(_) => Where(ty::Binder::dummy(Vec::new())),
2121+
ty::FnDef(..) | ty::FnPtr(_) | ty::Error(_) => Where(ty::Binder::dummy(Vec::new())),
21262122

21272123
ty::Uint(_)
21282124
| ty::Int(_)
2125+
| ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
21292126
| ty::Bool
21302127
| ty::Float(_)
21312128
| ty::Char

0 commit comments

Comments
 (0)