rust/compiler/rustc_monomorphize/src/lib.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

47 lines
1.3 KiB
Rust
Raw Normal View History

#![feature(array_windows)]
2021-09-01 19:05:35 +00:00
#![recursion_limit = "256"]
2022-02-23 13:06:22 +00:00
#![allow(rustc::potential_query_instability)]
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
#[macro_use]
extern crate tracing;
#[macro_use]
extern crate rustc_middle;
use rustc_hir::lang_items::LangItem;
2020-03-29 14:41:09 +00:00
use rustc_middle::traits;
use rustc_middle::ty::adjustment::CustomCoerceUnsized;
use rustc_middle::ty::query::{Providers, TyCtxtAt};
use rustc_middle::ty::{self, Ty};
mod collector;
mod errors;
mod partitioning;
mod polymorphize;
mod util;
2021-01-07 05:41:55 +00:00
fn custom_coerce_unsize_info<'tcx>(
tcx: TyCtxtAt<'tcx>,
source_ty: Ty<'tcx>,
target_ty: Ty<'tcx>,
) -> CustomCoerceUnsized {
let trait_ref =
ty::Binder::dummy(tcx.mk_trait_ref(LangItem::CoerceUnsized, [source_ty, target_ty]));
2022-09-09 11:36:27 +00:00
match tcx.codegen_select_candidate((ty::ParamEnv::reveal_all(), trait_ref)) {
Ok(traits::ImplSource::UserDefined(traits::ImplSourceUserDefinedData {
impl_def_id,
..
})) => tcx.coerce_unsized_info(impl_def_id).custom_kind.unwrap(),
2020-05-11 15:25:33 +00:00
impl_source => {
bug!("invalid `CoerceUnsized` impl_source: {:?}", impl_source);
}
}
}
pub fn provide(providers: &mut Providers) {
partitioning::provide(providers);
polymorphize::provide(providers);
}