mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Switch can_eq
and can_sub
to DefineOpaqueTypes::Yes
They are mostly used in diagnostics anyway
This commit is contained in:
parent
10e8bca7fe
commit
cdcca7e8f4
@ -843,7 +843,9 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||
{
|
||||
let origin = &ObligationCause::dummy();
|
||||
self.probe(|_| {
|
||||
self.at(origin, param_env).sub(DefineOpaqueTypes::No, expected, actual).is_ok()
|
||||
// We're only answering whether there could be a subtyping relation, and with
|
||||
// opaque types, "there could be one", via registering a hidden type.
|
||||
self.at(origin, param_env).sub(DefineOpaqueTypes::Yes, expected, actual).is_ok()
|
||||
})
|
||||
}
|
||||
|
||||
@ -852,7 +854,9 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||
T: at::ToTrace<'tcx>,
|
||||
{
|
||||
let origin = &ObligationCause::dummy();
|
||||
self.probe(|_| self.at(origin, param_env).eq(DefineOpaqueTypes::No, a, b).is_ok())
|
||||
// We're only answering whether the types could be the same, and with
|
||||
// opaque types, "they can be the same", via registering a hidden type.
|
||||
self.probe(|_| self.at(origin, param_env).eq(DefineOpaqueTypes::Yes, a, b).is_ok())
|
||||
}
|
||||
|
||||
#[instrument(skip(self), level = "debug")]
|
||||
|
@ -42,20 +42,20 @@ LL | fn bad_in_fn_syntax(x: fn() -> impl Into<impl Debug>) {}
|
||||
|
|
||||
= note: `impl Trait` is only allowed in arguments and return types of functions and methods
|
||||
|
||||
error[E0277]: the trait bound `impl Debug: From<impl Into<u32>>` is not satisfied
|
||||
error[E0277]: the trait bound `impl Into<u32>: Into<impl Debug>` is not satisfied
|
||||
--> $DIR/nested_impl_trait.rs:6:46
|
||||
|
|
||||
LL | fn bad_in_ret_position(x: impl Into<u32>) -> impl Into<impl Debug> { x }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ the trait `From<impl Into<u32>>` is not implemented for `impl Debug`, which is required by `impl Into<u32>: Into<impl Debug>`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ the trait `From<impl Into<u32>>` is not implemented for `impl Into<u32>`, which is required by `impl Into<u32>: Into<impl Debug>`
|
||||
|
|
||||
= help: the trait `Into<U>` is implemented for `T`
|
||||
= note: required for `impl Into<u32>` to implement `Into<impl Debug>`
|
||||
|
||||
error[E0277]: the trait bound `impl Debug: From<impl Into<u32>>` is not satisfied
|
||||
error[E0277]: the trait bound `impl Into<u32>: Into<impl Debug>` is not satisfied
|
||||
--> $DIR/nested_impl_trait.rs:19:34
|
||||
|
|
||||
LL | fn bad(x: impl Into<u32>) -> impl Into<impl Debug> { x }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ the trait `From<impl Into<u32>>` is not implemented for `impl Debug`, which is required by `impl Into<u32>: Into<impl Debug>`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ the trait `From<impl Into<u32>>` is not implemented for `impl Into<u32>`, which is required by `impl Into<u32>: Into<impl Debug>`
|
||||
|
|
||||
= help: the trait `Into<U>` is implemented for `T`
|
||||
= note: required for `impl Into<u32>` to implement `Into<impl Debug>`
|
||||
|
12
tests/ui/self/arbitrary-self-opaque.rs
Normal file
12
tests/ui/self/arbitrary-self-opaque.rs
Normal file
@ -0,0 +1,12 @@
|
||||
#![feature(type_alias_impl_trait)]
|
||||
struct Foo;
|
||||
|
||||
type Bar = impl Sized;
|
||||
//~^ ERROR unconstrained opaque type
|
||||
|
||||
impl Foo {
|
||||
fn foo(self: Bar) {}
|
||||
//~^ ERROR: invalid `self` parameter type: Bar
|
||||
}
|
||||
|
||||
fn main() {}
|
20
tests/ui/self/arbitrary-self-opaque.stderr
Normal file
20
tests/ui/self/arbitrary-self-opaque.stderr
Normal file
@ -0,0 +1,20 @@
|
||||
error: unconstrained opaque type
|
||||
--> $DIR/arbitrary-self-opaque.rs:4:12
|
||||
|
|
||||
LL | type Bar = impl Sized;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: `Bar` must be used in combination with a concrete type within the same module
|
||||
|
||||
error[E0307]: invalid `self` parameter type: Bar
|
||||
--> $DIR/arbitrary-self-opaque.rs:8:18
|
||||
|
|
||||
LL | fn foo(self: Bar) {}
|
||||
| ^^^
|
||||
|
|
||||
= note: type of `self` must be `Self` or a type that dereferences to it
|
||||
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0307`.
|
Loading…
Reference in New Issue
Block a user