Skip to content

Internal Compiler Error while compiling a special diesel change #85887

@weiznich

Description

@weiznich

Code

While working on diesel rustc crashed. I've uploaded my current local version here: weiznich/diesel@062572e. I'm happy to provide some guidiance about what could be relevant for minimization, but I unfortunally do not have the time to do that by myself.

Steps to reproduce:

  1. Clone the repository and checkout the corresponding commit
  2. cd /path/to/cloned/diesel/diesel_tests
  3. cargo test --no-default-features --features "postgres"

While the error message seems to suggest that this is releated to incremental compilation, this happen for me for clean builds. The target directory mentioned in the warning message above the crash is writeable and compilations generally work fine using this directory.

Meta

I can reproduce this error for the following rustc versions:

rustc 1.48.0 (7eac88abb 2020-11-16)
rustc 1.52.1 (9bc8c42bb 2021-05-09)
rustc 1.54.0-nightly (657bc0188 2021-05-31)

Error output

RUST_BACKTRACE=1 cargo +nightly test --no-default-features --features="postgres"
   Compiling diesel v2.0.0 (/home/weiznich/Dokumente/rust/diesel/diesel)
warning: missing documentation for a trait
   --> diesel/src/connection/mod.rs:28:1
    |
28  | pub trait IterableConnection<'a, DB: Backend> {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
note: the lint level is defined here
   --> diesel/src/lib.rs:102:5
    |
102 |     missing_docs
    |     ^^^^^^^^^^^^

warning: missing documentation for an associated type
  --> diesel/src/connection/mod.rs:29:5
   |
29 |     type Cursor: Iterator<Item = QueryResult<Self::Row>>;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: missing documentation for an associated type
  --> diesel/src/connection/mod.rs:30:5
   |
30 |     type Row: crate::row::Row<'a, DB>;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: type does not implement `Debug`; consider adding `#[derive(Debug)]` or a manual implementation
   --> diesel/src/query_dsl/load_dsl.rs:68:1
    |
68  | / pub struct LoadIter<'a, U, C, ST, DB> {
69  | |     cursor: C,
70  | |     _marker: std::marker::PhantomData<&'a (ST, U, DB)>,
71  | | }
    | |_^
    |
note: the lint level is defined here
   --> diesel/src/lib.rs:100:5
    |
100 |     missing_debug_implementations,
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: type does not implement `Debug`; consider adding `#[derive(Debug)]` or a manual implementation
  --> diesel/src/pg/connection/cursor.rs:8:1
   |
8  | / pub struct Cursor<'a> {
9  | |     current_row: usize,
10 | |     db_result: Rc<PgResult<'a>>,
11 | | }
   | |_^

warning: type does not implement `Debug`; consider adding `#[derive(Debug)]` or a manual implementation
  --> diesel/src/pg/connection/result.rs:15:1
   |
15 | / pub struct PgResult<'a> {
16 | |     internal_result: RawResult,
17 | |     column_count: usize,
18 | |     row_count: usize,
19 | |     _marker: PhantomData<&'a super::PgConnection>
20 | | }
   | |_^

warning: type does not implement `Debug`; consider adding `#[derive(Debug)]` or a manual implementation
  --> diesel/src/pg/connection/row.rs:7:1
   |
7  | / pub struct PgRow<'a> {
8  | |     db_result: Rc<PgResult<'a>>,
9  | |     row_idx: usize,
10 | | }
   | |_^

warning: type does not implement `Debug`; consider adding `#[derive(Debug)]` or a manual implementation
  --> diesel/src/pg/connection/row.rs:59:1
   |
59 | / pub struct PgField<'a> {
60 | |     db_result: Rc<PgResult<'a>>,
61 | |     row_idx: usize,
62 | |     col_idx: usize,
63 | | }
   | |_^

   Compiling diesel_migrations v2.0.0 (/home/weiznich/Dokumente/rust/diesel/diesel_migrations)
warning: Error finalizing incremental compilation session directory `/home/weiznich/Dokumente/rust/shared_target/debug/incremental/diesel-3rkg3lwwyoug5/s-fz54zikf9w-1bya14u-working`: No such file or directory (os error 2)

warning: 9 warnings emitted

error: internal compiler error: Encountered errors `[FulfillmentError(Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { substs: [expression::sql_literal::SqlLiteral<sql_types::Text>, ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:5182 ~ diesel[f7a1]::query_dsl::load_dsl::{impl#4}::'a), 'a) }), pg::connection::PgConnection, std::string::String], item_def_id: DefId(0:5132 ~ diesel[f7a1]::query_dsl::load_dsl::LoadQueryRet::Ret) }, query_dsl::load_dsl::LoadIter<'a, std::string::String, <pg::connection::PgConnection as connection::IterableConnection<'a, pg::backend::Pg>>::Cursor, sql_types::Text, pg::backend::Pg>), [Region(BrNamed(DefId(0:5182 ~ diesel[f7a1]::query_dsl::load_dsl::{impl#4}::'a), 'a))]), depth=1),MismatchedProjectionTypes(Sorts(ExpectedFound { expected: pg::connection::cursor::Cursor<'_>, found: <pg::connection::PgConnection as connection::IterableConnection<'a, pg::backend::Pg>>::Cursor })))]` resolving bounds after type-checking
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/codegen.rs:124:24

error: internal compiler error: Encountered errors `[FulfillmentError(Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { substs: [query_builder::select_statement::SelectStatement<query_source::joins::JoinOn<query_source::joins::Join<pg::metadata_lookup::pg_type::table, pg::metadata_lookup::pg_namespace::table, query_source::joins::Inner>, expression::grouped::Grouped<expression::operators::Eq<expression::nullable::Nullable<pg::metadata_lookup::pg_type::columns::typnamespace>, expression::nullable::Nullable<pg::metadata_lookup::pg_namespace::columns::oid>>>>, query_builder::select_clause::SelectClause<(pg::metadata_lookup::pg_type::columns::oid, pg::metadata_lookup::pg_type::columns::typarray)>, query_builder::distinct_clause::NoDistinctClause, query_builder::where_clause::WhereClause<expression::grouped::Grouped<expression::operators::And<expression::grouped::Grouped<expression::operators::Eq<pg::metadata_lookup::pg_type::columns::typname, expression::bound::Bound<sql_types::Text, &str>>>, expression::grouped::Grouped<expression::operators::Or<expression::grouped::Grouped<expression::operators::Eq<pg::metadata_lookup::pg_namespace::columns::nspname, pg::expression::array_comparison::Any<expression::bound::Bound<pg::types::sql_types::Array<sql_types::Text>, std::vec::Vec<&str>>>>>, expression::grouped::Grouped<expression::operators::Eq<pg::metadata_lookup::pg_namespace::columns::oid, pg::metadata_lookup::pg_my_temp_schema::pg_my_temp_schema>>>>>>>, query_builder::order_clause::NoOrderClause, query_builder::limit_offset_clause::LimitOffsetClause<query_builder::limit_clause::LimitClause<expression::bound::Bound<sql_types::BigInt, i64>>, query_builder::offset_clause::NoOffsetClause>>, ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:5182 ~ diesel[f7a1]::query_dsl::load_dsl::{impl#4}::'a), 'a) }), pg::connection::PgConnection, pg::backend::InnerPgTypeMetadata], item_def_id: DefId(0:5132 ~ diesel[f7a1]::query_dsl::load_dsl::LoadQueryRet::Ret) }, query_dsl::load_dsl::LoadIter<'a, pg::backend::InnerPgTypeMetadata, <pg::connection::PgConnection as connection::IterableConnection<'a, pg::backend::Pg>>::Cursor, (pg::types::sql_types::Oid, pg::types::sql_types::Oid), pg::backend::Pg>), [Region(BrNamed(DefId(0:5182 ~ diesel[f7a1]::query_dsl::load_dsl::{impl#4}::'a), 'a))]), depth=1),MismatchedProjectionTypes(Sorts(ExpectedFound { expected: pg::connection::cursor::Cursor<'_>, found: <pg::connection::PgConnection as connection::IterableConnection<'a, pg::backend::Pg>>::Cursor })))]` resolving bounds after type-checking
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/codegen.rs:124:24

error: internal compiler error: Encountered errors `[FulfillmentError(Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { substs: [query_builder::select_statement::SelectStatement<query_source::joins::JoinOn<query_source::joins::Join<pg::metadata_lookup::pg_type::table, pg::metadata_lookup::pg_namespace::table, query_source::joins::Inner>, expression::grouped::Grouped<expression::operators::Eq<expression::nullable::Nullable<pg::metadata_lookup::pg_type::columns::typnamespace>, expression::nullable::Nullable<pg::metadata_lookup::pg_namespace::columns::oid>>>>, query_builder::select_clause::SelectClause<(pg::metadata_lookup::pg_type::columns::oid, pg::metadata_lookup::pg_type::columns::typarray)>, query_builder::distinct_clause::NoDistinctClause, query_builder::where_clause::WhereClause<expression::grouped::Grouped<expression::operators::And<expression::grouped::Grouped<expression::operators::Eq<pg::metadata_lookup::pg_type::columns::typname, expression::bound::Bound<sql_types::Text, &str>>>, expression::grouped::Grouped<expression::operators::Eq<pg::metadata_lookup::pg_namespace::columns::nspname, pg::expression::array_comparison::Any<expression::bound::Bound<pg::types::sql_types::Array<sql_types::Text>, std::vec::Vec<&str>>>>>>>>, query_builder::order_clause::NoOrderClause, query_builder::limit_offset_clause::LimitOffsetClause<query_builder::limit_clause::LimitClause<expression::bound::Bound<sql_types::BigInt, i64>>, query_builder::offset_clause::NoOffsetClause>>, ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:5182 ~ diesel[f7a1]::query_dsl::load_dsl::{impl#4}::'a), 'a) }), pg::connection::PgConnection, pg::backend::InnerPgTypeMetadata], item_def_id: DefId(0:5132 ~ diesel[f7a1]::query_dsl::load_dsl::LoadQueryRet::Ret) }, query_dsl::load_dsl::LoadIter<'a, pg::backend::InnerPgTypeMetadata, <pg::connection::PgConnection as connection::IterableConnection<'a, pg::backend::Pg>>::Cursor, (pg::types::sql_types::Oid, pg::types::sql_types::Oid), pg::backend::Pg>), [Region(BrNamed(DefId(0:5182 ~ diesel[f7a1]::query_dsl::load_dsl::{impl#4}::'a), 'a))]), depth=1),MismatchedProjectionTypes(Sorts(ExpectedFound { expected: pg::connection::cursor::Cursor<'_>, found: <pg::connection::PgConnection as connection::IterableConnection<'a, pg::backend::Pg>>::Cursor })))]` resolving bounds after type-checking
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/codegen.rs:124:24

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1021:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/657bc01888e6297257655585f9c475a0801db6d2/library/std/src/panicking.rs:515:5
   1: std::panicking::begin_panic_fmt
             at /rustc/657bc01888e6297257655585f9c475a0801db6d2/library/std/src/panicking.rs:457:5
   2: rustc_errors::HandlerInner::flush_delayed
   3: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   4: core::ptr::drop_in_place<rustc_session::parse::ParseSess>
   5: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
   6: core::ptr::drop_in_place<rustc_interface::interface::Compiler>
   7: rustc_span::with_source_map
   8: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.54.0-nightly (657bc0188 2021-05-31) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental -C link-args=-fuse-ld=lld -C link-arg=-fuse-ld=lld --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `diesel`

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions