rust-lang / chalk

An implementation and definition of the Rust trait system using a PROLOG-like logic solver
https://rust-lang.github.io/chalk/book/
Other
1.84k stars 182 forks source link

Lowered command panics with auto trait #762

Closed jrr45 closed 2 years ago

jrr45 commented 2 years ago

Using the interactive commands, creating the program

#[auto] trait Send { }
struct SomeStruct<T> { }

then calling "lowered" causes chalk to panic. The same does not seem to happen by creating a test and using "lowering_success" with the same program.

detrumi commented 2 years ago

That's this assertion in Binders<T>::substitute() https://github.com/rust-lang/chalk/blob/60bbf5408cb6050ef62c98fb75400f95f664ccb2/chalk-ir/src/lib.rs#L2249

Backtrace

``` thread 'main' panicked at 'assertion failed: `(left == right)` left: `1`, right: `0`', /home/wilco/p/rust/chalk/chalk-ir/src/lib.rs:2249:9 stack backtrace: 0: rust_begin_unwind at /rustc/bb8c2f41174caceec00c28bc6c5c20ae9f9a175c/library/std/src/panicking.rs:584:5 1: core::panicking::panic_fmt at /rustc/bb8c2f41174caceec00c28bc6c5c20ae9f9a175c/library/core/src/panicking.rs:142:14 2: core::panicking::assert_failed_inner 3: core::panicking::assert_failed at /rustc/bb8c2f41174caceec00c28bc6c5c20ae9f9a175c/library/core/src/panicking.rs:181:5 4: chalk_ir::Binders::substitute at ./chalk-ir/src/lib.rs:2249:9 5: chalk_solve::clauses::constituent_types at ./chalk-solve/src/clauses.rs:33:35 6: chalk_solve::clauses::push_auto_trait_impls at ./chalk-solve/src/clauses.rs:208:30 7: chalk_integration::query::environment at ./chalk-integration/src/query.rs:229:13 8: ::execute at ./chalk-integration/src/query.rs:51:8 9: salsa::derived::slot::Slot::read_upgrade::{{closure}} at /home/wilco/.cargo/registry/src/github.com-1ecc6299db9ec823/salsa-0.16.1/src/derived/slot.rs:218:13 10: salsa::runtime::Runtime::execute_query_implementation at /home/wilco/.cargo/registry/src/github.com-1ecc6299db9ec823/salsa-0.16.1/src/runtime.rs:330:21 11: salsa::derived::slot::Slot::read_upgrade at /home/wilco/.cargo/registry/src/github.com-1ecc6299db9ec823/salsa-0.16.1/src/derived/slot.rs:215:26 12: salsa::derived::slot::Slot::read at /home/wilco/.cargo/registry/src/github.com-1ecc6299db9ec823/salsa-0.16.1/src/derived/slot.rs:148:9 13: as salsa::plumbing::QueryStorageOps>::try_fetch at /home/wilco/.cargo/registry/src/github.com-1ecc6299db9ec823/salsa-0.16.1/src/derived.rs:170:13 14: salsa::QueryTable::try_get at /home/wilco/.cargo/registry/src/github.com-1ecc6299db9ec823/salsa-0.16.1/src/lib.rs:494:9 15: salsa::QueryTable::get at /home/wilco/.cargo/registry/src/github.com-1ecc6299db9ec823/salsa-0.16.1/src/lib.rs:490:9 16: ::environment::__shim at ./chalk-integration/src/query.rs:27:1 17: ::environment at ./chalk-integration/src/query.rs:27:1 18: chalk::process::{{closure}} at ./src/main.rs:245:48 19: chalk_integration::db::ChalkDatabase::with_program::{{closure}} at ./chalk-integration/src/db.rs:43:46 20: chalk_integration::tls::set_current_program::{{closure}} at ./chalk-integration/src/tls.rs:172:17 21: std::thread::local::LocalKey::try_with at /rustc/bb8c2f41174caceec00c28bc6c5c20ae9f9a175c/library/std/src/thread/local.rs:445:16 22: std::thread::local::LocalKey::with at /rustc/bb8c2f41174caceec00c28bc6c5c20ae9f9a175c/library/std/src/thread/local.rs:421:9 23: chalk_integration::tls::set_current_program at ./chalk-integration/src/tls.rs:170:5 24: chalk_integration::db::ChalkDatabase::with_program at ./chalk-integration/src/db.rs:43:9 25: chalk::process at ./src/main.rs:239:9 26: chalk::run::{{closure}} at ./src/main.rs:138:29 27: chalk::readline_loop at ./src/main.rs:181:17 28: chalk::run at ./src/main.rs:137:9 29: chalk::main::{{closure}} at ./src/main.rs:313:36 30: tracing_core::dispatcher::with_default at /home/wilco/.cargo/registry/src/github.com-1ecc6299db9ec823/tracing-core-0.1.21/src/dispatcher.rs:228:5 31: tracing::subscriber::with_default at /home/wilco/.cargo/registry/src/github.com-1ecc6299db9ec823/tracing-0.1.29/src/subscriber.rs:24:5 32: chalk_solve::logging::with_tracing_logs at ./chalk-solve/src/logging.rs:11:5 33: chalk::main at ./src/main.rs:312:5 34: core::ops::function::FnOnce::call_once at /rustc/bb8c2f41174caceec00c28bc6c5c20ae9f9a175c/library/core/src/ops/function.rs:248:5 ```

Also happens when you load the program from a file.