Skip to content

Commit aad66c7

Browse files
Fix 2024 syntax errors
1 parent 71ff7fb commit aad66c7

File tree

11 files changed

+35
-28
lines changed

11 files changed

+35
-28
lines changed

crates/hir-expand/src/builtin/derive_macro.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl VariantShape {
117117
quote! {span => #it : #mapped , }
118118
});
119119
quote! {span =>
120-
#path { ##fields }
120+
#path { # #fields }
121121
}
122122
}
123123
&VariantShape::Tuple(n) => {
@@ -128,7 +128,7 @@ impl VariantShape {
128128
}
129129
});
130130
quote! {span =>
131-
#path ( ##fields )
131+
#path ( # #fields )
132132
}
133133
}
134134
VariantShape::Unit => path,
@@ -523,7 +523,7 @@ fn expand_simple_derive_with_parsed(
523523

524524
let name = info.name;
525525
quote! {invoc_span =>
526-
impl < ##params #extra_impl_params > #trait_path for #name < ##args > where ##where_block { #trait_body }
526+
impl < # #params #extra_impl_params > #trait_path for #name < # #args > where # #where_block { #trait_body }
527527
}
528528
}
529529

@@ -572,7 +572,7 @@ fn clone_expand(
572572
quote! {span =>
573573
fn clone(&self) -> Self {
574574
match self {
575-
##arms
575+
# #arms
576576
}
577577
}
578578
}
@@ -650,7 +650,7 @@ fn debug_expand(
650650
}
651651
});
652652
quote! {span =>
653-
f.debug_struct(#name) ##for_fields .finish()
653+
f.debug_struct(#name) # #for_fields .finish()
654654
}
655655
}
656656
VariantShape::Tuple(n) => {
@@ -660,7 +660,7 @@ fn debug_expand(
660660
}
661661
});
662662
quote! {span =>
663-
f.debug_tuple(#name) ##for_fields .finish()
663+
f.debug_tuple(#name) # #for_fields .finish()
664664
}
665665
}
666666
VariantShape::Unit => quote! {span =>
@@ -703,7 +703,7 @@ fn debug_expand(
703703
quote! {span =>
704704
fn fmt(&self, f: &mut #krate::fmt::Formatter) -> #krate::fmt::Result {
705705
match self {
706-
##arms
706+
# #arms
707707
}
708708
}
709709
}
@@ -736,7 +736,7 @@ fn hash_expand(
736736
let it =
737737
names.iter().map(|it| quote! {span => #it . hash(ra_expand_state); });
738738
quote! {span => {
739-
##it
739+
# #it
740740
} }
741741
};
742742
let fat_arrow = fat_arrow(span);
@@ -754,7 +754,7 @@ fn hash_expand(
754754
fn hash<H: #krate::hash::Hasher>(&self, ra_expand_state: &mut H) {
755755
#check_discriminant
756756
match self {
757-
##arms
757+
# #arms
758758
}
759759
}
760760
}
@@ -803,7 +803,7 @@ fn partial_eq_expand(
803803
let t2 = tt::Ident::new(&format!("{}_other", first.sym), first.span);
804804
quote!(span =>#t1 .eq( #t2 ))
805805
};
806-
quote!(span =>#first ##rest)
806+
quote!(span =>#first # #rest)
807807
}
808808
};
809809
quote! {span => ( #pat1 , #pat2 ) #fat_arrow #body , }
@@ -814,7 +814,7 @@ fn partial_eq_expand(
814814
quote! {span =>
815815
fn eq(&self, other: &Self) -> bool {
816816
match (self, other) {
817-
##arms
817+
# #arms
818818
_unused #fat_arrow false
819819
}
820820
}
@@ -891,7 +891,7 @@ fn ord_expand(
891891
let fat_arrow = fat_arrow(span);
892892
let mut body = quote! {span =>
893893
match (self, other) {
894-
##arms
894+
# #arms
895895
_unused #fat_arrow #krate::cmp::Ordering::Equal
896896
}
897897
};
@@ -961,7 +961,7 @@ fn partial_ord_expand(
961961
right,
962962
quote! {span =>
963963
match (self, other) {
964-
##arms
964+
# #arms
965965
_unused #fat_arrow #krate::option::Option::Some(#krate::cmp::Ordering::Equal)
966966
}
967967
},

crates/hir-expand/src/builtin/fn_macro.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ fn assert_expand(
240240
let dollar_crate = dollar_crate(span);
241241
let panic_args = rest.iter();
242242
let mac = if use_panic_2021(db, span) {
243-
quote! {call_site_span => #dollar_crate::panic::panic_2021!(##panic_args) }
243+
quote! {call_site_span => #dollar_crate::panic::panic_2021!(# #panic_args) }
244244
} else {
245-
quote! {call_site_span => #dollar_crate::panic!(##panic_args) }
245+
quote! {call_site_span => #dollar_crate::panic!(# #panic_args) }
246246
};
247247
let value = cond.value;
248248
let expanded = quote! {call_site_span =>{

crates/hir-expand/src/builtin/quote.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ macro_rules! quote_impl__ {
6161
$crate::builtin::quote::__quote!($span $builder $($tail)*);
6262
};
6363

64-
($span:ident $builder:ident ## $first:ident $($tail:tt)* ) => {{
64+
($span:ident $builder:ident # # $first:ident $($tail:tt)* ) => {{
6565
::std::iter::IntoIterator::into_iter($first).for_each(|it| $crate::builtin::quote::ToTokenTree::to_tokens(it, $span, $builder));
6666
$crate::builtin::quote::__quote!($span $builder $($tail)*);
6767
}};

crates/hir-ty/src/mir/lower.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
518518
let Some(def) = self.owner.as_generic_def_id(self.db.upcast()) else {
519519
not_supported!("owner without generic def id");
520520
};
521-
let gen = generics(self.db.upcast(), def);
521+
let generics = generics(self.db.upcast(), def);
522522
let ty = self.expr_ty_without_adjust(expr_id);
523523
self.push_assignment(
524524
current,
@@ -528,7 +528,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
528528
ty,
529529
value: chalk_ir::ConstValue::BoundVar(BoundVar::new(
530530
DebruijnIndex::INNERMOST,
531-
gen.type_or_const_param_idx(p.into()).ok_or(
531+
generics.type_or_const_param_idx(p.into()).ok_or(
532532
MirLowerError::TypeError(
533533
"fail to lower const generic param",
534534
),

crates/hir/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5261,7 +5261,7 @@ impl Type {
52615261

52625262
/// Returns types that this type dereferences to (including this type itself). The returned
52635263
/// iterator won't yield the same type more than once even if the deref chain contains a cycle.
5264-
pub fn autoderef(&self, db: &dyn HirDatabase) -> impl Iterator<Item = Type> + '_ {
5264+
pub fn autoderef<'db>(&self, db: &'db dyn HirDatabase) -> impl Iterator<Item = Type> + use<'_, 'db> {
52655265
self.autoderef_(db).map(move |ty| self.derived(ty))
52665266
}
52675267

@@ -5637,7 +5637,10 @@ impl Type {
56375637
.map(Trait::from)
56385638
}
56395639

5640-
pub fn as_impl_traits(&self, db: &dyn HirDatabase) -> Option<impl Iterator<Item = Trait>> {
5640+
pub fn as_impl_traits(
5641+
&self,
5642+
db: &dyn HirDatabase,
5643+
) -> Option<impl Iterator<Item = Trait> + use<>> {
56415644
self.ty.impl_trait_bounds(db).map(|it| {
56425645
it.into_iter().filter_map(|pred| match pred.skip_binders() {
56435646
hir_ty::WhereClause::Implemented(trait_ref) => {

crates/hir/src/semantics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2087,7 +2087,7 @@ impl SemanticsScope<'_> {
20872087
)
20882088
}
20892089

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

crates/ide-diagnostics/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,8 @@ fn fill_lint_attrs(
780780
}
781781
});
782782

783-
let all_matching_groups = lint_groups(&diag.code, edition)
783+
let lints = lint_groups(&diag.code, edition);
784+
let all_matching_groups = lints
784785
.iter()
785786
.filter_map(|lint_group| cached.get(lint_group));
786787
let cached_severity =

crates/ide/src/inlay_hints/lifetime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,13 @@ fn hints_(
268268
ctx.lifetime_stacks.iter().flat_map(|it| it.iter()).cloned().zip(iter::repeat(0)).collect();
269269
// allocate names
270270
let mut gen_idx_name = {
271-
let mut gen = (0u8..).map(|idx| match idx {
271+
let mut generic = (0u8..).map(|idx| match idx {
272272
idx if idx < 10 => SmolStr::from_iter(['\'', (idx + 48) as char]),
273273
idx => format_smolstr!("'{idx}"),
274274
});
275275
let ctx = &*ctx;
276276
move || {
277-
gen.by_ref()
277+
generic.by_ref()
278278
.find(|s| ctx.lifetime_stacks.iter().flat_map(|it| it.iter()).all(|n| n != s))
279279
.unwrap_or_default()
280280
}

crates/rust-analyzer/src/bin/main.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,15 @@ fn setup_logging(log_file_flag: Option<PathBuf>) -> anyhow::Result<()> {
123123
// https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-syminitialize
124124
if let Ok(path) = env::current_exe() {
125125
if let Some(path) = path.parent() {
126-
env::set_var("_NT_SYMBOL_PATH", path);
126+
// SAFETY: This is safe because this is single-threaded.
127+
unsafe { env::set_var("_NT_SYMBOL_PATH", path); }
127128
}
128129
}
129130
}
130131

131132
if env::var("RUST_BACKTRACE").is_err() {
132-
env::set_var("RUST_BACKTRACE", "short");
133+
// SAFETY: This is safe because this is single-threaded.
134+
unsafe { env::set_var("RUST_BACKTRACE", "short"); }
133135
}
134136

135137
let log_file = env::var("RA_LOG_FILE").ok().map(PathBuf::from).or(log_file_flag);

crates/rust-analyzer/tests/slow-tests/support.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ impl Project<'_> {
148148
let guard = CONFIG_DIR_LOCK.lock();
149149
let test_dir = TestDir::new();
150150
let value = test_dir.path().to_owned();
151-
env::set_var("__TEST_RA_USER_CONFIG_DIR", &value);
151+
// SAFETY: This is safe because this is single-threaded.
152+
unsafe { env::set_var("__TEST_RA_USER_CONFIG_DIR", &value); }
152153
(guard, test_dir)
153154
})
154155
} else {

0 commit comments

Comments
 (0)