use diesel::prelude::*; // 2.1.5
table! {
users(id) {
id -> Integer,
name -> Text,
}
}
#[derive(Insertable)]
struct User {
id: String,
name: i32,
}
fn main() {}
I expected to see a meaningful error that points to the relevant fields that cause this issue:
error[E0277]: the trait bound `String: diesel::Expression` is not satisfied
--> src/main.rs:12:5
|
12 | id: String,
| ^^ the trait `diesel::Expression` is not implemented for `String`
|
= help: the following other types implement trait `diesel::Expression`:
columns::name
columns::id
Box<T>
columns::star
diesel::expression::ops::numeric::Add<Lhs, Rhs>
diesel::expression::ops::numeric::Sub<Lhs, Rhs>
diesel::expression::ops::numeric::Mul<Lhs, Rhs>
diesel::expression::ops::numeric::Div<Lhs, Rhs>
and 119 others
= note: required for `String` to implement `AsExpression<diesel::sql_types::Integer>`
error[E0277]: the trait bound `i32: diesel::Expression` is not satisfied
--> src/main.rs:13:5
|
13 | name: i32,
| ^^^^ the trait `diesel::Expression` is not implemented for `i32`
|
= help: the following other types implement trait `diesel::Expression`:
columns::name
columns::id
Box<T>
columns::star
diesel::expression::ops::numeric::Add<Lhs, Rhs>
diesel::expression::ops::numeric::Sub<Lhs, Rhs>
diesel::expression::ops::numeric::Mul<Lhs, Rhs>
diesel::expression::ops::numeric::Div<Lhs, Rhs>
and 119 others
= note: required for `i32` to implement `AsExpression<diesel::sql_types::Text>`
error[E0277]: the trait bound `String: diesel::Expression` is not satisfied
--> src/main.rs:12:5
|
12 | id: String,
| ^^ the trait `diesel::Expression` is not implemented for `String`
|
= help: the following other types implement trait `diesel::Expression`:
columns::name
columns::id
Box<T>
columns::star
diesel::expression::ops::numeric::Add<Lhs, Rhs>
diesel::expression::ops::numeric::Sub<Lhs, Rhs>
diesel::expression::ops::numeric::Mul<Lhs, Rhs>
diesel::expression::ops::numeric::Div<Lhs, Rhs>
and 119 others
= note: required for `&'insert String` to implement `diesel::Expression`
= note: required for `&'insert String` to implement `AsExpression<diesel::sql_types::Integer>`
error[E0277]: the trait bound `i32: diesel::Expression` is not satisfied
--> src/main.rs:13:5
|
13 | name: i32,
| ^^^^ the trait `diesel::Expression` is not implemented for `i32`
|
= help: the following other types implement trait `diesel::Expression`:
columns::name
columns::id
Box<T>
columns::star
diesel::expression::ops::numeric::Add<Lhs, Rhs>
diesel::expression::ops::numeric::Sub<Lhs, Rhs>
diesel::expression::ops::numeric::Mul<Lhs, Rhs>
diesel::expression::ops::numeric::Div<Lhs, Rhs>
and 119 others
= note: required for `&'insert i32` to implement `diesel::Expression`
= note: required for `&'insert i32` to implement `AsExpression<diesel::sql_types::Text>`
Instead, this happened: Rustc emits an error message that duplicates the actual error several times. First it only points to the derive, later versions of the same error message point to the correct fields:
error[E0277]: the trait bound `String: diesel::Expression` is not satisfied
--> src/main.rs:10:10
|
10 | #[derive(Insertable)]
| ^^^^^^^^^^ the trait `diesel::Expression` is not implemented for `String`, which is required by `String: AsExpression<diesel::sql_types::Integer>`
|
= help: the following other types implement trait `diesel::Expression`:
&'a T
(T0, T1)
(T0, T1, T2)
(T0, T1, T2, T3)
(T0, T1, T2, T3, T4)
(T0, T1, T2, T3, T4, T5)
(T0, T1, T2, T3, T4, T5, T6)
(T0, T1, T2, T3, T4, T5, T6, T7)
and 119 others
= note: required for `String` to implement `AsExpression<diesel::sql_types::Integer>`
= note: this error originates in the derive macro `Insertable` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `i32: diesel::Expression` is not satisfied
--> src/main.rs:10:10
|
10 | #[derive(Insertable)]
| ^^^^^^^^^^ the trait `diesel::Expression` is not implemented for `i32`, which is required by `i32: AsExpression<diesel::sql_types::Text>`
|
= help: the following other types implement trait `diesel::Expression`:
&'a T
(T0, T1)
(T0, T1, T2)
(T0, T1, T2, T3)
(T0, T1, T2, T3, T4)
(T0, T1, T2, T3, T4, T5)
(T0, T1, T2, T3, T4, T5, T6)
(T0, T1, T2, T3, T4, T5, T6, T7)
and 119 others
= note: required for `i32` to implement `AsExpression<diesel::sql_types::Text>`
= note: this error originates in the derive macro `Insertable` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `String: diesel::Expression` is not satisfied
--> src/main.rs:10:10
|
10 | #[derive(Insertable)]
| ^^^^^^^^^^ the trait `diesel::Expression` is not implemented for `String`, which is required by `&'insert String: AsExpression<diesel::sql_types::Integer>`
|
= help: the following other types implement trait `diesel::Expression`:
&'a T
(T0, T1)
(T0, T1, T2)
(T0, T1, T2, T3)
(T0, T1, T2, T3, T4)
(T0, T1, T2, T3, T4, T5)
(T0, T1, T2, T3, T4, T5, T6)
(T0, T1, T2, T3, T4, T5, T6, T7)
and 119 others
= note: required for `&'insert String` to implement `diesel::Expression`
= note: required for `&'insert String` to implement `AsExpression<diesel::sql_types::Integer>`
= note: this error originates in the derive macro `Insertable` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `i32: diesel::Expression` is not satisfied
--> src/main.rs:10:10
|
10 | #[derive(Insertable)]
| ^^^^^^^^^^ the trait `diesel::Expression` is not implemented for `i32`, which is required by `&'insert i32: AsExpression<diesel::sql_types::Text>`
|
= help: the following other types implement trait `diesel::Expression`:
&'a T
(T0, T1)
(T0, T1, T2)
(T0, T1, T2, T3)
(T0, T1, T2, T3, T4)
(T0, T1, T2, T3, T4, T5)
(T0, T1, T2, T3, T4, T5, T6)
(T0, T1, T2, T3, T4, T5, T6, T7)
and 119 others
= note: required for `&'insert i32` to implement `diesel::Expression`
= note: required for `&'insert i32` to implement `AsExpression<diesel::sql_types::Text>`
= note: this error originates in the derive macro `Insertable` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `String: diesel::Expression` is not satisfied
--> src/main.rs:12:5
|
12 | id: String,
| ^^ the trait `diesel::Expression` is not implemented for `String`, which is required by `String: AsExpression<diesel::sql_types::Integer>`
|
= help: the following other types implement trait `diesel::Expression`:
&'a T
(T0, T1)
(T0, T1, T2)
(T0, T1, T2, T3)
(T0, T1, T2, T3, T4)
(T0, T1, T2, T3, T4, T5)
(T0, T1, T2, T3, T4, T5, T6)
(T0, T1, T2, T3, T4, T5, T6, T7)
and 119 others
= note: required for `String` to implement `AsExpression<diesel::sql_types::Integer>`
error[E0277]: the trait bound `i32: diesel::Expression` is not satisfied
--> src/main.rs:13:5
|
13 | name: i32,
| ^^^^ the trait `diesel::Expression` is not implemented for `i32`, which is required by `i32: AsExpression<diesel::sql_types::Text>`
|
= help: the following other types implement trait `diesel::Expression`:
&'a T
(T0, T1)
(T0, T1, T2)
(T0, T1, T2, T3)
(T0, T1, T2, T3, T4)
(T0, T1, T2, T3, T4, T5)
(T0, T1, T2, T3, T4, T5, T6)
(T0, T1, T2, T3, T4, T5, T6, T7)
and 119 others
= note: required for `i32` to implement `AsExpression<diesel::sql_types::Text>`
error[E0277]: the trait bound `String: diesel::Expression` is not satisfied
--> src/main.rs:12:5
|
12 | id: String,
| ^^ the trait `diesel::Expression` is not implemented for `String`, which is required by `&'insert String: AsExpression<diesel::sql_types::Integer>`
|
= help: the following other types implement trait `diesel::Expression`:
&'a T
(T0, T1)
(T0, T1, T2)
(T0, T1, T2, T3)
(T0, T1, T2, T3, T4)
(T0, T1, T2, T3, T4, T5)
(T0, T1, T2, T3, T4, T5, T6)
(T0, T1, T2, T3, T4, T5, T6, T7)
and 119 others
= note: required for `&'insert String` to implement `diesel::Expression`
= note: required for `&'insert String` to implement `AsExpression<diesel::sql_types::Integer>`
error[E0277]: the trait bound `i32: diesel::Expression` is not satisfied
--> src/main.rs:13:5
|
13 | name: i32,
| ^^^^ the trait `diesel::Expression` is not implemented for `i32`, which is required by `&'insert i32: AsExpression<diesel::sql_types::Text>`
|
= help: the following other types implement trait `diesel::Expression`:
&'a T
(T0, T1)
(T0, T1, T2)
(T0, T1, T2, T3)
(T0, T1, T2, T3, T4)
(T0, T1, T2, T3, T4, T5)
(T0, T1, T2, T3, T4, T5, T6)
(T0, T1, T2, T3, T4, T5, T6, T7)
and 119 others
= note: required for `&'insert i32` to implement `diesel::Expression`
= note: required for `&'insert i32` to implement `AsExpression<diesel::sql_types::Text>`
I've checked the stable rust versions in between and the error message first changes in 1.75 which introduces the messages that point to #[derive(Insertable)] but back then these were shown at the end of the output instead as first error message. Bisecting between the two stable releases points to https://github.com/rust-lang/rust/pull/117159 as PR that introduced the duplicated messages.
Bisect Log
Regression in https://github.com/rust-lang-ci/rust/commit/dc8cfe13cc0d7e7d320f9be78932717fe80846a8
The PR introducing the regression in this rollup is #117159: Work around the fact that `check_mod_type_wf` may spuriousl…
searched nightlies: from nightly-2023-10-01 to nightly-2023-11-11
regressed nightly: nightly-2023-10-26
searched commit range: https://github.com/rust-lang/rust/compare/df871fbf053de3a855398964cd05fadbe91cf4fd...ab5c841a1f3c09edc5ea07722519627c960aed17
regressed commit: https://github.com/rust-lang/rust/commit/ab5c841a1f3c09edc5ea07722519627c960aed17
bisected with cargo-bisect-rustc v0.6.8
Host triple: x86_64-unknown-linux-gnu
Reproduce with:
```bash
cargo bisect-rustc --start 1.74.0 --end 1.75.0 --prompt
```
Had a similar regression bisected to 1ca424ca436d4d4449def39723c9ec442837c370
Example
Before:
```rust
error[E0277]: `{integer}` is not an iterator
--> tests/compile-fail/surface_source_iter_badtype.rs:5:21
|
5 | source_iter(5) -> for_each(std::mem::drop);
| ------------^-
| | |
| | `{integer}` is not an iterator
| required by a bound introduced by this call
|
= help: the trait `Iterator` is not implemented for `{integer}`, which is required by `{integer}: IntoIterator`
= note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end`
= note: required for `{integer}` to implement `IntoIterator`
note: required by a bound in `check_iter`
--> tests/compile-fail/surface_source_iter_badtype.rs:5:9
|
5 | source_iter(5) -> for_each(std::mem::drop);
| ^^^^^^^^^^^^^^ required by this bound in `check_iter`
```
After
```rust
error[E0277]: `{integer}` is not an iterator
--> tests/compile-fail/surface_source_iter_badtype.rs:5:21
|
5 | source_iter(5) -> for_each(std::mem::drop);
| ------------^-
| | |
| | `{integer}` is not an iterator
| required by a bound introduced by this call
|
= help: the trait `Iterator` is not implemented for `{integer}`, which is required by `{integer}: IntoIterator`
= note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end`
= note: required for `{integer}` to implement `IntoIterator`
note: required by a bound in `check_iter`
--> tests/compile-fail/surface_source_iter_badtype.rs:5:9
|
5 | source_iter(5) -> for_each(std::mem::drop);
| ^^^^^^^^^^^^^^ required by this bound in `check_iter`
error[E0277]: `{integer}` is not an iterator
--> tests/compile-fail/surface_source_iter_badtype.rs:5:9
|
5 | source_iter(5) -> for_each(std::mem::drop);
| ^^^^^^^^^^^^^^ `{integer}` is not an iterator
|
= help: the trait `Iterator` is not implemented for `{integer}`, which is required by `{integer}: IntoIterator`
= note: required for `{integer}` to implement `IntoIterator`
note: required by a bound in `check_iter`
--> tests/compile-fail/surface_source_iter_badtype.rs:5:9
|
5 | source_iter(5) -> for_each(std::mem::drop);
| ^^^^^^^^^^^^^^ required by this bound in `check_iter`
error[E0277]: `{integer}` is not an iterator
--> tests/compile-fail/surface_source_iter_badtype.rs:5:9
|
5 | source_iter(5) -> for_each(std::mem::drop);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `{integer}` is not an iterator
|
= help: the trait `Iterator` is not implemented for `{integer}`, which is required by `{integer}: IntoIterator`
= note: required for `{integer}` to implement `IntoIterator`
note: required by a bound in `check_iter`
--> tests/compile-fail/surface_source_iter_badtype.rs:5:9
|
5 | source_iter(5) -> for_each(std::mem::drop);
| ^^^^^^^^^^^^^^ required by this bound in `check_iter`
```
Code
I tried this code:
I expected to see a meaningful error that points to the relevant fields that cause this issue:
Instead, this happened: Rustc emits an error message that duplicates the actual error several times. First it only points to the derive, later versions of the same error message point to the correct fields:
Version it worked on
It most recently worked on: Rust 1.74
Version with regression
rustc --version --verbose
:I've checked the stable rust versions in between and the error message first changes in 1.75 which introduces the messages that point to
#[derive(Insertable)]
but back then these were shown at the end of the output instead as first error message. Bisecting between the two stable releases points to https://github.com/rust-lang/rust/pull/117159 as PR that introduced the duplicated messages.Bisect Log
Regression in https://github.com/rust-lang-ci/rust/commit/dc8cfe13cc0d7e7d320f9be78932717fe80846a8 The PR introducing the regression in this rollup is #117159: Work around the fact that `check_mod_type_wf` may spuriousl… searched nightlies: from nightly-2023-10-01 to nightly-2023-11-11 regressed nightly: nightly-2023-10-26 searched commit range: https://github.com/rust-lang/rust/compare/df871fbf053de3a855398964cd05fadbe91cf4fd...ab5c841a1f3c09edc5ea07722519627c960aed17 regressed commit: https://github.com/rust-lang/rust/commit/ab5c841a1f3c09edc5ea07722519627c960aed17bisected with cargo-bisect-rustc v0.6.8
Host triple: x86_64-unknown-linux-gnu Reproduce with: ```bash cargo bisect-rustc --start 1.74.0 --end 1.75.0 --prompt ```The error then changed again between 1.76.0 and 1.77.0 by moving the message mentioning
#[derive(Insertable)]
at the begin of the error output. Bisecting points to https://github.com/rust-lang/rust/commit/791a53f380d5cf800191f25941c94ace5099876e as the commit that introduced that change.Bisect Log
Attempting to search unrolled perf builds ERROR: couldn't find perf build comment searched nightlies: from nightly-2023-12-21 to nightly-2024-02-01 regressed nightly: nightly-2024-01-06 searched commit range: https://github.com/rust-lang/rust/compare/f688dd684faca5b31b156fac2c6e0ae81fc9bc90...595bc6f00369475047538fdae1ff8cea692ac385 regressed commit: https://github.com/rust-lang/rust/commit/791a53f380d5cf800191f25941c94ace5099876ebisected with cargo-bisect-rustc v0.6.8
Host triple: x86_64-unknown-linux-gnu Reproduce with: ```bash cargo bisect-rustc --start 1.76.0 --end 1.77.0 --prompt ```@rustbot modify labels: +regression-from-stable-to-stable -regression-untriaged +A-diagnostics