Skip to content

⬆️ rust-analyzer #109377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 81 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
68fd1ce
feat: bump variant suggestion for enums in patterns completion
feniljain Dec 12, 2022
794988c
feat: filter already present enum variants in match arms
feniljain Dec 17, 2022
c6da2f9
Remove uses of `box_syntax` in rustc and tools
clubby789 Feb 27, 2023
b2f6fd4
:arrow_up: rust-analyzer
lnicola Mar 13, 2023
fe82649
feat: add `is_float` & `is_char` to `hir::Type`
swarnimarun Mar 13, 2023
34e3ea8
feat: add `remove_slice` to `hir::Type`
swarnimarun Mar 13, 2023
cf95322
Allow the status bar item to be clicked again
Veykril Mar 13, 2023
cfbdf62
fix: as suggested change `remove_slice` to `as_slice`
swarnimarun Mar 13, 2023
228b44c
fix: Only skip adjustment hints for block, if and match expressions f…
Veykril Mar 13, 2023
9fb9ee3
internal: Rename AstDatabase to ExpandDatabase
Veykril Mar 13, 2023
aaf08bd
Shrink ProcMacroExpander size
Veykril Mar 13, 2023
544b4cf
Auto merge of #109069 - lnicola:rust-analyzer-2023-03-13, r=lnicola
bors Mar 13, 2023
8af3d63
This commit add Cargo-style project discovery for Buck and Bazel users.
davidbarsky Mar 9, 2023
46e0220
fmt
davidbarsky Mar 9, 2023
1f5c535
remove errant `--` in `executeDiscoverProject`
davidbarsky Mar 9, 2023
68d3eae
fix typo in package.json.
davidbarsky Mar 9, 2023
7a6e111
Update crates/rust-analyzer/src/handlers.rs
davidbarsky Mar 10, 2023
9137149
move `rust-analyzer.discoverProjectCommand` above `$generated-start` …
davidbarsky Mar 10, 2023
8d9bff0
Add a workspace config-based approach to reloading discovered projects.
davidbarsky Mar 11, 2023
56273b3
Remove `rust-analyzer/addProject` in favor of notifying r-a that conf…
davidbarsky Mar 13, 2023
cb93c12
fmt
davidbarsky Mar 13, 2023
677c0ee
Add path of workspace root folders to status output
davidbarsky Mar 13, 2023
78aed30
rename "addProject" command
davidbarsky Mar 13, 2023
a10372d
fix: use compute_type_match correctly and update tests accordingly
feniljain Mar 14, 2023
3b6db22
Merge branch 'master' into sync-from-rust
lnicola Mar 14, 2023
ce4f79f
Auto merge of #14345 - lnicola:sync-from-rust, r=lnicola
bors Mar 14, 2023
3ba7501
Auto merge of #14342 - davidbarsky:davidbarsky/add-workspace-source-t…
bors Mar 14, 2023
057857e
Auto merge of #14334 - swarnimarun:is-float-char, r=lnicola
bors Mar 14, 2023
4cbb940
Auto merge of #14337 - Veykril:vscode-status, r=lnicola
bors Mar 14, 2023
d7da9e6
Add storage dead for let bindings without initializer
HKalbasi Mar 14, 2023
5780375
Auto merge of #14347 - HKalbasi:dev, r=lnicola
bors Mar 14, 2023
def4dbb
Auto merge of #14336 - swarnimarun:remove-slice, r=lnicola
bors Mar 14, 2023
6a98e96
Auto merge of #14340 - Veykril:expand, r=lnicola
bors Mar 14, 2023
88f0fe7
fix: Fix rustc proc-macro handling being broken on the rustc workspac…
Veykril Mar 14, 2023
6f297b9
Auto merge of #14348 - Veykril:rustc-proc, r=Veykril
bors Mar 14, 2023
1a9fbf0
fix: Fix visibility resolution not respecting parent blocks
Veykril Mar 14, 2023
74303a3
Auto merge of #14349 - Veykril:vis-res, r=Veykril
bors Mar 14, 2023
ad91622
Auto merge of #14338 - Veykril:inlay-adjust, r=Veykril
bors Mar 14, 2023
bd545a1
Address review comments
davidbarsky Mar 14, 2023
6e7bc07
fix: don't override `linkedProjects` if no workspace was discovered.
davidbarsky Mar 14, 2023
c15335c
Auto merge of #14307 - davidbarsky:davidbarsky/add-cargo-style-projec…
bors Mar 14, 2023
f34b246
lint incoherent inherent impls
Veykril Jan 20, 2023
2c364f6
Fix tests
Veykril Mar 14, 2023
610a94c
Add fundamental attributes to data
Veykril Mar 14, 2023
510e4b4
Simplify
Veykril Mar 14, 2023
b4d7ea0
Auto merge of #13994 - Veykril:incoherent-impl, r=Veykril
bors Mar 14, 2023
03a6ab0
Add signature help for record struct patterns
Veykril Mar 14, 2023
82780d8
feat: add an autofix for inserting an unsafe block to missing unsafe …
xffxff Mar 9, 2023
bf0322c
pick the best ancestor expr of unsafe expr to add unsafe block. Thank…
xffxff Mar 11, 2023
0c93573
do not offer fixit for macro expansions and refactor the code
xffxff Mar 15, 2023
d03c789
chore: change casing for variants in tests
feniljain Mar 15, 2023
60548db
Auto merge of #14281 - XFFXFF:fix_missing_unsafe, r=Veykril
bors Mar 15, 2023
01bf072
fix: don't replace `SyntaxToken` with `SyntaxNode`
lowr Mar 15, 2023
55120b3
Add signature help for tuple struct patterns
Veykril Mar 15, 2023
05f95cb
Auto merge of #14354 - Veykril:sighelp, r=Veykril
bors Mar 15, 2023
1a31896
Auto merge of #14353 - lowr:fix/inline-call-bad-ast, r=Veykril
bors Mar 15, 2023
82ed68c
fix: Fix reference completions being emitted in places other than arg…
Veykril Mar 15, 2023
e611fbe
Auto merge of #14355 - Veykril:completion-ref-strip, r=Veykril
bors Mar 15, 2023
8b8cd04
fix: Don't pass feature flags to rustc private crates metadata invoca…
Veykril Mar 15, 2023
579797f
Auto merge of #14357 - Veykril:rustc-priv, r=Veykril
bors Mar 15, 2023
e2ab0ff
Aggregate errors and warnings in the status message
Veykril Mar 15, 2023
d9c7d28
Report sysroot and rustc crate loading errors
Veykril Mar 15, 2023
1787c14
Auto merge of #14358 - Veykril:err-reporting, r=Veykril
bors Mar 15, 2023
74e08cb
fix: Do not retry inlay hint requests
Veykril Mar 15, 2023
adbda94
Auto merge of #14359 - Veykril:opt-out-retry, r=Veykril
bors Mar 15, 2023
6746a08
fix: Fix return type of async closures.
zachs18 Aug 7, 2022
af175dd
Add test for async closure types.
zachs18 Aug 7, 2022
3bf07a5
Simplify
Veykril Mar 15, 2023
802d7ea
internal: Prioritize remove-dbg assist over inline-macro
Veykril Mar 15, 2023
c16f051
Auto merge of #14362 - Veykril:remove-dbg, r=Veykril
bors Mar 15, 2023
9fe2069
fix: Fix ast::IfExpr child accessors
Veykril Mar 15, 2023
8330f8e
Auto merge of #12958 - zachs18:async_closure, r=Veykril
bors Mar 15, 2023
924d277
Auto merge of #14361 - Veykril:if-then-parse, r=Veykril
bors Mar 15, 2023
6778d1a
feat: do not remove other variants, just push them down in list
feniljain Mar 16, 2023
f711368
fix: make tests valid rust code
feniljain Mar 18, 2023
a79a76a
refactor: pass is_variant_missing as args to build_completion
feniljain Mar 18, 2023
7c05f55
Auto merge of #13789 - feniljain:fix_enum_completion, r=Veykril
bors Mar 18, 2023
1d1a86f
Bump chalk to 0.89
lowr Mar 19, 2023
e12460b
Add regression test
lowr Mar 19, 2023
825833c
Auto merge of #14378 - lowr:patch/bump-chalk-0.89, r=lnicola
bors Mar 19, 2023
0f499b4
:arrow_up: rust-analyzer
lnicola Mar 20, 2023
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
16 changes: 8 additions & 8 deletions src/tools/rust-analyzer/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"

[[package]]
name = "chalk-derive"
version = "0.88.0"
version = "0.89.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4df80a3fbc1f0e59f560eeeebca94bf655566a8ad3023c210a109deb6056455a"
checksum = "ea176c50987dc4765961aa165001e8eb5a722a26308c5797a47303ea91686aab"
dependencies = [
"proc-macro2",
"quote",
Expand All @@ -181,9 +181,9 @@ dependencies = [

[[package]]
name = "chalk-ir"
version = "0.88.0"
version = "0.89.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f39e5272016916956298cceea5147006f897972c274a768ed4d6e074efe5d3fb"
checksum = "473b480241695428c14e8f84f1c9a47ef232450a50faf3a4041e5c9dc11e0a3b"
dependencies = [
"bitflags",
"chalk-derive",
Expand All @@ -192,9 +192,9 @@ dependencies = [

[[package]]
name = "chalk-recursive"
version = "0.88.0"
version = "0.89.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9d60b42ad7478d3e027e2f9ea4e99fbbb8fdee0c8c3cf068be269f57e603618"
checksum = "6764b4fe67cac3a3758185084efbfbd39bf0352795824ba849ddd2b64cd4bb28"
dependencies = [
"chalk-derive",
"chalk-ir",
Expand All @@ -205,9 +205,9 @@ dependencies = [

[[package]]
name = "chalk-solve"
version = "0.88.0"
version = "0.89.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab30620ea5b36819525eaab2204f4b8e1842fc7ee36826424a28bef59ae7fecf"
checksum = "55a7e6160966eceb6e7dcc2f479a2af4c477aaf5bccbc640d82515995ab1a6cc"
dependencies = [
"chalk-derive",
"chalk-ir",
Expand Down
4 changes: 2 additions & 2 deletions src/tools/rust-analyzer/bench_data/numerous_macro_rules
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ macro_rules! __ra_macro_fixture339 {($name : ident )=>{ impl Clone for $name
macro_rules! __ra_macro_fixture340 {([$($stack : tt )*])=>{$($stack )* }; ([$($stack : tt )*]{$($tail : tt )* })=>{$($stack )* { remove_sections_inner ! ([]$($tail )*); }}; ([$($stack : tt )*]$t : tt $($tail : tt )*)=>{ remove_sections ! ([$($stack )* $t ]$($tail )*); }; }
macro_rules! __ra_macro_fixture341 {($t : ty ,$z : expr )=>{ impl Zero for $t { fn zero ()-> Self {$z as $t } fn is_zero (& self )-> bool { self == & Self :: zero ()}}}; }
macro_rules! __ra_macro_fixture342 {($($ident : ident ),* $(,)?)=>{$(# [ allow ( bad_style )] pub const $ident : super :: Name = super :: Name :: new_inline ( stringify ! ($ident )); )* }; }
macro_rules! __ra_macro_fixture343 {($($trait : ident =>$expand : ident ),* )=>{# [ derive ( Debug , Clone , Copy , PartialEq , Eq , Hash )] pub enum BuiltinDeriveExpander {$($trait ),* } impl BuiltinDeriveExpander { pub fn expand (& self , db : & dyn AstDatabase , id : LazyMacroId , tt : & tt :: Subtree , )-> Result < tt :: Subtree , mbe :: ExpandError > { let expander = match * self {$(BuiltinDeriveExpander ::$trait =>$expand , )* }; expander ( db , id , tt )} fn find_by_name ( name : & name :: Name )-> Option < Self > { match name {$(id if id == & name :: name ! [$trait ]=> Some ( BuiltinDeriveExpander ::$trait ), )* _ => None , }}}}; }
macro_rules! __ra_macro_fixture344 {( LAZY : $(($name : ident , $kind : ident )=>$expand : ident ),* , EAGER : $(($e_name : ident , $e_kind : ident )=>$e_expand : ident ),* )=>{# [ derive ( Debug , Clone , Copy , PartialEq , Eq , Hash )] pub enum BuiltinFnLikeExpander {$($kind ),* }# [ derive ( Debug , Clone , Copy , PartialEq , Eq , Hash )] pub enum EagerExpander {$($e_kind ),* } impl BuiltinFnLikeExpander { pub fn expand (& self , db : & dyn AstDatabase , id : LazyMacroId , tt : & tt :: Subtree , )-> ExpandResult < tt :: Subtree > { let expander = match * self {$(BuiltinFnLikeExpander ::$kind =>$expand , )* }; expander ( db , id , tt )}} impl EagerExpander { pub fn expand (& self , db : & dyn AstDatabase , arg_id : EagerMacroId , tt : & tt :: Subtree , )-> ExpandResult < Option < ( tt :: Subtree , FragmentKind )>> { let expander = match * self {$(EagerExpander ::$e_kind =>$e_expand , )* }; expander ( db , arg_id , tt )}} fn find_by_name ( ident : & name :: Name )-> Option < Either < BuiltinFnLikeExpander , EagerExpander >> { match ident {$(id if id == & name :: name ! [$name ]=> Some ( Either :: Left ( BuiltinFnLikeExpander ::$kind )), )* $(id if id == & name :: name ! [$e_name ]=> Some ( Either :: Right ( EagerExpander ::$e_kind )), )* _ => return None , }}}; }
macro_rules! __ra_macro_fixture343 {($($trait : ident =>$expand : ident ),* )=>{# [ derive ( Debug , Clone , Copy , PartialEq , Eq , Hash )] pub enum BuiltinDeriveExpander {$($trait ),* } impl BuiltinDeriveExpander { pub fn expand (& self , db : & dyn ExpandDatabase , id : LazyMacroId , tt : & tt :: Subtree , )-> Result < tt :: Subtree , mbe :: ExpandError > { let expander = match * self {$(BuiltinDeriveExpander ::$trait =>$expand , )* }; expander ( db , id , tt )} fn find_by_name ( name : & name :: Name )-> Option < Self > { match name {$(id if id == & name :: name ! [$trait ]=> Some ( BuiltinDeriveExpander ::$trait ), )* _ => None , }}}}; }
macro_rules! __ra_macro_fixture344 {( LAZY : $(($name : ident , $kind : ident )=>$expand : ident ),* , EAGER : $(($e_name : ident , $e_kind : ident )=>$e_expand : ident ),* )=>{# [ derive ( Debug , Clone , Copy , PartialEq , Eq , Hash )] pub enum BuiltinFnLikeExpander {$($kind ),* }# [ derive ( Debug , Clone , Copy , PartialEq , Eq , Hash )] pub enum EagerExpander {$($e_kind ),* } impl BuiltinFnLikeExpander { pub fn expand (& self , db : & dyn ExpandDatabase , id : LazyMacroId , tt : & tt :: Subtree , )-> ExpandResult < tt :: Subtree > { let expander = match * self {$(BuiltinFnLikeExpander ::$kind =>$expand , )* }; expander ( db , id , tt )}} impl EagerExpander { pub fn expand (& self , db : & dyn ExpandDatabase , arg_id : EagerMacroId , tt : & tt :: Subtree , )-> ExpandResult < Option < ( tt :: Subtree , FragmentKind )>> { let expander = match * self {$(EagerExpander ::$e_kind =>$e_expand , )* }; expander ( db , arg_id , tt )}} fn find_by_name ( ident : & name :: Name )-> Option < Either < BuiltinFnLikeExpander , EagerExpander >> { match ident {$(id if id == & name :: name ! [$name ]=> Some ( Either :: Left ( BuiltinFnLikeExpander ::$kind )), )* $(id if id == & name :: name ! [$e_name ]=> Some ( Either :: Right ( EagerExpander ::$e_kind )), )* _ => return None , }}}; }
macro_rules! __ra_macro_fixture345 {($($ty : ty =>$this : ident $im : block );*)=>{$(impl ToTokenTree for $ty { fn to_token ($this )-> tt :: TokenTree { let leaf : tt :: Leaf = $im . into (); leaf . into ()}} impl ToTokenTree for &$ty { fn to_token ($this )-> tt :: TokenTree { let leaf : tt :: Leaf = $im . clone (). into (); leaf . into ()}})* }}
macro_rules! __ra_macro_fixture346 {($name : ident )=>{ impl $crate :: salsa :: InternKey for $name { fn from_intern_id ( v : $crate :: salsa :: InternId )-> Self {$name ( v )} fn as_intern_id (& self )-> $crate :: salsa :: InternId { self . 0 }}}; }
macro_rules! __ra_macro_fixture347 {($($var : ident ($t : ty )),+ )=>{$(impl From <$t > for AttrOwner { fn from ( t : $t )-> AttrOwner { AttrOwner ::$var ( t )}})+ }; }
Expand Down
19 changes: 11 additions & 8 deletions src/tools/rust-analyzer/crates/hir-def/src/adt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub struct StructData {
pub repr: Option<ReprOptions>,
pub visibility: RawVisibility,
pub rustc_has_incoherent_inherent_impls: bool,
pub fundamental: bool,
}

#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down Expand Up @@ -173,10 +174,10 @@ impl StructData {
let item_tree = loc.id.item_tree(db);
let repr = repr_from_value(db, krate, &item_tree, ModItem::from(loc.id.value).into());
let cfg_options = db.crate_graph()[loc.container.krate].cfg_options.clone();
let rustc_has_incoherent_inherent_impls = item_tree
.attrs(db, loc.container.krate, ModItem::from(loc.id.value).into())
.by_key("rustc_has_incoherent_inherent_impls")
.exists();
let attrs = item_tree.attrs(db, loc.container.krate, ModItem::from(loc.id.value).into());
let rustc_has_incoherent_inherent_impls =
attrs.by_key("rustc_has_incoherent_inherent_impls").exists();
let fundamental = attrs.by_key("fundamental").exists();

let strukt = &item_tree[loc.id.value];
let (variant_data, diagnostics) = lower_fields(
Expand All @@ -196,6 +197,7 @@ impl StructData {
repr,
visibility: item_tree[strukt.visibility].clone(),
rustc_has_incoherent_inherent_impls,
fundamental,
}),
diagnostics.into(),
)
Expand All @@ -215,10 +217,10 @@ impl StructData {
let repr = repr_from_value(db, krate, &item_tree, ModItem::from(loc.id.value).into());
let cfg_options = db.crate_graph()[loc.container.krate].cfg_options.clone();

let rustc_has_incoherent_inherent_impls = item_tree
.attrs(db, loc.container.krate, ModItem::from(loc.id.value).into())
.by_key("rustc_has_incoherent_inherent_impls")
.exists();
let attrs = item_tree.attrs(db, loc.container.krate, ModItem::from(loc.id.value).into());
let rustc_has_incoherent_inherent_impls =
attrs.by_key("rustc_has_incoherent_inherent_impls").exists();
let fundamental = attrs.by_key("fundamental").exists();

let union = &item_tree[loc.id.value];
let (variant_data, diagnostics) = lower_fields(
Expand All @@ -238,6 +240,7 @@ impl StructData {
repr,
visibility: item_tree[union.visibility].clone(),
rustc_has_incoherent_inherent_impls,
fundamental,
}),
diagnostics.into(),
)
Expand Down
42 changes: 41 additions & 1 deletion src/tools/rust-analyzer/crates/hir-def/src/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ use syntax::{ast, AstPtr, SyntaxNode, SyntaxNodePtr};
use crate::{
attr::Attrs,
db::DefDatabase,
expr::{dummy_expr_id, Binding, BindingId, Expr, ExprId, Label, LabelId, Pat, PatId},
expr::{
dummy_expr_id, Binding, BindingId, Expr, ExprId, Label, LabelId, Pat, PatId, RecordFieldPat,
},
item_scope::BuiltinShadowMode,
macro_id_to_def_id,
nameres::DefMap,
Expand Down Expand Up @@ -432,6 +434,44 @@ impl Body {
pats.shrink_to_fit();
bindings.shrink_to_fit();
}

pub fn walk_bindings_in_pat(&self, pat_id: PatId, mut f: impl FnMut(BindingId)) {
self.walk_pats(pat_id, &mut |pat| {
if let Pat::Bind { id, .. } = pat {
f(*id);
}
});
}

pub fn walk_pats(&self, pat_id: PatId, f: &mut impl FnMut(&Pat)) {
let pat = &self[pat_id];
f(pat);
match pat {
Pat::Range { .. }
| Pat::Lit(..)
| Pat::Path(..)
| Pat::ConstBlock(..)
| Pat::Wild
| Pat::Missing => {}
&Pat::Bind { subpat, .. } => {
if let Some(subpat) = subpat {
self.walk_pats(subpat, f);
}
}
Pat::Or(args) | Pat::Tuple { args, .. } | Pat::TupleStruct { args, .. } => {
args.iter().copied().for_each(|p| self.walk_pats(p, f));
}
Pat::Ref { pat, .. } => self.walk_pats(*pat, f),
Pat::Slice { prefix, slice, suffix } => {
let total_iter = prefix.iter().chain(slice.iter()).chain(suffix.iter());
total_iter.copied().for_each(|p| self.walk_pats(p, f));
}
Pat::Record { args, .. } => {
args.iter().for_each(|RecordFieldPat { pat, .. }| self.walk_pats(*pat, f));
}
Pat::Box { inner } => self.walk_pats(*inner, f),
}
}
}

impl Default for Body {
Expand Down
2 changes: 2 additions & 0 deletions src/tools/rust-analyzer/crates/hir-def/src/body/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,8 @@ impl ExprCollector<'_> {
Movability::Movable
};
ClosureKind::Generator(movability)
} else if e.async_token().is_some() {
ClosureKind::Async
} else {
ClosureKind::Closure
};
Expand Down
10 changes: 8 additions & 2 deletions src/tools/rust-analyzer/crates/hir-def/src/body/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,14 @@ impl<'a> Printer<'a> {
w!(self, "]");
}
Expr::Closure { args, arg_types, ret_type, body, closure_kind } => {
if let ClosureKind::Generator(Movability::Static) = closure_kind {
w!(self, "static ");
match closure_kind {
ClosureKind::Generator(Movability::Static) => {
w!(self, "static ");
}
ClosureKind::Async => {
w!(self, "async ");
}
_ => (),
}
w!(self, "|");
for (i, (pat, ty)) in args.iter().zip(arg_types.iter()).enumerate() {
Expand Down
33 changes: 26 additions & 7 deletions src/tools/rust-analyzer/crates/hir-def/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub struct FunctionData {
pub visibility: RawVisibility,
pub abi: Option<Interned<str>>,
pub legacy_const_generics_indices: Box<[u32]>,
pub rustc_allow_incoherent_impl: bool,
flags: FnFlags,
}

Expand Down Expand Up @@ -84,13 +85,14 @@ impl FunctionData {
}
}

let legacy_const_generics_indices = item_tree
.attrs(db, krate, ModItem::from(loc.id.value).into())
let attrs = item_tree.attrs(db, krate, ModItem::from(loc.id.value).into());
let legacy_const_generics_indices = attrs
.by_key("rustc_legacy_const_generics")
.tt_values()
.next()
.map(parse_rustc_legacy_const_generics)
.unwrap_or_default();
let rustc_allow_incoherent_impl = attrs.by_key("rustc_allow_incoherent_impl").exists();

Arc::new(FunctionData {
name: func.name.clone(),
Expand All @@ -108,6 +110,7 @@ impl FunctionData {
abi: func.abi.clone(),
legacy_const_generics_indices,
flags,
rustc_allow_incoherent_impl,
})
}

Expand Down Expand Up @@ -171,6 +174,7 @@ pub struct TypeAliasData {
pub visibility: RawVisibility,
pub is_extern: bool,
pub rustc_has_incoherent_inherent_impls: bool,
pub rustc_allow_incoherent_impl: bool,
/// Bounds restricting the type alias itself (eg. `type Ty: Bound;` in a trait or impl).
pub bounds: Vec<Interned<TypeBound>>,
}
Expand All @@ -189,17 +193,22 @@ impl TypeAliasData {
item_tree[typ.visibility].clone()
};

let rustc_has_incoherent_inherent_impls = item_tree
.attrs(db, loc.container.module(db).krate(), ModItem::from(loc.id.value).into())
.by_key("rustc_has_incoherent_inherent_impls")
.exists();
let attrs = item_tree.attrs(
db,
loc.container.module(db).krate(),
ModItem::from(loc.id.value).into(),
);
let rustc_has_incoherent_inherent_impls =
attrs.by_key("rustc_has_incoherent_inherent_impls").exists();
let rustc_allow_incoherent_impl = attrs.by_key("rustc_allow_incoherent_impl").exists();

Arc::new(TypeAliasData {
name: typ.name.clone(),
type_ref: typ.type_ref.clone(),
visibility,
is_extern: matches!(loc.container, ItemContainerId::ExternBlockId(_)),
rustc_has_incoherent_inherent_impls,
rustc_allow_incoherent_impl,
bounds: typ.bounds.to_vec(),
})
}
Expand All @@ -212,11 +221,12 @@ pub struct TraitData {
pub is_auto: bool,
pub is_unsafe: bool,
pub rustc_has_incoherent_inherent_impls: bool,
pub skip_array_during_method_dispatch: bool,
pub fundamental: bool,
pub visibility: RawVisibility,
/// Whether the trait has `#[rust_skip_array_during_method_dispatch]`. `hir_ty` will ignore
/// method calls to this trait's methods when the receiver is an array and the crate edition is
/// 2015 or 2018.
pub skip_array_during_method_dispatch: bool,
// box it as the vec is usually empty anyways
pub attribute_calls: Option<Box<Vec<(AstId<ast::Item>, MacroCallId)>>>,
}
Expand Down Expand Up @@ -245,6 +255,7 @@ impl TraitData {
attrs.by_key("rustc_skip_array_during_method_dispatch").exists();
let rustc_has_incoherent_inherent_impls =
attrs.by_key("rustc_has_incoherent_inherent_impls").exists();
let fundamental = attrs.by_key("fundamental").exists();
let mut collector =
AssocItemCollector::new(db, module_id, tree_id.file_id(), ItemContainerId::TraitId(tr));
collector.collect(&item_tree, tree_id.tree_id(), &tr_def.items);
Expand All @@ -260,6 +271,7 @@ impl TraitData {
visibility,
skip_array_during_method_dispatch,
rustc_has_incoherent_inherent_impls,
fundamental,
}),
diagnostics.into(),
)
Expand Down Expand Up @@ -450,6 +462,7 @@ pub struct ConstData {
pub name: Option<Name>,
pub type_ref: Interned<TypeRef>,
pub visibility: RawVisibility,
pub rustc_allow_incoherent_impl: bool,
}

impl ConstData {
Expand All @@ -463,10 +476,16 @@ impl ConstData {
item_tree[konst.visibility].clone()
};

let rustc_allow_incoherent_impl = item_tree
.attrs(db, loc.container.module(db).krate(), ModItem::from(loc.id.value).into())
.by_key("rustc_allow_incoherent_impl")
.exists();

Arc::new(ConstData {
name: konst.name.clone(),
type_ref: konst.type_ref.clone(),
visibility,
rustc_allow_incoherent_impl,
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/tools/rust-analyzer/crates/hir-def/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::sync::Arc;

use base_db::{salsa, CrateId, SourceDatabase, Upcast};
use either::Either;
use hir_expand::{db::AstDatabase, HirFileId};
use hir_expand::{db::ExpandDatabase, HirFileId};
use intern::Interned;
use la_arena::ArenaMap;
use syntax::{ast, AstPtr};
Expand Down Expand Up @@ -64,7 +64,7 @@ pub trait InternDatabase: SourceDatabase {
}

#[salsa::query_group(DefDatabaseStorage)]
pub trait DefDatabase: InternDatabase + AstDatabase + Upcast<dyn AstDatabase> {
pub trait DefDatabase: InternDatabase + ExpandDatabase + Upcast<dyn ExpandDatabase> {
#[salsa::input]
fn enable_proc_attr_macros(&self) -> bool;

Expand Down
1 change: 1 addition & 0 deletions src/tools/rust-analyzer/crates/hir-def/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ pub enum Expr {
pub enum ClosureKind {
Closure,
Generator(Movability),
Async,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use ::mbe::TokenMap;
use base_db::{fixture::WithFixture, ProcMacro, SourceDatabase};
use expect_test::Expect;
use hir_expand::{
db::{AstDatabase, TokenExpander},
db::{ExpandDatabase, TokenExpander},
AstId, InFile, MacroDefId, MacroDefKind, MacroFile,
};
use stdx::format_to;
Expand Down
Loading