]>
git.lizzy.rs Git - rust.git/log
bors[bot] [Sat, 10 Apr 2021 23:42:26 +0000 (23:42 +0000)]
Merge #8465
8465: Include more info in assert r=jonas-schievink a=jonas-schievink
This helped find https://github.com/rust-analyzer/rust-analyzer/issues/8464
changelog skip
bors r+
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Jonas Schievink [Sat, 10 Apr 2021 23:41:40 +0000 (01:41 +0200)]
Include more info in assert
bors[bot] [Sat, 10 Apr 2021 23:33:18 +0000 (23:33 +0000)]
Merge #8463
8463: Support macros in pattern position r=jonas-schievink a=jonas-schievink
This was fairly easy, because patterns are limited to bodies, so almost all changes were inside body lowering.
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Jonas Schievink [Sat, 10 Apr 2021 21:12:02 +0000 (23:12 +0200)]
Support macros in pattern position
bors[bot] [Sat, 10 Apr 2021 21:35:05 +0000 (21:35 +0000)]
Merge #8436
8436: Fix extract function's mutability of variables outliving the body r=matklad a=brandondong
**Reproduction:**
```rust
fn main() {
let mut k = 1;
let mut j = 2;
j += 1;
k += j;
}
```
1. Select the first to third lines of the main function. Use the "Extract into function" code assist.
2. The output is the following which does not compile because the outlived variable `k` is declared as immutable:
```rust
fn main() {
let (k, j) = fun_name();
k += j;
}
fn fun_name() -> (i32, i32) {
let mut k = 1;
let mut j = 2;
j += 1;
(k, j)
}
```
3. We would instead expect the output to be:
```rust
fn main() {
let (mut k, j) = fun_name();
k += j;
}
```
**Fix:**
- Instead of declaring outlived variables as immutable unconditionally, check for any mutable usages outside of the extracted function.
Co-authored-by: Brandon <brandondong604@hotmail.com>
bors[bot] [Sat, 10 Apr 2021 18:34:59 +0000 (18:34 +0000)]
Merge #8460
8460: Revert "Rewrite `#[derive]` removal code to be based on AST" r=jonas-schievink a=jonas-schievink
It breaks some function-like proc macros: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Proc.20macro.20expansion/near/
233971916
It also uses attribute indices incorrectly, which causes insufficient attributes to be removed.
bors r+
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Jonas Schievink [Sat, 10 Apr 2021 18:30:28 +0000 (20:30 +0200)]
Revert "Rewrite `#[derive]` removal to be based on AST"
This reverts commit
7e78aebc8fbbb4043d62949681e4d700f1a2ec46 .
Jonas Schievink [Sat, 10 Apr 2021 18:30:24 +0000 (20:30 +0200)]
Revert "Use `pub(crate)`"
This reverts commit
c51213c2e7de21b7e68e6773ca3be0cdfc7c18af .
Jonas Schievink [Sat, 10 Apr 2021 18:30:19 +0000 (20:30 +0200)]
Revert "Use `name![derive]`"
This reverts commit
d6187de4cd34a1288c7820c5477b81b1e9b692a9 .
bors[bot] [Sat, 10 Apr 2021 16:06:01 +0000 (16:06 +0000)]
Merge #8458
8458: Respect test style guidelines in tests::traits r=Veykril a=Veykril
bors r+
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Lukas Wirth [Sat, 10 Apr 2021 16:03:27 +0000 (18:03 +0200)]
Respect test style guidelines in tests::traits
bors[bot] [Sat, 10 Apr 2021 15:53:06 +0000 (15:53 +0000)]
Merge #8457
8457: Implement more precise binary op return type heuristic r=flodiebold a=Veykril
Should fix #7150
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Lukas Wirth [Sat, 10 Apr 2021 15:52:24 +0000 (17:52 +0200)]
Add test for binary op return ty with adt
Lukas Wirth [Sat, 10 Apr 2021 15:16:35 +0000 (17:16 +0200)]
Add manual ops::Add impls to test::traits::closure_2
Lukas Wirth [Sat, 10 Apr 2021 14:56:32 +0000 (16:56 +0200)]
Implement more precise binary op return type prediction
bors[bot] [Sat, 10 Apr 2021 13:07:46 +0000 (13:07 +0000)]
Merge #8410
8410: Use CompletionTextEdit::InsertAndReplace if supported by the client r=Veykril a=Veykril
Fixes #8404, Fixes #3130
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
bors[bot] [Sat, 10 Apr 2021 10:01:03 +0000 (10:01 +0000)]
Merge #8384
8384: add is quadratic test r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
Aleksey Kladov [Tue, 6 Apr 2021 18:59:47 +0000 (21:59 +0300)]
Let's try testing for "is not quadratic" condition
bors[bot] [Fri, 9 Apr 2021 20:52:41 +0000 (20:52 +0000)]
Merge #8453
8453: Avoid an unnecessary `collect` r=jonas-schievink a=jonas-schievink
bors r+
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Jonas Schievink [Fri, 9 Apr 2021 20:52:13 +0000 (22:52 +0200)]
Avoid an unnecessary `collect`
bors[bot] [Fri, 9 Apr 2021 15:16:36 +0000 (15:16 +0000)]
Merge #8450
8450: Don't ignore unnamed consts when looking for definitions r=Veykril a=Veykril
Fixes #8448
bors r+
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Lukas Wirth [Fri, 9 Apr 2021 15:14:48 +0000 (17:14 +0200)]
Insert unnamed consts to ChildBySource DynMap
bors[bot] [Fri, 9 Apr 2021 13:30:12 +0000 (13:30 +0000)]
Merge #8447
8447: Resolve prelude and crate root names in the root DefMap r=jonas-schievink a=jonas-schievink
Should fix https://github.com/rust-analyzer/rust-analyzer/issues/8418
bors r+
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Jonas Schievink [Fri, 9 Apr 2021 13:25:12 +0000 (15:25 +0200)]
Resolve prelude and crate root names in the root DefMap
bors[bot] [Fri, 9 Apr 2021 12:53:49 +0000 (12:53 +0000)]
Merge #8443 #8446
8443: Rewrite `#[derive]` removal code to be based on AST r=jonas-schievink a=jonas-schievink
We now remove any `#[derive]` before and including the one we want to expand, in the `macro_arg` query.
The same infra will be needed by attribute macros (except we only remove the attribute we're expanding, not any preceding ones).
Part of https://github.com/rust-analyzer/rust-analyzer/issues/8434 (doesn't implement the cfg-expansion yet, because that's more difficult)
8446: Undo path resolution hack for extern prelude r=jonas-schievink a=jonas-schievink
Reverts the change made in https://github.com/rust-analyzer/rust-analyzer/pull/7959
We don't populate the extern prelude for block DefMaps anymore,
so this is unnecessary
bors r+
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Jonas Schievink [Fri, 9 Apr 2021 12:50:42 +0000 (14:50 +0200)]
Use `name![derive]`
Jonas Schievink [Fri, 9 Apr 2021 12:46:52 +0000 (14:46 +0200)]
Undo path resolution hack for extern prelude
We don't populate the extern prelude for block DefMaps anymore,
so this is unnecessary
bors[bot] [Fri, 9 Apr 2021 12:43:48 +0000 (12:43 +0000)]
Merge #8445
8445: `hir_ty` cleanup r=flodiebold a=flodiebold
Move lots of things around within `hir_ty`. Most notably, all the Chalk-related stuff moves from within `traits/` to the top-level, since Chalk isn't purely a "traits thing" anymore.
Co-authored-by: Florian Diebold <flodiebold@gmail.com>
Florian Diebold [Fri, 9 Apr 2021 12:39:07 +0000 (14:39 +0200)]
More cleanups / module docs
Florian Diebold [Fri, 9 Apr 2021 12:33:03 +0000 (14:33 +0200)]
More cleanups
Florian Diebold [Fri, 9 Apr 2021 12:28:04 +0000 (14:28 +0200)]
More moving stuff around
Jonas Schievink [Fri, 9 Apr 2021 12:24:31 +0000 (14:24 +0200)]
Use `pub(crate)`
bors[bot] [Fri, 9 Apr 2021 12:24:03 +0000 (12:24 +0000)]
Merge #8444
8444: Shrink `unlinked-file` diagnostic to 3 characters r=jonas-schievink a=jonas-schievink
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/8442
(the diagnostic fires intentionally on `#[cfg]`d modules, but with this won't cover the whole file)
bors r+
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Jonas Schievink [Fri, 9 Apr 2021 12:22:38 +0000 (14:22 +0200)]
Shrink `unlinked-file` diagnostic to 3 characters
Florian Diebold [Fri, 9 Apr 2021 12:18:58 +0000 (14:18 +0200)]
Move some more stuff to better places
Florian Diebold [Fri, 9 Apr 2021 12:15:26 +0000 (14:15 +0200)]
Move ToChalk -> mapping
Florian Diebold [Fri, 9 Apr 2021 12:11:37 +0000 (14:11 +0200)]
Reorganize hir_ty modules
Chalk isn't really a 'traits' thing anymore, so it doesn't make sense to
have all the Chalk-related stuff in submodules of `traits`.
Jonas Schievink [Fri, 9 Apr 2021 12:10:54 +0000 (14:10 +0200)]
Rewrite `#[derive]` removal to be based on AST
Jonas Schievink [Fri, 9 Apr 2021 11:38:01 +0000 (13:38 +0200)]
Store `#[derive]` attribute ID along macro invoc
Jonas Schievink [Fri, 9 Apr 2021 11:36:22 +0000 (13:36 +0200)]
Rename `Attr`s `index` field to `id`
Jonas Schievink [Thu, 8 Apr 2021 17:44:21 +0000 (19:44 +0200)]
Add `AttrId` to track attribute sources
bors[bot] [Fri, 9 Apr 2021 10:45:34 +0000 (10:45 +0000)]
Merge #8406
8406: Improve indexing of impls r=flodiebold a=flodiebold
Store impls for e.g. &Foo with the ones for Foo instead of the big "other" bucket. This can improve performance and simplifies the HIR impl search a bit.
Co-authored-by: Florian Diebold <flodiebold@gmail.com>
Florian Diebold [Wed, 7 Apr 2021 17:35:24 +0000 (19:35 +0200)]
Improve indexing of impls
Store impls for e.g. &Foo with the ones for Foo instead of the big
"other" bucket. This can improve performance and simplifies the HIR impl
search a bit.
bors[bot] [Fri, 9 Apr 2021 09:18:42 +0000 (09:18 +0000)]
Merge #8440
8440: Fix crash on syn involving lifetimes returned by Chalk r=flodiebold a=flodiebold
If we get lifetime variables back in autoderef, just immediately replace them by static lifetimes for now. Method resolution doesn't really deal correctly with new variables being introduced (this needs to be fixed more properly).
This fixes `rust-analyzer analysis-stats --with-deps` crashing in the RA repo.
Co-authored-by: Florian Diebold <flodiebold@gmail.com>
Florian Diebold [Thu, 8 Apr 2021 21:34:05 +0000 (23:34 +0200)]
Fix crash on syn involving lifetimes returned by Chalk
If we get lifetime variables back in autoderef, just immediately replace
them by static lifetimes for now. Method resolution doesn't really deal
correctly with new variables being introduced (this needs to be fixed
more properly).
This fixes `rust-analyzer analysis-stats --with-deps` crashing in the RA
repo.
Brandon [Wed, 7 Apr 2021 05:09:26 +0000 (22:09 -0700)]
Fix extract function's mutability of variables outliving the body
bors[bot] [Thu, 8 Apr 2021 23:33:36 +0000 (23:33 +0000)]
Merge #8429
8429: 8425: Added documentation for on enter covering //! doc comments. r=jonas-schievink a=chetankhilosiya
Also added passing test case.
Co-authored-by: Chetan Khilosiya <chetan.khilosiya@gmail.com>
bors[bot] [Thu, 8 Apr 2021 21:11:53 +0000 (21:11 +0000)]
Merge #8433
8433: Intern lots of things r=jonas-schievink a=flodiebold
This uses the new interning infrastructure for most type-related things, where it had a positive effect on memory usage and performance. In total, this gives a slight performance improvement and a quite good memory reduction (1119MB->885MB on RA, 1774MB->1188MB on Diesel).
Co-authored-by: Florian Diebold <flodiebold@gmail.com>
Florian Diebold [Thu, 8 Apr 2021 19:15:01 +0000 (21:15 +0200)]
Cleanup
Florian Diebold [Thu, 8 Apr 2021 18:55:03 +0000 (20:55 +0200)]
Intern Variances
This may be a slight performance improvement.
Florian Diebold [Thu, 8 Apr 2021 18:39:43 +0000 (20:39 +0200)]
Don't intern ProgramClause at all
This seems to work best performance/memory-wise.
Florian Diebold [Thu, 8 Apr 2021 18:18:51 +0000 (20:18 +0200)]
Intern QuantifiedWhereClauses
Slight performance and memory usage improvement.
Florian Diebold [Thu, 8 Apr 2021 18:13:21 +0000 (20:13 +0200)]
Intern ProgramClauses
Florian Diebold [Thu, 8 Apr 2021 18:06:19 +0000 (20:06 +0200)]
Intern CanonicalVarKinds
Slight savings in performance and memory.
Florian Diebold [Thu, 8 Apr 2021 16:45:07 +0000 (18:45 +0200)]
Intern consts & lifetimes
Slight memory usage reduction.
Florian Diebold [Thu, 8 Apr 2021 16:32:20 +0000 (18:32 +0200)]
Intern types
Performance about the same, memory reduced by ~5%.
Florian Diebold [Thu, 8 Apr 2021 16:25:18 +0000 (18:25 +0200)]
Intern Substitutions
(Costs a bit of performance, reduces memory usage on RA by ~10%.)
Florian Diebold [Thu, 8 Apr 2021 16:13:02 +0000 (18:13 +0200)]
Intern VariableKinds
bors[bot] [Thu, 8 Apr 2021 19:47:54 +0000 (19:47 +0000)]
Merge #8431
8431: 8024: Added the trait highlight modifier for assoc types. r=Veykril a=chetankhilosiya
Co-authored-by: Chetan Khilosiya <chetan.khilosiya@gmail.com>
Chetan Khilosiya [Thu, 8 Apr 2021 19:30:35 +0000 (01:00 +0530)]
8024: Added the trait modifier for assoc types.
Chetan Khilosiya [Thu, 8 Apr 2021 19:01:07 +0000 (00:31 +0530)]
8425: Added documentation for on enter covering //! doc comments.
Also added passing test case.
bors[bot] [Thu, 8 Apr 2021 18:43:41 +0000 (18:43 +0000)]
Merge #8428
8428: Use named fields in `MacroCallKind` r=jonas-schievink a=jonas-schievink
bors r+
changelog skip
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Jonas Schievink [Thu, 8 Apr 2021 18:43:07 +0000 (20:43 +0200)]
Use named fields in `MacroCallKind`
bors[bot] [Thu, 8 Apr 2021 16:51:11 +0000 (16:51 +0000)]
Merge #8426
8426: Track recursion limit when expanding custom derive r=jonas-schievink a=jonas-schievink
You can write a custom derive that expands to itself:
```rust
#[proc_macro_derive(Derive)]
pub fn derive(item: TokenStream) -> TokenStream {
let mut out: TokenStream = "#[derive(Derive)]".parse().unwrap();
out.extend(item);
out
}
```
rustc reports a recursion limit error, but rust-analyzer used to spin in name resolution and eventually fail with "name resolution is stuck". This makes it fail fast by respecting the recursion depth of the invocation.
bors r+
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Jonas Schievink [Thu, 8 Apr 2021 16:49:30 +0000 (18:49 +0200)]
Track recursion limit when expanding custom derive
bors[bot] [Thu, 8 Apr 2021 15:43:30 +0000 (15:43 +0000)]
Merge #8421
8421: Reduce allocations in "Expand macro" formatter r=edwin0cheng a=lnicola
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
bors[bot] [Thu, 8 Apr 2021 15:00:53 +0000 (15:00 +0000)]
Merge #8419 #8423
8419: Move hir_ty to Chalk IR r=flodiebold a=flodiebold
Closes #8313.
There's some further cleanups to do:
- we're still using our `TypeWalk` in lots of places (not for mutating/folding though, just for walking)
- we're still using our own canonicalization and unification and our `InferenceTable`
- ~`ToChalk` still exists and gets called, it's just the identity in most cases now (I'll probably clean those up before merging this)~
8423: Bump lsp-types and syn r=kjeremy a=kjeremy
This lsp-types now supports a default InsertTextMode for completion and a per-completion item commit_characters
Co-authored-by: Florian Diebold <flodiebold@gmail.com>
Co-authored-by: kjeremy <kjeremy@gmail.com>
kjeremy [Thu, 8 Apr 2021 14:57:47 +0000 (10:57 -0400)]
Bump lsp-types and syn
This lsp-types now supports a default InsertTextMode for completion and a per-completion item commit_characters
bors[bot] [Thu, 8 Apr 2021 14:51:51 +0000 (14:51 +0000)]
Merge #8422
8422: Remove extra bracket in architecture docs r=lnicola a=lnicola
bors r+
changelog skip
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
Laurențiu Nicola [Thu, 8 Apr 2021 14:51:02 +0000 (17:51 +0300)]
Remove extra bracket in architecture docs
Laurențiu Nicola [Thu, 8 Apr 2021 14:20:14 +0000 (17:20 +0300)]
Reduce allocations in Expand macro
Lukas Wirth [Thu, 8 Apr 2021 12:22:54 +0000 (14:22 +0200)]
Use CompletionTextEdit::InsertAndReplace if supported by the client
Florian Diebold [Thu, 8 Apr 2021 12:35:15 +0000 (14:35 +0200)]
Remove unused
Florian Diebold [Thu, 8 Apr 2021 12:21:22 +0000 (14:21 +0200)]
Replace `make_binders` by the now equivalent `make_only_type_binders`
Florian Diebold [Thu, 8 Apr 2021 12:16:05 +0000 (14:16 +0200)]
Remove identity impls for ToChalk
Florian Diebold [Thu, 8 Apr 2021 11:58:03 +0000 (13:58 +0200)]
Fix `Canonicalized::apply_solution`
Now that we're using Chalk's `substitute` which actually knows about
lifetimes, the hack doesn't work anymore, but we can put in a proper
lifetime.
Florian Diebold [Thu, 8 Apr 2021 11:51:04 +0000 (13:51 +0200)]
Fix missing match arms
Florian Diebold [Thu, 8 Apr 2021 11:32:56 +0000 (13:32 +0200)]
Fix remaining `interned_mut` call
Florian Diebold [Thu, 8 Apr 2021 11:32:48 +0000 (13:32 +0200)]
Replace remaining `fold` calls
Florian Diebold [Wed, 7 Apr 2021 19:26:37 +0000 (21:26 +0200)]
Replace some `fold` calls
Florian Diebold [Wed, 7 Apr 2021 19:26:24 +0000 (21:26 +0200)]
Fix shifted_{in,out} calls
Florian Diebold [Wed, 7 Apr 2021 19:17:51 +0000 (21:17 +0200)]
Fix subst_prefix
Florian Diebold [Wed, 7 Apr 2021 19:16:18 +0000 (21:16 +0200)]
Get rid of walk_mut [not compiling]
Florian Diebold [Wed, 7 Apr 2021 19:12:42 +0000 (21:12 +0200)]
Fix TyBuilder methods
Florian Diebold [Wed, 7 Apr 2021 19:10:28 +0000 (21:10 +0200)]
Impl Fold for CallableSig
Florian Diebold [Sat, 3 Apr 2021 15:49:29 +0000 (17:49 +0200)]
Add HasInterner bounds
Florian Diebold [Sat, 3 Apr 2021 15:42:13 +0000 (17:42 +0200)]
Allow unused
Florian Diebold [Sat, 3 Apr 2021 15:41:55 +0000 (17:41 +0200)]
Remove obsolete Cast impls
Florian Diebold [Sat, 3 Apr 2021 15:41:14 +0000 (17:41 +0200)]
Make ToChalk implementations identity
Florian Diebold [Sat, 3 Apr 2021 15:40:56 +0000 (17:40 +0200)]
Replace all the types by their Chalk versions
bors[bot] [Thu, 8 Apr 2021 05:46:15 +0000 (05:46 +0000)]
Merge #8207
8207: Show dbg remove assist on empty contents r=edwin0cheng a=ivan770
Closes #8185
Co-authored-by: ivan770 <leshenko.ivan770@gmail.com>
Co-authored-by: ivan770 <ivan@ivan770.me>
bors[bot] [Wed, 7 Apr 2021 22:12:43 +0000 (22:12 +0000)]
Merge #8412
8412: Emit folding ranges for multiline array literals r=Veykril a=Veykril
bors r+
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
Lukas Wirth [Wed, 7 Apr 2021 22:05:08 +0000 (00:05 +0200)]
Emit folding ranges for multiline array literals
bors[bot] [Wed, 7 Apr 2021 18:51:36 +0000 (18:51 +0000)]
Merge #8409
8409: Various remaining fixes for Chalk IR move r=flodiebold a=flodiebold
CC #8313
Co-authored-by: Florian Diebold <flodiebold@gmail.com>
Florian Diebold [Wed, 7 Apr 2021 18:50:26 +0000 (20:50 +0200)]
Fix return type of Substitution::interned
Florian Diebold [Wed, 7 Apr 2021 18:48:58 +0000 (20:48 +0200)]
InEnvironment::new takes a reference
Florian Diebold [Wed, 7 Apr 2021 18:47:04 +0000 (20:47 +0200)]
Make Canonical::new a free-standing function
Florian Diebold [Wed, 7 Apr 2021 18:41:52 +0000 (20:41 +0200)]
Fix return type of `self_type_parameter`
Florian Diebold [Wed, 7 Apr 2021 18:40:01 +0000 (20:40 +0200)]
Move hir_trait_id to extension trait
Florian Diebold [Wed, 7 Apr 2021 18:26:27 +0000 (20:26 +0200)]
Change TraitRef::hir_fmt_ext to free-standing function