summary refs log tree commit diff
path: root/compiler/rustc_hir/src
AgeCommit message (Collapse)AuthorLines
2021-11-23Add generator lang-itemMichael Goulet-0/+1
2021-11-21Simplify for loop desugarCameron Steffen-2/+11
2021-11-19Rollup merge of #90990 - nnethercote:arenas-cleanup, r=oli-obkYuki Okushi-38/+38
Arenas cleanup I was looking closely at the arenas code and here are some small improvement to readability.
2021-11-19Add some comments.Nicholas Nethercote-1/+1
Also use `Default::default()` in one `TypedArena::default()`, for consistency with `DroplessArena::default()`.
2021-11-18rustc: Remove `#[rustc_synthetic]`Vadim Petrochenkov-11/+1
This function parameter attribute was introduced in https://github.com/rust-lang/rust/pull/44866 as an intermediate step in implementing `impl Trait`, it's not necessary or used anywhere by itself.
2021-11-17Remove unnecessary lifetime argument from arena macros.Nicholas Nethercote-37/+37
Because it's always `'tcx`. In fact, some of them use a mixture of passed-in `$tcx` and hard-coded `'tcx`, so no other lifetime would even work. This makes the code easier to read.
2021-11-16Auto merge of #90919 - nnethercote:rm-DropArena, r=Mark-Simulacrumbors-10/+5
Remove `DropArena`. Most arena-allocate types that impl `Drop` get their own `TypedArena`, but a few infrequently used ones share a `DropArena`. This sharing adds complexity but doesn't help performance or memory usage. Perhaps it was more effective in the past prior to some other improvements to arenas. This commit removes `DropArena` and the sharing of arenas via the `few` attribute of the `arena_types` macro. This change removes over 100 lines of code and nine uses of `unsafe` (one of which affects the parallel compiler) and makes the remaining code easier to read.
2021-11-15refactor is_param_boundTaylor Yu-0/+16
2021-11-15Remove `DropArena`.Nicholas Nethercote-10/+5
Most arena-allocate types that impl `Drop` get their own `TypedArena`, but a few infrequently used ones share a `DropArena`. This sharing adds complexity but doesn't help performance or memory usage. Perhaps it was more effective in the past prior to some other improvements to arenas. This commit removes `DropArena` and the sharing of arenas via the `few` attribute of the `arena_types` macro. This change removes over 100 lines of code and nine uses of `unsafe` (one of which affects the parallel compiler) and makes the remaining code easier to read.
2021-11-07Give inline const separate DefKindGary Guo-1/+6
2021-11-01Auto merge of #90406 - nbdd0121:panic, r=cjgillotbors-2/+2
Collect `panic/panic_bounds_check` during monomorphization This would prevent link time errors if these functions are `#[inline]` (e.g. when `panic_immediate_abort` is used). Fix #90405 Fix rust-lang/cargo#10019 `@rustbot` label: T-compiler A-codegen
2021-10-31Remove `rustc_hir::hir_id::HirIdVec`pierwill-68/+0
2021-10-31Require `panic` and `panic_bounds_check` to be non-genericGary Guo-2/+2
2021-10-21Use SortedMap in HIR.Camille GILLOT-4/+4
2021-10-21Rollup merge of #90071 - cjgillot:no-blocks, r=oli-obkYuki Okushi-0/+35
Remove hir::map::blocks and use FnKind instead The principal tool is `FnLikeNode`, which is not often used and can be easily implemented using `rustc_hir::intravisit::FnKind`.
2021-10-19Replace FnLikeNode by FnKind.Camille GILLOT-0/+35
2021-10-20Rollup merge of #88860 - nbdd0121:panic, r=m-ou-seYuki Okushi-1/+0
Deduplicate panic_fmt std's begin_panic_fmt and core's panic_fmt are duplicates. Merge them to declutter code and remove a lang item.
2021-10-19Deduplicate panic_fmtGary Guo-1/+0
std's begin_panic_fmt and core's panic_fmt are duplicates. Merge them to declutter code and remove a lang item.
2021-10-18Auto merge of #89124 - cjgillot:owner-info, r=michaelwoeristerbors-36/+135
Index and hash HIR as part of lowering Part of https://github.com/rust-lang/rust/pull/88186 ~Based on https://github.com/rust-lang/rust/pull/88880 (see merge commit).~ Once HIR is lowered, it is later indexed by the `index_hir` query and hashed for `crate_hash`. This PR moves those post-processing steps to lowering itself. As a side objective, the HIR crate data structure is refactored as an `IndexVec<LocalDefId, Option<OwnerInfo<'hir>>>` where `OwnerInfo` stores all the relevant information for an HIR owner. r? `@michaelwoerister` cc `@petrochenkov`
2021-10-17rustc_span: `Ident::invalid` -> `Ident::empty`Vadim Petrochenkov-3/+3
The equivalent for `Symbol`s was renamed some time ago (`kw::Invalid` -> `kw::Empty`), and it makes sense to do the same thing for `Ident`s.
2021-10-14Document structs.Camille GILLOT-1/+5
2021-10-14Auto merge of #89247 - fee1-dead:const-eval-select, r=oli-obkbors-0/+2
Add `const_eval_select` intrinsic Adds an intrinsic that calls a given function when evaluated at compiler time, but generates a call to another function when called at runtime. See https://github.com/rust-lang/const-eval/issues/7 for previous discussion. r? `@oli-obk.`
2021-10-13Re-use logic for adding a suggestion when a lifetime bound is missing on an ↵Oli Scherer-2/+1
impl trait
2021-10-12Use invalid local id for zeroth node parent.Camille GILLOT-1/+7
2021-10-12Add const_eval_select intrinsicDeadbeef-0/+2
2021-10-11Remove unused function.Camille GILLOT-6/+0
2021-10-11Make naming more explicit.Camille GILLOT-5/+6
2021-10-10Compute full HIR hash during lowering.Camille GILLOT-3/+18
2021-10-10Directly use AttributeMap inside OwnerInfo.Camille GILLOT-4/+31
2021-10-09Perform indexing during lowering.Camille GILLOT-42/+73
Do not access DefId<->HirId maps before they are initialized.
2021-10-09Make index_hir incremental.Camille GILLOT-0/+6
2021-10-09Hash during lowering.Camille GILLOT-0/+5
2021-10-09Use an IndexVec for bodies.Camille GILLOT-3/+4
2021-10-09Store lowering outputs per owner.Camille GILLOT-15/+24
2021-10-09Rollup merge of #89641 - asquared31415:asm-feature-attr-regs, r=oli-obkMatthias Krüger-0/+7
make #[target_feature] work with `asm` register classes Fixes #89289
2021-10-07make #[target_feature] work with `asm` register classesasquared31415-0/+7
2021-10-06Introduce get_diagnostic_nameCameron Steffen-0/+18
2021-10-03Move some HashStable impls.Camille GILLOT-0/+19
2021-10-01Auto merge of #88880 - cjgillot:no-krate, r=oli-obkbors-48/+1
Rework HIR API to make invocations of the hir_crate query harder. `hir_crate` forces the recomputation of queries that depend on it. This PR aims at avoiding useless invocations of `hir_crate` by making dependent code go through `tcx.hir()`.
2021-10-01Rollup merge of #89029 - notriddle:notriddle/issue-89013, r=estebankManish Goregaokar-0/+10
feat(rustc_parse): recover from pre-RFC-2000 const generics syntax Fixes #89013
2021-09-30Rollup merge of #88782 - asquared31415:issue-79559, r=cjgillotManish Goregaokar-1/+1
Fix ICE when `start` lang item has wrong generics In my previous pr #87875 I missed the requirements on the `start` lang item due to its relative difficulty to test and opting for more conservative estimates. This fixes that by updating the requirement to be exactly one generic type. The `start` lang item should have exactly one generic type for the return type of the `main` fn ptr passed to it. I believe having zero would previously *sometimes* compile (often with the use of `fn() -> ()` as the fn ptr but it was likely UB to call if the return type of `main` was not `()` as far as I know) however it also sometimes would not for various errors including ICEs and LLVM errors depending on exact situations. Having more than 1 generic has always failed with an ICE because only the one generic type is expected and provided. Fixes #79559, fixes #73584, fixes #83117 (all duplicates) Relevant to #9307 r? ````@cjgillot````
2021-09-30Apply suggestions from code reviewCamille Gillot-1/+1
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2021-09-29Avoid more invocations of hir_crate query.Camille GILLOT-49/+2
2021-09-28feat(rustc_typeck): avoid erroring with "wrong number of generics" if ↵Michael Howell-0/+10
there's other problems As shown in the two test requirements that got updated, if there's other problems, then those other problems are probably the root cause of the incorrect generics count.
2021-09-20Do not store visibility in *ItemRef.Camille GILLOT-16/+12
2021-09-19Auto merge of #88703 - cjgillot:lazymod, r=petrochenkovbors-15/+1
Gather module items after lowering. This avoids having a non-local analysis inside lowering. By implementing `hir_module_items` using a visitor, we make sure that iterations and visitors are consistent.
2021-09-18Auto merge of #82183 - michaelwoerister:lazier-defpathhash-loading2, ↵bors-6/+54
r=wesleywiser Simplify lazy DefPathHash decoding by using an on-disk hash table. This PR simplifies the logic around mapping `DefPathHash` values encountered during incremental compilation to valid `DefId`s in the current session. It is able to do so by using an on-disk hash table encoding that allows for looking up values directly, i.e. without deserializing the entire table. The main simplification comes from not having to keep track of `DefPathHashes` being used during the compilation session.
2021-09-17Rollup merge of #88954 - nbdd0121:panic3, r=oli-obkGuillaume Gomez-0/+1
Allow `panic!("{}", computed_str)` in const fn. Special-case `panic!("{}", arg)` and translate it to `panic_display(&arg)`. `panic_display` will behave like `panic_any` in cosnt eval and behave like `panic!(format_args!("{}", arg))` in runtime. This should bring Rust 2015 and 2021 to feature parity in terms of `const_panic`; and hopefully would unblock the stabilisation of #51999. `@rustbot` modify labels: +T-compiler +T-libs +A-const-eval +A-const-fn r? `@oli-obk`
2021-09-15Allow `panic!("{}", computed_str)` in const fn.Gary Guo-0/+1
2021-09-15Auto merge of #88558 - fee1-dead:const-drop, r=oli-obkbors-7/+1
Const drop The changes are pretty primitive at this point. But at least it works. ^-^ Problems with the current change that I can think of now: - [x] `~const Drop` shouldn't change anything in the non-const world. - [x] types that do not have drop glues shouldn't fail to satisfy `~const Drop` in const contexts. `struct S { a: u8, b: u16 }` This might not fail for `needs_non_const_drop`, but it will fail in `rustc_trait_selection`. - [x] The current change accepts types that have `const Drop` impls but have non-const `Drop` glue. Fixes #88424. Significant Changes: - `~const Drop` is no longer treated as a normal trait bound. In non-const contexts, this bound has no effect, but in const contexts, this restricts the input type and all of its transitive fields to either a) have a `const Drop` impl or b) can be trivially dropped (i.e. no drop glue) - `T: ~const Drop` will not be linted like `T: Drop`. - Instead of recursing and iterating through the type in `rustc_mir::transform::check_consts`, we use the trait system to special case `~const Drop`. See [`rustc_trait_selection::...::candidate_assembly#assemble_const_drop_candidates`](https://github.com/fee1-dead/rust/blob/const-drop/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs#L817) and others. Changes not related to `const Drop`ping and/or changes that are insignificant: - `Node.constness_for_typeck` no longer returns `hir::Constness::Const` for type aliases in traits. This was previously used to hack how we determine default bound constness for items. But because we now use an explicit opt-in, it is no longer needed. - Removed `is_const_impl_raw` query. We have `impl_constness`, and the only existing use of that query uses `HirId`, which means we can just operate it with hir. - `ty::Destructor` now has a field `constness`, which represents the constness of the destructor. r? `@oli-obk`