Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use tuple inference for closures #21

Closed
wants to merge 3,352 commits into from
Closed

Conversation

roxelo
Copy link
Member

@roxelo roxelo commented Jul 22, 2020

Still a work in progress

Relies and blocked on rust-lang#74314

Closes rust-lang/project-rfc-2229#4


This change is Reviewable

@roxelo roxelo requested a review from arora-aman July 22, 2020 01:16
@roxelo
Copy link
Member Author

roxelo commented Jul 22, 2020

As expected, many tests are failing currently.

[ui] ui/async-await/await-keyword/incorrect-syntax-suggestions.rs
[ui] ui/async-await/issue-64130-4-async-move.rs
[ui] ui/async-await/issue-67252-unnamed-future.rs
[ui] ui/async-await/issue-68112.rs
[ui] ui/async-await/issue-70818.rs
[ui] ui/async-await/issues/issue-51719.rs
[ui] ui/async-await/issues/issue-62009-2.rs
[ui] ui/async-await/issues/issue-65436-raw-ptr-not-send.rs
[ui] ui/async-await/issues/non-async-enclosing-span.rs
[ui] ui/async-await/try-on-option-in-async.rs
[ui] ui/block-result/issue-20862.rs
[ui] ui/closures/closure-move-sync.rs
[ui] ui/closures/closure-no-fn-1.rs
[ui] ui/closures/closure-no-fn-2.rs
[ui] ui/closures/closure-no-fn-3.rs
[ui] ui/closures/closure-reform-bad.rs
[ui] ui/closures/closure_cap_coerce_many_fail.rs
[ui] ui/closures/closure_no_cap_coerce_many_check_pass.rs
[ui] ui/closures/closure_no_cap_coerce_many_run_pass.rs
[ui] ui/closures/closure_no_cap_coerce_many_unsafe_0.rs
[ui] ui/closures/closure_no_cap_coerce_many_unsafe_1.rs
[ui] ui/closures/issue-46742.rs
[ui] ui/closures/issue-48109.rs
[ui] ui/error-codes/E0057.rs
[ui] ui/error-codes/E0267.rs
[ui] ui/functions-closures/closure-to-fn-coercion.rs
[ui] ui/generator/auto-trait-regions.rs
[ui] ui/generator/generator-yielding-or-returning-itself.rs
[ui] ui/generator/issue-68112.rs
[ui] ui/generator/not-send-sync.rs
[ui] ui/generator/static-not-unpin.rs
[ui] ui/generator/type-mismatch-signature-deduction.rs
[ui] ui/interior-mutability/interior-mutability.rs
[ui] ui/issues/issue-17651.rs
[ui] ui/issues/issue-24036.rs
[ui] ui/issues/issue-31173.rs
[ui] ui/kindck/kindck-nonsendable-1.rs
[ui] ui/mismatched_types/issue-36053-2.rs
[ui] ui/no-send-res-ports.rs
[ui] ui/regions/region-borrow-params-issue-29793-small.rs
[ui] ui/span/E0057.rs
[ui] ui/suggestions/type-ascription-instead-of-let.rs
[ui] ui/try-on-option-diagnostics.rs
[ui] ui/type-alias-impl-trait/issue-63279.rs
[ui] ui/unboxed-closures/unboxed-closures-type-mismatch.rs

@roxelo roxelo requested a review from logmosier July 22, 2020 01:19
@arora-aman
Copy link
Member

@roxelo can u rebase this on rust-lang/master?

src/librustc_typeck/check/coercion.rs Outdated Show resolved Hide resolved
src/librustc_trait_selection/traits/wf.rs Outdated Show resolved Hide resolved
src/librustc_middle/ty/sty.rs Outdated Show resolved Hide resolved
src/librustc_trait_selection/opaque_types.rs Outdated Show resolved Hide resolved
src/librustc_trait_selection/opaque_types.rs Outdated Show resolved Hide resolved
@roxelo roxelo force-pushed the use_tuple_inference_for_closures branch from 3c19b06 to 349f23e Compare July 22, 2020 17:58
Copy link
Member

@arora-aman arora-aman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roxelo did we see any changes in number of tests passing?

Also can you look in rust/build/x86_64-unknown-linux-gnu/test/ui and figure out what is the general theme for the tests failing?

You should be able to compare the expected results in https://github.com/sexxi-goose/rust/tree/master/src/test/ui

The test folder in build aggregates files with name x.rs and x.err in one folder called x and compares x.err agiainst x.stderr in the src/test

src/librustc_typeck/check/coercion.rs Outdated Show resolved Hide resolved
src/librustc_trait_selection/opaque_types.rs Outdated Show resolved Hide resolved
for upvar_ty in substs.as_generator().upvar_tys() {
upvar_ty.visit_with(self);
}
let ty = self.infcx.shallow_resolve(substs.as_generator().upvar_tuple_ty());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we are calling this peice of code a lot now,

can you add something like

upvar_types(cx: &InferCtxt) -> Option<&[Ty]> as niko suggested on zulip?

So if the ty is resolved it return Some(ty), else None

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, can't work because infer depends on middle

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in that case we could just add a method to the inference context, so that you wrote self.infcx.upvar_tys(substs.as_generator()) (and make sure to note that the method exists from upvar_tuple_ty)

src/librustc_middle/ty/sty.rs Outdated Show resolved Hide resolved
@roxelo
Copy link
Member Author

roxelo commented Jul 23, 2020

After the following two changes. Nine of the previous failing tests now pass:

[ui] ui/closures/closure_no_cap_coerce_many_check_pass.rs
[ui] ui/closures/closure_no_cap_coerce_many_run_pass.rs
[ui] ui/closures/closure_no_cap_coerce_many_unsafe_0.rs
[ui] ui/closures/closure_no_cap_coerce_many_unsafe_1.rs
[ui] ui/closures/issue-46742.rs
[ui] ui/closures/issue-48109.rs
[ui] ui/functions-closures/closure-to-fn-coercion.rs
[ui] ui/issues/issue-24036.rs
[ui] ui/regions/region-borrow-params-issue-29793-small.rs

The following tests still fail:

    [ui] ui/async-await/await-keyword/incorrect-syntax-suggestions.rs
    [ui] ui/async-await/issue-64130-4-async-move.rs
    [ui] ui/async-await/issue-67252-unnamed-future.rs
    [ui] ui/async-await/issue-68112.rs
    [ui] ui/async-await/issue-70818.rs
    [ui] ui/async-await/issues/issue-51719.rs
    [ui] ui/async-await/issues/issue-62009-2.rs
    [ui] ui/async-await/issues/issue-65436-raw-ptr-not-send.rs
    [ui] ui/async-await/issues/non-async-enclosing-span.rs
    [ui] ui/async-await/try-on-option-in-async.rs
    [ui] ui/block-result/issue-20862.rs
    [ui] ui/closures/closure-move-sync.rs
    [ui] ui/closures/closure-no-fn-1.rs
    [ui] ui/closures/closure-no-fn-2.rs
    [ui] ui/closures/closure-no-fn-3.rs
    [ui] ui/closures/closure-reform-bad.rs
    [ui] ui/closures/closure_cap_coerce_many_fail.rs
    [ui] ui/error-codes/E0057.rs
    [ui] ui/error-codes/E0267.rs
    [ui] ui/generator/auto-trait-regions.rs
    [ui] ui/generator/generator-yielding-or-returning-itself.rs
    [ui] ui/generator/issue-68112.rs
    [ui] ui/generator/not-send-sync.rs
    [ui] ui/generator/static-not-unpin.rs
    [ui] ui/generator/type-mismatch-signature-deduction.rs
    [ui] ui/interior-mutability/interior-mutability.rs
    [ui] ui/issues/issue-17651.rs
    [ui] ui/issues/issue-31173.rs
    [ui] ui/kindck/kindck-nonsendable-1.rs
    [ui] ui/mismatched_types/issue-36053-2.rs
    [ui] ui/no-send-res-ports.rs
    [ui] ui/span/E0057.rs
    [ui] ui/suggestions/type-ascription-instead-of-let.rs
    [ui] ui/try-on-option-diagnostics.rs
    [ui] ui/type-alias-impl-trait/issue-63279.rs
    [ui] ui/unboxed-closures/unboxed-closures-type-mismatch.rs

Once I have finished my investigation on why the above test fails, I'll add another comment

@jenniferwills
Copy link

jenniferwills commented Jul 27, 2020

common issues:

sty.rs was changed in this PR
error: internal compiler error: src/librustc_middle/ty/sty.rs:2135:18: tuple_fields called on non-tuple
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:915:9

stack backtrace:
   0:     0x7f8e3a76c2cc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf884405d6c157cc7
   1:     0x7f8e3a7f2e17 - core::fmt::write::h90dae023bd746e85
   2:     0x7f8e3a77bfc3 - std::io::Write::write_fmt::h55dd60fe459af5ab
   3:     0x7f8e3a76c17d - std::sys_common::backtrace::print::h72f39b569c774d5a
   4:     0x7f8e3a76e095 - std::panicking::default_hook::{{closure}}::hde73b551a8e04d63
   5:     0x7f8e3a76dea9 - std::panicking::default_hook::hbcc6926c977ca439
   6:     0x7f8e3b0e645c - rustc_driver::report_ice::h669351d34139b940
   7:     0x7f8e3a76e549 - std::panicking::rust_panic_with_hook::h3ddc9bfc1cdf8a55
   8:     0x7f8e3f84e773 - std::panicking::begin_panic::h92330fcd63c0abbf
   9:     0x7f8e3f83ea20 - rustc_errors::HandlerInner::bug::h1492104dd352ab23
  10:     0x7f8e3f83d58a - rustc_errors::Handler::bug::h4407df48f7f3be6a
  11:     0x7f8e3f4797b4 - rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}::h7c7f5a323080ec65
  12:     0x7f8e3f47964b - rustc_middle::ty::context::tls::with_opt::{{closure}}::h037fd34873094571
  13:     0x7f8e3f4795fc - rustc_middle::ty::context::tls::with_opt::he55745146c74eb8b
  14:     0x7f8e3f4796d9 - rustc_middle::util::bug::opt_span_bug_fmt::h674720fcc613bbee
  15:     0x7f8e3f2cf29e - rustc_middle::util::bug::bug_fmt::hff6e58c2a0a9f448
  16:     0x7f8e3f450aa6 - rustc_middle::ty::sty::<impl rustc_middle::ty::TyS>::tuple_fields::hf7c2268c5ab608dc
  17:     0x7f8e3da79d2c - rustc_data_structures::stack::ensure_sufficient_stack::h1a25d97d434632e3
  18:     0x7f8e3d9dcd50 - rustc_traits::dropck_outlives::dtorck_constraint_for_ty::h7fbb6644b4a3799a
  19:     0x7f8e3d9eb1ba - rustc_infer::infer::InferCtxtBuilder::enter_with_canonical::hc5180c06ff62a1f7
  20:     0x7f8e3d9dc8bb - rustc_traits::dropck_outlives::dropck_outlives::h501cd7f1b8560305
  21:     0x7f8e3ee49396 - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::dropck_outlives>::compute::h35ba903d0686dcf8
  22:     0x7f8e3ef44f83 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::he8dcdb299be47235
  23:     0x7f8e3ef47adf - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::h7790fea3d30a0c95
  24:     0x7f8e3efd5322 - rustc_data_structures::stack::ensure_sufficient_stack::hd1125bf29b8eb3ca
  25:     0x7f8e3eefc7ec - rustc_query_system::query::plumbing::get_query_impl::h2ea9b4cbd6e66b56
  26:     0x7f8e3ee494dc - <rustc_infer::infer::at::At as rustc_trait_selection::traits::query::dropck_outlives::AtExt>::dropck_outlives::h0eda9216d13f7e1c
  27:     0x7f8e3dce2977 - rustc_typeck::check::dropck::check_drop_obligations::h99ce453e13b86c1b
  28:     0x7f8e3ddaef98 - rustc_hir::hir::Pat::walk_::ha93224746d478e10
  29:     0x7f8e3ddb0514 - rustc_hir::pat_util::<impl rustc_hir::hir::Pat>::each_binding::hc93e42d04379f221
  30:     0x7f8e3dde25d7 - <rustc_typeck::check::regionck::RegionCtxt as rustc_hir::intravisit::Visitor>::visit_local::h592c29765d8c9504
  31:     0x7f8e3de39d06 - rustc_hir::intravisit::walk_expr::hc8a815ad730ea817
  32:     0x7f8e3dde2b5b - <rustc_typeck::check::regionck::RegionCtxt as rustc_hir::intravisit::Visitor>::visit_expr::h653bec822952db49
  33:     0x7f8e3dde22cd - rustc_typeck::check::regionck::RegionCtxt::visit_fn_body::h02d2ebbdd8b838c9
  34:     0x7f8e3dc80c7d - rustc_typeck::check::regionck::<impl rustc_typeck::check::FnCtxt>::regionck_fn::h092026dea4b8e7a9
  35:     0x7f8e3dd95a79 - rustc_infer::infer::InferCtxtBuilder::enter::h1087d6648abac187
  36:     0x7f8e3dec2b54 - rustc_typeck::check::typeck_with_fallback::hf3413b3099a79a54
  37:     0x7f8e3dc837bb - rustc_typeck::check::typeck::h5cae1099b740539a
  38:     0x7f8e3dd74eae - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck>::compute::h35bb7de02b429322
  39:     0x7f8e3dd401df - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::h87509ee919b74cc9
  40:     0x7f8e3dec8063 - rustc_data_structures::stack::ensure_sufficient_stack::h39ddbb6e7a59ed60
  41:     0x7f8e3de9f2b6 - rustc_query_system::query::plumbing::get_query_impl::hfa8c96bc61797ce2
  42:     0x7f8e3dea1caf - rustc_query_system::query::plumbing::ensure_query_impl::h36b70674ce6df1b2
  43:     0x7f8e3dd74e29 - rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::par_body_owners::h20a057f49342677e
  44:     0x7f8e3dc8328d - rustc_typeck::check::typeck_item_bodies::h336720b69ff6d98c
  45:     0x7f8e3de1e38e - 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::h44e1803829c3d01b
  46:     0x7f8e3dd4718f - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::hdbdeb8d54c121e9b
  47:     0x7f8e3dec5ba3 - rustc_data_structures::stack::ensure_sufficient_stack::h06ff421d243bce8f
  48:     0x7f8e3de8e8bb - rustc_query_system::query::plumbing::get_query_impl::hbb0e66da6b36c942
  49:     0x7f8e3de1ea22 - rustc_session::utils::<impl rustc_session::session::Session>::time::hbf0873ea716fb68d
  50:     0x7f8e3dddae9e - rustc_typeck::check_crate::hb6e9403a1863495b
  51:     0x7f8e3b259acf - rustc_interface::passes::analysis::h7f451e59e548569c
  52:     0x7f8e3b0a9bfb - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute::h629ed809fb9f8bef
  53:     0x7f8e3b0dc22f - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::hbc6ae9595f54ffb1
  54:     0x7f8e3b0dcce0 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_eval_always_task::h1a872e681a3969bc
  55:     0x7f8e3b0c62f4 - rustc_data_structures::stack::ensure_sufficient_stack::hf8ad3bb6e2549bf9
  56:     0x7f8e3b0c9b13 - rustc_query_system::query::plumbing::get_query_impl::heca530f2189d151d
  57:     0x7f8e3b0aa03f - rustc_middle::ty::context::tls::enter_global::hf5949ffe6845b31c
  58:     0x7f8e3b06d525 - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::hb53330577f919d08
  59:     0x7f8e3b06b4a0 - rustc_span::with_source_map::h90e986e49cea0427
  60:     0x7f8e3b06dc93 - rustc_interface::interface::create_compiler_and_run::h09d4e6d64925ffad
  61:     0x7f8e3b06bfa4 - scoped_tls::ScopedKey<T>::set::hab57bb33015630e1
  62:     0x7f8e3afd5544 - rustc_ast::attr::with_session_globals::h4b9653ede0e01f55
  63:     0x7f8e3b0c30c1 - std::sys_common::backtrace::__rust_begin_short_backtrace::h104eb60f00600f01
  64:     0x7f8e3b067b46 - std::panicking::try::hbac77c8e6ff99cd5
  65:     0x7f8e3b06ac6e - core::ops::function::FnOnce::call_once{{vtable.shim}}::h6fe5a7f07ddc0b52
  66:     0x7f8e3a75cd78 - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h360f3d8fe0afa8c5
  67:     0x7f8e3a758ffa - std::sys::unix::thread::Thread::new::thread_start::h99a1381164ee7465
  68:     0x7f8e3a297fa3 - start_thread
  69:     0x7f8e3a5d94cf - clone
  70:                0x0 - <unknown>

files:

[ui] ui/async-await/await-keyword/incorrect-syntax-suggestions.rs
[ui] ui/async-await/issues/issue-51719.rs
[ui] ui/async-await/issues/issue-62009-2.rs
[ui] ui/async-await/issues/non-async-enclosing-span.rs
[ui] ui/async-await/try-on-option-in-async.rs
[ui] ui/error-codes/E0057.rs
[ui] ui/error-codes/E0267.rs
[ui] ui/issues/issue-17651.rs
[ui] ui/span/E0057.rs
[ui] ui/suggestions/type-ascription-instead-of-let.rs
[ui] ui/try-on-option-diagnostics.rs
[ui] ui/type-alias-impl-trait/issue-63279.rs
[ui] ui/unboxed-closures/unboxed-closures-type-mismatch.rs

    error: internal compiler error: broken MIR in DefId(0:12 ~ issue_65436_raw_ptr_not_send[317d]::main[0]) (NoSolution): could not prove Binder(TraitPredicate(<impl std::future::Future as std::marker::Send>))
   |
   = note: delayed at src/librustc_mir/borrow_check/type_check/mod.rs:258:27

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:366:17

stack backtrace:
   0:     0x7f70b886c2cc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf884405d6c157cc7
   1:     0x7f70b88f2e17 - core::fmt::write::h90dae023bd746e85
   2:     0x7f70b887bfc3 - std::io::Write::write_fmt::h55dd60fe459af5ab
   3:     0x7f70b886c17d - std::sys_common::backtrace::print::h72f39b569c774d5a
   4:     0x7f70b886e095 - std::panicking::default_hook::{{closure}}::hde73b551a8e04d63
   5:     0x7f70b886dea9 - std::panicking::default_hook::hbcc6926c977ca439
   6:     0x7f70b91e645c - rustc_driver::report_ice::h669351d34139b940
   7:     0x7f70b886e549 - std::panicking::rust_panic_with_hook::h3ddc9bfc1cdf8a55
   8:     0x7f70bd94e74e - std::panicking::begin_panic::h41c341d5156adc36
   9:     0x7f70bd955b74 - <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop::h5d18a4277c38fe2a
  10:     0x7f70b918caba - core::ptr::drop_in_place::h71c244dedad5c5a2
  11:     0x7f70b91869f5 - core::ptr::drop_in_place::h552f28d698448c03
  12:     0x7f70b9172a70 - core::ptr::drop_in_place::h1422f5b5516a2a86
  13:     0x7f70b91959c1 - core::ptr::drop_in_place::haaca922ee45ac1c0
  14:     0x7f70b916b77e - rustc_span::with_source_map::h90e986e49cea0427
  15:     0x7f70b916dc93 - rustc_interface::interface::create_compiler_and_run::h09d4e6d64925ffad
  16:     0x7f70b916bfa4 - scoped_tls::ScopedKey<T>::set::hab57bb33015630e1
  17:     0x7f70b90d5544 - rustc_ast::attr::with_session_globals::h4b9653ede0e01f55
  18:     0x7f70b91c30c1 - std::sys_common::backtrace::__rust_begin_short_backtrace::h104eb60f00600f01
  19:     0x7f70b9167b46 - std::panicking::try::hbac77c8e6ff99cd5
  20:     0x7f70b916ac6e - core::ops::function::FnOnce::call_once{{vtable.shim}}::h6fe5a7f07ddc0b52
  21:     0x7f70b885cd78 - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h360f3d8fe0afa8c5
  22:     0x7f70b8858ffa - std::sys::unix::thread::Thread::new::thread_start::h99a1381164ee7465
  23:     0x7f70b8397fa3 - start_thread
  24:     0x7f70b86d94cf - clone
  25:                0x0 - <unknown>

(in this error, the error type + note at the bottom is the same, the rest includes the actual file names etc)

files:
[ui] ui/async-await/issues/issue-65436-raw-ptr-not-send.rs
[ui] ui/async-await/issue-67252-unnamed-future.rs
[ui] ui/generator/not-send-sync.rs
[ui] ui/interior-mutability/interior-mutability.rs
[ui] ui/kindck/kindck-nonsendable-1.rs
[ui] ui/no-send-res-ports.rs

error: internal compiler error: errors selecting obligation during MIR typeck: [FulfillmentError(Obligation(predicate=Binder(TraitPredicate(<U as std::marker::Send>)), depth=3),Unimplemented)]
   |
   = note: delayed at /users/jgwills/rust/src/librustc_trait_selection/traits/query/type_op/custom.rs:84:37

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:366:17

stack backtrace:
   0:     0x7fb8372c42cc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf884405d6c157cc7
   1:     0x7fb83734ae17 - core::fmt::write::h90dae023bd746e85
   2:     0x7fb8372d3fc3 - std::io::Write::write_fmt::h55dd60fe459af5ab
   3:     0x7fb8372c417d - std::sys_common::backtrace::print::h72f39b569c774d5a
   4:     0x7fb8372c6095 - std::panicking::default_hook::{{closure}}::hde73b551a8e04d63
   5:     0x7fb8372c5ea9 - std::panicking::default_hook::hbcc6926c977ca439
   6:     0x7fb837c3e45c - rustc_driver::report_ice::h669351d34139b940
   7:     0x7fb8372c6549 - std::panicking::rust_panic_with_hook::h3ddc9bfc1cdf8a55
   8:     0x7fb83c3a674e - std::panicking::begin_panic::h41c341d5156adc36
   9:     0x7fb83c3adb74 - <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop::h5d18a4277c38fe2a
  10:     0x7fb837be4aba - core::ptr::drop_in_place::h71c244dedad5c5a2
  11:     0x7fb837bde9f5 - core::ptr::drop_in_place::h552f28d698448c03
  12:     0x7fb837bcaa70 - core::ptr::drop_in_place::h1422f5b5516a2a86
  13:     0x7fb837bed9c1 - core::ptr::drop_in_place::haaca922ee45ac1c0
  14:     0x7fb837bc377e - rustc_span::with_source_map::h90e986e49cea0427
  15:     0x7fb837bc5c93 - rustc_interface::interface::create_compiler_and_run::h09d4e6d64925ffad
  16:     0x7fb837bc3fa4 - scoped_tls::ScopedKey<T>::set::hab57bb33015630e1
  17:     0x7fb837b2d544 - rustc_ast::attr::with_session_globals::h4b9653ede0e01f55
  18:     0x7fb837c1b0c1 - std::sys_common::backtrace::__rust_begin_short_backtrace::h104eb60f00600f01
  19:     0x7fb837bbfb46 - std::panicking::try::hbac77c8e6ff99cd5
  20:     0x7fb837bc2c6e - core::ops::function::FnOnce::call_once{{vtable.shim}}::h6fe5a7f07ddc0b52
  21:     0x7fb8372b4d78 - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h360f3d8fe0afa8c5
  22:     0x7fb8372b0ffa - std::sys::unix::thread::Thread::new::thread_start::h99a1381164ee7465
  23:     0x7fb836deffa3 - start_thread
  24:     0x7fb8371314cf - clone
  25:                0x0 - <unknown>


files:
[ui] ui/async-await/issue-64130-4-async-move.rs
[ui] ui/async-await/issue-70818.rs

^ expected fn pointer, found closure
files:
[ui] ui/closures/closure-no-fn-1.rs 6:29
[ui] ui/closures/closure-no-fn-2.rs 6:27
[ui] ui/closures/closure-reform-bad.rs 11:15

@jenniferwills
Copy link

jenniferwills commented Jul 27, 2020

There are also a few other files not included in this overview that actually have a different stderr than expected, but they are mostly unique per file, see build logs

// All we care here is if any variable is being captured and not the exact paths,
// so we check `upvars_mentioned` for root variables being captured.
ty::FnPtr(fn_ty)
if self.tcx.upvars_mentioned(closure_def_id_a.expect_local()).is_none() =>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion from aman:try size ==1 instead of is_none()

Copy link
Member

@arora-aman arora-aman Jul 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or maybe self.tcx.upvars_mentioned(closure_def_id_a.expect_local().map_or(true, |u| u.is_empty())

for ty in substs.as_closure().upvar_tys() {
dtorck_constraint_for_ty(tcx, span, for_ty, depth + 1, ty, constraints)?;
ty::Closure(_, substs) => {
if !substs.as_closure().is_valid() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment here

            // By the time this code runs, all type variables ought to		            // By the time this code runs, all type variables ought to
            // be fully resolved.

Same as the ty::Infer case

@@ -241,6 +247,10 @@ fn dtorck_constraint_for_ty<'tcx>(
// derived from lifetimes attached to the upvars and resume
// argument, and we *do* incorporate those here.

if !substs.as_generator().is_valid() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment here

            // By the time this code runs, all type variables ought to		            // By the time this code runs, all type variables ought to
            // be fully resolved.

Same as the ty::Infer case

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm well im already deleting my folder so i can use ssh
so that it a later issue

let ty = self.infcx.shallow_resolve(substs.as_closure().upvar_tuple_ty());
if let ty::Infer(ty::TyVar(_)) = ty.kind {
// Not yet resolved.
warn!("asked to assemble constituent types of unexpected type: {:?}", t);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be bug!, like the calls above

for upvar_ty in substs.as_closure().upvar_tys() {
// FIXME(eddyb) add the type to `walker` instead of recursing.
self.compute(upvar_ty.into());
let ty = self.infcx.shallow_resolve(substs.as_closure().upvar_tuple_ty());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can just be self.compute(substs.as_closure().upvar_tuple_ty()), I believe, as inference variables will already be resolved in that recursive call

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dtorck_constraint_for_ty(tcx, span, for_ty, depth + 1, ty, constraints)?;
ty::Closure(_, substs) => {
if !substs.as_closure().is_valid() {
return Err(NoSolution);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this code can also just recursive on the upvar_tys, because the inference variable should be replaced by this point with a tuple

Copy link
Member

@arora-aman arora-aman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woops I forgot to submit this

for upvar_ty in substs.as_closure().upvar_tys() {
// FIXME(eddyb) add the type to `walker` instead of recursing.
self.compute(upvar_ty.into());
let ty = self.infcx.shallow_resolve(substs.as_closure().upvar_tuple_ty());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

giraffate and others added 15 commits September 8, 2020 08:25
…oli-obk

Add derive macro for specifying diagnostics using attributes.

Introduces `#[derive(SessionDiagnostic)]`, a derive macro for specifying structs that can be converted to Diagnostics using directions given by attributes on the struct and its fields. Currently, the following attributes have been implemented:
- `#[code = "..."]` -- this sets the Diagnostic's error code, and must be provided on the struct iself (ie, not on a field). Equivalent to calling `code`.
- `#[message = "..."]` -- this sets the Diagnostic's primary error message.
- `#[label = "..."]` -- this must be applied to fields of type `Span`, and is equivalent to `span_label`
- `#[suggestion(..)]` -- this allows a suggestion message to be supplied. This attribute must be applied to a field of type `Span` or `(Span, Applicability)`, and is equivalent to calling `span_suggestion`. Valid arguments are:
    - `message = "..."` -- this sets the suggestion message.
    - (Optional) `code = "..."` -- this suggests code for the suggestion. Defaults to empty.

`suggestion`also  comes with other variants: `#[suggestion_short(..)]`, `#[suggestion_hidden(..)]` and `#[suggestion_verbose(..)]` which all take the same keys.

Within the strings passed to each attribute, fields can be referenced without needing to be passed explicitly into the format string -- eg, `#[error = "{ident} already declared"] ` will set the error message to `format!("{} already declared", &self.ident)`. Any fields on the struct can be referenced in this way.

Additionally, for any of these attributes, Option fields can be used to only optionally apply the decoration -- for example:

```rust
#[derive(SessionDiagnostic)]
#[code = "E0123"]
struct SomeKindOfError {
    ...
    #[suggestion(message = "informative error message")]
    opt_sugg: Option<(Span, Applicability)>
    ...
}
```
will not emit a suggestion if `opt_sugg` is `None`.

We plan on iterating on this macro further; this PR is a start.

Closes rust-lang#61132.

r? `@oli-obk`
Co-authored-by: Peter Todd <pete@petertodd.org>
…-obk

Tracing update

This does not bring the more significant changes that are coming down the pipeline, but since I've already prepared the PR leaving it up :)

See rust-lang#76210 (comment):
> Unfortunately, tracing 0.1.20 — which contained the change to reduce the amount of code generated by the tracing macros — had to be yanked, as it broke previously-compiling code for some downstream crates. I've not yet had the chance to fix this and release a new patch. So, in order to benefit from the changes to reduce generated code, you'll need to wait until there's a new version of tracing as well as tracing-attributes and tracing-core.
Do not promote &mut of a non-ZST ever

Since ~pre-1.0~ 1.36, we have accepted code like this:
```rust
static mut TEST: &'static mut [i32] = {
    let x = &mut [1,2,3];
    x
};
```
I tracked it back to rust-lang#21744, but unfortunately could not find any discussion or RFC that would explain why we thought this was a good idea. And it's not, it breaks all sorts of things -- see rust-lang#75556.

To fix rust-lang#75556, we have to stop promoting non-ZST mutable references no matter the context, which is what this PR does. It's a breaking change.

Notice that this still works, since it does not rely on promotion:
```rust
static mut TEST: &'static mut [i32] = &mut [0,1,2];
```

Cc `@rust-lang/wg-const-eval`
…yn514

Make bootstrap build on beta

This is generally a good idea, and will help with being able to build bootstrap
without Python over time as it means we can "just" build with cargo +beta build
rather than needing the user to set environment variables. This is a minor step,
but a necessary one on that road.

r? `@jyn514`
RalfJung and others added 26 commits September 12, 2020 10:43
…=lcnr

Finish off revisions for const generics UI tests.

This time it really does fix it. 😅 The only ones left are `min-and-full-same-time.rs`, which doesn't need it, and `array-impls/` which check the feature indirectly.

Fixes rust-lang#75279.

r? @lcnr
…ary-ops, r=jyn514

Add missing examples on binary core traits

r? @jyn514
Rollup of 7 pull requests

Successful merges:

 - rust-lang#76114 (Add saturating methods for `Duration`)
 - rust-lang#76297 (rustdoc: fix min_const_generics with ty::Param)
 - rust-lang#76484 (Add MaybeUninit::assume_init_drop.)
 - rust-lang#76530 (Eliminate mut reference UB in Drop impl for Rc<T>)
 - rust-lang#76583 (Update `std::os` module documentation.)
 - rust-lang#76599 (Finish off revisions for const generics UI tests.)
 - rust-lang#76615 (Add missing examples on binary core traits)

Failed merges:

r? `@ghost`
…Amanieu

Use IOV_MAX and UIO_MAXIOV constants in limit vectored I/O

Also updates the libc dependency to 0.2.77 (from 0.2.74) as the
constants were only recently added.

Related rust-lang#68042, rust-lang#75005

r? `@Amanieu` (also reviewed rust-lang#75005)
update the version of itertools and parking_lot

this is to avoid compiling multiple version of the crates in rustc speeding up compilation of rustc

an old version of parking_lot is still used in measureme but new version will not be released for some time see [zulip chat](https://rust-lang.zulipchat.com/#narrow/stream/187831-t-compiler.2Fwg-self-profile/topic/new.20release.20of.20measureme)
It is really painful to inspect differences in what was built in CI if things
are appearing and disappearing randomly as they hover around the 100ms mark. No
matter what we choose there's always going to be quite a bit of variability on
CI in timing, so we're going to see things appear and vanish.
Add host triples to CI builders

This is a follow-up to rust-lang#76415, which changed how x.py interprets cross-compilation target/host flags. This should fix the known cases, but I'm still working through CI logs before/after that PR to identify if anything else is missing.
…s-unstable-trait-impl, r=lcnr

Warn for #[unstable] on trait impls when it has no effect.

Earlier today I sent a PR with an `#[unstable]` attribute on a trait `impl`, but was informed that this attribute has no effect there. (comment: rust-lang#76525 (comment), issue: rust-lang#55436)

This PR adds a warning for this situation. Trait `impl` blocks with `#[unstable]` where both the type and the trait are stable will result in a warning:

```
warning: An `#[unstable]` annotation here has no effect. See issue rust-lang#55436 <rust-lang#55436> for more information.
   --> library/std/src/panic.rs:235:1
    |
235 | #[unstable(feature = "integer_atomics", issue = "32976")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

---

It detects three problems in the existing code:

1. A few `RefUnwindSafe` implementations for the atomic integer types in `library/std/src/panic.rs`. Example:
https://github.com/rust-lang/rust/blob/d92155bf6ae0b7d79fc83cbeeb0cc0c765353471/library/std/src/panic.rs#L235-L236
2. An implementation of `Error` for `LayoutErr` in `library/std/srd/error.rs`:
https://github.com/rust-lang/rust/blob/d92155bf6ae0b7d79fc83cbeeb0cc0c765353471/library/std/src/error.rs#L392-L397
3. `From` implementations for `Waker` and `RawWaker` in `library/alloc/src/task.rs`. Example:
https://github.com/rust-lang/rust/blob/d92155bf6ae0b7d79fc83cbeeb0cc0c765353471/library/alloc/src/task.rs#L36-L37

Case 3 interesting: It has a bound with an `#[unstable]` trait (`W: Wake`), so appears to have much effect on stable code. It does however break similar blanket implementations. It would also have immediate effect if `Wake` was implemented for any stable type. (Which is not the case right now, but there are no warnings in place to prevent it.) Whether this case is a problem or not is not clear to me. If it isn't, adding a simple `c.visit_generics(..);` to this PR will stop the warning for this case.
This avoids missing a shared build when uplifting LLVM artifacts into the
sysroot. We were already producing a shared link anyway, though, so this is not
a visible change from the end user's perspective.
…ement, r=matthewjasper

Validate built-in attribute placement

Closes rust-lang#54584, closes rust-lang#47725, closes rust-lang#54044.

I've changed silently ignoring some incorrectly placed attributes to errors.  I'm not sure what the policy is since this can theoretically break code (should they be warnings instead? does it warrant a crater run?).
NRVO: Allow occurrences of the return place in var debug info

The non-use occurrence of the return place in var debug info does not
currently inhibit NRVO optimization, but it will fail assertion in
`visit_place` when optimization is performed.

Relax assertion check to allow the return place in var debug info.

This case might be impossible to hit in optimization pipelines as of
now, but can be encountered in customized mir-opt-level=2 pipeline with
copy propagation disabled. For example in:

```rust
pub fn b(s: String) -> String {
    a(s)
}

#[inline]
pub fn a(s: String) -> String {
    let x = s;
    let y = x;
    y
}
```
Download LLVM from CI to bootstrap (linux-only to start)

This follows rust-lang#76332, adding support for using CI-built LLVM rather than building it locally. This should essentially "just work," but is left off by default in this PR.

While we can support downloading LLVM for multiple host triples, this currently only downloads it for the build triple. That said, it should be possible to expand this relatively easily should multiple host triples be desired. Most people shouldn't be adjusting host/target triples though, so this should cover most use cases.

Currently this downloads LLVM for the last bors-authored commit in the `git log`. This is a bit suboptimal -- we want the last bors-authored commit that touched the llvm-project submodule in basically all cases. But for now this just adds an extra ~20 MB download when rebasing atop latest master. Once we have a submodule bump landing after rust-lang#76332, we can fix this behavior to reduce downloads further.
Previously, we would throw away the `SyntaxContext` of any span with a
dummy location during metadata encoding. This commit makes metadata Span
encoding consistent with incr-cache Span encoding - an 'invalid span'
tag is only used when it doesn't lose any information.
…enkov

Ignore `|` and `+` tokens during proc-macro pretty-print check

Fixes rust-lang#76182

This is an alternative to PR rust-lang#76188

These tokens are not preserved in the AST in certain cases
(e.g. a leading `|` in a pattern or a trailing `+` in a trait bound).

This PR ignores them entirely during the pretty-print/reparse check
to avoid spuriously using the re-parsed tokenstream.
…Simulacrum

Add a dedicated debug-logging option to config.toml

`@Mark-Simulacrum` and I were talking in zulip and we found that turning on debug/trace logging in rustc is fairly confusing, as it effectively depends on debug-assertions and is not documented as such. `@Mark-Simulacrum` mentioned that we should probably have a separate option for logging anyways.

this diff adds that, having the option follow debug-assertions (so everyone's existing config.toml should be fine) and if the option is false

to test I ran ./x.py test <something> twice, once with `debug-logging = false` and once with `debug-logging = true` and made sure i only saw trace's when it was true
…r=lcnr

Properly encode spans with a dummy location and non-root `SyntaxContext`

Previously, we would throw away the `SyntaxContext` of any span with a
dummy location during metadata encoding. This commit makes metadata Span
encoding consistent with incr-cache Span encoding - an 'invalid span'
tag is only used when it doesn't lose any information.
…ebank

Fixing memory exhaustion when formatting short code suggestion

Details can be found in issue rust-lang#76597. This PR replaces substractions with `saturating_sub`'s to avoid usize wrapping leading to memory exhaustion when formatting short suggestion messages.
Use shallow_resolve and is_valid to check if tuple has been resolved
Check upvars_mentioned instead of substs to coerce closure to fnptr

Co-authored-by: Aman Arora <me@aman-arora.com>
Co-authored-by: Aman Arora <me@aman-arora.com>
@roxelo
Copy link
Member Author

roxelo commented Sep 15, 2020

Changes have been rebased on the latest changes.
Still a lot of failing tests (182), logs and trace can be found here: https://csclub.uwaterloo.ca/~rlmmfruy/build-logs/Pull21Logs

I will do a more thorough analysis in the next few days, but, at first glance, there seems to be 2 recurring issues:

error: Error: expected failure status (Some(1)) but received status Some(101).
error: test compilation failed although it shouldn't!
status: exit code: 101

caused by

error: internal compiler error: compiler/rustc_trait_selection/src/traits/select/mod.rs:1743:21: asked to assemble constituent types of unexpected type for Closure: _

@roxelo
Copy link
Member Author

roxelo commented Sep 16, 2020

Moving the conversation to #23 as it is now impossible to keep track of all the changes as a result of the rebase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Always make the "upvar types" a tuple of the actual upvar types (Parent issue#53488)