about summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src
AgeCommit message (Collapse)AuthorLines
2023-04-04Split out ast::ItemKind::Const into its own structOli Scherer-5/+5
2023-04-04rust-analyzer guided tuple field to named fieldOli Scherer-1/+1
2023-04-04rust-analyzer guided enum variant structificationOli Scherer-1/+1
2023-04-02Use `&IndexSlice` instead of `&IndexVec` where possibleScott McMurray-4/+4
All the same reasons as for `[T]`: more general, less pointer chasing, and `&mut IndexSlice` emphasizes that it doesn't change *length*.
2023-03-31Auto merge of #109010 - compiler-errors:rtn, r=eholkbors-21/+107
Initial support for return type notation (RTN) See: https://smallcultfollowing.com/babysteps/blog/2023/02/13/return-type-notation-send-bounds-part-2/ 1. Only supports `T: Trait<method(): Send>` style bounds, not `<T as Trait>::method(): Send`. Checking validity and injecting an implicit binder for all of the late-bound method generics is harder to do for the latter. * I'd add this in a follow-up. 3. ~Doesn't support RTN in general type position, i.e. no `let x: <T as Trait>::method() = ...`~ * I don't think we actually want this. 5. Doesn't add syntax for "eliding" the function args -- i.e. for now, we write `method(): Send` instead of `method(..): Send`. * May be a hazard if we try to add it in the future. I'll probably add it in a follow-up later, with a structured suggestion to change `method()` to `method(..)` once we add it. 7. ~I'm not in love with the feature gate name 😺~ * I renamed it to `return_type_notation` :heavy_check_mark: Follow-up PRs will probably add support for `where T::method(): Send` bounds. I'm not sure if we ever want to support return-type-notation in arbitrary type positions. I may also make the bounds require `..` in the args list later. r? `@ghost`
2023-03-29Rollup merge of #109664 - m-ou-se:format-args-placeholder-span, r=oli-obkDylan DPC-23/+43
Use span of placeholders in format_args!() expansion. `format_args!("{}", x)` expands to something that contains `Argument::new_display(&x)`. That entire expression was generated with the span of `x`. After this PR, `&x` uses the span of `x`, but the `new_display` call uses the span of the `{}` placeholder within the format string. If an implicitly captured argument was used like in `format_args!("{x}")`, both use the span of the `{x}` placeholder. This fixes https://github.com/rust-lang/rust/issues/109576, and also allows for more improvements to similar diagnostics in the future, since the usage of `x` can now be traced to the exact `{}` placeholder that required it to be `Display` (or `Debug` etc.)
2023-03-28Add `(..)` syntax for RTNMichael Goulet-36/+87
2023-03-28Add tests and error messagesMichael Goulet-5/+28
2023-03-28RTNMichael Goulet-0/+12
2023-03-28ParenthesizedGenericArgs::{Ok -> ParenSugar}Michael Goulet-5/+5
2023-03-27Rollup merge of #109354 - Swatinem:rm-closureid, r=compiler-errorsGuillaume Gomez-42/+42
Remove the `NodeId` of `ast::ExprKind::Async` This is a followup to https://github.com/rust-lang/rust/pull/104833#pullrequestreview-1314537416. In my original attempt, I was using `LoweringContext::expr`, which was not correct as it creates a fresh `DefId`. It now uses the correct `DefId` for the wrapping `Expr`, and also makes forwarding `#[track_caller]` attributes more explicit.
2023-03-27Use span of placeholders in format_args!() expansion.Mara Bos-23/+43
2023-03-22rustc: Remove unused `Session` argument from some attribute functionsVadim Petrochenkov-1/+1
2023-03-19Remove the `NodeId` of `ast::ExprKind::Async`Arpad Borsos-42/+42
2023-03-16Gate fmt args flattening behind -Zflatten-format-args.Mara Bos-2/+5
2023-03-16Don't allow new const panic through format flattening.Mara Bos-1/+17
panic!("a {}", "b") is still not allowed in const, even if the hir flattens to panic!("a b").
2023-03-16Also inline integer literals into format_args!().Mara Bos-5/+18
2023-03-16Check all arg indexes before removing inlined format args.Mara Bos-13/+15
2023-03-16Remove unreachable branch in format_args ast lowering.Mara Bos-19/+8
2023-03-16Fix argument index remapping in format_args flattening.Mara Bos-28/+36
2023-03-16Only inline `{}` string literals in format_args.Mara Bos-0/+1
Placeholders like {:123} would incorrectly get inlined.
2023-03-16Support flattening/inlining format_args through & and ().Mara Bos-6/+12
E.g. format_args!("{}", &(format_args!("abc"))).
2023-03-16Inline string literals into format_args!().Mara Bos-3/+61
2023-03-16Coalesce adjacent literal pieces in expand_format_args.Mara Bos-16/+16
2023-03-16Flatten nested format_args!() into one.Mara Bos-2/+100
2023-03-14Auto merge of #104833 - Swatinem:async-identity-future, r=compiler-errorsbors-38/+28
Remove `identity_future` indirection This was previously needed because the indirection used to hide some unexplained lifetime errors, which it turned out were related to the `min_choice` algorithm. Removing the indirection also solves a couple of cycle errors, large moves and makes async blocks support the `#[track_caller]`annotation. Fixes https://github.com/rust-lang/rust/issues/104826.
2023-03-13Auto merge of #108471 - clubby789:unbox-the-syntax, r=Nilstrieb,est31bors-1/+0
Remove `box_syntax` r? `@Nilstrieb` This removes the feature `box_syntax`, which allows the use of `box <expr>` to create a Box, and finalises removing use of the feature from the compiler. `box_patterns` (allowing the use of `box <pat>` in a pattern) is unaffected. It also removes `ast::ExprKind::Box` - the only way to create a 'box' expression now is with the rustc-internal `#[rustc_box]` attribute. As a temporary measure to help users move away, `box <expr>` now parses the inner expression, and emits a `MachineApplicable` lint to replace it with `Box::new` Closes #49733
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-12Remove `box_syntax` from AST and use in toolsclubby789-1/+0
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-08Remove `identity_future` indirectionArpad Borsos-38/+28
This was previously needed because the indirection used to hide some unexplained lifetime errors, which it turned out were related to the `min_choice` algorithm. Removing the indirection also solves a couple of cycle errors, large moves and makes async blocks support the `#[track_caller]` annotation.
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-05Auto merge of #108351 - petrochenkov:rmdit, r=cjgillotbors-1/+1
rustc_middle: Remove trait `DefIdTree` This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-03-03Match unmatched backticks in compiler/ that are part of rustdocest31-1/+1
2023-03-02rustc_middle: Remove trait `DefIdTree`Vadim Petrochenkov-1/+1
This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-03-02Rollup merge of #108516 - clubby789:rustc-box-restrict, r=compiler-errorsMatthias Krüger-17/+2
Restrict `#[rustc_box]` to `Box::new` calls Currently, `#[rustc_box]` can be applied to any call expression with a single argument. This PR only allows it to be applied to calls to `Box::new`
2023-03-02Restrict `#[rustc_box]` to `Box::new` callsclubby789-17/+2
2023-02-28Only look for param in generics if it actually comes from genericsMichael Goulet-13/+41
2023-02-25Add ErrorGuaranteed to HIR ExprKind::ErrMichael Goulet-17/+34
2023-02-25Add ErrorGuaranteed to HIR TyKind::ErrMichael Goulet-23/+29
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/+15
This makes the check for when associated type bounds more accurate
2023-02-22errors: generate typed identifiers in each crateDavid Wood-4/+11
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::AngleBracketedArgs`.Nicholas Nethercote-1/+1
2023-02-21Use `ThinVec` in various AST types.Nicholas Nethercote-2/+2
This commit changes the sequence parsers to produce `ThinVec`, which triggers numerous conversions.