Skip to content

Commit

Permalink
Rollup merge of rust-lang#65824 - eddyb:def-key-copy, r=varkor
Browse files Browse the repository at this point in the history
rustc: make DefPathData (and friends) Copy (now that it uses Symbol).

Spotted this while working on something else.
  • Loading branch information
Centril authored Oct 26, 2019
2 parents 7325a88 + 595d19e commit 84b62a0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/librustc/hir/map/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl DefPathTable {

#[inline(always)]
pub fn def_key(&self, index: DefIndex) -> DefKey {
self.index_to_key[index.index()].clone()
self.index_to_key[index.index()]
}

#[inline(always)]
Expand Down Expand Up @@ -111,7 +111,7 @@ pub struct Definitions {
/// A unique identifier that we can use to lookup a definition
/// precisely. It combines the index of the definition's parent (if
/// any) with a `DisambiguatedDefPathData`.
#[derive(Clone, PartialEq, Debug, RustcEncodable, RustcDecodable)]
#[derive(Copy, Clone, PartialEq, Debug, RustcEncodable, RustcDecodable)]
pub struct DefKey {
/// The parent path.
pub parent: Option<DefIndex>,
Expand Down Expand Up @@ -164,7 +164,7 @@ impl DefKey {
/// between them. This introduces some artificial ordering dependency
/// but means that if you have, e.g., two impls for the same type in
/// the same module, they do get distinct `DefId`s.
#[derive(Clone, PartialEq, Debug, RustcEncodable, RustcDecodable)]
#[derive(Copy, Clone, PartialEq, Debug, RustcEncodable, RustcDecodable)]
pub struct DisambiguatedDefPathData {
pub data: DefPathData,
pub disambiguator: u32
Expand Down Expand Up @@ -277,7 +277,7 @@ impl DefPath {
}
}

#[derive(Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
pub enum DefPathData {
// Root: these should only be used for the root nodes, because
// they are treated specially by the `def_path` function.
Expand Down Expand Up @@ -359,7 +359,7 @@ impl Definitions {

#[inline]
pub fn opt_def_index(&self, node: ast::NodeId) -> Option<DefIndex> {
self.node_to_def_index.get(&node).cloned()
self.node_to_def_index.get(&node).copied()
}

#[inline]
Expand Down Expand Up @@ -413,7 +413,7 @@ impl Definitions {
#[inline]
pub fn opt_span(&self, def_id: DefId) -> Option<Span> {
if def_id.krate == LOCAL_CRATE {
self.def_index_to_span.get(&def_id.index).cloned()
self.def_index_to_span.get(&def_id.index).copied()
} else {
None
}
Expand Down Expand Up @@ -472,7 +472,7 @@ impl Definitions {

// Find the next free disambiguator for this key.
let disambiguator = {
let next_disamb = self.next_disambiguator.entry((parent, data.clone())).or_insert(0);
let next_disamb = self.next_disambiguator.entry((parent, data)).or_insert(0);
let disambiguator = *next_disamb;
*next_disamb = next_disamb.checked_add(1).expect("disambiguator overflow");
disambiguator
Expand Down Expand Up @@ -525,7 +525,7 @@ impl Definitions {
}

pub fn expansion_that_defined(&self, index: DefIndex) -> ExpnId {
self.expansions_that_defined.get(&index).cloned().unwrap_or(ExpnId::root())
self.expansions_that_defined.get(&index).copied().unwrap_or(ExpnId::root())
}

pub fn parent_module_of_macro_def(&self, expn_id: ExpnId) -> DefId {
Expand Down

0 comments on commit 84b62a0

Please sign in to comment.