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

Internal Compiler Error #102762

Closed
antiphoton opened this issue Oct 7, 2022 · 1 comment · Fixed by #102764
Closed

Internal Compiler Error #102762

antiphoton opened this issue Oct 7, 2022 · 1 comment · Fixed by #102764
Assignees
Labels
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.

Comments

@antiphoton
Copy link

Code

Rust playground

use async_trait::async_trait;

pub trait MySend: Send {}
impl<T: Send> MySend for T {}

pub trait MySync: Sync {}
impl<T: Sync> MySync for T {}

#[async_trait]
pub trait Fetcher: MySend + MySync {
    async fn get(self: &Box<Self>, _url: &str) -> Vec<u8> {
        todo!()
    }
}

pub struct Runtime {
    pub fetcher: Box<dyn Fetcher>,
}

impl Default for Runtime {
    fn default() -> Self {
        todo!()
    }
}

pub fn foo() {
    let runtime: Runtime = Default::default();
    let _ = runtime.fetcher.get("https://example.com");
}

Meta

rustc --version --verbose:

rustc 1.64.0 (a55dd71d5 2022-09-19)
binary: rustc
commit-hash: a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52
commit-date: 2022-09-19
host: x86_64-unknown-linux-gnu
release: 1.64.0
LLVM version: 14.0.6

Error output

error: internal compiler error: compiler/rustc_middle/src/ty/layout.rs:3465:18: receiver type has unsupported layout: TyAndLayout { ty: &std::boxed::Box<dyn Fetcher>, layout: Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, abi: Scalar(Initialized { value: Pointer, valid_range: 1..=18446744073709551615 }), fields: Primitive, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer, valid_range: 1..=18446744073709551615 }), variants: Single { index: 0 } } }

Backtrace

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/compiler/rustc_errors/src/lib.rs:1392:9
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: std::panic::panic_any::<rustc_errors::ExplicitBug>
   2: <rustc_errors::HandlerInner>::bug::<&alloc::string::String>
   3: <rustc_errors::Handler>::bug::<&alloc::string::String>
   4: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, ()>
   5: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>
   6: rustc_middle::util::bug::bug_fmt
   7: rustc_middle::ty::layout::make_thin_self_ptr::<rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>>
   8: <&mut &mut <core::iter::adapters::enumerate::Enumerate<_> as core::iter::traits::iterator::Iterator>::try_fold::enumerate<rustc_middle::ty::Ty, (), core::ops::control_flow::ControlFlow<core::ops::control_flow::ControlFlow<rustc_target::abi::call::ArgAbi<rustc_middle::ty::Ty>>>, core::iter::adapters::map::map_try_fold<(usize, rustc_middle::ty::Ty), core::result::Result<rustc_target::abi::call::ArgAbi<rustc_middle::ty::Ty>, rustc_middle::ty::layout::FnAbiError>, (), core::ops::control_flow::ControlFlow<core::ops::control_flow::ControlFlow<rustc_target::abi::call::ArgAbi<rustc_middle::ty::Ty>>>, <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>>::fn_abi_new_uncached::{closure#2}, <core::iter::adapters::GenericShunt<core::iter::adapters::map::Map<core::iter::adapters::enumerate::Enumerate<core::iter::adapters::chain::Chain<core::iter::adapters::chain::Chain<core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::ty::Ty>>, core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::ty::Ty>>>, core::option::IntoIter<rustc_middle::ty::Ty>>>, <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>>::fn_abi_new_uncached::{closure#2}>, core::result::Result<core::convert::Infallible, rustc_middle::ty::layout::FnAbiError>> as core::iter::traits::iterator::Iterator>::try_fold<(), core::iter::traits::iterator::Iterator::try_for_each::call<rustc_target::abi::call::ArgAbi<rustc_middle::ty::Ty>, core::ops::control_flow::ControlFlow<rustc_target::abi::call::ArgAbi<rustc_middle::ty::Ty>>, core::ops::control_flow::ControlFlow<rustc_target::abi::call::ArgAbi<rustc_middle::ty::Ty>>::Break>::{closure#0}, core::ops::control_flow::ControlFlow<rustc_target::abi::call::ArgAbi<rustc_middle::ty::Ty>>>::{closure#0}>::{closure#0}>::{closure#0} as core::ops::function::FnMut<((), rustc_middle::ty::Ty)>>::call_mut
   9: <alloc::vec::Vec<rustc_target::abi::call::ArgAbi<rustc_middle::ty::Ty>> as alloc::vec::spec_from_iter::SpecFromIter<rustc_target::abi::call::ArgAbi<rustc_middle::ty::Ty>, core::iter::adapters::GenericShunt<core::iter::adapters::map::Map<core::iter::adapters::enumerate::Enumerate<core::iter::adapters::chain::Chain<core::iter::adapters::chain::Chain<core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::ty::Ty>>, core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::ty::Ty>>>, core::option::IntoIter<rustc_middle::ty::Ty>>>, <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>>::fn_abi_new_uncached::{closure#2}>, core::result::Result<core::convert::Infallible, rustc_middle::ty::layout::FnAbiError>>>>::from_iter
  10: <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>>::fn_abi_new_uncached
  11: rustc_middle::ty::layout::fn_abi_of_instance
  12: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_middle::ty::ParamEnvAnd<(rustc_middle::ty::instance::Instance, &rustc_middle::ty::list::List<rustc_middle::ty::Ty>)>, core::result::Result<&rustc_target::abi::call::FnAbi<rustc_middle::ty::Ty>, rustc_middle::ty::layout::FnAbiError>>
  13: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::fn_abi_of_instance, rustc_query_impl::plumbing::QueryCtxt>
  14: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::fn_abi_of_instance
  15: rustc_codegen_ssa::mir::codegen_mir::<rustc_codegen_llvm::builder::Builder>
  16: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
  17: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::symbol::Symbol, rustc_codegen_ssa::ModuleCodegen<rustc_codegen_llvm::ModuleLlvm>>
  18: rustc_codegen_llvm::base::compile_codegen_unit
  19: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  20: <rustc_session::session::Session>::time::<alloc::boxed::Box<dyn core::any::Any>, rustc_interface::passes::start_codegen::{closure#0}>
  21: <rustc_interface::passes::QueryContext>::enter::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_errors::ErrorGuaranteed>>
  22: <rustc_interface::queries::Queries>::ongoing_codegen
  23: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorGuaranteed>>
  24: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
  25: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>

@antiphoton antiphoton 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 Oct 7, 2022
@compiler-errors
Copy link
Member

Minimized:

use std::future::Future;
use std::pin::Pin;

pub trait Fetcher: Send + Sync {
    fn get<'a>(self: &'a Box<Self>) -> Pin<Box<dyn Future<Output = Vec<u8>> + 'a>>
    where
        Self: Sync,
    {
        todo!()
    }
}

fn fetcher() -> Box<dyn Fetcher> {
    todo!()
}

pub fn foo() {
    let fetcher = fetcher();
    let _ = fetcher.get();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants