Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
768091d
fix: don't panic on doc comments attached to literal expressions
Aditya-PS-05 Sep 4, 2026
f8326c9
ide: fix doc comment offset calculation
dimxy Sep 6, 2026
af3f278
internal: Add regression test for 'failed to unify type errors' panic
Wilfred Sep 7, 2026
fcdf7f6
Merge pull request #23309 from Wilfred/fix/term-search-unify-regressi…
ChayimFriedman2 Sep 7, 2026
071f269
fix: restore the `#[deprecated]` attr
ada4a Sep 3, 2026
ccfeaac
remove `allow`s that are no longer necessary
ada4a Aug 11, 2026
1aa9a9e
Fix `hir::Type` owner mismatches between anon consts
ChayimFriedman2 Sep 8, 2026
0de0415
Remove some unused code
ChayimFriedman2 Sep 8, 2026
2cd39c2
Merge pull request #23316 from ChayimFriedman2/remove-unused
ChayimFriedman2 Sep 8, 2026
a57cd31
Do not fill the body for `Drop::drop()` and `#[rustc_must_implement_o…
ChayimFriedman2 Sep 8, 2026
9fdf3cd
Do not run the "Generate lints and feature flags" CI workflow on forks
ChayimFriedman2 Sep 8, 2026
f625440
Merge pull request #23321 from ChayimFriedman2/no-lints-workflow-fork
ChayimFriedman2 Sep 8, 2026
45dda07
Merge pull request #23300 from dimxy/fix-doc-comment-nav-panic
ChayimFriedman2 Sep 8, 2026
1793d1e
Stop at eager macro recursion overflow
ChayimFriedman2 Sep 8, 2026
77db98f
use `expect` for lints we actually expect
ada4a Aug 11, 2026
3bae6b7
follow the suggestions of the lints
ada4a Aug 11, 2026
27e05d3
triage `clippy::disallowed_types`
ada4a Sep 7, 2026
93bf99f
underscore-prefix the field storing `EnteredSpan`
ada4a Sep 9, 2026
e6c7cf4
a few more misc clean-ups
ada4a Aug 11, 2026
065aa82
fix: Don't support const blocks in patterns
Wilfred Sep 7, 2026
c596c7d
fix: do not panic on json with invalid field name
A4-Tacks Sep 9, 2026
f82e963
fix: correct incorrect_case suggestion for raw identifiers
edragain2nd Sep 9, 2026
178a4df
Merge pull request #23311 from ada4a/push-lwkopltlwnlt
ChayimFriedman2 Sep 9, 2026
d22bc72
Merge pull request #23307 from Wilfred/fix/const-block-double-infer
ChayimFriedman2 Sep 9, 2026
3cdd184
Merge pull request #23330 from A4-Tacks/json-invalid-field-name
ChayimFriedman2 Sep 9, 2026
e3fefe4
Merge pull request #23333 from edragain2nd/fix/incorrect_upper_camel_…
ChayimFriedman2 Sep 9, 2026
a538446
Merge pull request #23295 from Aditya-PS-05/fix-doc-comment-literal-p…
ChayimFriedman2 Sep 9, 2026
ff71565
fix: correct incorrect_case suggestion for enum variants with raw key…
edragain2nd Sep 10, 2026
cea6437
Merge pull request #23340 from edragain2nd/fix/incorrect_upper_camel_…
A4-Tacks Sep 10, 2026
8ff7045
Merge pull request #23315 from ChayimFriedman2/anon-const-owner
Veykril Sep 11, 2026
fc45e8c
Merge pull request #23317 from ChayimFriedman2/force-empty-body
Veykril Sep 11, 2026
60aff9f
Merge pull request #23323 from ChayimFriedman2/eager-recursion-limit
Veykril Sep 11, 2026
df4f90d
panic when we call impls_trait for types associated with builtin deri…
anatawa12 Sep 13, 2026
b14856a
Merge pull request #23352 from anatawa12/fix-panic-with-is-impl-with-…
ChayimFriedman2 Sep 13, 2026
9282e0a
Remove the interner/db argument from `empty()` and `default_types()`
ChayimFriedman2 Sep 9, 2026
05c806d
Do not fill unstable methods in "Implement default members"
ChayimFriedman2 Sep 8, 2026
e9e9680
Merge pull request #23325 from ChayimFriedman2/no-interner-interneds
ChayimFriedman2 Sep 13, 2026
62bfc83
Merge pull request #23318 from ChayimFriedman2/add-impl-members-unstable
ChayimFriedman2 Sep 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/tools/rust-analyzer/.github/workflows/gen-lints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ defaults:

jobs:
lints-gen:
if: ${{ github.repository == 'rust-lang/rust-analyzer' || github.event_name == 'workflow_dispatch' }}
name: Generate lints
runs-on: ubuntu-latest
permissions:
Expand Down
1 change: 1 addition & 0 deletions src/tools/rust-analyzer/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1889,6 +1889,7 @@ dependencies = [
"line-index 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"paths",
"proc-macro-test",
"rustc-hash 2.1.2",
"span",
"stdx",
]
Expand Down
8 changes: 4 additions & 4 deletions src/tools/rust-analyzer/clippy.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
disallowed-types = [
{ path = "std::collections::HashMap", reason = "use FxHashMap" },
{ path = "std::collections::HashSet", reason = "use FxHashSet" },
{ path = "std::collections::hash_map::RandomState", reason = "use BuildHasherDefault<FxHasher>"}
{ path = "std::collections::HashMap", replacement = "rustc_hash::FxHashMap" },
{ path = "std::collections::HashSet", replacement = "rustc_hash::FxHashSet" },
{ path = "std::collections::hash_map::RandomState", replacement = "std::hash::BuildHasherDefault<FxHasher>"}
]

disallowed-methods = [
{ path = "std::process::Command::new", reason = "use `toolchain::command` instead as it forces the choice of a working directory" },
{ path = "std::process::Command::new", replacement = "toolchain::command", reason = "the latter forces the choice of a working directory" },
]
12 changes: 8 additions & 4 deletions src/tools/rust-analyzer/crates/base-db/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

use std::error::Error;
use std::hash::BuildHasherDefault;
use std::str::FromStr;
use std::{fmt, mem, ops};

use cfg::{CfgOptions, HashableCfgOptions};
Expand Down Expand Up @@ -315,14 +316,17 @@ impl ReleaseChannel {
ReleaseChannel::Nightly => "nightly",
}
}
}

impl FromStr for ReleaseChannel {
type Err = ();

#[allow(clippy::should_implement_trait)]
pub fn from_str(str: &str) -> Option<Self> {
Some(match str {
fn from_str(str: &str) -> Result<Self, Self::Err> {
Ok(match str {
"" | "stable" => ReleaseChannel::Stable,
"nightly" => ReleaseChannel::Nightly,
_ if str.starts_with("beta") => ReleaseChannel::Beta,
_ => return None,
_ => return Err(()),
})
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/tools/rust-analyzer/crates/base-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use std::{
cell::RefCell,
hash::BuildHasherDefault,
panic,
str::FromStr as _,
sync::{Once, atomic::AtomicUsize},
};

Expand Down Expand Up @@ -327,7 +328,7 @@ impl CrateWorkspaceData {
}

pub fn toolchain_channel(db: &dyn salsa::Database, krate: Crate) -> Option<ReleaseChannel> {
krate.workspace_data(db).toolchain.as_ref().and_then(|v| ReleaseChannel::from_str(&v.pre))
krate.workspace_data(db).toolchain.as_ref().and_then(|v| ReleaseChannel::from_str(&v.pre).ok())
}

#[salsa::input(singleton, debug)]
Expand Down
1 change: 1 addition & 0 deletions src/tools/rust-analyzer/crates/hir-def/src/attrs/docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ fn expand_doc_macro_call<'db>(
ExpandTo::Expr,
expander.krate,
expander.macro_depth + 1,
expander.recursion_limit,
|path| {
expander.resolver.resolve_path_as_macro_def(expander.db, path, Some(MacroSubNs::Bang))
},
Expand Down
4 changes: 0 additions & 4 deletions src/tools/rust-analyzer/crates/hir-def/src/dyn_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ pub struct Key<K, V, P = (K, V)> {
}

impl<K, V, P> Key<K, V, P> {
#[allow(
clippy::new_without_default,
reason = "this a const fn, so it can't be default yet. See <https://github.com/rust-lang/rust/issues/63065>"
)]
pub(crate) const fn new() -> Key<K, V, P> {
Key { _phantom: PhantomData }
}
Expand Down
1 change: 0 additions & 1 deletion src/tools/rust-analyzer/crates/hir-def/src/expr_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,6 @@ impl ExpressionStore {
visitor.on_expr_opt(*end);
}
Pat::Lit(expr) | Pat::Expr(expr) => visitor.on_expr(*expr),
Pat::ConstBlock(expr) => visitor.on_anon_const_expr(*expr),
Pat::Path(path) => visitor.on_path(path),
Pat::Wild | Pat::Missing | Pat::Rest | Pat::NotNull => {}
&Pat::Bind { subpat, id: _ } => visitor.on_pat_opt(subpat),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ impl<'db> Expander<'db> {
call_site.ctx,
expands_to,
krate,
this.macro_depth,
this.macro_depth + 1,
this.recursion_limit,
|path| resolver(path).map(|it| it.definition(db)),
eager_callback,
) {
Expand Down
21 changes: 1 addition & 20 deletions src/tools/rust-analyzer/crates/hir-def/src/expr_store/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3082,16 +3082,7 @@ impl<'db> ExprCollector<'db> {
Pat::Deref { inner }
}
ast::Pat::NotNull(_) => Pat::NotNull,
ast::Pat::ConstBlockPat(const_block_pat) => {
if let Some(block) = const_block_pat.block_expr() {
let expr_id = self.with_label_rib(RibKind::Constant, |this| {
this.with_binding_owner(|this| this.collect_block(block))
});
Pat::ConstBlock(expr_id)
} else {
Pat::Missing
}
}
ast::Pat::ConstBlockPat(_) => Pat::Missing,
ast::Pat::MacroPat(mac) => {
return self.collect_macro_pat_with(mac.clone(), |this, expanded_pat| {
this.collect_pat(expanded_pat, binding_list)
Expand Down Expand Up @@ -3277,16 +3268,6 @@ impl<'db> ExprCollector<'db> {
let Some((literal, _)) = pat_literal_to_hir(it) else { return self.missing_expr() };
self.alloc_expr_from_pat(Expr::Literal(literal), ptr)
}
ast::Pat::ConstBlockPat(it) => {
if let Some(block) = it.block_expr() {
let expr_id = self.with_label_rib(RibKind::Constant, |this| {
this.with_binding_owner(|this| this.collect_block(block))
});
self.alloc_expr_from_pat(Expr::Const(expr_id), ptr)
} else {
self.missing_expr()
}
}
ast::Pat::PathPat(it) => {
let path = it
.path()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1033,10 +1033,6 @@ impl Printer<'_> {
self.print_pat(*inner);
w!(self, ")");
}
Pat::ConstBlock(c) => {
w!(self, "const ");
self.print_expr(*c);
}
Pat::Expr(expr) => {
self.print_expr_in(prec, *expr);
}
Expand Down
67 changes: 4 additions & 63 deletions src/tools/rust-analyzer/crates/hir-def/src/expr_store/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ impl ExprScopes {
}

/// If `scope` refers to a macro def scope, returns the corresponding `MacroId`.
#[allow(clippy::borrowed_box)] // If we return `&MacroDefId` we need to move it, this way we just clone the `Box`.
#[expect(
clippy::borrowed_box,
reason = "If we return `&MacroDefId` we need to move it, this way we just clone the `Box`."
)]
pub fn macro_def(&self, scope: ScopeId) -> Option<&Box<MacroDefId>> {
match &self.scopes[scope].kind {
ScopeKind::MacroDef(macro_def) => Some(macro_def),
Expand Down Expand Up @@ -818,66 +821,4 @@ fn test() {
100,
);
}
#[test]
fn pattern_const_block_expressions_have_scopes() {
do_check(
r#"
fn foo() {
match () {
const { |x: i32| { let y = x; $0 } } => (),
}
}
"#,
&["y", "x"],
);
}

#[test]
fn let_pattern_expr_scope() {
do_check(
r#"
fn foo(param: usize) {
let local = 0;
let const { $0 } = ();
}
"#,
&["param"],
);
}

#[test]
fn closure_param_pattern_expr_scope() {
do_check(
r#"
fn foo(param: usize) {
let local = 0;
let _ = |const { $0 }: ()| ();
}
"#,
&["param"],
);
}

#[test]
fn fn_param_pattern_expr_scope() {
do_check(
r#"
fn foo(param: usize, const { $0 }: ()) {}
"#,
&["param"],
);
}

#[test]
fn if_let_pattern_expr_scope() {
do_check(
r#"
fn foo(param: usize) {
let local = 0;
if let const { $0 } = () {}
}
"#,
&["param"],
);
}
}
2 changes: 0 additions & 2 deletions src/tools/rust-analyzer/crates/hir-def/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,6 @@ pub enum Pat {
inner: PatId,
},
NotNull,
ConstBlock(ExprId),
/// An expression inside a pattern. That can only occur inside assignments.
///
/// E.g. in `(a, *b) = (1, &mut 2)`, `*b` is an expression.
Expand All @@ -813,7 +812,6 @@ impl Pat {
Pat::Range { .. }
| Pat::Lit(..)
| Pat::Path(..)
| Pat::ConstBlock(..)
| Pat::Wild
| Pat::Missing
| Pat::Rest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ enum PositionUsedAs {
}
use PositionUsedAs::*;

#[allow(clippy::unnecessary_lazy_evaluations)]
pub(crate) fn parse(
s: &ast::String,
string_ptr: AstPtr<ast::Expr>,
Expand Down
2 changes: 2 additions & 0 deletions src/tools/rust-analyzer/crates/hir-def/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1442,6 +1442,7 @@ pub fn macro_call_as_call_id(
expand_to: ExpandTo,
krate: Crate,
macro_depth: u32,
recursion_limit: u32,
resolver: impl Fn(&ModPath) -> Option<MacroDefId> + Copy,
eager_callback: &mut dyn FnMut(
InFile<(syntax::AstPtr<ast::MacroCall>, span::FileAstId<ast::MacroCall>)>,
Expand All @@ -1459,6 +1460,7 @@ pub fn macro_call_as_call_id(
def,
call_site,
macro_depth,
recursion_limit,
&|path| resolver(path).filter(MacroDefId::is_fn_like),
eager_callback,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -628,3 +628,34 @@ const _: bool = foo::<(), fn() -> Foo<i32, i64>>(1, );
"#]],
);
}

#[test]
fn eager_recursion_limit() {
check(
r#"
//- minicore: concat

macro_rules! concat_separator {
() => {
concat!("", concat_separator!())
};
}

fn main() {
concat_separator!()
}
"#,
expect![[r#"

macro_rules! concat_separator {
() => {
concat!("", concat_separator!())
};
}

fn main() {
concat!("", concat_separator!())
}
"#]],
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ impl<'db> AssocItemCollector<'db> {
ExpandTo::Items,
self.module_id.krate(self.db),
self.macro_depth + 1,
self.def_map.recursion_limit(),
resolver,
&mut |ptr, call_id| {
self.macro_calls.push((ptr.map(|(_, it)| it.upcast()), call_id))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,7 @@ impl<'db> DefCollector<'db> {
*expand_to,
self.def_map.krate,
directive.depth,
self.def_map.recursion_limit(),
resolver_def_id,
&mut |ptr, call_id| {
eager_callback_buffer.push((directive.module_id, ptr, call_id));
Expand Down Expand Up @@ -1793,6 +1794,7 @@ impl<'db> DefCollector<'db> {
*expand_to,
self.def_map.krate,
directive.depth,
self.def_map.recursion_limit(),
|path| {
let resolved_res = self.def_map.resolve_path_fp_with_macro(
self.crate_local_def_map.unwrap_or(&self.local_def_map),
Expand Down Expand Up @@ -2698,6 +2700,7 @@ impl ModCollector<'_, '_> {
expand_to,
self.def_collector.def_map.krate,
self.macro_depth + 1,
self.def_collector.def_map.recursion_limit(),
|path| {
path.as_ident().and_then(|name| {
let def_map = &self.def_collector.def_map;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//! A simplified version of quote-crate like quasi quote macro
#![allow(clippy::crate_in_macro_def)]

use intern::{Symbol, sym};
use span::Span;
Expand Down Expand Up @@ -185,7 +184,7 @@ macro_rules! impl_to_to_tokentrees {
$(
impl ToTokenTree for $ty {
fn to_tokens($this, $span: Span, builder: &mut TopSubtreeBuilder) {
let leaf: crate::tt::Leaf = $im.into();
let leaf: $crate::tt::Leaf = $im.into();
builder.push(leaf);
}
}
Expand Down
Loading
Loading