1 //! Name resolution for lifetimes: type declarations.
5 use rustc_data_structures::fx::FxHashMap;
6 use rustc_hir::def_id::DefId;
7 use rustc_hir::{ItemLocalId, OwnerId};
8 use rustc_macros::HashStable;
10 #[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable, Debug, HashStable)]
13 EarlyBound(/* lifetime decl */ DefId),
14 LateBound(ty::DebruijnIndex, /* late-bound index */ u32, /* lifetime decl */ DefId),
15 Free(DefId, /* lifetime decl */ DefId),
18 /// A set containing, at most, one known element.
19 /// If two distinct values are inserted into a set, then it
20 /// becomes `Many`, which can be used to detect ambiguities.
21 #[derive(Copy, Clone, PartialEq, Eq, TyEncodable, TyDecodable, Debug, HashStable)]
28 impl<T: PartialEq> Set1<T> {
29 pub fn insert(&mut self, value: T) {
31 Set1::Empty => Set1::One(value),
32 Set1::One(old) if *old == value => return,
38 #[derive(Copy, Clone, Debug, HashStable, Encodable, Decodable)]
39 pub enum ObjectLifetimeDefault {
46 /// Maps the id of each lifetime reference to the lifetime decl
47 /// that it corresponds to.
48 #[derive(Default, HashStable, Debug)]
49 pub struct ResolveLifetimes {
50 /// Maps from every use of a named (not anonymous) lifetime to a
51 /// `Region` describing how that region is bound
52 pub defs: FxHashMap<OwnerId, FxHashMap<ItemLocalId, Region>>,
54 pub late_bound_vars: FxHashMap<OwnerId, FxHashMap<ItemLocalId, Vec<ty::BoundVariableKind>>>,