Rollup merge of #62039 - jeremystucki:needless_lifetimes, r=eddyb

Remove needless lifetimes (rustc)
This commit is contained in:
Mazdak Farrokhzad 2019-07-04 01:38:41 +02:00 committed by GitHub
commit e8a88f7d43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
128 changed files with 440 additions and 440 deletions

View File

@ -74,7 +74,7 @@ impl<T: LambdaL> ScopedCell<T> {
}
/// Sets the value in `self` to `value` while running `f`.
pub fn set<'a, R>(&self, value: <T as ApplyL<'a>>::Out, f: impl FnOnce() -> R) -> R {
pub fn set<R>(&self, value: <T as ApplyL<'_>>::Out, f: impl FnOnce() -> R) -> R {
self.replace(value, |_| f())
}
}

View File

@ -30,7 +30,7 @@ struct LoopScope {
break_index: CFGIndex, // where to go on a `break`
}
pub fn construct<'tcx>(tcx: TyCtxt<'tcx>, body: &hir::Body) -> CFG {
pub fn construct(tcx: TyCtxt<'_>, body: &hir::Body) -> CFG {
let mut graph = graph::Graph::new();
let entry = graph.add_node(CFGNodeData::Entry);

View File

@ -49,7 +49,7 @@ pub type CFGNode = graph::Node<CFGNodeData>;
pub type CFGEdge = graph::Edge<CFGEdgeData>;
impl CFG {
pub fn new<'tcx>(tcx: TyCtxt<'tcx>, body: &hir::Body) -> CFG {
pub fn new(tcx: TyCtxt<'_>, body: &hir::Body) -> CFG {
construct::construct(tcx, body)
}

View File

@ -841,7 +841,7 @@ impl DepGraph {
//
// This method will only load queries that will end up in the disk cache.
// Other queries will not be executed.
pub fn exec_cache_promotions<'tcx>(&self, tcx: TyCtxt<'tcx>) {
pub fn exec_cache_promotions(&self, tcx: TyCtxt<'_>) {
let data = self.data.as_ref().unwrap();
for prev_index in data.colors.values.indices() {
match data.colors.get(prev_index) {

View File

@ -347,7 +347,7 @@ fn is_c_like_enum(item: &hir::Item) -> bool {
}
}
fn check_mod_attrs<'tcx>(tcx: TyCtxt<'tcx>, module_def_id: DefId) {
fn check_mod_attrs(tcx: TyCtxt<'_>, module_def_id: DefId) {
tcx.hir().visit_item_likes_in_module(
module_def_id,
&mut CheckAttrVisitor { tcx }.as_deep_visitor()

View File

@ -4,7 +4,7 @@ use crate::hir::itemlikevisit::ItemLikeVisitor;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::sync::{Lock, ParallelIterator, par_iter};
pub fn check_crate<'hir>(hir_map: &hir::map::Map<'hir>) {
pub fn check_crate(hir_map: &hir::map::Map<'_>) {
hir_map.dep_graph.assert_ignored();
let errors = Lock::new(Vec::new());

View File

@ -147,7 +147,7 @@ impl Forest {
}
}
pub fn krate<'hir>(&'hir self) -> &'hir Crate {
pub fn krate(&self) -> &Crate {
self.dep_graph.read(DepNode::new_no_params(DepKind::Krate));
&self.krate
}
@ -155,7 +155,7 @@ impl Forest {
/// This is used internally in the dependency tracking system.
/// Use the `krate` method to ensure your dependency on the
/// crate is tracked.
pub fn untracked_krate<'hir>(&'hir self) -> &'hir Crate {
pub fn untracked_krate(&self) -> &Crate {
&self.krate
}
}
@ -1085,7 +1085,7 @@ impl<'a> NodesMatchingSuffix<'a> {
// If `id` itself is a mod named `m` with parent `p`, then
// returns `Some(id, m, p)`. If `id` has no mod in its parent
// chain, then returns `None`.
fn find_first_mod_parent<'a>(map: &'a Map<'_>, mut id: HirId) -> Option<(HirId, Name)> {
fn find_first_mod_parent(map: &Map<'_>, mut id: HirId) -> Option<(HirId, Name)> {
loop {
if let Node::Item(item) = map.find(id)? {
if item_is_mod(&item) {

View File

@ -115,7 +115,7 @@ impl<'tcx> TypeVariableTable<'tcx> {
///
/// Note that this function does not return care whether
/// `vid` has been unified with something else or not.
pub fn var_diverges<'a>(&'a self, vid: ty::TyVid) -> bool {
pub fn var_diverges(&self, vid: ty::TyVid) -> bool {
self.values.get(vid.index as usize).diverging
}

View File

@ -765,7 +765,7 @@ pub fn maybe_lint_level_root(tcx: TyCtxt<'_>, id: hir::HirId) -> bool {
attrs.iter().any(|attr| Level::from_symbol(attr.name_or_empty()).is_some())
}
fn lint_levels<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> &'tcx LintLevelMap {
fn lint_levels(tcx: TyCtxt<'_>, cnum: CrateNum) -> &LintLevelMap {
assert_eq!(cnum, LOCAL_CRATE);
let mut builder = LintLevelMapBuilder {
levels: LintLevelSets::builder(tcx.sess),

View File

@ -211,7 +211,7 @@ pub trait CrateStore {
fn crates_untracked(&self) -> Vec<CrateNum>;
// utility functions
fn encode_metadata<'tcx>(&self, tcx: TyCtxt<'tcx>) -> EncodedMetadata;
fn encode_metadata(&self, tcx: TyCtxt<'_>) -> EncodedMetadata;
fn metadata_encoding_version(&self) -> &[u8];
}

View File

@ -26,7 +26,7 @@ use syntax_pos;
// explored. For example, if it's a live Node::Item that is a
// function, then we should explore its block to check for codes that
// may need to be marked as live.
fn should_explore<'tcx>(tcx: TyCtxt<'tcx>, hir_id: hir::HirId) -> bool {
fn should_explore(tcx: TyCtxt<'_>, hir_id: hir::HirId) -> bool {
match tcx.hir().find(hir_id) {
Some(Node::Item(..)) |
Some(Node::ImplItem(..)) |
@ -662,7 +662,7 @@ impl Visitor<'tcx> for DeadVisitor<'tcx> {
}
}
pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx>) {
pub fn check_crate(tcx: TyCtxt<'_>) {
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
let krate = tcx.hir().krate();
let live_symbols = find_live(tcx, access_levels, krate);

View File

@ -81,7 +81,7 @@ pub enum Linkage {
Dynamic,
}
pub fn calculate<'tcx>(tcx: TyCtxt<'tcx>) {
pub fn calculate(tcx: TyCtxt<'_>) {
let sess = &tcx.sess;
let fmts = sess.crate_types.borrow().iter().map(|&ty| {
let linkage = calculate_type(tcx, ty);
@ -92,7 +92,7 @@ pub fn calculate<'tcx>(tcx: TyCtxt<'tcx>) {
sess.dependency_formats.set(fmts);
}
fn calculate_type<'tcx>(tcx: TyCtxt<'tcx>, ty: config::CrateType) -> DependencyList {
fn calculate_type(tcx: TyCtxt<'_>, ty: config::CrateType) -> DependencyList {
let sess = &tcx.sess;
if !sess.opts.output_types.should_codegen() {
@ -267,7 +267,7 @@ fn add_library(
}
}
fn attempt_static<'tcx>(tcx: TyCtxt<'tcx>) -> Option<DependencyList> {
fn attempt_static(tcx: TyCtxt<'_>) -> Option<DependencyList> {
let sess = &tcx.sess;
let crates = cstore::used_crates(tcx, RequireStatic);
if !crates.iter().by_ref().all(|&(_, ref p)| p.is_some()) {
@ -324,7 +324,7 @@ fn activate_injected_dep(injected: Option<CrateNum>,
// After the linkage for a crate has been determined we need to verify that
// there's only going to be one allocator in the output.
fn verify_ok<'tcx>(tcx: TyCtxt<'tcx>, list: &[Linkage]) {
fn verify_ok(tcx: TyCtxt<'_>, list: &[Linkage]) {
let sess = &tcx.sess;
if list.len() == 0 {
return

View File

@ -10,7 +10,7 @@ use syntax_pos::{Span, sym};
use crate::hir::intravisit::{self, Visitor, NestedVisitorMap};
use crate::hir;
fn check_mod_intrinsics<'tcx>(tcx: TyCtxt<'tcx>, module_def_id: DefId) {
fn check_mod_intrinsics(tcx: TyCtxt<'_>, module_def_id: DefId) {
tcx.hir().visit_item_likes_in_module(
module_def_id,
&mut ItemVisitor { tcx }.as_deep_visitor()

View File

@ -142,7 +142,7 @@ impl Visitor<'tcx> for LibFeatureCollector<'tcx> {
}
}
pub fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> LibFeatures {
pub fn collect(tcx: TyCtxt<'_>) -> LibFeatures {
let mut collector = LibFeatureCollector::new(tcx);
intravisit::walk_crate(&mut collector, tcx.hir().krate());
collector.lib_features

View File

@ -181,7 +181,7 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> {
fn visit_arm(&mut self, a: &'tcx hir::Arm) { visit_arm(self, a); }
}
fn check_mod_liveness<'tcx>(tcx: TyCtxt<'tcx>, module_def_id: DefId) {
fn check_mod_liveness(tcx: TyCtxt<'_>, module_def_id: DefId) {
tcx.hir().visit_item_likes_in_module(
module_def_id,
&mut IrMaps::new(tcx, module_def_id).as_deep_visitor(),

View File

@ -42,8 +42,8 @@ fn item_might_be_inlined(tcx: TyCtxt<'tcx>, item: &hir::Item, attrs: CodegenFnAt
}
}
fn method_might_be_inlined<'tcx>(
tcx: TyCtxt<'tcx>,
fn method_might_be_inlined(
tcx: TyCtxt<'_>,
impl_item: &hir::ImplItem,
impl_src: DefId,
) -> bool {
@ -391,7 +391,7 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, 'tcx
#[derive(Clone, HashStable)]
pub struct ReachableSet(pub Lrc<HirIdSet>);
fn reachable_set<'tcx>(tcx: TyCtxt<'tcx>, crate_num: CrateNum) -> ReachableSet {
fn reachable_set(tcx: TyCtxt<'_>, crate_num: CrateNum) -> ReachableSet {
debug_assert!(crate_num == LOCAL_CRATE);
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);

View File

@ -1446,7 +1446,7 @@ impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> {
}
}
fn region_scope_tree<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx ScopeTree {
fn region_scope_tree(tcx: TyCtxt<'_>, def_id: DefId) -> &ScopeTree {
let closure_base_def_id = tcx.closure_base_def_id(def_id);
if closure_base_def_id != def_id {
return tcx.region_scope_tree(closure_base_def_id);

View File

@ -368,7 +368,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
/// entire crate. You should not read the result of this query
/// directly, but rather use `named_region_map`, `is_late_bound_map`,
/// etc.
fn resolve_lifetimes<'tcx>(tcx: TyCtxt<'tcx>, for_krate: CrateNum) -> &'tcx ResolveLifetimes {
fn resolve_lifetimes(tcx: TyCtxt<'_>, for_krate: CrateNum) -> &ResolveLifetimes {
assert_eq!(for_krate, LOCAL_CRATE);
let named_region_map = krate(tcx);
@ -395,7 +395,7 @@ fn resolve_lifetimes<'tcx>(tcx: TyCtxt<'tcx>, for_krate: CrateNum) -> &'tcx Reso
tcx.arena.alloc(rl)
}
fn krate<'tcx>(tcx: TyCtxt<'tcx>) -> NamedRegionMap {
fn krate(tcx: TyCtxt<'_>) -> NamedRegionMap {
let krate = tcx.hir().krate();
let mut map = NamedRegionMap {
defs: Default::default(),

View File

@ -466,7 +466,7 @@ impl<'tcx> Index<'tcx> {
/// Cross-references the feature names of unstable APIs with enabled
/// features and possibly prints errors.
fn check_mod_unstable_api_usage<'tcx>(tcx: TyCtxt<'tcx>, module_def_id: DefId) {
fn check_mod_unstable_api_usage(tcx: TyCtxt<'_>, module_def_id: DefId) {
tcx.hir().visit_item_likes_in_module(module_def_id, &mut Checker { tcx }.as_deep_visitor());
}
@ -836,7 +836,7 @@ impl<'tcx> TyCtxt<'tcx> {
/// Given the list of enabled features that were not language features (i.e., that
/// were expected to be library features), and the list of features used from
/// libraries, identify activated features that don't exist and error about them.
pub fn check_unused_or_stable_features<'tcx>(tcx: TyCtxt<'tcx>) {
pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
if tcx.stability().staged_api[&LOCAL_CRATE] {
@ -920,8 +920,8 @@ pub fn check_unused_or_stable_features<'tcx>(tcx: TyCtxt<'tcx>) {
// don't lint about unused features. We should reenable this one day!
}
fn unnecessary_stable_feature_lint<'tcx>(
tcx: TyCtxt<'tcx>,
fn unnecessary_stable_feature_lint(
tcx: TyCtxt<'_>,
span: Span,
feature: Symbol,
since: Symbol,

View File

@ -2867,19 +2867,19 @@ impl<'tcx> graph::WithStartNode for Body<'tcx> {
}
impl<'tcx> graph::WithPredecessors for Body<'tcx> {
fn predecessors<'graph>(
&'graph self,
fn predecessors(
&self,
node: Self::Node,
) -> <Self as GraphPredecessors<'graph>>::Iter {
) -> <Self as GraphPredecessors<'_>>::Iter {
self.predecessors_for(node).clone().into_iter()
}
}
impl<'tcx> graph::WithSuccessors for Body<'tcx> {
fn successors<'graph>(
&'graph self,
fn successors(
&self,
node: Self::Node,
) -> <Self as GraphSuccessors<'graph>>::Iter {
) -> <Self as GraphSuccessors<'_>>::Iter {
self.basic_blocks[node].terminator().successors().cloned()
}
}

View File

@ -269,11 +269,11 @@ impl OutputTypes {
self.0.contains_key(key)
}
pub fn keys<'a>(&'a self) -> BTreeMapKeysIter<'a, OutputType, Option<PathBuf>> {
pub fn keys(&self) -> BTreeMapKeysIter<'_, OutputType, Option<PathBuf>> {
self.0.keys()
}
pub fn values<'a>(&'a self) -> BTreeMapValuesIter<'a, OutputType, Option<PathBuf>> {
pub fn values(&self) -> BTreeMapValuesIter<'_, OutputType, Option<PathBuf>> {
self.0.values()
}
@ -316,7 +316,7 @@ impl Externs {
self.0.get(key)
}
pub fn iter<'a>(&'a self) -> BTreeMapIter<'a, String, ExternEntry> {
pub fn iter(&self) -> BTreeMapIter<'_, String, ExternEntry> {
self.0.iter()
}
}

View File

@ -215,66 +215,66 @@ impl Session {
*self.crate_disambiguator.get()
}
pub fn struct_span_warn<'a, S: Into<MultiSpan>>(
&'a self,
pub fn struct_span_warn<S: Into<MultiSpan>>(
&self,
sp: S,
msg: &str,
) -> DiagnosticBuilder<'a> {
) -> DiagnosticBuilder<'_> {
self.diagnostic().struct_span_warn(sp, msg)
}
pub fn struct_span_warn_with_code<'a, S: Into<MultiSpan>>(
&'a self,
pub fn struct_span_warn_with_code<S: Into<MultiSpan>>(
&self,
sp: S,
msg: &str,
code: DiagnosticId,
) -> DiagnosticBuilder<'a> {
) -> DiagnosticBuilder<'_> {
self.diagnostic().struct_span_warn_with_code(sp, msg, code)
}
pub fn struct_warn<'a>(&'a self, msg: &str) -> DiagnosticBuilder<'a> {
pub fn struct_warn(&self, msg: &str) -> DiagnosticBuilder<'_> {
self.diagnostic().struct_warn(msg)
}
pub fn struct_span_err<'a, S: Into<MultiSpan>>(
&'a self,
pub fn struct_span_err<S: Into<MultiSpan>>(
&self,
sp: S,
msg: &str,
) -> DiagnosticBuilder<'a> {
) -> DiagnosticBuilder<'_> {
self.diagnostic().struct_span_err(sp, msg)
}
pub fn struct_span_err_with_code<'a, S: Into<MultiSpan>>(
&'a self,
pub fn struct_span_err_with_code<S: Into<MultiSpan>>(
&self,
sp: S,
msg: &str,
code: DiagnosticId,
) -> DiagnosticBuilder<'a> {
) -> DiagnosticBuilder<'_> {
self.diagnostic().struct_span_err_with_code(sp, msg, code)
}
// FIXME: This method should be removed (every error should have an associated error code).
pub fn struct_err<'a>(&'a self, msg: &str) -> DiagnosticBuilder<'a> {
pub fn struct_err(&self, msg: &str) -> DiagnosticBuilder<'_> {
self.diagnostic().struct_err(msg)
}
pub fn struct_err_with_code<'a>(
&'a self,
pub fn struct_err_with_code(
&self,
msg: &str,
code: DiagnosticId,
) -> DiagnosticBuilder<'a> {
) -> DiagnosticBuilder<'_> {
self.diagnostic().struct_err_with_code(msg, code)
}
pub fn struct_span_fatal<'a, S: Into<MultiSpan>>(
&'a self,
pub fn struct_span_fatal<S: Into<MultiSpan>>(
&self,
sp: S,
msg: &str,
) -> DiagnosticBuilder<'a> {
) -> DiagnosticBuilder<'_> {
self.diagnostic().struct_span_fatal(sp, msg)
}
pub fn struct_span_fatal_with_code<'a, S: Into<MultiSpan>>(
&'a self,
pub fn struct_span_fatal_with_code<S: Into<MultiSpan>>(
&self,
sp: S,
msg: &str,
code: DiagnosticId,
) -> DiagnosticBuilder<'a> {
) -> DiagnosticBuilder<'_> {
self.diagnostic().struct_span_fatal_with_code(sp, msg, code)
}
pub fn struct_fatal<'a>(&'a self, msg: &str) -> DiagnosticBuilder<'a> {
pub fn struct_fatal(&self, msg: &str) -> DiagnosticBuilder<'_> {
self.diagnostic().struct_fatal(msg)
}
@ -416,7 +416,7 @@ impl Session {
pub fn next_node_id(&self) -> NodeId {
self.reserve_node_ids(1)
}
pub fn diagnostic<'a>(&'a self) -> &'a errors::Handler {
pub fn diagnostic(&self) -> &errors::Handler {
&self.parse_sess.span_diagnostic
}
@ -504,7 +504,7 @@ impl Session {
);
}
pub fn source_map<'a>(&'a self) -> &'a source_map::SourceMap {
pub fn source_map(&self) -> &source_map::SourceMap {
self.parse_sess.source_map()
}
pub fn verbose(&self) -> bool {

View File

@ -48,8 +48,8 @@ pub fn add_placeholder_note(err: &mut errors::DiagnosticBuilder<'_>) {
/// If there are types that satisfy both impls, invokes `on_overlap`
/// with a suitably-freshened `ImplHeader` with those types
/// substituted. Otherwise, invokes `no_overlap`.
pub fn overlapping_impls<'tcx, F1, F2, R>(
tcx: TyCtxt<'tcx>,
pub fn overlapping_impls<F1, F2, R>(
tcx: TyCtxt<'_>,
impl1_def_id: DefId,
impl2_def_id: DefId,
intercrate_mode: IntercrateMode,
@ -247,10 +247,10 @@ pub enum OrphanCheckErr<'tcx> {
///
/// 1. All type parameters in `Self` must be "covered" by some local type constructor.
/// 2. Some local type must appear in `Self`.
pub fn orphan_check<'tcx>(
tcx: TyCtxt<'tcx>,
pub fn orphan_check(
tcx: TyCtxt<'_>,
impl_def_id: DefId,
) -> Result<(), OrphanCheckErr<'tcx>> {
) -> Result<(), OrphanCheckErr<'_>> {
debug!("orphan_check({:?})", impl_def_id);
// We only except this routine to be invoked on implementations

View File

@ -247,7 +247,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
fn fuzzy_match_tys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
/// returns the fuzzy category of a given type, or None
/// if the type can be equated to any type.
fn type_category<'tcx>(t: Ty<'tcx>) -> Option<u32> {
fn type_category(t: Ty<'_>) -> Option<u32> {
match t.sty {
ty::Bool => Some(0),
ty::Char => Some(1),

View File

@ -702,6 +702,6 @@ impl<'tcx> TyCtxt<'tcx> {
}
}
pub(super) fn is_object_safe_provider<'tcx>(tcx: TyCtxt<'tcx>, trait_def_id: DefId) -> bool {
pub(super) fn is_object_safe_provider(tcx: TyCtxt<'_>, trait_def_id: DefId) -> bool {
tcx.object_safety_violations(trait_def_id).is_empty()
}

View File

@ -1509,8 +1509,8 @@ fn confirm_impl_candidate<'cx, 'tcx>(
///
/// Based on the "projection mode", this lookup may in fact only examine the
/// topmost impl. See the comments for `Reveal` for more details.
fn assoc_ty_def<'cx, 'tcx>(
selcx: &SelectionContext<'cx, 'tcx>,
fn assoc_ty_def(
selcx: &SelectionContext<'_, '_>,
impl_def_id: DefId,
assoc_ty_def_id: DefId,
) -> specialization_graph::NodeItem<ty::AssocItem> {

View File

@ -145,8 +145,8 @@ pub fn find_associated_item<'tcx>(
/// Specialization is determined by the sets of types to which the impls apply;
/// `impl1` specializes `impl2` if it applies to a subset of the types `impl2` applies
/// to.
pub(super) fn specializes<'tcx>(
tcx: TyCtxt<'tcx>,
pub(super) fn specializes(
tcx: TyCtxt<'_>,
(impl1_def_id, impl2_def_id): (DefId, DefId),
) -> bool {
debug!("specializes({:?}, {:?})", impl1_def_id, impl2_def_id);
@ -282,10 +282,10 @@ fn fulfill_implication<'a, 'tcx>(
}
// Query provider for `specialization_graph_of`.
pub(super) fn specialization_graph_provider<'tcx>(
tcx: TyCtxt<'tcx>,
pub(super) fn specialization_graph_provider(
tcx: TyCtxt<'_>,
trait_id: DefId,
) -> &'tcx specialization_graph::Graph {
) -> &specialization_graph::Graph {
let mut sg = specialization_graph::Graph::new();
let mut trait_impls = tcx.all_impls(trait_id);

View File

@ -417,7 +417,7 @@ pub struct SupertraitDefIds<'tcx> {
visited: FxHashSet<DefId>,
}
pub fn supertrait_def_ids<'tcx>(tcx: TyCtxt<'tcx>, trait_def_id: DefId) -> SupertraitDefIds<'tcx> {
pub fn supertrait_def_ids(tcx: TyCtxt<'_>, trait_def_id: DefId) -> SupertraitDefIds<'_> {
SupertraitDefIds {
tcx,
stack: vec![trait_def_id],

View File

@ -306,9 +306,9 @@ impl<'sess> OnDiskCache<'sess> {
}
/// Loads a diagnostic emitted during the previous compilation session.
pub fn load_diagnostics<'tcx>(
pub fn load_diagnostics(
&self,
tcx: TyCtxt<'tcx>,
tcx: TyCtxt<'_>,
dep_node_index: SerializedDepNodeIndex,
) -> Vec<Diagnostic> {
let diagnostics: Option<EncodedDiagnostics> = self.load_indexed(
@ -335,9 +335,9 @@ impl<'sess> OnDiskCache<'sess> {
/// Returns the cached query result if there is something in the cache for
/// the given `SerializedDepNodeIndex`; otherwise returns `None`.
pub fn try_load_query_result<'tcx, T>(
pub fn try_load_query_result<T>(
&self,
tcx: TyCtxt<'tcx>,
tcx: TyCtxt<'_>,
dep_node_index: SerializedDepNodeIndex,
) -> Option<T>
where

View File

@ -1166,7 +1166,7 @@ macro_rules! define_provider_struct {
/// then `force_from_dep_node()` should not fail for it. Otherwise, you can just
/// add it to the "We don't have enough information to reconstruct..." group in
/// the match below.
pub fn force_from_dep_node<'tcx>(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> bool {
pub fn force_from_dep_node(tcx: TyCtxt<'_>, dep_node: &DepNode) -> bool {
use crate::dep_graph::RecoverKey;
// We must avoid ever having to call force_from_dep_node() for a

View File

@ -354,7 +354,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
cmt: &mc::cmt_<'tcx>,
loan_region: ty::Region<'tcx>,
borrow_span: Span) {
pub fn borrow_of_local_data<'tcx>(cmt: &mc::cmt_<'tcx>) -> bool {
pub fn borrow_of_local_data(cmt: &mc::cmt_<'_>) -> bool {
match cmt.cat {
// Borrows of static items is allowed
Categorization::StaticItem => false,

View File

@ -53,7 +53,7 @@ pub struct LoanDataFlowOperator;
pub type LoanDataFlow<'tcx> = DataFlowContext<'tcx, LoanDataFlowOperator>;
pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx>) {
pub fn check_crate(tcx: TyCtxt<'_>) {
tcx.par_body_owners(|body_owner_def_id| {
tcx.ensure().borrowck(body_owner_def_id);
});
@ -73,7 +73,7 @@ pub struct AnalysisData<'tcx> {
pub move_data: move_data::FlowedMoveData<'tcx>,
}
fn borrowck<'tcx>(tcx: TyCtxt<'tcx>, owner_def_id: DefId) -> &'tcx BorrowCheckResult {
fn borrowck(tcx: TyCtxt<'_>, owner_def_id: DefId) -> &BorrowCheckResult {
assert!(tcx.use_ast_borrowck() || tcx.migrate_borrowck());
debug!("borrowck(body_owner_def_id={:?})", owner_def_id);

View File

@ -84,9 +84,9 @@ struct PropagationContext<'a, 'tcx, O> {
changed: bool,
}
fn get_cfg_indices<'a>(id: hir::ItemLocalId,
index: &'a FxHashMap<hir::ItemLocalId, Vec<CFGIndex>>)
-> &'a [CFGIndex] {
fn get_cfg_indices(id: hir::ItemLocalId,
index: &FxHashMap<hir::ItemLocalId, Vec<CFGIndex>>)
-> &[CFGIndex] {
index.get(&id).map_or(&[], |v| &v[..])
}

View File

@ -239,9 +239,9 @@ impl<'a> Drop for DiagnosticHandlers<'a> {
}
}
unsafe extern "C" fn report_inline_asm<'a, 'b>(cgcx: &'a CodegenContext<LlvmCodegenBackend>,
msg: &'b str,
cookie: c_uint) {
unsafe extern "C" fn report_inline_asm(cgcx: &CodegenContext<LlvmCodegenBackend>,
msg: &str,
cookie: c_uint) {
cgcx.diag_emitter.inline_asm_error(cookie as u32, msg.to_owned());
}

View File

@ -123,8 +123,8 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'tcx>, cgu_name: InternedString) {
submit_codegened_module_to_llvm(&LlvmCodegenBackend(()), tcx, module, cost);
fn module_codegen<'tcx>(
tcx: TyCtxt<'tcx>,
fn module_codegen(
tcx: TyCtxt<'_>,
cgu_name: InternedString,
) -> ModuleCodegen<ModuleLlvm> {
let cgu = tcx.codegen_unit(cgu_name);

View File

@ -144,7 +144,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
}
}
fn build_sibling_block<'b>(&self, name: &'b str) -> Self {
fn build_sibling_block(&self, name: &str) -> Self {
Builder::new_block(self.cx, self.llfn(), name)
}

View File

@ -124,7 +124,7 @@ impl ExtraBackendMethods for LlvmCodegenBackend {
) {
unsafe { allocator::codegen(tcx, mods, kind) }
}
fn compile_codegen_unit<'tcx>(&self, tcx: TyCtxt<'tcx>, cgu_name: InternedString) {
fn compile_codegen_unit(&self, tcx: TyCtxt<'_>, cgu_name: InternedString) {
base::compile_codegen_unit(tcx, cgu_name);
}
fn target_machine_factory(

View File

@ -46,10 +46,10 @@ pub fn crates_export_threshold(crate_types: &[config::CrateType]) -> SymbolExpor
}
}
fn reachable_non_generics_provider<'tcx>(
tcx: TyCtxt<'tcx>,
fn reachable_non_generics_provider(
tcx: TyCtxt<'_>,
cnum: CrateNum,
) -> &'tcx DefIdMap<SymbolExportLevel> {
) -> &DefIdMap<SymbolExportLevel> {
assert_eq!(cnum, LOCAL_CRATE);
if !tcx.sess.opts.output_types.should_codegen() {
@ -157,7 +157,7 @@ fn reachable_non_generics_provider<'tcx>(
tcx.arena.alloc(reachable_non_generics)
}
fn is_reachable_non_generic_provider_local<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool {
fn is_reachable_non_generic_provider_local(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
let export_threshold = threshold(tcx);
if let Some(&level) = tcx.reachable_non_generics(def_id.krate).get(&def_id) {
@ -167,14 +167,14 @@ fn is_reachable_non_generic_provider_local<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefI
}
}
fn is_reachable_non_generic_provider_extern<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool {
fn is_reachable_non_generic_provider_extern(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
tcx.reachable_non_generics(def_id.krate).contains_key(&def_id)
}
fn exported_symbols_provider_local<'tcx>(
tcx: TyCtxt<'tcx>,
fn exported_symbols_provider_local(
tcx: TyCtxt<'_>,
cnum: CrateNum,
) -> Arc<Vec<(ExportedSymbol<'tcx>, SymbolExportLevel)>> {
) -> Arc<Vec<(ExportedSymbol<'_>, SymbolExportLevel)>> {
assert_eq!(cnum, LOCAL_CRATE);
if !tcx.sess.opts.output_types.should_codegen() {
@ -273,10 +273,10 @@ fn exported_symbols_provider_local<'tcx>(
Arc::new(symbols)
}
fn upstream_monomorphizations_provider<'tcx>(
tcx: TyCtxt<'tcx>,
fn upstream_monomorphizations_provider(
tcx: TyCtxt<'_>,
cnum: CrateNum,
) -> &'tcx DefIdMap<FxHashMap<SubstsRef<'tcx>, CrateNum>> {
) -> &DefIdMap<FxHashMap<SubstsRef<'_>, CrateNum>> {
debug_assert!(cnum == LOCAL_CRATE);
let cnums = tcx.all_crate_nums(LOCAL_CRATE);
@ -322,10 +322,10 @@ fn upstream_monomorphizations_provider<'tcx>(
tcx.arena.alloc(instances)
}
fn upstream_monomorphizations_for_provider<'tcx>(
tcx: TyCtxt<'tcx>,
fn upstream_monomorphizations_for_provider(
tcx: TyCtxt<'_>,
def_id: DefId,
) -> Option<&'tcx FxHashMap<SubstsRef<'tcx>, CrateNum>> {
) -> Option<&FxHashMap<SubstsRef<'_>, CrateNum>> {
debug_assert!(!def_id.is_local());
tcx.upstream_monomorphizations(LOCAL_CRATE).get(&def_id)
}

View File

@ -700,7 +700,7 @@ impl<B: ExtraBackendMethods> Drop for AbortCodegenOnDrop<B> {
}
}
fn assert_and_save_dep_graph<'tcx>(tcx: TyCtxt<'tcx>) {
fn assert_and_save_dep_graph(tcx: TyCtxt<'_>) {
time(tcx.sess,
"assert dep graph",
|| ::rustc_incremental::assert_dep_graph(tcx));

View File

@ -10,7 +10,7 @@ pub enum FunctionDebugContext<D> {
}
impl<D> FunctionDebugContext<D> {
pub fn get_ref<'a>(&'a self, span: Span) -> &'a FunctionDebugContextData<D> {
pub fn get_ref(&self, span: Span) -> &FunctionDebugContextData<D> {
match *self {
FunctionDebugContext::RegularContext(ref data) => data,
FunctionDebugContext::DebugInfoDisabled => {

View File

@ -273,7 +273,7 @@ impl CleanupKind {
}
}
pub fn cleanup_kinds<'tcx>(mir: &mir::Body<'tcx>) -> IndexVec<mir::BasicBlock, CleanupKind> {
pub fn cleanup_kinds(mir: &mir::Body<'_>) -> IndexVec<mir::BasicBlock, CleanupKind> {
fn discover_masters<'tcx>(result: &mut IndexVec<mir::BasicBlock, CleanupKind>,
mir: &mir::Body<'tcx>) {
for (bb, data) in mir.basic_blocks().iter_enumerated() {

View File

@ -44,7 +44,7 @@ pub trait ExtraBackendMethods: CodegenBackend + WriteBackendMethods + Sized + Se
mods: &mut Self::Module,
kind: AllocatorKind,
);
fn compile_codegen_unit<'tcx>(&self, tcx: TyCtxt<'tcx>, cgu_name: InternedString);
fn compile_codegen_unit(&self, tcx: TyCtxt<'_>, cgu_name: InternedString);
// If find_features is true this won't access `sess.crate_types` by assuming
// that `is_pie_binary` is false. When we discover LLVM target features
// `sess.crate_types` is uninitialized so we cannot access it.

View File

@ -36,7 +36,7 @@ pub trait BuilderMethods<'a, 'tcx>:
{
fn new_block<'b>(cx: &'a Self::CodegenCx, llfn: Self::Value, name: &'b str) -> Self;
fn with_cx(cx: &'a Self::CodegenCx) -> Self;
fn build_sibling_block<'b>(&self, name: &'b str) -> Self;
fn build_sibling_block(&self, name: &str) -> Self;
fn cx(&self) -> &Self::CodegenCx;
fn llbb(&self) -> Self::BasicBlock;

View File

@ -11,7 +11,7 @@ use syntax::symbol::{Symbol, sym};
const SYMBOL_NAME: Symbol = sym::rustc_symbol_name;
const DEF_PATH: Symbol = sym::rustc_def_path;
pub fn report_symbol_names<'tcx>(tcx: TyCtxt<'tcx>) {
pub fn report_symbol_names(tcx: TyCtxt<'_>) {
// if the `rustc_attrs` feature is not enabled, then the
// attributes we are interested in cannot be present anyway, so
// skip the walk.

View File

@ -168,7 +168,7 @@ impl<T: Idx> BitSet<T> {
/// Iterates over the indices of set bits in a sorted order.
#[inline]
pub fn iter<'a>(&'a self) -> BitIter<'a, T> {
pub fn iter(&self) -> BitIter<'_, T> {
BitIter {
cur: None,
iter: self.words.iter().enumerate(),
@ -849,7 +849,7 @@ impl<R: Idx, C: Idx> BitMatrix<R, C> {
/// Iterates through all the columns set to true in a given row of
/// the matrix.
pub fn iter<'a>(&'a self, row: R) -> BitIter<'a, C> {
pub fn iter(&self, row: R) -> BitIter<'_, C> {
assert!(row.index() < self.num_rows);
let (start, end) = self.range(row);
BitIter {

View File

@ -58,7 +58,7 @@ impl Fingerprint {
Ok(())
}
pub fn decode_opaque<'a>(decoder: &mut Decoder<'a>) -> Result<Fingerprint, String> {
pub fn decode_opaque(decoder: &mut Decoder<'_>) -> Result<Fingerprint, String> {
let mut bytes = [0; 16];
decoder.read_raw_bytes(&mut bytes)?;

View File

@ -247,11 +247,11 @@ impl<N: Debug, E: Debug> Graph<N, E> {
self.incoming_edges(target).sources()
}
pub fn depth_traverse<'a>(
&'a self,
pub fn depth_traverse(
&self,
start: NodeIndex,
direction: Direction,
) -> DepthFirstTraversal<'a, N, E> {
) -> DepthFirstTraversal<'_, N, E> {
DepthFirstTraversal::with_start_node(self, start, direction)
}

View File

@ -26,10 +26,10 @@ pub trait WithSuccessors: DirectedGraph
where
Self: for<'graph> GraphSuccessors<'graph, Item = <Self as DirectedGraph>::Node>,
{
fn successors<'graph>(
&'graph self,
fn successors(
&self,
node: Self::Node,
) -> <Self as GraphSuccessors<'graph>>::Iter;
) -> <Self as GraphSuccessors<'_>>::Iter;
fn depth_first_search(&self, from: Self::Node) -> iterate::DepthFirstSearch<'_, Self>
where
@ -48,10 +48,10 @@ pub trait WithPredecessors: DirectedGraph
where
Self: for<'graph> GraphPredecessors<'graph, Item = <Self as DirectedGraph>::Node>,
{
fn predecessors<'graph>(
&'graph self,
fn predecessors(
&self,
node: Self::Node,
) -> <Self as GraphPredecessors<'graph>>::Iter;
) -> <Self as GraphPredecessors<'_>>::Iter;
}
pub trait GraphPredecessors<'graph> {

View File

@ -17,15 +17,15 @@ impl<'graph, G: WithStartNode> WithStartNode for &'graph G {
}
impl<'graph, G: WithSuccessors> WithSuccessors for &'graph G {
fn successors<'iter>(&'iter self, node: Self::Node) -> <Self as GraphSuccessors<'iter>>::Iter {
fn successors(&self, node: Self::Node) -> <Self as GraphSuccessors<'_>>::Iter {
(**self).successors(node)
}
}
impl<'graph, G: WithPredecessors> WithPredecessors for &'graph G {
fn predecessors<'iter>(&'iter self,
node: Self::Node)
-> <Self as GraphPredecessors<'iter>>::Iter {
fn predecessors(&self,
node: Self::Node)
-> <Self as GraphPredecessors<'_>>::Iter {
(**self).predecessors(node)
}
}

View File

@ -51,15 +51,15 @@ impl WithNumNodes for TestGraph {
}
impl WithPredecessors for TestGraph {
fn predecessors<'graph>(&'graph self,
node: usize)
-> <Self as GraphPredecessors<'graph>>::Iter {
fn predecessors(&self,
node: usize)
-> <Self as GraphPredecessors<'_>>::Iter {
self.predecessors[&node].iter().cloned()
}
}
impl WithSuccessors for TestGraph {
fn successors<'graph>(&'graph self, node: usize) -> <Self as GraphSuccessors<'graph>>::Iter {
fn successors(&self, node: usize) -> <Self as GraphSuccessors<'_>>::Iter {
self.successors[&node].iter().cloned()
}
}

View File

@ -188,7 +188,7 @@ impl PpSourceMode {
_ => panic!("Should use call_with_pp_support_hir"),
}
}
fn call_with_pp_support_hir<'tcx, A, F>(&self, tcx: TyCtxt<'tcx>, f: F) -> A
fn call_with_pp_support_hir<A, F>(&self, tcx: TyCtxt<'_>, f: F) -> A
where
F: FnOnce(&dyn HirPrinterSupport<'_>, &hir::Crate) -> A,
{
@ -228,7 +228,7 @@ impl PpSourceMode {
trait PrinterSupport: pprust::PpAnn {
/// Provides a uniform interface for re-extracting a reference to a
/// `Session` from a value that now owns it.
fn sess<'a>(&'a self) -> &'a Session;
fn sess(&self) -> &Session;
/// Produces the pretty-print annotation object.
///
@ -240,7 +240,7 @@ trait PrinterSupport: pprust::PpAnn {
trait HirPrinterSupport<'hir>: pprust_hir::PpAnn {
/// Provides a uniform interface for re-extracting a reference to a
/// `Session` from a value that now owns it.
fn sess<'a>(&'a self) -> &'a Session;
fn sess(&self) -> &Session;
/// Provides a uniform interface for re-extracting a reference to an
/// `hir_map::Map` from a value that now owns it.
@ -272,7 +272,7 @@ struct NoAnn<'hir> {
}
impl<'hir> PrinterSupport for NoAnn<'hir> {
fn sess<'a>(&'a self) -> &'a Session {
fn sess(&self) -> &Session {
self.sess
}
@ -282,7 +282,7 @@ impl<'hir> PrinterSupport for NoAnn<'hir> {
}
impl<'hir> HirPrinterSupport<'hir> for NoAnn<'hir> {
fn sess<'a>(&'a self) -> &'a Session {
fn sess(&self) -> &Session {
self.sess
}
@ -313,7 +313,7 @@ struct IdentifiedAnnotation<'hir> {
}
impl<'hir> PrinterSupport for IdentifiedAnnotation<'hir> {
fn sess<'a>(&'a self) -> &'a Session {
fn sess(&self) -> &Session {
self.sess
}
@ -360,7 +360,7 @@ impl<'hir> pprust::PpAnn for IdentifiedAnnotation<'hir> {
}
impl<'hir> HirPrinterSupport<'hir> for IdentifiedAnnotation<'hir> {
fn sess<'a>(&'a self) -> &'a Session {
fn sess(&self) -> &Session {
self.sess
}
@ -458,7 +458,7 @@ struct TypedAnnotation<'a, 'tcx> {
}
impl<'b, 'tcx> HirPrinterSupport<'tcx> for TypedAnnotation<'b, 'tcx> {
fn sess<'a>(&'a self) -> &'a Session {
fn sess(&self) -> &Session {
&self.tcx.sess
}
@ -866,8 +866,8 @@ pub fn print_after_hir_lowering<'tcx>(
// analysis is performed. However, we want to call `phase_3_run_analysis_passes`
// with a different callback than the standard driver, so that isn't easy.
// Instead, we call that function ourselves.
fn print_with_analysis<'tcx>(
tcx: TyCtxt<'tcx>,
fn print_with_analysis(
tcx: TyCtxt<'_>,
ppm: PpMode,
uii: Option<UserIdentifiedItem>,
ofile: Option<&Path>,

View File

@ -1635,7 +1635,7 @@ impl Destination {
}
}
fn writable<'a>(&'a mut self) -> WritableDst<'a> {
fn writable(&mut self) -> WritableDst<'_> {
match *self {
Destination::Terminal(ref mut t) => WritableDst::Terminal(t),
Destination::Buffered(ref mut t) => {

View File

@ -438,14 +438,14 @@ impl Handler {
self.err_count.store(0, SeqCst);
}
pub fn struct_dummy<'a>(&'a self) -> DiagnosticBuilder<'a> {
pub fn struct_dummy(&self) -> DiagnosticBuilder<'_> {
DiagnosticBuilder::new(self, Level::Cancelled, "")
}
pub fn struct_span_warn<'a, S: Into<MultiSpan>>(&'a self,
sp: S,
msg: &str)
-> DiagnosticBuilder<'a> {
pub fn struct_span_warn<S: Into<MultiSpan>>(&self,
sp: S,
msg: &str)
-> DiagnosticBuilder<'_> {
let mut result = DiagnosticBuilder::new(self, Level::Warning, msg);
result.set_span(sp);
if !self.flags.can_emit_warnings {
@ -453,11 +453,11 @@ impl Handler {
}
result
}
pub fn struct_span_warn_with_code<'a, S: Into<MultiSpan>>(&'a self,
sp: S,
msg: &str,
code: DiagnosticId)
-> DiagnosticBuilder<'a> {
pub fn struct_span_warn_with_code<S: Into<MultiSpan>>(&self,
sp: S,
msg: &str,
code: DiagnosticId)
-> DiagnosticBuilder<'_> {
let mut result = DiagnosticBuilder::new(self, Level::Warning, msg);
result.set_span(sp);
result.code(code);
@ -466,63 +466,63 @@ impl Handler {
}
result
}
pub fn struct_warn<'a>(&'a self, msg: &str) -> DiagnosticBuilder<'a> {
pub fn struct_warn(&self, msg: &str) -> DiagnosticBuilder<'_> {
let mut result = DiagnosticBuilder::new(self, Level::Warning, msg);
if !self.flags.can_emit_warnings {
result.cancel();
}
result
}
pub fn struct_span_err<'a, S: Into<MultiSpan>>(&'a self,
sp: S,
msg: &str)
-> DiagnosticBuilder<'a> {
pub fn struct_span_err<S: Into<MultiSpan>>(&self,
sp: S,
msg: &str)
-> DiagnosticBuilder<'_> {
let mut result = DiagnosticBuilder::new(self, Level::Error, msg);
result.set_span(sp);
result
}
pub fn struct_span_err_with_code<'a, S: Into<MultiSpan>>(&'a self,
sp: S,
msg: &str,
code: DiagnosticId)
-> DiagnosticBuilder<'a> {
pub fn struct_span_err_with_code<S: Into<MultiSpan>>(&self,
sp: S,
msg: &str,
code: DiagnosticId)
-> DiagnosticBuilder<'_> {
let mut result = DiagnosticBuilder::new(self, Level::Error, msg);
result.set_span(sp);
result.code(code);
result
}
// FIXME: This method should be removed (every error should have an associated error code).
pub fn struct_err<'a>(&'a self, msg: &str) -> DiagnosticBuilder<'a> {
pub fn struct_err(&self, msg: &str) -> DiagnosticBuilder<'_> {
DiagnosticBuilder::new(self, Level::Error, msg)
}
pub fn struct_err_with_code<'a>(
&'a self,
pub fn struct_err_with_code(
&self,
msg: &str,
code: DiagnosticId,
) -> DiagnosticBuilder<'a> {
) -> DiagnosticBuilder<'_> {
let mut result = DiagnosticBuilder::new(self, Level::Error, msg);
result.code(code);
result
}
pub fn struct_span_fatal<'a, S: Into<MultiSpan>>(&'a self,
sp: S,
msg: &str)
-> DiagnosticBuilder<'a> {
pub fn struct_span_fatal<S: Into<MultiSpan>>(&self,
sp: S,
msg: &str)
-> DiagnosticBuilder<'_> {
let mut result = DiagnosticBuilder::new(self, Level::Fatal, msg);
result.set_span(sp);
result
}
pub fn struct_span_fatal_with_code<'a, S: Into<MultiSpan>>(&'a self,
sp: S,
msg: &str,
code: DiagnosticId)
-> DiagnosticBuilder<'a> {
pub fn struct_span_fatal_with_code<S: Into<MultiSpan>>(&self,
sp: S,
msg: &str,
code: DiagnosticId)
-> DiagnosticBuilder<'_> {
let mut result = DiagnosticBuilder::new(self, Level::Fatal, msg);
result.set_span(sp);
result.code(code);
result
}
pub fn struct_fatal<'a>(&'a self, msg: &str) -> DiagnosticBuilder<'a> {
pub fn struct_fatal(&self, msg: &str) -> DiagnosticBuilder<'_> {
DiagnosticBuilder::new(self, Level::Fatal, msg)
}
@ -563,10 +563,10 @@ impl Handler {
pub fn span_err<S: Into<MultiSpan>>(&self, sp: S, msg: &str) {
self.emit(&sp.into(), msg, Error);
}
pub fn mut_span_err<'a, S: Into<MultiSpan>>(&'a self,
sp: S,
msg: &str)
-> DiagnosticBuilder<'a> {
pub fn mut_span_err<S: Into<MultiSpan>>(&self,
sp: S,
msg: &str)
-> DiagnosticBuilder<'_> {
let mut result = DiagnosticBuilder::new(self, Level::Error, msg);
result.set_span(sp);
result
@ -605,10 +605,10 @@ impl Handler {
pub fn span_note_without_error<S: Into<MultiSpan>>(&self, sp: S, msg: &str) {
self.emit(&sp.into(), msg, Note);
}
pub fn span_note_diag<'a>(&'a self,
sp: Span,
msg: &str)
-> DiagnosticBuilder<'a> {
pub fn span_note_diag(&self,
sp: Span,
msg: &str)
-> DiagnosticBuilder<'_> {
let mut db = DiagnosticBuilder::new(self, Note, msg);
db.set_span(sp);
db

View File

@ -51,7 +51,7 @@ use std::io::Write;
use syntax::ast;
use syntax_pos::Span;
pub fn assert_dep_graph<'tcx>(tcx: TyCtxt<'tcx>) {
pub fn assert_dep_graph(tcx: TyCtxt<'_>) {
tcx.dep_graph.with_ignore(|| {
if tcx.sess.opts.debugging_opts.dump_dep_graph {
dump_graph(tcx);

View File

@ -35,7 +35,7 @@ const MODULE: Symbol = sym::module;
const CFG: Symbol = sym::cfg;
const KIND: Symbol = sym::kind;
pub fn assert_module_sources<'tcx>(tcx: TyCtxt<'tcx>) {
pub fn assert_module_sources(tcx: TyCtxt<'_>) {
tcx.dep_graph.with_ignore(|| {
if tcx.sess.opts.incremental.is_none() {
return;

View File

@ -206,7 +206,7 @@ impl Assertion {
}
}
pub fn check_dirty_clean_annotations<'tcx>(tcx: TyCtxt<'tcx>) {
pub fn check_dirty_clean_annotations(tcx: TyCtxt<'_>) {
// can't add `#[rustc_dirty]` etc without opting in to this feature
if !tcx.features().rustc_attrs {
return;

View File

@ -15,7 +15,7 @@ use super::fs::*;
use super::file_format;
use super::work_product;
pub fn dep_graph_tcx_init<'tcx>(tcx: TyCtxt<'tcx>) {
pub fn dep_graph_tcx_init(tcx: TyCtxt<'_>) {
if !tcx.dep_graph.is_fully_enabled() {
return
}
@ -192,7 +192,7 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture {
}))
}
pub fn load_query_result_cache<'sess>(sess: &'sess Session) -> OnDiskCache<'sess> {
pub fn load_query_result_cache(sess: &Session) -> OnDiskCache<'_> {
if sess.opts.incremental.is_none() ||
!sess.opts.debugging_opts.incremental_queries {
return OnDiskCache::new_empty(sess.source_map());

View File

@ -15,7 +15,7 @@ use super::dirty_clean;
use super::file_format;
use super::work_product;
pub fn save_dep_graph<'tcx>(tcx: TyCtxt<'tcx>) {
pub fn save_dep_graph(tcx: TyCtxt<'_>) {
debug!("save_dep_graph()");
tcx.dep_graph.with_ignore(|| {
let sess = tcx.sess;

View File

@ -878,7 +878,7 @@ pub fn create_global_ctxt(
/// Runs the resolution, type-checking, region checking and other
/// miscellaneous analysis passes on the crate.
fn analysis<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> Result<()> {
fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> {
assert_eq!(cnum, LOCAL_CRATE);
let sess = tcx.sess;
@ -995,8 +995,8 @@ fn analysis<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> Result<()> {
Ok(())
}
fn encode_and_write_metadata<'tcx>(
tcx: TyCtxt<'tcx>,
fn encode_and_write_metadata(
tcx: TyCtxt<'_>,
outputs: &OutputFilenames,
) -> (middle::cstore::EncodedMetadata, bool) {
#[derive(PartialEq, Eq, PartialOrd, Ord)]

View File

@ -6,11 +6,11 @@ use rustc::ty::query::Providers;
use syntax::attr;
use syntax::symbol::sym;
pub fn find<'tcx>(tcx: TyCtxt<'tcx>) -> Option<DefId> {
pub fn find(tcx: TyCtxt<'_>) -> Option<DefId> {
tcx.proc_macro_decls_static(LOCAL_CRATE)
}
fn proc_macro_decls_static<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> Option<DefId> {
fn proc_macro_decls_static(tcx: TyCtxt<'_>, cnum: CrateNum) -> Option<DefId> {
assert_eq!(cnum, LOCAL_CRATE);
let mut finder = Finder { decls: None };

View File

@ -74,7 +74,7 @@ pub fn provide(providers: &mut Providers<'_>) {
};
}
fn lint_mod<'tcx>(tcx: TyCtxt<'tcx>, module_def_id: DefId) {
fn lint_mod(tcx: TyCtxt<'_>, module_def_id: DefId) {
lint::late_lint_mod(tcx, module_def_id, BuiltinCombinedModuleLateLintPass::new());
}

View File

@ -250,7 +250,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
exported_symbols => { Arc::new(cdata.exported_symbols(tcx)) }
}
pub fn provide<'tcx>(providers: &mut Providers<'tcx>) {
pub fn provide(providers: &mut Providers<'_>) {
// FIXME(#44234) - almost all of these queries have no sub-queries and
// therefore no actual inputs, they're just reading tables calculated in
// resolve! Does this work? Unsure! That's what the issue is about
@ -550,7 +550,7 @@ impl CrateStore for cstore::CStore {
self.do_postorder_cnums_untracked()
}
fn encode_metadata<'tcx>(&self, tcx: TyCtxt<'tcx>) -> EncodedMetadata {
fn encode_metadata(&self, tcx: TyCtxt<'_>) -> EncodedMetadata {
encoder::encode_metadata(tcx)
}

View File

@ -1863,7 +1863,7 @@ impl<'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'tcx> {
// will allow us to slice the metadata to the precise length that we just
// generated regardless of trailing bytes that end up in it.
pub fn encode_metadata<'tcx>(tcx: TyCtxt<'tcx>) -> EncodedMetadata {
pub fn encode_metadata(tcx: TyCtxt<'_>) -> EncodedMetadata {
let mut encoder = opaque::Encoder::new(vec![]);
encoder.emit_raw_bytes(METADATA_HEADER);
@ -1905,7 +1905,7 @@ pub fn encode_metadata<'tcx>(tcx: TyCtxt<'tcx>) -> EncodedMetadata {
EncodedMetadata { raw_data: result }
}
pub fn get_repr_options<'tcx>(tcx: TyCtxt<'tcx>, did: DefId) -> ReprOptions {
pub fn get_repr_options(tcx: TyCtxt<'_>, did: DefId) -> ReprOptions {
let ty = tcx.type_of(did);
match ty.sty {
ty::Adt(ref def, _) => return def.repr,

View File

@ -3,7 +3,7 @@ use rustc::hir;
use rustc::middle::cstore::ForeignModule;
use rustc::ty::TyCtxt;
pub fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> Vec<ForeignModule> {
pub fn collect(tcx: TyCtxt<'_>) -> Vec<ForeignModule> {
let mut collector = Collector {
tcx,
modules: Vec::new(),

View File

@ -4,7 +4,7 @@ use rustc::ty::TyCtxt;
use rustc_target::spec::abi::Abi;
use syntax::symbol::sym;
pub fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> Vec<String> {
pub fn collect(tcx: TyCtxt<'_>) -> Vec<String> {
let mut collector = Collector {
args: Vec::new(),
};

View File

@ -11,7 +11,7 @@ use syntax::feature_gate::{self, GateIssue};
use syntax::symbol::{Symbol, sym};
use syntax::{span_err, struct_span_err};
pub fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> Vec<NativeLibrary> {
pub fn collect(tcx: TyCtxt<'_>) -> Vec<NativeLibrary> {
let mut collector = Collector {
tcx,
libs: Vec::new(),

View File

@ -87,7 +87,7 @@ pub fn provide(providers: &mut Providers<'_>) {
};
}
fn mir_borrowck<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> BorrowCheckResult<'tcx> {
fn mir_borrowck(tcx: TyCtxt<'_>, def_id: DefId) -> BorrowCheckResult<'_> {
let input_body = tcx.mir_validated(def_id);
debug!("run query mir_borrowck: {}", tcx.def_path_str(def_id));

View File

@ -234,10 +234,10 @@ impl<'s, D: ConstraintGraphDirecton> graph::WithNumNodes for RegionGraph<'s, D>
}
impl<'s, D: ConstraintGraphDirecton> graph::WithSuccessors for RegionGraph<'s, D> {
fn successors<'graph>(
&'graph self,
fn successors(
&self,
node: Self::Node,
) -> <Self as graph::GraphSuccessors<'graph>>::Iter {
) -> <Self as graph::GraphSuccessors<'_>>::Iter {
self.outgoing_regions(node)
}
}

View File

@ -162,7 +162,7 @@ impl<N: Idx> LivenessValues<N> {
}
/// Iterate through each region that has a value in this set.
crate fn rows<'a>(&'a self) -> impl Iterator<Item = N> {
crate fn rows(&self) -> impl Iterator<Item=N> {
self.points.rows()
}

View File

@ -130,7 +130,7 @@ pub(super) fn is_active<'tcx>(
/// Determines if a given borrow is borrowing local data
/// This is called for all Yield statements on movable generators
pub(super) fn borrow_of_local_data<'tcx>(place: &Place<'tcx>) -> bool {
pub(super) fn borrow_of_local_data(place: &Place<'_>) -> bool {
place.iterate(|place_base, place_projection| {
match place_base {
PlaceBase::Static(..) => return false,

View File

@ -31,7 +31,7 @@ pub enum RvalueFunc {
/// Determines the category for a given expression. Note that scope
/// and paren expressions have no category.
impl Category {
pub fn of<'tcx>(ek: &ExprKind<'tcx>) -> Option<Category> {
pub fn of(ek: &ExprKind<'_>) -> Option<Category> {
match *ek {
ExprKind::Scope { .. } => None,

View File

@ -826,6 +826,6 @@ impl Test<'_> {
}
}
fn is_switch_ty<'tcx>(ty: Ty<'tcx>) -> bool {
fn is_switch_ty(ty: Ty<'_>) -> bool {
ty.is_integral() || ty.is_char() || ty.is_bool()
}

View File

@ -22,7 +22,7 @@ use syntax_pos::Span;
use super::lints;
/// Construct the MIR for a given `DefId`.
pub fn mir_build<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Body<'tcx> {
pub fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> Body<'_> {
let id = tcx.hir().as_local_hir_id(def_id).unwrap();
// Figure out what primary body this item has.
@ -171,11 +171,11 @@ pub fn mir_build<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Body<'tcx> {
///////////////////////////////////////////////////////////////////////////
// BuildMir -- walks a crate, looking for fn items and methods to build MIR from
fn liberated_closure_env_ty<'tcx>(
tcx: TyCtxt<'tcx>,
fn liberated_closure_env_ty(
tcx: TyCtxt<'_>,
closure_expr_id: hir::HirId,
body_id: hir::BodyId,
) -> Ty<'tcx> {
) -> Ty<'_> {
let closure_ty = tcx.body_tables(body_id).node_type(closure_expr_id);
let (closure_def_id, closure_substs) = match closure_ty.sty {
@ -485,7 +485,7 @@ macro_rules! unpack {
};
}
fn should_abort_on_panic<'tcx>(tcx: TyCtxt<'tcx>, fn_def_id: DefId, abi: Abi) -> bool {
fn should_abort_on_panic(tcx: TyCtxt<'_>, fn_def_id: DefId, abi: Abi) -> bool {
// Not callable from C, so we can safely unwind through these
if abi == Abi::Rust || abi == Abi::RustCall { return false; }

View File

@ -92,7 +92,7 @@ struct BorrowedLocalsVisitor<'gk> {
trans: &'gk mut GenKillSet<Local>,
}
fn find_local<'tcx>(place: &Place<'tcx>) -> Option<Local> {
fn find_local(place: &Place<'_>) -> Option<Local> {
place.iterate(|place_base, place_projection| {
for proj in place_projection {
if proj.elem == ProjectionElem::Deref {

View File

@ -835,7 +835,7 @@ impl<'tcx> IntRange<'tcx> {
fn from_ctor(tcx: TyCtxt<'tcx>, ctor: &Constructor<'tcx>) -> Option<IntRange<'tcx>> {
// Floating-point ranges are permitted and we don't want
// to consider them when constructing integer ranges.
fn is_integral<'tcx>(ty: Ty<'tcx>) -> bool {
fn is_integral(ty: Ty<'_>) -> bool {
match ty.sty {
ty::Char | ty::Int(_) | ty::Uint(_) => true,
_ => false,

View File

@ -26,7 +26,7 @@ use std::slice;
use syntax_pos::{Span, DUMMY_SP, MultiSpan};
pub(crate) fn check_match<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) {
pub(crate) fn check_match(tcx: TyCtxt<'_>, def_id: DefId) {
let body_id = if let Some(id) = tcx.hir().as_local_hir_id(def_id) {
tcx.hir().body_owned_by(id)
} else {
@ -43,7 +43,7 @@ pub(crate) fn check_match<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) {
}.visit_body(tcx.hir().body(body_id));
}
fn create_e0004<'a>(sess: &'a Session, sp: Span, error_message: String) -> DiagnosticBuilder<'a> {
fn create_e0004(sess: &Session, sp: Span, error_message: String) -> DiagnosticBuilder<'_> {
struct_span_err!(sess, sp, E0004, "{}", &error_message)
}

View File

@ -281,10 +281,10 @@ impl<'tcx> InliningMap<'tcx> {
}
}
pub fn collect_crate_mono_items<'tcx>(
tcx: TyCtxt<'tcx>,
pub fn collect_crate_mono_items(
tcx: TyCtxt<'_>,
mode: MonoItemCollectionMode,
) -> (FxHashSet<MonoItem<'tcx>>, InliningMap<'tcx>) {
) -> (FxHashSet<MonoItem<'_>>, InliningMap<'_>) {
let roots = time(tcx.sess, "collecting roots", || {
collect_roots(tcx, mode)
});
@ -315,7 +315,7 @@ pub fn collect_crate_mono_items<'tcx>(
// Find all non-generic items by walking the HIR. These items serve as roots to
// start monomorphizing from.
fn collect_roots<'tcx>(tcx: TyCtxt<'tcx>, mode: MonoItemCollectionMode) -> Vec<MonoItem<'tcx>> {
fn collect_roots(tcx: TyCtxt<'_>, mode: MonoItemCollectionMode) -> Vec<MonoItem<'_>> {
debug!("Collecting roots");
let mut roots = Vec::new();
@ -912,7 +912,7 @@ fn find_vtable_types_for_unsizing<'tcx>(
}
}
fn create_fn_mono_item<'tcx>(instance: Instance<'tcx>) -> MonoItem<'tcx> {
fn create_fn_mono_item(instance: Instance<'_>) -> MonoItem<'_> {
debug!("create_fn_mono_item(instance={})", instance);
MonoItem::Fn(instance)
}
@ -1114,7 +1114,7 @@ impl RootCollector<'_, 'v> {
}
}
fn item_requires_monomorphization<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool {
fn item_requires_monomorphization(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
let generics = tcx.generics_of(def_id);
generics.requires_monomorphization(tcx)
}
@ -1243,7 +1243,7 @@ fn collect_neighbours<'tcx>(
}
}
fn def_id_to_string<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> String {
fn def_id_to_string(tcx: TyCtxt<'_>, def_id: DefId) -> String {
let mut output = String::new();
let printer = DefPathBasedNames::new(tcx, false, false);
printer.push_def_path(def_id, &mut output);

View File

@ -839,10 +839,10 @@ where
}
}
fn collect_and_partition_mono_items<'tcx>(
tcx: TyCtxt<'tcx>,
fn collect_and_partition_mono_items(
tcx: TyCtxt<'_>,
cnum: CrateNum,
) -> (Arc<DefIdSet>, Arc<Vec<Arc<CodegenUnit<'tcx>>>>) {
) -> (Arc<DefIdSet>, Arc<Vec<Arc<CodegenUnit<'_>>>>) {
assert_eq!(cnum, LOCAL_CRATE);
let collection_mode = match tcx.sess.opts.debugging_opts.print_mono_items {

View File

@ -829,7 +829,7 @@ fn build_call_shim<'tcx>(
body
}
pub fn build_adt_ctor<'tcx>(tcx: TyCtxt<'tcx>, ctor_id: DefId) -> &'tcx Body<'tcx> {
pub fn build_adt_ctor(tcx: TyCtxt<'_>, ctor_id: DefId) -> &Body<'_> {
debug_assert!(tcx.is_constructor(ctor_id));
let span = tcx.hir().span_if_local(ctor_id)

View File

@ -14,8 +14,8 @@ pub struct AddRetag;
/// after the assignment, we can be sure to obtain the same place value.
/// (Concurrent accesses by other threads are no problem as these are anyway non-atomic
/// copies. Data races are UB.)
fn is_stable<'tcx>(
place: &Place<'tcx>,
fn is_stable(
place: &Place<'_>,
) -> bool {
use rustc::mir::Place::*;

View File

@ -480,11 +480,11 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for UnusedUnsafeVisitor<'a> {
}
}
fn check_unused_unsafe<'a, 'tcx>(
tcx: TyCtxt<'tcx>,
fn check_unused_unsafe(
tcx: TyCtxt<'_>,
def_id: DefId,
used_unsafe: &FxHashSet<hir::HirId>,
unsafe_blocks: &'a mut Vec<(hir::HirId, bool)>,
unsafe_blocks: &mut Vec<(hir::HirId, bool)>,
) {
let body_id =
tcx.hir().as_local_hir_id(def_id).and_then(|hir_id| {
@ -506,7 +506,7 @@ fn check_unused_unsafe<'a, 'tcx>(
hir::intravisit::Visitor::visit_body(&mut visitor, body);
}
fn unsafety_check_result<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> UnsafetyCheckResult {
fn unsafety_check_result(tcx: TyCtxt<'_>, def_id: DefId) -> UnsafetyCheckResult {
debug!("unsafety_violations({:?})", def_id);
// N.B., this borrow is valid because all the consumers of
@ -545,7 +545,7 @@ fn unsafety_check_result<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> UnsafetyChec
}
}
fn unsafe_derive_on_repr_packed<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) {
fn unsafe_derive_on_repr_packed(tcx: TyCtxt<'_>, def_id: DefId) {
let lint_hir_id = tcx.hir().as_local_hir_id(def_id).unwrap_or_else(||
bug!("checking unsafety for non-local def id {:?}", def_id));
@ -602,7 +602,7 @@ fn report_unused_unsafe(tcx: TyCtxt<'_>, used_unsafe: &FxHashSet<hir::HirId>, id
db.emit();
}
fn builtin_derive_def_id<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Option<DefId> {
fn builtin_derive_def_id(tcx: TyCtxt<'_>, def_id: DefId) -> Option<DefId> {
debug!("builtin_derive_def_id({:?})", def_id);
if let Some(impl_def_id) = tcx.impl_of_method(def_id) {
if tcx.has_attr(impl_def_id, sym::automatically_derived) {
@ -618,7 +618,7 @@ fn builtin_derive_def_id<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Option<DefId
}
}
pub fn check_unsafety<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) {
pub fn check_unsafety(tcx: TyCtxt<'_>, def_id: DefId) {
debug!("check_unsafety({:?})", def_id);
// closures are handled by their parent fn.

View File

@ -14,7 +14,7 @@ use crate::util as mir_util;
pub struct Marker(pub &'static str);
impl MirPass for Marker {
fn name<'a>(&'a self) -> Cow<'a, str> {
fn name(&self) -> Cow<'_, str> {
Cow::Borrowed(self.0)
}
@ -52,7 +52,7 @@ pub fn on_mir_pass<'tcx>(
}
}
pub fn emit_mir<'tcx>(tcx: TyCtxt<'tcx>, outputs: &OutputFilenames) -> io::Result<()> {
pub fn emit_mir(tcx: TyCtxt<'_>, outputs: &OutputFilenames) -> io::Result<()> {
let path = outputs.path(OutputType::Mir);
let mut f = File::create(&path)?;
mir_util::write_mir_pretty(tcx, None, &mut f)?;

View File

@ -1028,14 +1028,14 @@ fn create_generator_resume_function<'tcx>(
dump_mir(tcx, None, "generator_resume", &0, source, body, |_, _| Ok(()) );
}
fn source_info<'tcx>(body: &Body<'tcx>) -> SourceInfo {
fn source_info(body: &Body<'_>) -> SourceInfo {
SourceInfo {
span: body.span,
scope: OUTERMOST_SOURCE_SCOPE,
}
}
fn insert_clean_drop<'tcx>(body: &mut Body<'tcx>) -> BasicBlock {
fn insert_clean_drop(body: &mut Body<'_>) -> BasicBlock {
let return_block = insert_term_block(body, TerminatorKind::Return);
// Create a block to destroy an unresumed generators. This can only destroy upvars.

View File

@ -50,13 +50,13 @@ pub(crate) fn provide(providers: &mut Providers<'_>) {
};
}
fn is_mir_available<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool {
fn is_mir_available(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
tcx.mir_keys(def_id.krate).contains(&def_id)
}
/// Finds the full set of `DefId`s within the current crate that have
/// MIR associated with them.
fn mir_keys<'tcx>(tcx: TyCtxt<'tcx>, krate: CrateNum) -> &'tcx DefIdSet {
fn mir_keys(tcx: TyCtxt<'_>, krate: CrateNum) -> &DefIdSet {
assert_eq!(krate, LOCAL_CRATE);
let mut set = DefIdSet::default();
@ -94,7 +94,7 @@ fn mir_keys<'tcx>(tcx: TyCtxt<'tcx>, krate: CrateNum) -> &'tcx DefIdSet {
tcx.arena.alloc(set)
}
fn mir_built<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx Steal<Body<'tcx>> {
fn mir_built(tcx: TyCtxt<'_>, def_id: DefId) -> &Steal<Body<'_>> {
let mir = build::mir_build(tcx, def_id);
tcx.alloc_steal_mir(mir)
}
@ -137,7 +137,7 @@ pub fn default_name<T: ?Sized>() -> Cow<'static, str> {
/// pass will be named after the type, and it will consist of a main
/// loop that goes over each available MIR and applies `run_pass`.
pub trait MirPass {
fn name<'a>(&'a self) -> Cow<'a, str> {
fn name(&self) -> Cow<'_, str> {
default_name::<Self>()
}
@ -192,7 +192,7 @@ pub fn run_passes(
}
}
fn mir_const<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx Steal<Body<'tcx>> {
fn mir_const(tcx: TyCtxt<'_>, def_id: DefId) -> &Steal<Body<'_>> {
// Unsafety check uses the raw mir, so make sure it is run
let _ = tcx.unsafety_check_result(def_id);
@ -223,7 +223,7 @@ fn mir_validated(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx Steal<Body<'tcx>> {
tcx.alloc_steal_mir(body)
}
fn optimized_mir<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx Body<'tcx> {
fn optimized_mir(tcx: TyCtxt<'_>, def_id: DefId) -> &Body<'_> {
if tcx.is_constructor(def_id) {
// There's no reason to run all of the MIR passes on constructors when
// we can just output the MIR we want directly. This also saves const

View File

@ -1473,7 +1473,7 @@ pub fn provide(providers: &mut Providers<'_>) {
};
}
fn mir_const_qualif<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> (u8, &'tcx BitSet<Local>) {
fn mir_const_qualif(tcx: TyCtxt<'_>, def_id: DefId) -> (u8, &BitSet<Local>) {
// N.B., this `borrow()` is guaranteed to be valid (i.e., the value
// cannot yet be stolen), because `mir_validated()`, which steals
// from `mir_const(), forces this query to execute before

View File

@ -53,7 +53,7 @@ pub fn simplify_cfg(body: &mut Body<'_>) {
}
impl MirPass for SimplifyCfg {
fn name<'a>(&'a self) -> Cow<'a, str> {
fn name(&self) -> Cow<'_, str> {
Cow::Borrowed(&self.label)
}

View File

@ -15,7 +15,7 @@ impl SimplifyBranches {
}
impl MirPass for SimplifyBranches {
fn name<'a>(&'a self) -> Cow<'a, str> {
fn name(&self) -> Cow<'_, str> {
Cow::Borrowed(&self.label)
}

View File

@ -8,8 +8,8 @@ use std::io::{self, Write};
use super::pretty::dump_mir_def_ids;
/// Write a graphviz DOT graph of a list of MIRs.
pub fn write_mir_graphviz<'tcx, W>(
tcx: TyCtxt<'tcx>,
pub fn write_mir_graphviz<W>(
tcx: TyCtxt<'_>,
single: Option<DefId>,
w: &mut W,
) -> io::Result<()>

View File

@ -56,8 +56,8 @@ pub struct LivenessResult {
/// Computes which local variables are live within the given function
/// `mir`, including drops.
pub fn liveness_of_locals<'tcx>(
body: &Body<'tcx>,
pub fn liveness_of_locals(
body: &Body<'_>,
) -> LivenessResult {
let num_live_vars = body.local_decls.len();
@ -243,8 +243,8 @@ impl<'tcx> Visitor<'tcx> for DefsUsesVisitor
}
}
fn block<'tcx>(
b: &BasicBlockData<'tcx>,
fn block(
b: &BasicBlockData<'_>,
locals: usize,
) -> DefsUses {
let mut visitor = DefsUsesVisitor {

View File

@ -21,7 +21,7 @@ pub use self::graphviz::{graphviz_safe_def_name, write_mir_graphviz};
pub use self::graphviz::write_node_label as write_graphviz_node_label;
/// If possible, suggest replacing `ref` with `ref mut`.
pub fn suggest_ref_mut<'tcx>(tcx: TyCtxt<'tcx>, binding_span: Span) -> Option<(String)> {
pub fn suggest_ref_mut(tcx: TyCtxt<'_>, binding_span: Span) -> Option<(String)> {
let hi_src = tcx.sess.source_map().span_to_snippet(binding_span).unwrap();
if hi_src.starts_with("ref")
&& hi_src["ref".len()..].starts_with(Pattern_White_Space)

View File

@ -38,7 +38,7 @@ pub fn print_hir_stats(krate: &hir::Crate) {
collector.print("HIR STATS");
}
pub fn print_ast_stats<'v>(krate: &'v ast::Crate, title: &str) {
pub fn print_ast_stats(krate: &ast::Crate, title: &str) {
let mut collector = StatCollector {
krate: None,
data: FxHashMap::default(),

View File

@ -14,7 +14,7 @@ use rustc::ty::TyCtxt;
use syntax::ast::Attribute;
use syntax::symbol::sym;
pub fn test_layout<'tcx>(tcx: TyCtxt<'tcx>) {
pub fn test_layout(tcx: TyCtxt<'_>) {
if tcx.features().rustc_attrs {
// if the `rustc_attrs` feature is not enabled, don't bother testing layout
tcx.hir()

View File

@ -45,7 +45,7 @@ struct CheckLoopVisitor<'a, 'hir> {
cx: Context,
}
fn check_mod_loops<'tcx>(tcx: TyCtxt<'tcx>, module_def_id: DefId) {
fn check_mod_loops(tcx: TyCtxt<'_>, module_def_id: DefId) {
tcx.hir().visit_item_likes_in_module(module_def_id, &mut CheckLoopVisitor {
sess: &tcx.sess,
hir_map: &tcx.hir(),

View File

@ -39,7 +39,7 @@ pub fn provide(providers: &mut Providers<'_>) {
};
}
fn const_is_rvalue_promotable_to_static<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool {
fn const_is_rvalue_promotable_to_static(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
assert!(def_id.is_local());
let hir_id = tcx.hir().as_local_hir_id(def_id)
@ -48,7 +48,7 @@ fn const_is_rvalue_promotable_to_static<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId)
tcx.rvalue_promotable_map(def_id).contains(&body_id.hir_id.local_id)
}
fn rvalue_promotable_map<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx ItemLocalSet {
fn rvalue_promotable_map(tcx: TyCtxt<'_>, def_id: DefId) -> &ItemLocalSet {
let outer_def_id = tcx.closure_base_def_id(def_id);
if outer_def_id != def_id {
return tcx.rvalue_promotable_map(outer_def_id);

View File

@ -30,11 +30,11 @@ impl<'v> ItemLikeVisitor<'v> for RegistrarFinder {
}
/// Finds the function marked with `#[plugin_registrar]`, if any.
pub fn find_plugin_registrar<'tcx>(tcx: TyCtxt<'tcx>) -> Option<DefId> {
pub fn find_plugin_registrar(tcx: TyCtxt<'_>) -> Option<DefId> {
tcx.plugin_registrar_fn(LOCAL_CRATE)
}
fn plugin_registrar_fn<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> Option<DefId> {
fn plugin_registrar_fn(tcx: TyCtxt<'_>, cnum: CrateNum) -> Option<DefId> {
assert_eq!(cnum, LOCAL_CRATE);
let mut finder = RegistrarFinder { registrars: Vec::new() };

View File

@ -77,7 +77,7 @@ impl<'a> Registry<'a> {
///
/// Returns empty slice in case the plugin was loaded
/// with `--extra-plugins`
pub fn args<'b>(&'b self) -> &'b [ast::NestedMetaItem] {
pub fn args(&self) -> &[ast::NestedMetaItem] {
self.args_hidden.as_ref().map(|v| &v[..]).unwrap_or(&[])
}

View File

@ -337,7 +337,7 @@ fn item_tables<'a, 'tcx>(
if tcx.has_typeck_tables(def_id) { tcx.typeck_tables_of(def_id) } else { empty_tables }
}
fn min<'tcx>(vis1: ty::Visibility, vis2: ty::Visibility, tcx: TyCtxt<'tcx>) -> ty::Visibility {
fn min(vis1: ty::Visibility, vis2: ty::Visibility, tcx: TyCtxt<'_>) -> ty::Visibility {
if vis1.is_at_least(vis2, tcx) { vis2 } else { vis1 }
}
@ -384,14 +384,14 @@ impl<'a, 'tcx, VL: VisibilityLike> DefIdVisitor<'tcx> for FindMin<'a, 'tcx, VL>
trait VisibilityLike: Sized {
const MAX: Self;
const SHALLOW: bool = false;
fn new_min<'a, 'tcx>(find: &FindMin<'a, 'tcx, Self>, def_id: DefId) -> Self;
fn new_min(find: &FindMin<'_, '_, Self>, def_id: DefId) -> Self;
// Returns an over-approximation (`skip_assoc_tys` = true) of visibility due to
// associated types for which we can't determine visibility precisely.
fn of_impl<'a, 'tcx>(
fn of_impl(
hir_id: hir::HirId,
tcx: TyCtxt<'tcx>,
access_levels: &'a AccessLevels,
tcx: TyCtxt<'_>,
access_levels: &AccessLevels,
) -> Self {
let mut find = FindMin { tcx, access_levels, min: Self::MAX };
let def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
@ -404,7 +404,7 @@ trait VisibilityLike: Sized {
}
impl VisibilityLike for ty::Visibility {
const MAX: Self = ty::Visibility::Public;
fn new_min<'a, 'tcx>(find: &FindMin<'a, 'tcx, Self>, def_id: DefId) -> Self {
fn new_min(find: &FindMin<'_, '_, Self>, def_id: DefId) -> Self {
min(def_id_visibility(find.tcx, def_id).0, find.min, find.tcx)
}
}
@ -420,7 +420,7 @@ impl VisibilityLike for Option<AccessLevel> {
// both "shallow" version of its self type and "shallow" version of its trait if it exists
// (which require reaching the `DefId`s in them).
const SHALLOW: bool = true;
fn new_min<'a, 'tcx>(find: &FindMin<'a, 'tcx, Self>, def_id: DefId) -> Self {
fn new_min(find: &FindMin<'_, '_, Self>, def_id: DefId) -> Self {
cmp::min(if let Some(hir_id) = find.tcx.hir().as_local_hir_id(def_id) {
find.access_levels.map.get(&hir_id).cloned()
} else {
@ -1828,7 +1828,7 @@ pub fn provide(providers: &mut Providers<'_>) {
};
}
fn check_mod_privacy<'tcx>(tcx: TyCtxt<'tcx>, module_def_id: DefId) {
fn check_mod_privacy(tcx: TyCtxt<'_>, module_def_id: DefId) {
let empty_tables = ty::TypeckTables::empty(None);
// Check privacy of names not checked in previous compilation stages.
@ -1855,7 +1855,7 @@ fn check_mod_privacy<'tcx>(tcx: TyCtxt<'tcx>, module_def_id: DefId) {
intravisit::walk_mod(&mut visitor, module, hir_id);
}
fn privacy_access_levels<'tcx>(tcx: TyCtxt<'tcx>, krate: CrateNum) -> &'tcx AccessLevels {
fn privacy_access_levels(tcx: TyCtxt<'_>, krate: CrateNum) -> &AccessLevels {
assert_eq!(krate, LOCAL_CRATE);
// Build up a set of all exported items in the AST. This is a set of all
@ -1879,7 +1879,7 @@ fn privacy_access_levels<'tcx>(tcx: TyCtxt<'tcx>, krate: CrateNum) -> &'tcx Acce
tcx.arena.alloc(visitor.access_levels)
}
fn check_private_in_public<'tcx>(tcx: TyCtxt<'tcx>, krate: CrateNum) {
fn check_private_in_public(tcx: TyCtxt<'_>, krate: CrateNum) {
assert_eq!(krate, LOCAL_CRATE);
let access_levels = tcx.privacy_access_levels(LOCAL_CRATE);

View File

@ -198,9 +198,9 @@ enum ResolutionError<'a> {
///
/// This takes the error provided, combines it with the span and any additional spans inside the
/// error and emits it.
fn resolve_error<'sess, 'a>(resolver: &'sess Resolver<'_>,
span: Span,
resolution_error: ResolutionError<'a>) {
fn resolve_error(resolver: &Resolver<'_>,
span: Span,
resolution_error: ResolutionError<'_>) {
resolve_struct_error(resolver, span, resolution_error).emit();
}

View File

@ -15,7 +15,7 @@ use crate::lowering::Lower;
use crate::generic_types;
use std::iter;
crate fn wf_clause_for_raw_ptr<'tcx>(tcx: TyCtxt<'tcx>, mutbl: hir::Mutability) -> Clauses<'tcx> {
crate fn wf_clause_for_raw_ptr(tcx: TyCtxt<'_>, mutbl: hir::Mutability) -> Clauses<'_> {
let ptr_ty = generic_types::raw_ptr(tcx, mutbl);
let wf_clause = ProgramClause {
@ -29,13 +29,13 @@ crate fn wf_clause_for_raw_ptr<'tcx>(tcx: TyCtxt<'tcx>, mutbl: hir::Mutability)
tcx.mk_clauses(iter::once(wf_clause))
}
crate fn wf_clause_for_fn_ptr<'tcx>(
tcx: TyCtxt<'tcx>,
crate fn wf_clause_for_fn_ptr(
tcx: TyCtxt<'_>,
arity_and_output: usize,
variadic: bool,
unsafety: hir::Unsafety,
abi: abi::Abi,
) -> Clauses<'tcx> {
) -> Clauses<'_> {
let fn_ptr = generic_types::fn_ptr(tcx, arity_and_output, variadic, unsafety, abi);
let wf_clause = ProgramClause {
@ -50,7 +50,7 @@ crate fn wf_clause_for_fn_ptr<'tcx>(
tcx.mk_clauses(iter::once(wf_clause))
}
crate fn wf_clause_for_slice<'tcx>(tcx: TyCtxt<'tcx>) -> Clauses<'tcx> {
crate fn wf_clause_for_slice(tcx: TyCtxt<'_>) -> Clauses<'_> {
let ty = generic_types::bound(tcx, 0);
let slice_ty = tcx.mk_slice(ty);
@ -111,7 +111,7 @@ crate fn wf_clause_for_array<'tcx>(
tcx.mk_clauses(iter::once(wf_clause))
}
crate fn wf_clause_for_tuple<'tcx>(tcx: TyCtxt<'tcx>, arity: usize) -> Clauses<'tcx> {
crate fn wf_clause_for_tuple(tcx: TyCtxt<'_>, arity: usize) -> Clauses<'_> {
let type_list = generic_types::type_list(tcx, arity);
let tuple_ty = tcx.mk_ty(ty::Tuple(type_list));
@ -152,7 +152,7 @@ crate fn wf_clause_for_tuple<'tcx>(tcx: TyCtxt<'tcx>, arity: usize) -> Clauses<'
tcx.mk_clauses(iter::once(wf_clause))
}
crate fn wf_clause_for_ref<'tcx>(tcx: TyCtxt<'tcx>, mutbl: hir::Mutability) -> Clauses<'tcx> {
crate fn wf_clause_for_ref(tcx: TyCtxt<'_>, mutbl: hir::Mutability) -> Clauses<'_> {
let region = tcx.mk_region(
ty::ReLateBound(ty::INNERMOST, ty::BoundRegion::BrAnon(0))
);
@ -176,7 +176,7 @@ crate fn wf_clause_for_ref<'tcx>(tcx: TyCtxt<'tcx>, mutbl: hir::Mutability) -> C
tcx.mk_clauses(iter::once(wf_clause))
}
crate fn wf_clause_for_fn_def<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> Clauses<'tcx> {
crate fn wf_clause_for_fn_def(tcx: TyCtxt<'_>, def_id: DefId) -> Clauses<'_> {
let fn_def = generic_types::fn_def(tcx, def_id);
let wf_clause = ProgramClause {

View File

@ -279,10 +279,10 @@ fn dtorck_constraint_for_ty<'tcx>(
}
/// Calculates the dtorck constraint for a type.
crate fn adt_dtorck_constraint<'tcx>(
tcx: TyCtxt<'tcx>,
crate fn adt_dtorck_constraint(
tcx: TyCtxt<'_>,
def_id: DefId,
) -> Result<DtorckConstraint<'tcx>, NoSolution> {
) -> Result<DtorckConstraint<'_>, NoSolution> {
let def = tcx.adt_def(def_id);
let span = tcx.def_span(def_id);
debug!("dtorck_constraint: {:?}", def);
@ -313,7 +313,7 @@ crate fn adt_dtorck_constraint<'tcx>(
Ok(result)
}
fn dedup_dtorck_constraint<'tcx>(c: &mut DtorckConstraint<'tcx>) {
fn dedup_dtorck_constraint(c: &mut DtorckConstraint<'_>) {
let mut outlives = FxHashSet::default();
let mut dtorck_types = FxHashSet::default();

Some files were not shown because too many files have changed in this diff Show More