diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 8ed177c82a8..d95000ece5a 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -774,9 +774,8 @@ fn check_stmt(&mut self, cx: &Context, s: &ast::Stmt) { warned |= check_must_use(cx, &it.attrs[], s.span); } } else { - csearch::get_item_attrs(&cx.sess().cstore, did, |attrs| { - warned |= check_must_use(cx, &attrs[], s.span); - }); + let attrs = csearch::get_item_attrs(&cx.sess().cstore, did); + warned |= check_must_use(cx, &attrs[], s.span); } } _ => {} diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index 8650df46cc4..0bbd11bea0a 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -203,13 +203,11 @@ pub fn get_methods_if_impl(cstore: &cstore::CStore, decoder::get_methods_if_impl(cstore.intr.clone(), &*cdata, def.node) } -pub fn get_item_attrs(cstore: &cstore::CStore, - def_id: ast::DefId, - f: F) where - F: FnOnce(Vec), -{ +pub fn get_item_attrs(cstore: &cstore::CStore, + def_id: ast::DefId) + -> Vec { let cdata = cstore.get_crate_data(def_id.krate); - f(decoder::get_item_attrs(&*cdata, def_id.node)); + decoder::get_item_attrs(&*cdata, def_id.node) } pub fn get_struct_fields(cstore: &cstore::CStore, diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index cf30969ebef..2cef5f8353f 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -5556,8 +5556,7 @@ pub fn predicates<'tcx>( } /// Iterate over attributes of a definition. -// (This should really be an iterator, but that would require csearch and -// decoder to use iterators instead of higher-order functions.) +// (This should really be an iterator.) pub fn each_attr(tcx: &ctxt, did: DefId, mut f: F) -> bool where F: FnMut(&ast::Attribute) -> bool, { @@ -5566,12 +5565,8 @@ pub fn each_attr(tcx: &ctxt, did: DefId, mut f: F) -> bool where item.attrs.iter().all(|attr| f(attr)) } else { info!("getting foreign attrs"); - let mut cont = true; - csearch::get_item_attrs(&tcx.sess.cstore, did, |attrs| { - if cont { - cont = attrs.iter().all(|attr| f(attr)); - } - }); + let attrs = csearch::get_item_attrs(&tcx.sess.cstore, did); + let cont = attrs.iter().all(|attr| f(attr)); info!("done"); cont } diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index ea98d6bb74e..fe7c0d4cf69 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -248,9 +248,8 @@ fn get_extern_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_ty: Ty<'tcx>, let f = decl_rust_fn(ccx, fn_ty, name); - csearch::get_item_attrs(&ccx.sess().cstore, did, |attrs| { - set_llvm_fn_attrs(ccx, &attrs[], f) - }); + let attrs = csearch::get_item_attrs(&ccx.sess().cstore, did); + set_llvm_fn_attrs(ccx, &attrs[], f); ccx.externs().borrow_mut().insert(name.to_string(), f); f diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 3e2474468ad..ccaefadc1fc 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -126,13 +126,8 @@ fn try_inline_def(cx: &DocContext, tcx: &ty::ctxt, pub fn load_attrs(cx: &DocContext, tcx: &ty::ctxt, did: ast::DefId) -> Vec { - let mut attrs = Vec::new(); - csearch::get_item_attrs(&tcx.sess.cstore, did, |v| { - attrs.extend(v.into_iter().map(|a| { - a.clean(cx) - })); - }); - attrs + let attrs = csearch::get_item_attrs(&tcx.sess.cstore, did); + attrs.into_iter().map(|a| a.clean(cx)).collect() } /// Record an external fully qualified name in the external_paths cache.