Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
c516c28
Add useless prefix `try_into_` for suggest_name
A4-Tacks Dec 28, 2025
72c6b07
Migrate `move_arm_cond_to_match_guard` assist to use `SyntaxEditor`
A4-Tacks Dec 30, 2025
862ab4c
remove unwanted comment
Shourya742 Dec 31, 2025
ec7db07
Allow finding references from doc comments
SomeoneToIgnore Dec 31, 2025
2a7e3e6
add bidirectional flow for file method
Shourya742 Dec 31, 2025
abbf027
add bidirectional flow for local file method
Shourya742 Dec 31, 2025
c4dd25f
add roundtrip abstraction to remove subrequest subresponse boilerplat…
Shourya742 Dec 31, 2025
019d016
Merge pull request #21376 from SomeoneToIgnore/doc-find-defs
Veykril Dec 31, 2025
cde301f
Bump qs from 6.14.0 to 6.14.1 in /editors/code
dependabot[bot] Jan 1, 2026
6394373
add nits
Shourya742 Jan 2, 2026
e34c265
Merge pull request #21361 from A4-Tacks/sugg-name-prefix-try-into
ShoyuVanilla Jan 2, 2026
644eff6
Merge pull request #21383 from rust-lang/dependabot/npm_and_yarn/edit…
ShoyuVanilla Jan 2, 2026
4b34f4f
minor: Fix some minor FIXMEs
Veykril Jan 2, 2026
854f1f8
Merge pull request #21387 from Veykril/push-slxpzqlrpuxt
Veykril Jan 2, 2026
cd7a58e
Pre-allocate intern storages with 64kb of data
Veykril Jan 2, 2026
f841758
Remove unnecessary `ConstLiteralRef` enum
Veykril Jan 2, 2026
94ed628
Merge pull request #21390 from Veykril/push-xkollqttmmrq
Veykril Jan 2, 2026
0598fc6
Merge pull request #21388 from Veykril/push-uyrsywszqotk
Veykril Jan 2, 2026
8d5a7b6
Reduce `impl_signature` query dependencies in method resolution
Veykril Jan 2, 2026
0451cc0
fix: add location links for generic type parameters in inlay hints
benodiwal Jan 2, 2026
1222bbf
feat: added tests
benodiwal Jan 2, 2026
dd97e41
for filename, use localfilename first and then resort to other constr…
Shourya742 Jan 2, 2026
3114dec
fix: add location links for type, const, and lifetime parameters in i…
benodiwal Jan 2, 2026
6326896
emit same info via localfilename and filename
Shourya742 Jan 3, 2026
2483775
Merge pull request #21393 from benodiwal/fix/generic-param-inlay-hint…
Veykril Jan 3, 2026
db43eb0
Merge pull request #21391 from Veykril/push-zttspnlnqpto
Veykril Jan 3, 2026
c56c36e
use fullpath instead of filename
Shourya742 Jan 3, 2026
dfc7440
Merge pull request #21377 from Shourya742/2025-12-31-add-more-proc-ma…
Veykril Jan 3, 2026
7af3130
perf: Only compute lang items for `#![feature(lang_items)]` crates
Veykril Jan 3, 2026
f5aa705
Merge pull request #21396 from Veykril/push-vowxzulyqvuu
Veykril Jan 3, 2026
c99f9c2
Replace sourcedb with expanddb
Shourya742 Jan 3, 2026
38b2e92
added serde to span
Shourya742 Jan 3, 2026
3941fed
add span to proc-macro-srv-cliy
Shourya742 Jan 3, 2026
be566f4
refactor subreq/resp variants to carry span
Shourya742 Jan 3, 2026
4f5502e
Add span to callbacks and correct the source_text implementation
Shourya742 Jan 3, 2026
ce19860
remove span related API from proc-macro-srv/cli/api and remove span f…
Shourya742 Jan 3, 2026
f3b06a1
remove serde from span
Shourya742 Jan 3, 2026
bfe82cb
Merge pull request #21397 from Shourya742/2026-01-03-fix-source-text
Veykril Jan 4, 2026
d4b9ea2
internal: Clean up proc-macro-srv callback trait
Veykril Jan 4, 2026
4bfdbb8
Merge pull request #21400 from Veykril/push-kslvlxlpmwwu
Veykril Jan 4, 2026
50b78f1
Add a README.md to proc-macro-srv-cli
Veykril Jan 4, 2026
6acaa27
Merge pull request #21401 from Veykril/push-optyvyworqny
Veykril Jan 4, 2026
b1ed7e6
Merge pull request #21369 from A4-Tacks/migrate-move-guard
ShoyuVanilla Jan 4, 2026
7dbe12e
fix: Suppress false positive missing assoc item diag on specialization
ShoyuVanilla Jan 4, 2026
8ddb153
Merge pull request #21403 from ShoyuVanilla/missing-assoc-specialize
ChayimFriedman2 Jan 4, 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
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ const _: () = {
krate: Crate,
}

// FIXME: This poses an invalidation problem, if one constructs an `EditionedFileId` with a
// different crate then whatever the input of a memo used, it will invalidate the memo causing
// it to recompute even if the crate is not really used.
/// We like to include the origin crate in an `EditionedFileId` (for use in the item tree),
/// but this poses us a problem.
///
Expand Down
8 changes: 4 additions & 4 deletions src/tools/rust-analyzer/crates/hir-def/src/expr_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ impl HygieneId {
Self(ctx)
}

// FIXME: Inline this
pub(crate) fn lookup(self) -> SyntaxContext {
pub(crate) fn syntax_context(self) -> SyntaxContext {
self.0
}

Expand All @@ -73,7 +72,8 @@ pub type ExprSource = InFile<ExprPtr>;
pub type PatPtr = AstPtr<ast::Pat>;
pub type PatSource = InFile<PatPtr>;

pub type LabelPtr = AstPtr<ast::Label>;
/// BlockExpr -> Desugared label from try block
pub type LabelPtr = AstPtr<Either<ast::Label, ast::BlockExpr>>;
pub type LabelSource = InFile<LabelPtr>;

pub type FieldPtr = AstPtr<ast::RecordExprField>;
Expand Down Expand Up @@ -942,7 +942,7 @@ impl ExpressionStoreSourceMap {
}

pub fn node_label(&self, node: InFile<&ast::Label>) -> Option<LabelId> {
let src = node.map(AstPtr::new);
let src = node.map(AstPtr::new).map(AstPtr::wrap_left);
self.expr_only()?.label_map.get(&src).cloned()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use hir_expand::{
ExpandError, ExpandErrorKind, ExpandResult, HirFileId, InFile, Lookup, MacroCallId,
eager::EagerCallBackFn, mod_path::ModPath, span_map::SpanMap,
};
use span::{AstIdMap, Edition, SyntaxContext};
use span::{AstIdMap, SyntaxContext};
use syntax::ast::HasAttrs;
use syntax::{AstNode, Parse, ast};
use triomphe::Arc;
Expand Down Expand Up @@ -75,11 +75,6 @@ impl Expander {
AttrFlags::is_cfg_enabled_for(owner, cfg_options)
}

pub(super) fn call_syntax_ctx(&self) -> SyntaxContext {
// FIXME:
SyntaxContext::root(Edition::CURRENT_FIXME)
}

pub(super) fn enter_expand<T: ast::AstNode>(
&mut self,
db: &dyn DefDatabase,
Expand Down
20 changes: 9 additions & 11 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 @@ -1096,7 +1096,7 @@ impl<'db> ExprCollector<'db> {
ast::Expr::WhileExpr(e) => self.collect_while_loop(syntax_ptr, e),
ast::Expr::ForExpr(e) => self.collect_for_loop(syntax_ptr, e),
ast::Expr::CallExpr(e) => {
// FIXME: Remove this once we drop support for <1.86, https://github.com/rust-lang/rust/commit/ac9cb908ac4301dfc25e7a2edee574320022ae2c
// FIXME(MINIMUM_SUPPORTED_TOOLCHAIN_VERSION): Remove this once we drop support for <1.86, https://github.com/rust-lang/rust/commit/ac9cb908ac4301dfc25e7a2edee574320022ae2c
let is_rustc_box = {
let attrs = e.attrs();
attrs.filter_map(|it| it.as_simple_atom()).any(|it| it == "rustc_box")
Expand Down Expand Up @@ -1649,7 +1649,7 @@ impl<'db> ExprCollector<'db> {
fn desugar_try_block(&mut self, e: BlockExpr) -> ExprId {
let try_from_output = self.lang_path(self.lang_items().TryTraitFromOutput);
let label = self.generate_new_name();
let label = self.alloc_label_desugared(Label { name: label });
let label = self.alloc_label_desugared(Label { name: label }, AstPtr::new(&e).wrap_right());
let old_label = self.current_try_block_label.replace(label);

let ptr = AstPtr::new(&e).upcast();
Expand Down Expand Up @@ -2319,7 +2319,6 @@ impl<'db> ExprCollector<'db> {
ast::Pat::SlicePat(p) => {
let SlicePatComponents { prefix, slice, suffix } = p.components();

// FIXME properly handle `RestPat`
Pat::Slice {
prefix: prefix.into_iter().map(|p| self.collect_pat(p, binding_list)).collect(),
slice: slice.map(|p| self.collect_pat(p, binding_list)),
Expand Down Expand Up @@ -2399,7 +2398,6 @@ impl<'db> ExprCollector<'db> {
};
let start = range_part_lower(p.start());
let end = range_part_lower(p.end());
// FIXME: Exclusive ended pattern range is stabilised
match p.op_kind() {
Some(range_type) => Pat::Range { start, end, range_type },
None => Pat::Missing,
Expand Down Expand Up @@ -2519,9 +2517,9 @@ impl<'db> ExprCollector<'db> {
let mut hygiene_info = if hygiene_id.is_root() {
None
} else {
hygiene_id.lookup().outer_expn(self.db).map(|expansion| {
hygiene_id.syntax_context().outer_expn(self.db).map(|expansion| {
let expansion = self.db.lookup_intern_macro_call(expansion.into());
(hygiene_id.lookup().parent(self.db), expansion.def)
(hygiene_id.syntax_context().parent(self.db), expansion.def)
})
};
let name = Name::new_lifetime(&lifetime.text());
Expand Down Expand Up @@ -2727,17 +2725,17 @@ impl ExprCollector<'_> {
self.store.pats.alloc(Pat::Missing)
}

fn alloc_label(&mut self, label: Label, ptr: LabelPtr) -> LabelId {
fn alloc_label(&mut self, label: Label, ptr: AstPtr<ast::Label>) -> LabelId {
self.alloc_label_desugared(label, ptr.wrap_left())
}

fn alloc_label_desugared(&mut self, label: Label, ptr: LabelPtr) -> LabelId {
let src = self.expander.in_file(ptr);
let id = self.store.labels.alloc(label);
self.store.label_map_back.insert(id, src);
self.store.label_map.insert(src, id);
id
}
// FIXME: desugared labels don't have ptr, that's wrong and should be fixed somehow.
fn alloc_label_desugared(&mut self, label: Label) -> LabelId {
self.store.labels.alloc(label)
}

fn is_lowering_awaitable_block(&self) -> &Awaitable {
self.awaitable_context.as_ref().unwrap_or(&Awaitable::No("unknown"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use base_db::FxIndexSet;
use hir_expand::name::Name;
use intern::{Symbol, sym};
use span::SyntaxContext;
use syntax::{AstPtr, AstToken as _, ast};

use crate::{
Expand Down Expand Up @@ -49,7 +50,7 @@ impl<'db> ExprCollector<'db> {
self.expand_macros_to_string(template.clone()).map(|it| (it, template))
}) {
Some(((s, is_direct_literal), template)) => {
let call_ctx = self.expander.call_syntax_ctx();
let call_ctx = SyntaxContext::root(self.def_map.edition());
let hygiene = self.hygiene_id_for(s.syntax().text_range());
let fmt = format_args::parse(
&s,
Expand Down
3 changes: 1 addition & 2 deletions src/tools/rust-analyzer/crates/hir-def/src/hir/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ pub type LocalLifetimeParamId = Idx<LifetimeParamData>;
/// Data about a generic type parameter (to a function, struct, impl, ...).
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
pub struct TypeParamData {
/// [`None`] only if the type ref is an [`crate::type_ref::TypeRef::ImplTrait`]. FIXME: Might be better to just
/// make it always be a value, giving impl trait a special name.
/// [`None`] only if the type ref is an [`crate::type_ref::TypeRef::ImplTrait`].
pub name: Option<Name>,
pub default: Option<TypeRefId>,
pub provenance: TypeParamProvenance,
Expand Down
58 changes: 1 addition & 57 deletions src/tools/rust-analyzer/crates/hir-def/src/hir/type_ref.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
//! HIR for references to types. Paths in these are not yet resolved. They can
//! be directly created from an ast::TypeRef, without further queries.

use std::fmt::Write;

use hir_expand::name::Name;
use intern::Symbol;
use la_arena::Idx;
use thin_vec::ThinVec;

use crate::{
LifetimeParamId, TypeParamId,
builtin_type::{BuiltinInt, BuiltinType, BuiltinUint},
expr_store::{
ExpressionStore,
path::{GenericArg, Path},
},
hir::{ExprId, Literal},
hir::ExprId,
};

#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
Expand Down Expand Up @@ -275,56 +272,3 @@ impl TypeBound {
pub struct ConstRef {
pub expr: ExprId,
}

/// A literal constant value
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum LiteralConstRef {
Int(i128),
UInt(u128),
Bool(bool),
Char(char),

/// Case of an unknown value that rustc might know but we don't
// FIXME: this is a hack to get around chalk not being able to represent unevaluatable
// constants
// https://github.com/rust-lang/rust-analyzer/pull/8813#issuecomment-840679177
// https://rust-lang.zulipchat.com/#narrow/stream/144729-wg-traits/topic/Handling.20non.20evaluatable.20constants'.20equality/near/238386348
Unknown,
}

impl LiteralConstRef {
pub fn builtin_type(&self) -> BuiltinType {
match self {
LiteralConstRef::UInt(_) | LiteralConstRef::Unknown => {
BuiltinType::Uint(BuiltinUint::U128)
}
LiteralConstRef::Int(_) => BuiltinType::Int(BuiltinInt::I128),
LiteralConstRef::Char(_) => BuiltinType::Char,
LiteralConstRef::Bool(_) => BuiltinType::Bool,
}
}
}

impl From<Literal> for LiteralConstRef {
fn from(literal: Literal) -> Self {
match literal {
Literal::Char(c) => Self::Char(c),
Literal::Bool(flag) => Self::Bool(flag),
Literal::Int(num, _) => Self::Int(num),
Literal::Uint(num, _) => Self::UInt(num),
_ => Self::Unknown,
}
}
}

impl std::fmt::Display for LiteralConstRef {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
match self {
LiteralConstRef::Int(num) => num.fmt(f),
LiteralConstRef::UInt(num) => num.fmt(f),
LiteralConstRef::Bool(flag) => flag.fmt(f),
LiteralConstRef::Char(c) => write!(f, "'{c}'"),
LiteralConstRef::Unknown => f.write_char('_'),
}
}
}
16 changes: 12 additions & 4 deletions src/tools/rust-analyzer/crates/hir-def/src/item_scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ pub struct ItemScope {
/// declared.
declarations: ThinVec<ModuleDefId>,

impls: ThinVec<ImplId>,
impls: ThinVec<(ImplId, /* trait impl */ bool)>,
builtin_derive_impls: ThinVec<BuiltinDeriveImplId>,
extern_blocks: ThinVec<ExternBlockId>,
unnamed_consts: ThinVec<ConstId>,
Expand Down Expand Up @@ -327,7 +327,15 @@ impl ItemScope {
}

pub fn impls(&self) -> impl ExactSizeIterator<Item = ImplId> + '_ {
self.impls.iter().copied()
self.impls.iter().map(|&(id, _)| id)
}

pub fn trait_impls(&self) -> impl Iterator<Item = ImplId> + '_ {
self.impls.iter().filter(|&&(_, is_trait_impl)| is_trait_impl).map(|&(id, _)| id)
}

pub fn inherent_impls(&self) -> impl Iterator<Item = ImplId> + '_ {
self.impls.iter().filter(|&&(_, is_trait_impl)| !is_trait_impl).map(|&(id, _)| id)
}

pub fn builtin_derive_impls(&self) -> impl ExactSizeIterator<Item = BuiltinDeriveImplId> + '_ {
Expand Down Expand Up @@ -472,8 +480,8 @@ impl ItemScope {
self.legacy_macros.get(name).map(|it| &**it)
}

pub(crate) fn define_impl(&mut self, imp: ImplId) {
self.impls.push(imp);
pub(crate) fn define_impl(&mut self, imp: ImplId, is_trait_impl: bool) {
self.impls.push((imp, is_trait_impl));
}

pub(crate) fn define_builtin_derive_impl(&mut self, imp: BuiltinDeriveImplId) {
Expand Down
4 changes: 3 additions & 1 deletion src/tools/rust-analyzer/crates/hir-def/src/item_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,9 @@ pub struct Trait {
}

#[derive(Debug, Clone, Eq, PartialEq)]
pub struct Impl {}
pub struct Impl {
pub is_trait_impl: bool,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct TypeAlias {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ impl<'a> Ctx<'a> {
let ast_id = self.source_ast_id_map.ast_id(impl_def);
// Note that trait impls don't get implicit `Self` unlike traits, because here they are a
// type alias rather than a type parameter, so this is handled by the resolver.
let res = Impl {};
let res = Impl { is_trait_impl: impl_def.trait_().is_some() };
self.tree.small_data.insert(ast_id.upcast(), SmallModItem::Impl(res));
ast_id
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ impl Printer<'_> {
w!(self, "trait {} {{ ... }}", name.display(self.db, self.edition));
}
ModItemId::Impl(ast_id) => {
let Impl {} = &self.tree[ast_id];
let Impl { is_trait_impl: _ } = &self.tree[ast_id];
self.print_ast_id(ast_id.erase());
w!(self, "impl {{ ... }}");
}
Expand Down
6 changes: 5 additions & 1 deletion src/tools/rust-analyzer/crates/hir-def/src/lang_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ pub fn crate_lang_items(db: &dyn DefDatabase, krate: Crate) -> Option<Box<LangIt

let crate_def_map = crate_def_map(db, krate);

if !crate_def_map.is_unstable_feature_enabled(&sym::lang_items) {
return None;
}

for (_, module_data) in crate_def_map.modules() {
for impl_def in module_data.scope.impls() {
for impl_def in module_data.scope.inherent_impls() {
lang_items.collect_lang_item(db, impl_def);
for &(_, assoc) in impl_def.impl_items(db).items.iter() {
match assoc {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mod proc_macros;

use std::{any::TypeId, iter, ops::Range, sync};

use base_db::{RootQueryDb, SourceDatabase};
use base_db::RootQueryDb;
use expect_test::Expect;
use hir_expand::{
AstId, ExpansionInfo, InFile, MacroCallId, MacroCallKind, MacroKind,
Expand Down Expand Up @@ -387,7 +387,7 @@ struct IdentityWhenValidProcMacroExpander;
impl ProcMacroExpander for IdentityWhenValidProcMacroExpander {
fn expand(
&self,
_: &dyn SourceDatabase,
_: &dyn ExpandDatabase,
subtree: &TopSubtree,
_: Option<&TopSubtree>,
_: &base_db::Env,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2028,7 +2028,9 @@ impl ModCollector<'_, '_> {
let impl_id =
ImplLoc { container: module_id, id: InFile::new(self.file_id(), imp) }
.intern(db);
self.def_collector.def_map.modules[self.module_id].scope.define_impl(impl_id)
self.def_collector.def_map.modules[self.module_id]
.scope
.define_impl(impl_id, self.item_tree[imp].is_trait_impl)
}
ModItemId::Function(id) => {
let it = &self.item_tree[id];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ impl DefMap {
// plain import or absolute path in 2015: crate-relative with
// fallback to extern prelude (with the simplification in
// rust-lang/rust#57745)
// FIXME there must be a nicer way to write this condition
PathKind::Plain | PathKind::Abs
if self.data.edition == Edition::Edition2015
&& (path.kind == PathKind::Abs || mode == ResolveMode::Import) =>
Expand Down Expand Up @@ -383,7 +382,6 @@ impl DefMap {
// plain import or absolute path in 2015: crate-relative with
// fallback to extern prelude (with the simplification in
// rust-lang/rust#57745)
// FIXME there must be a nicer way to write this condition
PathKind::Plain | PathKind::Abs
if self.data.edition == Edition::Edition2015
&& (path.kind == PathKind::Abs || mode == ResolveMode::Import) =>
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rust-analyzer/crates/hir-def/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ fn hygiene_info(
hygiene_id: HygieneId,
) -> Option<(SyntaxContext, MacroDefId)> {
if !hygiene_id.is_root() {
let ctx = hygiene_id.lookup();
let ctx = hygiene_id.syntax_context();
ctx.outer_expn(db).map(|expansion| {
let expansion = db.lookup_intern_macro_call(expansion.into());
(ctx.parent(db), expansion.def)
Expand Down
Loading
Loading