Skip to content

Commit

Permalink
Auto merge of #37104 - luqmana:fixmes, r=eddyb
Browse files Browse the repository at this point in the history
Clean up some FIXMEs.

Remove some assorted FIXMEs in the codebase.
  • Loading branch information
bors authored Nov 11, 2016
2 parents 1473007 + c2f1e5d commit de46bea
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 41 deletions.
1 change: 0 additions & 1 deletion src/librustc/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ pub enum TypeOrigin {
MethodCompatCheck(Span),

// Checking that this expression can be assigned where it needs to be
// FIXME(eddyb) #11161 is the original Expr required?
ExprAssignable(Span),

// Relating trait type parameters to those found in impl etc
Expand Down
4 changes: 1 addition & 3 deletions src/librustc/middle/mem_categorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -945,9 +945,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
let ref_ty = self.overloaded_method_return_ty(method_ty);
base_cmt = self.cat_rvalue_node(elt.id(), elt.span(), ref_ty);

// FIXME(#20649) -- why are we using the `self_ty` as the element type...?
let self_ty = method_ty.fn_sig().input(0);
(self.tcx().no_late_bound_regions(&self_ty).unwrap(),
(ref_ty.builtin_deref(false, ty::NoPreference).unwrap().ty,
ElementKind::OtherElement)
}
None => {
Expand Down
2 changes: 0 additions & 2 deletions src/librustc_trans/adt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,6 @@ fn generic_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
// So we start with the discriminant, pad it up to the alignment with
// more of its own type, then use alignment-sized ints to get the rest
// of the size.
//
// FIXME #10604: this breaks when vector types are present.
let size = size.bytes();
let align = align.abi();
let discr_ty = Type::from_integer(cx, discr);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ pub fn C_cstr(cx: &CrateContext, s: InternedString, null_terminated: bool) -> Va
pub fn C_str_slice(cx: &CrateContext, s: InternedString) -> ValueRef {
let len = s.len();
let cs = consts::ptrcast(C_cstr(cx, s, false), Type::i8p(cx));
C_named_struct(cx.tn().find_type("str_slice").unwrap(), &[cs, C_uint(cx, len)])
C_named_struct(cx.str_slice_type(), &[cs, C_uint(cx, len)])
}

pub fn C_struct(cx: &CrateContext, elts: &[ValueRef], packed: bool) -> ValueRef {
Expand Down
16 changes: 8 additions & 8 deletions src/librustc_trans/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use monomorphize::Instance;

use partitioning::CodegenUnit;
use trans_item::TransItem;
use type_::{Type, TypeNames};
use type_::Type;
use rustc::ty::subst::Substs;
use rustc::ty::{self, Ty, TyCtxt};
use session::config::NoDebugInfo;
Expand Down Expand Up @@ -87,7 +87,6 @@ pub struct LocalCrateContext<'tcx> {
llmod: ModuleRef,
llcx: ContextRef,
previous_work_product: Option<WorkProduct>,
tn: TypeNames, // FIXME: This seems to be largely unused.
codegen_unit: CodegenUnit<'tcx>,
needs_unwind_cleanup_cache: RefCell<FxHashMap<Ty<'tcx>, bool>>,
fn_pointer_shims: RefCell<FxHashMap<Ty<'tcx>, ValueRef>>,
Expand Down Expand Up @@ -137,6 +136,7 @@ pub struct LocalCrateContext<'tcx> {
type_hashcodes: RefCell<FxHashMap<Ty<'tcx>, String>>,
int_type: Type,
opaque_vec_type: Type,
str_slice_type: Type,
builder: BuilderRef_res,

/// Holds the LLVM values for closure IDs.
Expand Down Expand Up @@ -611,7 +611,6 @@ impl<'tcx> LocalCrateContext<'tcx> {
llcx: llcx,
previous_work_product: previous_work_product,
codegen_unit: codegen_unit,
tn: TypeNames::new(),
needs_unwind_cleanup_cache: RefCell::new(FxHashMap()),
fn_pointer_shims: RefCell::new(FxHashMap()),
drop_glues: RefCell::new(FxHashMap()),
Expand All @@ -631,6 +630,7 @@ impl<'tcx> LocalCrateContext<'tcx> {
type_hashcodes: RefCell::new(FxHashMap()),
int_type: Type::from_ref(ptr::null_mut()),
opaque_vec_type: Type::from_ref(ptr::null_mut()),
str_slice_type: Type::from_ref(ptr::null_mut()),
builder: BuilderRef_res(llvm::LLVMCreateBuilderInContext(llcx)),
closure_vals: RefCell::new(FxHashMap()),
dbg_cx: dbg_cx,
Expand Down Expand Up @@ -662,7 +662,7 @@ impl<'tcx> LocalCrateContext<'tcx> {

local_ccx.int_type = int_type;
local_ccx.opaque_vec_type = opaque_vec_type;
local_ccx.tn.associate_type("str_slice", &str_slice_ty);
local_ccx.str_slice_type = str_slice_ty;

if shared.tcx.sess.count_llvm_insns() {
base::init_insn_ctxt()
Expand Down Expand Up @@ -778,10 +778,6 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> {
unsafe { llvm::LLVMRustGetModuleDataLayout(self.llmod()) }
}

pub fn tn<'a>(&'a self) -> &'a TypeNames {
&self.local().tn
}

pub fn export_map<'a>(&'a self) -> &'a ExportMap {
&self.shared.export_map
}
Expand Down Expand Up @@ -885,6 +881,10 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> {
self.local().opaque_vec_type
}

pub fn str_slice_type(&self) -> Type {
self.local().str_slice_type
}

pub fn closure_vals<'a>(&'a self) -> &'a RefCell<FxHashMap<Instance<'tcx>, ValueRef>> {
&self.local().closure_vals
}
Expand Down
25 changes: 0 additions & 25 deletions src/librustc_trans/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use llvm::{TypeRef, Bool, False, True, TypeKind};
use llvm::{Float, Double, X86_FP80, PPC_FP128, FP128};

use context::CrateContext;
use util::nodemap::FxHashMap;

use syntax::ast;
use rustc::ty::layout;
Expand All @@ -24,7 +23,6 @@ use std::ffi::CString;
use std::fmt;
use std::mem;
use std::ptr;
use std::cell::RefCell;

use libc::c_uint;

Expand Down Expand Up @@ -321,26 +319,3 @@ impl Type {
}
}
}

/* Memory-managed object interface to type handles. */

pub struct TypeNames {
named_types: RefCell<FxHashMap<String, TypeRef>>,
}

impl TypeNames {
pub fn new() -> TypeNames {
TypeNames {
named_types: RefCell::new(FxHashMap())
}
}

pub fn associate_type(&self, s: &str, t: &Type) {
assert!(self.named_types.borrow_mut().insert(s.to_string(),
t.to_ref()).is_none());
}

pub fn find_type(&self, s: &str) -> Option<Type> {
self.named_types.borrow().get(s).map(|x| Type::from_ref(*x))
}
}
2 changes: 1 addition & 1 deletion src/librustc_trans/type_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
if let ty::TyStr = ty.sty {
// This means we get a nicer name in the output (str is always
// unsized).
cx.tn().find_type("str_slice").unwrap()
cx.str_slice_type()
} else {
let ptr_ty = in_memory_type_of(cx, ty).ptr_to();
let info_ty = unsized_info_ty(cx, ty);
Expand Down

0 comments on commit de46bea

Please sign in to comment.