Skip to content

Commit

Permalink
Don't emit copy clauses for tys with impls in core
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanwhit committed May 21, 2020
1 parent 5f2ae21 commit de32339
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 70 deletions.
5 changes: 1 addition & 4 deletions chalk-solve/src/clauses/builtin_traits/copy.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::clauses::builtin_traits::needs_impl_for_tys;
use crate::clauses::ClauseBuilder;
use crate::{Interner, RustIrDatabase, TraitRef};
use chalk_ir::{ApplicationTy, Mutability, Substitution, TyData, TypeName};
use chalk_ir::{ApplicationTy, Substitution, TyData, TypeName};

fn push_tuple_copy_conditions<I: Interner>(
db: &dyn RustIrDatabase<I>,
Expand Down Expand Up @@ -41,9 +41,6 @@ pub fn add_copy_program_clauses<I: Interner>(
TypeName::Tuple(arity) => {
push_tuple_copy_conditions(db, builder, trait_ref, *arity, substitution)
}
TypeName::Raw(_) | TypeName::Ref(Mutability::Not) => {
builder.push_fact(trait_ref.clone())
}
_ => return,
},
TyData::Function(_) => builder.push_fact(trait_ref.clone()),
Expand Down
2 changes: 1 addition & 1 deletion chalk-solve/src/clauses/builtin_traits/sized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn add_sized_program_clauses<I: Interner>(
TypeName::Tuple(arity) => {
push_tuple_sized_conditions(db, builder, trait_ref, *arity, substitution)
}
TypeName::Scalar(_) | TypeName::Raw(_) | TypeName::Ref(_) => {
TypeName::Never | TypeName::Scalar(_) | TypeName::Raw(_) | TypeName::Ref(_) => {
builder.push_fact(trait_ref.clone())
}
_ => return,
Expand Down
66 changes: 1 addition & 65 deletions tests/test/refs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,71 +51,7 @@ fn mut_refs_are_sized() {
}

goal {
forall<'a, T> { &'a mut T: Sized }
} yields {
"Unique; substitution [], lifetime constraints []"
}
}
}

#[test]
fn immut_refs_are_copy() {
test! {
program {
#[lang(copy)]
trait Copy { }
}

goal {
forall<'a, T> { &'a T: Copy }
} yields {
"Unique; substitution [], lifetime constraints []"
}
}
}

#[test]
fn immut_refs_are_clone() {
test! {
program {
#[lang(clone)]
trait Clone { }
}

goal {
forall<'a, T> { &'a T: Clone }
} yields {
"Unique; substitution [], lifetime constraints []"
}
}
}

#[test]
fn mut_refs_are_not_copy() {
test! {
program {
#[lang(copy)]
trait Copy { }
}

goal {
forall<'a, T> { not { &'a mut T: Copy } }
} yields {
"Unique; substitution [], lifetime constraints []"
}
}
}

#[test]
fn mut_refs_are_not_clone() {
test! {
program {
#[lang(clone)]
trait Clone { }
}

goal {
forall<'a, T> { not { &'a mut T: Clone } }
forall<'a, T> { &'a T: Sized }
} yields {
"Unique; substitution [], lifetime constraints []"
}
Expand Down

0 comments on commit de32339

Please sign in to comment.