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

Incoherent impls are allowed on opaque types #74298

Closed
matthewjasper opened this issue Jul 13, 2020 · 1 comment
Closed

Incoherent impls are allowed on opaque types #74298

matthewjasper opened this issue Jul 13, 2020 · 1 comment
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthewjasper
Copy link
Contributor

matthewjasper commented Jul 13, 2020

I tried this code:

#![feature(type_alias_impl_trait)]

type X<T> = impl Sized;

fn f<T>() -> X<T> {}

trait Y {
    fn g(&self) {}
}

impl Y for X<()> {}
impl Y for X<i32> {}

fn main() {
    f::<()>().g();
}

I expected to see this happen: error for potentially overlapping impls

Instead, this happened: ICEs in codegen

Meta

rustc --version --verbose:

rustc 1.46.0-nightly (346aec9b0 2020-07-11)
binary: rustc
commit-hash: 346aec9b02f3c74f3fce97fd6bda24709d220e49
commit-date: 2020-07-11
host: x86_64-pc-windows-msvc
release: 1.46.0-nightly
LLVM version: 10.0
Backtrace

error: internal compiler error: src\librustc_trait_selection\traits\codegen\mod.rs:62:17: Encountered error `Unimplemented` selecting `Binder(<() as Y>)` during codegen

thread 'rustc' panicked at 'Box<Any>', src\librustc_errors\lib.rs:916:9
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: <std::io::IoSliceMut as core::fmt::Debug>::fmt
   3: std::panicking::take_hook
   4: std::panicking::take_hook
   5: rustc_driver::report_ice
   6: std::panicking::rust_panic_with_hook
   7: <rustc_errors::styled_buffer::StyledBuffer as core::fmt::Debug>::fmt
   8: rustc_errors::HandlerInner::err_count
   9: rustc_errors::Handler::bug
  10: rustc_middle::util::bug::bug_fmt
  11: <rustc_middle::ty::consts::ConstInt as core::fmt::Debug>::fmt
  12: <rustc_middle::ty::consts::ConstInt as core::fmt::Debug>::fmt
  13: rustc_middle::util::bug::bug_fmt
  14: rustc_middle::util::bug::bug_fmt
  15: unicode_normalization::normalize::is_hangul_syllable
  16: rustc_trait_selection::traits::codegen::codegen_fulfill_obligation
  17: rustc_ty::provide
  18: crc32fast::Hasher::finalize
  19: crc32fast::Hasher::finalize
  20: crc32fast::Hasher::finalize
  21: rustc_ty::provide
  22: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::features_query>::hash_result
  23: <rustc_middle::ty::binding::BindingMode as rustc_middle::ty::context::Lift>::lift_to_tcx
  24: rustc_middle::ty::structural_impls::<impl rustc_middle::ty::context::Lift for rustc_ast::ast::InlineAsmTemplatePiece>::lift_to_tcx
  25: <rustc_middle::ty::subst::UserSubsts as core::fmt::Debug>::fmt
  26: rustc_middle::ty::instance::Instance::resolve
  27: <rustc_mir::monomorphize::collector::MirNeighborCollector as rustc_middle::mir::visit::Visitor>::visit_terminator
  28: <rustc_mir::monomorphize::collector::RootCollector as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_impl_item
  29: rustc_mir::monomorphize::collector::collect_crate_mono_items
  30: <rustc_mir::dataflow::impls::borrows::BorrowIndex as core::fmt::Debug>::fmt
  31: rustc_mir::monomorphize::collector::collect_crate_mono_items
  32: rustc_mir::monomorphize::partitioning::compute_codegen_unit_name
  33: <rustc_target::abi::TyAndLayout<&rustc_middle::ty::TyS> as rustc_codegen_llvm::type_of::LayoutLlvmExt>::pointee_info_at
  34: <rustc_codegen_llvm::llvm_::ffi::debuginfo::DISPFlags as core::fmt::Debug>::fmt
  35: rustc_codegen_llvm::type_::<impl rustc_codegen_ssa::traits::type_::LayoutTypeMethods for rustc_codegen_llvm::context::CodegenCx>::reg_backend_type
  36: rustc_codegen_llvm::type_::<impl rustc_codegen_ssa::traits::type_::LayoutTypeMethods for rustc_codegen_llvm::context::CodegenCx>::reg_backend_type
  37: <rustc_target::abi::TyAndLayout<&rustc_middle::ty::TyS> as rustc_codegen_llvm::type_of::LayoutLlvmExt>::pointee_info_at
  38: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  39: rustc_interface::passes::QueryContext::print_stats
  40: rustc_interface::passes::BoxedResolver::complete
  41: rustc_interface::queries::Queries::ongoing_codegen
  42: <rustc_codegen_ssa::back::linker::MsvcLinker as rustc_codegen_ssa::back::linker::Linker>::partial_relro
  43: <env_logger::filter::inner::Filter as core::fmt::Display>::fmt
  44: <rustc_driver::DEFAULT_HOOK as core::ops::deref::Deref>::deref
  45: <rustc_driver::DEFAULT_HOOK as core::ops::deref::Deref>::deref
  46: <(&rustc_middle::ty::sty::Const,rustc_middle::mir::Field) as rustc_middle::ty::query::keys::Key>::default_span
  47: std::sys::windows::thread::Thread::new
  48: BaseThreadInitThunk
  49: RtlUserThreadStart
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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.46.0-nightly (346aec9b0 2020-07-11) running on x86_64-pc-windows-msvc

query stack during panic:
#0 [codegen_fulfill_obligation] checking if `Y` fulfills its obligations
#1 [resolve_instance] resolving instance `<() as Y>::g`
#2 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: aborting due to previous error

@matthewjasper matthewjasper added 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. A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` labels Jul 13, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Jul 14, 2020
@Alexendoo Alexendoo added the requires-nightly This issue requires a nightly compiler in some way. label Jul 15, 2020
@Aaron1011
Copy link
Member

These impls shouldn't be allowed at all, so #76940 should fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Development

No branches or pull requests

4 participants