Add support for static EIIs in late resolution

This commit is contained in:
Jonathan Brouwer
2026-04-12 11:06:40 +02:00
parent 1f2b0900a7
commit 106b16cd2d
5 changed files with 26 additions and 13 deletions
+10 -5
View File
@@ -530,9 +530,8 @@ fn descr_expected(self) -> &'static str {
},
_ => "value",
},
PathSource::ReturnTypeNotation
| PathSource::Delegation
| PathSource::ExternItemImpl => "function",
PathSource::ReturnTypeNotation | PathSource::Delegation => "function",
PathSource::ExternItemImpl => "function or static",
PathSource::PreciseCapturingArg(..) => "type or const parameter",
PathSource::Macro => "macro",
PathSource::Module => "module",
@@ -625,7 +624,13 @@ pub(crate) fn is_expected(self, res: Res) -> bool {
},
PathSource::Delegation => matches!(res, Res::Def(DefKind::Fn | DefKind::AssocFn, _)),
PathSource::ExternItemImpl => {
matches!(res, Res::Def(DefKind::Fn | DefKind::AssocFn | DefKind::Ctor(..), _))
matches!(
res,
Res::Def(
DefKind::Fn | DefKind::AssocFn | DefKind::Ctor(..) | DefKind::Static { .. },
_
)
)
}
PathSource::PreciseCapturingArg(ValueNS) => {
matches!(res, Res::Def(DefKind::ConstParam, _))
@@ -5500,7 +5505,7 @@ fn resolve_eii(&mut self, eii_impls: &[EiiImpl]) {
*node_id,
&None,
&target.foreign_item,
PathSource::ExternItemImpl
PathSource::ExternItemImpl,
);
} else {
self.smart_resolve_path(*node_id, &None, &eii_macro_path, PathSource::Macro);
@@ -6,7 +6,7 @@
const A: () = ();
#[eii]
fn A() {} //~ ERROR the name `A` is defined multiple times
//~^ ERROR expected function, found constant
//~| ERROR expected function, found constant
//~^ ERROR expected function or static, found constant
//~| ERROR expected function or static, found constant
fn main() {}
@@ -9,17 +9,17 @@ LL | fn A() {}
|
= note: `A` must be defined only once in the value namespace of this module
error[E0423]: expected function, found constant `self::A`
error[E0423]: expected function or static, found constant `self::A`
--> $DIR/eii-declaration-not-fn-issue-152337.rs:8:4
|
LL | fn A() {}
| ^ not a function
| ^ not a function or static
error[E0423]: expected function, found constant `A`
error[E0423]: expected function or static, found constant `A`
--> $DIR/eii-declaration-not-fn-issue-152337.rs:8:4
|
LL | fn A() {}
| ^ not a function
| ^ not a function or static
error: aborting due to 3 previous errors
+1
View File
@@ -4,6 +4,7 @@
#[eii(A)]
static A: u64;
//~^ ERROR the name `A` is defined multiple times
//~| ERROR expected function or static, found constant `A`
#[A]
static A_IMPL: u64 = 5;
+9 -2
View File
@@ -9,6 +9,13 @@ LL | static A: u64;
|
= note: `A` must be defined only once in the value namespace of this module
error: aborting due to 1 previous error
error[E0423]: expected function or static, found constant `A`
--> $DIR/multiple_decls.rs:5:8
|
LL | static A: u64;
| ^ not a function or static
For more information about this error, try `rustc --explain E0428`.
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0423, E0428.
For more information about an error, try `rustc --explain E0423`.