Rollup merge of #31842 - dileepbapat:master, r=alexcrichton

I have made changes and built it after that. Please advise,

https://github.com/rust-lang/rust/issues/31820
This commit is contained in:
Manish Goregaokar
2016-02-25 04:21:10 +05:30
9 changed files with 28 additions and 42 deletions

View File

@@ -331,9 +331,8 @@ impl Matches {
/// Returns the string argument supplied to one of several matching options or `None`. /// Returns the string argument supplied to one of several matching options or `None`.
pub fn opts_str(&self, names: &[String]) -> Option<String> { pub fn opts_str(&self, names: &[String]) -> Option<String> {
for nm in names { for nm in names {
match self.opt_val(&nm[..]) { if let Some(Val(ref s)) = self.opt_val(&nm[..]) {
Some(Val(ref s)) => return Some(s.clone()), return Some(s.clone())
_ => (),
} }
} }
None None

View File

@@ -226,9 +226,8 @@ fn symbol_hash<'tcx>(tcx: &ty::ctxt<'tcx>,
} }
fn get_symbol_hash<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> String { fn get_symbol_hash<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> String {
match ccx.type_hashcodes().borrow().get(&t) { if let Some(h) = ccx.type_hashcodes().borrow().get(&t) {
Some(h) => return h.to_string(), return h.to_string()
None => {}
} }
let mut symbol_hasher = ccx.symbol_hasher().borrow_mut(); let mut symbol_hasher = ccx.symbol_hasher().borrow_mut();
@@ -315,9 +314,8 @@ pub fn mangle<PI: Iterator<Item=InternedString>>(path: PI, hash: Option<&str>) -
push(&mut n, &data); push(&mut n, &data);
} }
match hash { if let Some(s) = hash {
Some(s) => push(&mut n, s), push(&mut n, s)
None => {}
} }
n.push('E'); // End name-sequence. n.push('E'); // End name-sequence.

View File

@@ -150,9 +150,8 @@ impl Drop for _InsnCtxt {
pub fn push_ctxt(s: &'static str) -> _InsnCtxt { pub fn push_ctxt(s: &'static str) -> _InsnCtxt {
debug!("new InsnCtxt: {}", s); debug!("new InsnCtxt: {}", s);
TASK_LOCAL_INSN_KEY.with(|slot| { TASK_LOCAL_INSN_KEY.with(|slot| {
match slot.borrow_mut().as_mut() { if let Some(ctx) = slot.borrow_mut().as_mut() {
Some(ctx) => ctx.push(s), ctx.push(s)
None => {}
} }
}); });
_InsnCtxt { _InsnCtxt {
@@ -198,9 +197,8 @@ fn get_extern_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
name: &str, name: &str,
did: DefId) did: DefId)
-> ValueRef { -> ValueRef {
match ccx.externs().borrow().get(name) { if let Some(n) = ccx.externs().borrow().get(name) {
Some(n) => return *n, return *n;
None => (),
} }
let f = declare::declare_rust_fn(ccx, name, fn_ty); let f = declare::declare_rust_fn(ccx, name, fn_ty);
@@ -238,9 +236,8 @@ pub fn get_extern_const<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
-> ValueRef { -> ValueRef {
let name = ccx.sess().cstore.item_symbol(did); let name = ccx.sess().cstore.item_symbol(did);
let ty = type_of(ccx, t); let ty = type_of(ccx, t);
match ccx.externs().borrow_mut().get(&name) { if let Some(n) = ccx.externs().borrow_mut().get(&name) {
Some(n) => return *n, return *n;
None => (),
} }
// FIXME(nagisa): perhaps the map of externs could be offloaded to llvm somehow? // FIXME(nagisa): perhaps the map of externs could be offloaded to llvm somehow?
// FIXME(nagisa): investigate whether it can be changed into define_global // FIXME(nagisa): investigate whether it can be changed into define_global
@@ -2755,9 +2752,8 @@ fn contains_null(s: &str) -> bool {
pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef { pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
debug!("get_item_val(id=`{}`)", id); debug!("get_item_val(id=`{}`)", id);
match ccx.item_vals().borrow().get(&id).cloned() { if let Some(v) = ccx.item_vals().borrow().get(&id).cloned() {
Some(v) => return v, return v;
None => {}
} }
let item = ccx.tcx().map.get(id); let item = ccx.tcx().map.get(id);

View File

@@ -947,9 +947,8 @@ pub fn C_u8(ccx: &CrateContext, i: u8) -> ValueRef {
// our boxed-and-length-annotated strings. // our boxed-and-length-annotated strings.
pub fn C_cstr(cx: &CrateContext, s: InternedString, null_terminated: bool) -> ValueRef { pub fn C_cstr(cx: &CrateContext, s: InternedString, null_terminated: bool) -> ValueRef {
unsafe { unsafe {
match cx.const_cstr_cache().borrow().get(&s) { if let Some(&llval) = cx.const_cstr_cache().borrow().get(&s) {
Some(&llval) => return llval, return llval;
None => ()
} }
let sc = llvm::LLVMConstStringInContext(cx.llcx(), let sc = llvm::LLVMConstStringInContext(cx.llcx(),

View File

@@ -182,9 +182,8 @@ pub fn type_of_fn_from_ty<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, fty: Ty<'tcx>)
// recursive types. For example, enum types rely on this behavior. // recursive types. For example, enum types rely on this behavior.
pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Type { pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Type {
match cx.llsizingtypes().borrow().get(&t).cloned() { if let Some(t) = cx.llsizingtypes().borrow().get(&t).cloned() {
Some(t) => return t, return t;
None => ()
} }
debug!("sizing_type_of {:?}", t); debug!("sizing_type_of {:?}", t);
@@ -317,9 +316,8 @@ pub fn type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -> Type {
/// NB: If you update this, be sure to update `sizing_type_of()` as well. /// NB: If you update this, be sure to update `sizing_type_of()` as well.
pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Type { pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Type {
// Check the cache. // Check the cache.
match cx.lltypes().borrow().get(&t) { if let Some(&llty) = cx.lltypes().borrow().get(&t) {
Some(&llty) => return llty, return llty;
None => ()
} }
debug!("type_of {:?}", t); debug!("type_of {:?}", t);

View File

@@ -385,9 +385,8 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche
*s.borrow_mut() = analysis.take(); *s.borrow_mut() = analysis.take();
}); });
match matches.opt_str("crate-name") { if let Some(name) = matches.opt_str("crate-name") {
Some(name) => krate.name = name, krate.name = name
None => {}
} }
// Process all of the crate attributes, extracting plugin metadata along // Process all of the crate attributes, extracting plugin metadata along

View File

@@ -467,9 +467,8 @@ impl ToSocketAddrs for str {
type Iter = vec::IntoIter<SocketAddr>; type Iter = vec::IntoIter<SocketAddr>;
fn to_socket_addrs(&self) -> io::Result<vec::IntoIter<SocketAddr>> { fn to_socket_addrs(&self) -> io::Result<vec::IntoIter<SocketAddr>> {
// try to parse as a regular SocketAddr first // try to parse as a regular SocketAddr first
match self.parse().ok() { if let Some(addr) = self.parse().ok() {
Some(addr) => return Ok(vec![addr].into_iter()), return Ok(vec![addr].into_iter());
None => {}
} }
macro_rules! try_opt { macro_rules! try_opt {

View File

@@ -66,9 +66,8 @@ impl<'a> Parser<'a> {
fn read_or<T>(&mut self, parsers: &mut [Box<FnMut(&mut Parser) -> Option<T> + 'static>]) fn read_or<T>(&mut self, parsers: &mut [Box<FnMut(&mut Parser) -> Option<T> + 'static>])
-> Option<T> { -> Option<T> {
for pf in parsers { for pf in parsers {
match self.read_atomically(|p: &mut Parser| pf(p)) { if let Some(r) = self.read_atomically(|p: &mut Parser| pf(p)) {
Some(r) => return Some(r), return Some(r);
None => {}
} }
} }
None None

View File

@@ -69,9 +69,8 @@ static mut DTORS: *mut Vec<(Key, Dtor)> = ptr::null_mut();
pub unsafe fn create(dtor: Option<Dtor>) -> Key { pub unsafe fn create(dtor: Option<Dtor>) -> Key {
let key = c::TlsAlloc(); let key = c::TlsAlloc();
assert!(key != c::TLS_OUT_OF_INDEXES); assert!(key != c::TLS_OUT_OF_INDEXES);
match dtor { if let Some(f) = dtor {
Some(f) => register_dtor(key, f), register_dtor(key, f);
None => {}
} }
return key; return key;
} }