Remove DefiningAnchor::Bubble
from opaque wf check
This commit is contained in:
parent
64368d0279
commit
743e6d1601
7 changed files with 37 additions and 48 deletions
|
@ -1,5 +1,6 @@
|
||||||
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
|
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
|
||||||
use rustc_errors::ErrorGuaranteed;
|
use rustc_errors::ErrorGuaranteed;
|
||||||
|
use rustc_hir::def::DefKind;
|
||||||
use rustc_hir::def_id::LocalDefId;
|
use rustc_hir::def_id::LocalDefId;
|
||||||
use rustc_hir::OpaqueTyOrigin;
|
use rustc_hir::OpaqueTyOrigin;
|
||||||
use rustc_infer::infer::InferCtxt;
|
use rustc_infer::infer::InferCtxt;
|
||||||
|
@ -308,20 +309,19 @@ fn check_opaque_type_well_formed<'tcx>(
|
||||||
return Ok(definition_ty);
|
return Ok(definition_ty);
|
||||||
};
|
};
|
||||||
let param_env = tcx.param_env(def_id);
|
let param_env = tcx.param_env(def_id);
|
||||||
// HACK This bubble is required for this tests to pass:
|
|
||||||
// nested-return-type2-tait2.rs
|
let mut parent_def_id = def_id;
|
||||||
// nested-return-type2-tait3.rs
|
while tcx.def_kind(parent_def_id) == DefKind::OpaqueTy {
|
||||||
|
parent_def_id = tcx.local_parent(parent_def_id);
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME(-Ztrait-solver=next): We probably should use `DefiningAnchor::Error`
|
// FIXME(-Ztrait-solver=next): We probably should use `DefiningAnchor::Error`
|
||||||
// and prepopulate this `InferCtxt` with known opaque values, rather than
|
// and prepopulate this `InferCtxt` with known opaque values, rather than
|
||||||
// using the `Bind` anchor here. For now it's fine.
|
// using the `Bind` anchor here. For now it's fine.
|
||||||
let infcx = tcx
|
let infcx = tcx
|
||||||
.infer_ctxt()
|
.infer_ctxt()
|
||||||
.with_next_trait_solver(next_trait_solver)
|
.with_next_trait_solver(next_trait_solver)
|
||||||
.with_opaque_type_inference(if next_trait_solver {
|
.with_opaque_type_inference(DefiningAnchor::Bind(parent_def_id))
|
||||||
DefiningAnchor::Bind(def_id)
|
|
||||||
} else {
|
|
||||||
DefiningAnchor::Bubble
|
|
||||||
})
|
|
||||||
.build();
|
.build();
|
||||||
let ocx = ObligationCtxt::new(&infcx);
|
let ocx = ObligationCtxt::new(&infcx);
|
||||||
let identity_args = GenericArgs::identity_for_item(tcx, def_id);
|
let identity_args = GenericArgs::identity_for_item(tcx, def_id);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#![feature(type_alias_impl_trait)]
|
#![feature(type_alias_impl_trait)]
|
||||||
// edition:2021
|
// edition:2021
|
||||||
//[rpit] check-pass
|
// check-pass
|
||||||
// revisions: tait rpit
|
// revisions: tait rpit
|
||||||
|
|
||||||
struct Pending {}
|
struct Pending {}
|
||||||
|
@ -23,7 +23,7 @@ impl Pending {
|
||||||
|
|
||||||
#[cfg(tait)]
|
#[cfg(tait)]
|
||||||
fn read_fut(&mut self) -> OpeningReadFuture<'_> {
|
fn read_fut(&mut self) -> OpeningReadFuture<'_> {
|
||||||
self.read() //[tait]~ ERROR: cannot satisfy `impl AsyncRead + 'a == PendingReader<'a>`
|
self.read()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(rpit)]
|
#[cfg(rpit)]
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
error[E0284]: type annotations needed: cannot satisfy `impl AsyncRead + 'a == PendingReader<'a>`
|
|
||||||
--> $DIR/async_scope_creep.rs:26:9
|
|
||||||
|
|
|
||||||
LL | self.read()
|
|
||||||
| ^^^^^^^^^^^ cannot satisfy `impl AsyncRead + 'a == PendingReader<'a>`
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0284`.
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// check-pass
|
||||||
|
|
||||||
#![feature(type_alias_impl_trait)]
|
#![feature(type_alias_impl_trait)]
|
||||||
|
|
||||||
trait Duh {}
|
trait Duh {}
|
||||||
|
@ -17,6 +19,7 @@ impl<R: Duh, F: FnMut() -> R> Trait for F {
|
||||||
|
|
||||||
type Sendable = impl Send;
|
type Sendable = impl Send;
|
||||||
type Traitable = impl Trait<Assoc = Sendable>;
|
type Traitable = impl Trait<Assoc = Sendable>;
|
||||||
|
//~^ WARN opaque type `Traitable` does not satisfy its associated type bounds
|
||||||
|
|
||||||
// The `impl Send` here is then later compared against the inference var
|
// The `impl Send` here is then later compared against the inference var
|
||||||
// created, causing the inference var to be set to `impl Send` instead of
|
// created, causing the inference var to be set to `impl Send` instead of
|
||||||
|
@ -25,7 +28,6 @@ type Traitable = impl Trait<Assoc = Sendable>;
|
||||||
// type does not implement `Duh`, even if its hidden type does. So we error out.
|
// type does not implement `Duh`, even if its hidden type does. So we error out.
|
||||||
fn foo() -> Traitable {
|
fn foo() -> Traitable {
|
||||||
|| 42
|
|| 42
|
||||||
//~^ ERROR `Sendable: Duh` is not satisfied
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -1,18 +1,13 @@
|
||||||
error[E0277]: the trait bound `Sendable: Duh` is not satisfied
|
warning: opaque type `Traitable` does not satisfy its associated type bounds
|
||||||
--> $DIR/nested-return-type2-tait2.rs:27:5
|
--> $DIR/nested-return-type2-tait2.rs:21:29
|
||||||
|
|
|
|
||||||
LL | || 42
|
LL | type Assoc: Duh;
|
||||||
| ^^^^^ the trait `Duh` is not implemented for `Sendable`
|
| --- this associated type bound is unsatisfied for `Sendable`
|
||||||
|
...
|
||||||
|
LL | type Traitable = impl Trait<Assoc = Sendable>;
|
||||||
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= help: the trait `Duh` is implemented for `i32`
|
= note: `#[warn(opaque_hidden_inferred_bound)]` on by default
|
||||||
note: required for `{closure@$DIR/nested-return-type2-tait2.rs:27:5: 27:7}` to implement `Trait`
|
|
||||||
--> $DIR/nested-return-type2-tait2.rs:14:31
|
|
||||||
|
|
|
||||||
LL | impl<R: Duh, F: FnMut() -> R> Trait for F {
|
|
||||||
| --- ^^^^^ ^
|
|
||||||
| |
|
|
||||||
| unsatisfied trait bound introduced here
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
warning: 1 warning emitted
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0277`.
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// check-pass
|
||||||
|
|
||||||
#![feature(type_alias_impl_trait)]
|
#![feature(type_alias_impl_trait)]
|
||||||
|
|
||||||
trait Duh {}
|
trait Duh {}
|
||||||
|
@ -16,6 +18,7 @@ impl<R: Duh, F: FnMut() -> R> Trait for F {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Traitable = impl Trait<Assoc = impl Send>;
|
type Traitable = impl Trait<Assoc = impl Send>;
|
||||||
|
//~^ WARN opaque type `Traitable` does not satisfy its associated type bounds
|
||||||
|
|
||||||
// The `impl Send` here is then later compared against the inference var
|
// The `impl Send` here is then later compared against the inference var
|
||||||
// created, causing the inference var to be set to `impl Send` instead of
|
// created, causing the inference var to be set to `impl Send` instead of
|
||||||
|
@ -24,7 +27,6 @@ type Traitable = impl Trait<Assoc = impl Send>;
|
||||||
// type does not implement `Duh`, even if its hidden type does. So we error out.
|
// type does not implement `Duh`, even if its hidden type does. So we error out.
|
||||||
fn foo() -> Traitable {
|
fn foo() -> Traitable {
|
||||||
|| 42
|
|| 42
|
||||||
//~^ ERROR `impl Send: Duh` is not satisfied
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -1,18 +1,17 @@
|
||||||
error[E0277]: the trait bound `impl Send: Duh` is not satisfied
|
warning: opaque type `Traitable` does not satisfy its associated type bounds
|
||||||
--> $DIR/nested-return-type2-tait3.rs:26:5
|
--> $DIR/nested-return-type2-tait3.rs:20:29
|
||||||
|
|
|
|
||||||
LL | || 42
|
LL | type Assoc: Duh;
|
||||||
| ^^^^^ the trait `Duh` is not implemented for `impl Send`
|
| --- this associated type bound is unsatisfied for `impl Send`
|
||||||
|
...
|
||||||
|
LL | type Traitable = impl Trait<Assoc = impl Send>;
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= help: the trait `Duh` is implemented for `i32`
|
= note: `#[warn(opaque_hidden_inferred_bound)]` on by default
|
||||||
note: required for `{closure@$DIR/nested-return-type2-tait3.rs:26:5: 26:7}` to implement `Trait`
|
help: add this bound
|
||||||
--> $DIR/nested-return-type2-tait3.rs:14:31
|
|
||||||
|
|
|
|
||||||
LL | impl<R: Duh, F: FnMut() -> R> Trait for F {
|
LL | type Traitable = impl Trait<Assoc = impl Send + Duh>;
|
||||||
| --- ^^^^^ ^
|
| +++++
|
||||||
| |
|
|
||||||
| unsatisfied trait bound introduced here
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
warning: 1 warning emitted
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0277`.
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue