mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-29 20:46:07 +03:00
Track lifetime_elision_allowed per owner, and discard fn ptr and Fn() syntax registrations of it, they are never used
This commit is contained in:
@@ -321,10 +321,6 @@ fn delegation_info(&self, id: LocalDefId) -> Option<&DelegationInfo> {
|
||||
fn owner_def_id(&self, id: NodeId) -> LocalDefId {
|
||||
self.owners[&id].def_id
|
||||
}
|
||||
|
||||
fn lifetime_elision_allowed(&self, id: NodeId) -> bool {
|
||||
self.lifetime_elision_allowed.contains(&id)
|
||||
}
|
||||
}
|
||||
|
||||
/// How relaxed bounds `?Trait` should be treated.
|
||||
@@ -1866,7 +1862,9 @@ fn lower_fn_decl(
|
||||
_ => hir::ImplicitSelfKind::None,
|
||||
}
|
||||
}))
|
||||
.set_lifetime_elision_allowed(self.resolver.lifetime_elision_allowed(fn_node_id))
|
||||
.set_lifetime_elision_allowed(
|
||||
self.owner.id == fn_node_id && self.owner.lifetime_elision_allowed,
|
||||
)
|
||||
.set_c_variadic(c_variadic);
|
||||
|
||||
self.arena.alloc(hir::FnDecl { inputs, output, fn_decl_kind })
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
use rustc_ast::expand::typetree::{FncTree, Kind, Type, TypeTree};
|
||||
use rustc_ast::node_id::NodeMap;
|
||||
pub use rustc_ast_ir::{Movability, Mutability, try_visit};
|
||||
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
|
||||
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
|
||||
use rustc_data_structures::intern::Interned;
|
||||
use rustc_data_structures::stable_hash::{StableHash, StableHashCtxt, StableHasher};
|
||||
use rustc_data_structures::steal::Steal;
|
||||
@@ -207,6 +207,9 @@ pub struct ResolverGlobalCtxt {
|
||||
#[derive(Debug)]
|
||||
pub struct PerOwnerResolverData {
|
||||
pub node_id_to_def_id: NodeMap<LocalDefId> = Default::default(),
|
||||
/// Whether lifetime elision was successful.
|
||||
pub lifetime_elision_allowed: bool = false,
|
||||
|
||||
/// The id of the owner
|
||||
pub id: ast::NodeId,
|
||||
/// The `DefId` of the owner, can't be found in `node_id_to_def_id`.
|
||||
@@ -239,8 +242,6 @@ pub struct ResolverAstLowering<'tcx> {
|
||||
pub owners: NodeMap<PerOwnerResolverData>,
|
||||
|
||||
pub trait_map: NodeMap<&'tcx [hir::TraitCandidate<'tcx>]>,
|
||||
/// List functions and methods for which lifetime elision was successful.
|
||||
pub lifetime_elision_allowed: FxHashSet<ast::NodeId>,
|
||||
|
||||
/// Lints that were emitted by the resolver and early lints.
|
||||
pub lint_buffer: Steal<LintBuffer>,
|
||||
|
||||
@@ -2456,7 +2456,9 @@ fn resolve_fn_signature(
|
||||
|
||||
let outer_failures = take(&mut this.diag_metadata.current_elision_failures);
|
||||
let output_rib = if let Ok(res) = elision_lifetime.as_ref() {
|
||||
this.r.lifetime_elision_allowed.insert(fn_id);
|
||||
if fn_id == this.r.current_owner.id {
|
||||
this.r.current_owner.lifetime_elision_allowed = true;
|
||||
}
|
||||
LifetimeRibKind::Elided(*res)
|
||||
} else {
|
||||
LifetimeRibKind::ElisionFailure
|
||||
|
||||
@@ -1533,8 +1533,6 @@ pub struct Resolver<'ra, 'tcx> {
|
||||
/// they are declared in the static array generated by proc_macro_harness.
|
||||
proc_macros: Vec<LocalDefId> = Vec::new(),
|
||||
confused_type_with_std_module: FxIndexMap<Span, Span>,
|
||||
/// Whether lifetime elision was successful.
|
||||
lifetime_elision_allowed: FxHashSet<NodeId> = default::fx_hash_set(),
|
||||
|
||||
/// Names of items that were stripped out via cfg with their corresponding cfg meta item.
|
||||
stripped_cfg_items: Vec<StrippedCfgItem<NodeId>> = Vec::new(),
|
||||
@@ -2023,7 +2021,6 @@ pub fn into_outputs(self) -> ResolverOutputs<'tcx> {
|
||||
next_node_id: self.next_node_id,
|
||||
owners: self.owners,
|
||||
trait_map: self.trait_map,
|
||||
lifetime_elision_allowed: self.lifetime_elision_allowed,
|
||||
lint_buffer: Steal::new(self.lint_buffer),
|
||||
delegation_infos: self.delegation_infos,
|
||||
disambiguators,
|
||||
|
||||
Reference in New Issue
Block a user