rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.97k stars 12.68k forks source link

Unexplained errors applying `-Z instrument-coverage` to some rustc `ui` tests #80045

Open richkadel opened 3 years ago

richkadel commented 3 years ago

When experimentally adding -Zinstrument-coverage to the set of ui tests in the Rust source tree, most tests still pass; of those that don't, almost all failures can be explained, and some improvements have been made to surface known incompatibilities between -Zinstrument-coverage and other compiler options (see https://github.com/rust-lang/rust/pull/79958#issuecomment-743958675).

However, there are ~4~ 3 tests that still fail with -Zinstrument-coverage that I don't understand.

I'm hoping someone(s) that understand these tests and/or compiler options can take a look, explain why they are expected to fail, or clarify what the bug might be, if they should not fail.


Fixed via #80072

~$ ./x.py test --rustc-args="-Zinstrument-coverage" src/test/ui/consts/unstable-precise-live-drops-in-libcore.rs~

~Failure due to: error[E0493]: destructors cannot be evaluated at compile-time --> /usr/local/google/home/richkadel/rust/src/test/ui/consts/unstable-precise-live-drops-in-libcore.rs:15:25 | LL | pub const fn unwrap(self) -> T { | ^^^^ constant functions cannot evaluate destructors (this error is printed twice)~


$ ./x.py test --rustc-args="-Zinstrument-coverage" src/test/ui/issues/issue-33287.rs

Failure due to:
   stderr:
   ------------------------------------------
   error: this operation will panic at runtime
     --> /usr/local/google/home/richkadel/rust/src/test/ui/issues/issue-33287.rs:7:17
      |
   LL |     let range = A[1]..;
      |                 ^^^^ index out of bounds: the length is 1 but the index is 1
      |
      = note: `#[deny(unconditional_panic)]` on by default

$ ./x.py test --rustc-args="-Zinstrument-coverage" src/test/ui/print_type_sizes/niche-filling.rs

Failure due to additional lines in the compiler output:
   +       print-type-size type: `std::option::Option<std::num::NonZeroU32>`: 4 bytes, alignment: 4 bytes
   +       print-type-size     variant `Some`: 4 bytes
   +       print-type-size         field `.0`: 4 bytes
   +       print-type-size     variant `None`: 0 bytes

$ ./x.py test --rustc-args="-Zinstrument-coverage" src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs

Failure due to:
   error: internal compiler error:
   compiler/rustc_traits/src/normalize_erasing_regions.rs:43:32:
   could not fully normalize `std::option::Option<<i32 as std::iter::Iterator>::Item>`
richkadel commented 3 years ago

@tmandry @wesleywiser

I created this issue for the 4 tests that created errors or output that I can't explain.

richkadel commented 3 years ago

I don't know if any of these issues are actually bugs in -Z instrument-coverage, or acceptable incompatabilities. In case there are bugs, they might affect the tracking issue: #79121

tmandry commented 3 years ago

unstable-precise-live-drops-in-libcore.rs emits unused code warnings, but only if -Zinstrument-coverage is not specified:

> rustc +stage1 src/test/ui/consts/unstable-precise-live-drops-in-libcore.rs
warning: enum is never used: `Either`
 --> src/test/ui/consts/unstable-precise-live-drops-in-libcore.rs:7:6
  |
7 | enum Either<T, S> {
  |      ^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: associated function is never used: `unwrap`
  --> src/test/ui/consts/unstable-precise-live-drops-in-libcore.rs:15:18
   |
15 |     pub const fn unwrap(self) -> T {
   |                  ^^^^^^

warning: 2 warnings emitted

Backtrace:

``` > RUST_BACKTRACE=1 rustc +stage1 -Zinstrument-coverage -Ztreat-err-as-bug src/test/ui/consts/unstable-precise-live-drops-in-libcore.rs error[E0493]: destructors cannot be evaluated at compile-time --> src/test/ui/consts/unstable-precise-live-drops-in-libcore.rs:15:25 | 15 | pub const fn unwrap(self) -> T { | ^^^^ constant functions cannot evaluate destructors thread 'rustc' panicked at 'aborting due to `-Z treat-err-as-bug=1`', compiler/rustc_errors/src/lib.rs:990:27 stack backtrace: 0: std::panicking::begin_panic at ./library/std/src/panicking.rs:519:12 1: rustc_errors::HandlerInner::panic_if_treat_err_as_bug at ./compiler/rustc_errors/src/lib.rs:990:27 2: rustc_errors::HandlerInner::bump_err_count at ./compiler/rustc_errors/src/lib.rs:980:9 3: rustc_errors::HandlerInner::emit_diagnostic at ./compiler/rustc_errors/src/lib.rs:796:13 4: rustc_errors::Handler::emit_diagnostic at ./compiler/rustc_errors/src/lib.rs:715:9 5: rustc_errors::diagnostic_builder::DiagnosticBuilder::emit at ./compiler/rustc_errors/src/diagnostic_builder.rs:101:9 6: rustc_mir::transform::check_consts::post_drop_elaboration::CheckLiveDrops::check_live_drop at ./compiler/rustc_mir/src/transform/check_consts/post_drop_elaboration.rs:59:9 7: ::visit_terminator at ./compiler/rustc_mir/src/transform/check_consts/post_drop_elaboration.rs:93:21 8: ::visit_basic_block_data at ./compiler/rustc_mir/src/transform/check_consts/post_drop_elaboration.rs:72:9 9: rustc_middle::mir::visit::Visitor::super_body at ./compiler/rustc_middle/src/mir/visit.rs:259:21 10: rustc_middle::mir::visit::Visitor::visit_body at ./compiler/rustc_middle/src/mir/visit.rs:78:17 11: rustc_mir::transform::check_consts::post_drop_elaboration::check_live_drops at ./compiler/rustc_mir/src/transform/check_consts/post_drop_elaboration.rs:40:5 12: rustc_mir::transform::mir_drops_elaborated_and_const_checked at ./compiler/rustc_mir/src/transform/mod.rs:341:5 13: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::mir_drops_elaborated_and_const_checked>::compute at ./compiler/rustc_middle/src/ty/query/plumbing.rs:377:17 14: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl at ./compiler/rustc_query_system/src/dep_graph/graph.rs:301:14 15: rustc_query_system::dep_graph::graph::DepGraph::with_task at ./compiler/rustc_query_system/src/dep_graph/graph.rs:200:9 16: rustc_query_system::query::plumbing::force_query_with_job::{{closure}}::{{closure}} at ./compiler/rustc_query_system/src/query/plumbing.rs:608:17 17: rustc_middle::ty::query::plumbing::::start_query::{{closure}}::{{closure}}::{{closure}} at ./compiler/rustc_middle/src/ty/query/plumbing.rs:73:74 18: stacker::maybe_grow at /usr/local/google/home/tmandry/.cargo/registry/src/github.com-1ecc6299db9ec823/stacker-0.1.12/src/lib.rs:55:9 19: rustc_data_structures::stack::ensure_sufficient_stack at ./compiler/rustc_data_structures/src/stack.rs:16:5 20: rustc_middle::ty::query::plumbing::::start_query::{{closure}}::{{closure}} at ./compiler/rustc_middle/src/ty/query/plumbing.rs:73:17 21: rustc_middle::ty::context::tls::enter_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1733:50 22: rustc_middle::ty::context::tls::set_tlv at ./compiler/rustc_middle/src/ty/context.rs:1717:9 23: rustc_middle::ty::context::tls::enter_context at ./compiler/rustc_middle/src/ty/context.rs:1733:9 24: rustc_middle::ty::query::plumbing::::start_query::{{closure}} at ./compiler/rustc_middle/src/ty/query/plumbing.rs:72:13 25: rustc_middle::ty::context::tls::with_related_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1777:13 26: rustc_middle::ty::context::tls::with_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1761:40 27: rustc_middle::ty::context::tls::with_context_opt at ./compiler/rustc_middle/src/ty/context.rs:1750:22 28: rustc_middle::ty::context::tls::with_context at ./compiler/rustc_middle/src/ty/context.rs:1761:9 29: rustc_middle::ty::context::tls::with_related_context at ./compiler/rustc_middle/src/ty/context.rs:1774:9 30: rustc_middle::ty::query::plumbing::::start_query at ./compiler/rustc_middle/src/ty/query/plumbing.rs:61:9 31: rustc_query_system::query::plumbing::force_query_with_job::{{closure}} at ./compiler/rustc_query_system/src/query/plumbing.rs:598:9 32: rustc_query_system::query::plumbing::with_diagnostics at ./compiler/rustc_query_system/src/query/plumbing.rs:302:18 33: rustc_query_system::query::plumbing::force_query_with_job at ./compiler/rustc_query_system/src/query/plumbing.rs:597:51 34: rustc_query_system::query::plumbing::try_execute_query at ./compiler/rustc_query_system/src/query/plumbing.rs:426:16 35: rustc_query_system::query::plumbing::get_query_impl::{{closure}} at ./compiler/rustc_query_system/src/query/plumbing.rs:645:23 36: as rustc_query_system::query::caches::QueryCache>::lookup at ./compiler/rustc_query_system/src/query/caches.rs:114:79 37: rustc_query_system::query::plumbing::try_get_cached at ./compiler/rustc_query_system/src/query/plumbing.rs:379:5 38: rustc_query_system::query::plumbing::get_query_impl at ./compiler/rustc_query_system/src/query/plumbing.rs:637:5 39: rustc_query_system::query::plumbing::ensure_query_impl 40: rustc_query_system::query::plumbing::ensure_query at ./compiler/rustc_query_system/src/query/plumbing.rs:749:5 41: rustc_middle::ty::query::TyCtxtEnsure::mir_drops_elaborated_and_const_checked at ./compiler/rustc_middle/src/ty/query/plumbing.rs:404:17 42: rustc_interface::passes::analysis::{{closure}} at ./compiler/rustc_interface/src/passes.rs:865:17 43: rustc_data_structures::profiling::VerboseTimingGuard::run at ./compiler/rustc_data_structures/src/profiling.rs:570:9 44: rustc_session::utils::::time at ./compiler/rustc_session/src/utils.rs:9:9 45: rustc_interface::passes::analysis at ./compiler/rustc_interface/src/passes.rs:860:5 46: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::analysis>::compute at ./compiler/rustc_middle/src/ty/query/plumbing.rs:377:17 47: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl at ./compiler/rustc_query_system/src/dep_graph/graph.rs:301:14 48: rustc_query_system::dep_graph::graph::DepGraph::with_eval_always_task at ./compiler/rustc_query_system/src/dep_graph/graph.rs:334:9 49: rustc_query_system::query::plumbing::force_query_with_job::{{closure}}::{{closure}} at ./compiler/rustc_query_system/src/query/plumbing.rs:600:17 50: rustc_middle::ty::query::plumbing::::start_query::{{closure}}::{{closure}}::{{closure}} at ./compiler/rustc_middle/src/ty/query/plumbing.rs:73:74 51: stacker::maybe_grow at /usr/local/google/home/tmandry/.cargo/registry/src/github.com-1ecc6299db9ec823/stacker-0.1.12/src/lib.rs:55:9 52: rustc_data_structures::stack::ensure_sufficient_stack at ./compiler/rustc_data_structures/src/stack.rs:16:5 53: rustc_middle::ty::query::plumbing::::start_query::{{closure}}::{{closure}} at ./compiler/rustc_middle/src/ty/query/plumbing.rs:73:17 54: rustc_middle::ty::context::tls::enter_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1733:50 55: rustc_middle::ty::context::tls::set_tlv at ./compiler/rustc_middle/src/ty/context.rs:1717:9 56: rustc_middle::ty::context::tls::enter_context at ./compiler/rustc_middle/src/ty/context.rs:1733:9 57: rustc_middle::ty::query::plumbing::::start_query::{{closure}} at ./compiler/rustc_middle/src/ty/query/plumbing.rs:72:13 58: rustc_middle::ty::context::tls::with_related_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1777:13 59: rustc_middle::ty::context::tls::with_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1761:40 60: rustc_middle::ty::context::tls::with_context_opt at ./compiler/rustc_middle/src/ty/context.rs:1750:22 61: rustc_middle::ty::context::tls::with_context at ./compiler/rustc_middle/src/ty/context.rs:1761:9 62: rustc_middle::ty::context::tls::with_related_context at ./compiler/rustc_middle/src/ty/context.rs:1774:9 63: rustc_middle::ty::query::plumbing::::start_query at ./compiler/rustc_middle/src/ty/query/plumbing.rs:61:9 64: rustc_query_system::query::plumbing::force_query_with_job::{{closure}} at ./compiler/rustc_query_system/src/query/plumbing.rs:598:9 65: rustc_query_system::query::plumbing::with_diagnostics at ./compiler/rustc_query_system/src/query/plumbing.rs:302:18 66: rustc_query_system::query::plumbing::force_query_with_job at ./compiler/rustc_query_system/src/query/plumbing.rs:597:51 67: rustc_query_system::query::plumbing::try_execute_query at ./compiler/rustc_query_system/src/query/plumbing.rs:426:16 68: rustc_query_system::query::plumbing::get_query_impl::{{closure}} at ./compiler/rustc_query_system/src/query/plumbing.rs:645:23 69: as rustc_query_system::query::caches::QueryCache>::lookup at ./compiler/rustc_query_system/src/query/caches.rs:114:79 70: rustc_query_system::query::plumbing::try_get_cached at ./compiler/rustc_query_system/src/query/plumbing.rs:379:5 71: rustc_query_system::query::plumbing::get_query_impl at ./compiler/rustc_query_system/src/query/plumbing.rs:637:5 72: rustc_query_system::query::plumbing::get_query at ./compiler/rustc_query_system/src/query/plumbing.rs:739:5 73: rustc_middle::ty::query::TyCtxtAt::analysis at ./compiler/rustc_middle/src/ty/query/plumbing.rs:487:17 74: rustc_middle::ty::query::::analysis at ./compiler/rustc_middle/src/ty/query/plumbing.rs:448:17 75: rustc_driver::run_compiler::{{closure}}::{{closure}}::{{closure}} at ./compiler/rustc_driver/src/lib.rs:440:59 76: rustc_interface::passes::QueryContext::enter::{{closure}} at ./compiler/rustc_interface/src/passes.rs:725:42 77: rustc_middle::ty::context::tls::enter_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1733:50 78: rustc_middle::ty::context::tls::set_tlv at ./compiler/rustc_middle/src/ty/context.rs:1717:9 79: rustc_middle::ty::context::tls::enter_context at ./compiler/rustc_middle/src/ty/context.rs:1733:9 80: rustc_interface::passes::QueryContext::enter at ./compiler/rustc_interface/src/passes.rs:725:9 81: rustc_driver::run_compiler::{{closure}}::{{closure}} at ./compiler/rustc_driver/src/lib.rs:440:13 82: rustc_interface::queries::::enter at ./compiler/rustc_interface/src/queries.rs:413:19 83: rustc_driver::run_compiler::{{closure}} at ./compiler/rustc_driver/src/lib.rs:341:22 84: rustc_interface::interface::create_compiler_and_run::{{closure}} at ./compiler/rustc_interface/src/interface.rs:196:13 85: rustc_span::with_source_map at ./compiler/rustc_span/src/lib.rs:765:5 86: rustc_interface::interface::create_compiler_and_run at ./compiler/rustc_interface/src/interface.rs:190:5 87: rustc_interface::interface::run_compiler::{{closure}} at ./compiler/rustc_interface/src/interface.rs:212:12 88: rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::{{closure}}::{{closure}} at ./compiler/rustc_interface/src/util.rs:152:13 89: scoped_tls::ScopedKey::set at /usr/local/google/home/tmandry/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:137:9 90: rustc_span::with_session_globals at ./compiler/rustc_span/src/lib.rs:94:5 91: rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::{{closure}} at ./compiler/rustc_interface/src/util.rs:150:9 92: rustc_interface::util::scoped_thread::{{closure}} at ./compiler/rustc_interface/src/util.rs:125:24 note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. error: internal compiler error: unexpected panic 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.50.0-dev running on x86_64-unknown-linux-gnu note: compiler flags: -Z instrument-coverage -Z treat-err-as-bug query stack during panic: #0 [mir_drops_elaborated_and_const_checked] elaborating drops for `Either::::unwrap` #1 [analysis] running analysis passes on this crate end of query stack ```

The error happens during drop elaboration. I'm guessing -Zinstrument-coverage somehow marks the code as used; perhaps the unreachable function handling is involved somehow?

cc @ecstatic-morse

tmandry commented 3 years ago

issue-33287.rs: Using -Ztreat-err-as-bug again we can see that the covered_file_name query is causing optimized_mir to be evaluated for the test function, when it wasn't before.

``` > RUST_BACKTRACE=1 rustc +stage1 -Zinstrument-coverage -Ztreat-err-as-bug src/test/ui/issues/issue-33287.rs error: this operation will panic at runtime --> src/test/ui/issues/issue-33287.rs:7:17 | 7 | let range = A[1]..; | ^^^^ index out of bounds: the length is 1 but the index is 1 | = note: `#[deny(unconditional_panic)]` on by default thread 'rustc' panicked at 'aborting due to `-Z treat-err-as-bug=1`', compiler/rustc_errors/src/lib.rs:990:27 stack backtrace: 0: std::panicking::begin_panic at ./library/std/src/panicking.rs:519:12 1: rustc_errors::HandlerInner::panic_if_treat_err_as_bug at ./compiler/rustc_errors/src/lib.rs:990:27 2: rustc_errors::HandlerInner::bump_err_count at ./compiler/rustc_errors/src/lib.rs:980:9 3: rustc_errors::HandlerInner::emit_diagnostic at ./compiler/rustc_errors/src/lib.rs:796:13 4: rustc_errors::Handler::emit_diagnostic at ./compiler/rustc_errors/src/lib.rs:715:9 5: rustc_errors::diagnostic_builder::DiagnosticBuilder::emit at ./compiler/rustc_errors/src/diagnostic_builder.rs:101:9 6: rustc_mir::transform::const_prop::ConstPropagator::report_assert_as_lint::{{closure}} at ./compiler/rustc_mir/src/transform/const_prop.rs:522:13 7: core::ops::function::FnOnce::call_once{{vtable.shim}} at ./library/core/src/ops/function.rs:227:5 8: as core::ops::function::FnOnce>::call_once at ./library/alloc/src/boxed.rs:1328:9 9: rustc_middle::lint::struct_lint_level::struct_lint_level_impl at ./compiler/rustc_middle/src/lint.rs:362:9 10: rustc_middle::lint::struct_lint_level at ./compiler/rustc_middle/src/lint.rs:364:5 11: rustc_middle::ty::context::TyCtxt::struct_span_lint_hir at ./compiler/rustc_middle/src/ty/context.rs:2575:9 12: rustc_mir::transform::const_prop::ConstPropagator::report_assert_as_lint at ./compiler/rustc_mir/src/transform/const_prop.rs:519:9 13: ::visit_terminator at ./compiler/rustc_mir/src/transform/const_prop.rs:1216:29 14: ::visit_body at ./compiler/rustc_mir/src/transform/const_prop.rs:1050:13 15: ::run_pass at ./compiler/rustc_mir/src/transform/const_prop.rs:150:9 16: rustc_mir::transform::run_passes::{{closure}} at ./compiler/rustc_mir/src/transform/mod.rs:186:9 17: rustc_mir::transform::run_passes at ./compiler/rustc_mir/src/transform/mod.rs:202:13 18: rustc_mir::transform::run_optimization_passes at ./compiler/rustc_mir/src/transform/mod.rs:446:5 19: rustc_mir::transform::inner_optimized_mir at ./compiler/rustc_mir/src/transform/mod.rs:486:5 20: rustc_mir::transform::optimized_mir at ./compiler/rustc_mir/src/transform/mod.rs:462:25 21: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::optimized_mir>::compute at ./compiler/rustc_middle/src/ty/query/plumbing.rs:377:17 22: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl at ./compiler/rustc_query_system/src/dep_graph/graph.rs:301:14 23: rustc_query_system::query::plumbing::force_query_with_job::{{closure}}::{{closure}} 24: rustc_middle::ty::query::plumbing::::start_query::{{closure}}::{{closure}}::{{closure}} at ./compiler/rustc_middle/src/ty/query/plumbing.rs:73:74 25: stacker::maybe_grow at /usr/local/google/home/tmandry/.cargo/registry/src/github.com-1ecc6299db9ec823/stacker-0.1.12/src/lib.rs:55:9 26: rustc_data_structures::stack::ensure_sufficient_stack at ./compiler/rustc_data_structures/src/stack.rs:16:5 27: rustc_middle::ty::query::plumbing::::start_query::{{closure}}::{{closure}} at ./compiler/rustc_middle/src/ty/query/plumbing.rs:73:17 28: rustc_middle::ty::context::tls::enter_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1733:50 29: rustc_middle::ty::context::tls::set_tlv at ./compiler/rustc_middle/src/ty/context.rs:1717:9 30: rustc_middle::ty::context::tls::enter_context at ./compiler/rustc_middle/src/ty/context.rs:1733:9 31: rustc_middle::ty::query::plumbing::::start_query::{{closure}} at ./compiler/rustc_middle/src/ty/query/plumbing.rs:72:13 32: rustc_middle::ty::context::tls::with_related_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1777:13 33: rustc_middle::ty::context::tls::with_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1761:40 34: rustc_middle::ty::context::tls::with_context_opt at ./compiler/rustc_middle/src/ty/context.rs:1750:22 35: rustc_middle::ty::context::tls::with_context at ./compiler/rustc_middle/src/ty/context.rs:1761:9 36: rustc_middle::ty::context::tls::with_related_context at ./compiler/rustc_middle/src/ty/context.rs:1774:9 37: rustc_middle::ty::query::plumbing::::start_query at ./compiler/rustc_middle/src/ty/query/plumbing.rs:61:9 38: rustc_query_system::query::plumbing::force_query_with_job::{{closure}} at ./compiler/rustc_query_system/src/query/plumbing.rs:598:9 39: rustc_query_system::query::plumbing::with_diagnostics at ./compiler/rustc_query_system/src/query/plumbing.rs:302:18 40: rustc_query_system::query::plumbing::force_query_with_job at ./compiler/rustc_query_system/src/query/plumbing.rs:597:51 41: rustc_query_system::query::plumbing::try_execute_query at ./compiler/rustc_query_system/src/query/plumbing.rs:426:16 42: rustc_query_system::query::plumbing::get_query_impl::{{closure}} at ./compiler/rustc_query_system/src/query/plumbing.rs:645:23 43: as rustc_query_system::query::caches::QueryCache>::lookup at ./compiler/rustc_query_system/src/query/caches.rs:114:79 44: rustc_query_system::query::plumbing::try_get_cached at ./compiler/rustc_query_system/src/query/plumbing.rs:379:5 45: rustc_query_system::query::plumbing::get_query_impl at ./compiler/rustc_query_system/src/query/plumbing.rs:637:5 46: rustc_query_system::query::plumbing::get_query at ./compiler/rustc_query_system/src/query/plumbing.rs:739:5 47: rustc_middle::ty::query::TyCtxtAt::optimized_mir at ./compiler/rustc_middle/src/ty/query/plumbing.rs:487:17 48: rustc_middle::ty::query::::optimized_mir at ./compiler/rustc_middle/src/ty/query/plumbing.rs:448:17 49: rustc_mir::transform::coverage::query::covered_file_name at ./compiler/rustc_mir/src/transform/coverage/query.rs:132:20 50: rustc_mir::transform::coverage::query::provide::{{closure}} at ./compiler/rustc_mir/src/transform/coverage/query.rs:14:49 51: core::ops::function::FnOnce::call_once at ./library/core/src/ops/function.rs:227:5 52: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::covered_file_name>::compute at ./compiler/rustc_middle/src/ty/query/plumbing.rs:377:17 53: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl at ./compiler/rustc_query_system/src/dep_graph/graph.rs:301:14 54: rustc_query_system::query::plumbing::force_query_with_job::{{closure}}::{{closure}} 55: rustc_middle::ty::query::plumbing::::start_query::{{closure}}::{{closure}}::{{closure}} at ./compiler/rustc_middle/src/ty/query/plumbing.rs:73:74 56: stacker::maybe_grow at /usr/local/google/home/tmandry/.cargo/registry/src/github.com-1ecc6299db9ec823/stacker-0.1.12/src/lib.rs:55:9 57: rustc_data_structures::stack::ensure_sufficient_stack at ./compiler/rustc_data_structures/src/stack.rs:16:5 58: rustc_middle::ty::query::plumbing::::start_query::{{closure}}::{{closure}} at ./compiler/rustc_middle/src/ty/query/plumbing.rs:73:17 59: rustc_middle::ty::context::tls::enter_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1733:50 60: rustc_middle::ty::context::tls::set_tlv at ./compiler/rustc_middle/src/ty/context.rs:1717:9 61: rustc_middle::ty::context::tls::enter_context at ./compiler/rustc_middle/src/ty/context.rs:1733:9 62: rustc_middle::ty::query::plumbing::::start_query::{{closure}} at ./compiler/rustc_middle/src/ty/query/plumbing.rs:72:13 63: rustc_middle::ty::context::tls::with_related_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1777:13 64: rustc_middle::ty::context::tls::with_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1761:40 65: rustc_middle::ty::context::tls::with_context_opt at ./compiler/rustc_middle/src/ty/context.rs:1750:22 66: rustc_middle::ty::context::tls::with_context at ./compiler/rustc_middle/src/ty/context.rs:1761:9 67: rustc_middle::ty::context::tls::with_related_context at ./compiler/rustc_middle/src/ty/context.rs:1774:9 68: rustc_middle::ty::query::plumbing::::start_query at ./compiler/rustc_middle/src/ty/query/plumbing.rs:61:9 69: rustc_query_system::query::plumbing::force_query_with_job::{{closure}} at ./compiler/rustc_query_system/src/query/plumbing.rs:598:9 70: rustc_query_system::query::plumbing::with_diagnostics at ./compiler/rustc_query_system/src/query/plumbing.rs:302:18 71: rustc_query_system::query::plumbing::force_query_with_job at ./compiler/rustc_query_system/src/query/plumbing.rs:597:51 72: rustc_query_system::query::plumbing::try_execute_query at ./compiler/rustc_query_system/src/query/plumbing.rs:426:16 73: rustc_query_system::query::plumbing::get_query_impl::{{closure}} at ./compiler/rustc_query_system/src/query/plumbing.rs:645:23 74: as rustc_query_system::query::caches::QueryCache>::lookup at ./compiler/rustc_query_system/src/query/caches.rs:198:13 75: rustc_query_system::query::plumbing::try_get_cached at ./compiler/rustc_query_system/src/query/plumbing.rs:379:5 76: rustc_query_system::query::plumbing::get_query_impl at ./compiler/rustc_query_system/src/query/plumbing.rs:637:5 77: rustc_query_system::query::plumbing::get_query at ./compiler/rustc_query_system/src/query/plumbing.rs:739:5 78: rustc_middle::ty::query::TyCtxtAt::covered_file_name at ./compiler/rustc_middle/src/ty/query/plumbing.rs:487:17 79: rustc_middle::ty::query::::covered_file_name at ./compiler/rustc_middle/src/ty/query/plumbing.rs:448:17 80: rustc_codegen_llvm::coverageinfo::mapgen::add_unreachable_coverage at ./compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs:292:49 81: rustc_codegen_llvm::coverageinfo::mapgen::finalize at ./compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs:51:5 82: rustc_codegen_llvm::coverageinfo::::coverageinfo_finalize at ./compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs:46:9 83: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen at ./compiler/rustc_codegen_llvm/src/base.rs:149:17 84: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl at ./compiler/rustc_query_system/src/dep_graph/graph.rs:301:14 85: rustc_query_system::dep_graph::graph::DepGraph::with_task at ./compiler/rustc_query_system/src/dep_graph/graph.rs:200:9 86: rustc_codegen_llvm::base::compile_codegen_unit at ./compiler/rustc_codegen_llvm/src/base.rs:104:9 87: ::compile_codegen_unit at ./compiler/rustc_codegen_llvm/src/lib.rs:106:9 88: rustc_codegen_ssa::base::codegen_crate at ./compiler/rustc_codegen_ssa/src/base.rs:642:38 89: ::codegen_crate at ./compiler/rustc_codegen_llvm/src/lib.rs:267:18 90: rustc_interface::passes::start_codegen::{{closure}} at ./compiler/rustc_interface/src/passes.rs:996:9 91: rustc_data_structures::profiling::VerboseTimingGuard::run at ./compiler/rustc_data_structures/src/profiling.rs:570:9 92: rustc_session::utils::::time at ./compiler/rustc_session/src/utils.rs:9:9 93: rustc_interface::passes::start_codegen at ./compiler/rustc_interface/src/passes.rs:995:19 94: rustc_interface::queries::Queries::ongoing_codegen::{{closure}}::{{closure}} at ./compiler/rustc_interface/src/queries.rs:282:20 95: rustc_interface::passes::QueryContext::enter::{{closure}} at ./compiler/rustc_interface/src/passes.rs:725:42 96: rustc_middle::ty::context::tls::enter_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1733:50 97: rustc_middle::ty::context::tls::set_tlv at ./compiler/rustc_middle/src/ty/context.rs:1717:9 98: rustc_middle::ty::context::tls::enter_context at ./compiler/rustc_middle/src/ty/context.rs:1733:9 99: rustc_interface::passes::QueryContext::enter at ./compiler/rustc_interface/src/passes.rs:725:9 100: rustc_interface::queries::Queries::ongoing_codegen::{{closure}} at ./compiler/rustc_interface/src/queries.rs:273:13 101: rustc_interface::queries::Query::compute at ./compiler/rustc_interface/src/queries.rs:35:28 102: rustc_interface::queries::Queries::ongoing_codegen at ./compiler/rustc_interface/src/queries.rs:271:9 103: rustc_driver::run_compiler::{{closure}}::{{closure}} at ./compiler/rustc_driver/src/lib.rs:446:13 104: rustc_interface::queries::::enter at ./compiler/rustc_interface/src/queries.rs:413:19 105: rustc_driver::run_compiler::{{closure}} at ./compiler/rustc_driver/src/lib.rs:341:22 106: rustc_interface::interface::create_compiler_and_run::{{closure}} at ./compiler/rustc_interface/src/interface.rs:196:13 107: rustc_span::with_source_map at ./compiler/rustc_span/src/lib.rs:765:5 108: rustc_interface::interface::create_compiler_and_run at ./compiler/rustc_interface/src/interface.rs:190:5 109: rustc_interface::interface::run_compiler::{{closure}} at ./compiler/rustc_interface/src/interface.rs:212:12 110: rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::{{closure}}::{{closure}} at ./compiler/rustc_interface/src/util.rs:152:13 111: scoped_tls::ScopedKey::set at /usr/local/google/home/tmandry/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:137:9 112: rustc_span::with_session_globals at ./compiler/rustc_span/src/lib.rs:94:5 113: rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::{{closure}} at ./compiler/rustc_interface/src/util.rs:150:9 114: rustc_interface::util::scoped_thread::{{closure}} at ./compiler/rustc_interface/src/util.rs:125:24 note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. error: internal compiler error: unexpected panic 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.50.0-dev running on x86_64-unknown-linux-gnu note: compiler flags: -Z instrument-coverage -Z treat-err-as-bug query stack during panic: #0 [optimized_mir] optimizing MIR for `test` #1 [covered_file_name] retrieving the covered file name, if instrumented, for `test` end of query stack ```

This indicates a possible performance issue with that query; maybe there's a way we can implement it that doesn't demand optimized MIR. EDIT: The fact that this is causing new errors might also mean that it isn't correct to rely on that query, but that is less clear to me.

Also, I feel like this function should be getting called by main in the test to make sure we're exercising all the code paths the original regression test was meant to exercise.

cc @wesleywiser

tmandry commented 3 years ago

..skipping the layout one for now..

trivial-bounds-inconsistent.rs: This again seems to be happening during drop elaboration, but this time it's happening as a direct result of the covered_file_name query, so sort of a combination of the last two.

``` > RUST_BACKTRACE=1 rustc +stage1 -Zinstrument-coverage src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs warning: Trait bound i32: Foo does not depend on any type or lifetime parameters --> src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs:14:19 | 14 | enum E where i32: Foo { V } //~ WARNING trivial_bounds | ^^^ | = note: `#[warn(trivial_bounds)]` on by default warning: Trait bound i32: Foo does not depend on any type or lifetime parameters --> src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs:16:21 | 16 | struct S where i32: Foo; //~ WARNING trivial_bounds | ^^^ warning: Trait bound i32: Foo does not depend on any type or lifetime parameters --> src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs:18:20 | 18 | trait T where i32: Foo {} //~ WARNING trivial_bounds | ^^^ warning: Trait bound i32: Foo does not depend on any type or lifetime parameters --> src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs:20:20 | 20 | union U where i32: Foo { f: i32 } //~ WARNING trivial_bounds | ^^^ warning: where clauses are not enforced in type aliases --> src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs:22:14 | 22 | type Y where i32: Foo = (); | ^^^^^^^^ | = note: `#[warn(type_alias_bounds)]` on by default help: the clause will not be checked when the type alias is used, and should be removed | 22 | type Y = (); | -- warning: Trait bound i32: Foo does not depend on any type or lifetime parameters --> src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs:22:19 | 22 | type Y where i32: Foo = (); | ^^^ warning: Trait bound i32: Foo does not depend on any type or lifetime parameters --> src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs:26:28 | 26 | impl Foo for () where i32: Foo { //~ WARNING trivial_bounds | ^^^ warning: Trait bound i32: Foo does not depend on any type or lifetime parameters --> src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs:34:19 | 34 | fn f() where i32: Foo { //~ WARNING trivial_bounds | ^^^ warning: Trait bound &'static str: Foo does not depend on any type or lifetime parameters --> src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs:41:28 | 41 | fn g() where &'static str: Foo { //~ WARNING trivial_bounds | ^^^ warning: Trait bound str: Sized does not depend on any type or lifetime parameters --> src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs:55:37 | 55 | struct TwoStrs(str, str) where str: Sized; //~ WARNING trivial_bounds | ^^^^^ warning: Trait bound for<'a> Dst<(dyn A + 'a)>: Sized does not depend on any type or lifetime parameters --> src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs:57:51 | 57 | fn unsized_local() where for<'a> Dst: Sized { //~ WARNING trivial_bounds | ^^^^^ warning: Trait bound str: Sized does not depend on any type or lifetime parameters --> src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs:61:35 | 61 | fn return_str() -> str where str: Sized { //~ WARNING trivial_bounds | ^^^^^ warning: Trait bound String: Neg does not depend on any type or lifetime parameters --> src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs:65:46 | 65 | fn use_op(s: String) -> String where String: ::std::ops::Neg { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: Trait bound i32: Iterator does not depend on any type or lifetime parameters --> src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs:70:25 | 70 | fn use_for() where i32: Iterator { //~ WARNING trivial_bounds | ^^^^^^^^ error: internal compiler error: compiler/rustc_traits/src/normalize_erasing_regions.rs:43:32: could not fully normalize `std::option::Option<::Item>` thread 'rustc' panicked at 'Box', compiler/rustc_errors/src/lib.rs:958:9 stack backtrace: 0: std::panicking::begin_panic at ./library/std/src/panicking.rs:519:12 1: rustc_errors::HandlerInner::bug at ./compiler/rustc_errors/src/lib.rs:958:9 2: rustc_errors::Handler::bug at ./compiler/rustc_errors/src/lib.rs:675:9 3: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}} at ./compiler/rustc_middle/src/util/bug.rs:33:34 4: rustc_middle::ty::context::tls::with_opt::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1798:40 5: rustc_middle::ty::context::tls::with_context_opt at ./compiler/rustc_middle/src/ty/context.rs:1750:22 6: rustc_middle::ty::context::tls::with_opt at ./compiler/rustc_middle/src/ty/context.rs:1798:9 7: rustc_middle::util::bug::opt_span_bug_fmt at ./compiler/rustc_middle/src/util/bug.rs:29:5 8: rustc_middle::util::bug::bug_fmt at ./compiler/rustc_middle/src/util/bug.rs:14:5 9: rustc_traits::normalize_erasing_regions::normalize_generic_arg_after_erasing_regions::{{closure}} at ./compiler/rustc_traits/src/normalize_erasing_regions.rs:43:32 10: rustc_infer::infer::InferCtxtBuilder::enter at ./compiler/rustc_infer/src/infer/mod.rs:583:9 11: rustc_traits::normalize_erasing_regions::normalize_generic_arg_after_erasing_regions at ./compiler/rustc_traits/src/normalize_erasing_regions.rs:22:5 12: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl at ./compiler/rustc_query_system/src/dep_graph/graph.rs:301:14 13: rustc_query_system::query::plumbing::force_query_with_job::{{closure}}::{{closure}} 14: rustc_middle::ty::query::plumbing::::start_query::{{closure}}::{{closure}}::{{closure}} at ./compiler/rustc_middle/src/ty/query/plumbing.rs:73:74 15: stacker::maybe_grow at /usr/local/google/home/tmandry/.cargo/registry/src/github.com-1ecc6299db9ec823/stacker-0.1.12/src/lib.rs:55:9 16: rustc_data_structures::stack::ensure_sufficient_stack at ./compiler/rustc_data_structures/src/stack.rs:16:5 17: rustc_middle::ty::query::plumbing::::start_query::{{closure}}::{{closure}} at ./compiler/rustc_middle/src/ty/query/plumbing.rs:73:17 18: rustc_middle::ty::context::tls::enter_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1733:50 19: rustc_middle::ty::context::tls::set_tlv at ./compiler/rustc_middle/src/ty/context.rs:1717:9 20: rustc_middle::ty::context::tls::enter_context at ./compiler/rustc_middle/src/ty/context.rs:1733:9 21: rustc_middle::ty::query::plumbing::::start_query::{{closure}} at ./compiler/rustc_middle/src/ty/query/plumbing.rs:72:13 22: rustc_middle::ty::context::tls::with_related_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1777:13 23: rustc_middle::ty::context::tls::with_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1761:40 24: rustc_middle::ty::context::tls::with_context_opt at ./compiler/rustc_middle/src/ty/context.rs:1750:22 25: rustc_middle::ty::context::tls::with_context at ./compiler/rustc_middle/src/ty/context.rs:1761:9 26: rustc_middle::ty::context::tls::with_related_context at ./compiler/rustc_middle/src/ty/context.rs:1774:9 27: rustc_middle::ty::query::plumbing::::start_query at ./compiler/rustc_middle/src/ty/query/plumbing.rs:61:9 28: rustc_query_system::query::plumbing::force_query_with_job::{{closure}} at ./compiler/rustc_query_system/src/query/plumbing.rs:598:9 29: rustc_query_system::query::plumbing::with_diagnostics at ./compiler/rustc_query_system/src/query/plumbing.rs:302:18 30: rustc_query_system::query::plumbing::force_query_with_job at ./compiler/rustc_query_system/src/query/plumbing.rs:597:51 31: rustc_query_system::query::plumbing::try_execute_query at ./compiler/rustc_query_system/src/query/plumbing.rs:426:16 32: rustc_query_system::query::plumbing::get_query_impl::{{closure}} at ./compiler/rustc_query_system/src/query/plumbing.rs:645:23 33: as rustc_query_system::query::caches::QueryCache>::lookup at ./compiler/rustc_query_system/src/query/caches.rs:114:79 34: rustc_query_system::query::plumbing::try_get_cached at ./compiler/rustc_query_system/src/query/plumbing.rs:379:5 35: rustc_query_system::query::plumbing::get_query_impl at ./compiler/rustc_query_system/src/query/plumbing.rs:637:5 36: rustc_query_system::query::plumbing::get_query at ./compiler/rustc_query_system/src/query/plumbing.rs:739:5 37: rustc_middle::ty::query::TyCtxtAt::normalize_generic_arg_after_erasing_regions at ./compiler/rustc_middle/src/ty/query/plumbing.rs:487:17 38: rustc_middle::ty::query::::normalize_generic_arg_after_erasing_regions at ./compiler/rustc_middle/src/ty/query/plumbing.rs:448:17 39: ::fold_ty at ./compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:97:9 40: rustc_middle::ty::structural_impls::::fold_with at ./compiler/rustc_middle/src/ty/structural_impls.rs:969:9 41: rustc_middle::ty::normalize_erasing_regions::::normalize_erasing_regions at ./compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:37:13 42: rustc_middle::ty::util::::needs_drop at ./compiler/rustc_middle/src/ty/util.rs:766:30 43: rustc_mir::dataflow::drop_flag_effects::on_all_drop_children_bits::{{closure}} at ./compiler/rustc_mir/src/dataflow/drop_flag_effects.rs:156:12 44: rustc_mir::dataflow::drop_flag_effects::on_all_children_bits::on_all_children_bits at ./compiler/rustc_mir/src/dataflow/drop_flag_effects.rs:126:9 45: rustc_mir::dataflow::drop_flag_effects::on_all_children_bits at ./compiler/rustc_mir/src/dataflow/drop_flag_effects.rs:138:5 46: rustc_mir::dataflow::drop_flag_effects::on_all_drop_children_bits at ./compiler/rustc_mir/src/dataflow/drop_flag_effects.rs:150:5 47: rustc_mir::transform::elaborate_drops::find_dead_unwinds at ./compiler/rustc_mir/src/transform/elaborate_drops.rs:116:9 48: ::run_pass at ./compiler/rustc_mir/src/transform/elaborate_drops.rs:41:32 49: rustc_mir::transform::run_passes::{{closure}} at ./compiler/rustc_mir/src/transform/mod.rs:186:9 50: rustc_mir::transform::run_passes at ./compiler/rustc_mir/src/transform/mod.rs:202:13 51: rustc_mir::transform::run_post_borrowck_cleanup_passes at ./compiler/rustc_mir/src/transform/mod.rs:372:5 52: rustc_mir::transform::mir_drops_elaborated_and_const_checked at ./compiler/rustc_mir/src/transform/mod.rs:340:5 53: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::mir_drops_elaborated_and_const_checked>::compute at ./compiler/rustc_middle/src/ty/query/plumbing.rs:377:17 54: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl at ./compiler/rustc_query_system/src/dep_graph/graph.rs:301:14 55: rustc_query_system::dep_graph::graph::DepGraph::with_task at ./compiler/rustc_query_system/src/dep_graph/graph.rs:200:9 56: rustc_query_system::query::plumbing::force_query_with_job::{{closure}}::{{closure}} at ./compiler/rustc_query_system/src/query/plumbing.rs:608:17 57: rustc_middle::ty::query::plumbing::::start_query::{{closure}}::{{closure}}::{{closure}} at ./compiler/rustc_middle/src/ty/query/plumbing.rs:73:74 58: stacker::maybe_grow at /usr/local/google/home/tmandry/.cargo/registry/src/github.com-1ecc6299db9ec823/stacker-0.1.12/src/lib.rs:55:9 59: rustc_data_structures::stack::ensure_sufficient_stack at ./compiler/rustc_data_structures/src/stack.rs:16:5 60: rustc_middle::ty::query::plumbing::::start_query::{{closure}}::{{closure}} at ./compiler/rustc_middle/src/ty/query/plumbing.rs:73:17 61: rustc_middle::ty::context::tls::enter_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1733:50 62: rustc_middle::ty::context::tls::set_tlv at ./compiler/rustc_middle/src/ty/context.rs:1717:9 63: rustc_middle::ty::context::tls::enter_context at ./compiler/rustc_middle/src/ty/context.rs:1733:9 64: rustc_middle::ty::query::plumbing::::start_query::{{closure}} at ./compiler/rustc_middle/src/ty/query/plumbing.rs:72:13 65: rustc_middle::ty::context::tls::with_related_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1777:13 66: rustc_middle::ty::context::tls::with_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1761:40 67: rustc_middle::ty::context::tls::with_context_opt at ./compiler/rustc_middle/src/ty/context.rs:1750:22 68: rustc_middle::ty::context::tls::with_context at ./compiler/rustc_middle/src/ty/context.rs:1761:9 69: rustc_middle::ty::context::tls::with_related_context at ./compiler/rustc_middle/src/ty/context.rs:1774:9 70: rustc_middle::ty::query::plumbing::::start_query at ./compiler/rustc_middle/src/ty/query/plumbing.rs:61:9 71: rustc_query_system::query::plumbing::force_query_with_job::{{closure}} at ./compiler/rustc_query_system/src/query/plumbing.rs:598:9 72: rustc_query_system::query::plumbing::with_diagnostics at ./compiler/rustc_query_system/src/query/plumbing.rs:302:18 73: rustc_query_system::query::plumbing::force_query_with_job at ./compiler/rustc_query_system/src/query/plumbing.rs:597:51 74: rustc_query_system::query::plumbing::try_execute_query at ./compiler/rustc_query_system/src/query/plumbing.rs:426:16 75: rustc_query_system::query::plumbing::get_query_impl::{{closure}} at ./compiler/rustc_query_system/src/query/plumbing.rs:645:23 76: as rustc_query_system::query::caches::QueryCache>::lookup at ./compiler/rustc_query_system/src/query/caches.rs:114:79 77: rustc_query_system::query::plumbing::try_get_cached at ./compiler/rustc_query_system/src/query/plumbing.rs:379:5 78: rustc_query_system::query::plumbing::get_query_impl at ./compiler/rustc_query_system/src/query/plumbing.rs:637:5 79: rustc_query_system::query::plumbing::get_query at ./compiler/rustc_query_system/src/query/plumbing.rs:739:5 80: rustc_middle::ty::query::TyCtxtAt::mir_drops_elaborated_and_const_checked at ./compiler/rustc_middle/src/ty/query/plumbing.rs:487:17 81: rustc_middle::ty::query::::mir_drops_elaborated_and_const_checked at ./compiler/rustc_middle/src/ty/query/plumbing.rs:448:17 82: rustc_mir::transform::inner_optimized_mir at ./compiler/rustc_mir/src/transform/mod.rs:485:20 83: rustc_mir::transform::optimized_mir at ./compiler/rustc_mir/src/transform/mod.rs:462:25 84: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::optimized_mir>::compute at ./compiler/rustc_middle/src/ty/query/plumbing.rs:377:17 85: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl at ./compiler/rustc_query_system/src/dep_graph/graph.rs:301:14 86: rustc_query_system::query::plumbing::force_query_with_job::{{closure}}::{{closure}} 87: rustc_middle::ty::query::plumbing::::start_query::{{closure}}::{{closure}}::{{closure}} at ./compiler/rustc_middle/src/ty/query/plumbing.rs:73:74 88: stacker::maybe_grow at /usr/local/google/home/tmandry/.cargo/registry/src/github.com-1ecc6299db9ec823/stacker-0.1.12/src/lib.rs:55:9 89: rustc_data_structures::stack::ensure_sufficient_stack at ./compiler/rustc_data_structures/src/stack.rs:16:5 90: rustc_middle::ty::query::plumbing::::start_query::{{closure}}::{{closure}} at ./compiler/rustc_middle/src/ty/query/plumbing.rs:73:17 91: rustc_middle::ty::context::tls::enter_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1733:50 92: rustc_middle::ty::context::tls::set_tlv at ./compiler/rustc_middle/src/ty/context.rs:1717:9 93: rustc_middle::ty::context::tls::enter_context at ./compiler/rustc_middle/src/ty/context.rs:1733:9 94: rustc_middle::ty::query::plumbing::::start_query::{{closure}} at ./compiler/rustc_middle/src/ty/query/plumbing.rs:72:13 95: rustc_middle::ty::context::tls::with_related_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1777:13 96: rustc_middle::ty::context::tls::with_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1761:40 97: rustc_middle::ty::context::tls::with_context_opt at ./compiler/rustc_middle/src/ty/context.rs:1750:22 98: rustc_middle::ty::context::tls::with_context at ./compiler/rustc_middle/src/ty/context.rs:1761:9 99: rustc_middle::ty::context::tls::with_related_context at ./compiler/rustc_middle/src/ty/context.rs:1774:9 100: rustc_middle::ty::query::plumbing::::start_query at ./compiler/rustc_middle/src/ty/query/plumbing.rs:61:9 101: rustc_query_system::query::plumbing::force_query_with_job::{{closure}} at ./compiler/rustc_query_system/src/query/plumbing.rs:598:9 102: rustc_query_system::query::plumbing::with_diagnostics at ./compiler/rustc_query_system/src/query/plumbing.rs:302:18 103: rustc_query_system::query::plumbing::force_query_with_job at ./compiler/rustc_query_system/src/query/plumbing.rs:597:51 104: rustc_query_system::query::plumbing::try_execute_query at ./compiler/rustc_query_system/src/query/plumbing.rs:426:16 105: rustc_query_system::query::plumbing::get_query_impl::{{closure}} at ./compiler/rustc_query_system/src/query/plumbing.rs:645:23 106: as rustc_query_system::query::caches::QueryCache>::lookup at ./compiler/rustc_query_system/src/query/caches.rs:114:79 107: rustc_query_system::query::plumbing::try_get_cached at ./compiler/rustc_query_system/src/query/plumbing.rs:379:5 108: rustc_query_system::query::plumbing::get_query_impl at ./compiler/rustc_query_system/src/query/plumbing.rs:637:5 109: rustc_query_system::query::plumbing::get_query at ./compiler/rustc_query_system/src/query/plumbing.rs:739:5 110: rustc_middle::ty::query::TyCtxtAt::optimized_mir at ./compiler/rustc_middle/src/ty/query/plumbing.rs:487:17 111: rustc_middle::ty::query::::optimized_mir at ./compiler/rustc_middle/src/ty/query/plumbing.rs:448:17 112: rustc_mir::transform::coverage::query::covered_file_name at ./compiler/rustc_mir/src/transform/coverage/query.rs:132:20 113: rustc_mir::transform::coverage::query::provide::{{closure}} at ./compiler/rustc_mir/src/transform/coverage/query.rs:14:49 114: core::ops::function::FnOnce::call_once at ./library/core/src/ops/function.rs:227:5 115: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::covered_file_name>::compute at ./compiler/rustc_middle/src/ty/query/plumbing.rs:377:17 116: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl at ./compiler/rustc_query_system/src/dep_graph/graph.rs:301:14 117: rustc_query_system::query::plumbing::force_query_with_job::{{closure}}::{{closure}} 118: rustc_middle::ty::query::plumbing::::start_query::{{closure}}::{{closure}}::{{closure}} at ./compiler/rustc_middle/src/ty/query/plumbing.rs:73:74 119: stacker::maybe_grow at /usr/local/google/home/tmandry/.cargo/registry/src/github.com-1ecc6299db9ec823/stacker-0.1.12/src/lib.rs:55:9 120: rustc_data_structures::stack::ensure_sufficient_stack at ./compiler/rustc_data_structures/src/stack.rs:16:5 121: rustc_middle::ty::query::plumbing::::start_query::{{closure}}::{{closure}} at ./compiler/rustc_middle/src/ty/query/plumbing.rs:73:17 122: rustc_middle::ty::context::tls::enter_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1733:50 123: rustc_middle::ty::context::tls::set_tlv at ./compiler/rustc_middle/src/ty/context.rs:1717:9 124: rustc_middle::ty::context::tls::enter_context at ./compiler/rustc_middle/src/ty/context.rs:1733:9 125: rustc_middle::ty::query::plumbing::::start_query::{{closure}} at ./compiler/rustc_middle/src/ty/query/plumbing.rs:72:13 126: rustc_middle::ty::context::tls::with_related_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1777:13 127: rustc_middle::ty::context::tls::with_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1761:40 128: rustc_middle::ty::context::tls::with_context_opt at ./compiler/rustc_middle/src/ty/context.rs:1750:22 129: rustc_middle::ty::context::tls::with_context at ./compiler/rustc_middle/src/ty/context.rs:1761:9 130: rustc_middle::ty::context::tls::with_related_context at ./compiler/rustc_middle/src/ty/context.rs:1774:9 131: rustc_middle::ty::query::plumbing::::start_query at ./compiler/rustc_middle/src/ty/query/plumbing.rs:61:9 132: rustc_query_system::query::plumbing::force_query_with_job::{{closure}} at ./compiler/rustc_query_system/src/query/plumbing.rs:598:9 133: rustc_query_system::query::plumbing::with_diagnostics at ./compiler/rustc_query_system/src/query/plumbing.rs:302:18 134: rustc_query_system::query::plumbing::force_query_with_job at ./compiler/rustc_query_system/src/query/plumbing.rs:597:51 135: rustc_query_system::query::plumbing::try_execute_query at ./compiler/rustc_query_system/src/query/plumbing.rs:426:16 136: rustc_query_system::query::plumbing::get_query_impl::{{closure}} at ./compiler/rustc_query_system/src/query/plumbing.rs:645:23 137: as rustc_query_system::query::caches::QueryCache>::lookup at ./compiler/rustc_query_system/src/query/caches.rs:198:13 138: rustc_query_system::query::plumbing::try_get_cached at ./compiler/rustc_query_system/src/query/plumbing.rs:379:5 139: rustc_query_system::query::plumbing::get_query_impl at ./compiler/rustc_query_system/src/query/plumbing.rs:637:5 140: rustc_query_system::query::plumbing::get_query at ./compiler/rustc_query_system/src/query/plumbing.rs:739:5 141: rustc_middle::ty::query::TyCtxtAt::covered_file_name at ./compiler/rustc_middle/src/ty/query/plumbing.rs:487:17 142: rustc_middle::ty::query::::covered_file_name at ./compiler/rustc_middle/src/ty/query/plumbing.rs:448:17 143: rustc_codegen_llvm::coverageinfo::mapgen::add_unreachable_coverage at ./compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs:292:49 144: rustc_codegen_llvm::coverageinfo::mapgen::finalize at ./compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs:51:5 145: rustc_codegen_llvm::coverageinfo::::coverageinfo_finalize at ./compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs:46:9 146: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen at ./compiler/rustc_codegen_llvm/src/base.rs:149:17 147: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl at ./compiler/rustc_query_system/src/dep_graph/graph.rs:301:14 148: rustc_query_system::dep_graph::graph::DepGraph::with_task at ./compiler/rustc_query_system/src/dep_graph/graph.rs:200:9 149: rustc_codegen_llvm::base::compile_codegen_unit at ./compiler/rustc_codegen_llvm/src/base.rs:104:9 150: ::compile_codegen_unit at ./compiler/rustc_codegen_llvm/src/lib.rs:106:9 151: rustc_codegen_ssa::base::codegen_crate at ./compiler/rustc_codegen_ssa/src/base.rs:642:38 152: ::codegen_crate at ./compiler/rustc_codegen_llvm/src/lib.rs:267:18 153: rustc_interface::passes::start_codegen::{{closure}} at ./compiler/rustc_interface/src/passes.rs:996:9 154: rustc_data_structures::profiling::VerboseTimingGuard::run at ./compiler/rustc_data_structures/src/profiling.rs:570:9 155: rustc_session::utils::::time at ./compiler/rustc_session/src/utils.rs:9:9 156: rustc_interface::passes::start_codegen at ./compiler/rustc_interface/src/passes.rs:995:19 157: rustc_interface::queries::Queries::ongoing_codegen::{{closure}}::{{closure}} at ./compiler/rustc_interface/src/queries.rs:282:20 158: rustc_interface::passes::QueryContext::enter::{{closure}} at ./compiler/rustc_interface/src/passes.rs:725:42 159: rustc_middle::ty::context::tls::enter_context::{{closure}} at ./compiler/rustc_middle/src/ty/context.rs:1733:50 160: rustc_middle::ty::context::tls::set_tlv at ./compiler/rustc_middle/src/ty/context.rs:1717:9 161: rustc_middle::ty::context::tls::enter_context at ./compiler/rustc_middle/src/ty/context.rs:1733:9 162: rustc_interface::passes::QueryContext::enter at ./compiler/rustc_interface/src/passes.rs:725:9 163: rustc_interface::queries::Queries::ongoing_codegen::{{closure}} at ./compiler/rustc_interface/src/queries.rs:273:13 164: rustc_interface::queries::Query::compute at ./compiler/rustc_interface/src/queries.rs:35:28 165: rustc_interface::queries::Queries::ongoing_codegen at ./compiler/rustc_interface/src/queries.rs:271:9 166: rustc_driver::run_compiler::{{closure}}::{{closure}} at ./compiler/rustc_driver/src/lib.rs:446:13 167: rustc_interface::queries::::enter at ./compiler/rustc_interface/src/queries.rs:413:19 168: rustc_driver::run_compiler::{{closure}} at ./compiler/rustc_driver/src/lib.rs:341:22 169: rustc_interface::interface::create_compiler_and_run::{{closure}} at ./compiler/rustc_interface/src/interface.rs:196:13 170: rustc_span::with_source_map at ./compiler/rustc_span/src/lib.rs:765:5 171: rustc_interface::interface::create_compiler_and_run at ./compiler/rustc_interface/src/interface.rs:190:5 172: rustc_interface::interface::run_compiler::{{closure}} at ./compiler/rustc_interface/src/interface.rs:212:12 173: rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::{{closure}}::{{closure}} at ./compiler/rustc_interface/src/util.rs:152:13 174: scoped_tls::ScopedKey::set at /usr/local/google/home/tmandry/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:137:9 175: rustc_span::with_session_globals at ./compiler/rustc_span/src/lib.rs:94:5 176: rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::{{closure}} at ./compiler/rustc_interface/src/util.rs:150:9 177: rustc_interface::util::scoped_thread::{{closure}} at ./compiler/rustc_interface/src/util.rs:125:24 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.50.0-dev running on x86_64-unknown-linux-gnu note: compiler flags: -Z instrument-coverage query stack during panic: #0 [normalize_generic_arg_after_erasing_regions] normalizing `std::option::Option<::Item>` #1 [mir_drops_elaborated_and_const_checked] elaborating drops for `use_for` #2 [optimized_mir] optimizing MIR for `use_for` #3 [covered_file_name] retrieving the covered file name, if instrumented, for `use_for` end of query stack error: aborting due to previous error; 14 warnings emitted ```

Here we're generating MIR for a function which can never be called, due to its where i32: Iterator clause. So this might indicate that it's a bug to run the optimized_mir query on a function which couldn't be called. Or that the normalization code is too brittle somehow.

cc @matthewjasper

tmandry commented 3 years ago

I haven't looked into the layout issue yet but it looks like the coverage code is causing a layout to be computed that wasn't before. Unclear to me if that's actually a problem or not; the test is relying on the side effectful outputs of a query computed on demand so that's not going to be super robust.

richkadel commented 3 years ago

perhaps the unreachable function handling is involved somehow?

I can't think of a reason the "unreachable function handling" would mark anything as used. It also seems "late" in the process (well after MIR processing is done). But in any case, it doesn't (at least not intentionally) actually use the code. It just gets the spans for unused functions, and adds code regions for those spans to the coverage map for a function that is used (being codegenned).

But outside of that, if an unused function (as reported by these errors) is still going through codegen anyway, the coverage map variables (generated by LLVM) may add references to those functions' symbols that could mark functions "used" (perhaps only indirectly) in LLVM IR.

Are the errors generated based on an assessment of used or not used, from an LLVM perspective? Or just from MIR? If only from MIR, then I don't think the coverage map generation would play a role in marking them used; and I would look at the InstrumentCoverage pass instead. It's inserting additional statements and occasionally additional BasicBlocks with Goto terminators (to count some branches).

tmandry commented 3 years ago

LLVM [IR] won't affect any compiler messages emitted by rustc.

I also can't think of how the unreachable code handling would affect this, just throwing out ideas. It does seem that without coverage enabled the functions are marked unused, and with coverage they are considered used, and I'm not sure why.

ecstatic-morse commented 3 years ago

The regression in the first case is legitimate and not related to unused functions. If you look at the MIR after SimplifyCfg-elaborate-drops, you'll see that drop elaboration is no longer able to remove the frivolous drops in the presence of code coverage statements. IIRC, I looked for a very specific pattern when determining whether a SwitchInt terminator is a switch on an enum discriminant or not:

https://github.com/rust-lang/rust/blob/4031f7b0a8047653f2f989f2d8579bf5650e71ca/compiler/rustc_mir/src/dataflow/impls/mod.rs#L680-L717

We used to have a bespoke terminator for that operation, but it was refactored away. To fix the test, modify that function to skip over code coverage statements when looking for a discriminant read or put the code coverage statements elsewhere.

richkadel commented 3 years ago

@tmandry - I currently inject the Coverage statement in the last bb of the bcb, and I push it to the end of the statements vec. But looking at this example, I think that looks weird, since Terminators are sort of a special case of a Statement, and in this case, one logically flows into the other. Adding the Coverage statement oddly breaks up that pair.

I think I will try injecting the statement at the front of the statements vec, and in the first (leader) bb of the bcb. A slight performance hit with the vec insert(0, cov_stmt) vs. the push(), but I think it's negligible.

I'll see if that resolves it. Who knows, maybe it will help with other issues.

richkadel commented 3 years ago
$ ./x.py test --rustc-args="-Zinstrument-coverage" src/test/ui/consts/unstable-precise-live-drops-in-libcore.rs

Now passes, with #80072

richkadel commented 3 years ago

1 down, 3 to go.

The fix in #80072 did not fix tests 2, 3, and 4 above.