Skip to content

Commit 66a1548

Browse files
committed
Auto merge of #152739 - Zalathar:rollup-8qaJ8F2, r=Zalathar
Rollup of 11 pull requests Successful merges: - rust-lang/rust#152700 (miri subtree update) - rust-lang/rust#152715 (`rust-analyzer` subtree update) - rust-lang/rust#151783 (Implement RFC 3678: Final trait methods) - rust-lang/rust#152512 (core: Implement feature `float_exact_integer_constants`) - rust-lang/rust#152661 (Avoid ICE in From/TryFrom diagnostic under -Znext-solver) - rust-lang/rust#152703 (Remove `rustc_query_system`) - rust-lang/rust#152206 (misc doc improvements) - rust-lang/rust#152664 (Fix mis-constructed `file_span` when generating scraped examples) - rust-lang/rust#152698 (Suppress unstable-trait notes under `-Zforce-unstable-if-unmarked`) - rust-lang/rust#152727 (`probe_op` silence ambiguity errors if tainted) - rust-lang/rust#152728 (Port #![default_lib_allocator] to the new attribute parser)
2 parents 3efb0c2 + b11bb5e commit 66a1548

71 files changed

Lines changed: 1709 additions & 589 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yaml

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ jobs:
9696
run: |
9797
rustup update --no-self-update stable
9898
rustup default stable
99-
rustup component add --toolchain stable rust-src clippy rustfmt
99+
rustup component add --toolchain stable rust-src rustfmt
100100
# We also install a nightly rustfmt, because we use `--file-lines` in
101101
# a test.
102102
rustup toolchain install nightly --profile minimal --component rustfmt
@@ -128,10 +128,6 @@ jobs:
128128
- name: Run cargo-machete
129129
run: cargo machete
130130

131-
- name: Run Clippy
132-
if: matrix.os == 'macos-latest'
133-
run: cargo clippy --all-targets -- -D clippy::disallowed_macros -D clippy::dbg_macro -D clippy::todo -D clippy::print_stdout -D clippy::print_stderr
134-
135131
analysis-stats:
136132
if: github.repository == 'rust-lang/rust-analyzer'
137133
runs-on: ubuntu-latest
@@ -178,6 +174,28 @@ jobs:
178174
179175
- run: cargo fmt -- --check
180176

177+
clippy:
178+
if: github.repository == 'rust-lang/rust-analyzer'
179+
runs-on: ubuntu-latest
180+
181+
steps:
182+
- name: Checkout repository
183+
uses: actions/checkout@v4
184+
185+
# Note that clippy output is currently dependent on whether rust-src is installed,
186+
# https://github.com/rust-lang/rust-clippy/issues/14625
187+
- name: Install Rust toolchain
188+
run: |
189+
rustup update --no-self-update stable
190+
rustup default stable
191+
rustup component add --toolchain stable rust-src clippy
192+
193+
# https://github.com/actions-rust-lang/setup-rust-toolchain/blob/main/rust.json
194+
- name: Install Rust Problem Matcher
195+
run: echo "::add-matcher::.github/rust.json"
196+
197+
- run: cargo clippy --all-targets -- -D clippy::disallowed_macros -D clippy::dbg_macro -D clippy::todo -D clippy::print_stdout -D clippy::print_stderr
198+
181199
miri:
182200
if: github.repository == 'rust-lang/rust-analyzer'
183201
runs-on: ubuntu-latest
@@ -188,8 +206,11 @@ jobs:
188206

189207
- name: Install Rust toolchain
190208
run: |
191-
rustup update --no-self-update nightly
192-
rustup default nightly
209+
# FIXME: Pin nightly due to a regression in miri on nightly-2026-02-12.
210+
# See https://github.com/rust-lang/miri/issues/4855.
211+
# Revert to plain `nightly` once this is fixed upstream.
212+
rustup toolchain install nightly-2026-02-10
213+
rustup default nightly-2026-02-10
193214
rustup component add miri
194215
195216
# - name: Cache Dependencies
@@ -309,7 +330,7 @@ jobs:
309330
run: typos
310331

311332
conclusion:
312-
needs: [rust, rust-cross, typescript, typo-check, proc-macro-srv, miri, rustfmt, analysis-stats]
333+
needs: [rust, rust-cross, typescript, typo-check, proc-macro-srv, miri, rustfmt, clippy, analysis-stats]
313334
# We need to ensure this job does *not* get skipped if its dependencies fail,
314335
# because a skipped job is considered a success by GitHub. So we have to
315336
# overwrite `if:`. We use `!cancelled()` to ensure the job does still not get run

Cargo.lock

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,13 @@ rayon = "1.10.0"
135135
rowan = "=0.15.17"
136136
# Ideally we'd not enable the macros feature but unfortunately the `tracked` attribute does not work
137137
# on impls without it
138-
salsa = { version = "0.26", default-features = false, features = [
138+
salsa = { version = "0.25.2", default-features = false, features = [
139139
"rayon",
140140
"salsa_unstable",
141141
"macros",
142142
"inventory",
143143
] }
144-
salsa-macros = "0.26"
144+
salsa-macros = "0.25.2"
145145
semver = "1.0.26"
146146
serde = { version = "1.0.219" }
147147
serde_derive = { version = "1.0.219" }

crates/base-db/src/editioned_file_id.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const _: () = {
6060
}
6161
}
6262

63-
impl zalsa_::HashEqLike<WithoutCrate> for EditionedFileIdData {
63+
impl zalsa_struct_::HashEqLike<WithoutCrate> for EditionedFileIdData {
6464
#[inline]
6565
fn hash<H: Hasher>(&self, state: &mut H) {
6666
Hash::hash(self, state);

crates/hir-def/src/expr_store/lower.rs

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ use triomphe::Arc;
3232
use tt::TextRange;
3333

3434
use crate::{
35-
AdtId, BlockId, BlockLoc, DefWithBodyId, FunctionId, GenericDefId, ImplId, MacroId,
36-
ModuleDefId, ModuleId, TraitId, TypeAliasId, UnresolvedMacro,
35+
AdtId, BlockId, BlockLoc, DefWithBodyId, FunctionId, GenericDefId, ImplId, ItemContainerId,
36+
MacroId, ModuleDefId, ModuleId, TraitId, TypeAliasId, UnresolvedMacro,
3737
attrs::AttrFlags,
3838
db::DefDatabase,
3939
expr_store::{
@@ -141,9 +141,19 @@ pub(super) fn lower_body(
141141
source_map_self_param = Some(collector.expander.in_file(AstPtr::new(&self_param_syn)));
142142
}
143143

144+
let is_extern = matches!(
145+
owner,
146+
DefWithBodyId::FunctionId(id)
147+
if matches!(id.loc(db).container, ItemContainerId::ExternBlockId(_)),
148+
);
149+
144150
for param in param_list.params() {
145151
if collector.check_cfg(&param) {
146-
let param_pat = collector.collect_pat_top(param.pat());
152+
let param_pat = if is_extern {
153+
collector.collect_extern_fn_param(param.pat())
154+
} else {
155+
collector.collect_pat_top(param.pat())
156+
};
147157
params.push(param_pat);
148158
}
149159
}
@@ -2248,6 +2258,32 @@ impl<'db> ExprCollector<'db> {
22482258
}
22492259
}
22502260

2261+
fn collect_extern_fn_param(&mut self, pat: Option<ast::Pat>) -> PatId {
2262+
// `extern` functions cannot have pattern-matched parameters, and furthermore, the identifiers
2263+
// in their parameters are always interpreted as bindings, even if in a normal function they
2264+
// won't be, because they would refer to a path pattern.
2265+
let Some(pat) = pat else { return self.missing_pat() };
2266+
2267+
match &pat {
2268+
ast::Pat::IdentPat(bp) => {
2269+
// FIXME: Emit an error if `!bp.is_simple_ident()`.
2270+
2271+
let name = bp.name().map(|nr| nr.as_name()).unwrap_or_else(Name::missing);
2272+
let hygiene = bp
2273+
.name()
2274+
.map(|name| self.hygiene_id_for(name.syntax().text_range()))
2275+
.unwrap_or(HygieneId::ROOT);
2276+
let binding = self.alloc_binding(name, BindingAnnotation::Unannotated, hygiene);
2277+
let pat =
2278+
self.alloc_pat(Pat::Bind { id: binding, subpat: None }, AstPtr::new(&pat));
2279+
self.add_definition_to_binding(binding, pat);
2280+
pat
2281+
}
2282+
// FIXME: Emit an error.
2283+
_ => self.missing_pat(),
2284+
}
2285+
}
2286+
22512287
// region: patterns
22522288

22532289
fn collect_pat_top(&mut self, pat: Option<ast::Pat>) -> PatId {

crates/hir-def/src/item_scope.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,11 @@ impl ItemScope {
483483
self.declarations.push(def)
484484
}
485485

486+
pub(crate) fn remove_from_value_ns(&mut self, name: &Name, def: ModuleDefId) {
487+
let entry = self.values.shift_remove(name);
488+
assert!(entry.is_some_and(|entry| entry.def == def))
489+
}
490+
486491
pub(crate) fn get_legacy_macro(&self, name: &Name) -> Option<&[MacroId]> {
487492
self.legacy_macros.get(name).map(|it| &**it)
488493
}

crates/hir-def/src/nameres.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ struct DefMapCrateData {
211211
/// Side table for resolving derive helpers.
212212
exported_derives: FxHashMap<MacroId, Box<[Name]>>,
213213
fn_proc_macro_mapping: FxHashMap<FunctionId, ProcMacroId>,
214+
fn_proc_macro_mapping_back: FxHashMap<ProcMacroId, FunctionId>,
214215

215216
/// Custom tool modules registered with `#![register_tool]`.
216217
registered_tools: Vec<Symbol>,
@@ -230,6 +231,7 @@ impl DefMapCrateData {
230231
Self {
231232
exported_derives: FxHashMap::default(),
232233
fn_proc_macro_mapping: FxHashMap::default(),
234+
fn_proc_macro_mapping_back: FxHashMap::default(),
233235
registered_tools: PREDEFINED_TOOLS.iter().map(|it| Symbol::intern(it)).collect(),
234236
unstable_features: FxHashSet::default(),
235237
rustc_coherence_is_core: false,
@@ -244,6 +246,7 @@ impl DefMapCrateData {
244246
let Self {
245247
exported_derives,
246248
fn_proc_macro_mapping,
249+
fn_proc_macro_mapping_back,
247250
registered_tools,
248251
unstable_features,
249252
rustc_coherence_is_core: _,
@@ -254,6 +257,7 @@ impl DefMapCrateData {
254257
} = self;
255258
exported_derives.shrink_to_fit();
256259
fn_proc_macro_mapping.shrink_to_fit();
260+
fn_proc_macro_mapping_back.shrink_to_fit();
257261
registered_tools.shrink_to_fit();
258262
unstable_features.shrink_to_fit();
259263
}
@@ -570,6 +574,10 @@ impl DefMap {
570574
self.data.fn_proc_macro_mapping.get(&id).copied()
571575
}
572576

577+
pub fn proc_macro_as_fn(&self, id: ProcMacroId) -> Option<FunctionId> {
578+
self.data.fn_proc_macro_mapping_back.get(&id).copied()
579+
}
580+
573581
pub fn krate(&self) -> Crate {
574582
self.krate
575583
}

crates/hir-def/src/nameres/collector.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@ impl<'db> DefCollector<'db> {
634634
crate_data.exported_derives.insert(proc_macro_id.into(), helpers);
635635
}
636636
crate_data.fn_proc_macro_mapping.insert(fn_id, proc_macro_id);
637+
crate_data.fn_proc_macro_mapping_back.insert(proc_macro_id, fn_id);
637638
}
638639

639640
/// Define a macro with `macro_rules`.
@@ -2095,6 +2096,8 @@ impl ModCollector<'_, '_> {
20952096

20962097
let vis = resolve_vis(def_map, local_def_map, &self.item_tree[it.visibility]);
20972098

2099+
update_def(self.def_collector, fn_id.into(), &it.name, vis, false);
2100+
20982101
if self.def_collector.def_map.block.is_none()
20992102
&& self.def_collector.is_proc_macro
21002103
&& self.module_id == self.def_collector.def_map.root
@@ -2105,9 +2108,14 @@ impl ModCollector<'_, '_> {
21052108
InFile::new(self.file_id(), id),
21062109
fn_id,
21072110
);
2108-
}
21092111

2110-
update_def(self.def_collector, fn_id.into(), &it.name, vis, false);
2112+
// A proc macro is implemented as a function, but it's treated as a macro, not a function.
2113+
// You cannot call it like a function, for example, except in its defining crate.
2114+
// So we keep the function definition, but remove it from the scope, leaving only the macro.
2115+
self.def_collector.def_map[module_id]
2116+
.scope
2117+
.remove_from_value_ns(&it.name, fn_id.into());
2118+
}
21112119
}
21122120
ModItemId::Struct(id) => {
21132121
let it = &self.item_tree[id];

crates/hir-def/src/nameres/tests/macros.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,10 +1068,8 @@ pub fn derive_macro_2(_item: TokenStream) -> TokenStream {
10681068
- AnotherTrait : macro#
10691069
- DummyTrait : macro#
10701070
- TokenStream : type value
1071-
- attribute_macro : value macro#
1072-
- derive_macro : value
1073-
- derive_macro_2 : value
1074-
- function_like_macro : value macro!
1071+
- attribute_macro : macro#
1072+
- function_like_macro : macro!
10751073
"#]],
10761074
);
10771075
}

0 commit comments

Comments
 (0)