mirror of
https://github.com/rust-lang/rust.git
synced 2025-11-22 17:47:25 +00:00
This makes it easier to open the messages file while developing on features. The commit was the result of automatted changes: for p in compiler/rustc_*; do mv $p/locales/en-US.ftl $p/messages.ftl; rmdir $p/locales; done for p in compiler/rustc_*; do sed -i "s#\.\./locales/en-US.ftl#../messages.ftl#" $p/src/lib.rs; done
51 lines
1.4 KiB
Rust
51 lines
1.4 KiB
Rust
#![feature(array_windows)]
|
|
#![recursion_limit = "256"]
|
|
#![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_errors::{DiagnosticMessage, SubdiagnosticMessage};
|
|
use rustc_hir::lang_items::LangItem;
|
|
use rustc_macros::fluent_messages;
|
|
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;
|
|
|
|
fluent_messages! { "../messages.ftl" }
|
|
|
|
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]));
|
|
|
|
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(),
|
|
impl_source => {
|
|
bug!("invalid `CoerceUnsized` impl_source: {:?}", impl_source);
|
|
}
|
|
}
|
|
}
|
|
|
|
pub fn provide(providers: &mut Providers) {
|
|
partitioning::provide(providers);
|
|
polymorphize::provide(providers);
|
|
}
|