Open fmease opened 1 year ago
Doesn't actually need ITIAP, a normal bound works just as well:
#![feature(non_lifetime_binders)]
fn take<F>(_: F) where F: for<T> FnOnce(T) -> T {}
fn main() {
take(|x| x)
}
|x| x
should probably be rejected since we don't support type-generic closures (yet).
It's probably fine that the following is well-typed under non_lifetime_binders
since it's impossible to call take
at this time anyway.
fn take(id: impl for<T> Fn(T) -> T) {
id(0);
id("");
}
@fmease no need to, I've got a more minimal repro of that issue here:
#![feature(non_lifetime_binders)]
trait Foo: for<T> Bar<T> {}
trait Bar<T> {
fn method() -> T;
}
fn x<T: Foo>() {
let _: i32 = T::method();
}
fn main() {}
I'll need to fix this in a couple of steps.
another one, possibly
#![crate_type="lib"]
pub trait Foo<T> {
type A;
fn get::A
}
struct YetAnotherStruct<'a, I: for<isize> Foo<&'x &isize>> {
field: I::A,
}
That ^ is a separate bug, also doesn't ICE with the code provided. I did minimize it tho:
#![feature(non_lifetime_binders)]
pub trait Foo<T> {
type A;
}
struct YetAnotherStruct<'a, I: for<T> Foo<T>> {
field: I::A,
}
fn main() {}
Error output
Backtrace
``` stack backtrace: 0: 0x7f1e8f56653a - std::backtrace_rs::backtrace::libunwind::trace::ha7277b97837a680e at /rustc/ac4379fea9e83465d814bb05005689f49bd2141e/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5 1: 0x7f1e8f56653a - std::backtrace_rs::backtrace::trace_unsynchronized::h2eae6446df1fb3c7 at /rustc/ac4379fea9e83465d814bb05005689f49bd2141e/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7f1e8f56653a - std::sys_common::backtrace::_print_fmt::hcce758637ada6e5e at /rustc/ac4379fea9e83465d814bb05005689f49bd2141e/library/std/src/sys_common/backtrace.rs:65:5 3: 0x7f1e8f56653a -::fmt::h048020a39b1c8541
at /rustc/ac4379fea9e83465d814bb05005689f49bd2141e/library/std/src/sys_common/backtrace.rs:44:22
4: 0x7f1e8f5c9cee - core::fmt::write::h8cb0e60463f917ed
at /rustc/ac4379fea9e83465d814bb05005689f49bd2141e/library/core/src/fmt/mod.rs:1232:17
5: 0x7f1e8f5593e5 - std::io::Write::write_fmt::h6a4bf43ae33fb5c2
at /rustc/ac4379fea9e83465d814bb05005689f49bd2141e/library/std/src/io/mod.rs:1684:15
6: 0x7f1e8f566305 - std::sys_common::backtrace::_print::h01686671a8f910e8
at /rustc/ac4379fea9e83465d814bb05005689f49bd2141e/library/std/src/sys_common/backtrace.rs:47:5
7: 0x7f1e8f566305 - std::sys_common::backtrace::print::hb036d568178720fa
at /rustc/ac4379fea9e83465d814bb05005689f49bd2141e/library/std/src/sys_common/backtrace.rs:34:9
8: 0x7f1e8f56907f - std::panicking::default_hook::{{closure}}::hac5f47cee0e06043
at /rustc/ac4379fea9e83465d814bb05005689f49bd2141e/library/std/src/panicking.rs:271:22
9: 0x7f1e8f568dbb - std::panicking::default_hook::hc30c65fb62dafbb3
at /rustc/ac4379fea9e83465d814bb05005689f49bd2141e/library/std/src/panicking.rs:290:9
10: 0x7f1e927e25c5 - rustc_driver_impl[1bafdf3e8b0cbe0c]::DEFAULT_HOOK::{closure#0}::{closure#0}
11: 0x7f1e8f5698bd - as core::ops::function::Fn>::call::hec34b5992590fa06
at /rustc/ac4379fea9e83465d814bb05005689f49bd2141e/library/alloc/src/boxed.rs:2001:9
12: 0x7f1e8f5698bd - std::panicking::rust_panic_with_hook::h44e2196c38854f66
at /rustc/ac4379fea9e83465d814bb05005689f49bd2141e/library/std/src/panicking.rs:696:13
13: 0x7f1e92d3e671 - std[f869becc71c6b456]::panicking::begin_panic::::{closure#0}
14: 0x7f1e92d36fe6 - std[f869becc71c6b456]::sys_common::backtrace::__rust_end_short_backtrace::::{closure#0}, !>
15: 0x7f1e92daba26 - std[f869becc71c6b456]::panicking::begin_panic::
16: 0x7f1e92d8a1a6 - std[f869becc71c6b456]::panic::panic_any::
17: 0x7f1e92d85ba6 - ::bug::<&alloc[56a1e614eb299497]::string::String>
18: 0x7f1e92d85870 - ::bug::<&alloc[56a1e614eb299497]::string::String>
19: 0x7f1e92d7cb7b - rustc_middle[6b96750649b9b523]::util::bug::opt_span_bug_fmt::::{closure#0}
20: 0x7f1e92d7b4ca - rustc_middle[6b96750649b9b523]::ty::context::tls::with_opt::::{closure#0}, !>::{closure#0}
21: 0x7f1e92d7b496 - rustc_middle[6b96750649b9b523]::ty::context::tls::with_context_opt::::{closure#0}, !>::{closure#0}, !>
22: 0x7f1e92d7cac6 - rustc_middle[6b96750649b9b523]::util::bug::opt_span_bug_fmt::
23: 0x7f1e90eeec13 - rustc_middle[6b96750649b9b523]::util::bug::bug_fmt
24: 0x7f1e92a4230c - ::replace_late_bound_regions_uncached::::replace_late_bound_regions::erase_late_bound_regions::{closure#0}>::{closure#0}>::{closure#0}
25: 0x7f1e90e228fd - <&rustc_middle[6b96750649b9b523]::ty::list::List as rustc_type_ir[52d4fefb1527696e]::fold::TypeFoldable>::try_fold_with::>
26: 0x7f1e90c1236b - ::closure_sigs
27: 0x7f1e90c10183 - ::check_expr_closure
28: 0x7f1e90b9f3fc - ::check_expr_with_expectation_and_args
29: 0x7f1e90e86ebd - ::check_argument_types
30: 0x7f1e90b6d7bb - ::check_call
31: 0x7f1e90b9b6ad - ::check_expr_with_expectation_and_args
32: 0x7f1e90bcacbe - ::check_block_with_expected
33: 0x7f1e90b9bbdf - ::check_expr_with_expectation_and_args
34: 0x7f1e9166f7d4 - ::check_return_expr
35: 0x7f1e91667bc7 - rustc_hir_typeck[b98449f9e1a7a434]::check::check_fn
36: 0x7f1e91651c37 - rustc_hir_typeck[b98449f9e1a7a434]::typeck
37: 0x7f1e90a2052c - rustc_query_system[5157c2c547c7c596]::query::plumbing::try_execute_query::
38: 0x7f1e91faf34f - rustc_data_structures[afc619c2eff4eef5]::sync::par_for_each_in::<&[rustc_span[481fe46353bf1cdc]::def_id::LocalDefId], ::par_body_owners::{closure#0}>
39: 0x7f1e91faf10f - rustc_hir_typeck[b98449f9e1a7a434]::typeck_item_bodies
40: 0x7f1e91e2c55d - rustc_query_system[5157c2c547c7c596]::query::plumbing::try_execute_query::
41: 0x7f1e91e2c24b - ::typeck_item_bodies
42: 0x7f1e90b68493 - ::time::<(), rustc_hir_analysis[717970e329447c82]::check_crate::{closure#7}>
43: 0x7f1e90b64f4d - rustc_hir_analysis[717970e329447c82]::check_crate
44: 0x7f1e90b5b072 - rustc_interface[841154c2f5280d71]::passes::analysis
45: 0x7f1e92033d9d - rustc_query_system[5157c2c547c7c596]::query::plumbing::try_execute_query::
46: 0x7f1e92033a9f - ::analysis
47: 0x7f1e91e63616 - ::enter::>
48: 0x7f1e91a47f48 - rustc_span[481fe46353bf1cdc]::with_source_map::, rustc_interface[841154c2f5280d71]::interface::run_compiler, rustc_driver_impl[1bafdf3e8b0cbe0c]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
49: 0x7f1e91a3f4dc - std[f869becc71c6b456]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[1bafdf3e8b0cbe0c]::run_compiler::{closure#1}>::{closure#0}, core[c7837a1117e32cc5]::result::Result<(), rustc_span[481fe46353bf1cdc]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c7837a1117e32cc5]::result::Result<(), rustc_span[481fe46353bf1cdc]::ErrorGuaranteed>>
50: 0x7f1e91a3ef0a - <::spawn_unchecked_, rustc_driver_impl[1bafdf3e8b0cbe0c]::run_compiler::{closure#1}>::{closure#0}, core[c7837a1117e32cc5]::result::Result<(), rustc_span[481fe46353bf1cdc]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c7837a1117e32cc5]::result::Result<(), rustc_span[481fe46353bf1cdc]::ErrorGuaranteed>>::{closure#1} as core[c7837a1117e32cc5]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
51: 0x7f1e8f5737b3 - as core::ops::function::FnOnce>::call_once::hc371c06232f0c824
at /rustc/ac4379fea9e83465d814bb05005689f49bd2141e/library/alloc/src/boxed.rs:1987:9
52: 0x7f1e8f5737b3 - as core::ops::function::FnOnce>::call_once::h7dc3758286df85d1
at /rustc/ac4379fea9e83465d814bb05005689f49bd2141e/library/alloc/src/boxed.rs:1987:9
53: 0x7f1e8f5737b3 - std::sys::unix::thread::Thread::new::thread_start::h64782255c7c71ccd
at /rustc/ac4379fea9e83465d814bb05005689f49bd2141e/library/std/src/sys/unix/thread.rs:108:17
54: 0x7f1e8f3068fd -
55: 0x7f1e8f388a60 -
56: 0x0 -
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.70.0-nightly (ac4379fea 2023-03-06) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [typeck] type-checking `main`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error; 1 warning emitted
```
Meta
Latest master (ac4379fea9e83465d814bb05005689f49bd2141e).
rustc -Vv
:@rustbot label F-non_lifetime_binders