Closed
Description
Code
fn main()
{
let x = String::new();
x.y;
}
This doesn't work for all structs, for example using Vec<u8>
produces a normal compiler error.
Meta
rustc --version --verbose
:
rustc 1.51.0-nightly (d4e3570db 2021-02-01)
binary: rustc
commit-hash: d4e3570db4c007089035b833cc20c7fc2f8cb32f
commit-date: 2021-02-01
host: x86_64-pc-windows-gnu
release: 1.51.0-nightly
LLVM version: 11.0.1
Couldn't reproduce this on 1.49.0 or 1.50.0-beta.8.
Error output
error: internal compiler error: compiler\rustc_middle\src\ty\subst.rs:529:17: type parameter `T/#0` (T/0) out of range when substituting, substs=[]
Backtrace
thread 'rustc' panicked at 'Box<Any>', /rustc/d4e3570db4c007089035b833cc20c7fc2f8cb32f\compiler\rustc_errors\src\lib.rs:904:9
stack backtrace:
0: std::panicking::begin_panic
1: rustc_errors::HandlerInner::span_bug
2: rustc_errors::Handler::span_bug
3: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
4: rustc_middle::ty::context::tls::with_opt
5: rustc_middle::util::bug::opt_span_bug_fmt
6: rustc_middle::util::bug::span_bug_fmt
7: <rustc_middle::ty::subst::SubstFolder as rustc_middle::ty::fold::TypeFolder>::fold_ty
8: rustc_middle::ty::fold::TypeFoldable::fold_with
9: rustc_middle::ty::structural_impls::<impl rustc_middle::ty::fold::TypeFoldable for &rustc_middle::ty::TyS>::super_fold_with
10: rustc_middle::ty::FieldDef::ty
11: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_for_nested_field
12: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_for_nested_field
13: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_field
14: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
15: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
16: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_stmt
17: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
18: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
19: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
20: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_return_expr
21: rustc_typeck::check::check::check_fn
22: rustc_infer::infer::InferCtxtBuilder::enter
23: rustc_typeck::check::typeck
24: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck>::compute
25: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
26: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
27: rustc_middle::ty::query::plumbing::<impl rustc_query_system::query::QueryContext for rustc_middle::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}::{{closure}}
28: rustc_query_system::query::plumbing::force_query_with_job
29: rustc_query_system::query::plumbing::get_query_impl
30: rustc_query_system::query::plumbing::ensure_query_impl
31: rustc_typeck::check::typeck_item_bodies
32: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck_item_bodies>::compute
33: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
34: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
35: rustc_data_structures::stack::ensure_sufficient_stack
36: rustc_query_system::query::plumbing::force_query_with_job
37: rustc_query_system::query::plumbing::get_query_impl
38: rustc_typeck::check_crate
39: rustc_interface::passes::analysis
40: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
41: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
42: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
43: rustc_middle::ty::query::plumbing::<impl rustc_query_system::query::QueryContext for rustc_middle::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}::{{closure}}
44: rustc_query_system::query::plumbing::force_query_with_job
45: rustc_query_system::query::plumbing::get_query_impl
46: rustc_interface::passes::QueryContext::enter
47: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
48: rustc_span::with_source_map
49: rustc_interface::interface::create_compiler_and_run