Commit Graph

470 Commits

Author SHA1 Message Date
Lukas Wirth
b6fb35f20c Shrink hir_expand::attr::AttrInput by boxing a variant 2023-06-10 01:21:52 +02:00
Lukas Wirth
a02b9b279e internal: Lazy eager macros 2023-06-09 13:02:13 +02:00
hkalbasi
30e16e20d0 Fix unwrap on None in expanding format args 2023-06-08 00:17:22 +03:30
Ryo Yoshida
4f0c6fac17
fix: only generate trait bound for associated types in field types 2023-06-07 20:52:49 +09:00
Laurențiu Nicola
c3dbe7c717 Merge remote-tracking branch 'upstream/master' into sync-from-rust 2023-06-05 11:07:47 +03:00
bors
9d5c34a80e Auto merge of #14970 - HKalbasi:mir-fix, r=HKalbasi
Detect "bound more than once" error and suppress `need-mut` for it.

Fix the `need-mut` false positive for `izip!`
2023-06-04 09:33:53 +00:00
hkalbasi
71f3e4b08c Detect "bound more than once" error and suppress need-mut for it. 2023-06-04 12:39:36 +03:30
Lukas Wirth
f9a9e40c0a Update builtin attribute list 2023-06-04 10:02:11 +02:00
bors
0b4c09b1d2 Auto merge of #14941 - Veykril:def-map, r=Veykril
Shrink `DefMap`, share crate level items with block def maps
2023-06-01 16:42:12 +00:00
Lukas Wirth
11b937177b Skip extern prelude path resolution in block def maps 2023-06-01 17:58:08 +02:00
bors
4458e7f190 Auto merge of #14942 - HKalbasi:for-loop-label, r=HKalbasi
fix bug in labeled for loop desugaring

fix https://github.com/rust-lang/rust-analyzer/pull/14892#discussion_r1213091393
2023-06-01 14:54:47 +00:00
hkalbasi
f4c52b40bd fix bug in labeled for loop desugaring 2023-06-01 17:51:53 +03:30
Lukas Wirth
54e3ef658a Rename nameres::CrateData to DefMapCrateData 2023-06-01 15:50:19 +02:00
Lukas Wirth
1e6406e223 Move extern prelude into CrateData 2023-06-01 15:49:05 +02:00
Lukas Wirth
bdca349573 Arc DefMap::data so the block def maps can share it 2023-06-01 15:27:05 +02:00
Lukas Wirth
5c466ccc2b Refactor out some crate wide data in DefMap into nested struct 2023-06-01 15:04:38 +02:00
Lukas Wirth
dc7c6d43c7 Slightly shrink DefMap 2023-06-01 14:46:36 +02:00
Lukas Wirth
0e28202832 Insert missing expr/pat for leading comma tuples 2023-06-01 08:56:40 +02:00
Oli Scherer
1570299af4 Remove const eval limit and implement an exponential backoff lint instead 2023-05-31 10:24:17 +00:00
bors
76d86502f7 Auto merge of #14912 - Veykril:cargo-alltargets, r=Veykril
Don't add --all-targets to runnables for no-std crates

Fixes https://github.com/rust-lang/rust-analyzer/issues/14155
2023-05-30 12:34:28 +00:00
hkalbasi
51368793b4 MIR episode 6 2023-05-28 23:25:15 +03:30
Lukas Wirth
8bc826dd53 Add diagnostic for _ expressions (typed holes) 2023-05-28 14:55:28 +02:00
Lukas Wirth
bbd9e41606 Don't add --all-targets to runnables for no-std crates 2023-05-28 14:18:44 +02:00
Ryo Yoshida
0d4d1d7e3b
Implement ${count()} metavariable expression 2023-05-28 19:54:36 +09:00
Ryo Yoshida
9ebaa85d37
Split test module for metavariable expressions 2023-05-28 19:54:23 +09:00
hkalbasi
780349bdaf fix need-mut false positive in closure capture of match scrutinee 2023-05-26 02:08:37 +03:30
hkalbasi
b0f17668f7 use ::core instead of $crate in option_env! 2023-05-25 18:46:34 +03:30
Lukas Wirth
c7ef6c25b7 internal: Replace Display impl for Name 2023-05-24 20:55:12 +02:00
bors
2f840c2236 Auto merge of #14874 - Veykril:crate-cfg, r=Veykril
expand: Change how `#![cfg(FALSE)]` behaves on crate root

Closes https://github.com/rust-lang/rust-analyzer/issues/14769
2023-05-24 16:06:09 +00:00
bors
2df56cadcb Auto merge of #14755 - poliorcetics:clippy-fixes, r=Veykril
Fix: a TODO and some clippy fixes

- fix(todo): implement IntoIterator for ArenaMap<IDX, V>
- chore: remove unused method
- fix: remove useless `return`s
- fix: various clippy lints
- fix: simplify boolean test to a single negation
2023-05-24 11:13:52 +00:00
Lukas Wirth
74d6826858 expand: Change how #![cfg(FALSE)] behaves on crate root 2023-05-24 13:02:38 +02:00
hkalbasi
c5ea2d7adc handle match scrutinee in closure captures 2023-05-19 12:04:12 +03:30
hkalbasi
4adfbbfbad partially support panic message in MirEvalError 2023-05-18 18:30:49 +03:30
bors
9ce95674e8 Auto merge of #14837 - Veykril:rustc-lexer, r=Veykril
Support c string literals
2023-05-18 11:55:38 +00:00
Lukas Wirth
3e528b85f9 Fix cstring literals construct &CStr not &str 2023-05-18 12:03:15 +02:00
bors
034d7c8537 Auto merge of #14787 - HKalbasi:mir2, r=HKalbasi
MIR episode 5

This PR inits drop support (it is very broken at this stage, some things are dropped multiple time, drop scopes are wrong, ...) and adds stdout support (`println!` doesn't work since its expansion is dummy, but `stdout().write(b"hello world\n")` works if you use `RA_SYSROOT_HACK`) for interpreting. There is no useful unit test that it can interpret yet, but it is a good sign that it didn't hit a major road block yet.

In MIR lowering, it adds support for slice pattern and anonymous const blocks, and some fixes so that we can evaluate `SmolStr::new_inline` in const eval. With these changes, 57 failed mir body remains.
2023-05-18 09:44:26 +00:00
bors
f9be79603a Auto merge of #14820 - HKalbasi:format-args, r=HKalbasi
Expand `format_args!` with more details
2023-05-18 09:09:06 +00:00
Lukas Wirth
4b577e2bc8 Support c string literals 2023-05-18 11:06:05 +02:00
hkalbasi
5c83e222a3 fix format_args expansion error with raw strings 2023-05-18 12:32:41 +03:30
bors
c7b03491cd Auto merge of #14834 - Veykril:ty-diag-unit, r=Veykril
internal: Less file parsing for symbol index generation
2023-05-18 06:25:40 +00:00
Lukas Wirth
d6dcfa5744 internal: Less file parsing for symbol index generation 2023-05-18 08:25:06 +02:00
Ryo Yoshida
68a74decb6
Process macro_use prelude in semantic scope resolver 2023-05-17 17:45:44 +09:00
hkalbasi
a2fba7c67e Add test for eager expanding of format_args 2023-05-17 01:15:04 +03:30
hkalbasi
a6e5a912f9 Expand format_args! with more details 2023-05-16 19:12:40 +03:30
bors
9eb26a9375 Auto merge of #14809 - lowr:patch/macro_use-filter, r=Veykril
Support `#[macro_use(name, ...)]`

This PR adds support for another form of the `macro_use` attribute: `#[macro_use(name, ...)]` ([reference]).

Note that this form of the attribute is only applicable to extern crate decls, not to mod decls.

[reference]: https://doc.rust-lang.org/reference/macros-by-example.html#the-macro_use-attribute
2023-05-15 10:04:05 +00:00
bors
bc03418127 Auto merge of #14746 - lowr:patch/associated-return-types, r=Veykril
Parse associated return type bounds

This PR implements parser support for associated return type bounds: `T: Foo<bar(): Send>`. This PR does not implement associated return types (`T::bar(): Send`) because it's not implemented even in rustc, and also removes `(..)`-style return type notation because it has been removed in rust-lang/rust#110203 (effectively reverting #14465).

I don't plan to proactively follow this unstable feature unless an RFC is accepted and my main motivation here is to remove no-longer-valid syntax `(..)` from our parser, nevertheless adding minimal parser support so anyone interested (as can be seen in #14465) can experiment it without rust-analyzer's syntax errors.
2023-05-15 09:16:51 +00:00
Ryo Yoshida
1bc7f8a4c6
Support #[macro_use(name, ...)] 2023-05-15 00:05:44 +09:00
bors
daa03b0b0b Auto merge of #14800 - lowr:patch/macro-subns-and-prelude, r=Veykril
Expand more single ident macro calls upon item collection

Addresses https://github.com/rust-lang/rust-analyzer/pull/14781#issuecomment-1546201022

I believe this (almost) brings the number of unresolved names back to pre-#14781:

|r-a version|`analysis-stats compiler/rustc` (rust-lang/rust@69fef92ab2) |
|---|---|
|pre-#14781 (b069eb720b) | exprs: 2747778, ??ty: 122236 (4%), ?ty: 107826 (3%), !ty: 728 |
| #14781 (a7944a93a1) | exprs: 2713080, ??ty: 139651 (5%), ?ty: 114444 (4%), !ty: 730 |
| with this fix | exprs: 2747871, ??ty: 122237 (4%), ?ty: 108171 (3%), !ty: 676 |

(I haven't investigated on the increase in some numbers but hopefully not too much of a problem)

This is only a temporary solution. The core problem is that we haven't fully implemented the textual scope of legacy macros. For example, we *have been* failing to resolve `foo` in the following snippet, even before #14781 or after this patch. As noted in a FIXME, we need a way to resolve names in textual scope without eager expansion during item collection.

```rust
//- /main.rs crate:main deps:lib
lib::mk_foo!();
const A: i32 = foo!();
             //^^^^^^ unresolved-macro-call

//- /lib.rs crate:lib
#[macro_export]
macro_rules! mk_foo {
    () => {
        macro_rules! foo { () => { 42 } }
    }
}
```
2023-05-13 18:47:42 +00:00
Ryo Yoshida
e9ddb62c65
Expand more single ident macro calls upon their collection 2023-05-14 03:11:10 +09:00
hkalbasi
cbcafd3539 MIR episode 5 2023-05-12 18:17:15 +03:30