Skip to content

Extern crate usage causes Box predicate to fail #113

@adpaco-aws

Description

@adpaco-aws

When trying to reproduce #111:

git clone https://github.com/rust-random/rand.git
cd rand
RUST_BACKTRACE=1 RUSTFLAGS="-Z trim-diagnostic-paths=no -Z codegen-backend=gotoc" RUSTC_LOG="rustc_codegen_llvm::gotoc" RUSTC=rmc-rustc cargo build --verbose --target x86_64-unknown-linux-gnu -j 1 

We got the following error instead:

DEBUG rustc_codegen_llvm::gotoc::metadata finding function name for instance: error_impls::std::boxed::Box::<error::Error>::new, debug: Instance { def: Item(WithOptConstParam { did: DefId(6:203 ~ alloc[4805]::boxed::{impl#0}::new), const_param_did: None }), substs: [error::Error] }, name: error_impls::std::boxed::Box::<T>::new, symbol: _ZN5alloc5boxed12Box$LT$T$GT$3new17hc5fab4a3b3554312E, demangle: alloc::boxed::Box<T>::new::hc5fab4a3b3554312
DEBUG rustc_codegen_llvm::gotoc handling error_impls::std::boxed::Box::<error::Error>::new, error_impls::std::boxed::Box::<T>::new
DEBUG rustc_codegen_llvm::gotoc variables: 
DEBUG rustc_codegen_llvm::gotoc let _1: error::Error
DEBUG rustc_codegen_llvm::gotoc block bb0
DEBUG rustc_codegen_llvm::gotoc _0 = Box(T)
DEBUG rustc_codegen_llvm::gotoc (*_0) = move _1
DEBUG rustc_codegen_llvm::gotoc return
DEBUG rustc_codegen_llvm::gotoc::metadata finding function name for instance: error_impls::std::boxed::Box::<error::Error>::new, debug: Instance { def: Item(WithOptConstParam { did: DefId(6:203 ~ alloc[4805]::boxed::{impl#0}::new), const_param_did: None }), substs: [error::Error] }, name: error_impls::std::boxed::Box::<T>::new, symbol: _ZN5alloc5boxed12Box$LT$T$GT$3new17hc5fab4a3b3554312E, demangle: alloc::boxed::Box<T>::new::hc5fab4a3b3554312
DEBUG rustc_codegen_llvm::gotoc::typ variants are: [VariantDef { def_id: DefId(6:195 ~ alloc[4805]::boxed::Box), ctor_def_id: Some(DefId(6:196 ~ alloc[4805]::boxed::Box::{constructor#0})), ident: Box#0, discr: Relative(0), fields: [FieldDef { did: DefId(6:199 ~ alloc[4805]::boxed::Box::0), ident: 0#0, vis: Restricted(DefId(6:72 ~ alloc[4805]::boxed)) }, FieldDef { did: DefId(6:200 ~ alloc[4805]::boxed::Box::1), ident: 1#0, vis: Restricted(DefId(6:72 ~ alloc[4805]::boxed)) }], ctor_kind: Fn, flags: NO_VARIANT_FLAGS }]
DEBUG rustc_codegen_llvm::gotoc::metadata finding function name for instance: error_impls::std::boxed::Box::<error::Error>::new, debug: Instance { def: Item(WithOptConstParam { did: DefId(6:203 ~ alloc[4805]::boxed::{impl#0}::new), const_param_did: None }), substs: [error::Error] }, name: error_impls::std::boxed::Box::<T>::new, symbol: _ZN5alloc5boxed12Box$LT$T$GT$3new17hc5fab4a3b3554312E, demangle: alloc::boxed::Box<T>::new::hc5fab4a3b3554312
DEBUG rustc_codegen_llvm::gotoc::metadata finding function name for instance: error_impls::std::boxed::Box::<error::Error>::new, debug: Instance { def: Item(WithOptConstParam { did: DefId(6:203 ~ alloc[4805]::boxed::{impl#0}::new), const_param_did: None }), substs: [error::Error] }, name: error_impls::std::boxed::Box::<T>::new, symbol: _ZN5alloc5boxed12Box$LT$T$GT$3new17hc5fab4a3b3554312E, demangle: alloc::boxed::Box<T>::new::hc5fab4a3b3554312
DEBUG rustc_codegen_llvm::gotoc::metadata finding function name for instance: error_impls::std::boxed::Box::<error::Error>::new, debug: Instance { def: Item(WithOptConstParam { did: DefId(6:203 ~ alloc[4805]::boxed::{impl#0}::new), const_param_did: None }), substs: [error::Error] }, name: error_impls::std::boxed::Box::<T>::new, symbol: _ZN5alloc5boxed12Box$LT$T$GT$3new17hc5fab4a3b3554312E, demangle: alloc::boxed::Box<T>::new::hc5fab4a3b3554312
DEBUG rustc_codegen_llvm::gotoc::typ variants are: [VariantDef { def_id: DefId(0:81 ~ getrandom[f3b5]::error::Error), ctor_def_id: Some(DefId(0:82 ~ getrandom[f3b5]::error::Error::{constructor#0})), ident: Error#0, discr: Relative(0), fields: [FieldDef { did: DefId(0:83 ~ getrandom[f3b5]::error::Error::0), ident: 0#0, vis: Restricted(DefId(0:5 ~ getrandom[f3b5]::error)) }], ctor_kind: Fn, flags: NO_VARIANT_FLAGS }]
DEBUG rustc_codegen_llvm::gotoc::metadata finding function name for instance: error_impls::std::boxed::Box::<error::Error>::new, debug: Instance { def: Item(WithOptConstParam { did: DefId(6:203 ~ alloc[4805]::boxed::{impl#0}::new), const_param_did: None }), substs: [error::Error] }, name: error_impls::std::boxed::Box::<T>::new, symbol: _ZN5alloc5boxed12Box$LT$T$GT$3new17hc5fab4a3b3554312E, demangle: alloc::boxed::Box<T>::new::hc5fab4a3b3554312
DEBUG rustc_codegen_llvm::gotoc::metadata finding function name for instance: error_impls::std::boxed::Box::<error::Error>::new, debug: Instance { def: Item(WithOptConstParam { did: DefId(6:203 ~ alloc[4805]::boxed::{impl#0}::new), const_param_did: None }), substs: [error::Error] }, name: error_impls::std::boxed::Box::<T>::new, symbol: _ZN5alloc5boxed12Box$LT$T$GT$3new17hc5fab4a3b3554312E, demangle: alloc::boxed::Box<T>::new::hc5fab4a3b3554312
DEBUG rustc_codegen_llvm::gotoc::statement handling statement _0 = Box(T)
DEBUG rustc_codegen_llvm::gotoc::place codegen_place: _0
DEBUG rustc_codegen_llvm::gotoc::metadata finding function name for instance: error_impls::std::boxed::Box::<error::Error>::new, debug: Instance { def: Item(WithOptConstParam { did: DefId(6:203 ~ alloc[4805]::boxed::{impl#0}::new), const_param_did: None }), substs: [error::Error] }, name: error_impls::std::boxed::Box::<T>::new, symbol: _ZN5alloc5boxed12Box$LT$T$GT$3new17hc5fab4a3b3554312E, demangle: alloc::boxed::Box<T>::new::hc5fab4a3b3554312
DEBUG rustc_codegen_llvm::gotoc::typ variants are: [VariantDef { def_id: DefId(6:195 ~ alloc[4805]::boxed::Box), ctor_def_id: Some(DefId(6:196 ~ alloc[4805]::boxed::Box::{constructor#0})), ident: Box#0, discr: Relative(0), fields: [FieldDef { did: DefId(6:199 ~ alloc[4805]::boxed::Box::0), ident: 0#0, vis: Restricted(DefId(6:72 ~ alloc[4805]::boxed)) }, FieldDef { did: DefId(6:200 ~ alloc[4805]::boxed::Box::1), ident: 1#0, vis: Restricted(DefId(6:72 ~ alloc[4805]::boxed)) }], ctor_kind: Fn, flags: NO_VARIANT_FLAGS }]
DEBUG rustc_codegen_llvm::gotoc::typ variants are: [VariantDef { def_id: DefId(6:195 ~ alloc[4805]::boxed::Box), ctor_def_id: Some(DefId(6:196 ~ alloc[4805]::boxed::Box::{constructor#0})), ident: Box#0, discr: Relative(0), fields: [FieldDef { did: DefId(6:199 ~ alloc[4805]::boxed::Box::0), ident: 0#0, vis: Restricted(DefId(6:72 ~ alloc[4805]::boxed)) }, FieldDef { did: DefId(6:200 ~ alloc[4805]::boxed::Box::1), ident: 1#0, vis: Restricted(DefId(6:72 ~ alloc[4805]::boxed)) }], ctor_kind: Fn, flags: NO_VARIANT_FLAGS }]
DEBUG rustc_codegen_llvm::gotoc::typ variants are: [VariantDef { def_id: DefId(0:81 ~ getrandom[f3b5]::error::Error), ctor_def_id: Some(DefId(0:82 ~ getrandom[f3b5]::error::Error::{constructor#0})), ident: Error#0, discr: Relative(0), fields: [FieldDef { did: DefId(0:83 ~ getrandom[f3b5]::error::Error::0), ident: 0#0, vis: Restricted(DefId(0:5 ~ getrandom[f3b5]::error)) }], ctor_kind: Fn, flags: NO_VARIANT_FLAGS }]
thread 'rustc' panicked at 'assertion failed: boxed_type.is_rust_box()', compiler/rustc_codegen_llvm/src/gotoc/utils.rs:94:9
stack backtrace:
   0: rust_begin_unwind
             at /home/ubuntu/rmc/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /home/ubuntu/rmc/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /home/ubuntu/rmc/library/core/src/panicking.rs:50:5
   3: rustc_codegen_llvm::gotoc::utils::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::box_value
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/utils.rs:94:9
   4: rustc_codegen_llvm::gotoc::rvalue::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_rvalue
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/rvalue.rs:406:21
   5: rustc_codegen_llvm::gotoc::statement::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_statement
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/statement.rs:412:60
   6: rustc_codegen_llvm::gotoc::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_block
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/mod.rs:55:29
   7: rustc_codegen_llvm::gotoc::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_function::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/mod.rs:113:71
   8: core::iter::traits::iterator::Iterator::for_each::call::{{closure}}
             at /home/ubuntu/rmc/library/core/src/iter/traits/iterator.rs:773:29
   9: core::iter::adapters::map::map_fold::{{closure}}
             at /home/ubuntu/rmc/library/core/src/iter/adapters/map.rs:82:21
  10: <core::iter::adapters::enumerate::Enumerate<I> as core::iter::traits::iterator::Iterator>::fold::enumerate::{{closure}}
             at /home/ubuntu/rmc/library/core/src/iter/adapters/enumerate.rs:104:27
  11: core::iter::traits::iterator::Iterator::fold
             at /home/ubuntu/rmc/library/core/src/iter/traits/iterator.rs:2146:21
  12: <core::iter::adapters::enumerate::Enumerate<I> as core::iter::traits::iterator::Iterator>::fold
             at /home/ubuntu/rmc/library/core/src/iter/adapters/enumerate.rs:110:9
  13: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
             at /home/ubuntu/rmc/library/core/src/iter/adapters/map.rs:122:9
  14: core::iter::traits::iterator::Iterator::for_each
             at /home/ubuntu/rmc/library/core/src/iter/traits/iterator.rs:776:9
  15: rustc_codegen_llvm::gotoc::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_function
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/mod.rs:113:13
  16: <rustc_codegen_llvm::gotoc::GotocCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/mod.rs:281:47
  17: rustc_interface::passes::start_codegen::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/passes.rs:1021:9
  18: rustc_data_structures::profiling::VerboseTimingGuard::run
             at /home/ubuntu/rmc/compiler/rustc_data_structures/src/profiling.rs:573:9
  19: rustc_session::utils::<impl rustc_session::session::Session>::time
             at /home/ubuntu/rmc/compiler/rustc_session/src/utils.rs:16:9
  20: rustc_interface::passes::start_codegen
             at /home/ubuntu/rmc/compiler/rustc_interface/src/passes.rs:1020:19
  21: rustc_interface::queries::Queries::ongoing_codegen::{{closure}}::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/queries.rs:296:20
  22: rustc_interface::passes::QueryContext::enter::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/passes.rs:755:42
  23: rustc_middle::ty::context::tls::enter_context::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_middle/src/ty/context.rs:1736:50
  24: rustc_middle::ty::context::tls::set_tlv
             at /home/ubuntu/rmc/compiler/rustc_middle/src/ty/context.rs:1720:9
  25: rustc_middle::ty::context::tls::enter_context
             at /home/ubuntu/rmc/compiler/rustc_middle/src/ty/context.rs:1736:9
  26: rustc_interface::passes::QueryContext::enter
             at /home/ubuntu/rmc/compiler/rustc_interface/src/passes.rs:755:9
  27: rustc_interface::queries::Queries::ongoing_codegen::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/queries.rs:287:13
  28: rustc_interface::queries::Query<T>::compute
             at /home/ubuntu/rmc/compiler/rustc_interface/src/queries.rs:40:28
  29: rustc_interface::queries::Queries::ongoing_codegen
             at /home/ubuntu/rmc/compiler/rustc_interface/src/queries.rs:285:9
  30: rustc_driver::run_compiler::{{closure}}::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_driver/src/lib.rs:442:13
  31: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
             at /home/ubuntu/rmc/compiler/rustc_interface/src/queries.rs:432:19
  32: rustc_driver::run_compiler::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_driver/src/lib.rs:337:22
  33: rustc_interface::interface::create_compiler_and_run::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/interface.rs:208:13
  34: rustc_span::with_source_map
             at /home/ubuntu/rmc/compiler/rustc_span/src/lib.rs:788:5
  35: rustc_interface::interface::create_compiler_and_run
             at /home/ubuntu/rmc/compiler/rustc_interface/src/interface.rs:202:5
  36: rustc_interface::interface::run_compiler::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/interface.rs:224:12
  37: rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::{{closure}}::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/util.rs:155:13
  38: scoped_tls::ScopedKey<T>::set
             at /home/ubuntu/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:137:9
  39: rustc_span::with_session_globals
             at /home/ubuntu/rmc/compiler/rustc_span/src/lib.rs:105:5
  40: rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/util.rs:153:9
  41: rustc_interface::util::scoped_thread::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/util.rs:128:24
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

The cause of the error is that an instance of std::boxed::Box was being imported with extern crate std in error_impls.rs and getting the name error_impls::std::boxed::Box, so our is_rust_box predicate (based on the type name) fails because of the error_impls prefix.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions