summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2021-09-16Revert "Implement Anonymous{Struct, Union} in the AST"Felix S. Klock II-9/+0
This reverts commit 059b68dd677808e14e560802d235ad40beeba71e. Note that this was manually adjusted to retain some of the refactoring introduced by commit 059b68dd677808e14e560802d235ad40beeba71e, so that it could likewise retain the correction introduced in commit 5b4bc05fa57be19bb5962f4b7c0f165e194e3151 (cherry picked from commit 91feb76d133952825e3eb32bed399ec6e4bd9219)
2021-09-03Auto merge of #88597 - cjgillot:lower-global, r=petrochenkovbors-61/+4
Move global analyses from lowering to resolution Split off https://github.com/rust-lang/rust/pull/87234 r? `@petrochenkov`
2021-09-02Auto merge of #87114 - cjgillot:abilint, r=estebankbors-24/+2
Lint missing Abi in ast validation instead of lowering.
2021-09-01Compute proc_macros in resolutions.Camille GILLOT-4/+0
2021-09-01Compute all_traits_impls during resolution.Camille GILLOT-4/+0
2021-09-01Compute item_generics_num_lifetimes during resolution.Camille GILLOT-43/+4
2021-09-01Stop sorting bodies by span.Camille GILLOT-10/+0
The definition order is already close to the span order, and only differs in corner cases.
2021-09-01Auto merge of #87688 - camsteffen:let-else, r=cjgillotbors-95/+2
Introduce `let...else` Tracking issue: #87335 The trickiest part for me was enforcing the diverging else block with clear diagnostics. Perhaps the obvious solution is to expand to `let _: ! = ..`, but I decided against this because, when a "mismatched type" error is found in typeck, there is no way to trace where in the HIR the expected type originated, AFAICT. In order to pass down this information, I believe we should introduce `Expectation::LetElseNever(HirId)` or maybe add `HirId` to `Expectation::HasType`, but I left that as a future enhancement. For now, I simply assert that the block is `!` with a custom `ObligationCauseCode`, and I think this is clear enough, at least to start. The downside here is that the error points at the entire block rather than the specific expression with the wrong type. I left a todo to this effect. Overall, I believe this PR is feature-complete with regard to the RFC.
2021-08-31Lint Abi in ast validation.Camille GILLOT-24/+2
2021-08-30Move some methods to block moduleCameron Steffen-95/+2
2021-08-30Add let-else to ASTCameron Steffen-1/+1
2021-08-30Remove unused arena macro argsbjorn3-1/+1
2021-08-29ast_lowering: Introduce `lower_span` for catching all spans entering HIRVadim Petrochenkov-65/+102
2021-08-28Treat macros as HIR itemsinquisitivecrystal-10/+0
2021-08-27Introduce `~const`Deadbeef-1/+1
- [x] Removed `?const` and change uses of `?const` - [x] Added `~const` to the AST. It is gated behind const_trait_impl. - [x] Validate `~const` in ast_validation. - [ ] Add enum `BoundConstness` to the HIR. (With variants `NotConst` and `ConstIfConst` allowing future extensions) - [ ] Adjust trait selection and pre-existing code to use `BoundConstness`. - [ ] Optional steps (*for this PR, obviously*) - [ ] Fix #88155 - [ ] Do something with constness bounds in chalk
2021-08-24Auto merge of #87739 - Aaron1011:remove-used-attrs, r=wesleywiserbors-1/+1
Remove `Session.used_attrs` and move logic to `CheckAttrVisitor` Instead of updating global state to mark attributes as used, we now explicitly emit a warning when an attribute is used in an unsupported position. As a side effect, we are to emit more detailed warning messages (instead of just a generic "unused" message). `Session.check_name` is removed, since its only purpose was to mark the attribute as used. All of the callers are modified to use `Attribute.has_name` Additionally, `AttributeType::AssumedUsed` is removed - an 'assumed used' attribute is implemented by simply not performing any checks in `CheckAttrVisitor` for a particular attribute. We no longer emit unused attribute warnings for the `#[rustc_dummy]` attribute - it's an internal attribute used for tests, so it doesn't mark sense to treat it as 'unused'. With this commit, a large source of global untracked state is removed.
2021-08-22Fix typos “a”→“an”Frank Steffahn-2/+2
2021-08-21Remove `Session.used_attrs` and move logic to `CheckAttrVisitor`Aaron Hill-1/+1
Instead of updating global state to mark attributes as used, we now explicitly emit a warning when an attribute is used in an unsupported position. As a side effect, we are to emit more detailed warning messages (instead of just a generic "unused" message). `Session.check_name` is removed, since its only purpose was to mark the attribute as used. All of the callers are modified to use `Attribute.has_name` Additionally, `AttributeType::AssumedUsed` is removed - an 'assumed used' attribute is implemented by simply not performing any checks in `CheckAttrVisitor` for a particular attribute. We no longer emit unused attribute warnings for the `#[rustc_dummy]` attribute - it's an internal attribute used for tests, so it doesn't mark sense to treat it as 'unused'. With this commit, a large source of global untracked state is removed.
2021-08-15Introduce hir::ExprKind::Let - Take 2Caio-10/+0
2021-07-30Do not discard `?Sized` type params and suggest their removalEsteban Küber-5/+5
2021-07-27Auto merge of #83484 - JulianKnodt:infer, r=oli-obk,lcnrbors-41/+52
Add hir::GenericArg::Infer In order to extend inference to consts, make an Infer type on hir::GenericArg.
2021-07-26Actually infer args in visitorskadmin-3/+7
2021-07-25Introduce OwnerNode::Crate.Camille GILLOT-2/+4
2021-07-25Merge the BTreeMap in hir::Crate.Camille GILLOT-18/+41
2021-07-25Add generic arg inferkadmin-40/+47
2021-07-19Improve impl trait disallowed context error textSantiago Pastorino-1/+1
2021-07-18Remove impl_trait_in_bindings feature flagSantiago Pastorino-7/+1
2021-07-18Remove origin field from TypeAliasesOpaqueTySantiago Pastorino-8/+4
2021-07-18Remove OpaqueTyOrigin::Misc, use TyAlias insteadSantiago Pastorino-2/+2
2021-07-17Remove impl traits bindings error message handling on AST loweringSantiago Pastorino-6/+1
2021-07-17Fix TypeAliasesOpaqueTy origin docsSantiago Pastorino-1/+1
2021-07-17Rename OtherOpaqueTy to TypeAliasesOpaqueTySantiago Pastorino-9/+13
2021-07-17Remove OpaqueTyOrigin::BindingSantiago Pastorino-16/+5
2021-07-15Remove refs from pat slicesCameron Steffen-9/+18
2021-07-13Cache expansion hash.Camille GILLOT-3/+43
2021-06-30Arena-allocate Crate during lowering.Camille GILLOT-4/+5
2021-06-15Auto merge of #86321 - JohnTitor:rollup-q61c8q4, r=JohnTitorbors-1/+1
Rollup of 10 pull requests Successful merges: - #80269 (Explain non-dropped sender recv in docs) - #82179 (Add functions `Duration::try_from_secs_{f32, f64}`) - #85608 (Stabilize `ops::ControlFlow` (just the type)) - #85792 (Refactor windows sockets impl methods) - #86220 (Improve maybe_uninit_extra docs) - #86277 (Remove must_use from ALLOWED_ATTRIBUTES) - #86285 (:arrow_up: rust-analyzer) - #86294 (Stabilize {std, core}::prelude::rust_*.) - #86306 (Add mailmap entries for myself) - #86314 (Remove trailing triple backticks in `mut_keyword` docs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-06-15Rollup merge of #85608 - scottmcm:stabilize-control-flow-enum-basics, r=m-ou-seYuki Okushi-1/+1
Stabilize `ops::ControlFlow` (just the type) Tracking issue: https://github.com/rust-lang/rust/issues/75744 (which also tracks items *not* closed by this PR). With the new `?` desugar implemented, [it's no longer possible to mix `Result` and `ControlFlow`](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=13feec97f5c96a9d791d97f7de2d49a6). (At the time of making this PR, godbolt was still on the 2021-05-01 nightly, where you can see that [the mixing example compiled](https://rust.godbolt.org/z/13Ke54j16).) That resolves the only blocker I know of, so I'd like to propose that `ControlFlow` be considered for stabilization. Its basic existence was part of https://github.com/rust-lang/rfcs/pull/3058, where it got a bunch of positive comments (examples [1](https://github.com/rust-lang/rfcs/pull/3058#issuecomment-758277325) [2](https://github.com/rust-lang/rfcs/pull/3058#pullrequestreview-592106494) [3](https://github.com/rust-lang/rfcs/pull/3058#issuecomment-784444155) [4](https://github.com/rust-lang/rfcs/pull/3058#issuecomment-797031584)). Its use in the compiler has been well received (https://github.com/rust-lang/rust/pull/78182#issuecomment-713695594), and there are ecosystem updates interested in using it (https://github.com/rust-itertools/itertools/issues/469#issuecomment-677729589, https://github.com/jonhoo/rust-imap/issues/194). As this will need an FCP, picking a libs member manually: r? `@m-ou-se` ## Stabilized APIs ```rust #[derive(Debug, Clone, Copy, PartialEq)] pub enum ControlFlow<B, C = ()> { /// Exit the operation without running subsequent phases. Break(B), /// Move on to the next phase of the operation as normal. Continue(C), } ``` As well as using `?` on a `ControlFlow<B, _>` in a function returning `ControlFlow<B, _>`. (Note, in particular, that there's no `From::from`-conversion on the `Break` value, the way there is for `Err`s.) ## Existing APIs *not* stabilized here All the associated methods and constants: `break_value`, `is_continue`, `map_break`, [`CONTINUE`](https://doc.rust-lang.org/nightly/std/ops/enum.ControlFlow.html#associatedconstant.CONTINUE), etc. Some of the existing methods in nightly seem reasonable, some seem like they should be removed, and some need more discussion to decide. But none of them are *essential*, so [as in the RFC](https://rust-lang.github.io/rfcs/3058-try-trait-v2.html#methods-on-controlflow), they're all omitted from this PR. They can be considered separately later, as further usage demonstrates which are important.
2021-06-14Use the now available implementation of `IntoIterator` for arraysLeSeulArtichaut-1/+1
2021-06-01Rename take_trait_map.Camille GILLOT-2/+2
2021-06-01Remove StableVec.Camille GILLOT-2/+1
2021-06-01Only compute the trait_map once.Camille GILLOT-10/+10
2021-06-01Revert "Reduce the amount of untracked state in TyCtxt"Camille Gillot-9/+10
2021-05-30Rename take_trait_map.Camille GILLOT-2/+2
2021-05-30Remove StableVec.Camille GILLOT-2/+1
2021-05-30Only compute the trait_map once.Camille GILLOT-10/+10
2021-05-24remove cfg(bootstrap)Pietro Albini-1/+0
2021-05-23Stabilize ops::ControlFlow (just the type)Scott McMurray-1/+1
2021-05-18Auto merge of #84767 - scottmcm:try_trait_actual, r=lcnrbors-5/+5
Implement the new desugaring from `try_trait_v2` ~~Currently blocked on https://github.com/rust-lang/rust/issues/84782, which has a PR in https://github.com/rust-lang/rust/pull/84811~~ Rebased atop that fix. `try_trait_v2` tracking issue: https://github.com/rust-lang/rust/issues/84277 Unfortunately this is already touching a ton of things, so if you have suggestions for good ways to split it up, I'd be happy to hear them. (The combination between the use in the library, the compiler changes, the corresponding diagnostic differences, even MIR tests mean that I don't really have a great plan for it other than trying to have decently-readable commits. r? `@ghost` ~~(This probably shouldn't go in during the last week before the fork anyway.)~~ Fork happened.
2021-05-16Implement Anonymous{Struct, Union} in the ASTjedel1043-0/+9
Add unnamed_fields feature gate and gate unnamed fields on parsing