diff --git a/crates/hir-expand/src/builtin/derive_macro.rs b/crates/hir-expand/src/builtin/derive_macro.rs index ff50ccef0f..149ab73ec5 100644 --- a/crates/hir-expand/src/builtin/derive_macro.rs +++ b/crates/hir-expand/src/builtin/derive_macro.rs @@ -117,7 +117,7 @@ impl VariantShape { quote! {span => #it : #mapped , } }); quote! {span => - #path { ##fields } + #path { # #fields } } } &VariantShape::Tuple(n) => { @@ -128,7 +128,7 @@ impl VariantShape { } }); quote! {span => - #path ( ##fields ) + #path ( # #fields ) } } VariantShape::Unit => path, @@ -523,7 +523,7 @@ fn expand_simple_derive_with_parsed( let name = info.name; quote! {invoc_span => - impl < ##params #extra_impl_params > #trait_path for #name < ##args > where ##where_block { #trait_body } + impl < # #params #extra_impl_params > #trait_path for #name < # #args > where # #where_block { #trait_body } } } @@ -572,7 +572,7 @@ fn clone_expand( quote! {span => fn clone(&self) -> Self { match self { - ##arms + # #arms } } } @@ -650,7 +650,7 @@ fn debug_expand( } }); quote! {span => - f.debug_struct(#name) ##for_fields .finish() + f.debug_struct(#name) # #for_fields .finish() } } VariantShape::Tuple(n) => { @@ -660,7 +660,7 @@ fn debug_expand( } }); quote! {span => - f.debug_tuple(#name) ##for_fields .finish() + f.debug_tuple(#name) # #for_fields .finish() } } VariantShape::Unit => quote! {span => @@ -703,7 +703,7 @@ fn debug_expand( quote! {span => fn fmt(&self, f: &mut #krate::fmt::Formatter) -> #krate::fmt::Result { match self { - ##arms + # #arms } } } @@ -736,7 +736,7 @@ fn hash_expand( let it = names.iter().map(|it| quote! {span => #it . hash(ra_expand_state); }); quote! {span => { - ##it + # #it } } }; let fat_arrow = fat_arrow(span); @@ -754,7 +754,7 @@ fn hash_expand( fn hash(&self, ra_expand_state: &mut H) { #check_discriminant match self { - ##arms + # #arms } } } @@ -803,7 +803,7 @@ fn partial_eq_expand( let t2 = tt::Ident::new(&format!("{}_other", first.sym), first.span); quote!(span =>#t1 .eq( #t2 )) }; - quote!(span =>#first ##rest) + quote!(span =>#first # #rest) } }; quote! {span => ( #pat1 , #pat2 ) #fat_arrow #body , } @@ -814,7 +814,7 @@ fn partial_eq_expand( quote! {span => fn eq(&self, other: &Self) -> bool { match (self, other) { - ##arms + # #arms _unused #fat_arrow false } } @@ -891,7 +891,7 @@ fn ord_expand( let fat_arrow = fat_arrow(span); let mut body = quote! {span => match (self, other) { - ##arms + # #arms _unused #fat_arrow #krate::cmp::Ordering::Equal } }; @@ -961,7 +961,7 @@ fn partial_ord_expand( right, quote! {span => match (self, other) { - ##arms + # #arms _unused #fat_arrow #krate::option::Option::Some(#krate::cmp::Ordering::Equal) } }, diff --git a/crates/hir-expand/src/builtin/fn_macro.rs b/crates/hir-expand/src/builtin/fn_macro.rs index b56ec3d04c..2fb1f96350 100644 --- a/crates/hir-expand/src/builtin/fn_macro.rs +++ b/crates/hir-expand/src/builtin/fn_macro.rs @@ -240,9 +240,9 @@ fn assert_expand( let dollar_crate = dollar_crate(span); let panic_args = rest.iter(); let mac = if use_panic_2021(db, span) { - quote! {call_site_span => #dollar_crate::panic::panic_2021!(##panic_args) } + quote! {call_site_span => #dollar_crate::panic::panic_2021!(# #panic_args) } } else { - quote! {call_site_span => #dollar_crate::panic!(##panic_args) } + quote! {call_site_span => #dollar_crate::panic!(# #panic_args) } }; let value = cond.value; let expanded = quote! {call_site_span =>{ diff --git a/crates/hir-expand/src/builtin/quote.rs b/crates/hir-expand/src/builtin/quote.rs index 4c8eb74486..9dd2b77b52 100644 --- a/crates/hir-expand/src/builtin/quote.rs +++ b/crates/hir-expand/src/builtin/quote.rs @@ -61,7 +61,7 @@ macro_rules! quote_impl__ { $crate::builtin::quote::__quote!($span $builder $($tail)*); }; - ($span:ident $builder:ident ## $first:ident $($tail:tt)* ) => {{ + ($span:ident $builder:ident # # $first:ident $($tail:tt)* ) => {{ ::std::iter::IntoIterator::into_iter($first).for_each(|it| $crate::builtin::quote::ToTokenTree::to_tokens(it, $span, $builder)); $crate::builtin::quote::__quote!($span $builder $($tail)*); }}; diff --git a/crates/hir-ty/src/mir/lower.rs b/crates/hir-ty/src/mir/lower.rs index 102048b3f4..38924d7c95 100644 --- a/crates/hir-ty/src/mir/lower.rs +++ b/crates/hir-ty/src/mir/lower.rs @@ -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", ), diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 9f91f155ea..caf00665a1 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -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 + '_ { + pub fn autoderef<'db>(&self, db: &'db dyn HirDatabase) -> impl Iterator + 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> { + pub fn as_impl_traits( + &self, + db: &dyn HirDatabase, + ) -> Option + 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) => { diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index b971b2e9f1..a1c0521a5e 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs @@ -2087,7 +2087,7 @@ impl SemanticsScope<'_> { ) } - pub fn resolve_mod_path(&self, path: &ModPath) -> impl Iterator { + pub fn resolve_mod_path(&self, path: &ModPath) -> impl Iterator + use<> { let items = self.resolver.resolve_module_path_in_items(self.db.upcast(), path); items.iter_items().map(|(item, _)| item.into()) } diff --git a/crates/ide-diagnostics/src/lib.rs b/crates/ide-diagnostics/src/lib.rs index dc6fd1f5ea..c6f60a9a96 100644 --- a/crates/ide-diagnostics/src/lib.rs +++ b/crates/ide-diagnostics/src/lib.rs @@ -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 = diff --git a/crates/ide/src/inlay_hints/lifetime.rs b/crates/ide/src/inlay_hints/lifetime.rs index 1fdd698991..7b0b3e19f2 100644 --- a/crates/ide/src/inlay_hints/lifetime.rs +++ b/crates/ide/src/inlay_hints/lifetime.rs @@ -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() } diff --git a/crates/rust-analyzer/src/bin/main.rs b/crates/rust-analyzer/src/bin/main.rs index 1a9cdef256..f2e96197ec 100644 --- a/crates/rust-analyzer/src/bin/main.rs +++ b/crates/rust-analyzer/src/bin/main.rs @@ -123,13 +123,15 @@ fn setup_logging(log_file_flag: Option) -> 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); diff --git a/crates/rust-analyzer/tests/slow-tests/support.rs b/crates/rust-analyzer/tests/slow-tests/support.rs index 1f52f366c5..8496068d67 100644 --- a/crates/rust-analyzer/tests/slow-tests/support.rs +++ b/crates/rust-analyzer/tests/slow-tests/support.rs @@ -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 { diff --git a/crates/syntax/src/ast/node_ext.rs b/crates/syntax/src/ast/node_ext.rs index 56f94b965e..2b330f0858 100644 --- a/crates/syntax/src/ast/node_ext.rs +++ b/crates/syntax/src/ast/node_ext.rs @@ -1066,7 +1066,7 @@ impl ast::GenericParamList { ast::GenericParam::TypeParam(_) | ast::GenericParam::ConstParam(_) => None, }) } - pub fn type_or_const_params(&self) -> impl Iterator { + pub fn type_or_const_params(&self) -> impl Iterator + use<> { self.generic_params().filter_map(|param| match param { ast::GenericParam::TypeParam(it) => Some(ast::TypeOrConstParam::Type(it)), ast::GenericParam::LifetimeParam(_) => None,