Merge pull request #19644 from ChayimFriedman2/const-syms

internal: Make predefined symbols `const` instead of `static`
This commit is contained in:
Lukas Wirth 2025-04-21 12:34:59 +00:00 committed by GitHub
commit 34e7d60e30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
72 changed files with 432 additions and 473 deletions

View file

@ -631,8 +631,7 @@ fn enum_variants_with_paths(
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);

View file

@ -260,7 +260,7 @@ pub(crate) fn complete_expr_path(
path_ctx,
strukt,
None,
Some(Name::new_symbol_root(sym::Self_.clone())),
Some(Name::new_symbol_root(sym::Self_)),
);
}
}
@ -280,7 +280,7 @@ pub(crate) fn complete_expr_path(
ctx,
un,
None,
Some(Name::new_symbol_root(sym::Self_.clone())),
Some(Name::new_symbol_root(sym::Self_)),
);
}
}

View file

@ -31,13 +31,13 @@ pub(crate) fn complete_lifetime(
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));
}
}

View file

@ -92,7 +92,7 @@ impl<'a> RenderContext<'a> {
fn is_deprecated(&self, def: impl HasAttrs) -> bool {
let attrs = def.attrs(self.db());
attrs.by_key(&sym::deprecated).exists()
attrs.by_key(sym::deprecated).exists()
}
fn is_deprecated_assoc_item(&self, as_assoc_item: impl AsAssocItem) -> bool {

View file

@ -96,7 +96,7 @@ pub(crate) fn visible_fields(
.copied()
.collect::<Vec<_>>();
let has_invisible_field = n_fields - fields.len() > 0;
let is_foreign_non_exhaustive = item.attrs(ctx.db).by_key(&sym::non_exhaustive).exists()
let is_foreign_non_exhaustive = item.attrs(ctx.db).by_key(sym::non_exhaustive).exists()
&& item.krate(ctx.db) != module.krate();
let fields_omitted = has_invisible_field || is_foreign_non_exhaustive;
Some((fields, fields_omitted))