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

Rust 1.19 regression, scopeguard, ICE #42463

Closed
brson opened this issue Jun 6, 2017 · 2 comments
Closed

Rust 1.19 regression, scopeguard, ICE #42463

brson opened this issue Jun 6, 2017 · 2 comments
Labels
regression-from-stable-to-beta Performance or correctness regression from stable to beta.

Comments

@brson
Copy link
Contributor

brson commented Jun 6, 2017

https://github.com/bluss/scopeguard

commit e1639812249432b5d4dc0fea3e804582a7092a50
Author: bluss <bluss@users.noreply.github.com>
Date:   Sat Jan 21 11:31:53 2017 +0100

    Add categories

brian@ip-10-145-43-250:/mnt2/dev⟫ rustc +nightly -Vv
rustc 1.19.0-nightly (0418fa9d3 2017-06-04)
binary: rustc
commit-hash: 0418fa9d382a47d782cc1e195c14573be9c32095
commit-date: 2017-06-04
host: x86_64-unknown-linux-gnu
release: 1.19.0-nightly
LLVM version: 4.0

101 brian@ip-10-145-43-250:~/dev/scopeguard⟫ RUST_BACKTRACE=1 cargo +nightly test
   Compiling scopeguard v0.3.2 (file:///mnt2/dev/scopeguard)
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/blob/master/CONTRIBUTING.md#bug-reports

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'already mutably borrowed: BorrowError', /checkout/src/libcore/result.rs:860
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at /checkout/src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/sys_common/backtrace.rs:60
             at /checkout/src/libstd/panicking.rs:355
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:365
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:549
   5: std::panicking::begin_panic
             at /checkout/src/libstd/panicking.rs:511
   6: std::panicking::begin_panic_fmt
             at /checkout/src/libstd/panicking.rs:495
   7: rust_begin_unwind
             at /checkout/src/libstd/panicking.rs:471
   8: core::panicking::panic_fmt
             at /checkout/src/libcore/panicking.rs:69
   9: core::result::unwrap_failed
  10: rustc::infer::InferCtxt::closure_type
  11: rustc::traits::select::SelectionContext::closure_trait_ref
  12: rustc::traits::select::SelectionContext::confirm_candidate
  13: rustc::traits::select::SelectionContext::select
  14: rustc::traits::project::assemble_candidates_from_impls::{{closure}}
  15: rustc::traits::project::assemble_candidates_from_impls
  16: rustc::traits::project::opt_normalize_projection_type
  17: rustc::traits::project::poly_project_and_unify_type::{{closure}}
  18: rustc::traits::project::poly_project_and_unify_type
  19: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  20: rustc::traits::select::SelectionContext::evaluate_predicates_recursively
  21: rustc::traits::select::SelectionContext::evaluate_candidate::{{closure}}
  22: rustc::infer::InferCtxt::probe
  23: rustc::traits::select::SelectionContext::evaluate_candidate
  24: rustc::traits::select::SelectionContext::evaluate_stack
  25: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  26: rustc::traits::select::SelectionContext::evaluate_obligation
  27: rustc_typeck::check::method::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::lookup_method_in_trait
  28: rustc_typeck::check::FnCtxt::try_overloaded_lvalue_op
  29: rustc_typeck::check::FnCtxt::check_method_call
  30: rustc_typeck::check::FnCtxt::check_expr_kind
  31: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  32: rustc_typeck::check::FnCtxt::check_method_call
  33: rustc_typeck::check::FnCtxt::check_expr_kind
  34: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  35: rustc_typeck::check::FnCtxt::check_block_with_expected::{{closure}}
  36: rustc_typeck::check::FnCtxt::check_block_with_expected
  37: rustc_typeck::check::FnCtxt::check_expr_kind
  38: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  39: rustc_typeck::check::FnCtxt::check_return_expr
  40: rustc_typeck::check::check_fn
  41: rustc_typeck::check::typeck_tables_of::{{closure}}
  42: rustc_typeck::check::typeck_tables_of
  43: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::try_get
  44: rustc::ty::maps::TyCtxtAt::typeck_tables_of
  45: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_tables_of
  46: rustc_typeck::check::typeck_item_bodies
  47: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_item_bodies<'tcx>>::try_get
  48: rustc::ty::maps::TyCtxtAt::typeck_item_bodies
  49: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_item_bodies
  50: rustc_typeck::check_crate
  51: rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}
  52: rustc_driver::driver::phase_3_run_analysis_passes
  53: rustc_driver::driver::compile_input
  54: rustc_driver::run_compiler

error: Could not compile `scopeguard`.

To learn more, run the command again with --verbose.

cc @bluss

@brson brson added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Jun 6, 2017
@Mark-Simulacrum
Copy link
Member

4ed2eda -- #42281; cc @eddyb

@eddyb
Copy link
Member

eddyb commented Jun 6, 2017

Reduced testcase (closure satisfying Fn bound on DerefMut impl used in autoderef):

use std::ops::{Deref, DerefMut};

struct CheckedDeref<T, F> {
    value: T,
    check: F
}

impl<F: Fn(&T) -> bool, T> Deref for CheckedDeref<T, F> {
    type Target = T;
    fn deref(&self) -> &T {
        assert!((self.check)(&self.value));
        &self.value
    }
}

impl<F: Fn(&T) -> bool, T> DerefMut for CheckedDeref<T, F> {
    fn deref_mut(&mut self) -> &mut T {
        assert!((self.check)(&self.value));
        &mut self.value
    }
}


fn main() {
    let mut v = CheckedDeref {
        value: vec![0],
        check: |v: &Vec<_>| !v.is_empty()
    };
    v.push(1);
    assert_eq!(*v, vec![0, 1]);
}

Working on a fix now.

@eddyb eddyb added regression-from-stable-to-beta Performance or correctness regression from stable to beta. and removed regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. labels Jun 6, 2017
bors added a commit that referenced this issue Jun 7, 2017
rustc_typeck: do not overlap a borrow of TypeckTables with method lookup.

If trait selection is reached, it could potentially request a closure signature, which will have to borrow the `TypeckTables` of the current function, and so those tables *should not* be mutably borrowed.

Fixes #42463.
r? @nikomatsakis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression-from-stable-to-beta Performance or correctness regression from stable to beta.
Projects
None yet
Development

No branches or pull requests

3 participants