Closed nvksv closed 4 years ago
Output on 1.46:
error[E0308]: mismatched types
--> <source>:8:28
|
8 | let f = |x: &dyn TT| x.func();
| ^^^^ lifetime mismatch
|
= note: expected reference `&(dyn TT + 'static)`
found reference `&dyn TT`
note: the anonymous lifetime #1 defined on the body at 8:13...
--> <source>:8:13
|
8 | let f = |x: &dyn TT| x.func();
| ^^^^^^^^^^^^^^^^^^^^^
= note: ...does not necessarily outlive the static lifetime
error: aborting due to previous error
Changing the closure argument type to &(dyn TT + 'static)
compiles successfully on both verions.
@rustbot modify labels: +A-diagnostics +A-lifetimes +regression-from-stable-to-stable
With impl (dyn TT + '_) {...}
instead of impl dyn TT {...}
it compiles successfully too.
We probably have to check for closures in try_report_static_impl_trait
here.
Assigning P-medium
as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.
Code
Meta
rustc --version --verbose
:This bug also exists at Rust Playground.
Error output
Backtrace
``` error: internal compiler error: src\librustc_typeck\collect.rs:1587:13: to get the signature of a closure, use `substs.as_closure().sig()` not `fn_sig()` thread 'rustc' panicked at 'Box', src\librustc_errors\lib.rs:918:9
stack backtrace:
0: std::panicking::begin_panic
1: rustc_errors::HandlerInner::bug
2: rustc_errors::Handler::bug
3: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
4: rustc_middle::ty::context::tls::with_opt::{{closure}}
5: rustc_middle::ty::context::tls::with_opt
6: rustc_middle::util::bug::opt_span_bug_fmt
7: rustc_middle::util::bug::bug_fmt
8: rustc_typeck::collect::fn_sig
9: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::fn_sig>::compute
10: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl
11: rustc_data_structures::stack::ensure_sufficient_stack
12: rustc_query_system::query::plumbing::get_query_impl
13: rustc_infer::infer::error_reporting::nice_region_error::util::::find_param_with_region
14: rustc_infer::infer::error_reporting::nice_region_error::static_impl_trait::::try_report_static_impl_trait
15: rustc_infer::infer::error_reporting::nice_region_error::NiceRegionError::try_report
16: rustc_infer::infer::error_reporting::::report_region_errors
17: rustc_infer::infer::InferCtxt::resolve_regions_and_report_errors
18: rustc_typeck::check::regionck::::regionck_fn
19: rustc_infer::infer::InferCtxtBuilder::enter
20: rustc_typeck::check::typeck
21: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::typeck>::compute
22: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl
23: rustc_data_structures::stack::ensure_sufficient_stack
24: rustc_query_system::query::plumbing::get_query_impl
25: rustc_query_system::query::plumbing::ensure_query_impl
26: rustc_typeck::check::typeck_item_bodies
27: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::typeck_item_bodies>::compute
28: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl
29: rustc_data_structures::stack::ensure_sufficient_stack
30: rustc_query_system::query::plumbing::get_query_impl
31: rustc_typeck::check_crate
32: rustc_interface::passes::analysis
33: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::analysis>::compute
34: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl
35: rustc_data_structures::stack::ensure_sufficient_stack
36: rustc_query_system::query::plumbing::get_query_impl
37: rustc_interface::queries::::enter
38: rustc_span::with_source_map
39: rustc_interface::interface::create_compiler_and_run
40: scoped_tls::ScopedKey::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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.47.0 (18bf6b4f0 2020-10-07) running on x86_64-pc-windows-gnu
query stack during panic:
#0 [fn_sig] computing function signature of `main::{{closure}}#0`
#1 [typeck] type-checking `main`
#2 [typeck_item_bodies] type-checking all item bodies
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error
```