Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion compiler/rustc_hir_analysis/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,6 @@ pub(super) fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, def_id:

assert_eq!(predicates.predicates.len(), predicates.spans.len());
let wf_obligations = predicates.into_iter().flat_map(|(p, sp)| {
let p = wfcx.normalize(sp, None, p);
traits::wf::clause_obligations(infcx, wfcx.param_env, wfcx.body_def_id, p, sp)
});
let obligations: Vec<_> = wf_obligations.chain(default_obligations).collect();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ fn take(
K = { () }
>,
) {}
//~^^^^^ ERROR implementation of `Project` is not general enough
//~^^^^ ERROR higher-ranked subtype error
//~^^^ ERROR higher-ranked subtype error
//~| ERROR higher-ranked subtype error

trait Project { type Out; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,5 @@ LL | K = { () }
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: implementation of `Project` is not general enough
--> $DIR/assoc-const-eq-bound-var-in-ty-not-wf.rs:10:13
|
LL | _: impl Trait<
| _____________^
LL | | <<for<'a> fn(&'a str) -> &'a str as Project>::Out as Discard>::Out,
LL | | K = { () }
LL | | >,
| |_____^ implementation of `Project` is not general enough
|
= note: `Project` would have to be implemented for the type `for<'a> fn(&'a str) -> &'a str`
= note: ...but `Project` is actually implemented for the type `fn(&'0 str) -> &'0 str`, for some specific lifetime `'0`

error: aborting due to 3 previous errors
error: aborting due to 2 previous errors

10 changes: 5 additions & 5 deletions tests/ui/associated-types/issue-38821.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ pub trait Column: Expression {}
//~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
//~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
//~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
pub enum ColumnInsertValue<Col, Expr> where
//~^ ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
Col: Column,
Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
//~^ ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
//~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
//~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
//~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
//~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
//~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
pub enum ColumnInsertValue<Col, Expr> where
//~^ ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
Col: Column,
Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
//~^ ERROR the trait bound `<Col as Expression>::SqlType: IntoNullable` is not satisfied
{
Expression(Col, Expr),
Default(Col),
Expand Down
61 changes: 42 additions & 19 deletions tests/ui/associated-types/issue-38821.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
--> $DIR/issue-38821.rs:35:1
--> $DIR/issue-38821.rs:40:1
|
LL | pub enum ColumnInsertValue<Col, Expr> where
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
Expand All @@ -16,8 +16,8 @@ help: consider extending the `where` clause, but there might be an alternative b
LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Col as Expression>::SqlType: NotNull
| +++++++++++++++++++++++++++++++++++++

error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
--> $DIR/issue-38821.rs:38:22
error[E0277]: the trait bound `<Col as Expression>::SqlType: IntoNullable` is not satisfied
--> $DIR/issue-38821.rs:43:22
|
LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
Expand Down Expand Up @@ -82,10 +82,10 @@ LL | impl<T: NotNull> IntoNullable for T {
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
--> $DIR/issue-38821.rs:38:22
--> $DIR/issue-38821.rs:23:10
|
LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
LL | #[derive(Debug, Copy, Clone)]
| ^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
|
note: required for `<Col as Expression>::SqlType` to implement `IntoNullable`
--> $DIR/issue-38821.rs:9:18
Expand All @@ -94,6 +94,14 @@ LL | impl<T: NotNull> IntoNullable for T {
| ------- ^^^^^^^^^^^^ ^
| |
| unsatisfied trait bound introduced here
note: required for `ColumnInsertValue<Col, Expr>` to implement `Debug`
--> $DIR/issue-38821.rs:23:10
|
LL | #[derive(Debug, Copy, Clone)]
| ^^^^^
...
LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
| ------------------------------------------------ unsatisfied trait bound introduced in this `derive` macro
help: consider further restricting the associated type
|
LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Col as Expression>::SqlType: NotNull,
Expand All @@ -118,10 +126,10 @@ LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Co
| +++++++++++++++++++++++++++++++++++++++

error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
--> $DIR/issue-38821.rs:38:22
--> $DIR/issue-38821.rs:23:17
|
LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
LL | #[derive(Debug, Copy, Clone)]
| ^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
|
note: required for `<Col as Expression>::SqlType` to implement `IntoNullable`
--> $DIR/issue-38821.rs:9:18
Expand All @@ -130,6 +138,14 @@ LL | impl<T: NotNull> IntoNullable for T {
| ------- ^^^^^^^^^^^^ ^
| |
| unsatisfied trait bound introduced here
note: required for `ColumnInsertValue<Col, Expr>` to implement `Copy`
--> $DIR/issue-38821.rs:23:17
|
LL | #[derive(Debug, Copy, Clone)]
| ^^^^
...
LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
| ------------------------------------------------ unsatisfied trait bound introduced in this `derive` macro
help: consider further restricting the associated type
|
LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Col as Expression>::SqlType: NotNull,
Expand Down Expand Up @@ -183,10 +199,10 @@ LL | impl<T: NotNull> IntoNullable for T {
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
--> $DIR/issue-38821.rs:38:22
--> $DIR/issue-38821.rs:23:23
|
LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
LL | #[derive(Debug, Copy, Clone)]
| ^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
|
note: required for `<Col as Expression>::SqlType` to implement `IntoNullable`
--> $DIR/issue-38821.rs:9:18
Expand All @@ -195,6 +211,14 @@ LL | impl<T: NotNull> IntoNullable for T {
| ------- ^^^^^^^^^^^^ ^
| |
| unsatisfied trait bound introduced here
note: required for `ColumnInsertValue<Col, Expr>` to implement `Clone`
--> $DIR/issue-38821.rs:23:23
|
LL | #[derive(Debug, Copy, Clone)]
| ^^^^^
...
LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
| ------------------------------------------------ unsatisfied trait bound introduced in this `derive` macro
help: consider further restricting the associated type
|
LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Col as Expression>::SqlType: NotNull,
Expand All @@ -216,10 +240,10 @@ LL | impl<T: NotNull> IntoNullable for T {
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
--> $DIR/issue-38821.rs:38:22
--> $DIR/issue-38821.rs:23:10
|
LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
LL | #[derive(Debug, Copy, Clone)]
| ^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
|
note: required for `<Col as Expression>::SqlType` to implement `IntoNullable`
--> $DIR/issue-38821.rs:9:18
Expand All @@ -245,10 +269,10 @@ LL | impl<T: NotNull> IntoNullable for T {
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
--> $DIR/issue-38821.rs:38:22
--> $DIR/issue-38821.rs:23:23
|
LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
LL | #[derive(Debug, Copy, Clone)]
| ^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType`
|
note: required for `<Col as Expression>::SqlType` to implement `IntoNullable`
--> $DIR/issue-38821.rs:9:18
Expand All @@ -257,7 +281,6 @@ LL | impl<T: NotNull> IntoNullable for T {
| ------- ^^^^^^^^^^^^ ^
| |
| unsatisfied trait bound introduced here
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied
--> $DIR/issue-38821.rs:23:10
Expand Down
3 changes: 0 additions & 3 deletions tests/ui/lifetimes/issue-76168-hr-outlives-3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ async fn wrapper<F>(f: F)
where
F:,
for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
//~^ ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32`
//~| ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32`
//~| ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32`
{
//~^ ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32`
let mut i = 41;
Expand Down
28 changes: 2 additions & 26 deletions tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,6 @@ LL | | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a
|
= help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `i32`

error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32`
--> $DIR/issue-76168-hr-outlives-3.rs:12:50
|
LL | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
| ^^^^^^^^^^^^^^^^^^^ expected an `FnOnce(&'a mut i32)` closure, found `i32`
|
= help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `i32`

error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32`
--> $DIR/issue-76168-hr-outlives-3.rs:12:57
|
LL | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
| ^^^^^^^^^^^ expected an `FnOnce(&'a mut i32)` closure, found `i32`
|
= help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `i32`

error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32`
--> $DIR/issue-76168-hr-outlives-3.rs:12:72
|
LL | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
| ^^ expected an `FnOnce(&'a mut i32)` closure, found `i32`
|
= help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `i32`

error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32`
--> $DIR/issue-76168-hr-outlives-3.rs:6:1
|
Expand All @@ -57,7 +33,7 @@ LL | | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32`
--> $DIR/issue-76168-hr-outlives-3.rs:16:1
--> $DIR/issue-76168-hr-outlives-3.rs:13:1
|
LL | / {
LL | |
Expand All @@ -68,6 +44,6 @@ LL | | }
|
= help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `i32`

error: aborting due to 7 previous errors
error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0277`.
2 changes: 0 additions & 2 deletions tests/ui/methods/filter-relevant-fn-bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ impl Wrapper {
//~^ ERROR the trait bound `for<'a> F: Output<'a>` is not satisfied
where
F: for<'a> FnOnce(<F as Output<'a>>::Type),
//~^ ERROR the trait bound `for<'a> F: Output<'a>` is not satisfied
//~| ERROR the trait bound `for<'a> F: Output<'a>` is not satisfied
{
}
}
Expand Down
32 changes: 5 additions & 27 deletions tests/ui/methods/filter-relevant-fn-bounds.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,15 @@ help: consider further restricting type parameter `F` with trait `Output`
LL | F: for<'a> FnOnce(<F as Output<'a>>::Type) + for<'a> Output<'a>,
| ++++++++++++++++++++

error[E0277]: the trait bound `for<'a> F: Output<'a>` is not satisfied
--> $DIR/filter-relevant-fn-bounds.rs:11:12
|
LL | F: for<'a> FnOnce(<F as Output<'a>>::Type),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Output<'a>` is not implemented for `F`
|
help: consider further restricting type parameter `F` with trait `Output`
|
LL | F: for<'a> FnOnce(<F as Output<'a>>::Type) + for<'a> Output<'a>,
| ++++++++++++++++++++

error[E0277]: the trait bound `for<'a> F: Output<'a>` is not satisfied
--> $DIR/filter-relevant-fn-bounds.rs:11:20
|
LL | F: for<'a> FnOnce(<F as Output<'a>>::Type),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Output<'a>` is not implemented for `F`
|
help: consider further restricting type parameter `F` with trait `Output`
|
LL | F: for<'a> FnOnce(<F as Output<'a>>::Type) + for<'a> Output<'a>,
| ++++++++++++++++++++

error[E0277]: expected a `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:20:34: 20:41} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:20:34: 20:41}`
--> $DIR/filter-relevant-fn-bounds.rs:20:34
error[E0277]: expected a `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:18:34: 18:41} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:18:34: 18:41}`
--> $DIR/filter-relevant-fn-bounds.rs:18:34
|
LL | wrapper.do_something_wrapper(|value| ());
| -------------------- ^^^^^^^^^^ expected an `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:20:34: 20:41} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:20:34: 20:41}`
| -------------------- ^^^^^^^^^^ expected an `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:18:34: 18:41} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:18:34: 18:41}`
| |
| required by a bound introduced by this call
|
= help: the trait `for<'a> Output<'a>` is not implemented for closure `{closure@$DIR/filter-relevant-fn-bounds.rs:20:34: 20:41}`
= help: the trait `for<'a> Output<'a>` is not implemented for closure `{closure@$DIR/filter-relevant-fn-bounds.rs:18:34: 18:41}`
help: this trait has no implementations, consider adding one
--> $DIR/filter-relevant-fn-bounds.rs:1:1
|
Expand All @@ -57,6 +35,6 @@ LL | fn do_something_wrapper<O, F>(self, _: F)
LL | F: for<'a> FnOnce(<F as Output<'a>>::Type),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Wrapper::do_something_wrapper`

error: aborting due to 4 previous errors
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.
1 change: 1 addition & 0 deletions tests/ui/regions/regions-normalize-in-where-clause-list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ fn bar<'a, 'b>()
where
<() as Project<'a, 'b>>::Item: Eq,
//~^ ERROR cannot infer
//~| ERROR cannot infer
{
}

Expand Down
27 changes: 26 additions & 1 deletion tests/ui/regions/regions-normalize-in-where-clause-list.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,31 @@ LL | <() as Project<'a, 'b>>::Item: Eq,
= note: expected `Project<'a, 'b>`
found `Project<'_, '_>`

error: aborting due to 1 previous error
error[E0803]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
--> $DIR/regions-normalize-in-where-clause-list.rs:26:36
|
LL | <() as Project<'a, 'b>>::Item: Eq,
| ^^
|
note: first, the lifetime cannot outlive the lifetime `'a` as defined here...
--> $DIR/regions-normalize-in-where-clause-list.rs:24:8
|
LL | fn bar<'a, 'b>()
| ^^
note: ...but the lifetime must also be valid for the lifetime `'b` as defined here...
--> $DIR/regions-normalize-in-where-clause-list.rs:24:12
|
LL | fn bar<'a, 'b>()
| ^^
note: ...so that the types are compatible
--> $DIR/regions-normalize-in-where-clause-list.rs:26:36
|
LL | <() as Project<'a, 'b>>::Item: Eq,
| ^^
= note: expected `Project<'a, 'b>`
found `Project<'_, '_>`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0803`.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ enum RefIndirect<'a, T> {
enum RefDouble<'a, 'b, T> {
RefDoubleVariant1(&'a RequireOutlives<'b, T>),
//~^ ERROR the parameter type `T` may not live long enough [E0309]
//~| ERROR the parameter type `T` may not live long enough [E0309]
}

fn main() {}
16 changes: 15 additions & 1 deletion tests/ui/rfcs/rfc-2093-infer-outlives/regions-enum-not-wf.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ help: consider adding an explicit lifetime bound
LL | enum RefDouble<'a, 'b, T: 'b> {
| ++++

error: aborting due to 3 previous errors
error[E0309]: the parameter type `T` may not live long enough
--> $DIR/regions-enum-not-wf.rs:35:23
|
LL | enum RefDouble<'a, 'b, T> {
| -- the parameter type `T` must be valid for the lifetime `'b` as defined here...
LL | RefDoubleVariant1(&'a RequireOutlives<'b, T>),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: consider adding an explicit lifetime bound
|
LL | enum RefDouble<'a, 'b, T: 'b> {
| ++++

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0309`.
Loading
Loading