Rollup merge of #136928 - lcnr:method-lookup-check-wf, r=compiler-errors
eagerly prove WF when resolving fully qualified paths fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/161. This hopefully shouldn't impact perf. I do think we need to deal with at least part of the fallout here, opening for vibes. r? ``@compiler-errors``
This commit is contained in:
commit
1b603f959b
28 changed files with 366 additions and 186 deletions
|
@ -798,13 +798,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
bug!("`resolve_ty_and_res_fully_qualified_call` called on `LangItem`")
|
||||
}
|
||||
};
|
||||
if let Some(&cached_result) = self.typeck_results.borrow().type_dependent_defs().get(hir_id)
|
||||
{
|
||||
|
||||
self.register_wf_obligation(
|
||||
ty.raw.into(),
|
||||
qself.span,
|
||||
ObligationCauseCode::WellFormed(None),
|
||||
);
|
||||
self.select_obligations_where_possible(|_| {});
|
||||
|
||||
if let Some(&cached_result) = self.typeck_results.borrow().type_dependent_defs().get(hir_id)
|
||||
{
|
||||
// Return directly on cache hit. This is useful to avoid doubly reporting
|
||||
// errors with default match binding modes. See #44614.
|
||||
let def = cached_result.map_or(Res::Err, |(kind, def_id)| Res::Def(kind, def_id));
|
||||
|
@ -824,18 +827,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|
||||
let trait_missing_method =
|
||||
matches!(error, method::MethodError::NoMatch(_)) && ty.normalized.is_trait();
|
||||
// If we have a path like `MyTrait::missing_method`, then don't register
|
||||
// a WF obligation for `dyn MyTrait` when method lookup fails. Otherwise,
|
||||
// register a WF obligation so that we can detect any additional
|
||||
// errors in the self type.
|
||||
if !trait_missing_method {
|
||||
self.register_wf_obligation(
|
||||
ty.raw.into(),
|
||||
qself.span,
|
||||
ObligationCauseCode::WellFormed(None),
|
||||
);
|
||||
}
|
||||
|
||||
if item_name.name != kw::Empty {
|
||||
self.report_method_error(
|
||||
hir_id,
|
||||
|
@ -849,14 +840,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
result
|
||||
});
|
||||
|
||||
if result.is_ok() {
|
||||
self.register_wf_obligation(
|
||||
ty.raw.into(),
|
||||
qself.span,
|
||||
ObligationCauseCode::WellFormed(None),
|
||||
);
|
||||
}
|
||||
|
||||
// Write back the new resolution.
|
||||
self.write_resolution(hir_id, result);
|
||||
(
|
||||
|
|
|
@ -8,6 +8,7 @@ impl dyn Trait {
|
|||
//~^ ERROR the trait `Trait` is not dyn compatible [E0038]
|
||||
const fn n() -> usize { Self::N }
|
||||
//~^ ERROR the trait `Trait` is not dyn compatible [E0038]
|
||||
//~| ERROR the trait `Trait` is not dyn compatible
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -30,6 +30,22 @@ LL | const N: usize;
|
|||
| ^ ...because it contains this associated `const`
|
||||
= help: consider moving `N` to another trait
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error[E0038]: the trait `Trait` is not dyn compatible
|
||||
--> $DIR/associated-const-in-trait.rs:9:29
|
||||
|
|
||||
LL | const fn n() -> usize { Self::N }
|
||||
| ^^^^^^^ `Trait` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/associated-const-in-trait.rs:4:11
|
||||
|
|
||||
LL | trait Trait {
|
||||
| ----- this trait is not dyn compatible...
|
||||
LL | const N: usize;
|
||||
| ^ ...because it contains this associated `const`
|
||||
= help: consider moving `N` to another trait
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
||||
|
|
|
@ -1,15 +1,3 @@
|
|||
error[E0599]: no associated item named `C` found for struct `Fail<i32, u32>` in the current scope
|
||||
--> $DIR/wrong-projection-self-ty-invalid-bivariant-arg2.rs:15:23
|
||||
|
|
||||
LL | struct Fail<T: Proj<Assoc = U>, U>(T);
|
||||
| ---------------------------------- associated item `C` not found for this struct
|
||||
...
|
||||
LL | Fail::<i32, u32>::C
|
||||
| ^ associated item not found in `Fail<i32, u32>`
|
||||
|
|
||||
= note: the associated item was found for
|
||||
- `Fail<i32, i32>`
|
||||
|
||||
error[E0271]: type mismatch resolving `<i32 as Proj>::Assoc == u32`
|
||||
--> $DIR/wrong-projection-self-ty-invalid-bivariant-arg2.rs:15:5
|
||||
|
|
||||
|
@ -27,6 +15,18 @@ note: required by a bound in `Fail`
|
|||
LL | struct Fail<T: Proj<Assoc = U>, U>(T);
|
||||
| ^^^^^^^^^ required by this bound in `Fail`
|
||||
|
||||
error[E0599]: no associated item named `C` found for struct `Fail<i32, u32>` in the current scope
|
||||
--> $DIR/wrong-projection-self-ty-invalid-bivariant-arg2.rs:15:23
|
||||
|
|
||||
LL | struct Fail<T: Proj<Assoc = U>, U>(T);
|
||||
| ---------------------------------- associated item `C` not found for this struct
|
||||
...
|
||||
LL | Fail::<i32, u32>::C
|
||||
| ^ associated item not found in `Fail<i32, u32>`
|
||||
|
|
||||
= note: the associated item was found for
|
||||
- `Fail<i32, i32>`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0271, E0599.
|
||||
|
|
|
@ -9,6 +9,7 @@ fn f<'a, T: X<'a> + ?Sized>(x: &<T as X<'a>>::U) {
|
|||
<<T as X<'_>>::U>::clone(x);
|
||||
//~^ ERROR the trait bound `for<'b> <T as X<'b>>::U: Clone` is not satisfied
|
||||
//~| ERROR the trait bound `for<'b> <T as X<'b>>::U: Clone` is not satisfied
|
||||
//~| ERROR the trait bound `for<'b> <T as X<'b>>::U: Clone` is not satisfied
|
||||
//~| ERROR the trait bound `<T as X<'_>>::U: Clone` is not satisfied
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,25 @@ help: consider further restricting the associated type
|
|||
LL | fn f<'a, T: X<'a> + ?Sized>(x: &<T as X<'a>>::U) where <T as X<'_>>::U: Clone {
|
||||
| ++++++++++++++++++++++++++++
|
||||
|
||||
error[E0277]: the trait bound `for<'b> <T as X<'b>>::U: Clone` is not satisfied
|
||||
--> $DIR/hr-associated-type-bound-object.rs:9:5
|
||||
|
|
||||
LL | <<T as X<'_>>::U>::clone(x);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'b> Clone` is not implemented for `<T as X<'b>>::U`
|
||||
|
|
||||
note: required by a bound in `X`
|
||||
--> $DIR/hr-associated-type-bound-object.rs:3:33
|
||||
|
|
||||
LL | trait X<'a>
|
||||
| - required by a bound in this trait
|
||||
LL | where
|
||||
LL | for<'b> <Self as X<'b>>::U: Clone,
|
||||
| ^^^^^ required by this bound in `X`
|
||||
help: consider further restricting the associated type
|
||||
|
|
||||
LL | fn f<'a, T: X<'a> + ?Sized>(x: &<T as X<'a>>::U) where for<'b> <T as X<'b>>::U: Clone {
|
||||
| ++++++++++++++++++++++++++++++++++++
|
||||
|
||||
error[E0277]: the trait bound `for<'b> <T as X<'b>>::U: Clone` is not satisfied
|
||||
--> $DIR/hr-associated-type-bound-object.rs:9:5
|
||||
|
|
||||
|
@ -66,6 +85,6 @@ help: consider further restricting the associated type
|
|||
LL | fn f<'a, T: X<'a> + ?Sized>(x: &<T as X<'a>>::U) where for<'b> <T as X<'b>>::U: Clone {
|
||||
| ++++++++++++++++++++++++++++++++++++
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
|
@ -10,6 +10,7 @@ where
|
|||
<T::W>::clone(x);
|
||||
//~^ the trait bound `str: Clone` is not satisfied
|
||||
//~| the trait bound `str: Clone` is not satisfied
|
||||
//~| the trait bound `str: Clone` is not satisfied
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ LL | for<'b> <T as Z<'b, u16>>::W: Clone,
|
|||
| ^^^^^ required by this bound in `Z`
|
||||
|
||||
error[E0277]: the trait bound `str: Clone` is not satisfied
|
||||
--> $DIR/hr-associated-type-bound-param-2.rs:17:14
|
||||
--> $DIR/hr-associated-type-bound-param-2.rs:18:14
|
||||
|
|
||||
LL | type W = str;
|
||||
| ^^^ the trait `Clone` is not implemented for `str`
|
||||
|
@ -63,6 +63,22 @@ LL | {
|
|||
LL | type W: ?Sized;
|
||||
| - required by a bound in this associated type
|
||||
|
||||
error[E0277]: the trait bound `str: Clone` is not satisfied
|
||||
--> $DIR/hr-associated-type-bound-param-2.rs:10:9
|
||||
|
|
||||
LL | <T::W>::clone(x);
|
||||
| ^^^^^^^^^^^^^ the trait `Clone` is not implemented for `str`
|
||||
|
|
||||
= help: the trait `Clone` is implemented for `String`
|
||||
note: required by a bound in `Z`
|
||||
--> $DIR/hr-associated-type-bound-param-2.rs:6:35
|
||||
|
|
||||
LL | trait Z<'a, T: ?Sized>
|
||||
| - required by a bound in this trait
|
||||
...
|
||||
LL | for<'b> <T as Z<'b, u16>>::W: Clone,
|
||||
| ^^^^^ required by this bound in `Z`
|
||||
|
||||
error[E0277]: the trait bound `str: Clone` is not satisfied
|
||||
--> $DIR/hr-associated-type-bound-param-2.rs:10:9
|
||||
|
|
||||
|
@ -80,7 +96,7 @@ LL | for<'b> <T as Z<'b, u16>>::W: Clone,
|
|||
| ^^^^^ required by this bound in `Z`
|
||||
|
||||
error[E0277]: the trait bound `str: Clone` is not satisfied
|
||||
--> $DIR/hr-associated-type-bound-param-2.rs:22:10
|
||||
--> $DIR/hr-associated-type-bound-param-2.rs:23:10
|
||||
|
|
||||
LL | 1u16.h("abc");
|
||||
| ^ the trait `Clone` is not implemented for `str`
|
||||
|
@ -95,6 +111,6 @@ LL | for<'b> <T as Z<'b, u16>>::W: Clone,
|
|||
LL | fn h(&self, x: &T::W) {
|
||||
| - required by a bound in this associated function
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
error[E0284]: type annotations needed for `Foo<_>`
|
||||
--> $DIR/doesnt_infer.rs:13:9
|
||||
|
|
||||
LL | let foo = Foo::foo();
|
||||
| ^^^ --- type must be known at this point
|
||||
|
|
||||
note: required by a const generic parameter in `Foo`
|
||||
--> $DIR/doesnt_infer.rs:3:12
|
||||
|
|
||||
LL | struct Foo<const N: u32 = 2>;
|
||||
| ^^^^^^^^^^^^^^^^ required by this const generic parameter in `Foo`
|
||||
help: consider giving `foo` an explicit type, where the value of const parameter `N` is specified
|
||||
|
|
||||
LL | let foo: Foo<N> = Foo::foo();
|
||||
| ++++++++
|
||||
|
||||
error[E0284]: type annotations needed for `Foo<_>`
|
||||
--> $DIR/doesnt_infer.rs:13:9
|
||||
|
|
||||
|
@ -16,22 +32,6 @@ help: consider giving `foo` an explicit type, where the value of const parameter
|
|||
LL | let foo: Foo<N> = Foo::foo();
|
||||
| ++++++++
|
||||
|
||||
error[E0284]: type annotations needed for `Foo<_>`
|
||||
--> $DIR/doesnt_infer.rs:13:9
|
||||
|
|
||||
LL | let foo = Foo::foo();
|
||||
| ^^^ --- type must be known at this point
|
||||
|
|
||||
note: required by a const generic parameter in `Foo`
|
||||
--> $DIR/doesnt_infer.rs:3:12
|
||||
|
|
||||
LL | struct Foo<const N: u32 = 2>;
|
||||
| ^^^^^^^^^^^^^^^^ required by this const generic parameter in `Foo`
|
||||
help: consider giving `foo` an explicit type, where the value of const parameter `N` is specified
|
||||
|
|
||||
LL | let foo: Foo<N> = Foo::foo();
|
||||
| ++++++++
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0284`.
|
||||
|
|
|
@ -1,16 +1,3 @@
|
|||
error[E0284]: type annotations needed for `Mask<_, _>`
|
||||
--> $DIR/issue-91614.rs:6:9
|
||||
|
|
||||
LL | let y = Mask::<_, _>::splat(false);
|
||||
| ^ -------------------------- type must be known at this point
|
||||
|
|
||||
note: required by a const generic parameter in `Mask::<T, N>::splat`
|
||||
--> $SRC_DIR/core/src/../../portable-simd/crates/core_simd/src/masks.rs:LL:COL
|
||||
help: consider giving `y` an explicit type, where the value of const parameter `N` is specified
|
||||
|
|
||||
LL | let y: Mask<_, N> = Mask::<_, _>::splat(false);
|
||||
| ++++++++++++
|
||||
|
||||
error[E0284]: type annotations needed for `Mask<_, _>`
|
||||
--> $DIR/issue-91614.rs:6:9
|
||||
|
|
||||
|
@ -24,6 +11,19 @@ help: consider giving `y` an explicit type, where the value of const parameter `
|
|||
LL | let y: Mask<_, N> = Mask::<_, _>::splat(false);
|
||||
| ++++++++++++
|
||||
|
||||
error[E0284]: type annotations needed for `Mask<_, _>`
|
||||
--> $DIR/issue-91614.rs:6:9
|
||||
|
|
||||
LL | let y = Mask::<_, _>::splat(false);
|
||||
| ^ -------------------------- type must be known at this point
|
||||
|
|
||||
note: required by a const generic parameter in `Mask::<T, N>::splat`
|
||||
--> $SRC_DIR/core/src/../../portable-simd/crates/core_simd/src/masks.rs:LL:COL
|
||||
help: consider giving `y` an explicit type, where the value of const parameter `N` is specified
|
||||
|
|
||||
LL | let y: Mask<_, N> = Mask::<_, _>::splat(false);
|
||||
| ++++++++++++
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0284`.
|
||||
|
|
|
@ -18,6 +18,22 @@ help: try adding a `where` bound
|
|||
LL | pub const fn new() -> Self where [(); Self::SIZE]: {
|
||||
| +++++++++++++++++++++++
|
||||
|
||||
error[E0284]: type annotations needed for `ArrayHolder<_>`
|
||||
--> $DIR/issue-62504.rs:26:9
|
||||
|
|
||||
LL | let mut array = ArrayHolder::new();
|
||||
| ^^^^^^^^^ ----------- type must be known at this point
|
||||
|
|
||||
note: required by a const generic parameter in `ArrayHolder`
|
||||
--> $DIR/issue-62504.rs:14:20
|
||||
|
|
||||
LL | struct ArrayHolder<const X: usize>([u32; X]);
|
||||
| ^^^^^^^^^^^^^^ required by this const generic parameter in `ArrayHolder`
|
||||
help: consider giving `array` an explicit type, where the value of const parameter `X` is specified
|
||||
|
|
||||
LL | let mut array: ArrayHolder<X> = ArrayHolder::new();
|
||||
| ++++++++++++++++
|
||||
|
||||
error[E0284]: type annotations needed for `ArrayHolder<_>`
|
||||
--> $DIR/issue-62504.rs:26:9
|
||||
|
|
||||
|
@ -36,22 +52,6 @@ help: consider giving `array` an explicit type, where the value of const paramet
|
|||
LL | let mut array: ArrayHolder<X> = ArrayHolder::new();
|
||||
| ++++++++++++++++
|
||||
|
||||
error[E0284]: type annotations needed for `ArrayHolder<_>`
|
||||
--> $DIR/issue-62504.rs:26:9
|
||||
|
|
||||
LL | let mut array = ArrayHolder::new();
|
||||
| ^^^^^^^^^ ----------- type must be known at this point
|
||||
|
|
||||
note: required by a const generic parameter in `ArrayHolder`
|
||||
--> $DIR/issue-62504.rs:14:20
|
||||
|
|
||||
LL | struct ArrayHolder<const X: usize>([u32; X]);
|
||||
| ^^^^^^^^^^^^^^ required by this const generic parameter in `ArrayHolder`
|
||||
help: consider giving `array` an explicit type, where the value of const parameter `X` is specified
|
||||
|
|
||||
LL | let mut array: ArrayHolder<X> = ArrayHolder::new();
|
||||
| ++++++++++++++++
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0284, E0308.
|
||||
|
|
|
@ -20,6 +20,22 @@ note: tuple struct defined here
|
|||
LL | struct ArrayHolder<const X: usize>([u32; X]);
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error[E0284]: type annotations needed for `ArrayHolder<_>`
|
||||
--> $DIR/issue-62504.rs:26:9
|
||||
|
|
||||
LL | let mut array = ArrayHolder::new();
|
||||
| ^^^^^^^^^ ----------- type must be known at this point
|
||||
|
|
||||
note: required by a const generic parameter in `ArrayHolder`
|
||||
--> $DIR/issue-62504.rs:14:20
|
||||
|
|
||||
LL | struct ArrayHolder<const X: usize>([u32; X]);
|
||||
| ^^^^^^^^^^^^^^ required by this const generic parameter in `ArrayHolder`
|
||||
help: consider giving `array` an explicit type, where the value of const parameter `X` is specified
|
||||
|
|
||||
LL | let mut array: ArrayHolder<X> = ArrayHolder::new();
|
||||
| ++++++++++++++++
|
||||
|
||||
error[E0284]: type annotations needed for `ArrayHolder<_>`
|
||||
--> $DIR/issue-62504.rs:26:9
|
||||
|
|
||||
|
@ -38,22 +54,6 @@ help: consider giving `array` an explicit type, where the value of const paramet
|
|||
LL | let mut array: ArrayHolder<X> = ArrayHolder::new();
|
||||
| ++++++++++++++++
|
||||
|
||||
error[E0284]: type annotations needed for `ArrayHolder<_>`
|
||||
--> $DIR/issue-62504.rs:26:9
|
||||
|
|
||||
LL | let mut array = ArrayHolder::new();
|
||||
| ^^^^^^^^^ ----------- type must be known at this point
|
||||
|
|
||||
note: required by a const generic parameter in `ArrayHolder`
|
||||
--> $DIR/issue-62504.rs:14:20
|
||||
|
|
||||
LL | struct ArrayHolder<const X: usize>([u32; X]);
|
||||
| ^^^^^^^^^^^^^^ required by this const generic parameter in `ArrayHolder`
|
||||
help: consider giving `array` an explicit type, where the value of const parameter `X` is specified
|
||||
|
|
||||
LL | let mut array: ArrayHolder<X> = ArrayHolder::new();
|
||||
| ++++++++++++++++
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0284, E0308.
|
||||
|
|
|
@ -4,7 +4,7 @@ error: internal compiler error: compiler/rustc_const_eval/src/interpret/operator
|
|||
|
||||
Box<dyn Any>
|
||||
query stack during panic:
|
||||
#0 [eval_to_allocation_raw] const-evaluating + checking `<impl at $DIR/issue-80742.rs:26:1: 28:32>::{constant#0}`
|
||||
#0 [eval_to_allocation_raw] const-evaluating + checking `Inline::{constant#0}`
|
||||
#1 [eval_to_valtree] evaluating type-level constant
|
||||
... and 2 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
|
||||
error: aborting due to 1 previous error
|
||||
|
|
|
@ -1,12 +1,3 @@
|
|||
error[E0599]: no function or associated item named `assert` found for struct `Bool<{ std::mem::needs_drop::<T>() }>` in the current scope
|
||||
--> $DIR/const-needs_drop-monomorphic.rs:11:46
|
||||
|
|
||||
LL | struct Bool<const B: bool> {}
|
||||
| -------------------------- function or associated item `assert` not found for this struct
|
||||
...
|
||||
LL | Bool::<{ std::mem::needs_drop::<T>() }>::assert();
|
||||
| ^^^^^^ function or associated item cannot be called on `Bool<{ std::mem::needs_drop::<T>() }>` due to unsatisfied trait bounds
|
||||
|
||||
error: unconstrained generic constant
|
||||
--> $DIR/const-needs_drop-monomorphic.rs:11:5
|
||||
|
|
||||
|
@ -18,6 +9,15 @@ help: try adding a `where` bound
|
|||
LL | fn f<T>() where [(); { std::mem::needs_drop::<T>() } as usize]: {
|
||||
| +++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
error[E0599]: no function or associated item named `assert` found for struct `Bool<{ std::mem::needs_drop::<T>() }>` in the current scope
|
||||
--> $DIR/const-needs_drop-monomorphic.rs:11:46
|
||||
|
|
||||
LL | struct Bool<const B: bool> {}
|
||||
| -------------------------- function or associated item `assert` not found for this struct
|
||||
...
|
||||
LL | Bool::<{ std::mem::needs_drop::<T>() }>::assert();
|
||||
| ^^^^^^ function or associated item cannot be called on `Bool<{ std::mem::needs_drop::<T>() }>` due to unsatisfied trait bounds
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0599`.
|
||||
|
|
|
@ -52,6 +52,14 @@ LL | pub struct InvariantRef<'a, T: ?Sized>(&'a T, PhantomData<&'a mut &'a T>);
|
|||
LL | pub const NEW: Self = InvariantRef::new(&());
|
||||
| ^^^ function or associated item not found in `InvariantRef<'_, _>`
|
||||
|
||||
error[E0277]: the trait bound `u8: Trait` is not satisfied
|
||||
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:22:12
|
||||
|
|
||||
LL | reuse <u8 as Trait>::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW } }
|
||||
| ^^ the trait `Trait` is not implemented for `u8`
|
||||
|
|
||||
= help: the trait `Trait` is implemented for `Z`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:22:53
|
||||
|
|
||||
|
@ -68,6 +76,7 @@ LL | reuse <u8 as Trait>::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW
|
|||
| ^^ the trait `Trait` is not implemented for `u8`
|
||||
|
|
||||
= help: the trait `Trait` is implemented for `Z`
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:22:53
|
||||
|
@ -98,15 +107,6 @@ LL | reuse <u8 as Trait>::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW
|
|||
found struct `InvariantRef<'_, ()>`
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error[E0277]: the trait bound `u8: Trait` is not satisfied
|
||||
--> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:22:12
|
||||
|
|
||||
LL | reuse <u8 as Trait>::{foo, bar, meh} { &const { InvariantRef::<'a>::NEW } }
|
||||
| ^^ the trait `Trait` is not implemented for `u8`
|
||||
|
|
||||
= help: the trait `Trait` is implemented for `Z`
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0261, E0277, E0308, E0599.
|
||||
|
|
|
@ -1,17 +1,3 @@
|
|||
error[E0599]: the function or associated item `default` exists for associated type `<T as Bop>::Bar`, but its trait bounds were not satisfied
|
||||
--> $DIR/assoc_type_bounds_sized_used.rs:11:30
|
||||
|
|
||||
LL | let _ = <T as Bop>::Bar::default();
|
||||
| ^^^^^^^ function or associated item cannot be called on `<T as Bop>::Bar` due to unsatisfied trait bounds
|
||||
|
|
||||
= note: the following trait bounds were not satisfied:
|
||||
`T: Sized`
|
||||
which is required by `<T as Bop>::Bar: Default`
|
||||
help: consider restricting the type parameter to satisfy the trait bound
|
||||
|
|
||||
LL | fn bop<T: Bop + ?Sized>() where T: Sized {
|
||||
| ++++++++++++++
|
||||
|
||||
error[E0277]: the size for values of type `T` cannot be known at compilation time
|
||||
--> $DIR/assoc_type_bounds_sized_used.rs:11:14
|
||||
|
|
||||
|
@ -38,6 +24,20 @@ help: consider relaxing the implicit `Sized` restriction
|
|||
LL | type Bar: Default + ?Sized
|
||||
| ++++++++
|
||||
|
||||
error[E0599]: the function or associated item `default` exists for associated type `<T as Bop>::Bar`, but its trait bounds were not satisfied
|
||||
--> $DIR/assoc_type_bounds_sized_used.rs:11:30
|
||||
|
|
||||
LL | let _ = <T as Bop>::Bar::default();
|
||||
| ^^^^^^^ function or associated item cannot be called on `<T as Bop>::Bar` due to unsatisfied trait bounds
|
||||
|
|
||||
= note: the following trait bounds were not satisfied:
|
||||
`T: Sized`
|
||||
which is required by `<T as Bop>::Bar: Default`
|
||||
help: consider restricting the type parameter to satisfy the trait bound
|
||||
|
|
||||
LL | fn bop<T: Bop + ?Sized>() where T: Sized {
|
||||
| ++++++++++++++
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0277, E0599.
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
error[E0277]: the trait bound `RawImpl<_>: Raw<_>` is not satisfied
|
||||
--> $DIR/issue-62742.rs:4:5
|
||||
|
|
||||
LL | WrongImpl::foo(0i32);
|
||||
| ^^^^^^^^^ the trait `Raw<_>` is not implemented for `RawImpl<_>`
|
||||
|
|
||||
= help: the trait `Raw<_>` is not implemented for `RawImpl<_>`
|
||||
but trait `Raw<[_]>` is implemented for it
|
||||
note: required by a bound in `SafeImpl`
|
||||
--> $DIR/issue-62742.rs:33:35
|
||||
|
|
||||
LL | pub struct SafeImpl<T: ?Sized, A: Raw<T>>(PhantomData<(A, T)>);
|
||||
| ^^^^^^ required by this bound in `SafeImpl`
|
||||
|
||||
error[E0599]: the function or associated item `foo` exists for struct `SafeImpl<_, RawImpl<_>>`, but its trait bounds were not satisfied
|
||||
--> $DIR/issue-62742.rs:4:16
|
||||
|
|
||||
|
@ -23,14 +37,15 @@ note: the trait `Raw` must be implemented
|
|||
LL | pub trait Raw<T: ?Sized> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `RawImpl<_>: Raw<_>` is not satisfied
|
||||
--> $DIR/issue-62742.rs:4:5
|
||||
error[E0277]: the trait bound `RawImpl<()>: Raw<()>` is not satisfied
|
||||
--> $DIR/issue-62742.rs:10:5
|
||||
|
|
||||
LL | WrongImpl::foo(0i32);
|
||||
| ^^^^^^^^^ the trait `Raw<_>` is not implemented for `RawImpl<_>`
|
||||
LL | WrongImpl::<()>::foo(0i32);
|
||||
| ^^^^^^^^^^^^^^^ the trait `Raw<()>` is not implemented for `RawImpl<()>`
|
||||
|
|
||||
= help: the trait `Raw<_>` is not implemented for `RawImpl<_>`
|
||||
but trait `Raw<[_]>` is implemented for it
|
||||
= help: the trait `Raw<()>` is not implemented for `RawImpl<()>`
|
||||
but trait `Raw<[()]>` is implemented for it
|
||||
= help: for that trait implementation, expected `[()]`, found `()`
|
||||
note: required by a bound in `SafeImpl`
|
||||
--> $DIR/issue-62742.rs:33:35
|
||||
|
|
||||
|
@ -62,21 +77,6 @@ note: the trait `Raw` must be implemented
|
|||
LL | pub trait Raw<T: ?Sized> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `RawImpl<()>: Raw<()>` is not satisfied
|
||||
--> $DIR/issue-62742.rs:10:5
|
||||
|
|
||||
LL | WrongImpl::<()>::foo(0i32);
|
||||
| ^^^^^^^^^^^^^^^ the trait `Raw<()>` is not implemented for `RawImpl<()>`
|
||||
|
|
||||
= help: the trait `Raw<()>` is not implemented for `RawImpl<()>`
|
||||
but trait `Raw<[()]>` is implemented for it
|
||||
= help: for that trait implementation, expected `[()]`, found `()`
|
||||
note: required by a bound in `SafeImpl`
|
||||
--> $DIR/issue-62742.rs:33:35
|
||||
|
|
||||
LL | pub struct SafeImpl<T: ?Sized, A: Raw<T>>(PhantomData<(A, T)>);
|
||||
| ^^^^^^ required by this bound in `SafeImpl`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0277, E0599.
|
||||
|
|
|
@ -2,7 +2,7 @@ error[E0282]: type annotations needed
|
|||
--> $DIR/type-alias.rs:12:5
|
||||
|
|
||||
LL | DirectAlias::new()
|
||||
| ^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T`
|
||||
| ^^^^^^^^^^^ cannot infer type for type parameter `T` declared on the type alias `DirectAlias`
|
||||
|
||||
error[E0282]: type annotations needed
|
||||
--> $DIR/type-alias.rs:18:5
|
||||
|
@ -14,7 +14,7 @@ error[E0282]: type annotations needed
|
|||
--> $DIR/type-alias.rs:32:5
|
||||
|
|
||||
LL | DirectButWithDefaultAlias::new();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T` declared on the type alias `DirectButWithDefaultAlias`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
@ -21,4 +21,5 @@ fn main() {
|
|||
//~^ ERROR no function or associated item named `nonexistent` found
|
||||
//~| WARN trait objects without an explicit `dyn` are deprecated
|
||||
//~| WARN this is accepted in the current edition
|
||||
//~| ERROR the trait `Trait` is not dyn compatible
|
||||
}
|
||||
|
|
|
@ -12,12 +12,38 @@ help: if this is a dyn-compatible trait, use `dyn`
|
|||
LL | <dyn Trait>::nonexistent(());
|
||||
| ++++ +
|
||||
|
||||
error[E0038]: the trait `Trait` is not dyn compatible
|
||||
--> $DIR/issue-58734.rs:20:5
|
||||
|
|
||||
LL | Trait::nonexistent(());
|
||||
| ^^^^^ `Trait` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/issue-58734.rs:4:8
|
||||
|
|
||||
LL | trait Trait {
|
||||
| ----- this trait is not dyn compatible...
|
||||
...
|
||||
LL | fn dyn_incompatible() -> Self;
|
||||
| ^^^^^^^^^^^^^^^^ ...because associated function `dyn_incompatible` has no `self` parameter
|
||||
= help: only type `()` implements `Trait`; consider using it directly instead.
|
||||
help: consider turning `dyn_incompatible` into a method by giving it a `&self` argument
|
||||
|
|
||||
LL | fn dyn_incompatible(&self) -> Self;
|
||||
| +++++
|
||||
help: alternatively, consider constraining `dyn_incompatible` so it does not apply to trait objects
|
||||
|
|
||||
LL | fn dyn_incompatible() -> Self where Self: Sized;
|
||||
| +++++++++++++++++
|
||||
|
||||
error[E0599]: no function or associated item named `nonexistent` found for trait object `dyn Trait` in the current scope
|
||||
--> $DIR/issue-58734.rs:20:12
|
||||
|
|
||||
LL | Trait::nonexistent(());
|
||||
| ^^^^^^^^^^^ function or associated item not found in `dyn Trait`
|
||||
|
||||
error: aborting due to 1 previous error; 1 warning emitted
|
||||
error: aborting due to 2 previous errors; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0599`.
|
||||
Some errors have detailed explanations: E0038, E0599.
|
||||
For more information about an error, try `rustc --explain E0038`.
|
||||
|
|
|
@ -9,10 +9,10 @@ note: required by a bound in `std::iter::IntoIterator::IntoIter`
|
|||
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
|
||||
|
||||
error[E0275]: overflow evaluating the requirement `&_: IntoIterator`
|
||||
--> $DIR/inherent-bound-in-probe.rs:44:17
|
||||
--> $DIR/inherent-bound-in-probe.rs:44:9
|
||||
|
|
||||
LL | Helper::new(&self.0)
|
||||
| ^^^
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`inherent_bound_in_probe`)
|
||||
note: required for `&BitReaderWrapper<_>` to implement `IntoIterator`
|
||||
|
@ -25,11 +25,14 @@ LL | &'a T: IntoIterator<Item = &'a u8>,
|
|||
| ------------- unsatisfied trait bound introduced here
|
||||
= note: 126 redundant requirements hidden
|
||||
= note: required for `&BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<_>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `IntoIterator`
|
||||
note: required by a bound in `Helper<'a, T>`
|
||||
--> $DIR/inherent-bound-in-probe.rs:25:25
|
||||
note: required by a bound in `Helper`
|
||||
--> $DIR/inherent-bound-in-probe.rs:18:12
|
||||
|
|
||||
LL | struct Helper<'a, T>
|
||||
| ------ required by a bound in this struct
|
||||
LL | where
|
||||
LL | &'a T: IntoIterator<Item = &'a u8>,
|
||||
| ^^^^^^^^^^^^^ required by this bound in `Helper<'a, T>`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Helper`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -98,9 +98,12 @@ fn check_assoc_const() {
|
|||
S::B; //~ ERROR no associated item named `B` found
|
||||
S::C; // OK
|
||||
// A, B, C are resolved as inherent items, their traits don't need to be in scope
|
||||
<dyn C>::A; //~ ERROR associated constant `A` is private
|
||||
<dyn C>::A;
|
||||
//~^ ERROR associated constant `A` is private
|
||||
//~| ERROR the trait `assoc_const::C` is not dyn compatible
|
||||
//~| ERROR the trait `assoc_const::C` is not dyn compatible
|
||||
<dyn C>::B;
|
||||
//~^ ERROR the trait `assoc_const::C` is not dyn compatible
|
||||
<dyn C>::B; // ERROR the trait `assoc_const::C` is not dyn compatible
|
||||
C::C; // OK
|
||||
}
|
||||
|
||||
|
|
|
@ -130,15 +130,6 @@ help: trait `B` which provides `B` is implemented but not in scope; perhaps you
|
|||
LL + use assoc_const::B;
|
||||
|
|
||||
|
||||
error[E0624]: associated constant `A` is private
|
||||
--> $DIR/item-privacy.rs:101:14
|
||||
|
|
||||
LL | const A: u8 = 0;
|
||||
| ----------- private associated constant defined here
|
||||
...
|
||||
LL | <dyn C>::A;
|
||||
| ^ private associated constant
|
||||
|
||||
error[E0038]: the trait `assoc_const::C` is not dyn compatible
|
||||
--> $DIR/item-privacy.rs:101:6
|
||||
|
|
||||
|
@ -164,8 +155,67 @@ LL | const C: u8 = 0;
|
|||
= help: consider moving `B` to another trait
|
||||
= help: only type `S` implements `assoc_const::C`; consider using it directly instead.
|
||||
|
||||
error[E0624]: associated constant `A` is private
|
||||
--> $DIR/item-privacy.rs:101:14
|
||||
|
|
||||
LL | const A: u8 = 0;
|
||||
| ----------- private associated constant defined here
|
||||
...
|
||||
LL | <dyn C>::A;
|
||||
| ^ private associated constant
|
||||
|
||||
error[E0038]: the trait `assoc_const::C` is not dyn compatible
|
||||
--> $DIR/item-privacy.rs:101:5
|
||||
|
|
||||
LL | <dyn C>::A;
|
||||
| ^^^^^^^^^^ `assoc_const::C` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/item-privacy.rs:25:15
|
||||
|
|
||||
LL | const A: u8 = 0;
|
||||
| ^ ...because it contains this associated `const`
|
||||
...
|
||||
LL | const B: u8 = 0;
|
||||
| ^ ...because it contains this associated `const`
|
||||
...
|
||||
LL | pub trait C: A + B {
|
||||
| - this trait is not dyn compatible...
|
||||
LL | const C: u8 = 0;
|
||||
| ^ ...because it contains this associated `const`
|
||||
= help: consider moving `C` to another trait
|
||||
= help: consider moving `A` to another trait
|
||||
= help: consider moving `B` to another trait
|
||||
= help: only type `S` implements `assoc_const::C`; consider using it directly instead.
|
||||
|
||||
error[E0038]: the trait `assoc_const::C` is not dyn compatible
|
||||
--> $DIR/item-privacy.rs:105:5
|
||||
|
|
||||
LL | <dyn C>::B;
|
||||
| ^^^^^^^^^^ `assoc_const::C` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/item-privacy.rs:25:15
|
||||
|
|
||||
LL | const A: u8 = 0;
|
||||
| ^ ...because it contains this associated `const`
|
||||
...
|
||||
LL | const B: u8 = 0;
|
||||
| ^ ...because it contains this associated `const`
|
||||
...
|
||||
LL | pub trait C: A + B {
|
||||
| - this trait is not dyn compatible...
|
||||
LL | const C: u8 = 0;
|
||||
| ^ ...because it contains this associated `const`
|
||||
= help: consider moving `C` to another trait
|
||||
= help: consider moving `A` to another trait
|
||||
= help: consider moving `B` to another trait
|
||||
= help: only type `S` implements `assoc_const::C`; consider using it directly instead.
|
||||
|
||||
error[E0223]: ambiguous associated type
|
||||
--> $DIR/item-privacy.rs:115:12
|
||||
--> $DIR/item-privacy.rs:118:12
|
||||
|
|
||||
LL | let _: S::A;
|
||||
| ^^^^
|
||||
|
@ -177,19 +227,19 @@ LL + let _: <S as Example>::A;
|
|||
|
|
||||
|
||||
error[E0223]: ambiguous associated type
|
||||
--> $DIR/item-privacy.rs:116:12
|
||||
--> $DIR/item-privacy.rs:119:12
|
||||
|
|
||||
LL | let _: S::B;
|
||||
| ^^^^ help: use fully-qualified syntax: `<S as assoc_ty::B>::B`
|
||||
|
||||
error[E0223]: ambiguous associated type
|
||||
--> $DIR/item-privacy.rs:117:12
|
||||
--> $DIR/item-privacy.rs:120:12
|
||||
|
|
||||
LL | let _: S::C;
|
||||
| ^^^^ help: use fully-qualified syntax: `<S as assoc_ty::C>::C`
|
||||
|
||||
error[E0624]: associated type `A` is private
|
||||
--> $DIR/item-privacy.rs:119:12
|
||||
--> $DIR/item-privacy.rs:122:12
|
||||
|
|
||||
LL | type A = u8;
|
||||
| ------ the associated type is defined here
|
||||
|
@ -198,7 +248,7 @@ LL | let _: T::A;
|
|||
| ^^^^ private associated type
|
||||
|
||||
error[E0624]: associated type `A` is private
|
||||
--> $DIR/item-privacy.rs:128:9
|
||||
--> $DIR/item-privacy.rs:131:9
|
||||
|
|
||||
LL | type A = u8;
|
||||
| ------ the associated type is defined here
|
||||
|
@ -206,7 +256,7 @@ LL | type A = u8;
|
|||
LL | A = u8,
|
||||
| ^^^^^^ private associated type
|
||||
|
||||
error: aborting due to 15 previous errors
|
||||
error: aborting due to 17 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0038, E0223, E0599, E0624.
|
||||
For more information about an error, try `rustc --explain E0038`.
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
//@ compile-flags: -Znext-solver
|
||||
//@ check-pass
|
||||
|
||||
// A regression test for trait-system-refactor-initiative#161
|
||||
|
||||
trait Constrain<T> {
|
||||
type Assoc;
|
||||
}
|
||||
impl<T> Constrain<T> for () {
|
||||
type Assoc = ();
|
||||
}
|
||||
struct Foo<T, U = <() as Constrain<T>>::Assoc>(T, U);
|
||||
|
||||
impl<T: Copy> Foo<T> {
|
||||
fn foo() {}
|
||||
}
|
||||
struct B;
|
||||
impl Foo<B> {
|
||||
fn foo() {}
|
||||
}
|
||||
|
||||
type Alias<T> = Foo<T>;
|
||||
fn via_guidance<T: Copy>()
|
||||
where
|
||||
(): Constrain<T>,
|
||||
{
|
||||
// Method selection on `Foo<?t, <() as Constrain<?t>>::Assoc>` is ambiguous.
|
||||
// only by unnecessarily constraining `?t` to `T` when proving `(): Constrain<?t>`
|
||||
// are we able to select the first impl.
|
||||
//
|
||||
// This happens in the old solver when normalizing `Alias<?t>`. The new solver doesn't try
|
||||
// to eagerly normalize `<() as Constrain<?t>>::Assoc` so we instead always prove that the
|
||||
// self type is well-formed before method lookup.
|
||||
Alias::foo();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
via_guidance::<()>();
|
||||
}
|
|
@ -7,6 +7,15 @@ LL | let x = <Foo as Trait<Bar>>::Assoc::default();
|
|||
= help: the trait `Trait<Bar>` is not implemented for `Foo`
|
||||
but trait `Trait<()>` is implemented for it
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
error[E0277]: the trait bound `Foo: Trait<Bar>` is not satisfied
|
||||
--> $DIR/constrain_in_projection.rs:24:13
|
||||
|
|
||||
LL | let x = <Foo as Trait<Bar>>::Assoc::default();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<Bar>` is not implemented for `Foo`
|
||||
|
|
||||
= help: the trait `Trait<Bar>` is not implemented for `Foo`
|
||||
but trait `Trait<()>` is implemented for it
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
|
@ -23,6 +23,7 @@ impl Trait<()> for Foo {
|
|||
fn bop(_: Bar) {
|
||||
let x = <Foo as Trait<Bar>>::Assoc::default();
|
||||
//[current]~^ `Foo: Trait<Bar>` is not satisfied
|
||||
//[current]~| `Foo: Trait<Bar>` is not satisfied
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -8,6 +8,16 @@ LL | let x = <Foo as Trait<Bar>>::Assoc::default();
|
|||
`Foo` implements `Trait<()>`
|
||||
`Foo` implements `Trait<u32>`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
error[E0277]: the trait bound `Foo: Trait<Bar>` is not satisfied
|
||||
--> $DIR/constrain_in_projection2.rs:27:13
|
||||
|
|
||||
LL | let x = <Foo as Trait<Bar>>::Assoc::default();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<Bar>` is not implemented for `Foo`
|
||||
|
|
||||
= help: the following other types implement trait `Trait<T>`:
|
||||
`Foo` implements `Trait<()>`
|
||||
`Foo` implements `Trait<u32>`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
|
@ -27,6 +27,7 @@ fn bop(_: Bar) {
|
|||
let x = <Foo as Trait<Bar>>::Assoc::default();
|
||||
//[next]~^ ERROR: cannot satisfy `Foo: Trait<Bar>`
|
||||
//[current]~^^ ERROR: `Foo: Trait<Bar>` is not satisfied
|
||||
//[current]~| ERROR: `Foo: Trait<Bar>` is not satisfied
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue