Fix 2024 syntax errors

This commit is contained in:
BenjaminBrienen 2025-03-10 12:37:43 +01:00
parent 71ff7fbe22
commit aad66c7bf1
11 changed files with 35 additions and 28 deletions

View file

@ -518,7 +518,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
let Some(def) = self.owner.as_generic_def_id(self.db.upcast()) else {
not_supported!("owner without generic def id");
};
let gen = generics(self.db.upcast(), def);
let generics = generics(self.db.upcast(), def);
let ty = self.expr_ty_without_adjust(expr_id);
self.push_assignment(
current,
@ -528,7 +528,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
ty,
value: chalk_ir::ConstValue::BoundVar(BoundVar::new(
DebruijnIndex::INNERMOST,
gen.type_or_const_param_idx(p.into()).ok_or(
generics.type_or_const_param_idx(p.into()).ok_or(
MirLowerError::TypeError(
"fail to lower const generic param",
),

View file

@ -5261,7 +5261,7 @@ impl Type {
/// Returns types that this type dereferences to (including this type itself). The returned
/// iterator won't yield the same type more than once even if the deref chain contains a cycle.
pub fn autoderef(&self, db: &dyn HirDatabase) -> impl Iterator<Item = Type> + '_ {
pub fn autoderef<'db>(&self, db: &'db dyn HirDatabase) -> impl Iterator<Item = Type> + use<'_, 'db> {
self.autoderef_(db).map(move |ty| self.derived(ty))
}
@ -5637,7 +5637,10 @@ impl Type {
.map(Trait::from)
}
pub fn as_impl_traits(&self, db: &dyn HirDatabase) -> Option<impl Iterator<Item = Trait>> {
pub fn as_impl_traits(
&self,
db: &dyn HirDatabase,
) -> Option<impl Iterator<Item = Trait> + use<>> {
self.ty.impl_trait_bounds(db).map(|it| {
it.into_iter().filter_map(|pred| match pred.skip_binders() {
hir_ty::WhereClause::Implemented(trait_ref) => {

View file

@ -2087,7 +2087,7 @@ impl SemanticsScope<'_> {
)
}
pub fn resolve_mod_path(&self, path: &ModPath) -> impl Iterator<Item = ItemInNs> {
pub fn resolve_mod_path(&self, path: &ModPath) -> impl Iterator<Item = ItemInNs> + use<> {
let items = self.resolver.resolve_module_path_in_items(self.db.upcast(), path);
items.iter_items().map(|(item, _)| item.into())
}

View file

@ -780,7 +780,8 @@ fn fill_lint_attrs(
}
});
let all_matching_groups = lint_groups(&diag.code, edition)
let lints = lint_groups(&diag.code, edition);
let all_matching_groups = lints
.iter()
.filter_map(|lint_group| cached.get(lint_group));
let cached_severity =

View file

@ -268,13 +268,13 @@ fn hints_(
ctx.lifetime_stacks.iter().flat_map(|it| it.iter()).cloned().zip(iter::repeat(0)).collect();
// allocate names
let mut gen_idx_name = {
let mut gen = (0u8..).map(|idx| match idx {
let mut generic = (0u8..).map(|idx| match idx {
idx if idx < 10 => SmolStr::from_iter(['\'', (idx + 48) as char]),
idx => format_smolstr!("'{idx}"),
});
let ctx = &*ctx;
move || {
gen.by_ref()
generic.by_ref()
.find(|s| ctx.lifetime_stacks.iter().flat_map(|it| it.iter()).all(|n| n != s))
.unwrap_or_default()
}

View file

@ -123,13 +123,15 @@ fn setup_logging(log_file_flag: Option<PathBuf>) -> anyhow::Result<()> {
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-syminitialize
if let Ok(path) = env::current_exe() {
if let Some(path) = path.parent() {
env::set_var("_NT_SYMBOL_PATH", path);
// SAFETY: This is safe because this is single-threaded.
unsafe { env::set_var("_NT_SYMBOL_PATH", path); }
}
}
}
if env::var("RUST_BACKTRACE").is_err() {
env::set_var("RUST_BACKTRACE", "short");
// SAFETY: This is safe because this is single-threaded.
unsafe { env::set_var("RUST_BACKTRACE", "short"); }
}
let log_file = env::var("RA_LOG_FILE").ok().map(PathBuf::from).or(log_file_flag);

View file

@ -148,7 +148,8 @@ impl Project<'_> {
let guard = CONFIG_DIR_LOCK.lock();
let test_dir = TestDir::new();
let value = test_dir.path().to_owned();
env::set_var("__TEST_RA_USER_CONFIG_DIR", &value);
// SAFETY: This is safe because this is single-threaded.
unsafe { env::set_var("__TEST_RA_USER_CONFIG_DIR", &value); }
(guard, test_dir)
})
} else {

View file

@ -1066,7 +1066,7 @@ impl ast::GenericParamList {
ast::GenericParam::TypeParam(_) | ast::GenericParam::ConstParam(_) => None,
})
}
pub fn type_or_const_params(&self) -> impl Iterator<Item = ast::TypeOrConstParam> {
pub fn type_or_const_params(&self) -> impl Iterator<Item = ast::TypeOrConstParam> + use<> {
self.generic_params().filter_map(|param| match param {
ast::GenericParam::TypeParam(it) => Some(ast::TypeOrConstParam::Type(it)),
ast::GenericParam::LifetimeParam(_) => None,