Rustfmt
This commit is contained in:
parent
89702b9917
commit
95539518ec
24
src/base.rs
24
src/base.rs
@ -18,9 +18,8 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(
|
||||
) {
|
||||
match mono_item {
|
||||
MonoItem::Fn(inst) => {
|
||||
let _inst_guard = PrintOnPanic(|| {
|
||||
format!("{:?} {}", inst, tcx.symbol_name(inst).as_str())
|
||||
});
|
||||
let _inst_guard =
|
||||
PrintOnPanic(|| format!("{:?} {}", inst, tcx.symbol_name(inst).as_str()));
|
||||
let _mir_guard = PrintOnPanic(|| {
|
||||
match inst.def {
|
||||
InstanceDef::Item(_)
|
||||
@ -377,8 +376,9 @@ fn trans_stmt<'a, 'tcx: 'a>(
|
||||
if *variant_index != dataful_variant {
|
||||
let niche = place.place_field(fx, mir::Field::new(0));
|
||||
//let niche_llty = niche.layout.immediate_llvm_type(bx.cx);
|
||||
let niche_value = ((variant_index.as_u32() - niche_variants.start().as_u32()) as u128)
|
||||
.wrapping_add(niche_start);
|
||||
let niche_value =
|
||||
((variant_index.as_u32() - niche_variants.start().as_u32()) as u128)
|
||||
.wrapping_add(niche_start);
|
||||
// FIXME(eddyb) Check the actual primitive type here.
|
||||
let niche_llval = if niche_value == 0 {
|
||||
CValue::const_val(fx, niche.layout().ty, 0)
|
||||
@ -606,7 +606,10 @@ fn trans_stmt<'a, 'tcx: 'a>(
|
||||
let usize_type = fx.clif_type(fx.tcx.types.usize).unwrap();
|
||||
let layout = fx.layout_of(content_ty);
|
||||
let llsize = fx.bcx.ins().iconst(usize_type, layout.size.bytes() as i64);
|
||||
let llalign = fx.bcx.ins().iconst(usize_type, layout.align.abi.bytes() as i64);
|
||||
let llalign = fx
|
||||
.bcx
|
||||
.ins()
|
||||
.iconst(usize_type, layout.align.abi.bytes() as i64);
|
||||
let box_layout = fx.layout_of(fx.tcx.mk_box(content_ty));
|
||||
|
||||
// Allocate space:
|
||||
@ -688,9 +691,12 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>(
|
||||
}
|
||||
match layout.variants {
|
||||
layout::Variants::Single { index } => {
|
||||
let discr_val = layout.ty.ty_adt_def().map_or(index.as_u32() as u128, |def| {
|
||||
def.discriminant_for_variant(fx.tcx, index).val
|
||||
});
|
||||
let discr_val = layout
|
||||
.ty
|
||||
.ty_adt_def()
|
||||
.map_or(index.as_u32() as u128, |def| {
|
||||
def.discriminant_for_variant(fx.tcx, index).val
|
||||
});
|
||||
return CValue::const_val(fx, dest_layout.ty, discr_val as u64 as i64);
|
||||
}
|
||||
layout::Variants::Tagged { .. } | layout::Variants::NicheFilling { .. } => {}
|
||||
|
@ -389,15 +389,18 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> {
|
||||
// &'a T -> &'b T is allowed
|
||||
}
|
||||
(ty::FnPtr(_), ty::FnPtr(_)) => {
|
||||
let from_sig = fx.tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &from_ty.fn_sig(fx.tcx));
|
||||
let to_sig = fx.tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &to_ty.fn_sig(fx.tcx));
|
||||
let from_sig = fx.tcx.normalize_erasing_late_bound_regions(
|
||||
ParamEnv::reveal_all(),
|
||||
&from_ty.fn_sig(fx.tcx),
|
||||
);
|
||||
let to_sig = fx.tcx.normalize_erasing_late_bound_regions(
|
||||
ParamEnv::reveal_all(),
|
||||
&to_ty.fn_sig(fx.tcx),
|
||||
);
|
||||
assert_eq!(
|
||||
from_sig,
|
||||
to_sig,
|
||||
from_sig, to_sig,
|
||||
"Can't write fn ptr with incompatible sig {:?} to place with sig {:?}\n\n{:#?}",
|
||||
from_sig,
|
||||
to_sig,
|
||||
fx,
|
||||
from_sig, to_sig, fx,
|
||||
);
|
||||
// fn(&T) -> for<'l> fn(&'l T) is allowed
|
||||
}
|
||||
@ -577,7 +580,11 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn downcast_variant(self, fx: &FunctionCx<'a, 'tcx, impl Backend>, variant: VariantIdx) -> Self {
|
||||
pub fn downcast_variant(
|
||||
self,
|
||||
fx: &FunctionCx<'a, 'tcx, impl Backend>,
|
||||
variant: VariantIdx,
|
||||
) -> Self {
|
||||
let layout = self.layout().for_variant(fx, variant);
|
||||
self.unchecked_cast_to(layout)
|
||||
}
|
||||
|
@ -133,13 +133,23 @@ fn trans_const_place<'a, 'tcx: 'a>(
|
||||
ty::ParamEnv::reveal_all(),
|
||||
TransPlaceInterpreter,
|
||||
);
|
||||
ecx.push_stack_frame(fx.instance, DUMMY_SP, fx.mir, None, StackPopCleanup::None { cleanup: false }).unwrap();
|
||||
let op = ecx.eval_operand(&Operand::Constant(Box::new(Constant {
|
||||
span: DUMMY_SP,
|
||||
ty: const_.ty,
|
||||
user_ty: None,
|
||||
literal: const_,
|
||||
})), None)?;
|
||||
ecx.push_stack_frame(
|
||||
fx.instance,
|
||||
DUMMY_SP,
|
||||
fx.mir,
|
||||
None,
|
||||
StackPopCleanup::None { cleanup: false },
|
||||
)
|
||||
.unwrap();
|
||||
let op = ecx.eval_operand(
|
||||
&Operand::Constant(Box::new(Constant {
|
||||
span: DUMMY_SP,
|
||||
ty: const_.ty,
|
||||
user_ty: None,
|
||||
literal: const_,
|
||||
})),
|
||||
None,
|
||||
)?;
|
||||
let ptr = ecx.allocate(op.layout, MemoryKind::Stack)?;
|
||||
ecx.copy_op(op, ptr.into())?;
|
||||
let alloc = ecx.memory().get(ptr.to_ptr()?.alloc_id)?;
|
||||
|
30
src/lib.rs
30
src/lib.rs
@ -1,22 +1,17 @@
|
||||
#![feature(
|
||||
rustc_private,
|
||||
macro_at_most_once_rep,
|
||||
never_type,
|
||||
decl_macro,
|
||||
)]
|
||||
#![feature(rustc_private, macro_at_most_once_rep, never_type, decl_macro)]
|
||||
#![allow(intra_doc_link_resolution_failure)]
|
||||
|
||||
extern crate syntax;
|
||||
extern crate log;
|
||||
extern crate rustc;
|
||||
extern crate rustc_allocator;
|
||||
extern crate rustc_codegen_ssa;
|
||||
extern crate rustc_codegen_utils;
|
||||
extern crate rustc_data_structures;
|
||||
extern crate rustc_fs_util;
|
||||
extern crate rustc_incremental;
|
||||
extern crate rustc_mir;
|
||||
extern crate rustc_target;
|
||||
extern crate rustc_data_structures;
|
||||
extern crate rustc_fs_util;
|
||||
extern crate log;
|
||||
extern crate syntax;
|
||||
|
||||
use std::any::Any;
|
||||
use std::fs::File;
|
||||
@ -29,10 +24,10 @@ use rustc::session::{
|
||||
CompileIncomplete,
|
||||
};
|
||||
use rustc::ty::query::Providers;
|
||||
use rustc_codegen_ssa::back::linker::LinkerInfo;
|
||||
use rustc_codegen_ssa::CrateInfo;
|
||||
use rustc_codegen_utils::codegen_backend::CodegenBackend;
|
||||
use rustc_codegen_utils::link::out_filename;
|
||||
use rustc_codegen_ssa::CrateInfo;
|
||||
use rustc_codegen_ssa::back::linker::LinkerInfo;
|
||||
|
||||
use cranelift::codegen::settings;
|
||||
use cranelift_faerie::*;
|
||||
@ -83,8 +78,8 @@ mod prelude {
|
||||
};
|
||||
pub use rustc_mir::monomorphize::{collector, MonoItem};
|
||||
|
||||
pub use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleKind};
|
||||
pub use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
|
||||
pub use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleKind};
|
||||
|
||||
pub use cranelift::codegen::ir::{
|
||||
condcodes::IntCC, function::Function, ExternalName, FuncRef, Inst, StackSlot,
|
||||
@ -183,13 +178,14 @@ impl CodegenBackend for CraneliftCodegenBackend {
|
||||
match tcx.sess.opts.optimize {
|
||||
OptLevel::No => {
|
||||
flags_builder.set("opt_level", "fastest").unwrap();
|
||||
},
|
||||
OptLevel::Less | OptLevel::Default => {},
|
||||
}
|
||||
OptLevel::Less | OptLevel::Default => {}
|
||||
OptLevel::Aggressive => {
|
||||
flags_builder.set("opt_level", "best").unwrap();
|
||||
},
|
||||
}
|
||||
OptLevel::Size | OptLevel::SizeMin => {
|
||||
tcx.sess.warn("Optimizing for size is not supported. Just ignoring the request");
|
||||
tcx.sess
|
||||
.warn("Optimizing for size is not supported. Just ignoring the request");
|
||||
}
|
||||
}
|
||||
|
||||
|
16
src/link.rs
16
src/link.rs
@ -9,8 +9,8 @@ use rustc::session::config::{self, CrateType, DebugInfo, RUST_CGU_EXT};
|
||||
use rustc::session::search_paths::PathKind;
|
||||
use rustc::session::Session;
|
||||
use rustc_codegen_ssa::back::command::Command;
|
||||
use rustc_codegen_ssa::back::linker::*;
|
||||
use rustc_codegen_ssa::back::link::*;
|
||||
use rustc_codegen_ssa::back::linker::*;
|
||||
use rustc_fs_util::fix_windows_verbatim_for_gcc;
|
||||
use rustc_target::spec::{LinkerFlavor, PanicStrategy, RelroLevel};
|
||||
|
||||
@ -27,11 +27,15 @@ pub(crate) fn link_rlib(sess: &Session, res: &CodegenResults, output_name: PathB
|
||||
if let Some(ref object_path) = module.object {
|
||||
let object = File::open(object_path).expect("Someone deleted our object file");
|
||||
let object_len = object.metadata().unwrap().len();
|
||||
builder.append(
|
||||
&ar::Header::new((module.name.to_string() + RUST_CGU_EXT).into_bytes(), object_len),
|
||||
object,
|
||||
)
|
||||
.unwrap();
|
||||
builder
|
||||
.append(
|
||||
&ar::Header::new(
|
||||
(module.name.to_string() + RUST_CGU_EXT).into_bytes(),
|
||||
object_len,
|
||||
),
|
||||
object,
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
use cranelift::prelude::*;
|
||||
|
||||
use cranelift::codegen::ir::TrapCode;
|
||||
|
||||
/// Trap code: user0
|
||||
|
@ -21,16 +21,20 @@ pub macro unimpl($($tt:tt)*) {
|
||||
}
|
||||
|
||||
pub fn try_unimpl(tcx: TyCtxt, log: &mut Option<File>, f: impl FnOnce()) {
|
||||
let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| {
|
||||
f()
|
||||
}));
|
||||
let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| f()));
|
||||
|
||||
if let Err(err) = res {
|
||||
SPAN_STACK.with(|span_stack| {
|
||||
match err.downcast::<NonFatal>() {
|
||||
Ok(non_fatal) => {
|
||||
if cfg!(debug_assertions) {
|
||||
writeln!(log.as_mut().unwrap(), "{} at {:?}", &non_fatal.0, span_stack.borrow()).unwrap();
|
||||
writeln!(
|
||||
log.as_mut().unwrap(),
|
||||
"{} at {:?}",
|
||||
&non_fatal.0,
|
||||
span_stack.borrow()
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
tcx.sess.err(&non_fatal.0)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user