Commit Graph

816 Commits

Author SHA1 Message Date
Matthias Krüger 68f12338af
Rollup merge of #104505 - WaffleLapkin:no-double-spaces-in-comments, r=jackh726
Remove double spaces after dots in comments

Most of the comments do not have double spaces, so I assume these are typos.
2023-01-17 20:21:25 +01:00
Maybe Waffle 6a28fb42a8 Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
bors 0b90256ada Auto merge of #106776 - oli-obk:om_nom_nom_nom_nom, r=cjgillot
Feed a bunch of queries instead of tracking fields on TyCtxt

r? `@cjgillot`

pulled out of https://github.com/rust-lang/rust/pull/105462
2023-01-13 13:57:21 +00:00
Oli Scherer 33b6a7790e Remove `untracked_crate` field and instead pass it along with the resolver. 2023-01-12 17:14:17 +00:00
Deadbeef 4fb10c0ce4 parse const closures 2023-01-12 02:28:37 +00:00
Albert Larsan 40ba0e84d5
Change `src/test` to `tests` in source files, fix tidy and tests 2023-01-11 09:32:13 +00: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
bors fb9dfa8cef Auto merge of #84762 - cjgillot:resolve-span-opt, r=petrochenkov
Encode spans relative to the enclosing item -- enable on nightly

Follow-up to #84373 with the flag `-Zincremental-relative-spans` set by default.

This PR seeks to remove one of the main shortcomings of incremental: the handling of spans.
Changing the contents of a function may require redoing part of the compilation process for another function in another file because of span information is changed.
Within one file: all the spans in HIR change, so typechecking had to be re-done.
Between files: spans of associated types/consts/functions change, so type-based resolution needs to be re-done (hygiene information is stored in the span).

The flag `-Zincremental-relative-spans` encodes local spans relative to the span of an item, stored inside the `source_span` query.

Trap: stashed diagnostics are referenced by the "raw" span, so stealing them requires to remove the span's parent.

In order to avoid too much traffic in the span interner, span encoding uses the `ctxt_or_tag` field to encode:
- the parent when the `SyntaxContext` is 0;
- the `SyntaxContext` when the parent is `None`.
Even with this, the PR creates a lot of traffic to the Span interner, when a Span has both a LocalDefId parent and a non-root SyntaxContext. They appear in lowering, when we add a parent to all spans, including those which come from macros, and during inlining when we mark inlined spans.

The last commit changes how queries of `LocalDefId` manage their cache. I can put this in a separate PR if required.

Possible future directions:
- validate that all spans are marked in HIR validation;
- mark macro-expanded spans relative to the def-site and not the use-site.
2023-01-02 13:10:16 +00: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
Michael Goulet 18bf19c3a9
Rollup merge of #106064 - lukas-code:outlives-macro, r=cjgillot
Partially fix `explicit_outlives_requirements` lint in macros

Show the suggestion if and only if the bounds are from the same source context.

fixes https://github.com/rust-lang/rust/issues/106044
fixes https://github.com/rust-lang/rust/issues/106063
2022-12-27 12:33:35 -08:00
Lukas Markeffsky 1eba6c404f address review comments + better tests 2022-12-26 16:35:21 +01:00
Matthias Krüger 23967a9990
Rollup merge of #106137 - matthiaskrgr:clippy_style, r=jyn514
fix more clippy::style findings

match_result_ok
obfuscated_if_else
single_char_add
writeln_empty_string
collapsible_match
iter_cloned_collect
unnecessary_mut_passed

r? `@compiler-errors`
2022-12-25 22:15:00 +01:00
Matthias Krüger 44065e4184
Rollup merge of #105375 - WaffleLapkin:docfix, r=cjgillot
Fix an outdated comment mentioning parameter that doesn't exist anymore

I'm not too familiar with the code in question, but from what I see I think the new comment makes sense.

r? `@cjgillot` (you touched these arguments lately https://github.com/rust-lang/rust/pull/91557/files#diff-ad0c15bbde97a607d4758ec7eaf88248be5d6b8ae084dfc84127f81e3f7a9bb4L1702, https://github.com/rust-lang/rust/pull/104048/files#diff-ad0c15bbde97a607d4758ec7eaf88248be5d6b8ae084dfc84127f81e3f7a9bb4L1682)
2022-12-25 22:14:59 +01:00
Camille GILLOT 40c8165395 Only enable relative span hashing on nightly. 2022-12-25 18:48:36 +00:00
Camille GILLOT 65f342daea Enable relative span hashing. 2022-12-25 18:48:31 +00:00
Matthias Krüger d8874f259a fix more clippy::style findings
match_result_ok
obfuscated_if_else
single_char_add
writeln_empty_string
collapsible_match
iter_cloned_collect
unnecessary_mut_passed
2022-12-25 17:32:26 +01:00
Matthias Krüger d23cb738d2
Rollup merge of #105975 - jeremystucki:rustc-remove-needless-lifetimes, r=eholk
rustc: Remove needless lifetimes
2022-12-24 00:31:41 +01:00
Lukas Markeffsky 94d6245003 Fix `explicit_outlives_requirements` lint in macros
Show the suggestion if and only if the bounds are from the same source context.
2022-12-22 22:04:40 +01:00
Bryan Garza ccbba0a60e Update track_caller tests; run fmt 2022-12-21 23:25:08 +00:00
Bryan Garza 9650a4168f Improve code based on feedback.
This patch improves the readability of some of the code by using
if-let-chains. Also, make use of the `add_feature_diagnostics` function.
2022-12-21 03:47:27 +00:00
Bryan Garza 2d060034f0 Update track_caller logic/lint after rebase 2022-12-21 03:39:33 +00:00
Jeremy Stucki 3dde32ca97
rustc: Remove needless lifetimes 2022-12-20 22:10:40 +01:00
Andrew Pollack 8441ca5d81
Revert "Replace usage of `ResumeTy` in async lowering with `Context`" 2022-12-19 11:24:59 -08:00
Dylan DPC a9005b6cc0
Rollup merge of #105864 - matthiaskrgr:compl, r=Nilstrieb
clippy::complexity fixes

filter_next
needless_question_mark
bind_instead_of_map
manual_find
derivable_impls
map_identity
redundant_slicing
skip_while_next
unnecessary_unwrap
needless_bool

r? `@compiler-errors`
2022-12-19 14:41:35 +05:30
Matthias Krüger 1da4a49912 clippy::complexity fixes
filter_next
needless_question_mark
bind_instead_of_map
manual_find
derivable_impls
map_identity
redundant_slicing
skip_while_next
unnecessary_unwrap
needless_bool
2022-12-19 00:04:28 +01:00
Nilstrieb d59a2ac2bc Revert "Introduce lowering_arena to avoid creating AST nodes on the fly"
This reverts commit d9a1faaa9c.

This was originally part of a larger PR that has now been closed as a
different approach is taken now.
2022-12-18 20:28:59 +01:00
Matthias Krüger 5e38e702aa
Rollup merge of #105464 - nbdd0121:hir, r=compiler-errors
Support #[track_caller] on async closures

Follow up on #105180

r? ```@compiler-errors```
cc ```@cjgillot```
2022-12-13 19:57:10 +01:00
bors 2cd2070af7 Auto merge of #105160 - nnethercote:rm-Lit-token_lit, r=petrochenkov
Remove `token::Lit` from `ast::MetaItemLit`.

Currently `ast::MetaItemLit` represents the literal kind twice. This PR removes that redundancy. Best reviewed one commit at a time.

r? `@petrochenkov`
2022-12-12 05:16:50 +00:00
KaDiWa 9bc69925cb
compiler: remove unnecessary imports and qualified paths 2022-12-10 18:45:34 +01:00
Gary Guo 6275b045d7 Move paren expr and loop HIR lowering 2022-12-08 17:28:21 +00:00
Gary Guo 0c0fb226bb Support `#[track_caller]` on async closures 2022-12-08 17:23:44 +00:00
Matthias Krüger 2fbde2b028
Rollup merge of #105408 - cuviper:help-rpitirpit, r=compiler-errors
Add help for `#![feature(impl_trait_in_fn_trait_return)]`

This adds a new variant `ImplTraitContext::FeatureGated`, so we can
generalize the help for `return_position_impl_trait_in_trait` to also
work for `impl_trait_in_fn_trait_return`.

cc #99697
2022-12-08 12:57:31 +01:00
Matthias Krüger 95da525982
Rollup merge of #105343 - nbdd0121:hir, r=fee1-dead
Simplify attribute handling in rustc_ast_lowering

Given that attributes is stored in a separate BTreeMap, it's not necessary to pass it in when constructing `hir::Expr`. We can just construct `hir::Expr` and then call `self.lower_attrs` later if it needs attributes.

As most desugaring code don't use attributes, this allows some code cleanup.
2022-12-07 15:39:07 +01:00
Josh Stone e9dd59131b Add help for `#![feature(impl_trait_in_fn_trait_return)]`
This adds a new variant `ImplTraitContext::FeatureGated`, so we can
generalize the help for `return_position_impl_trait_in_trait` to also
work for `impl_trait_in_fn_trait_return`.
2022-12-06 17:53:50 -08:00
Maybe Waffle d87a8349ee Fix an outdated comment mentioning parameter that doesn't exist anymore 2022-12-06 14:32:14 +00:00
Arpad Borsos cf031a3355
Replace usage of `ResumeTy` in async lowering with `Context`
Replaces using `ResumeTy` / `get_context` in favor of using `&'static mut Context<'_>`.

Usage of the `'static` lifetime here is technically "cheating", and replaces
the raw pointer in `ResumeTy` and the `get_context` fn that pulls the
correct lifetimes out of thin air.
2022-12-06 10:16:23 +01:00
Gary Guo c559cf62c2 Simplify attribute handling in rustc_ast_lowering
Given that attributes is stored in a separate BTreeMap, it's not necessary
to pass it in when constructing `hir::Expr`. We can just construct
`hir::Expr` and then call `self.lower_attrs` later if it needs attributes.

As most desugaring code don't use attributes, this allows some code cleanup.
2022-12-06 01:05:17 +00:00
Matthias Krüger 78cf0b916a
Rollup merge of #105180 - nbdd0121:async_track_caller, r=compiler-errors
Use proper HirId for async track_caller attribute check

Fix #105134
2022-12-05 20:43:42 +01:00
Gary Guo 34c377335b Add fixme note 2022-12-05 03:18:26 +00:00
Matthias Krüger c89bff29e5
Rollup merge of #104199 - SarthakSingh31:issue-97417-1, r=cjgillot
Keep track of the start of the argument block of a closure

This removes a call to `tcx.sess.source_map()` from [compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs](https://github.com/rust-lang/rust/compare/master...SarthakSingh31:issue-97417-1?expand=1#diff-8406bbc0d0b43d84c91b1933305df896ecdba0d1f9269e6744f13d87a2ab268a) as required by #97417.

VsCode automatically applied `rustfmt` to the files I edited under `src/tools`. I can undo that if its a problem.

r? `@cjgillot`
2022-12-03 17:37:41 +01:00
bors 703d95e183 Auto merge of #105133 - oli-obk:promoted_def_ids, r=cjgillot
Ensure query backtraces work for `DefId`s created after ast lowering

r? `@cjgillot`
2022-12-03 08:17:46 +00:00
Gary Guo ec4080b236 Fix async track caller for assoc fn and trait impl fn 2022-12-02 16:47:57 +00:00
Gary Guo 4c73b64632 Use proper HirId for async track_caller attribute check 2022-12-02 16:47:57 +00:00
Nicholas Nethercote 2fd364acff Remove `token::Lit` from `ast::MetaItemLit`.
`token::Lit` contains a `kind` field that indicates what kind of literal
it is. `ast::MetaItemLit` currently wraps a `token::Lit` but also has
its own `kind` field. This means that `ast::MetaItemLit` encodes the
literal kind in two different ways.

This commit changes `ast::MetaItemLit` so it no longer wraps
`token::Lit`. It now contains the `symbol` and `suffix` fields from
`token::Lit`, but not the `kind` field, eliminating the redundancy.
2022-12-02 13:49:19 +11:00
Nicholas Nethercote a7f35c42d4 Add `StrStyle` to `ast::LitKind::ByteStr`.
This is required to distinguish between cooked and raw byte string
literals in an `ast::LitKind`, without referring to an adjacent
`token::Lit`. It's a prerequisite for the next commit.
2022-12-02 10:38:58 +11:00
Vadim Petrochenkov b32a4edb20 rustc_ast_lowering: Stop lowering imports into multiple items
Lower them into a single item with multiple resolutions instead.
This also allows to remove additional `NodId`s and `DefId`s related to those additional items.
2022-12-01 18:51:20 +03:00
Vadim Petrochenkov 1f259ae679 rustc_hir: Change representation of import paths to support multiple resolutions 2022-12-01 18:51:05 +03:00
Oli Scherer ab75d777de Fill in `def_span` when creating def ids.
This makes sure that ICEing because of def ids created outside of ast lowering will be able to produce a query backtrace and not cause a double panic because of trying to call the  `def_span` query
2022-12-01 10:33:28 +00:00
bors d6c4de0fb2 Auto merge of #104861 - nnethercote:attr-cleanups, r=petrochenkov
Attribute cleanups

Best reviewed one commit at a time.

r? `@petrochenkov`
2022-12-01 07:13:45 +00:00