Closed
Description
auto-reduced (treereduce-rust):
#![feature(effects)]
use std::ops::{, FromResidual, Try};
struct TryMe;
struct Error;
impl const FromResidual<Error> for TryMe {
}
impl const Try for TryMe {
type Output = ();
type Residual = Error;
}
const fn t() -> TryMe {
TryMe?;
TryMe
}
const _: () = {
t();
};
original:
// check-pass
// Demonstrates what's needed to make use of `?` in const contexts.
#![crate_type = "lib"]
#![feature(try_trait_v2)]
#![feature(const_trait_impl)]
#![feature(const_try)]
use std::ops::{ControlFlow, FromResidual, Try};
struct TryMe;
struct Error;
impl const FromResidual<Error> for TryMe {
fn from_residual(residual: Error) -> Self {
TryMe
}
}
impl const Try for TryMe {
type Output = ();
type Residual = Error;
fn from_output(output: Self::Output) -> Self {
TryMe
}
fn branch(self) -> ControlFlow<Self::Residual, Self::Output> {
ControlFlow::Break(Error)
}
}
const fn t() -> TryMe {
TryMe?;
TryMe
}
const _: () = {
t();
};
Version information
rustc 1.81.0-nightly (ff014f5de 2024-06-08)
binary: rustc
commit-hash: ff014f5de0c4d9a53e2d80b53e1faaca96964314
commit-date: 2024-06-08
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(effects)
Program output
error: expected identifier, found `,`
--> /tmp/icemaker_global_tempdir.eb116uAziiSn/rustc_testrunner_tmpdir_reporting.c0Pc0Cr1avWx/mvce.rs:10:16
|
10 | use std::ops::{, FromResidual, Try};
| ^
| |
| expected identifier
| help: remove this comma
error[E0658]: const trait impls are experimental
--> /tmp/icemaker_global_tempdir.eb116uAziiSn/rustc_testrunner_tmpdir_reporting.c0Pc0Cr1avWx/mvce.rs:15:6
|
15 | impl const FromResidual<Error> for TryMe {
| ^^^^^
|
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
= note: this compiler was built on 2024-06-08; consider upgrading it if it is out of date
error[E0658]: const trait impls are experimental
--> /tmp/icemaker_global_tempdir.eb116uAziiSn/rustc_testrunner_tmpdir_reporting.c0Pc0Cr1avWx/mvce.rs:19:6
|
19 | impl const Try for TryMe {
| ^^^^^
|
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
= note: this compiler was built on 2024-06-08; consider upgrading it if it is out of date
error[E0601]: `main` function not found in crate `mvce`
--> /tmp/icemaker_global_tempdir.eb116uAziiSn/rustc_testrunner_tmpdir_reporting.c0Pc0Cr1avWx/mvce.rs:33:3
|
33 | };
| ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.eb116uAziiSn/rustc_testrunner_tmpdir_reporting.c0Pc0Cr1avWx/mvce.rs`
error[E0658]: use of unstable library feature 'try_trait_v2'
--> /tmp/icemaker_global_tempdir.eb116uAziiSn/rustc_testrunner_tmpdir_reporting.c0Pc0Cr1avWx/mvce.rs:10:16
|
10 | use std::ops::{, FromResidual, Try};
| ^^^^^^^^^^^^^^
|
= note: see issue #84277 <https://github.com/rust-lang/rust/issues/84277> for more information
= help: add `#![feature(try_trait_v2)]` to the crate attributes to enable
= note: this compiler was built on 2024-06-08; consider upgrading it if it is out of date
error[E0658]: use of unstable library feature 'try_trait_v2'
--> /tmp/icemaker_global_tempdir.eb116uAziiSn/rustc_testrunner_tmpdir_reporting.c0Pc0Cr1avWx/mvce.rs:10:32
|
10 | use std::ops::{, FromResidual, Try};
| ^^^
|
= note: see issue #84277 <https://github.com/rust-lang/rust/issues/84277> for more information
= help: add `#![feature(try_trait_v2)]` to the crate attributes to enable
= note: this compiler was built on 2024-06-08; consider upgrading it if it is out of date
error[E0658]: use of unstable library feature 'try_trait_v2'
--> /tmp/icemaker_global_tempdir.eb116uAziiSn/rustc_testrunner_tmpdir_reporting.c0Pc0Cr1avWx/mvce.rs:15:12
|
15 | impl const FromResidual<Error> for TryMe {
| ^^^^^^^^^^^^^^^^^^^
|
= note: see issue #84277 <https://github.com/rust-lang/rust/issues/84277> for more information
= help: add `#![feature(try_trait_v2)]` to the crate attributes to enable
= note: this compiler was built on 2024-06-08; consider upgrading it if it is out of date
error[E0658]: use of unstable library feature 'try_trait_v2'
--> /tmp/icemaker_global_tempdir.eb116uAziiSn/rustc_testrunner_tmpdir_reporting.c0Pc0Cr1avWx/mvce.rs:20:5
|
20 | type Output = ();
| ^^^^^^^^^^^^^^^^^
|
= note: see issue #84277 <https://github.com/rust-lang/rust/issues/84277> for more information
= help: add `#![feature(try_trait_v2)]` to the crate attributes to enable
= note: this compiler was built on 2024-06-08; consider upgrading it if it is out of date
error[E0658]: use of unstable library feature 'try_trait_v2'
--> /tmp/icemaker_global_tempdir.eb116uAziiSn/rustc_testrunner_tmpdir_reporting.c0Pc0Cr1avWx/mvce.rs:21:5
|
21 | type Residual = Error;
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #84277 <https://github.com/rust-lang/rust/issues/84277> for more information
= help: add `#![feature(try_trait_v2)]` to the crate attributes to enable
= note: this compiler was built on 2024-06-08; consider upgrading it if it is out of date
error[E0658]: use of unstable library feature 'try_trait_v2'
--> /tmp/icemaker_global_tempdir.eb116uAziiSn/rustc_testrunner_tmpdir_reporting.c0Pc0Cr1avWx/mvce.rs:19:12
|
19 | impl const Try for TryMe {
| ^^^
|
= note: see issue #84277 <https://github.com/rust-lang/rust/issues/84277> for more information
= help: add `#![feature(try_trait_v2)]` to the crate attributes to enable
= note: this compiler was built on 2024-06-08; consider upgrading it if it is out of date
error[E0658]: `?` is not allowed in a `const fn`
--> /tmp/icemaker_global_tempdir.eb116uAziiSn/rustc_testrunner_tmpdir_reporting.c0Pc0Cr1avWx/mvce.rs:27:5
|
27 | TryMe?;
| ^^^^^^
|
= note: see issue #74935 <https://github.com/rust-lang/rust/issues/74935> for more information
= help: add `#![feature(const_try)]` to the crate attributes to enable
= note: this compiler was built on 2024-06-08; consider upgrading it if it is out of date
error: const `impl` for trait `FromResidual` which is not marked with `#[const_trait]`
--> /tmp/icemaker_global_tempdir.eb116uAziiSn/rustc_testrunner_tmpdir_reporting.c0Pc0Cr1avWx/mvce.rs:15:12
|
15 | impl const FromResidual<Error> for TryMe {
| ^^^^^^^^^^^^^^^^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error[E0207]: the const parameter `host` is not constrained by the impl trait, self type, or predicates
--> /tmp/icemaker_global_tempdir.eb116uAziiSn/rustc_testrunner_tmpdir_reporting.c0Pc0Cr1avWx/mvce.rs:15:6
|
15 | impl const FromResidual<Error> for TryMe {
| ^^^^^ unconstrained const parameter
|
= note: expressions using a const parameter must map each value to a distinct output value
= note: proving the result of expressions other than the parameter are unique is not supported
error: const `impl` for trait `Try` which is not marked with `#[const_trait]`
--> /tmp/icemaker_global_tempdir.eb116uAziiSn/rustc_testrunner_tmpdir_reporting.c0Pc0Cr1avWx/mvce.rs:19:12
|
19 | impl const Try for TryMe {
| ^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error[E0207]: the const parameter `host` is not constrained by the impl trait, self type, or predicates
--> /tmp/icemaker_global_tempdir.eb116uAziiSn/rustc_testrunner_tmpdir_reporting.c0Pc0Cr1avWx/mvce.rs:19:6
|
19 | impl const Try for TryMe {
| ^^^^^ unconstrained const parameter
|
= note: expressions using a const parameter must map each value to a distinct output value
= note: proving the result of expressions other than the parameter are unique is not supported
error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:168:90: Failed to normalize std::ops::ControlFlow<Alias(Projection, AliasTy { args: [TryMe], def_id: DefId(2:3651 ~ core[3b0a]::ops::try_trait::Try::Residual) }), Alias(Projection, AliasTy { args: [TryMe], def_id: DefId(2:3650 ~ core[3b0a]::ops::try_trait::Try::Output) })>, maybe try to call `try_normalize_erasing_regions` instead
thread 'rustc' panicked at compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:168:90:
Box<dyn Any>
stack backtrace:
0: 0x7c48ee7c2f15 - std::backtrace_rs::backtrace::libunwind::trace::h391c84fc4ecc1dec
at /rustc/ff014f5de0c4d9a53e2d80b53e1faaca96964314/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
1: 0x7c48ee7c2f15 - std::backtrace_rs::backtrace::trace_unsynchronized::h3e92edc77e0c5c4e
at /rustc/ff014f5de0c4d9a53e2d80b53e1faaca96964314/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7c48ee7c2f15 - std::sys_common::backtrace::_print_fmt::h87ef60a1873724a8
at /rustc/ff014f5de0c4d9a53e2d80b53e1faaca96964314/library/std/src/sys_common/backtrace.rs:68:5
3: 0x7c48ee7c2f15 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb8e68420de9fbe34
at /rustc/ff014f5de0c4d9a53e2d80b53e1faaca96964314/library/std/src/sys_common/backtrace.rs:44:22
4: 0x7c48ee813c5b - core::fmt::rt::Argument::fmt::h988688d3b6b43938
at /rustc/ff014f5de0c4d9a53e2d80b53e1faaca96964314/library/core/src/fmt/rt.rs:165:63
5: 0x7c48ee813c5b - core::fmt::write::h26bacab22040c630
at /rustc/ff014f5de0c4d9a53e2d80b53e1faaca96964314/library/core/src/fmt/mod.rs:1168:21
6: 0x7c48ee7b7bef - std::io::Write::write_fmt::h6eccb8f4340b2875
at /rustc/ff014f5de0c4d9a53e2d80b53e1faaca96964314/library/std/src/io/mod.rs:1835:15
7: 0x7c48ee7c2cee - std::sys_common::backtrace::_print::h4e05c7347d93fefc
at /rustc/ff014f5de0c4d9a53e2d80b53e1faaca96964314/library/std/src/sys_common/backtrace.rs:47:5
8: 0x7c48ee7c2cee - std::sys_common::backtrace::print::h0d1ce927f3656a2b
at /rustc/ff014f5de0c4d9a53e2d80b53e1faaca96964314/library/std/src/sys_common/backtrace.rs:34:9
9: 0x7c48ee7c5729 - std::panicking::default_hook::{{closure}}::hf913f37399eebbd3
10: 0x7c48ee7c54ca - std::panicking::default_hook::h824adac0153bd182
at /rustc/ff014f5de0c4d9a53e2d80b53e1faaca96964314/library/std/src/panicking.rs:298:9
11: 0x7c48eafd91af - std[41894142a3d00c]::panicking::update_hook::<alloc[4f88e964462652ad]::boxed::Box<rustc_driver_impl[1c61470bbdda786f]::install_ice_hook::{closure#0}>>::{closure#0}
12: 0x7c48ee7c5e5b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h6bc7f7783dfea44c
at /rustc/ff014f5de0c4d9a53e2d80b53e1faaca96964314/library/alloc/src/boxed.rs:2077:9
13: 0x7c48ee7c5e5b - std::panicking::rust_panic_with_hook::hb16889bb52fcfe7b
at /rustc/ff014f5de0c4d9a53e2d80b53e1faaca96964314/library/std/src/panicking.rs:799:13
14: 0x7c48eb0099c4 - std[41894142a3d00c]::panicking::begin_panic::<rustc_errors[377a76983204126c]::ExplicitBug>::{closure#0}
15: 0x7c48eb0064a6 - std[41894142a3d00c]::sys_common::backtrace::__rust_end_short_backtrace::<std[41894142a3d00c]::panicking::begin_panic<rustc_errors[377a76983204126c]::ExplicitBug>::{closure#0}, !>
16: 0x7c48eb0018b6 - std[41894142a3d00c]::panicking::begin_panic::<rustc_errors[377a76983204126c]::ExplicitBug>
17: 0x7c48eb012fe1 - <rustc_errors[377a76983204126c]::diagnostic::BugAbort as rustc_errors[377a76983204126c]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
18: 0x7c48eb4f020c - rustc_middle[c314043e2f18fb75]::util::bug::opt_span_bug_fmt::<rustc_span[fc6a22b319982284]::span_encoding::Span>::{closure#0}
19: 0x7c48eb4d932a - rustc_middle[c314043e2f18fb75]::ty::context::tls::with_opt::<rustc_middle[c314043e2f18fb75]::util::bug::opt_span_bug_fmt<rustc_span[fc6a22b319982284]::span_encoding::Span>::{closure#0}, !>::{closure#0}
20: 0x7c48eb4d91ab - rustc_middle[c314043e2f18fb75]::ty::context::tls::with_context_opt::<rustc_middle[c314043e2f18fb75]::ty::context::tls::with_opt<rustc_middle[c314043e2f18fb75]::util::bug::opt_span_bug_fmt<rustc_span[fc6a22b319982284]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
21: 0x7c48e99acff0 - rustc_middle[c314043e2f18fb75]::util::bug::bug_fmt
22: 0x7c48eca53ad2 - <rustc_middle[c314043e2f18fb75]::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder as rustc_type_ir[b289e05cb1ac0049]::fold::TypeFolder<rustc_middle[c314043e2f18fb75]::ty::context::TyCtxt>>::fold_ty
23: 0x7c48ea1051bf - <rustc_const_eval[1a73614a22be4f32]::interpret::eval_context::InterpCx<rustc_const_eval[1a73614a22be4f32]::const_eval::machine::CompileTimeInterpreter>>::terminator
24: 0x7c48ea135b21 - rustc_const_eval[1a73614a22be4f32]::const_eval::eval_queries::eval_to_allocation_raw_provider
25: 0x7c48eca3443c - rustc_query_impl[31633fcbb427b4dc]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[31633fcbb427b4dc]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c314043e2f18fb75]::query::erase::Erased<[u8; 24usize]>>
26: 0x7c48eca33c59 - rustc_query_system[4bc92dc28279729a]::query::plumbing::try_execute_query::<rustc_query_impl[31633fcbb427b4dc]::DynamicConfig<rustc_query_system[4bc92dc28279729a]::query::caches::DefaultCache<rustc_middle[c314043e2f18fb75]::ty::ParamEnvAnd<rustc_middle[c314043e2f18fb75]::mir::interpret::GlobalId>, rustc_middle[c314043e2f18fb75]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[31633fcbb427b4dc]::plumbing::QueryCtxt, false>
27: 0x7c48eca33830 - rustc_query_impl[31633fcbb427b4dc]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
28: 0x7c48eca34f5c - rustc_const_eval[1a73614a22be4f32]::const_eval::eval_queries::eval_to_const_value_raw_provider
29: 0x7c48eca34d7a - rustc_query_impl[31633fcbb427b4dc]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[31633fcbb427b4dc]::query_impl::eval_to_const_value_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c314043e2f18fb75]::query::erase::Erased<[u8; 24usize]>>
30: 0x7c48eca33c1c - rustc_query_system[4bc92dc28279729a]::query::plumbing::try_execute_query::<rustc_query_impl[31633fcbb427b4dc]::DynamicConfig<rustc_query_system[4bc92dc28279729a]::query::caches::DefaultCache<rustc_middle[c314043e2f18fb75]::ty::ParamEnvAnd<rustc_middle[c314043e2f18fb75]::mir::interpret::GlobalId>, rustc_middle[c314043e2f18fb75]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[31633fcbb427b4dc]::plumbing::QueryCtxt, false>
31: 0x7c48eca33742 - rustc_query_impl[31633fcbb427b4dc]::query_impl::eval_to_const_value_raw::get_query_non_incr::__rust_end_short_backtrace
32: 0x7c48ec82077a - <rustc_middle[c314043e2f18fb75]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[53542630c6369c29]::check_crate::{closure#3}>::{closure#0}
33: 0x7c48ec81ebc0 - rustc_hir_analysis[53542630c6369c29]::check_crate
34: 0x7c48ec9a3dbe - rustc_interface[c8f1c8b6dfa33e5d]::passes::analysis
35: 0x7c48ec9a391b - rustc_query_impl[31633fcbb427b4dc]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[31633fcbb427b4dc]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c314043e2f18fb75]::query::erase::Erased<[u8; 1usize]>>
36: 0x7c48ed1f4ce5 - rustc_query_system[4bc92dc28279729a]::query::plumbing::try_execute_query::<rustc_query_impl[31633fcbb427b4dc]::DynamicConfig<rustc_query_system[4bc92dc28279729a]::query::caches::SingleCache<rustc_middle[c314043e2f18fb75]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[31633fcbb427b4dc]::plumbing::QueryCtxt, false>
37: 0x7c48ed1f4a4f - rustc_query_impl[31633fcbb427b4dc]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
38: 0x7c48ed0758d2 - rustc_interface[c8f1c8b6dfa33e5d]::interface::run_compiler::<core[3b0a81cff9e78d23]::result::Result<(), rustc_span[fc6a22b319982284]::ErrorGuaranteed>, rustc_driver_impl[1c61470bbdda786f]::run_compiler::{closure#0}>::{closure#1}
39: 0x7c48ed028f09 - std[41894142a3d00c]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[c8f1c8b6dfa33e5d]::util::run_in_thread_with_globals<rustc_interface[c8f1c8b6dfa33e5d]::util::run_in_thread_pool_with_globals<rustc_interface[c8f1c8b6dfa33e5d]::interface::run_compiler<core[3b0a81cff9e78d23]::result::Result<(), rustc_span[fc6a22b319982284]::ErrorGuaranteed>, rustc_driver_impl[1c61470bbdda786f]::run_compiler::{closure#0}>::{closure#1}, core[3b0a81cff9e78d23]::result::Result<(), rustc_span[fc6a22b319982284]::ErrorGuaranteed>>::{closure#0}, core[3b0a81cff9e78d23]::result::Result<(), rustc_span[fc6a22b319982284]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3b0a81cff9e78d23]::result::Result<(), rustc_span[fc6a22b319982284]::ErrorGuaranteed>>
40: 0x7c48ed028cc0 - <<std[41894142a3d00c]::thread::Builder>::spawn_unchecked_<rustc_interface[c8f1c8b6dfa33e5d]::util::run_in_thread_with_globals<rustc_interface[c8f1c8b6dfa33e5d]::util::run_in_thread_pool_with_globals<rustc_interface[c8f1c8b6dfa33e5d]::interface::run_compiler<core[3b0a81cff9e78d23]::result::Result<(), rustc_span[fc6a22b319982284]::ErrorGuaranteed>, rustc_driver_impl[1c61470bbdda786f]::run_compiler::{closure#0}>::{closure#1}, core[3b0a81cff9e78d23]::result::Result<(), rustc_span[fc6a22b319982284]::ErrorGuaranteed>>::{closure#0}, core[3b0a81cff9e78d23]::result::Result<(), rustc_span[fc6a22b319982284]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3b0a81cff9e78d23]::result::Result<(), rustc_span[fc6a22b319982284]::ErrorGuaranteed>>::{closure#2} as core[3b0a81cff9e78d23]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
41: 0x7c48ee7cfe4b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h7880e98e31b6901f
at /rustc/ff014f5de0c4d9a53e2d80b53e1faaca96964314/library/alloc/src/boxed.rs:2063:9
42: 0x7c48ee7cfe4b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h947e9b0d87d30ce7
at /rustc/ff014f5de0c4d9a53e2d80b53e1faaca96964314/library/alloc/src/boxed.rs:2063:9
43: 0x7c48ee7cfe4b - std::sys::pal::unix::thread::Thread::new::thread_start::hb9f9757f270b060b
at /rustc/ff014f5de0c4d9a53e2d80b53e1faaca96964314/library/std/src/sys/pal/unix/thread.rs:108:17
44: 0x7c48e7ca6ded - <unknown>
45: 0x7c48e7d2a0dc - <unknown>
46: 0x0 - <unknown>
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: please make sure that you have updated to the latest nightly
note: rustc 1.81.0-nightly (ff014f5de 2024-06-08) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z crate-attr=feature(effects) -Z dump-mir-dir=dir
query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `_`
#1 [eval_to_const_value_raw] simplifying constant for the type system `_`
end of query stack
error: aborting due to 16 previous errors
Some errors have detailed explanations: E0207, E0601, E0658.
For more information about an error, try `rustc --explain E0207`.
@rustbot label +F-try_trait_v2 +F-const_trait_impl +F-const_try +F-effects