Commit Graph

135 Commits

Author SHA1 Message Date
Lukas Wirth
a9f103e2fa Fix prelude injection 2022-09-15 12:12:22 +02:00
Lukas Wirth
a8ecaa1979 Restructure find_path into a separate functions for modules and non-module items
Also renames `prefer_core` imports config to `prefer_no_std` and changes the behavior of no_std path searching by preferring `core` paths `over` alloc
2022-09-13 15:15:27 +02:00
Lukas Wirth
7d19971666 Add config to unconditionally prefer core imports over std
Fixes https://github.com/rust-lang/rust-analyzer/issues/12979
2022-09-09 20:04:56 +02:00
Lukas Wirth
894aa0ed0d Clarify the state of (extern) preludes for block def maps 2022-09-02 17:43:20 +02:00
Lukas Wirth
8828049b23 Lift out the module scope into a field in the Resolver
A Resolver *always* has a module scope at the end of its scope stack,
instead of encoding this as an invariant we can just lift this scope
out into a field, allowing us to skip going through the scope vec
indirection entirely.
2022-09-02 17:02:12 +02:00
bors
2bb6635a85 Auto merge of #13173 - Veykril:synthetic, r=Veykril
Don't store SyntheticSyntax in the reverse maps in BodySourceMap

They are ZSTs which we can just create on missing access instead.
2022-09-02 13:17:16 +00:00
Lukas Wirth
fe0a106256 Don't store SyntheticSyntax in the reverse maps in BodySourceMap
They are ZSTs which we can just create on missing access instead.
2022-09-02 15:08:48 +02:00
bors
4f8153e4a5 Auto merge of #13167 - iDawer:exhaustive_patterns, r=Veykril
feat: Implement `feature(exhaustive_patterns)` from unstable Rust

Closes #12753

Recognize Rust's unstable `#![feature(exhaustive_patterns)]` (RFC 1872). Allow omitting visibly uninhabited variants from `match` expressions when the feature is on.

This adjusts match checking to the current implementation of the postponed RFC 1872 in rustc.
2022-09-02 12:32:36 +00:00
iDawer
8ae58b9fe4 Record enabled unstable features into DefMap 2022-09-02 16:31:15 +05:00
Lukas Wirth
ee02a4721b Remove unnecessary allocations 2022-08-31 18:05:52 +02:00
Lukas Wirth
192a79c235 Remove hir::Expr::MacroStmts
This hir expression isn't needed and only existed as it was simpler to
deal with at first as it gave us a direct mapping for the ast version of
the same construct. This PR removes it, properly handling the statements
that are introduced by macro call expressions.
2022-08-31 16:58:11 +02:00
Ryo Yoshida
662ab0cd8e
fix: unescape all occurrences of module name in module resolution 2022-08-31 03:51:37 +09:00
Lukas Wirth
d025c5d8d6 Make use of NoHash hashing for FileId and CrateId 2022-08-25 20:41:49 +02:00
bors
dea163970a Auto merge of #12965 - DesmondWillowbrook:assoc-method-dimming, r=Veykril
feat: make trait assoc items become inactive due to cfg

fixes #12394
2022-08-22 07:20:56 +00:00
Kartavya Vashishtha
23c00ed50d
fix: formatting 2022-08-20 13:44:01 +05:30
Kartavya Vashishtha
8f87fcb179
remove push_diagnostic methods
weren't used in the end
2022-08-20 13:30:25 +05:30
Kartavya Vashishtha
87b779756c
make impl and trait inactive diagnostics work 2022-08-20 13:28:43 +05:30
Dezhi Wu
23747419ca fix: a bunch of typos
This PR will fix some typos detected by [typos].

There are also some other typos in the function names, variable names, and file
names, which I leave as they are. I'm more certain that typos in comments
should be fixed.

[typos]: https://github.com/crate-ci/typos
2022-08-17 21:44:58 +08:00
bors
3903243192 Auto merge of #13027 - jonas-schievink:fix-mismatch-with-trailing-empty-macro, r=jonas-schievink
fix: Fix incorrect type mismatch with `cfg_if!` and other macros in expression position

Fixes https://github.com/rust-lang/rust-analyzer/issues/12940

This is a bit of a hack, ideally `MacroStmts` would not exist at all after HIR lowering, but that requires changing how the lowering code works.
2022-08-15 16:06:59 +00:00
Jonas Schievink
8c60813096 Fix lowering of empty macro expressions in trailing position 2022-08-15 18:01:58 +02:00
bors
3561433ef2 Auto merge of #13026 - Veykril:nameres, r=Veykril
internal: Make `resolve_name_in_module` a bit more lazy
2022-08-15 14:49:12 +00:00
Lukas Wirth
88b19cc39b Make resolve_name_in_module a bit more lazy 2022-08-15 16:41:51 +02:00
Jonas Schievink
dcbe892d7c Add an HIR pretty-printer 2022-08-15 13:51:45 +02:00
Ryo Yoshida
8fe73a2240
Make tests pass 2022-08-11 01:16:35 +09:00
Edwin Cheng
c47914c6cf Fixes tests 2022-08-10 16:29:23 +08:00
bors
b569bbbacc Auto merge of #12942 - lowr:fix/concat-with-char, r=Veykril
fix: make `concat!` work with char

Fixes #12921

- I avoided making `unquote_str()` take char literals as well because it's depended on by another function `parse_string()` that's only supposed to take strings.
- Even with this patch, we don't output `\0` as `\u{0}` which #12921 pointed out ~~, but we're not actually responsible for serializing it but rowan is~~. They are functionally equivalent and I don't think it'd cause any confusion, but we *could* try escaping them before serialization (for reference, `rustc -Zunpretty=expanded`, which `cargo expand` uses under the hood, [makes use of `str::escape_default()`](3830ecaa8d/compiler/rustc_ast/src/util/literal.rs (L161)).
2022-08-08 11:28:42 +00:00
Kartavya Vashishtha
c1eae3d028
make diagnostic function public 2022-08-08 16:45:27 +05:30
Kartavya Vashishtha
196f389a70
try adding diagnostrics for AssocItems 2022-08-08 16:40:29 +05:30
oxalica
326ffee5b7 Returns the old value for la_arena::ArenaMap::insert 2022-08-07 04:53:23 +08:00
Ryo Yoshida
4d5873e92f
minor: align with rustc on escaping characters in macro expansion 2022-08-05 22:01:09 +09:00
Ryo Yoshida
859d467276
fix: make concat! work with char 2022-08-05 02:58:16 +09:00
Jonas Schievink
bd7dfac5eb Fix r-a spelling in some places 2022-08-01 13:47:09 +02:00
bors
af646621de Auto merge of #12916 - Veykril:nits, r=Veykril
minor: Properly cfg the `max` field of Limit
2022-07-31 17:42:10 +00:00
Lukas Wirth
3b2ecf44a0 Give variables more descriptive names 2022-07-31 19:27:34 +02:00
Lukas Wirth
618cfd792c fix: Fix ast-id up when merging raw attributes 2022-07-30 09:43:30 +02:00
Lukas Wirth
f867ddc621 fix: Order ItemScope::entries results 2022-07-28 19:28:56 +02:00
Lukas Wirth
ddad2847ab Allow name querying for derive helpers 2022-07-26 09:27:22 +02:00
Lukas Wirth
aa1491ecde Record derive helper attributes, resolve them in IDE layer 2022-07-26 09:26:51 +02:00
Lukas Wirth
4e60db2d07 feat: Downmap tokens inside derive helpers 2022-07-26 09:26:47 +02:00
Amos Wenger
dc94050815 revert nightly rustfmt formatting that accidentally slipped in
cf. https://github.com/rust-lang/rust/pull/99603
cf. https://github.com/rust-lang/rust-analyzer/pull/12871#discussion_r928816339
2022-07-25 14:18:30 +02:00
Amos Wenger
0d04e63627 Merge remote-tracking branch 'origin/master' into sync-from-rust-2 2022-07-25 14:07:07 +02:00
Amos Wenger
dfe84494c1 Make macros test order-resistant 2022-07-24 16:48:06 +02:00
Amos Wenger
56c369db48 Sort when iterating through CrateGraph 2022-07-24 16:11:05 +02:00
Amos Wenger
d8c0d88e4f Sort in DefMap::dump, since HashMap iteration order isn't defined 2022-07-24 16:04:20 +02:00
Amos Wenger
ff317858c1 hir-def tests: sort results before comparing, since FxHashSet iteration order isn't guaranteed
(And, in fact, it failed on i686)
2022-07-24 15:55:26 +02:00
Ryo Yoshida
64758bd481
Add info whether it's assignee expr to relevant HIR Expr variants 2022-07-24 22:40:00 +09:00
Ryo Yoshida
fb063d360c
Add ellipsis to HIR RecordLit 2022-07-24 17:10:31 +09:00
bors
d469e0de9a Auto merge of #12840 - Veykril:be-lazy, r=Veykril
internal: Use ItemTree for variant, field and module attribute collection in attrs_query

Less parsing = very good, should speed up lang item collection as that basically probes attributes of all enum variants which currently triggers parsing

Not fond of how this is searching for the correct index, ideally we'd map between HIR and item tree Id here but I am not sure how, storing the item tree ids in the HIR version doesn't work due to the usage of `Trace`...
2022-07-22 20:35:31 +00:00
Lukas Wirth
0081ef3834 Use ItemTree for modules in attrs_query 2022-07-22 22:17:13 +02:00
Lukas Wirth
5f9a5825e0 Use ItemTree for crate root attr_query collection 2022-07-21 09:23:30 +02:00