Commit graph

83 commits

Author SHA1 Message Date
bors
f77b68a3cb Auto merge of #13860 - danieleades:clippy, r=lnicola
fix a bunch of clippy lints

fixes a bunch of clippy lints for fun and profit

i'm aware of this repo's position on clippy. The changes are split into separate commits so they can be reviewed separately
2023-01-08 17:29:57 +00:00
Laurențiu Nicola
9f6567f20c Fix option_env expansion 2023-01-06 16:00:23 +02:00
Daniel Eades
8615bba105 use 'unwrap_or_default' 2023-01-02 15:02:54 +00:00
Daniel Eades
cc80c5bd07 remove unnecessary lazy evaluations 2023-01-02 15:02:54 +00:00
Daniel Eades
ed128872eb remove needless borrows 2023-01-02 14:52:32 +00:00
Ryo Yoshida
0430b68398
Remove unused known Names 2022-12-31 16:17:38 +09:00
Yuri Astrakhan
e16c76e3c3 Inline all format arguments where possible
This makes code more readale and concise,
moving all format arguments like `format!("{}", foo)`
into the more compact `format!("{foo}")` form.

The change was automatically created with, so there are far less change
of an accidental typo.

```
cargo clippy --fix -- -A clippy::all -W clippy::uninlined_format_args
```
2022-12-24 14:36:10 -05:00
hkalbasi
86b5b609f1 Compute data layout of types 2022-12-04 00:29:34 +03:30
Crauzer
b3bd5a471e implement vararg type collection from function params 2022-11-29 00:32:13 +01:00
Lukas Wirth
7bf2a25dfe Encode the variants of HirFileId in a u32 with MSB as the tag 2022-11-25 23:28:35 +01:00
Jake Heinz
427b63b676 hir-expand: fix compile_error! expansion not unquoting strings 2022-11-20 08:48:27 +00:00
bors
6f313cef8e Auto merge of #13548 - lowr:fix/tt-punct-spacing, r=Veykril
Fix `tt::Punct`'s spacing calculation

Fixes #13499

We currently set a `tt::Punct`'s spacing to `Spacing::Joint` unless its next token is a trivia (i.e. whitespaces or comment). As I understand it, rustc only [sets `Spacing::Joint` if the next token is an operator](5b3e909075/compiler/rustc_parse/src/lexer/tokentrees.rs (L77-L78)) and we should follow it to guarantee the consistent behavior of proc macros.
2022-11-11 12:19:30 +00:00
Ryo Yoshida
5b07061011
Test TokenTrees' equality modulo Puncts' spacing 2022-11-10 19:40:40 +09:00
Ryo Yoshida
4f415fc348
Ignore outermost non-delimited Subtree when reversing fixups 2022-11-10 19:22:20 +09:00
Lukas Wirth
ffd7bf8bf9 Bump Cargo rust-version fields to latest stable 2022-11-07 12:59:51 +01:00
Laurențiu Nicola
cff7ab1308 Fix typos 2022-11-07 12:54:12 +02:00
Ryo Yoshida
41b0c54c07
Fix tt::Punct's spacing calculation 2022-11-05 19:42:09 +09:00
Ryo Yoshida
6459d7f817
Support const generics for builtin derive macro 2022-10-23 00:05:22 +09:00
Lukas Wirth
8047512dca
Revert "feat: Diagnose some incorrect usages of the question mark operator" 2022-10-18 14:18:59 +02:00
Lukas Wirth
381366f1dd Diagnose incorrect usages of the question mark operator 2022-10-16 12:58:24 +02:00
bors
855cd5c280 Auto merge of #13418 - lnicola:bump-deps, r=lnicola
Bump deps
2022-10-15 11:27:12 +00:00
Laurențiu Nicola
50f990c46f Bump smallvec 2022-10-15 12:52:34 +03:00
Laurențiu Nicola
cbce0cda08 Bump anyhow, arbitrary, itertools, semver, serde 2022-10-15 12:52:34 +03:00
bors
21319d135f Auto merge of #13329 - Veykril:rustc-proc-macro, r=Veykril
Use $crate instead of std for panic builtin_fn_macro

This should be closer to the expected output and gets rid of a few type mismatches in rustc/library
2022-10-10 21:35:07 +00:00
Lukas Wirth
c069f1b7d2 Prefer similar tokens when expanding macros speculatively 2022-10-10 22:47:52 +02:00
Lukas Wirth
1574fe0d54 Use $crate instead of std for panic builtin_fn_macro
This should be closer to the expected output and gets rid of a few
type mismatches in rustc/library
2022-10-10 10:33:49 +02:00
bors
f88293f777 Auto merge of #13324 - Veykril:trait-impl-completion, r=Veykril
Fix trait impl item completions using macro file text ranges

Fixes https://github.com/rust-lang/rust-analyzer/issues/13323
2022-10-01 13:35:08 +00:00
Lukas Wirth
bfd5f00bfc Fix trait impl item completions using macro file text ranges 2022-10-01 15:34:45 +02:00
Ryo Yoshida
6d8903ae5f
fix: infer for-loop item type with IntoIterator and Iterator 2022-09-29 19:48:08 +09:00
unexge
89107d5469 Emit unconfigured code diagnostics for fields 2022-09-26 19:04:57 +01: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
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
bors
1da9156b0d Auto merge of #12982 - jridgewell:into_future, r=Veykril
Implement IntoFuture type inference

One of my projects is using [IntoFuture](https://doc.rust-lang.org/std/future/trait.IntoFuture.html) to make our async code a little less verbose. However, rust-analyzer can't infer the output type of an await expression if the value uses `IntoFuture` to convert into another type. So we're getting `{unknown}` types everywhere since switching.

`foo.await` itself [desugars](e4417cf020/compiler/rustc_ast_lowering/src/expr.rs (L644-L658)) into a `match into_future(foo) {}`, with every `Future` impl getting a [default](e4417cf020/library/core/src/future/into_future.rs (L131-L139)) `IntoFuture` implementation. I'm not sure if we want to disable the old `future_trait` paths, since this only recently [stabilize](https://github.com/rust-lang/rust/pull/98718).
2022-08-18 07:37:47 +00:00
bors
82ff740501 Auto merge of #13044 - dzvon:fix-typo, r=Veykril
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 14:59:02 +00:00
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
d6412b5866 Auto merge of #13034 - lowr:fix/regression-from-12993, r=lowr
fix: escape keywords used as names in earlier editions

Fixes #13030

There are keywords in Rust 2018+ that you can use as names without escaping when your crate is in Rust 2015 e.g. "try". We need to be consistent on how to keep track of the names regardless of how they are actually written in each crate. This patch attempts at it by taking such names into account and storing them uniformly in their escaped form.
2022-08-17 09:55:14 +00:00
Ryo Yoshida
a3409c3a83
fix: escape keywords used as names in earlier editions 2022-08-17 18:46:17 +09:00
Lukas Wirth
3f149a63d2 Simplify 2022-08-15 16:40:10 +02:00
Ryo Yoshida
018266a7ff
Make ModPath display escaped path 2022-08-11 03:41:10 +09:00
Ryo Yoshida
4322cf7f5b
Remove EscapedName 2022-08-11 01:11:18 +09:00
Ryo Yoshida
53ec791dc6
Add UnescapedName and make Name hold escaped name 2022-08-11 01:03:08 +09:00
Edwin Cheng
c47914c6cf Fixes tests 2022-08-10 16:29:23 +08:00
Edwin Cheng
23e17cd581 Improve insert whitespace in mbe 2022-08-10 16:28:56 +08:00
Justin Ridgewell
5810c8188a Implement IntoFuture type inference 2022-08-08 21:05:56 -04:00
bors
b481b59be5 Auto merge of #12937 - fprasx:master, r=Veykril
Add fixups for incomplete in proc-macros

Partially implements https://github.com/rust-lang/rust-analyzer/issues/12777.

Added support for for loops and match statements.

I couldn't do paths like `crate::foo::` as I wasn't able to add `SyntheticTokens` to the end of `foo::`, they always ended up after `crate::`

This is my first contribution so please don't be shy about letting me know if I've done anything wrong!
2022-08-08 11:37:51 +00: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
Ryo Yoshida
4d5873e92f
minor: align with rustc on escaping characters in macro expansion 2022-08-05 22:01:09 +09:00
Lukas Wirth
d6e78b04d0 feat: Handle operators like their trait functions in the IDE 2022-08-05 14:16:36 +02:00
Ryo Yoshida
859d467276
fix: make concat! work with char 2022-08-05 02:58:16 +09:00