Commit Graph

763 Commits

Author SHA1 Message Date
Nicholas Nethercote
9570023ce1 Only compute the crate hash when necessary.
The crate hash is needed:
- if debug assertions are enabled, or
- if incr. comp. is enabled, or
- if metadata is being generated, or
- if `-C instrumentation-coverage` is enabled.

This commit avoids computing the crate hash when these conditions are
all false, such as when doing a release build of a binary crate.

It uses `Option` to store the hashes when needed, rather than
computing them on demand, because some of them are needed in multiple
places and computing them on demand would make compilation slower.

The commit also removes `Owner::hash_without_bodies`. There is no
benefit to pre-computing that one, it can just be done in the normal
fashion.
2023-03-08 09:30:22 +11:00
Michael Goulet
f851a8aefa Only look for param in generics if it actually comes from generics 2023-02-28 06:27:56 +00:00
Matthias Krüger
9c27fc7d34
Rollup merge of #108484 - Nilstrieb:˂DiagnosticItem˂FromFn˃ as From˂˂LangItemFromFn˃˃˃꞉꞉from, r=cjgillot
Remove `from` lang item

It was probably a leftover from the old `?` desugaring but anyways, it's unused now except for clippy, which can just use a diagnostics item.
2023-02-26 12:05:01 +01:00
Nilstrieb
312020ef6a Remove from_fn lang item
It was probably a leftover from the old `?` desugaring but anyways, it's
unused now except for clippy, which can just use a diagnostics item.
2023-02-26 09:15:54 +00:00
Michael Goulet
c0e58c3420 Add ErrorGuaranteed to HIR ExprKind::Err 2023-02-25 19:46:36 +00:00
Michael Goulet
a772a6fc2a Add ErrorGuaranteed to HIR TyKind::Err 2023-02-25 19:46:36 +00:00
Michael Howell
3d056c3125 diagnostics: if AssocFn has self argument, describe as method
Discussed in
https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.22associated.20function.22.20vs.20.22method.22/near/329265515

This commit also changes the tooltips on rustdoc intra-doc links
targeting methods.
2023-02-22 08:40:33 -07:00
Dylan DPC
076e627023
Rollup merge of #108141 - spastorino:add_rpitit_queries, r=compiler-errors
Add rpitit queries

This is part of the changes we are making to lower RPITITs as an associated type. The rest of the stuff will follow under a `-Z` flag.

I still need to add comments to the code, explain stuff and also I'd need to avoid encoding in metadata when rpitit queries return `&[]`

r? `@compiler-errors`
2023-02-21 14:19:59 +05:30
Matthias Krüger
7022ae4f8c
Rollup merge of #108255 - fee1-dead-contrib:fix-old-fixme, r=cjgillot
Remove old FIXMEs referring to #19596

Having an inner function that accepts a mutable reference seems to be the only way this can be expressed. Taking a mutable reference would call the same function with a new type &mut F which then causes the infinite recursion error in #19596.
2023-02-20 22:12:18 +01:00
Deadbeef
6b36c3078a Remove old FIXMEs referring to #19596 2023-02-20 06:12:56 +00:00
Santiago Pastorino
4e703a2772
Add associated_items_for_impl_trait_in_trait query 2023-02-19 11:18:56 -03:00
Maybe Waffle
8751fa1a9a if $c:expr { Some($r:expr) } else { None } =>> $c.then(|| $r) 2023-02-16 15:26:00 +00:00
Camille GILLOT
03dff82d59 Add of_trait to DefKind::Impl. 2023-02-14 19:55:44 +00:00
Vadim Petrochenkov
fd73d01c98 rustc_resolve: Remove Resolver::clone_output
And remove `Clone` impls and `Lrc`s that are no longer necessary
2023-02-13 00:10:15 +04:00
Vadim Petrochenkov
b62b82aef4 Resolve documentation links in rustc and store the results in metadata
This commit implements MCP https://github.com/rust-lang/compiler-team/issues/584

It also removes code that is no longer used, and that includes code cloning resolver, so issue #83761 is fixed.
2023-02-10 09:34:13 +04:00
Michael Goulet
2b70cbb8a5 Rename PointerSized to PointerLike 2023-02-07 19:05:53 +00:00
Matthias Krüger
4ac1796267
Rollup merge of #107125 - WaffleLapkin:expect_an_item_in_your_hir_by_the_next_morning, r=Nilstrieb
Add and use expect methods to hir.

[The future has come](https://github.com/rust-lang/rust/pull/106090/files#r1070062462).

r? `@Nilstrieb`

tbh I'm not even sure if it's worth it
2023-01-30 17:50:08 +01:00
Maybe Waffle
883145f75d fix TraitItemKind::expect_type docs 2023-01-30 05:55:20 +00:00
Maybe Waffle
a4aebf030e Improve ICE messages for *::expect_* 2023-01-30 05:50:06 +00:00
Camille GILLOT
15d6325747 Remove HirId -> LocalDefId map from HIR. 2023-01-28 09:55:26 +00:00
Camille GILLOT
3175d03d3b Take a LocalDefId in hir::Visitor::visit_fn. 2023-01-28 09:51:50 +00:00
Camille GILLOT
2870ce01b8 Impl HashStable/Encodable/Decodable for ObligationCause. 2023-01-27 18:56:32 +00:00
bors
3e97763872 Auto merge of #106745 - m-ou-se:format-args-ast, r=oli-obk
Move format_args!() into AST (and expand it during AST lowering)

Implements https://github.com/rust-lang/compiler-team/issues/541

This moves FormatArgs from rustc_builtin_macros to rustc_ast_lowering. For now, the end result is the same. But this allows for future changes to do smarter things with format_args!(). It also allows Clippy to directly access the ast::FormatArgs, making things a lot easier.

This change turns the format args types into lang items. The builtin macro used to refer to them by their path. After this change, the path is no longer relevant, making it easier to make changes in `core`.

This updates clippy to use the new language items, but this doesn't yet make clippy use the ast::FormatArgs structure that's now available. That should be done after this is merged.
2023-01-26 12:44:47 +00:00
yanchen4791
62a1e76d2b Add hint for missing lifetime bound on trait object when type alias is used 2023-01-23 09:54:45 -08:00
Maybe Waffle
70f9d52079 Add and use expect methods to hir. 2023-01-20 17:40:50 +00:00
Guillaume Gomez
1a878df2b8
Rollup merge of #106927 - Ezrashaw:e0606-make-machine-applicable, r=estebank
make `CastError::NeedsDeref` create a `MachineApplicable` suggestion

Fixes #106903

Simple impl for the linked issue. I also made some other small changes:
- `CastError::ErrorGuaranteed` now owns an actual `ErrorGuaranteed`. This better enforces the static guarantees of `ErrorGuaranteed`.
- `CastError::NeedDeref` code simplified a bit, we now just suggest the `*`, instead of the whole expression as well.
2023-01-19 11:19:34 +01:00
Arpad Borsos
96931a787a
Transform async ResumeTy in generator transform
- Eliminates all the `get_context` calls that async lowering created.
- Replace all `Local` `ResumeTy` types with `&mut Context<'_>`.

The `Local`s that have their types replaced are:
- The `resume` argument itself.
- The argument to `get_context`.
- The yielded value of a `yield`.

The `ResumeTy` hides a `&mut Context<'_>` behind an unsafe raw pointer, and the
`get_context` function is being used to convert that back to a `&mut Context<'_>`.

Ideally the async lowering would not use the `ResumeTy`/`get_context` indirection,
but rather directly use `&mut Context<'_>`, however that would currently
lead to higher-kinded lifetime errors.
See <https://github.com/rust-lang/rust/issues/105501>.

The async lowering step and the type / lifetime inference / checking are
still using the `ResumeTy` indirection for the time being, and that indirection
is removed here. After this transform, the generator body only knows about `&mut Context<'_>`.
2023-01-19 09:03:05 +01:00
Ezra Shaw
b73cdf1b29
special case removing & suggestion 2023-01-18 13:14:56 +13:00
Maybe Waffle
6a28fb42a8 Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
Deadbeef
4fb10c0ce4 parse const closures 2023-01-12 02:28:37 +00:00
Mara Bos
a4dbcb525b Expand format_args!() in rust_ast_lowering. 2023-01-12 00:25:45 +01:00
Mara Bos
bebf9fe063 Turn format arguments types into lang items. 2023-01-11 21:53:24 +01:00
klensy
cce2f5f772 fix typo LocalItemId -> ItemLocalId 2023-01-11 15:45:52 +03:00
nils
fd7a159710 Fix uninlined_format_args for some compiler crates
Convert all the crates that have had their diagnostic migration
completed (except save_analysis because that will be deleted soon and
apfloat because of the licensing problem).
2023-01-05 19:01:12 +01:00
Michael Goulet
b1b19bd851 get_parent and find_parent 2023-01-04 00:43:13 +00:00
Michael Goulet
a313ef05a7 rename get_parent_node to parent_id 2023-01-04 00:43:13 +00:00
Nilstrieb
e1787f5572 Reduce HIR debug output
HIR debug output is currently very verbose, especially when used with
the alternate (`#`) flag. This commit reduces the amount of noisy
newlines by forcing a few small key types to stay on one line, which
makes the output easier to read and scroll by.

```
$ rustc +after hello_world.rs -Zunpretty=hir-tree | wc -l
582
$ rustc +before hello_world.rs -Zunpretty=hir-tree | wc -l
932
```
2023-01-02 20:15:48 +01:00
Matthias Krüger
c610aeb592
Rollup merge of #106221 - Nilstrieb:rptr-more-like-ref-actually, r=compiler-errors
Rename `Rptr` to `Ref` in AST and HIR

The name makes a lot more sense, and `ty::TyKind` calls it `Ref` already as well.
2022-12-29 13:16:04 +01:00
Nilstrieb
9067e4417e Rename Rptr to Ref in AST and HIR
The name makes a lot more sense, and `ty::TyKind` calls it `Ref` already
as well.
2022-12-28 18:52:36 +01:00
Pietro Albini
11191279b7 Update bootstrap cfg 2022-12-28 09:18:43 -05:00
Ralf Jung
9f241b3a26 abort immediately on bad mem::zeroed/uninit 2022-12-22 16:37:42 +01:00
bors
eb9e5e711d Auto merge of #105880 - Nilstrieb:make-newtypes-less-not-rust, r=oli-obk
Improve syntax of `newtype_index`

This makes it more like proper Rust and also makes the implementation a lot simpler.

Mostly just turns weird flags in the body into proper attributes.

It should probably also be converted to an attribute macro instead of function-like, but that can be done in a future PR.
2022-12-20 07:27:01 +00:00
Andrew Pollack
8441ca5d81
Revert "Replace usage of ResumeTy in async lowering with Context" 2022-12-19 11:24:59 -08:00
Nilstrieb
8bfd6450c7 A few small cleanups for newtype_index
Remove the `..` from the body, only a few invocations used it and it's
inconsistent with rust syntax.

Use `;` instead of `,` between consts. As the Rust syntax gods inteded.
2022-12-18 21:47:28 +01:00
Matthias Krüger
2ea368e53c minor code cleanups 2022-12-12 19:49:53 +01:00
KaDiWa
9bc69925cb
compiler: remove unnecessary imports and qualified paths 2022-12-10 18:45:34 +01:00
Matthias Krüger
660795eee5
Rollup merge of #105441 - nnethercote:rm-UnsafetyState, r=lcnr
Remove `UnsafetyState`

r? `@lcnr`
2022-12-08 12:57:33 +01:00
Matthias Krüger
fbfc5ada02
Rollup merge of #105423 - oli-obk:symbols, r=jackh726
Use `Symbol` for the crate name instead of `String`/`str`

It always got converted to a symbol anyway
2022-12-08 12:57:32 +01:00
Nicholas Nethercote
9af48e5ab6 Fix a typo. 2022-12-08 15:53:31 +11:00
Oli Scherer
d30848b30a Use Symbol for the crate name instead of String/str 2022-12-07 20:30:02 +00:00