mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 14:51:48 +00:00
Merge #10338
10338: fix: Fix diagnostics in unnamed consts r=jonas-schievink a=jonas-schievink bors r+ Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
This commit is contained in:
commit
e372bdce2e
2 changed files with 16 additions and 2 deletions
|
@ -673,7 +673,12 @@ impl Module {
|
||||||
|
|
||||||
pub fn declarations(self, db: &dyn HirDatabase) -> Vec<ModuleDef> {
|
pub fn declarations(self, db: &dyn HirDatabase) -> Vec<ModuleDef> {
|
||||||
let def_map = self.id.def_map(db.upcast());
|
let def_map = self.id.def_map(db.upcast());
|
||||||
def_map[self.id.local_id].scope.declarations().map(ModuleDef::from).collect()
|
let scope = &def_map[self.id.local_id].scope;
|
||||||
|
scope
|
||||||
|
.declarations()
|
||||||
|
.map(ModuleDef::from)
|
||||||
|
.chain(scope.unnamed_consts().map(|id| ModuleDef::Const(Const::from(id))))
|
||||||
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn impl_defs(self, db: &dyn HirDatabase) -> Vec<Impl> {
|
pub fn impl_defs(self, db: &dyn HirDatabase) -> Vec<Impl> {
|
||||||
|
|
|
@ -185,7 +185,16 @@ static A: Option<()> = {($0)};
|
||||||
r#"
|
r#"
|
||||||
static A: Option<()> = {Some(())};
|
static A: Option<()> = {Some(())};
|
||||||
"#,
|
"#,
|
||||||
)
|
);
|
||||||
|
check_fix(
|
||||||
|
r#"
|
||||||
|
//- minicore: option, result
|
||||||
|
const _: Option<()> = {($0)};
|
||||||
|
"#,
|
||||||
|
r#"
|
||||||
|
const _: Option<()> = {Some(())};
|
||||||
|
"#,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue