mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Fix associated item visibility in block-local impls
This commit is contained in:
parent
443801755c
commit
83e24fec98
5 changed files with 52 additions and 8 deletions
|
@ -115,6 +115,44 @@ mod module {
|
|||
fn main(s: module::Struct) {
|
||||
s.method();
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_see_through_top_level_anonymous_const() {
|
||||
// regression test for #14046.
|
||||
check_diagnostics(
|
||||
r#"
|
||||
struct S;
|
||||
mod m {
|
||||
const _: () = {
|
||||
impl crate::S {
|
||||
pub(crate) fn method(self) {}
|
||||
pub(crate) const A: usize = 42;
|
||||
}
|
||||
};
|
||||
mod inner {
|
||||
const _: () = {
|
||||
impl crate::S {
|
||||
pub(crate) fn method2(self) {}
|
||||
pub(crate) const B: usize = 42;
|
||||
pub(super) fn private(self) {}
|
||||
pub(super) const PRIVATE: usize = 42;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
fn main() {
|
||||
S.method();
|
||||
S::A;
|
||||
S.method2();
|
||||
S::B;
|
||||
S.private();
|
||||
//^^^^^^^^^^^ error: function `private` is private
|
||||
S::PRIVATE;
|
||||
//^^^^^^^^^^ error: const `PRIVATE` is private
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue