Fix Chalk environments

The clauses need to be wrapped in `FromEnv` clauses for elaboration (i.e.
things like inferring `T: Clone` from `T: Copy`) to work correctly.
This commit is contained in:
Florian Diebold 2019-09-07 16:30:37 +02:00
parent a1776b27c7
commit 9db34eec20
2 changed files with 4 additions and 3 deletions

View file

@ -3687,9 +3687,9 @@ fn test<T: Trait1, U: Trait2>(x: T, y: U) {
[188; 189) 'y': U [188; 189) 'y': U
[194; 223) '{ ...o(); }': () [194; 223) '{ ...o(); }': ()
[200; 201) 'x': T [200; 201) 'x': T
[200; 207) 'x.foo()': {unknown} [200; 207) 'x.foo()': u32
[213; 214) 'y': U [213; 214) 'y': U
[213; 220) 'y.foo()': {unknown} [213; 220) 'y.foo()': u32
"### "###
); );
} }

View file

@ -314,7 +314,8 @@ impl ToChalk for Arc<super::TraitEnvironment> {
// for env, we just ignore errors // for env, we just ignore errors
continue; continue;
} }
clauses.push(pred.clone().to_chalk(db).cast()); let program_clause: chalk_ir::ProgramClause = pred.clone().to_chalk(db).cast();
clauses.push(program_clause.into_from_env_clause());
} }
chalk_ir::Environment::new().add_clauses(clauses) chalk_ir::Environment::new().add_clauses(clauses)
} }