summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2023-04-10Remove `..` from return type notationMichael Goulet-11/+16
2023-04-02Use `&IndexSlice` instead of `&IndexVec` where possibleScott McMurray-2/+2
All the same reasons as for `[T]`: more general, less pointer chasing, and `&mut IndexSlice` emphasizes that it doesn't change *length*.
2023-03-28Add `(..)` syntax for RTNMichael Goulet-30/+55
2023-03-28Add tests and error messagesMichael Goulet-5/+12
2023-03-28RTNMichael Goulet-0/+12
2023-03-28ParenthesizedGenericArgs::{Ok -> ParenSugar}Michael Goulet-1/+1
2023-03-22rustc: Remove unused `Session` argument from some attribute functionsVadim Petrochenkov-1/+1
2023-03-12Auto merge of #108820 - cjgillot:ensure-on-disk, r=oli-obkbors-2/+3
Ensure value is on the on-disk cache before returning from `ensure()`. The current logic for `ensure()` a query just checks that the node is green in the dependency graph. However, a lot of places use `ensure()` to prevent the query from being called later. This is the case before stealing a query result. If the query is actually green but the value is not available in the on-disk cache, `ensure` would return, but a subsequent call to the full query would run the code, and attempt to read from a stolen value. This PR conforms the query system to the usage by checking whether the queried value is loadable from disk before returning. Sadly, I can't manage to craft a proper test... Should fix all instances of "attempted to read from stolen value".
2023-03-12Auto merge of #108794 - nnethercote:avoid-unnecessary-hashing, r=cjgillotbors-31/+24
Avoid unnecessary hashing I noticed some stable hashing being done in a non-incremental build. It turns out that some of this is necessary to compute the crate hash, but some of it is not. Removing the unnecessary hashing is a perf win. r? `@cjgillot`
2023-03-11Use ensure_with_value in a few more places.Camille GILLOT-2/+3
2023-03-11Simplify message pathsest31-1/+1
This makes it easier to open the messages file while developing on features. The commit was the result of automatted changes: for p in compiler/rustc_*; do mv $p/locales/en-US.ftl $p/messages.ftl; rmdir $p/locales; done for p in compiler/rustc_*; do sed -i "s#\.\./locales/en-US.ftl#../messages.ftl#" $p/src/lib.rs; done
2023-03-11Rollup merge of #108806 - cjgillot:query-lints, r=davidtwcoMatthias Krüger-0/+1
Querify register_tools and post-expansion early lints The 2 extra queries correspond to code that happen before and after macro expansion, and don't need the resolver to exist.
2023-03-08Only compute the crate hash when necessary.Nicholas Nethercote-31/+24
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-06Querify early_lint_checks.Camille GILLOT-0/+1
2023-03-03Match unmatched backticks in compiler/ that are part of rustdocest31-1/+1
2023-02-28Only look for param in generics if it actually comes from genericsMichael Goulet-9/+30
2023-02-25Add ErrorGuaranteed to HIR TyKind::ErrMichael Goulet-9/+13
2023-02-22pluralize stuffMichael Goulet-31/+25
2023-02-22Suppress duplicated errors for associated type bounds in object typesMichael Goulet-33/+46
2023-02-22Move associated type bounds check to ast loweringMichael Goulet-3/+7
This makes the check for when associated type bounds more accurate
2023-02-22errors: generate typed identifiers in each crateDavid Wood-3/+10
Instead of loading the Fluent resources for every crate in `rustc_error_messages`, each crate generates typed identifiers for its own diagnostics and creates a static which are pulled together in the `rustc_driver` crate and provided to the diagnostic emitter. Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-21Use `ThinVec` in `ast::Generics` and related types.Nicholas Nethercote-2/+2
2023-02-14Better label for illegal impl trait typesMichael Goulet-4/+22
2023-01-28Remove `HirId -> LocalDefId` map from HIR.Camille GILLOT-12/+1
2023-01-26Auto merge of #106812 - oli-obk:output_filenames, r=petrochenkovbors-0/+1
make `output_filenames` a real query part of #105462 This may be a perf regression and is not obviously the right way forward. We may store this information in the resolver after freezing it for example.
2023-01-26Auto merge of #106745 - m-ou-se:format-args-ast, r=oli-obkbors-0/+1
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-23Evaluate `output_filenames` before one of its dependencies gets stolenOli Scherer-0/+1
2023-01-17Rollup merge of #104505 - WaffleLapkin:no-double-spaces-in-comments, r=jackh726Matthias Krüger-4/+4
Remove double spaces after dots in comments Most of the comments do not have double spaces, so I assume these are typos.
2023-01-17Remove double spaces after dots in commentsMaybe Waffle-4/+4
2023-01-12Remove `untracked_crate` field and instead pass it along with the resolver.Oli Scherer-2/+1
2023-01-12Expand format_args!() in rust_ast_lowering.Mara Bos-0/+1
2023-01-05Fix `uninlined_format_args` for some compiler cratesnils-4/+4
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-02Auto merge of #84762 - cjgillot:resolve-span-opt, r=petrochenkovbors-1/+1
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.
2022-12-29Rollup merge of #106221 - Nilstrieb:rptr-more-like-ref-actually, ↵Matthias Krüger-3/+3
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-28Rename `Rptr` to `Ref` in AST and HIRNilstrieb-3/+3
The name makes a lot more sense, and `ty::TyKind` calls it `Ref` already as well.
2022-12-27Rollup merge of #106064 - lukas-code:outlives-macro, r=cjgillotMichael Goulet-2/+5
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-26address review comments + better testsLukas Markeffsky-2/+5
2022-12-25Rollup merge of #106137 - matthiaskrgr:clippy_style, r=jyn514Matthias Krüger-2/+2
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-25Rollup merge of #105375 - WaffleLapkin:docfix, r=cjgillotMatthias Krüger-4/+2
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-25Only enable relative span hashing on nightly.Camille GILLOT-1/+1
2022-12-25Enable relative span hashing.Camille GILLOT-1/+1
2022-12-25fix more clippy::style findingsMatthias Krüger-2/+2
match_result_ok obfuscated_if_else single_char_add writeln_empty_string collapsible_match iter_cloned_collect unnecessary_mut_passed
2022-12-20rustc: Remove needless lifetimesJeremy Stucki-1/+1
2022-12-19Rollup merge of #105864 - matthiaskrgr:compl, r=NilstriebDylan DPC-1/+1
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-19clippy::complexity fixesMatthias Krüger-1/+1
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-18Revert "Introduce lowering_arena to avoid creating AST nodes on the fly"Nilstrieb-35/+20
This reverts commit d9a1faaa9cff6eab069ea8e5cd7862d0ae48e231. This was originally part of a larger PR that has now been closed as a different approach is taken now.
2022-12-12Auto merge of #105160 - nnethercote:rm-Lit-token_lit, r=petrochenkovbors-1/+2
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-10compiler: remove unnecessary imports and qualified pathsKaDiWa-2/+2
2022-12-08Rollup merge of #105408 - cuviper:help-rpitirpit, r=compiler-errorsMatthias Krüger-11/+21
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-06Add help for `#![feature(impl_trait_in_fn_trait_return)]`Josh Stone-11/+21
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`.