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
4586a31
Fix not complete after inner-attr in source-file
A4-Tacks Nov 6, 2025
c031184
Fix not complete type alias in pattern
A4-Tacks Nov 12, 2025
0234d7c
Fix skipiter not applicable in autoderef
A4-Tacks Nov 22, 2025
9bf3695
Add multiple generate for enum generate is, as, try_into
A4-Tacks Sep 18, 2025
83edf8f
make postcard first class member of proc-macro-srv-cli
Shourya742 Nov 7, 2025
4284804
add postcard related methods to proc-macro-apo
Shourya742 Nov 7, 2025
aea45c3
add postcard abstraction inside Message trait
Shourya742 Nov 22, 2025
c3708c7
add review suggestions
Shourya742 Nov 23, 2025
35e056e
Inline macro sub-namespace lookup into `sub_namespace_match`
Zalathar Nov 23, 2025
0ce6a06
Basic support for declarative attribute/derive macros
Zalathar Nov 23, 2025
09cf067
Record inferred type for type placeholders
nicolas-guichard Jun 26, 2025
eb5401e
Use inferred type in SourceAnalyzer::type_of_type
nicolas-guichard Jun 26, 2025
b331c52
extract_type_alias assist extracts inferred type when possible
nicolas-guichard Jun 26, 2025
93de020
Show inlay hints for type placeholders
nicolas-guichard Jun 30, 2025
af36027
Merge pull request #20125 from nicolas-guichard/push-pypzwzspzznu
ChayimFriedman2 Nov 24, 2025
d73c941
add regression tests for add_missing_impl_members
Natural-selection1 Nov 24, 2025
84d774c
Merge pull request #21123 from Natural-selection1/test
ChayimFriedman2 Nov 24, 2025
ddefc4b
add codec and framing to abstract encoding and decoding logic from run
Shourya742 Nov 24, 2025
8a19d58
Merge pull request #20986 from Shourya742/2025-11-07-add-support-for-…
Veykril Nov 24, 2025
16f4c86
Merge pull request #21121 from Zalathar/derive-macro
ChayimFriedman2 Nov 24, 2025
a54b195
Fix invalid completion arg nr
A4-Tacks Nov 25, 2025
416d88b
Build releases with static CRT for `-windows-msvc` targets.
ColinFinck Nov 12, 2025
ad952c0
Merge pull request #21126 from A4-Tacks/arglist-nr-error-comma
lnicola Nov 25, 2025
5c82106
Merge pull request #21027 from ColinFinck/msvc-crt-static
lnicola Nov 25, 2025
b0d1c9a
completions: Fix completions disregarding snippet capabilities
Veykril Nov 26, 2025
20fa8ab
Merge pull request #21131 from Veykril/push-rxrmsylwoowm
Veykril Nov 26, 2025
e5058c4
minor: Rename proc-macro-srv protocol flags
Veykril Nov 26, 2025
c414fc5
fix: Do not try to connect via postcard to proc-macro-srv
Veykril Nov 26, 2025
6eb6936
return Some(T) and not T in read method Message trait
Shourya742 Nov 26, 2025
c076ef3
Revert to spawning proc-macro-srv without format flag
Veykril Nov 26, 2025
c460a72
Merge pull request #21133 from Veykril/push-olvztmtwzmvv
Veykril Nov 26, 2025
98fffb4
Merge pull request #21135 from Shourya742/2025-11-26-default-json
Veykril Nov 26, 2025
c18ec02
Gate spawning proc-macro-srv with --format on toolchain version
Veykril Nov 26, 2025
f7970fd
Merge pull request #21139 from Veykril/push-wmxmrovmrrxx
Veykril Nov 26, 2025
8c5f7a3
Prepare for merging from rust-lang/rust
invalid-email-address Nov 27, 2025
fc4db45
Merge ref '1be6b13be73d' from rust-lang/rust
invalid-email-address Nov 27, 2025
a60d5fa
Merge pull request #21143 from rust-lang/rustc-pull
lnicola Nov 27, 2025
b8191e6
Merge pull request #20685 from A4-Tacks/enum-multi-gen-is-as
ShoyuVanilla Nov 27, 2025
e958534
Merge pull request #21028 from A4-Tacks/comp-pattern-alias
ShoyuVanilla Nov 27, 2025
32555af
Merge pull request #20976 from A4-Tacks/comp-after-top-inner-attr
ShoyuVanilla Nov 27, 2025
41a2df5
Merge pull request #21095 from A4-Tacks/autoderef-skipiter
Veykril Nov 27, 2025
2578d40
proc-macro-srv: Fix `<TokenStream as Display>::fmt` impl producing tr…
Veykril Nov 27, 2025
7f93ba5
Merge pull request #21145 from Veykril/push-prwwrlwmoxzx
Veykril Nov 27, 2025
6bbdb1f
proc-macro-srv: Fix `<TokenStream as Display>::fmt` impl rendering pu…
Veykril Nov 27, 2025
ac118f9
Merge pull request #21146 from Veykril/push-kwupvlsnstrx
Veykril Nov 27, 2025
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
17 changes: 17 additions & 0 deletions src/tools/rust-analyzer/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,18 @@ version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"

[[package]]
name = "embedded-io"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced"

[[package]]
name = "embedded-io"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d"

[[package]]
name = "ena"
version = "0.14.3"
Expand Down Expand Up @@ -1456,6 +1468,7 @@ name = "mbe"
version = "0.0.0"
dependencies = [
"arrayvec",
"bitflags 2.9.4",
"cov-mark",
"expect-test",
"intern",
Expand Down Expand Up @@ -1785,6 +1798,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6764c3b5dd454e283a30e6dfe78e9b31096d9e32036b5d1eaac7a6119ccb9a24"
dependencies = [
"cobs",
"embedded-io 0.4.0",
"embedded-io 0.6.1",
"heapless",
"serde",
]
Expand Down Expand Up @@ -1820,8 +1835,10 @@ dependencies = [
"indexmap",
"intern",
"paths",
"postcard",
"proc-macro-srv",
"rustc-hash 2.1.1",
"semver",
"serde",
"serde_derive",
"serde_json",
Expand Down
1 change: 1 addition & 0 deletions src/tools/rust-analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ object = { version = "0.36.7", default-features = false, features = [
"macho",
"pe",
] }
postcard = {version = "1.1.3", features = ["alloc"]}
process-wrap = { version = "8.2.1", features = ["std"] }
pulldown-cmark-to-cmark = "10.0.4"
pulldown-cmark = { version = "0.9.6", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rust-analyzer/crates/hir-def/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ fn macro_def(db: &dyn DefDatabase, id: MacroId) -> MacroDefId {
let kind = |expander, file_id, m| {
let in_file = InFile::new(file_id, m);
match expander {
MacroExpander::Declarative => MacroDefKind::Declarative(in_file),
MacroExpander::Declarative { styles } => MacroDefKind::Declarative(in_file, styles),
MacroExpander::BuiltIn(it) => MacroDefKind::BuiltIn(in_file, it),
MacroExpander::BuiltInAttr(it) => MacroDefKind::BuiltInAttr(in_file, it),
MacroExpander::BuiltInDerive(it) => MacroDefKind::BuiltInDerive(in_file, it),
Expand Down
14 changes: 9 additions & 5 deletions src/tools/rust-analyzer/crates/hir-def/src/hir/type_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,16 @@ impl TypeRef {
TypeRef::Tuple(ThinVec::new())
}

pub fn walk(this: TypeRefId, map: &ExpressionStore, f: &mut impl FnMut(&TypeRef)) {
pub fn walk(this: TypeRefId, map: &ExpressionStore, f: &mut impl FnMut(TypeRefId, &TypeRef)) {
go(this, f, map);

fn go(type_ref: TypeRefId, f: &mut impl FnMut(&TypeRef), map: &ExpressionStore) {
let type_ref = &map[type_ref];
f(type_ref);
fn go(
type_ref_id: TypeRefId,
f: &mut impl FnMut(TypeRefId, &TypeRef),
map: &ExpressionStore,
) {
let type_ref = &map[type_ref_id];
f(type_ref_id, type_ref);
match type_ref {
TypeRef::Fn(fn_) => {
fn_.params.iter().for_each(|&(_, param_type)| go(param_type, f, map))
Expand All @@ -224,7 +228,7 @@ impl TypeRef {
};
}

fn go_path(path: &Path, f: &mut impl FnMut(&TypeRef), map: &ExpressionStore) {
fn go_path(path: &Path, f: &mut impl FnMut(TypeRefId, &TypeRef), map: &ExpressionStore) {
if let Some(type_ref) = path.type_anchor() {
go(type_ref, f, map);
}
Expand Down
17 changes: 10 additions & 7 deletions src/tools/rust-analyzer/crates/hir-def/src/item_scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ use thin_vec::ThinVec;

use crate::{
AdtId, BuiltinType, ConstId, ExternBlockId, ExternCrateId, FxIndexMap, HasModule, ImplId,
LocalModuleId, Lookup, MacroId, ModuleDefId, ModuleId, TraitId, UseId,
LocalModuleId, Lookup, MacroCallStyles, MacroId, ModuleDefId, ModuleId, TraitId, UseId,
db::DefDatabase,
nameres::MacroSubNs,
per_ns::{Item, MacrosItem, PerNs, TypesItem, ValuesItem},
visibility::Visibility,
};
Expand Down Expand Up @@ -740,11 +739,15 @@ impl ItemScope {
let mut entries: Vec<_> = self.resolutions().collect();
entries.sort_by_key(|(name, _)| name.clone());

let print_macro_sub_ns =
|buf: &mut String, macro_id: MacroId| match MacroSubNs::from_id(db, macro_id) {
MacroSubNs::Bang => buf.push('!'),
MacroSubNs::Attr => buf.push('#'),
};
let print_macro_sub_ns = |buf: &mut String, macro_id: MacroId| {
let styles = crate::nameres::macro_styles_from_id(db, macro_id);
if styles.contains(MacroCallStyles::FN_LIKE) {
buf.push('!');
}
if styles.contains(MacroCallStyles::ATTR) || styles.contains(MacroCallStyles::DERIVE) {
buf.push('#');
}
};

for (name, def) in entries {
let display_name: &dyn fmt::Display = match &name {
Expand Down
6 changes: 3 additions & 3 deletions src/tools/rust-analyzer/crates/hir-def/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ use std::hash::{Hash, Hasher};

use base_db::{Crate, impl_intern_key};
use hir_expand::{
AstId, ExpandResult, ExpandTo, HirFileId, InFile, MacroCallId, MacroCallKind, MacroDefId,
MacroDefKind,
AstId, ExpandResult, ExpandTo, HirFileId, InFile, MacroCallId, MacroCallKind, MacroCallStyles,
MacroDefId, MacroDefKind,
builtin::{BuiltinAttrExpander, BuiltinDeriveExpander, BuiltinFnLikeExpander, EagerExpander},
db::ExpandDatabase,
eager::expand_eager_macro_input,
Expand Down Expand Up @@ -403,7 +403,7 @@ bitflags::bitflags! {

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum MacroExpander {
Declarative,
Declarative { styles: MacroCallStyles },
BuiltIn(BuiltinFnLikeExpander),
BuiltInAttr(BuiltinAttrExpander),
BuiltInDerive(BuiltinDeriveExpander),
Expand Down
55 changes: 32 additions & 23 deletions src/tools/rust-analyzer/crates/hir-def/src/nameres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ use tt::TextRange;

use crate::{
AstId, BlockId, BlockLoc, CrateRootModuleId, ExternCrateId, FunctionId, FxIndexMap,
LocalModuleId, Lookup, MacroExpander, MacroId, ModuleId, ProcMacroId, UseId,
LocalModuleId, Lookup, MacroCallStyles, MacroExpander, MacroId, ModuleId, ProcMacroId, UseId,
db::DefDatabase,
item_scope::{BuiltinShadowMode, ItemScope},
item_tree::TreeId,
Expand Down Expand Up @@ -813,26 +813,25 @@ pub enum MacroSubNs {
Attr,
}

impl MacroSubNs {
pub(crate) fn from_id(db: &dyn DefDatabase, macro_id: MacroId) -> Self {
let expander = match macro_id {
MacroId::Macro2Id(it) => it.lookup(db).expander,
MacroId::MacroRulesId(it) => it.lookup(db).expander,
MacroId::ProcMacroId(it) => {
return match it.lookup(db).kind {
ProcMacroKind::CustomDerive | ProcMacroKind::Attr => Self::Attr,
ProcMacroKind::Bang => Self::Bang,
};
}
};
pub(crate) fn macro_styles_from_id(db: &dyn DefDatabase, macro_id: MacroId) -> MacroCallStyles {
let expander = match macro_id {
MacroId::Macro2Id(it) => it.lookup(db).expander,
MacroId::MacroRulesId(it) => it.lookup(db).expander,
MacroId::ProcMacroId(it) => {
return match it.lookup(db).kind {
ProcMacroKind::CustomDerive => MacroCallStyles::DERIVE,
ProcMacroKind::Bang => MacroCallStyles::FN_LIKE,
ProcMacroKind::Attr => MacroCallStyles::ATTR,
};
}
};

match expander {
MacroExpander::Declarative { styles } => styles,
// Eager macros aren't *guaranteed* to be bang macros, but they *are* all bang macros currently.
match expander {
MacroExpander::Declarative
| MacroExpander::BuiltIn(_)
| MacroExpander::BuiltInEager(_) => Self::Bang,
MacroExpander::BuiltInAttr(_) | MacroExpander::BuiltInDerive(_) => Self::Attr,
}
MacroExpander::BuiltIn(_) | MacroExpander::BuiltInEager(_) => MacroCallStyles::FN_LIKE,
MacroExpander::BuiltInAttr(_) => MacroCallStyles::ATTR,
MacroExpander::BuiltInDerive(_) => MacroCallStyles::DERIVE,
}
}

Expand All @@ -842,9 +841,19 @@ impl MacroSubNs {
/// We ignore resolutions from one sub-namespace when searching names in scope for another.
///
/// [rustc]: https://github.com/rust-lang/rust/blob/1.69.0/compiler/rustc_resolve/src/macros.rs#L75
fn sub_namespace_match(candidate: Option<MacroSubNs>, expected: Option<MacroSubNs>) -> bool {
match (candidate, expected) {
(Some(candidate), Some(expected)) => candidate == expected,
_ => true,
fn sub_namespace_match(
db: &dyn DefDatabase,
macro_id: MacroId,
expected: Option<MacroSubNs>,
) -> bool {
let candidate = macro_styles_from_id(db, macro_id);
match expected {
Some(MacroSubNs::Bang) => candidate.contains(MacroCallStyles::FN_LIKE),
Some(MacroSubNs::Attr) => {
candidate.contains(MacroCallStyles::ATTR) || candidate.contains(MacroCallStyles::DERIVE)
}
// If we aren't expecting a specific sub-namespace
// (e.g. in `use` declarations), match any macro.
None => true,
}
}
17 changes: 9 additions & 8 deletions src/tools/rust-analyzer/crates/hir-def/src/nameres/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2300,7 +2300,10 @@ impl ModCollector<'_, '_> {
}
} else {
// Case 2: normal `macro_rules!` macro
MacroExpander::Declarative
let id = InFile::new(self.file_id(), ast_id);
let decl_expander = self.def_collector.db.decl_macro_expander(krate, id.upcast());
let styles = decl_expander.mac.rule_styles();
MacroExpander::Declarative { styles }
};
let allow_internal_unsafe = attrs.by_key(sym::allow_internal_unsafe).exists();

Expand Down Expand Up @@ -2369,7 +2372,10 @@ impl ModCollector<'_, '_> {
}
} else {
// Case 2: normal `macro`
MacroExpander::Declarative
let id = InFile::new(self.file_id(), ast_id);
let decl_expander = self.def_collector.db.decl_macro_expander(krate, id.upcast());
let styles = decl_expander.mac.rule_styles();
MacroExpander::Declarative { styles }
};
let allow_internal_unsafe = attrs.by_key(sym::allow_internal_unsafe).exists();

Expand Down Expand Up @@ -2429,12 +2435,7 @@ impl ModCollector<'_, '_> {
})
.or_else(|| def_map[self.module_id].scope.get(name).take_macros())
.or_else(|| Some(def_map.macro_use_prelude.get(name).copied()?.0))
.filter(|&id| {
sub_namespace_match(
Some(MacroSubNs::from_id(db, id)),
Some(MacroSubNs::Bang),
)
})
.filter(|&id| sub_namespace_match(db, id, Some(MacroSubNs::Bang)))
.map(|it| self.def_collector.db.macro_def(it))
})
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ impl PerNs {
db: &dyn DefDatabase,
expected: Option<MacroSubNs>,
) -> Self {
self.macros = self.macros.filter(|def| {
let this = MacroSubNs::from_id(db, def.def);
sub_namespace_match(Some(this), expected)
});
self.macros = self.macros.filter(|def| sub_namespace_match(db, def.def, expected));

self
}
Expand Down Expand Up @@ -668,9 +665,7 @@ impl DefMap {
// FIXME: shadowing
.and_then(|it| it.last())
.copied()
.filter(|&id| {
sub_namespace_match(Some(MacroSubNs::from_id(db, id)), expected_macro_subns)
})
.filter(|&id| sub_namespace_match(db, id, expected_macro_subns))
.map_or_else(PerNs::none, |m| PerNs::macros(m, Visibility::Public, None));
let from_scope = self[module].scope.get(name).filter_macro(db, expected_macro_subns);
let from_builtin = match self.block {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ pub struct S {}
"ast_id_map_shim",
"parse_shim",
"real_span_map_shim",
"decl_macro_expander_shim",
"file_item_tree_query",
"ast_id_map_shim",
"parse_shim",
Expand All @@ -235,7 +236,6 @@ pub struct S {}
"ast_id_map_shim",
"parse_macro_expansion_shim",
"macro_arg_shim",
"decl_macro_expander_shim",
]
"#]],
expect![[r#"
Expand Down Expand Up @@ -404,6 +404,7 @@ pub struct S {}
"ast_id_map_shim",
"parse_shim",
"real_span_map_shim",
"decl_macro_expander_shim",
"file_item_tree_query",
"ast_id_map_shim",
"parse_shim",
Expand All @@ -423,7 +424,6 @@ pub struct S {}
"ast_id_map_shim",
"parse_macro_expansion_shim",
"macro_arg_shim",
"decl_macro_expander_shim",
"crate_local_def_map",
"proc_macros_for_crate_shim",
"file_item_tree_query",
Expand All @@ -446,9 +446,9 @@ pub struct S {}
"file_item_tree_query",
"real_span_map_shim",
"macro_arg_shim",
"macro_arg_shim",
"decl_macro_expander_shim",
"macro_arg_shim",
"macro_arg_shim",
]
"#]],
);
Expand Down Expand Up @@ -520,6 +520,7 @@ m!(Z);
"ast_id_map_shim",
"parse_shim",
"real_span_map_shim",
"decl_macro_expander_shim",
"file_item_tree_query",
"ast_id_map_shim",
"parse_shim",
Expand All @@ -533,7 +534,6 @@ m!(Z);
"ast_id_map_shim",
"parse_macro_expansion_shim",
"macro_arg_shim",
"decl_macro_expander_shim",
"file_item_tree_query",
"ast_id_map_shim",
"parse_macro_expansion_shim",
Expand Down
Loading
Loading