Commit graph

16180 commits

Author SHA1 Message Date
unexge
8d4be829e0 Add convert tuple struct to named struct assist 2021-04-04 20:52:43 +03:00
unexge
d3a112d68c Allow including Self kw references to FindUsages 2021-04-04 20:48:31 +03:00
bors[bot]
0924888cce
Merge #8325
8325: Check if bitflags deps pulls its weight r=jonas-schievink a=matklad

Bitflags is generally a good dependency -- it's lightweight, well
maintained and embraced by the ecosystem.

I wonder, however, do we really need it? Doesn't feel like it adds much
to be honest.

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-04-04 15:42:19 +00:00
bors[bot]
bc8b278841
Merge #8295
8295: Add `convert_into_to_from` assist r=Veykril a=obmarg

This adds a "Convert Into to From" assist, useful since clippy has
recently started adding lints on every `Into`.

It covers converting the signature, and converting any `self`/`Self`
references within the body.

It does assume that every instance of `Into` can be converted to a
`From`, which I _think_ is the case now.  Let me know if there's
something I'm not thinking of and I can try and make it smarter.

Closes #8196 

![CleanShot 2021-04-02 at 13 39 54](https://user-images.githubusercontent.com/556490/113420108-9ce21c00-93c0-11eb-8c49-80b5fb189284.gif)

I'm extremely new to this codebase so please let me know if anything needs
changed.

Co-authored-by: Graeme Coupar <grambo@grambo.me.uk>
2021-04-04 11:38:20 +00:00
bors[bot]
0829960320
Merge #8327
8327: Move `Ty` creation methods out of `Ty` (Chalk move preparation) r=flodiebold a=flodiebold

When we'll move to using `chalk_ir::Ty` (#8313), we won't be able to have our own inherent methods on `Ty` anymore, so we need to move the helpers elsewhere.
This adds a `TyBuilder` that allows easily constructing `Ty` and related types (`TraitRef`, `ProjectionTy`, `Substitution`). It also replaces `SubstsBuilder`. `TyBuilder` can construct different things based on its type parameter; e.g. if it has an `AdtId`, we're constructing an ADT type, but if it has a `TraitId`, we're constructing a `TraitRef`. The common thing for all of them is that we need to build a `Substitution`, so the API stays the same for all of them except at the beginning and end.

We also use `TyBuilder` to house various one-shot methods for constructing types, e.g. `TyBuilder::unit()`.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-04-04 11:30:07 +00:00
Florian Diebold
cde3857897 Add comment 2021-04-04 13:23:22 +02:00
Florian Diebold
ebdfc932e7 Replace Substitution::type_params 2021-04-04 13:16:39 +02:00
Florian Diebold
a4d7bdf1c8 Replace Substitution::bound_vars and ::type_params_for_generics 2021-04-04 13:16:39 +02:00
Florian Diebold
715c178f0b Move TyBuilder to its own module 2021-04-04 13:16:39 +02:00
Florian Diebold
584d1c9e5b Replace last uses of SubstsBuilder by TyBuilder 2021-04-04 13:16:39 +02:00
Florian Diebold
505ca65216 Remove CallableSig::from_substs 2021-04-04 13:16:39 +02:00
Florian Diebold
ac8fee006a Use TyBuilder in another place 2021-04-04 13:16:38 +02:00
Florian Diebold
eaa03ef446 Some more TyBuilder use 2021-04-04 13:16:38 +02:00
Florian Diebold
5d2b488aeb Replace remaining uses of Substitution::build_for_def 2021-04-04 13:16:38 +02:00
Florian Diebold
77333a571f More TyBuilder use 2021-04-04 13:16:38 +02:00
Florian Diebold
66fec39aa0 More TyBuilder use 2021-04-04 13:16:38 +02:00
Florian Diebold
cd227f581e Add and start using TraitRef and ProjectionTy builders 2021-04-04 13:16:38 +02:00
Florian Diebold
2ead65190e Move Ty::builtin to TyBuilder 2021-04-04 13:16:38 +02:00
Florian Diebold
620769f322 Add TyBuilder::adt 2021-04-04 13:16:38 +02:00
Florian Diebold
e6f007d9a8 Move Ty::fn_ptr to TyBuilder 2021-04-04 13:16:38 +02:00
Florian Diebold
b0fe3d929f Add TyBuilder::unit() and TyExt::is_unit() 2021-04-04 13:16:38 +02:00
Florian Diebold
b15152c430 Add TyBuilder 2021-04-04 13:16:38 +02:00
Aleksey Kladov
d1474ae518 Check if bitflags deps pulls its weight
Bitflags is generally a good dependency -- it's lightweight, well
maintained and embraced by the ecosystem.

I wonder, however, do we really need it? Doesn't feel like it adds much
to be honest.
2021-04-04 12:06:01 +03:00
bors[bot]
c9bcbf9a43
Merge #8324
8324: Add `Body::shrink_to_fit` r=jonas-schievink a=jonas-schievink

Saves ~15 MB

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-04-04 01:27:14 +00:00
Jonas Schievink
1da6d0bed9 Add Body::shrink_to_fit 2021-04-04 03:26:16 +02:00
bors[bot]
3ea5ea1324
Merge #8323
8323: Only remember blocks that have a DefMap r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-04-04 01:18:13 +00:00
Jonas Schievink
9b13e1bb91 Only remember blocks that have a DefMap 2021-04-04 03:16:26 +02:00
bors[bot]
4c8ee9a531
Merge #8322
8322: Access a body's block def maps via a method r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-04-04 01:04:44 +00:00
Jonas Schievink
d8bf9bef80 Access a body's block def maps via a method 2021-04-04 03:03:18 +02:00
bors[bot]
6b43a518e6
Merge #8321
8321: Use exhaustive matches in shrink_to_fit impls r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-04-04 00:56:46 +00:00
Jonas Schievink
f774a56af2 Use exhaustive matches in shrink_to_fit impls 2021-04-04 02:56:11 +02:00
bors[bot]
234ddf34c7
Merge #8320
8320: Make `ast_to_token_tree` infallible r=jonas-schievink a=jonas-schievink

It could never return `None`, so reflect that in the return type

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-04-03 23:47:10 +00:00
Jonas Schievink
3abcdc03ba Make ast_to_token_tree infallible
It could never return `None`, so reflect that in the return type
2021-04-04 01:46:45 +02:00
bors[bot]
bcf600fc88
Merge #8319
8319: Glob-reexport hir_def database types r=jonas-schievink a=jonas-schievink

Avoids having to constantly adjust this list

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-04-03 23:30:41 +00:00
Jonas Schievink
613f9ea41e Glob-reexport hir_def database types 2021-04-04 01:29:59 +02:00
bors[bot]
a3dc04905b
Merge #8318
8318: Use shrink_to_fit to reduce DefMap sizes r=jonas-schievink a=jonas-schievink

Especially `block_def_map` can overallocate when there's not a lot of items in the `DefMap`. This saves around 10 MB during analysis-stats. Not too much, but a cheap win.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-04-03 21:47:39 +00:00
Jonas Schievink
d1bce6070d Use shrink_to_fit to reduce DefMap sizes 2021-04-03 23:45:27 +02:00
bors[bot]
b78f1a0a4d
Merge #8315
8315: Try to reduce ItemTree size further r=jonas-schievink a=jonas-schievink

This was mostly a failed experiment, but still seems like the right thing to do. Memory reduction is mostly negligible.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-04-03 19:01:03 +00:00
Jonas Schievink
ee4b5a34d8 Use bitflags to compress function properties
Very minor savings, only 1 MB or so
2021-04-03 20:58:42 +02:00
Jonas Schievink
f7e6b186e1 Intern ModPath in Import
Minor savings only
2021-04-03 20:57:25 +02:00
bors[bot]
e2213a503e
Merge #8312
8312: cargo update r=kjeremy a=kjeremy



Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
2021-04-03 16:18:44 +00:00
Jeremy Kolb
c7a664c2ea cargo update 2021-04-03 12:18:00 -04:00
Graeme Coupar
ee03849017 Convert Into to From assist
This adds a "Convert Into to From" assist, useful since clippy has
recently started adding lints on every `Into`.

It covers converting the signature, and converting any `self`/`Self`
references within the body to the correct types.

It does assume that every instance of `Into` can be converted to a
`From`, which I _think_ is the case now.  Let me know if there's
something I'm not thinking of and I can try and make it smarter.
2021-04-03 15:48:35 +01:00
bors[bot]
2f87ee7f3f
Merge #8310
8310: Rename Ty::interned to Ty::kind r=flodiebold a=flodiebold

... since that's the actual method on Chalk side that matches the signature.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-04-03 11:09:43 +00:00
Florian Diebold
c551604b5a Rename Ty::interned to Ty::kind
... since that's the actual method on Chalk side that matches the signature.
2021-04-03 13:08:29 +02:00
bors[bot]
8289b96216
Merge #8309
8309: Introduce `GenericArg` like in Chalk r=flodiebold a=flodiebold

Plus some more adaptations to Substitution.

Lots of `assert_ty_ref` that we should revisit when introducing lifetime/const parameters.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-04-03 09:19:55 +00:00
Florian Diebold
e480d81988 Introduce GenericArg like in Chalk
Plus some more adaptations to Substitution.

Lots of `assert_ty_ref` that we should revisit when introducing
lifetime/const parameters.
2021-04-03 11:17:13 +02:00
bors[bot]
327f3a0a30
Merge #8307
8307: Allow include! an empty content file r=edwin0cheng a=edwin0cheng

fixes #8306

bors r+

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2021-04-03 04:55:39 +00:00
Edwin Cheng
20d55ce44d Allow include! an empty content file 2021-04-03 12:50:55 +08:00
bors[bot]
b5804296dd
Merge #8305
8305: Fix joinLines panic if run on the empty last line r=edwin0cheng a=edwin0cheng

fixes #8299

bors r+

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2021-04-03 03:21:45 +00:00