Skip to content

Commit 6d083ff

Browse files
committed
Remove assertion now that we have a test covering the code path
1 parent 5b4e707 commit 6d083ff

File tree

7 files changed

+73
-37
lines changed

7 files changed

+73
-37
lines changed

compiler/rustc_infer/src/infer/mod.rs

-13
Original file line numberDiff line numberDiff line change
@@ -957,19 +957,6 @@ impl<'tcx> InferCtxt<'tcx> {
957957
(&ty::Infer(ty::TyVar(a_vid)), &ty::Infer(ty::TyVar(b_vid))) => {
958958
return Err((a_vid, b_vid));
959959
}
960-
// We don't silently want to constrain hidden types here, so we assert that either one side is
961-
// an infer var, so it'll get constrained to whatever the other side is, or there are no opaque
962-
// types involved.
963-
// We don't expect this to actually get hit, but if it does, we now at least know how to write
964-
// a test for it.
965-
(_, ty::Infer(ty::TyVar(_))) => {}
966-
(ty::Infer(ty::TyVar(_)), _) => {}
967-
_ if r_a != r_b && (r_a, r_b).has_opaque_types() => {
968-
span_bug!(
969-
cause.span(),
970-
"opaque types got hidden types registered from within subtype predicate: {r_a:?} vs {r_b:?}"
971-
)
972-
}
973960
_ => {}
974961
}
975962

src/tools/compiletest/src/runtest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ impl<'test> TestCx<'test> {
381381
// if a test does not crash, consider it an error
382382
if proc_res.status.success() || matches!(proc_res.status.code(), Some(1 | 0)) {
383383
self.fatal(&format!(
384-
"test no longer crashes/triggers ICE! Please give it a mearningful name, \
384+
"test no longer crashes/triggers ICE! Please give it a meaningful name, \
385385
add a doc-comment to the start of the test explaining why it exists and \
386386
move it to tests/ui or wherever you see fit."
387387
));

tests/crashes/124891.rs

-22
This file was deleted.

tests/ui/impl-trait/lazy_subtyping_of_opaques.rs

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//! This test checks that we allow subtyping predicates that contain opaque types.
2+
//! No hidden types are being constrained in the subtyping predicate, but type and
3+
//! lifetime variables get subtyped in the generic parameter list of the opaque.
4+
15
use std::iter;
26

37
mod either {
@@ -24,11 +28,17 @@ impl<'a> BabeConsensusLogRef<'a> {
2428
pub fn scale_encoding(
2529
&self,
2630
) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
31+
//~^ ERROR is not satisfied
32+
//~| ERROR is not satisfied
33+
//~| ERROR is not satisfied
2734
match self {
2835
BabeConsensusLogRef::NextEpochData(digest) => either::Left(either::Left(
2936
digest.scale_encoding().map(either::Left).map(either::Left),
3037
)),
3138
BabeConsensusLogRef::NextConfigData => either::Right(
39+
// The Opaque type from ``scale_encoding` gets used opaquely here, while the `R`
40+
// generic parameter of `Either` contains type variables that get subtyped and the
41+
// opaque type contains lifetime variables that get subtyped.
3242
iter::once(either::Right(either::Left([1])))
3343
.chain(std::iter::once([1]).map(either::Right).map(either::Right)),
3444
),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0277]: the trait bound `Either<Either<Map<Map<impl Iterator<Item = impl AsRef<[u8]> + Clone + '_> + Clone + '_, fn(impl AsRef<[u8]> + Clone + '_) -> Either<impl AsRef<[u8]> + Clone + '_, _> {Either::<impl AsRef<[u8]> + Clone + '_, _>::Left}>, fn(Either<impl AsRef<[u8]> + Clone + '_, _>) -> Either<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>> {Either::<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>>::Left}>, _>, std::iter::Chain<std::iter::Once<Either<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>>>, Map<Map<std::iter::Once<[{integer}; 1]>, fn([{integer}; 1]) -> Either<[{integer}; 1], [{integer}; 1]> {Either::<[{integer}; 1], [{integer}; 1]>::Right}>, fn(Either<[{integer}; 1], [{integer}; 1]>) -> Either<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>> {Either::<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>>::Right}>>>: Clone` is not satisfied
2+
--> $DIR/lazy_subtyping_of_opaques.rs:30:10
3+
|
4+
LL | ) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `Either<Either<Map<Map<impl Iterator<Item = impl AsRef<[u8]> + Clone + '_> + Clone + '_, fn(impl AsRef<[u8]> + Clone + '_) -> Either<impl AsRef<[u8]> + Clone + '_, _> {Either::<impl AsRef<[u8]> + Clone + '_, _>::Left}>, fn(Either<impl AsRef<[u8]> + Clone + '_, _>) -> Either<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>> {Either::<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>>::Left}>, _>, std::iter::Chain<std::iter::Once<Either<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>>>, Map<Map<std::iter::Once<[{integer}; 1]>, fn([{integer}; 1]) -> Either<[{integer}; 1], [{integer}; 1]> {Either::<[{integer}; 1], [{integer}; 1]>::Right}>, fn(Either<[{integer}; 1], [{integer}; 1]>) -> Either<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>> {Either::<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>>::Right}>>>`
6+
7+
error[E0277]: the trait bound `Either<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>>: AsRef<[u8]>` is not satisfied
8+
--> $DIR/lazy_subtyping_of_opaques.rs:30:31
9+
|
10+
LL | ) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsRef<[u8]>` is not implemented for `Either<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>>`
12+
13+
error[E0277]: the trait bound `Either<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>>: Clone` is not satisfied
14+
--> $DIR/lazy_subtyping_of_opaques.rs:30:31
15+
|
16+
LL | ) -> impl Iterator<Item = impl AsRef<[u8]> + Clone + 'a> + Clone + 'a {
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `Either<Either<impl AsRef<[u8]> + Clone + '_, _>, Either<[{integer}; 1], [{integer}; 1]>>`
18+
19+
error: aborting due to 3 previous errors
20+
21+
For more information about this error, try `rustc --explain E0277`.

tests/ui/type-alias-impl-trait/lazy_subtyping_of_opaques.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
#![feature(type_alias_impl_trait)]
22

3+
//! This test used to ICE rust-lang/rust#124891
4+
//! because we added an assertion for catching cases where opaque types get
5+
//! registered during the processing of subtyping predicates.
6+
37
type Tait = impl FnOnce() -> ();
48

59
fn reify_as_tait() -> Thunk<Tait> {
6-
Thunk::new(|cont| cont)
10+
//~^ ERROR expected a `FnOnce()` closure, found `()`
11+
Thunk::new(|cont| cont /* opaque type gets constrained to `()`` here */)
12+
//~^ ERROR expected a `FnOnce()` closure, found `()`
13+
//~| ERROR mismatched types
714
}
815

916
struct Thunk<F>(F);
@@ -20,3 +27,5 @@ impl<F> Thunk<F> {
2027
trait ContFn {}
2128

2229
impl<F: FnOnce(Tait) -> ()> ContFn for F {}
30+
31+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
error[E0277]: expected a `FnOnce()` closure, found `()`
2+
--> $DIR/lazy_subtyping_of_opaques.rs:11:23
3+
|
4+
LL | Thunk::new(|cont| cont /* opaque type gets constrained to `()`` here */)
5+
| ^^^^ expected an `FnOnce()` closure, found `()`
6+
|
7+
= help: the trait `FnOnce<()>` is not implemented for `()`
8+
= note: wrap the `()` in a closure with no arguments: `|| { /* code */ }`
9+
10+
error[E0277]: expected a `FnOnce()` closure, found `()`
11+
--> $DIR/lazy_subtyping_of_opaques.rs:9:23
12+
|
13+
LL | fn reify_as_tait() -> Thunk<Tait> {
14+
| ^^^^^^^^^^^ expected an `FnOnce()` closure, found `()`
15+
|
16+
= help: the trait `FnOnce<()>` is not implemented for `()`
17+
= note: wrap the `()` in a closure with no arguments: `|| { /* code */ }`
18+
19+
error[E0308]: mismatched types
20+
--> $DIR/lazy_subtyping_of_opaques.rs:11:5
21+
|
22+
LL | Thunk::new(|cont| cont /* opaque type gets constrained to `()`` here */)
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Thunk<_>`, found `()`
24+
|
25+
= note: expected struct `Thunk<_>`
26+
found unit type `()`
27+
28+
error: aborting due to 3 previous errors
29+
30+
Some errors have detailed explanations: E0277, E0308.
31+
For more information about an error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)