Skip to content

Commit 4844044

Browse files
committed
Change a test and some other minor things
1 parent 6863ff1 commit 4844044

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

src/ir/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use cast::Cast;
22
use chalk_parse::ast;
33
use lalrpop_intern::InternedString;
44
use solve::infer::{TyInferenceVariable, LifetimeInferenceVariable};
5-
use std::collections::{HashMap, BTreeMap};
5+
use std::collections::{HashSet, HashMap, BTreeMap};
66
use std::sync::Arc;
77

88
pub type Identifier = InternedString;
@@ -87,8 +87,6 @@ impl Environment {
8787
pub fn add_clauses<I>(&self, clauses: I) -> Arc<Environment>
8888
where I: IntoIterator<Item = DomainGoal>
8989
{
90-
use std::collections::HashSet;
91-
9290
let mut env = self.clone();
9391
let env_clauses: HashSet<_> = env.clauses.into_iter().chain(clauses).collect();
9492
env.clauses = env_clauses.into_iter().collect();

src/lower/default.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl Program {
1818

1919
// If a positive or negative impl is already provided for a type family
2020
// which includes `MyStruct`, we do not generate a default impl.
21-
if self.provide_impl_for(trait_ref.clone(), struct_datum) {
21+
if self.impl_provided_for(trait_ref.clone(), struct_datum) {
2222
continue;
2323
}
2424

@@ -35,7 +35,7 @@ impl Program {
3535
}
3636
}
3737

38-
fn provide_impl_for(&self, trait_ref: TraitRef, struct_datum: &StructDatum) -> bool {
38+
fn impl_provided_for(&self, trait_ref: TraitRef, struct_datum: &StructDatum) -> bool {
3939
let goal: DomainGoal = trait_ref.cast();
4040

4141
let env = Environment::new();

src/solve/test.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,7 +1431,12 @@ fn auto_trait_without_impls() {
14311431
#[auto] trait Send { }
14321432

14331433
struct i32 { }
1434-
struct Vec<T> { }
1434+
1435+
struct Useless<T> { }
1436+
1437+
struct Data<T> {
1438+
data: T
1439+
}
14351440
}
14361441

14371442
goal {
@@ -1440,9 +1445,20 @@ fn auto_trait_without_impls() {
14401445
"Unique"
14411446
}
14421447

1448+
// No fields so `Useless<T>` is `Send`.
14431449
goal {
14441450
forall<T> {
1445-
Vec<T>: Send
1451+
Useless<T>: Send
1452+
}
1453+
} yields {
1454+
"Unique"
1455+
}
1456+
1457+
goal {
1458+
forall<T> {
1459+
if (T: Send) {
1460+
Data<T>: Send
1461+
}
14461462
}
14471463
} yields {
14481464
"Unique"
@@ -1523,6 +1539,13 @@ fn coinductive_semantics() {
15231539
"CannotProve"
15241540
}
15251541

1542+
// `WellFormed(T)` is needed here because of the expanded bound `WellFormed(Ptr<List<T>>: Send)`
1543+
// on the default `List<T>: Send` impl, which will need that `List<T>` is well-formed in order to be
1544+
// proven, which will in turn need that `T` is well-formed.
1545+
//
1546+
// In fact, as soon as there is a field which is referencing `T` with an indirection like `Foo<Bar<T>>`,
1547+
// we need to add the `WellFormed(T)` because the `if (T: Send)` elaborates `WellFormed(T: Send)` but not
1548+
// `WellFormed(T)`. This is not an issue, but is maybe a bit inconsistent.
15261549
goal {
15271550
forall<T> {
15281551
if (WellFormed(T), T: Send) {

0 commit comments

Comments
 (0)