Remove unnecessary predefined symbol clones
Now that they're const it's no longer needed.
Nothing manual was performed: only a regexp search of `sym::([\w][\w\d]*)\.clone\(\)` and replace by `sym::$1`.
diff --git a/crates/cfg/src/lib.rs b/crates/cfg/src/lib.rs
index 86a7ea9..f17e0ea 100644
--- a/crates/cfg/src/lib.rs
+++ b/crates/cfg/src/lib.rs
@@ -31,7 +31,7 @@
impl Default for CfgOptions {
fn default() -> Self {
- Self { enabled: FxHashSet::from_iter([CfgAtom::Flag(sym::true_.clone())]) }
+ Self { enabled: FxHashSet::from_iter([CfgAtom::Flag(sym::true_)]) }
}
}
diff --git a/crates/hir-def/src/attr.rs b/crates/hir-def/src/attr.rs
index a3741e8..a80313a 100644
--- a/crates/hir-def/src/attr.rs
+++ b/crates/hir-def/src/attr.rs
@@ -217,11 +217,7 @@
.segments()
.iter()
.rev()
- .zip(
- [sym::core.clone(), sym::prelude.clone(), sym::v1.clone(), sym::test.clone()]
- .iter()
- .rev(),
- )
+ .zip([sym::core, sym::prelude, sym::v1, sym::test].iter().rev())
.all(|it| it.0 == it.1)
})
}
diff --git a/crates/hir-def/src/builtin_type.rs b/crates/hir-def/src/builtin_type.rs
index 6ea2135..8b61c6a 100644
--- a/crates/hir-def/src/builtin_type.rs
+++ b/crates/hir-def/src/builtin_type.rs
@@ -51,28 +51,28 @@
#[rustfmt::skip]
pub fn all_builtin_types() -> [(Name, BuiltinType); 19] {
[
- (Name::new_symbol_root(sym::char.clone()), BuiltinType::Char),
- (Name::new_symbol_root(sym::bool.clone()), BuiltinType::Bool),
- (Name::new_symbol_root(sym::str.clone()), BuiltinType::Str),
+ (Name::new_symbol_root(sym::char), BuiltinType::Char),
+ (Name::new_symbol_root(sym::bool), BuiltinType::Bool),
+ (Name::new_symbol_root(sym::str), BuiltinType::Str),
- (Name::new_symbol_root(sym::isize.clone()), BuiltinType::Int(BuiltinInt::Isize)),
- (Name::new_symbol_root(sym::i8.clone()), BuiltinType::Int(BuiltinInt::I8)),
- (Name::new_symbol_root(sym::i16.clone()), BuiltinType::Int(BuiltinInt::I16)),
- (Name::new_symbol_root(sym::i32.clone()), BuiltinType::Int(BuiltinInt::I32)),
- (Name::new_symbol_root(sym::i64.clone()), BuiltinType::Int(BuiltinInt::I64)),
- (Name::new_symbol_root(sym::i128.clone()), BuiltinType::Int(BuiltinInt::I128)),
+ (Name::new_symbol_root(sym::isize), BuiltinType::Int(BuiltinInt::Isize)),
+ (Name::new_symbol_root(sym::i8), BuiltinType::Int(BuiltinInt::I8)),
+ (Name::new_symbol_root(sym::i16), BuiltinType::Int(BuiltinInt::I16)),
+ (Name::new_symbol_root(sym::i32), BuiltinType::Int(BuiltinInt::I32)),
+ (Name::new_symbol_root(sym::i64), BuiltinType::Int(BuiltinInt::I64)),
+ (Name::new_symbol_root(sym::i128), BuiltinType::Int(BuiltinInt::I128)),
- (Name::new_symbol_root(sym::usize.clone()), BuiltinType::Uint(BuiltinUint::Usize)),
- (Name::new_symbol_root(sym::u8.clone()), BuiltinType::Uint(BuiltinUint::U8)),
- (Name::new_symbol_root(sym::u16.clone()), BuiltinType::Uint(BuiltinUint::U16)),
- (Name::new_symbol_root(sym::u32.clone()), BuiltinType::Uint(BuiltinUint::U32)),
- (Name::new_symbol_root(sym::u64.clone()), BuiltinType::Uint(BuiltinUint::U64)),
- (Name::new_symbol_root(sym::u128.clone()), BuiltinType::Uint(BuiltinUint::U128)),
+ (Name::new_symbol_root(sym::usize), BuiltinType::Uint(BuiltinUint::Usize)),
+ (Name::new_symbol_root(sym::u8), BuiltinType::Uint(BuiltinUint::U8)),
+ (Name::new_symbol_root(sym::u16), BuiltinType::Uint(BuiltinUint::U16)),
+ (Name::new_symbol_root(sym::u32), BuiltinType::Uint(BuiltinUint::U32)),
+ (Name::new_symbol_root(sym::u64), BuiltinType::Uint(BuiltinUint::U64)),
+ (Name::new_symbol_root(sym::u128), BuiltinType::Uint(BuiltinUint::U128)),
- (Name::new_symbol_root(sym::f16.clone()), BuiltinType::Float(BuiltinFloat::F16)),
- (Name::new_symbol_root(sym::f32.clone()), BuiltinType::Float(BuiltinFloat::F32)),
- (Name::new_symbol_root(sym::f64.clone()), BuiltinType::Float(BuiltinFloat::F64)),
- (Name::new_symbol_root(sym::f128.clone()), BuiltinType::Float(BuiltinFloat::F128)),
+ (Name::new_symbol_root(sym::f16), BuiltinType::Float(BuiltinFloat::F16)),
+ (Name::new_symbol_root(sym::f32), BuiltinType::Float(BuiltinFloat::F32)),
+ (Name::new_symbol_root(sym::f64), BuiltinType::Float(BuiltinFloat::F64)),
+ (Name::new_symbol_root(sym::f128), BuiltinType::Float(BuiltinFloat::F128)),
]
}
@@ -86,30 +86,30 @@
impl AsName for BuiltinType {
fn as_name(&self) -> Name {
match self {
- BuiltinType::Char => Name::new_symbol_root(sym::char.clone()),
- BuiltinType::Bool => Name::new_symbol_root(sym::bool.clone()),
- BuiltinType::Str => Name::new_symbol_root(sym::str.clone()),
+ BuiltinType::Char => Name::new_symbol_root(sym::char),
+ BuiltinType::Bool => Name::new_symbol_root(sym::bool),
+ BuiltinType::Str => Name::new_symbol_root(sym::str),
BuiltinType::Int(it) => match it {
- BuiltinInt::Isize => Name::new_symbol_root(sym::isize.clone()),
- BuiltinInt::I8 => Name::new_symbol_root(sym::i8.clone()),
- BuiltinInt::I16 => Name::new_symbol_root(sym::i16.clone()),
- BuiltinInt::I32 => Name::new_symbol_root(sym::i32.clone()),
- BuiltinInt::I64 => Name::new_symbol_root(sym::i64.clone()),
- BuiltinInt::I128 => Name::new_symbol_root(sym::i128.clone()),
+ BuiltinInt::Isize => Name::new_symbol_root(sym::isize),
+ BuiltinInt::I8 => Name::new_symbol_root(sym::i8),
+ BuiltinInt::I16 => Name::new_symbol_root(sym::i16),
+ BuiltinInt::I32 => Name::new_symbol_root(sym::i32),
+ BuiltinInt::I64 => Name::new_symbol_root(sym::i64),
+ BuiltinInt::I128 => Name::new_symbol_root(sym::i128),
},
BuiltinType::Uint(it) => match it {
- BuiltinUint::Usize => Name::new_symbol_root(sym::usize.clone()),
- BuiltinUint::U8 => Name::new_symbol_root(sym::u8.clone()),
- BuiltinUint::U16 => Name::new_symbol_root(sym::u16.clone()),
- BuiltinUint::U32 => Name::new_symbol_root(sym::u32.clone()),
- BuiltinUint::U64 => Name::new_symbol_root(sym::u64.clone()),
- BuiltinUint::U128 => Name::new_symbol_root(sym::u128.clone()),
+ BuiltinUint::Usize => Name::new_symbol_root(sym::usize),
+ BuiltinUint::U8 => Name::new_symbol_root(sym::u8),
+ BuiltinUint::U16 => Name::new_symbol_root(sym::u16),
+ BuiltinUint::U32 => Name::new_symbol_root(sym::u32),
+ BuiltinUint::U64 => Name::new_symbol_root(sym::u64),
+ BuiltinUint::U128 => Name::new_symbol_root(sym::u128),
},
BuiltinType::Float(it) => match it {
- BuiltinFloat::F16 => Name::new_symbol_root(sym::f16.clone()),
- BuiltinFloat::F32 => Name::new_symbol_root(sym::f32.clone()),
- BuiltinFloat::F64 => Name::new_symbol_root(sym::f64.clone()),
- BuiltinFloat::F128 => Name::new_symbol_root(sym::f128.clone()),
+ BuiltinFloat::F16 => Name::new_symbol_root(sym::f16),
+ BuiltinFloat::F32 => Name::new_symbol_root(sym::f32),
+ BuiltinFloat::F64 => Name::new_symbol_root(sym::f64),
+ BuiltinFloat::F128 => Name::new_symbol_root(sym::f128),
},
}
}
diff --git a/crates/hir-def/src/db.rs b/crates/hir-def/src/db.rs
index a5e58ec..34cf42d 100644
--- a/crates/hir-def/src/db.rs
+++ b/crates/hir-def/src/db.rs
@@ -387,8 +387,8 @@
let attrs = item_tree.raw_attrs(AttrOwner::TopLevel);
for attr in &**attrs {
match attr.path().as_ident() {
- Some(ident) if *ident == sym::no_std.clone() => return true,
- Some(ident) if *ident == sym::cfg_attr.clone() => {}
+ Some(ident) if *ident == sym::no_std => return true,
+ Some(ident) if *ident == sym::cfg_attr => {}
_ => continue,
}
diff --git a/crates/hir-def/src/expr_store/lower.rs b/crates/hir-def/src/expr_store/lower.rs
index cda8605..d12b85f 100644
--- a/crates/hir-def/src/expr_store/lower.rs
+++ b/crates/hir-def/src/expr_store/lower.rs
@@ -105,7 +105,7 @@
let is_mutable =
self_param_syn.mut_token().is_some() && self_param_syn.amp_token().is_none();
let binding_id: la_arena::Idx<Binding> = collector.alloc_binding(
- Name::new_symbol_root(sym::self_.clone()),
+ Name::new_symbol_root(sym::self_),
BindingAnnotation::new(is_mutable, false),
);
self_param = Some(binding_id);
@@ -137,7 +137,7 @@
let is_mutable =
self_param_syn.mut_token().is_some() && self_param_syn.amp_token().is_none();
let binding_id: la_arena::Idx<Binding> = collector.alloc_binding(
- Name::new_symbol_root(sym::self_.clone()),
+ Name::new_symbol_root(sym::self_),
BindingAnnotation::new(is_mutable, false),
);
let hygiene = self_param_syn
@@ -322,7 +322,7 @@
Some(ty) => collector.lower_type_ref(ty, &mut impl_trait_lower_fn),
None => {
let self_type = collector.alloc_type_ref_desugared(TypeRef::Path(
- Name::new_symbol_root(sym::Self_.clone()).into(),
+ Name::new_symbol_root(sym::Self_).into(),
));
let lifetime = param
.lifetime()
@@ -375,7 +375,7 @@
let mut generic_args: Vec<_> =
std::iter::repeat_n(None, path.segments().len() - 1).collect();
let binding = AssociatedTypeBinding {
- name: Name::new_symbol_root(sym::Output.clone()),
+ name: Name::new_symbol_root(sym::Output),
args: None,
type_ref: Some(
return_type
@@ -631,7 +631,7 @@
match abi.abi_string() {
Some(tok) => Symbol::intern(tok.text_without_quotes()),
// `extern` default to be `extern "C"`.
- _ => sym::C.clone(),
+ _ => sym::C,
}
}
@@ -760,7 +760,7 @@
let bindings = if let Some(ret_type) = ret_type {
let type_ref = self.lower_type_ref_opt(ret_type.ty(), impl_trait_lower_fn);
Box::new([AssociatedTypeBinding {
- name: Name::new_symbol_root(sym::Output.clone()),
+ name: Name::new_symbol_root(sym::Output),
args: None,
type_ref: Some(type_ref),
bounds: Box::default(),
@@ -769,7 +769,7 @@
// -> ()
let type_ref = self.alloc_type_ref_desugared(TypeRef::unit());
Box::new([AssociatedTypeBinding {
- name: Name::new_symbol_root(sym::Output.clone()),
+ name: Name::new_symbol_root(sym::Output),
args: None,
type_ref: Some(type_ref),
bounds: Box::default(),
@@ -2804,12 +2804,12 @@
let new_v1_formatted = LangItem::FormatArguments.ty_rel_path(
self.db,
self.module.krate(),
- Name::new_symbol_root(sym::new_v1_formatted.clone()),
+ Name::new_symbol_root(sym::new_v1_formatted),
);
let unsafe_arg_new = LangItem::FormatUnsafeArg.ty_rel_path(
self.db,
self.module.krate(),
- Name::new_symbol_root(sym::new.clone()),
+ Name::new_symbol_root(sym::new),
);
let new_v1_formatted =
self.alloc_expr_desugared(new_v1_formatted.map_or(Expr::Missing, Expr::Path));
@@ -2924,20 +2924,15 @@
Some(BuiltinUint::U32),
)));
- let position = RecordLitField {
- name: Name::new_symbol_root(sym::position.clone()),
- expr: position,
- };
- let flags =
- RecordLitField { name: Name::new_symbol_root(sym::flags.clone()), expr: flags };
+ let position =
+ RecordLitField { name: Name::new_symbol_root(sym::position), expr: position };
+ let flags = RecordLitField { name: Name::new_symbol_root(sym::flags), expr: flags };
let precision = RecordLitField {
- name: Name::new_symbol_root(sym::precision.clone()),
+ name: Name::new_symbol_root(sym::precision),
expr: precision_expr,
};
- let width = RecordLitField {
- name: Name::new_symbol_root(sym::width.clone()),
- expr: width_expr,
- };
+ let width =
+ RecordLitField { name: Name::new_symbol_root(sym::width), expr: width_expr };
self.alloc_expr_desugared(Expr::RecordLit {
path: LangItem::FormatPlaceholder.path(self.db, self.module.krate()).map(Box::new),
fields: Box::new([position, flags, precision, width]),
@@ -2948,7 +2943,7 @@
let format_placeholder_new = LangItem::FormatPlaceholder.ty_rel_path(
self.db,
self.module.krate(),
- Name::new_symbol_root(sym::new.clone()),
+ Name::new_symbol_root(sym::new),
);
match format_placeholder_new {
Some(path) => self.alloc_expr_desugared(Expr::Path(path)),
@@ -2972,10 +2967,10 @@
self.db,
self.module.krate(),
match alignment {
- Some(FormatAlignment::Left) => Name::new_symbol_root(sym::Left.clone()),
- Some(FormatAlignment::Right) => Name::new_symbol_root(sym::Right.clone()),
- Some(FormatAlignment::Center) => Name::new_symbol_root(sym::Center.clone()),
- None => Name::new_symbol_root(sym::Unknown.clone()),
+ Some(FormatAlignment::Left) => Name::new_symbol_root(sym::Left),
+ Some(FormatAlignment::Right) => Name::new_symbol_root(sym::Right),
+ Some(FormatAlignment::Center) => Name::new_symbol_root(sym::Center),
+ None => Name::new_symbol_root(sym::Unknown),
},
);
match align {
@@ -3024,7 +3019,7 @@
let count_is = match LangItem::FormatCount.ty_rel_path(
self.db,
self.module.krate(),
- Name::new_symbol_root(sym::Is.clone()),
+ Name::new_symbol_root(sym::Is),
) {
Some(count_is) => self.alloc_expr_desugared(Expr::Path(count_is)),
None => self.missing_expr(),
@@ -3042,7 +3037,7 @@
let count_param = match LangItem::FormatCount.ty_rel_path(
self.db,
self.module.krate(),
- Name::new_symbol_root(sym::Param.clone()),
+ Name::new_symbol_root(sym::Param),
) {
Some(count_param) => self.alloc_expr_desugared(Expr::Path(count_param)),
None => self.missing_expr(),
@@ -3060,7 +3055,7 @@
None => match LangItem::FormatCount.ty_rel_path(
self.db,
self.module.krate(),
- Name::new_symbol_root(sym::Implied.clone()),
+ Name::new_symbol_root(sym::Implied),
) {
Some(count_param) => self.alloc_expr_desugared(Expr::Path(count_param)),
None => self.missing_expr(),
@@ -3083,16 +3078,16 @@
self.db,
self.module.krate(),
Name::new_symbol_root(match ty {
- Format(Display) => sym::new_display.clone(),
- Format(Debug) => sym::new_debug.clone(),
- Format(LowerExp) => sym::new_lower_exp.clone(),
- Format(UpperExp) => sym::new_upper_exp.clone(),
- Format(Octal) => sym::new_octal.clone(),
- Format(Pointer) => sym::new_pointer.clone(),
- Format(Binary) => sym::new_binary.clone(),
- Format(LowerHex) => sym::new_lower_hex.clone(),
- Format(UpperHex) => sym::new_upper_hex.clone(),
- Usize => sym::from_usize.clone(),
+ Format(Display) => sym::new_display,
+ Format(Debug) => sym::new_debug,
+ Format(LowerExp) => sym::new_lower_exp,
+ Format(UpperExp) => sym::new_upper_exp,
+ Format(Octal) => sym::new_octal,
+ Format(Pointer) => sym::new_pointer,
+ Format(Binary) => sym::new_binary,
+ Format(LowerHex) => sym::new_lower_hex,
+ Format(UpperHex) => sym::new_upper_hex,
+ Usize => sym::from_usize,
}),
) {
Some(new_fn) => self.alloc_expr_desugared(Expr::Path(new_fn)),
diff --git a/crates/hir-def/src/expr_store/lower/generics.rs b/crates/hir-def/src/expr_store/lower/generics.rs
index 18cec77..4f14a7f 100644
--- a/crates/hir-def/src/expr_store/lower/generics.rs
+++ b/crates/hir-def/src/expr_store/lower/generics.rs
@@ -43,7 +43,7 @@
}
pub(crate) fn fill_self_param(&mut self, bounds: Option<ast::TypeBoundList>) {
- let self_ = Name::new_symbol_root(sym::Self_.clone());
+ let self_ = Name::new_symbol_root(sym::Self_);
let idx = self.type_or_consts.alloc(
TypeParamData {
name: Some(self_.clone()),
diff --git a/crates/hir-def/src/expr_store/lower/path.rs b/crates/hir-def/src/expr_store/lower/path.rs
index 5f847b6..36b3d11 100644
--- a/crates/hir-def/src/expr_store/lower/path.rs
+++ b/crates/hir-def/src/expr_store/lower/path.rs
@@ -105,7 +105,7 @@
push_segment(&segment, &mut segments, name);
}
ast::PathSegmentKind::SelfTypeKw => {
- push_segment(&segment, &mut segments, Name::new_symbol_root(sym::Self_.clone()));
+ push_segment(&segment, &mut segments, Name::new_symbol_root(sym::Self_));
}
ast::PathSegmentKind::Type { type_ref, trait_ref } => {
debug_assert!(path.qualifier().is_none()); // this can only occur at the first segment
diff --git a/crates/hir-def/src/item_tree/lower.rs b/crates/hir-def/src/item_tree/lower.rs
index 1c437a2..b490e16 100644
--- a/crates/hir-def/src/item_tree/lower.rs
+++ b/crates/hir-def/src/item_tree/lower.rs
@@ -532,7 +532,7 @@
match abi.abi_string() {
Some(tok) => Symbol::intern(tok.text_without_quotes()),
// `extern` default to be `extern "C"`.
- _ => sym::C.clone(),
+ _ => sym::C,
}
}
diff --git a/crates/hir-def/src/nameres/collector.rs b/crates/hir-def/src/nameres/collector.rs
index 92bf9c0..77effbc 100644
--- a/crates/hir-def/src/nameres/collector.rs
+++ b/crates/hir-def/src/nameres/collector.rs
@@ -268,24 +268,24 @@
let Some(attr_name) = attr.path.as_ident() else { continue };
match () {
- () if *attr_name == sym::recursion_limit.clone() => {
+ () if *attr_name == sym::recursion_limit => {
if let Some(limit) = attr.string_value() {
if let Ok(limit) = limit.as_str().parse() {
crate_data.recursion_limit = Some(limit);
}
}
}
- () if *attr_name == sym::crate_type.clone() => {
+ () if *attr_name == sym::crate_type => {
if attr.string_value() == Some(&sym::proc_dash_macro) {
self.is_proc_macro = true;
}
}
- () if *attr_name == sym::no_core.clone() => crate_data.no_core = true,
- () if *attr_name == sym::no_std.clone() => crate_data.no_std = true,
- () if *attr_name == sym::rustc_coherence_is_core.clone() => {
+ () if *attr_name == sym::no_core => crate_data.no_core = true,
+ () if *attr_name == sym::no_std => crate_data.no_std = true,
+ () if *attr_name == sym::rustc_coherence_is_core => {
crate_data.rustc_coherence_is_core = true;
}
- () if *attr_name == sym::feature.clone() => {
+ () if *attr_name == sym::feature => {
let features =
attr.parse_path_comma_token_tree(self.db).into_iter().flatten().filter_map(
|(feat, _)| match feat.segments() {
@@ -295,13 +295,13 @@
);
crate_data.unstable_features.extend(features);
}
- () if *attr_name == sym::register_attr.clone() => {
+ () if *attr_name == sym::register_attr => {
if let Some(ident) = attr.single_ident_value() {
crate_data.registered_attrs.push(ident.sym.clone());
cov_mark::hit!(register_attr);
}
}
- () if *attr_name == sym::register_tool.clone() => {
+ () if *attr_name == sym::register_tool => {
if let Some(ident) = attr.single_ident_value() {
crate_data.registered_tools.push(ident.sym.clone());
cov_mark::hit!(register_tool);
@@ -507,20 +507,20 @@
}
let krate = if self.def_map.data.no_std {
- Name::new_symbol_root(sym::core.clone())
- } else if self.local_def_map().extern_prelude().any(|(name, _)| *name == sym::std.clone()) {
- Name::new_symbol_root(sym::std.clone())
+ Name::new_symbol_root(sym::core)
+ } else if self.local_def_map().extern_prelude().any(|(name, _)| *name == sym::std) {
+ Name::new_symbol_root(sym::std)
} else {
// If `std` does not exist for some reason, fall back to core. This mostly helps
// keep r-a's own tests minimal.
- Name::new_symbol_root(sym::core.clone())
+ Name::new_symbol_root(sym::core)
};
let edition = match self.def_map.data.edition {
- Edition::Edition2015 => Name::new_symbol_root(sym::rust_2015.clone()),
- Edition::Edition2018 => Name::new_symbol_root(sym::rust_2018.clone()),
- Edition::Edition2021 => Name::new_symbol_root(sym::rust_2021.clone()),
- Edition::Edition2024 => Name::new_symbol_root(sym::rust_2024.clone()),
+ Edition::Edition2015 => Name::new_symbol_root(sym::rust_2015),
+ Edition::Edition2018 => Name::new_symbol_root(sym::rust_2018),
+ Edition::Edition2021 => Name::new_symbol_root(sym::rust_2021),
+ Edition::Edition2024 => Name::new_symbol_root(sym::rust_2024),
};
let path_kind = match self.def_map.data.edition {
@@ -529,7 +529,7 @@
};
let path = ModPath::from_segments(
path_kind,
- [krate, Name::new_symbol_root(sym::prelude.clone()), edition],
+ [krate, Name::new_symbol_root(sym::prelude), edition],
);
let (per_ns, _) = self.def_map.resolve_path(
@@ -1373,8 +1373,7 @@
MacroDefKind::BuiltInAttr(_, expander)
if expander.is_test() || expander.is_bench() || expander.is_test_case()
) {
- let test_is_active =
- self.cfg_options.check_atom(&CfgAtom::Flag(sym::test.clone()));
+ let test_is_active = self.cfg_options.check_atom(&CfgAtom::Flag(sym::test));
if test_is_active {
return recollect_without(self);
}
diff --git a/crates/hir-def/src/resolver.rs b/crates/hir-def/src/resolver.rs
index d2048c8..9b9335f 100644
--- a/crates/hir-def/src/resolver.rs
+++ b/crates/hir-def/src/resolver.rs
@@ -219,7 +219,7 @@
Scope::ExprScope(_) | Scope::MacroDefScope(_) => continue,
Scope::GenericParams { params, def } => {
if let &GenericDefId::ImplId(impl_) = def {
- if *first_name == sym::Self_.clone() {
+ if *first_name == sym::Self_ {
return Some((
TypeNs::SelfType(impl_),
remaining_idx(),
@@ -228,7 +228,7 @@
));
}
} else if let &GenericDefId::AdtId(adt) = def {
- if *first_name == sym::Self_.clone() {
+ if *first_name == sym::Self_ {
return Some((
TypeNs::AdtSelfType(adt),
remaining_idx(),
@@ -365,7 +365,7 @@
}
};
let n_segments = path.segments().len();
- let tmp = Name::new_symbol_root(sym::self_.clone());
+ let tmp = Name::new_symbol_root(sym::self_);
let first_name = if path.is_self() { &tmp } else { path.segments().first()? };
let skip_to_mod = path.kind != PathKind::Plain && !path.is_self();
if skip_to_mod {
@@ -397,7 +397,7 @@
}
Scope::GenericParams { params, def } => {
if let &GenericDefId::ImplId(impl_) = def {
- if *first_name == sym::Self_.clone() {
+ if *first_name == sym::Self_ {
return Some((
ResolveValueResult::ValueNs(ValueNs::ImplSelf(impl_), None),
ResolvePathResultPrefixInfo::default(),
@@ -425,14 +425,14 @@
Scope::ExprScope(_) | Scope::MacroDefScope(_) => continue,
Scope::GenericParams { params, def } => {
if let &GenericDefId::ImplId(impl_) = def {
- if *first_name == sym::Self_.clone() {
+ if *first_name == sym::Self_ {
return Some((
ResolveValueResult::Partial(TypeNs::SelfType(impl_), 1, None),
ResolvePathResultPrefixInfo::default(),
));
}
} else if let &GenericDefId::AdtId(adt) = def {
- if *first_name == sym::Self_.clone() {
+ if *first_name == sym::Self_ {
let ty = TypeNs::AdtSelfType(adt);
return Some((
ResolveValueResult::Partial(ty, 1, None),
@@ -1004,12 +1004,9 @@
}
&Scope::GenericParams { ref params, def: parent } => {
if let GenericDefId::ImplId(impl_) = parent {
- acc.add(
- &Name::new_symbol_root(sym::Self_.clone()),
- ScopeDef::ImplSelfType(impl_),
- );
+ acc.add(&Name::new_symbol_root(sym::Self_), ScopeDef::ImplSelfType(impl_));
} else if let GenericDefId::AdtId(adt) = parent {
- acc.add(&Name::new_symbol_root(sym::Self_.clone()), ScopeDef::AdtSelfType(adt));
+ acc.add(&Name::new_symbol_root(sym::Self_), ScopeDef::AdtSelfType(adt));
}
for (local_id, param) in params.iter_type_or_consts() {
diff --git a/crates/hir-def/src/signatures.rs b/crates/hir-def/src/signatures.rs
index 3645e19..389ef6d 100644
--- a/crates/hir-def/src/signatures.rs
+++ b/crates/hir-def/src/signatures.rs
@@ -566,8 +566,7 @@
}
let abi = source.value.abi().map(|abi| {
- abi.abi_string()
- .map_or_else(|| sym::C.clone(), |it| Symbol::intern(it.text_without_quotes()))
+ abi.abi_string().map_or_else(|| sym::C, |it| Symbol::intern(it.text_without_quotes()))
});
let (store, source_map, generic_params, params, ret_type, self_param, variadic) =
lower_function(db, module, source, id);
diff --git a/crates/hir-expand/src/attrs.rs b/crates/hir-expand/src/attrs.rs
index 4331997..5dae27f 100644
--- a/crates/hir-expand/src/attrs.rs
+++ b/crates/hir-expand/src/attrs.rs
@@ -66,10 +66,7 @@
kind,
suffix: None,
}))),
- path: Interned::new(ModPath::from(Name::new_symbol(
- sym::doc.clone(),
- span.ctx,
- ))),
+ path: Interned::new(ModPath::from(Name::new_symbol(sym::doc, span.ctx))),
ctxt: span.ctx,
}
}),
@@ -120,48 +117,47 @@
/// Processes `cfg_attr`s, returning the resulting semantic `Attrs`.
// FIXME: This should return a different type, signaling it was filtered?
pub fn filter(self, db: &dyn ExpandDatabase, krate: Crate) -> RawAttrs {
- let has_cfg_attrs = self
- .iter()
- .any(|attr| attr.path.as_ident().is_some_and(|name| *name == sym::cfg_attr.clone()));
+ let has_cfg_attrs =
+ self.iter().any(|attr| attr.path.as_ident().is_some_and(|name| *name == sym::cfg_attr));
if !has_cfg_attrs {
return self;
}
let cfg_options = krate.cfg_options(db);
- let new_attrs =
- self.iter()
- .flat_map(|attr| -> SmallVec<[_; 1]> {
- let is_cfg_attr =
- attr.path.as_ident().is_some_and(|name| *name == sym::cfg_attr.clone());
- if !is_cfg_attr {
- return smallvec![attr.clone()];
- }
+ let new_attrs = self
+ .iter()
+ .flat_map(|attr| -> SmallVec<[_; 1]> {
+ let is_cfg_attr = attr.path.as_ident().is_some_and(|name| *name == sym::cfg_attr);
+ if !is_cfg_attr {
+ return smallvec![attr.clone()];
+ }
- let subtree = match attr.token_tree_value() {
- Some(it) => it,
- _ => return smallvec![attr.clone()],
- };
+ let subtree = match attr.token_tree_value() {
+ Some(it) => it,
+ _ => return smallvec![attr.clone()],
+ };
- let (cfg, parts) = match parse_cfg_attr_input(subtree) {
- Some(it) => it,
- None => return smallvec![attr.clone()],
- };
- let index = attr.id;
- let attrs = parts.enumerate().take(1 << AttrId::CFG_ATTR_BITS).filter_map(
- |(idx, attr)| Attr::from_tt(db, attr, index.with_cfg_attr(idx)),
- );
+ let (cfg, parts) = match parse_cfg_attr_input(subtree) {
+ Some(it) => it,
+ None => return smallvec![attr.clone()],
+ };
+ let index = attr.id;
+ let attrs = parts
+ .enumerate()
+ .take(1 << AttrId::CFG_ATTR_BITS)
+ .filter_map(|(idx, attr)| Attr::from_tt(db, attr, index.with_cfg_attr(idx)));
- let cfg = TopSubtree::from_token_trees(subtree.top_subtree().delimiter, cfg);
- let cfg = CfgExpr::parse(&cfg);
- if cfg_options.check(&cfg) == Some(false) {
- smallvec![]
- } else {
- cov_mark::hit!(cfg_attr_active);
+ let cfg = TopSubtree::from_token_trees(subtree.top_subtree().delimiter, cfg);
+ let cfg = CfgExpr::parse(&cfg);
+ if cfg_options.check(&cfg) == Some(false) {
+ smallvec![]
+ } else {
+ cov_mark::hit!(cfg_attr_active);
- attrs.collect()
- }
- })
- .collect::<Vec<_>>();
+ attrs.collect()
+ }
+ })
+ .collect::<Vec<_>>();
let entries = if new_attrs.is_empty() {
None
} else {
@@ -401,7 +397,7 @@
}
pub fn cfg(&self) -> Option<CfgExpr> {
- if *self.path.as_ident()? == sym::cfg.clone() {
+ if *self.path.as_ident()? == sym::cfg {
self.token_tree_value().map(CfgExpr::parse)
} else {
None
diff --git a/crates/hir-expand/src/builtin/fn_macro.rs b/crates/hir-expand/src/builtin/fn_macro.rs
index b99eac7..621e174 100644
--- a/crates/hir-expand/src/builtin/fn_macro.rs
+++ b/crates/hir-expand/src/builtin/fn_macro.rs
@@ -177,10 +177,10 @@
ExpandResult::ok(tt::TopSubtree::invisible_from_leaves(
span,
[tt::Leaf::Literal(tt::Literal {
- symbol: sym::INTEGER_0.clone(),
+ symbol: sym::INTEGER_0,
span,
kind: tt::LitKind::Integer,
- suffix: Some(sym::u32.clone()),
+ suffix: Some(sym::u32),
})],
))
}
@@ -347,11 +347,7 @@
let dollar_crate = dollar_crate(span);
let call_site_span = span_with_call_site_ctxt(db, span, id.into(), Edition::CURRENT);
- let mac = if use_panic_2021(db, call_site_span) {
- sym::panic_2021.clone()
- } else {
- sym::panic_2015.clone()
- };
+ let mac = if use_panic_2021(db, call_site_span) { sym::panic_2021 } else { sym::panic_2015 };
// Pass the original arguments
let subtree = WithDelimiter {
@@ -379,9 +375,9 @@
let call_site_span = span_with_call_site_ctxt(db, span, id.into(), Edition::CURRENT);
let mac = if use_panic_2021(db, call_site_span) {
- sym::unreachable_2021.clone()
+ sym::unreachable_2021
} else {
- sym::unreachable_2015.clone()
+ sym::unreachable_2015
};
// Pass the original arguments
@@ -411,7 +407,7 @@
// FIXME: Record allow_internal_unstable in the macro def (not been done yet because it
// would consume quite a bit extra memory for all call locs...)
// if let Some(features) = expn.def.allow_internal_unstable {
- // if features.iter().any(|&f| f == sym::edition_panic.clone()) {
+ // if features.iter().any(|&f| f == sym::edition_panic) {
// span = expn.call_site;
// continue;
// }
diff --git a/crates/hir-expand/src/builtin/quote.rs b/crates/hir-expand/src/builtin/quote.rs
index f19edac..62b7b63 100644
--- a/crates/hir-expand/src/builtin/quote.rs
+++ b/crates/hir-expand/src/builtin/quote.rs
@@ -9,7 +9,7 @@
use crate::{name::Name, tt::TopSubtreeBuilder};
pub(crate) fn dollar_crate(span: Span) -> tt::Ident<Span> {
- tt::Ident { sym: sym::dollar_crate.clone(), span, is_raw: tt::IdentIsRaw::No }
+ tt::Ident { sym: sym::dollar_crate, span, is_raw: tt::IdentIsRaw::No }
}
// A helper macro quote macro
@@ -203,7 +203,7 @@
span: u32 => self { crate::tt::Literal{symbol: Symbol::integer(self as _), span, kind: tt::LitKind::Integer, suffix: None } };
span: usize => self { crate::tt::Literal{symbol: Symbol::integer(self as _), span, kind: tt::LitKind::Integer, suffix: None } };
span: i32 => self { crate::tt::Literal{symbol: Symbol::integer(self as _), span, kind: tt::LitKind::Integer, suffix: None } };
- span: bool => self { crate::tt::Ident{sym: if self { sym::true_.clone() } else { sym::false_.clone() }, span, is_raw: tt::IdentIsRaw::No } };
+ span: bool => self { crate::tt::Ident{sym: if self { sym::true_ } else { sym::false_ }, span, is_raw: tt::IdentIsRaw::No } };
_span: crate::tt::Leaf => self { self };
_span: crate::tt::Literal => self { self };
_span: crate::tt::Ident => self { self };
diff --git a/crates/hir-expand/src/declarative.rs b/crates/hir-expand/src/declarative.rs
index 50ef17c..1fa682c 100644
--- a/crates/hir-expand/src/declarative.rs
+++ b/crates/hir-expand/src/declarative.rs
@@ -88,7 +88,7 @@
.find(|it| {
it.path
.as_ident()
- .map(|it| *it == sym::rustc_macro_transparency.clone())
+ .map(|it| *it == sym::rustc_macro_transparency)
.unwrap_or(false)
})?
.token_tree_value()?
diff --git a/crates/hir-expand/src/fixup.rs b/crates/hir-expand/src/fixup.rs
index 7401528..4a4a3e5 100644
--- a/crates/hir-expand/src/fixup.rs
+++ b/crates/hir-expand/src/fixup.rs
@@ -82,7 +82,7 @@
original.push(original_tree);
let span = span_map.span_for_range(node_range);
let replacement = Leaf::Ident(Ident {
- sym: sym::__ra_fixup.clone(),
+ sym: sym::__ra_fixup,
span: Span {
range: TextRange::new(TextSize::new(idx), FIXUP_DUMMY_RANGE_END),
anchor: SpanAnchor { ast_id: FIXUP_DUMMY_AST_ID, ..span.anchor },
@@ -102,7 +102,7 @@
// incomplete field access: some_expr.|
append.insert(node.clone().into(), vec![
Leaf::Ident(Ident {
- sym: sym::__ra_fixup.clone(),
+ sym: sym::__ra_fixup,
span: fake_span(node_range),
is_raw: tt::IdentIsRaw::No
}),
@@ -141,7 +141,7 @@
};
append.insert(if_token.into(), vec![
Leaf::Ident(Ident {
- sym: sym::__ra_fixup.clone(),
+ sym: sym::__ra_fixup,
span: fake_span(node_range),
is_raw: tt::IdentIsRaw::No
}),
@@ -171,7 +171,7 @@
};
append.insert(while_token.into(), vec![
Leaf::Ident(Ident {
- sym: sym::__ra_fixup.clone(),
+ sym: sym::__ra_fixup,
span: fake_span(node_range),
is_raw: tt::IdentIsRaw::No
}),
@@ -217,7 +217,7 @@
};
append.insert(match_token.into(), vec![
Leaf::Ident(Ident {
- sym: sym::__ra_fixup.clone(),
+ sym: sym::__ra_fixup,
span: fake_span(node_range),
is_raw: tt::IdentIsRaw::No
}),
@@ -246,9 +246,9 @@
};
let [pat, in_token, iter] = [
- sym::underscore.clone(),
- sym::in_.clone(),
- sym::__ra_fixup.clone(),
+ sym::underscore,
+ sym::in_,
+ sym::__ra_fixup,
].map(|sym|
Leaf::Ident(Ident {
sym,
@@ -284,7 +284,7 @@
if it.name_ref().is_some() && it.expr().is_none() {
append.insert(colon.into(), vec![
Leaf::Ident(Ident {
- sym: sym::__ra_fixup.clone(),
+ sym: sym::__ra_fixup,
span: fake_span(node_range),
is_raw: tt::IdentIsRaw::No
})
@@ -297,7 +297,7 @@
if it.segment().is_none() {
append.insert(colon.into(), vec![
Leaf::Ident(Ident {
- sym: sym::__ra_fixup.clone(),
+ sym: sym::__ra_fixup,
span: fake_span(node_range),
is_raw: tt::IdentIsRaw::No
})
@@ -309,7 +309,7 @@
if it.body().is_none() {
append.insert(node.into(), vec![
Leaf::Ident(Ident {
- sym: sym::__ra_fixup.clone(),
+ sym: sym::__ra_fixup,
span: fake_span(node_range),
is_raw: tt::IdentIsRaw::No
})
diff --git a/crates/hir-expand/src/inert_attr_macro.rs b/crates/hir-expand/src/inert_attr_macro.rs
index 9a7a1a0..4157784 100644
--- a/crates/hir-expand/src/inert_attr_macro.rs
+++ b/crates/hir-expand/src/inert_attr_macro.rs
@@ -562,7 +562,7 @@
),
BuiltinAttribute {
- // name: sym::rustc_diagnostic_item.clone(),
+ // name: sym::rustc_diagnostic_item,
name: "rustc_diagnostic_item",
// FIXME: This can be `true` once we always use `tcx.is_diagnostic_item`.
// only_local: false,
@@ -571,7 +571,7 @@
// duplicates: ErrorFollowing,
// gate: Gated(
// Stability::Unstable,
- // sym::rustc_attrs.clone(),
+ // sym::rustc_attrs,
// "diagnostic items compiler internal support for linting",
// cfg_fn!(rustc_attrs),
// ),
diff --git a/crates/hir-expand/src/mod_path.rs b/crates/hir-expand/src/mod_path.rs
index 79a2e58..72a5627 100644
--- a/crates/hir-expand/src/mod_path.rs
+++ b/crates/hir-expand/src/mod_path.rs
@@ -111,8 +111,7 @@
#[allow(non_snake_case)]
pub fn is_Self(&self) -> bool {
- self.kind == PathKind::Plain
- && matches!(&*self.segments, [name] if *name == sym::Self_.clone())
+ self.kind == PathKind::Plain && matches!(&*self.segments, [name] if *name == sym::Self_)
}
/// If this path is a single identifier, like `foo`, return its name.
@@ -251,7 +250,7 @@
}
}
ast::PathSegmentKind::SelfTypeKw => {
- ModPath::from_segments(PathKind::Plain, Some(Name::new_symbol_root(sym::Self_.clone())))
+ ModPath::from_segments(PathKind::Plain, Some(Name::new_symbol_root(sym::Self_)))
}
ast::PathSegmentKind::CrateKw => ModPath::from_segments(PathKind::Crate, iter::empty()),
ast::PathSegmentKind::SelfKw => handle_super_kw(0)?,
@@ -399,7 +398,7 @@
macro_rules! __tool_path {
($start:ident $(:: $seg:ident)*) => ({
$crate::mod_path::ModPath::from_segments($crate::mod_path::PathKind::Plain, vec![
- $crate::name::Name::new_symbol_root($crate::intern::sym::rust_analyzer.clone()), $crate::name::Name::new_symbol_root($crate::intern::sym::$start.clone()), $($crate::name::Name::new_symbol_root($crate::intern::sym::$seg.clone()),)*
+ $crate::name::Name::new_symbol_root($crate::intern::sym::rust_analyzer), $crate::name::Name::new_symbol_root($crate::intern::sym::$start.clone()), $($crate::name::Name::new_symbol_root($crate::intern::sym::$seg.clone()),)*
])
});
}
diff --git a/crates/hir-expand/src/name.rs b/crates/hir-expand/src/name.rs
index 1065472..d43ef38 100644
--- a/crates/hir-expand/src/name.rs
+++ b/crates/hir-expand/src/name.rs
@@ -93,22 +93,22 @@
pub fn new_tuple_field(idx: usize) -> Name {
let symbol = match idx {
- 0 => sym::INTEGER_0.clone(),
- 1 => sym::INTEGER_1.clone(),
- 2 => sym::INTEGER_2.clone(),
- 3 => sym::INTEGER_3.clone(),
- 4 => sym::INTEGER_4.clone(),
- 5 => sym::INTEGER_5.clone(),
- 6 => sym::INTEGER_6.clone(),
- 7 => sym::INTEGER_7.clone(),
- 8 => sym::INTEGER_8.clone(),
- 9 => sym::INTEGER_9.clone(),
- 10 => sym::INTEGER_10.clone(),
- 11 => sym::INTEGER_11.clone(),
- 12 => sym::INTEGER_12.clone(),
- 13 => sym::INTEGER_13.clone(),
- 14 => sym::INTEGER_14.clone(),
- 15 => sym::INTEGER_15.clone(),
+ 0 => sym::INTEGER_0,
+ 1 => sym::INTEGER_1,
+ 2 => sym::INTEGER_2,
+ 3 => sym::INTEGER_3,
+ 4 => sym::INTEGER_4,
+ 5 => sym::INTEGER_5,
+ 6 => sym::INTEGER_6,
+ 7 => sym::INTEGER_7,
+ 8 => sym::INTEGER_8,
+ 9 => sym::INTEGER_9,
+ 10 => sym::INTEGER_10,
+ 11 => sym::INTEGER_11,
+ 12 => sym::INTEGER_12,
+ 13 => sym::INTEGER_13,
+ 14 => sym::INTEGER_14,
+ 15 => sym::INTEGER_15,
_ => Symbol::intern(&idx.to_string()),
};
Name { symbol, ctx: () }
diff --git a/crates/hir-ty/src/autoderef.rs b/crates/hir-ty/src/autoderef.rs
index 8f3526f..7115445 100644
--- a/crates/hir-ty/src/autoderef.rs
+++ b/crates/hir-ty/src/autoderef.rs
@@ -209,9 +209,8 @@
db.lang_item(table.trait_env.krate, LangItem::Deref).and_then(|l| l.as_trait())
};
let trait_id = trait_id()?;
- let target = db
- .trait_items(trait_id)
- .associated_type_by_name(&Name::new_symbol_root(sym::Target.clone()))?;
+ let target =
+ db.trait_items(trait_id).associated_type_by_name(&Name::new_symbol_root(sym::Target))?;
let projection = {
let b = TyBuilder::subst_for_def(db, trait_id, None);
diff --git a/crates/hir-ty/src/chalk_db.rs b/crates/hir-ty/src/chalk_db.rs
index 24deb00..dc52700 100644
--- a/crates/hir-ty/src/chalk_db.rs
+++ b/crates/hir-ty/src/chalk_db.rs
@@ -289,16 +289,17 @@
chalk_ir::Binders::new(binders, bound)
}
crate::ImplTraitId::AsyncBlockTypeImplTrait(..) => {
- if let Some((future_trait, future_output)) =
- self.db
- .lang_item(self.krate, LangItem::Future)
- .and_then(|item| item.as_trait())
- .and_then(|trait_| {
- let alias = self.db.trait_items(trait_).associated_type_by_name(
- &Name::new_symbol_root(sym::Output.clone()),
- )?;
- Some((trait_, alias))
- })
+ if let Some((future_trait, future_output)) = self
+ .db
+ .lang_item(self.krate, LangItem::Future)
+ .and_then(|item| item.as_trait())
+ .and_then(|trait_| {
+ let alias = self
+ .db
+ .trait_items(trait_)
+ .associated_type_by_name(&Name::new_symbol_root(sym::Output))?;
+ Some((trait_, alias))
+ })
{
// Making up Symbol’s value as variable is void: AsyncBlock<T>:
//
diff --git a/crates/hir-ty/src/diagnostics/expr.rs b/crates/hir-ty/src/diagnostics/expr.rs
index 1f197cb..5e3d880 100644
--- a/crates/hir-ty/src/diagnostics/expr.rs
+++ b/crates/hir-ty/src/diagnostics/expr.rs
@@ -492,9 +492,7 @@
ItemContainerId::TraitId(iterator_trait_id) => {
let iterator_trait_items = &db.trait_items(iterator_trait_id).items;
iterator_trait_items.iter().find_map(|(name, it)| match it {
- &AssocItemId::FunctionId(id) if *name == sym::filter_map.clone() => {
- Some(id)
- }
+ &AssocItemId::FunctionId(id) if *name == sym::filter_map => Some(id),
_ => None,
})
}
diff --git a/crates/hir-ty/src/display.rs b/crates/hir-ty/src/display.rs
index df304d6..8baa022 100644
--- a/crates/hir-ty/src/display.rs
+++ b/crates/hir-ty/src/display.rs
@@ -1350,9 +1350,8 @@
.lang_item(body.module(db).krate(), LangItem::Future)
.and_then(LangItemTarget::as_trait);
let output = future_trait.and_then(|t| {
- db.trait_items(t).associated_type_by_name(&Name::new_symbol_root(
- sym::Output.clone(),
- ))
+ db.trait_items(t)
+ .associated_type_by_name(&Name::new_symbol_root(sym::Output))
});
write!(f, "impl ")?;
if let Some(t) = future_trait {
diff --git a/crates/hir-ty/src/infer.rs b/crates/hir-ty/src/infer.rs
index 950c8ca..24b1909 100644
--- a/crates/hir-ty/src/infer.rs
+++ b/crates/hir-ty/src/infer.rs
@@ -1737,9 +1737,7 @@
}
fn resolve_output_on(&self, trait_: TraitId) -> Option<TypeAliasId> {
- self.db
- .trait_items(trait_)
- .associated_type_by_name(&Name::new_symbol_root(sym::Output.clone()))
+ self.db.trait_items(trait_).associated_type_by_name(&Name::new_symbol_root(sym::Output))
}
fn resolve_lang_trait(&self, lang: LangItem) -> Option<TraitId> {
diff --git a/crates/hir-ty/src/infer/closure.rs b/crates/hir-ty/src/infer/closure.rs
index e6cd1b9..59ec3ad 100644
--- a/crates/hir-ty/src/infer/closure.rs
+++ b/crates/hir-ty/src/infer/closure.rs
@@ -1175,7 +1175,7 @@
if let Some(deref_fn) = self
.db
.trait_items(deref_trait)
- .method_by_name(&Name::new_symbol_root(sym::deref_mut.clone()))
+ .method_by_name(&Name::new_symbol_root(sym::deref_mut))
{
break 'b deref_fn == f;
}
diff --git a/crates/hir-ty/src/infer/expr.rs b/crates/hir-ty/src/infer/expr.rs
index 068d9a59..3d14702 100644
--- a/crates/hir-ty/src/infer/expr.rs
+++ b/crates/hir-ty/src/infer/expr.rs
@@ -654,7 +654,7 @@
if let Some(deref_fn) = self
.db
.trait_items(deref_trait)
- .method_by_name(&Name::new_symbol_root(sym::deref.clone()))
+ .method_by_name(&Name::new_symbol_root(sym::deref))
{
// FIXME: this is wrong in multiple ways, subst is empty, and we emit it even for builtin deref (note that
// the mutability is not wrong, and will be fixed in `self.infer_mut`).
@@ -813,7 +813,7 @@
if let Some(func) = self
.db
.trait_items(index_trait)
- .method_by_name(&Name::new_symbol_root(sym::index.clone()))
+ .method_by_name(&Name::new_symbol_root(sym::index))
{
let subst = TyBuilder::subst_for_def(self.db, index_trait, None);
if subst.remaining() != 2 {
diff --git a/crates/hir-ty/src/infer/mutability.rs b/crates/hir-ty/src/infer/mutability.rs
index 4853908..cf0152e 100644
--- a/crates/hir-ty/src/infer/mutability.rs
+++ b/crates/hir-ty/src/infer/mutability.rs
@@ -134,7 +134,7 @@
if let Some(index_fn) = self
.db
.trait_items(index_trait)
- .method_by_name(&Name::new_symbol_root(sym::index_mut.clone()))
+ .method_by_name(&Name::new_symbol_root(sym::index_mut))
{
*f = index_fn;
let mut base_ty = None;
@@ -201,7 +201,7 @@
} else if let Some(deref_fn) = self
.db
.trait_items(deref_trait)
- .method_by_name(&Name::new_symbol_root(sym::deref_mut.clone()))
+ .method_by_name(&Name::new_symbol_root(sym::deref_mut))
{
*f = deref_fn;
}
diff --git a/crates/hir-ty/src/infer/unify.rs b/crates/hir-ty/src/infer/unify.rs
index 50bb6eb..60aa9b5 100644
--- a/crates/hir-ty/src/infer/unify.rs
+++ b/crates/hir-ty/src/infer/unify.rs
@@ -853,9 +853,9 @@
num_args: usize,
) -> Option<(FnTrait, Vec<Ty>, Ty)> {
for (fn_trait_name, output_assoc_name, subtraits) in [
- (FnTrait::FnOnce, sym::Output.clone(), &[FnTrait::Fn, FnTrait::FnMut][..]),
- (FnTrait::AsyncFnMut, sym::CallRefFuture.clone(), &[FnTrait::AsyncFn]),
- (FnTrait::AsyncFnOnce, sym::CallOnceFuture.clone(), &[]),
+ (FnTrait::FnOnce, sym::Output, &[FnTrait::Fn, FnTrait::FnMut][..]),
+ (FnTrait::AsyncFnMut, sym::CallRefFuture, &[FnTrait::AsyncFn]),
+ (FnTrait::AsyncFnOnce, sym::CallOnceFuture, &[]),
] {
let krate = self.trait_env.krate;
let fn_trait = fn_trait_name.get_id(self.db, krate)?;
diff --git a/crates/hir-ty/src/lang_items.rs b/crates/hir-ty/src/lang_items.rs
index 8ec3aee..9b46847 100644
--- a/crates/hir-ty/src/lang_items.rs
+++ b/crates/hir-ty/src/lang_items.rs
@@ -22,53 +22,43 @@
Some(match op {
BinaryOp::LogicOp(_) => return None,
BinaryOp::ArithOp(aop) => match aop {
- ArithOp::Add => (Name::new_symbol_root(sym::add.clone()), LangItem::Add),
- ArithOp::Mul => (Name::new_symbol_root(sym::mul.clone()), LangItem::Mul),
- ArithOp::Sub => (Name::new_symbol_root(sym::sub.clone()), LangItem::Sub),
- ArithOp::Div => (Name::new_symbol_root(sym::div.clone()), LangItem::Div),
- ArithOp::Rem => (Name::new_symbol_root(sym::rem.clone()), LangItem::Rem),
- ArithOp::Shl => (Name::new_symbol_root(sym::shl.clone()), LangItem::Shl),
- ArithOp::Shr => (Name::new_symbol_root(sym::shr.clone()), LangItem::Shr),
- ArithOp::BitXor => (Name::new_symbol_root(sym::bitxor.clone()), LangItem::BitXor),
- ArithOp::BitOr => (Name::new_symbol_root(sym::bitor.clone()), LangItem::BitOr),
- ArithOp::BitAnd => (Name::new_symbol_root(sym::bitand.clone()), LangItem::BitAnd),
+ ArithOp::Add => (Name::new_symbol_root(sym::add), LangItem::Add),
+ ArithOp::Mul => (Name::new_symbol_root(sym::mul), LangItem::Mul),
+ ArithOp::Sub => (Name::new_symbol_root(sym::sub), LangItem::Sub),
+ ArithOp::Div => (Name::new_symbol_root(sym::div), LangItem::Div),
+ ArithOp::Rem => (Name::new_symbol_root(sym::rem), LangItem::Rem),
+ ArithOp::Shl => (Name::new_symbol_root(sym::shl), LangItem::Shl),
+ ArithOp::Shr => (Name::new_symbol_root(sym::shr), LangItem::Shr),
+ ArithOp::BitXor => (Name::new_symbol_root(sym::bitxor), LangItem::BitXor),
+ ArithOp::BitOr => (Name::new_symbol_root(sym::bitor), LangItem::BitOr),
+ ArithOp::BitAnd => (Name::new_symbol_root(sym::bitand), LangItem::BitAnd),
},
BinaryOp::Assignment { op: Some(aop) } => match aop {
- ArithOp::Add => (Name::new_symbol_root(sym::add_assign.clone()), LangItem::AddAssign),
- ArithOp::Mul => (Name::new_symbol_root(sym::mul_assign.clone()), LangItem::MulAssign),
- ArithOp::Sub => (Name::new_symbol_root(sym::sub_assign.clone()), LangItem::SubAssign),
- ArithOp::Div => (Name::new_symbol_root(sym::div_assign.clone()), LangItem::DivAssign),
- ArithOp::Rem => (Name::new_symbol_root(sym::rem_assign.clone()), LangItem::RemAssign),
- ArithOp::Shl => (Name::new_symbol_root(sym::shl_assign.clone()), LangItem::ShlAssign),
- ArithOp::Shr => (Name::new_symbol_root(sym::shr_assign.clone()), LangItem::ShrAssign),
- ArithOp::BitXor => {
- (Name::new_symbol_root(sym::bitxor_assign.clone()), LangItem::BitXorAssign)
- }
- ArithOp::BitOr => {
- (Name::new_symbol_root(sym::bitor_assign.clone()), LangItem::BitOrAssign)
- }
- ArithOp::BitAnd => {
- (Name::new_symbol_root(sym::bitand_assign.clone()), LangItem::BitAndAssign)
- }
+ ArithOp::Add => (Name::new_symbol_root(sym::add_assign), LangItem::AddAssign),
+ ArithOp::Mul => (Name::new_symbol_root(sym::mul_assign), LangItem::MulAssign),
+ ArithOp::Sub => (Name::new_symbol_root(sym::sub_assign), LangItem::SubAssign),
+ ArithOp::Div => (Name::new_symbol_root(sym::div_assign), LangItem::DivAssign),
+ ArithOp::Rem => (Name::new_symbol_root(sym::rem_assign), LangItem::RemAssign),
+ ArithOp::Shl => (Name::new_symbol_root(sym::shl_assign), LangItem::ShlAssign),
+ ArithOp::Shr => (Name::new_symbol_root(sym::shr_assign), LangItem::ShrAssign),
+ ArithOp::BitXor => (Name::new_symbol_root(sym::bitxor_assign), LangItem::BitXorAssign),
+ ArithOp::BitOr => (Name::new_symbol_root(sym::bitor_assign), LangItem::BitOrAssign),
+ ArithOp::BitAnd => (Name::new_symbol_root(sym::bitand_assign), LangItem::BitAndAssign),
},
BinaryOp::CmpOp(cop) => match cop {
- CmpOp::Eq { negated: false } => {
- (Name::new_symbol_root(sym::eq.clone()), LangItem::PartialEq)
- }
- CmpOp::Eq { negated: true } => {
- (Name::new_symbol_root(sym::ne.clone()), LangItem::PartialEq)
- }
+ CmpOp::Eq { negated: false } => (Name::new_symbol_root(sym::eq), LangItem::PartialEq),
+ CmpOp::Eq { negated: true } => (Name::new_symbol_root(sym::ne), LangItem::PartialEq),
CmpOp::Ord { ordering: Ordering::Less, strict: false } => {
- (Name::new_symbol_root(sym::le.clone()), LangItem::PartialOrd)
+ (Name::new_symbol_root(sym::le), LangItem::PartialOrd)
}
CmpOp::Ord { ordering: Ordering::Less, strict: true } => {
- (Name::new_symbol_root(sym::lt.clone()), LangItem::PartialOrd)
+ (Name::new_symbol_root(sym::lt), LangItem::PartialOrd)
}
CmpOp::Ord { ordering: Ordering::Greater, strict: false } => {
- (Name::new_symbol_root(sym::ge.clone()), LangItem::PartialOrd)
+ (Name::new_symbol_root(sym::ge), LangItem::PartialOrd)
}
CmpOp::Ord { ordering: Ordering::Greater, strict: true } => {
- (Name::new_symbol_root(sym::gt.clone()), LangItem::PartialOrd)
+ (Name::new_symbol_root(sym::gt), LangItem::PartialOrd)
}
},
BinaryOp::Assignment { op: None } => return None,
diff --git a/crates/hir-ty/src/lib.rs b/crates/hir-ty/src/lib.rs
index 4cd112c..4f60bb2 100644
--- a/crates/hir-ty/src/lib.rs
+++ b/crates/hir-ty/src/lib.rs
@@ -889,7 +889,7 @@
let fn_once_trait = FnTrait::FnOnce.get_id(db, krate)?;
let output_assoc_type = db
.trait_items(fn_once_trait)
- .associated_type_by_name(&Name::new_symbol_root(sym::Output.clone()))?;
+ .associated_type_by_name(&Name::new_symbol_root(sym::Output))?;
let mut table = InferenceTable::new(db, trait_env.clone());
let b = TyBuilder::trait_ref(db, fn_once_trait);
diff --git a/crates/hir-ty/src/mir/eval.rs b/crates/hir-ty/src/mir/eval.rs
index dfcfa20..386226b 100644
--- a/crates/hir-ty/src/mir/eval.rs
+++ b/crates/hir-ty/src/mir/eval.rs
@@ -658,20 +658,18 @@
cached_fn_trait_func: db
.lang_item(crate_id, LangItem::Fn)
.and_then(|x| x.as_trait())
- .and_then(|x| {
- db.trait_items(x).method_by_name(&Name::new_symbol_root(sym::call.clone()))
- }),
+ .and_then(|x| db.trait_items(x).method_by_name(&Name::new_symbol_root(sym::call))),
cached_fn_mut_trait_func: db
.lang_item(crate_id, LangItem::FnMut)
.and_then(|x| x.as_trait())
.and_then(|x| {
- db.trait_items(x).method_by_name(&Name::new_symbol_root(sym::call_mut.clone()))
+ db.trait_items(x).method_by_name(&Name::new_symbol_root(sym::call_mut))
}),
cached_fn_once_trait_func: db
.lang_item(crate_id, LangItem::FnOnce)
.and_then(|x| x.as_trait())
.and_then(|x| {
- db.trait_items(x).method_by_name(&Name::new_symbol_root(sym::call_once.clone()))
+ db.trait_items(x).method_by_name(&Name::new_symbol_root(sym::call_once))
}),
})
}
@@ -2814,9 +2812,7 @@
) -> Result<()> {
let Some(drop_fn) = (|| {
let drop_trait = self.db.lang_item(self.crate_id, LangItem::Drop)?.as_trait()?;
- self.db
- .trait_items(drop_trait)
- .method_by_name(&Name::new_symbol_root(sym::drop.clone()))
+ self.db.trait_items(drop_trait).method_by_name(&Name::new_symbol_root(sym::drop))
})() else {
// in some tests we don't have drop trait in minicore, and
// we can ignore drop in them.
@@ -2926,7 +2922,7 @@
not_supported!("core::fmt::Debug not found");
};
let Some(debug_fmt_fn) =
- db.trait_items(debug_trait).method_by_name(&Name::new_symbol_root(sym::fmt.clone()))
+ db.trait_items(debug_trait).method_by_name(&Name::new_symbol_root(sym::fmt))
else {
not_supported!("core::fmt::Debug::fmt not found");
};
diff --git a/crates/hir-ty/src/mir/eval/shim.rs b/crates/hir-ty/src/mir/eval/shim.rs
index 12274ab..4de44cf 100644
--- a/crates/hir-ty/src/mir/eval/shim.rs
+++ b/crates/hir-ty/src/mir/eval/shim.rs
@@ -1261,7 +1261,7 @@
if let Some(def) = target.as_trait().and_then(|it| {
self.db
.trait_items(it)
- .method_by_name(&Name::new_symbol_root(sym::call_once.clone()))
+ .method_by_name(&Name::new_symbol_root(sym::call_once))
}) {
self.exec_fn_trait(
def,
diff --git a/crates/hir-ty/src/mir/lower/as_place.rs b/crates/hir-ty/src/mir/lower/as_place.rs
index 637a560..d3cd009 100644
--- a/crates/hir-ty/src/mir/lower/as_place.rs
+++ b/crates/hir-ty/src/mir/lower/as_place.rs
@@ -193,10 +193,10 @@
if let Some(deref_trait) =
self.resolve_lang_item(LangItem::DerefMut)?.as_trait()
{
- if let Some(deref_fn) =
- self.db.trait_items(deref_trait).method_by_name(
- &Name::new_symbol_root(sym::deref_mut.clone()),
- )
+ if let Some(deref_fn) = self
+ .db
+ .trait_items(deref_trait)
+ .method_by_name(&Name::new_symbol_root(sym::deref_mut))
{
break 'b deref_fn == f;
}
@@ -331,14 +331,14 @@
(
Mutability::Not,
LangItem::Deref,
- Name::new_symbol_root(sym::deref.clone()),
+ Name::new_symbol_root(sym::deref),
BorrowKind::Shared,
)
} else {
(
Mutability::Mut,
LangItem::DerefMut,
- Name::new_symbol_root(sym::deref_mut.clone()),
+ Name::new_symbol_root(sym::deref_mut),
BorrowKind::Mut { kind: MutBorrowKind::Default },
)
};
diff --git a/crates/hir-ty/src/traits.rs b/crates/hir-ty/src/traits.rs
index 75b8b50..a5c195d 100644
--- a/crates/hir-ty/src/traits.rs
+++ b/crates/hir-ty/src/traits.rs
@@ -282,12 +282,12 @@
pub fn method_name(self) -> Name {
match self {
- FnTrait::FnOnce => Name::new_symbol_root(sym::call_once.clone()),
- FnTrait::FnMut => Name::new_symbol_root(sym::call_mut.clone()),
- FnTrait::Fn => Name::new_symbol_root(sym::call.clone()),
- FnTrait::AsyncFnOnce => Name::new_symbol_root(sym::async_call_once.clone()),
- FnTrait::AsyncFnMut => Name::new_symbol_root(sym::async_call_mut.clone()),
- FnTrait::AsyncFn => Name::new_symbol_root(sym::async_call.clone()),
+ FnTrait::FnOnce => Name::new_symbol_root(sym::call_once),
+ FnTrait::FnMut => Name::new_symbol_root(sym::call_mut),
+ FnTrait::Fn => Name::new_symbol_root(sym::call),
+ FnTrait::AsyncFnOnce => Name::new_symbol_root(sym::async_call_once),
+ FnTrait::AsyncFnMut => Name::new_symbol_root(sym::async_call_mut),
+ FnTrait::AsyncFn => Name::new_symbol_root(sym::async_call),
}
}
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index b42cec0..ce48751 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -2056,7 +2056,7 @@
continue;
}
let mut need_mut = &mol[local];
- if body[binding_id].name == sym::self_.clone()
+ if body[binding_id].name == sym::self_
&& need_mut == &mir::MutabilityReason::Unused
{
need_mut = &mir::MutabilityReason::Not;
@@ -3045,7 +3045,7 @@
impl StaticLifetime {
pub fn name(self) -> Name {
- Name::new_symbol_root(sym::tick_static.clone())
+ Name::new_symbol_root(sym::tick_static)
}
}
@@ -3871,7 +3871,7 @@
}
pub fn is_self(self, db: &dyn HirDatabase) -> bool {
- self.name(db) == sym::self_.clone()
+ self.name(db) == sym::self_
}
pub fn is_mut(self, db: &dyn HirDatabase) -> bool {
@@ -4987,9 +4987,8 @@
return None;
}
- let output_assoc_type = db
- .trait_items(trait_)
- .associated_type_by_name(&Name::new_symbol_root(sym::Output.clone()))?;
+ let output_assoc_type =
+ db.trait_items(trait_).associated_type_by_name(&Name::new_symbol_root(sym::Output))?;
self.normalize_trait_assoc_type(db, &[], output_assoc_type.into())
}
@@ -5005,7 +5004,7 @@
let iterator_trait = db.lang_item(self.env.krate, LangItem::Iterator)?.as_trait()?;
let iterator_item = db
.trait_items(iterator_trait)
- .associated_type_by_name(&Name::new_symbol_root(sym::Item.clone()))?;
+ .associated_type_by_name(&Name::new_symbol_root(sym::Item))?;
self.normalize_trait_assoc_type(db, &[], iterator_item.into())
}
@@ -5037,7 +5036,7 @@
let into_iter_assoc_type = db
.trait_items(trait_)
- .associated_type_by_name(&Name::new_symbol_root(sym::IntoIter.clone()))?;
+ .associated_type_by_name(&Name::new_symbol_root(sym::IntoIter))?;
self.normalize_trait_assoc_type(db, &[], into_iter_assoc_type.into())
}
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs
index 0e5da85..48191d1 100644
--- a/crates/hir/src/semantics.rs
+++ b/crates/hir/src/semantics.rs
@@ -2058,7 +2058,7 @@
ast::PathSegmentKind::Name(name_ref) => segments.push(name_ref.as_name()),
ast::PathSegmentKind::Type { .. } => continue,
ast::PathSegmentKind::SelfTypeKw => {
- segments.push(Name::new_symbol_root(sym::Self_.clone()))
+ segments.push(Name::new_symbol_root(sym::Self_))
}
ast::PathSegmentKind::SelfKw => kind = PathKind::Super(0),
ast::PathSegmentKind::SuperKw => match kind {
diff --git a/crates/hir/src/source_analyzer.rs b/crates/hir/src/source_analyzer.rs
index b2ca2c6..8c35def 100644
--- a/crates/hir/src/source_analyzer.rs
+++ b/crates/hir/src/source_analyzer.rs
@@ -540,7 +540,7 @@
let items = into_future_trait.items(db);
let into_future_type = items.into_iter().find_map(|item| match item {
AssocItem::TypeAlias(alias)
- if alias.name(db) == Name::new_symbol_root(sym::IntoFuture.clone()) =>
+ if alias.name(db) == Name::new_symbol_root(sym::IntoFuture) =>
{
Some(alias)
}
@@ -569,11 +569,8 @@
// This can be either `Deref::deref` or `DerefMut::deref_mut`.
// Since deref kind is inferenced and stored in `InferenceResult.method_resolution`,
// use that result to find out which one it is.
- let (deref_trait, deref) = self.lang_trait_fn(
- db,
- LangItem::Deref,
- &Name::new_symbol_root(sym::deref.clone()),
- )?;
+ let (deref_trait, deref) =
+ self.lang_trait_fn(db, LangItem::Deref, &Name::new_symbol_root(sym::deref))?;
self.infer()
.and_then(|infer| {
let expr = self.expr_id(prefix_expr.clone().into())?.as_expr()?;
@@ -581,17 +578,17 @@
let (deref_mut_trait, deref_mut) = self.lang_trait_fn(
db,
LangItem::DerefMut,
- &Name::new_symbol_root(sym::deref_mut.clone()),
+ &Name::new_symbol_root(sym::deref_mut),
)?;
if func == deref_mut { Some((deref_mut_trait, deref_mut)) } else { None }
})
.unwrap_or((deref_trait, deref))
}
ast::UnaryOp::Not => {
- self.lang_trait_fn(db, LangItem::Not, &Name::new_symbol_root(sym::not.clone()))?
+ self.lang_trait_fn(db, LangItem::Not, &Name::new_symbol_root(sym::not))?
}
ast::UnaryOp::Neg => {
- self.lang_trait_fn(db, LangItem::Neg, &Name::new_symbol_root(sym::neg.clone()))?
+ self.lang_trait_fn(db, LangItem::Neg, &Name::new_symbol_root(sym::neg))?
}
};
@@ -613,7 +610,7 @@
let index_ty = self.ty_of_expr(index_expr.index()?)?;
let (index_trait, index_fn) =
- self.lang_trait_fn(db, LangItem::Index, &Name::new_symbol_root(sym::index.clone()))?;
+ self.lang_trait_fn(db, LangItem::Index, &Name::new_symbol_root(sym::index))?;
let (op_trait, op_fn) = self
.infer()
.and_then(|infer| {
@@ -622,7 +619,7 @@
let (index_mut_trait, index_mut_fn) = self.lang_trait_fn(
db,
LangItem::IndexMut,
- &Name::new_symbol_root(sym::index_mut.clone()),
+ &Name::new_symbol_root(sym::index_mut),
)?;
if func == index_mut_fn { Some((index_mut_trait, index_mut_fn)) } else { None }
})
diff --git a/crates/ide-assists/src/handlers/convert_bool_then.rs b/crates/ide-assists/src/handlers/convert_bool_then.rs
index 0a2eab2..cd23ad2 100644
--- a/crates/ide-assists/src/handlers/convert_bool_then.rs
+++ b/crates/ide-assists/src/handlers/convert_bool_then.rs
@@ -245,7 +245,7 @@
let fam = FamousDefs(sema, sema.scope(expr)?.krate());
let option_variants = fam.core_option_Option()?.variants(sema.db);
match &*option_variants {
- &[variant0, variant1] => Some(if variant0.name(sema.db) == sym::None.clone() {
+ &[variant0, variant1] => Some(if variant0.name(sema.db) == sym::None {
(variant0, variant1)
} else {
(variant1, variant0)
diff --git a/crates/ide-assists/src/handlers/convert_for_to_while_let.rs b/crates/ide-assists/src/handlers/convert_for_to_while_let.rs
index 7c5c983..2d6a59a 100644
--- a/crates/ide-assists/src/handlers/convert_for_to_while_let.rs
+++ b/crates/ide-assists/src/handlers/convert_for_to_while_let.rs
@@ -118,9 +118,9 @@
_ => return None,
};
let wanted_method = Name::new_symbol_root(if ref_expr.mut_token().is_some() {
- sym::iter_mut.clone()
+ sym::iter_mut
} else {
- sym::iter.clone()
+ sym::iter
});
let expr_behind_ref = ref_expr.expr()?;
let ty = sema.type_of_expr(&expr_behind_ref)?.adjusted();
diff --git a/crates/ide-assists/src/handlers/convert_iter_for_each_to_for.rs b/crates/ide-assists/src/handlers/convert_iter_for_each_to_for.rs
index d7f6594..3917ca1 100644
--- a/crates/ide-assists/src/handlers/convert_iter_for_each_to_for.rs
+++ b/crates/ide-assists/src/handlers/convert_iter_for_each_to_for.rs
@@ -154,9 +154,9 @@
_ => return None,
};
let wanted_method = Name::new_symbol_root(if ref_expr.mut_token().is_some() {
- sym::iter_mut.clone()
+ sym::iter_mut
} else {
- sym::iter.clone()
+ sym::iter
});
let expr_behind_ref = ref_expr.expr()?;
let ty = sema.type_of_expr(&expr_behind_ref)?.adjusted();
diff --git a/crates/ide-assists/src/handlers/generate_is_empty_from_len.rs b/crates/ide-assists/src/handlers/generate_is_empty_from_len.rs
index f86c717..af9c493 100644
--- a/crates/ide-assists/src/handlers/generate_is_empty_from_len.rs
+++ b/crates/ide-assists/src/handlers/generate_is_empty_from_len.rs
@@ -54,13 +54,13 @@
}
let impl_ = fn_node.syntax().ancestors().find_map(ast::Impl::cast)?;
- let len_fn = get_impl_method(ctx, &impl_, &Name::new_symbol_root(sym::len.clone()))?;
+ let len_fn = get_impl_method(ctx, &impl_, &Name::new_symbol_root(sym::len))?;
if !len_fn.ret_type(ctx.sema.db).is_usize() {
cov_mark::hit!(len_fn_different_return_type);
return None;
}
- if get_impl_method(ctx, &impl_, &Name::new_symbol_root(sym::is_empty.clone())).is_some() {
+ if get_impl_method(ctx, &impl_, &Name::new_symbol_root(sym::is_empty)).is_some() {
cov_mark::hit!(is_empty_already_implemented);
return None;
}
diff --git a/crates/ide-assists/src/handlers/inline_call.rs b/crates/ide-assists/src/handlers/inline_call.rs
index c029830..6f028e5 100644
--- a/crates/ide-assists/src/handlers/inline_call.rs
+++ b/crates/ide-assists/src/handlers/inline_call.rs
@@ -451,7 +451,7 @@
let ty = sema.type_of_expr(expr).filter(TypeInfo::has_adjustment).and(param_ty);
- let is_self = param.name(sema.db).is_some_and(|name| name == sym::self_.clone());
+ let is_self = param.name(sema.db).is_some_and(|name| name == sym::self_);
if is_self {
let mut this_pat = make::ident_pat(false, false, make::name("this"));
diff --git a/crates/ide-assists/src/handlers/wrap_return_type.rs b/crates/ide-assists/src/handlers/wrap_return_type.rs
index e4abf02..9ea7871 100644
--- a/crates/ide-assists/src/handlers/wrap_return_type.rs
+++ b/crates/ide-assists/src/handlers/wrap_return_type.rs
@@ -181,8 +181,8 @@
fn symbol(&self) -> hir::Symbol {
match self {
- WrapperKind::Option => hir::sym::Option.clone(),
- WrapperKind::Result => hir::sym::Result.clone(),
+ WrapperKind::Option => hir::sym::Option,
+ WrapperKind::Result => hir::sym::Result,
}
}
}
diff --git a/crates/ide-completion/src/completions.rs b/crates/ide-completion/src/completions.rs
index c8cdad5..5d68aca 100644
--- a/crates/ide-completion/src/completions.rs
+++ b/crates/ide-completion/src/completions.rs
@@ -631,8 +631,7 @@
let mut process_variant = |variant: Variant| {
let self_path = hir::ModPath::from_segments(
hir::PathKind::Plain,
- iter::once(Name::new_symbol_root(sym::Self_.clone()))
- .chain(iter::once(variant.name(ctx.db))),
+ iter::once(Name::new_symbol_root(sym::Self_)).chain(iter::once(variant.name(ctx.db))),
);
cb(acc, ctx, variant, self_path);
diff --git a/crates/ide-completion/src/completions/expr.rs b/crates/ide-completion/src/completions/expr.rs
index 0494d42..ee1a21f 100644
--- a/crates/ide-completion/src/completions/expr.rs
+++ b/crates/ide-completion/src/completions/expr.rs
@@ -260,7 +260,7 @@
path_ctx,
strukt,
None,
- Some(Name::new_symbol_root(sym::Self_.clone())),
+ Some(Name::new_symbol_root(sym::Self_)),
);
}
}
@@ -280,7 +280,7 @@
ctx,
un,
None,
- Some(Name::new_symbol_root(sym::Self_.clone())),
+ Some(Name::new_symbol_root(sym::Self_)),
);
}
}
diff --git a/crates/ide-completion/src/completions/lifetime.rs b/crates/ide-completion/src/completions/lifetime.rs
index 9bb2bea..b02f079 100644
--- a/crates/ide-completion/src/completions/lifetime.rs
+++ b/crates/ide-completion/src/completions/lifetime.rs
@@ -31,13 +31,13 @@
acc.add_lifetime(ctx, name);
}
});
- acc.add_lifetime(ctx, Name::new_symbol_root(sym::tick_static.clone()));
+ acc.add_lifetime(ctx, Name::new_symbol_root(sym::tick_static));
if !in_lifetime_param_bound
&& def.is_some_and(|def| {
!matches!(def, hir::GenericDef::Function(_) | hir::GenericDef::Impl(_))
})
{
- acc.add_lifetime(ctx, Name::new_symbol_root(sym::tick_underscore.clone()));
+ acc.add_lifetime(ctx, Name::new_symbol_root(sym::tick_underscore));
}
}
diff --git a/crates/ide-diagnostics/src/handlers/missing_fields.rs b/crates/ide-diagnostics/src/handlers/missing_fields.rs
index 220f4e0..6b02111 100644
--- a/crates/ide-diagnostics/src/handlers/missing_fields.rs
+++ b/crates/ide-diagnostics/src/handlers/missing_fields.rs
@@ -217,7 +217,7 @@
let has_new_func = ty
.iterate_assoc_items(ctx.sema.db, krate, |assoc_item| {
if let AssocItem::Function(func) = assoc_item {
- if func.name(ctx.sema.db) == sym::new.clone()
+ if func.name(ctx.sema.db) == sym::new
&& func.assoc_fn_params(ctx.sema.db).is_empty()
{
return Some(());
diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs
index 5b1738b..d4f6bf7 100644
--- a/crates/ide/src/inlay_hints.rs
+++ b/crates/ide/src/inlay_hints.rs
@@ -797,7 +797,7 @@
if ty.impls_trait(db, iter_trait, &[]) {
let assoc_type_item = iter_trait.items(db).into_iter().find_map(|item| match item {
- hir::AssocItem::TypeAlias(alias) if alias.name(db) == sym::Item.clone() => Some(alias),
+ hir::AssocItem::TypeAlias(alias) if alias.name(db) == sym::Item => Some(alias),
_ => None,
})?;
if let Some(ty) = ty.normalize_trait_assoc_type(db, &[], assoc_type_item) {
diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs
index 2a6f108..a13be6c 100644
--- a/crates/ide/src/lib.rs
+++ b/crates/ide/src/lib.rs
@@ -249,7 +249,7 @@
TryFrom::try_from(&*std::env::current_dir().unwrap().as_path().to_string_lossy())
.unwrap(),
);
- cfg_options.insert_atom(sym::test.clone());
+ cfg_options.insert_atom(sym::test);
crate_graph.add_crate_root(
file_id,
Edition::CURRENT,
diff --git a/crates/mbe/src/expander/transcriber.rs b/crates/mbe/src/expander/transcriber.rs
index e2340b4..ec277ba 100644
--- a/crates/mbe/src/expander/transcriber.rs
+++ b/crates/mbe/src/expander/transcriber.rs
@@ -80,7 +80,7 @@
| MetaVarKind::Expr(_)
| MetaVarKind::Ident => {
builder.push(tt::Leaf::Ident(tt::Ident {
- sym: sym::missing.clone(),
+ sym: sym::missing,
span,
is_raw: tt::IdentIsRaw::No,
}));
@@ -93,7 +93,7 @@
spacing: tt::Spacing::Joint,
}),
tt::Leaf::Ident(tt::Ident {
- sym: sym::missing.clone(),
+ sym: sym::missing,
span,
is_raw: tt::IdentIsRaw::No,
}),
@@ -101,7 +101,7 @@
}
MetaVarKind::Literal => {
builder.push(tt::Leaf::Ident(tt::Ident {
- sym: sym::missing.clone(),
+ sym: sym::missing,
span,
is_raw: tt::IdentIsRaw::No,
}));
diff --git a/crates/mbe/src/parser.rs b/crates/mbe/src/parser.rs
index 8a2f124..fbc353d 100644
--- a/crates/mbe/src/parser.rs
+++ b/crates/mbe/src/parser.rs
@@ -228,7 +228,7 @@
tt::Leaf::Ident(ident) if ident.sym == sym::crate_ => {
// We simply produce identifier `$crate` here. And it will be resolved when lowering ast to Path.
Op::Ident(tt::Ident {
- sym: sym::dollar_crate.clone(),
+ sym: sym::dollar_crate,
span: ident.span,
is_raw: tt::IdentIsRaw::No,
})
diff --git a/crates/proc-macro-api/src/legacy_protocol/msg.rs b/crates/proc-macro-api/src/legacy_protocol/msg.rs
index 33e84f6..55185aa 100644
--- a/crates/proc-macro-api/src/legacy_protocol/msg.rs
+++ b/crates/proc-macro-api/src/legacy_protocol/msg.rs
@@ -284,14 +284,14 @@
},
);
builder.push(Leaf::Literal(Literal {
- symbol: sym::INTEGER_0.clone(),
+ symbol: sym::INTEGER_0,
span: Span {
range: TextRange::at(TextSize::new(15), TextSize::of("0u32")),
anchor,
ctx: SyntaxContext::root(Edition::CURRENT),
},
kind: tt::LitKind::Integer,
- suffix: Some(sym::u32.clone()),
+ suffix: Some(sym::u32),
}));
builder.close(Span {
range: TextRange::at(TextSize::new(19), TextSize::of('}')),
diff --git a/crates/project-model/src/tests.rs b/crates/project-model/src/tests.rs
index 1faa7b8..c69891b 100644
--- a/crates/project-model/src/tests.rs
+++ b/crates/project-model/src/tests.rs
@@ -140,7 +140,7 @@
#[test]
fn cargo_hello_world_project_model_with_wildcard_overrides() {
let cfg_overrides = CfgOverrides {
- global: CfgDiff::new(Vec::new(), vec![CfgAtom::Flag(sym::test.clone())]),
+ global: CfgDiff::new(Vec::new(), vec![CfgAtom::Flag(sym::test)]),
selective: Default::default(),
};
let (crate_graph, _proc_macros) =
@@ -159,7 +159,7 @@
global: Default::default(),
selective: std::iter::once((
"libc".to_owned(),
- CfgDiff::new(Vec::new(), vec![CfgAtom::Flag(sym::test.clone())]),
+ CfgDiff::new(Vec::new(), vec![CfgAtom::Flag(sym::test)]),
))
.collect(),
};
diff --git a/crates/project-model/src/workspace.rs b/crates/project-model/src/workspace.rs
index 7a139ea..c1e68af 100644
--- a/crates/project-model/src/workspace.rs
+++ b/crates/project-model/src/workspace.rs
@@ -1036,9 +1036,9 @@
if *is_workspace_member {
if set_test && !is_sysroot {
// Add test cfg for local crates
- cfg_options.insert_atom(sym::test.clone());
+ cfg_options.insert_atom(sym::test);
}
- cfg_options.insert_atom(sym::rust_analyzer.clone());
+ cfg_options.insert_atom(sym::rust_analyzer);
}
override_cfg.apply(
@@ -1159,9 +1159,9 @@
if cargo[pkg].is_local {
if set_test && !cargo.is_sysroot() {
// Add test cfg for local crates
- cfg_options.insert_atom(sym::test.clone());
+ cfg_options.insert_atom(sym::test);
}
- cfg_options.insert_atom(sym::rust_analyzer.clone());
+ cfg_options.insert_atom(sym::rust_analyzer);
}
override_cfg.apply(&mut cfg_options, &cargo[pkg].name);
@@ -1351,9 +1351,9 @@
let mut cfg_options = CfgOptions::from_iter(rustc_cfg);
if set_test {
- cfg_options.insert_atom(sym::test.clone());
+ cfg_options.insert_atom(sym::test);
}
- cfg_options.insert_atom(sym::rust_analyzer.clone());
+ cfg_options.insert_atom(sym::rust_analyzer);
override_cfg.apply(&mut cfg_options, "");
let cfg_options = cfg_options;
@@ -1519,16 +1519,17 @@
None
} else {
let mut potential_cfg_options = cfg_options.clone();
- potential_cfg_options.extend(pkg.features.iter().map(|feat| CfgAtom::KeyValue {
- key: sym::feature.clone(),
- value: Symbol::intern(feat.0),
- }));
+ potential_cfg_options.extend(
+ pkg.features
+ .iter()
+ .map(|feat| CfgAtom::KeyValue { key: sym::feature, value: Symbol::intern(feat.0) }),
+ );
Some(potential_cfg_options)
};
let cfg_options = {
let mut opts = cfg_options;
for feature in pkg.active_features.iter() {
- opts.insert_key_value(sym::feature.clone(), Symbol::intern(feature));
+ opts.insert_key_value(sym::feature, Symbol::intern(feature));
}
if let Some(cfgs) = build_data.map(|(it, _)| &it.cfgs) {
opts.extend(cfgs.iter().cloned());
@@ -1662,11 +1663,11 @@
&CfgOverrides {
global: CfgDiff::new(
vec![
- CfgAtom::Flag(sym::debug_assertions.clone()),
- CfgAtom::Flag(sym::miri.clone()),
- CfgAtom::Flag(sym::bootstrap.clone()),
+ CfgAtom::Flag(sym::debug_assertions),
+ CfgAtom::Flag(sym::miri),
+ CfgAtom::Flag(sym::bootstrap),
],
- vec![CfgAtom::Flag(sym::test.clone())],
+ vec![CfgAtom::Flag(sym::test)],
),
..Default::default()
},
@@ -1686,10 +1687,7 @@
&FxHashMap::default(),
&CfgOverrides {
global: CfgDiff::new(
- vec![
- CfgAtom::Flag(sym::debug_assertions.clone()),
- CfgAtom::Flag(sym::miri.clone()),
- ],
+ vec![CfgAtom::Flag(sym::debug_assertions), CfgAtom::Flag(sym::miri)],
vec![],
),
..Default::default()
@@ -1705,8 +1703,8 @@
let cfg_options = {
let mut cfg_options = CfgOptions::default();
cfg_options.extend(rustc_cfg);
- cfg_options.insert_atom(sym::debug_assertions.clone());
- cfg_options.insert_atom(sym::miri.clone());
+ cfg_options.insert_atom(sym::debug_assertions);
+ cfg_options.insert_atom(sym::miri);
cfg_options
};
let sysroot_crates: FxHashMap<
diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs
index 5694072..a62005e 100644
--- a/crates/rust-analyzer/src/cli/analysis_stats.rs
+++ b/crates/rust-analyzer/src/cli/analysis_stats.rs
@@ -59,7 +59,7 @@
all_targets: true,
set_test: !self.no_test,
cfg_overrides: CfgOverrides {
- global: CfgDiff::new(vec![CfgAtom::Flag(hir::sym::miri.clone())], vec![]),
+ global: CfgDiff::new(vec![CfgAtom::Flag(hir::sym::miri)], vec![]),
selective: Default::default(),
},
..Default::default()