Auto merge of #111881 - lcnr:leak-check, r=nikomatsakis,jackh726

refactor and cleanup the leak check, add it to new solver

ended up being a bit more involved than I wanted but is hopefully still easy enough to review as a single PR, can split it into separate ones otherwise.

this can be reviewed commit by commit:
a473d55cdb9284aa2b01282d1b529a2a4d26547b 31a686646534ca006d906ec757ece4e771d6f973 949039c107852a5e36361c08b62821a0613656f5 242917bf5170d9a723c6c8e23e9d9d0c2fa8dc9d ed2b25a7aa28be3184be9e3022c2796a30eaad87 are all pretty straightforward.

03dd83b4c3f4ff27558f5c8ab859bd9f83db1d04 makes it easier to refactor coherence in a later commit, see the commit description, cc `@oli-obk`

4fe311d807a77b6270f384e41689bf5d58f46aec I don't quite remember what we wanted to test here, this definitely doesn't test that the occurs check doesn't cause incorrect errors in coherence, also cc `@oli-obk` here. I may end up writing a new test for this myself later.

5c200d88a91b75bd0875b973150655bd581ef97a is the main refactor of the leak check, changing it to take the `outer_universe` instead of getting it from a snapshot. Using a snapshot requires us to be in a probe which we aren't in the new solver, it also just feels dirty as snapshots don't really have anything to do with universes.

with all of this cfc230d54188d9c7ed867a9a0d1f51be77b485f9 is now kind of trivial.

r? `@nikomatsakis`
This commit is contained in:
bors 2023-05-30 18:48:12 +00:00
commit f0411ffceb
138 changed files with 320 additions and 244 deletions

View file

@ -1,14 +0,0 @@
error[E0592]: duplicate definitions with name `method1`
--> $DIR/coherence-inherited-subtyping.rs:14:5
|
LL | fn method1(&self) {}
| ^^^^^^^^^^^^^^^^^ duplicate definitions for `method1`
...
LL | fn method1(&self) {}
| ----------------- other definition for `method1`
|
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
error: aborting due to previous error
For more information about this error, try `rustc --explain E0592`.

View file

@ -4,8 +4,6 @@
// Note: This scenario is currently accepted, but as part of the
// universe transition (#56105) may eventually become an error.
// revisions: old re
struct Foo<T> {
t: T,
}

View file

@ -1,5 +1,5 @@
error[E0592]: duplicate definitions with name `method1`
--> $DIR/coherence-inherited-subtyping.rs:14:5
--> $DIR/coherence-inherited-subtyping.rs:12:5
|
LL | fn method1(&self) {}
| ^^^^^^^^^^^^^^^^^ duplicate definitions for `method1`

View file

@ -1,6 +1,6 @@
// check-pass
// revisions: old new
//[new] compile-flags: -Ztrait-solver=next
// revisions: old next
//[next] compile-flags: -Ztrait-solver=next
// If we use canonical goals during trait solving we have to reevaluate
// the root goal of a cycle until we hit a fixpoint.

View file

@ -1,11 +0,0 @@
// revisions: old new
//[new] compile-flags: -Ztrait-solver=next
//[old] check-pass
//[new] known-bug: #109764
pub struct Bar
where
for<'a> &'a mut Self:;
fn main() {}

View file

@ -0,0 +1,24 @@
// run-pass
// revisions: old next
//[next] compile-flags: -Ztrait-solver=next
#![allow(coherence_leak_check)]
trait Trait: Sized {
fn is_higher_ranked(self) -> bool;
}
impl Trait for for<'a> fn(&'a ()) {
fn is_higher_ranked(self) -> bool {
true
}
}
impl<'a> Trait for fn(&'a ()) {
fn is_higher_ranked(self) -> bool {
false
}
}
fn main() {
let x: for<'a> fn(&'a ()) = |&()| ();
assert!(x.is_higher_ranked());
}

View file

@ -14,7 +14,7 @@ LL | f
| ^ expected `&dyn Fn(&dyn Fn(&dyn Fn(&...)))`, found `&dyn Fn(u32)`
|
= note: expected reference `&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&...)))))))))))`
the full type name has been written to '$TEST_BUILD_DIR/higher-rank-trait-bounds/hang-on-deeply-nested-dyn/hang-on-deeply-nested-dyn.long-type-hash.txt'
the full type name has been written to '$TEST_BUILD_DIR/higher-ranked/trait-bounds/hang-on-deeply-nested-dyn/hang-on-deeply-nested-dyn.long-type-hash.txt'
found reference `&dyn Fn(u32)`
error: aborting due to previous error

View file

@ -31,7 +31,7 @@ LL | pub struct Filter<S, F> {
LL | let count = filter.countx();
| ^^^^^^ method cannot be called due to unsatisfied trait bounds
|
= note: the full type name has been written to '$TEST_BUILD_DIR/higher-rank-trait-bounds/issue-30786/issue-30786.long-type-hash.txt'
= note: the full type name has been written to '$TEST_BUILD_DIR/higher-ranked/trait-bounds/issue-30786/issue-30786.long-type-hash.txt'
note: the following trait bounds were not satisfied:
`&'a mut &Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:131:30: 131:37]>: Stream`
`&'a mut &mut Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:131:30: 131:37]>: Stream`

View file

@ -0,0 +1,11 @@
// revisions: old next
//[next] compile-flags: -Ztrait-solver=next
//[old] check-pass
//[next] known-bug: #109764
pub struct Bar
where
for<'a> &'a mut Self:;
fn main() {}

Some files were not shown because too many files have changed in this diff Show more