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

ICE: Unwrapping None in librustc_typeck/check/method/suggest.rs #71812

Closed
kriw opened this issue May 2, 2020 · 2 comments
Closed

ICE: Unwrapping None in librustc_typeck/check/method/suggest.rs #71812

kriw opened this issue May 2, 2020 · 2 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@kriw
Copy link

kriw commented May 2, 2020

Code

use std::io::Write;

struct A<W: std::io::Write> {
    file: Option<lzma::LzmaWriter<W>>,
}

impl<W> A<W> {
    async fn init(&mut self) {
        self.file.unwrap().write("".as_bytes()).unwrap();
    }
}

fn main() {}

Cargo.toml

[dependencies]

rust-lzma = "0.5"

Meta

rustc --version --verbose:

rustc 1.43.0-nightly (2890b37b8 2020-03-06)
binary: rustc
commit-hash: 2890b37b861247de3b8c6ba2ecbcd00048c728a1
commit-date: 2020-03-06
host: x86_64-unknown-linux-gnu
release: 1.43.0-nightly
LLVM version: 9.0

Error output

$ cargo check
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/librustc_typeck/check/method/suggest.rs:550:46
Backtrace

stack backtrace:                                        
   0: backtrace::backtrace::libunwind::trace                                                                    
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized                                                                
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/mod.rs:66 
   2: std::sys_common::backtrace::_print_fmt                                                                    
             at src/libstd/sys_common/backtrace.rs:78                                                           
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59                                                              4: core::fmt::write                                                                                          
             at src/libcore/fmt/mod.rs:1053            
   5: std::io::Write::write_fmt                                                                                 
             at src/libstd/io/mod.rs:1428                                                                       
   6: std::sys_common::backtrace::_print                                                                        
             at src/libstd/sys_common/backtrace.rs:62  
   7: std::sys_common::backtrace::print                                                                         
             at src/libstd/sys_common/backtrace.rs:49                                                           
   8: std::panicking::default_hook::{{closure}}                                                                 
             at src/libstd/panicking.rs:204                                                                     
   9: std::panicking::default_hook                                                                              
             at src/libstd/panicking.rs:224
  10: rustc_driver::report_ice                                                                                  
  11: std::panicking::rust_panic_with_hook 
             at src/libstd/panicking.rs:474                                                                     
  12: rust_begin_unwind                                                                                         
             at src/libstd/panicking.rs:378                                                                     
  13: core::panicking::panic_fmt                       
             at src/libcore/panicking.rs:85                                                                       14: core::panicking::panic               
             at src/libcore/panicking.rs:52                                                                     
  15: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut                     
  16: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter
  17: rustc_typeck::check::method::suggest::<impl rustc_typeck::check::FnCtxt>::report_method_error             
  18: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  19: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs      
  20: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  21: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs 
  22: rustc_typeck::check::FnCtxt::check_stmt           
  23: rustc_typeck::check::FnCtxt::check_block_with_expected                                                    
  24: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  25: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs      
  26: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind                     
  27: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  28: rustc_typeck::check::FnCtxt::check_block_with_expected
  29: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  30: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs      
  31: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_return_expr
  32: rustc_typeck::check::check_fn                                                                             
  33: rustc_typeck::check::closure::<impl rustc_typeck::check::FnCtxt>::check_expr_closure
  34: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind                           
  35: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  36: rustc_typeck::check::FnCtxt::check_argument_types
  37: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt>::confirm_builtin_call
  38: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt>::check_call
  39: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  40: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  41: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_return_expr
  42: rustc_typeck::check::check_fn
  43: rustc::ty::context::GlobalCtxt::enter_local
  44: rustc_typeck::check::typeck_tables_of
  45: rustc::ty::query::__query_compute::typeck_tables_of
  46: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tab
les_of>::compute
  47: rustc::dep_graph::graph::DepGraph::with_task_impl
  48: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  49: rustc_typeck::check::typeck_tables_of
  50: rustc::ty::query::__query_compute::typeck_tables_of
  51: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tab
les_of>::compute
  52: rustc::dep_graph::graph::DepGraph::with_task_impl
  53: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  54: rustc_typeck::collect::type_of::type_of
  55: rustc::ty::query::__query_compute::type_of
  56: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::type_of>::
compute
  57: rustc::dep_graph::graph::DepGraph::with_task_impl
  58: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  59: rustc_hir::intravisit::walk_expr
  60: <rustc_typeck::collect::CollectItemTypesVisitor as rustc_hir::intravisit::Visitor>::visit_impl_item
  61: rustc::hir::map::Map::visit_item_likes_in_module
  62: rustc_typeck::collect::collect_mod_item_types
  63: rustc::ty::query::__query_compute::collect_mod_item_types
  64: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::collect_mo
d_item_types>::compute
  65: rustc::dep_graph::graph::DepGraph::with_task_impl
  66: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  67: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::ensure_query
  68: rustc_typeck::check_crate
  69: rustc_interface::passes::analysis
  70: rustc::ty::query::__query_compute::analysis
  71: rustc::dep_graph::graph::DepGraph::with_task_impl
  72: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  73: rustc::ty::context::tls::enter_global
  74: rustc_interface::interface::run_compiler_in_existing_thread_pool
  75: rustc_ast::attr::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@kriw kriw added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 2, 2020
@kriw kriw changed the title Unwrapping None in librustc_typeck/check/method/suggest.rs ICE: Unwrapping None in librustc_typeck/check/method/suggest.rs May 2, 2020
@jonas-schievink jonas-schievink added A-diagnostics Area: Messages for errors, warnings, and lints E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels May 2, 2020
@jonas-schievink
Copy link
Contributor

Might be a duplicate of #69725, please check if it still happens on the current nightly.

@kriw
Copy link
Author

kriw commented May 2, 2020

It seems the bug is fixed on rustc 1.45.0-nightly, thank you.

@kriw kriw closed this as completed May 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants