about summary refs log tree commit diff
path: root/compiler/rustc_hir
AgeCommit message (Collapse)AuthorLines
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-21Auto merge of #89103 - Mark-Simulacrum:migrate-2021, r=estebankbors-1/+1
Migrate in-tree crates to 2021 This replaces #89075 (cherry picking some of the commits from there), and closes #88637 and fixes #89074. It excludes a migration of the library crates for now (see tidy diff) because we have some pending bugs around macro spans to fix there. I instrumented bootstrap during the migration to make sure all crates moved from 2018 to 2021 had the compatibility warnings applied first. Originally, the intent was to support cargo fix --edition within bootstrap, but this proved fairly difficult to pull off. We'd need to architect the check functionality to support running cargo check and cargo fix within the same x.py invocation, and only resetting sysroots on check. Further, it was found that cargo fix doesn't behave too well with "not quite workspaces", such as Clippy which has several crates. Bootstrap runs with --manifest-path ... for all the tools, and this makes cargo fix only attempt migration for that crate. We can't use e.g. --workspace due to needing to maintain sysroots for different phases of compilation appropriately. It is recommended to skip the mass migration of Cargo.toml's to 2021 for review purposes; you can also use `git diff d6cd2c6c877110748296760aefddc21a0ea1d316 -I'^edition = .20...$'` to ignore the edition = 2018/21 lines in the diff.
2021-09-21Auto merge of #87234 - cjgillot:lower-mono, r=petrochenkovbors-16/+12
Lower only one HIR owner at a time Based on https://github.com/rust-lang/rust/pull/83723 Additional diff is here: https://github.com/cjgillot/rust/compare/ownernode...lower-mono Lowering is very tangled and has a tendency to intertwine the transformation of different items. This PR aims at simplifying the logic by: - moving global analyses to the resolver (item_generics_num_lifetimes, proc_macros, trait_impls); - removing a few special cases (non-exported macros and use statements); - restricting the amount of available information at any one time; - avoiding back-and-forth between different owners: an item must now be lowered all at once, and its parent cannot refer to its nodes. I also removed the sorting of bodies by span. The diagnostic ordering changes marginally, since definitions are pretty much sorted already according to the AST. This uncovered a subtlety in thir-unsafeck. (While these items could logically be in different PRs, the dependency between commits and the amount of conflicts force a monolithic PR.)
2021-09-20Migrate to 2021Mark Rousskov-1/+1
2021-09-20Update odht crate to 0.3.0Michael Woerister-1/+1
This version of odht contains a potential fix for #89085.
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/+55
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-17Update odht to 0.2.1Michael Woerister-1/+1
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`
2021-09-14Fix ICE when `start` lang item has wrong genericsasquared31415-1/+1
2021-09-14Make DefPathHash->DefId panic for if the mapping fails.Michael Woerister-1/+2
We only use this mapping for cases where we know that it must succeed. Letting it panic otherwise makes it harder to use the API in unsupported ways.
2021-09-14Use on-disk-hash-table format for DefPathHashMap in hir::definitions.Michael Woerister-5/+53
2021-09-12Gather module items after lowering.Camille GILLOT-15/+1
2021-09-12Rollup merge of #88677 - petrochenkov:exportid, r=davidtwcoManish Goregaokar-0/+5
rustc: Remove local variable IDs from `Export`s Local variables can never be exported.
2021-09-10rustc: Remove local variable IDs from `Export`sVadim Petrochenkov-0/+5
Local variables can never be exported.
2021-09-10Add sanity check.Camille GILLOT-0/+4
We force the relative span's parent to be absolute. This avoids having to handle long dependency chains.
2021-09-10Keep def_spans collected by resolution.Camille GILLOT-1/+19
2021-09-09cleanup hir hackDeadbeef-7/+1
2021-09-07Don't move ?Trait bounds to param bounds if they're in where clausesjackh726-3/+0
2021-09-07Static assert size of GenericBoun to ensure size doesn't changejackh726-0/+3
2021-09-05Auto merge of #88435 - cjgillot:no-walk-crate, r=Aaron1011bors-12/+0
Avoid invoking the hir_crate query to traverse the HIR Walking the HIR tree is done using the `hir_crate` query. However, this is unnecessary, since `hir_owner(CRATE_DEF_ID)` provides the same information. Since depending on `hir_crate` forces dependents to always be executed, this leads to unnecessary work. By splitting HIR and attributes visits, we can avoid an edge to `hir_crate` when trying to visit the HIR tree.
2021-09-03Auto merge of #88572 - matthewjasper:if-let-scoping-fix, r=oli-obkbors-0/+1
Fix drop handling for `if let` expressions MIR lowering for `if let` expressions is now more complicated now that `if let` exists in HIR. This PR adds a scope for the variables bound in an `if let` expression and then uses an approach similar to how we handle loops to ensure that we reliably drop the correct variables. Closes #88307 cc `@flip1995` `@richkadel` `@c410-f3r`
2021-09-02Drop walk_crate_and_attributes.Camille GILLOT-12/+0
2021-09-02Stop using walk_crate.Camille GILLOT-1/+1
2021-09-01Fix drop handling for `if let` expressionsMatthew Jasper-0/+1
MIR lowering for `if let` expressions is now more complicated now that `if let` exists in HIR. This PR adds a scope for the variables bound in an `if let` expression and then uses an approach similar to how we handle loops to ensure that we reliably drop the correct variables.
2021-09-01Compute proc_macros in resolutions.Camille GILLOT-3/+0
2021-09-01Compute all_traits_impls during resolution.Camille GILLOT-1/+0
2021-09-01Stop sorting bodies by span.Camille GILLOT-6/+0
The definition order is already close to the span order, and only differs in corner cases.
2021-08-31Rollup merge of #88486 - bjorn3:better_arena_macro, r=jackh726Mara Bos-2/+2
Remove unused arena macro args
2021-08-30Remove unused arena macro argsbjorn3-2/+2
2021-08-30remove lazy_normalization_constsEllen-1/+1
2021-08-28Remove obsolete `MacroDef` variant of `OwnerNode`inquisitivecrystal-27/+5
2021-08-28Treat macros as HIR itemsinquisitivecrystal-55/+10
2021-08-26Rollup merge of #88123 - camelid:tup-pat-precise-spans, r=estebankManish Goregaokar-2/+33
Make spans for tuple patterns in E0023 more precise As suggested in #86307. Closes #86307. r? ````@estebank````
2021-08-25Rollup merge of #88196 - asquared31415:named-asm-labels-refactor, r=AmanieuLéo Lanteri Thauvin-0/+1
Refactor `named_asm_labels` to a HIR lint As discussed on #88169, the `named_asm_labels` lint could be moved to a HIR lint. That allows future lints or custom plugins or clippy lints to more easily access the `asm!` macro's data and create better error messages with the lints.
2021-08-25Auto merge of #87875 - asquared31415:generic-lang-items, r=cjgillotbors-151/+163
Improve detection of generics on lang items Adds detection for the required generics for all lang items. Many lang items require an exact or minimum amount of generic arguments and if they don't exist, the compiler will ICE. This does not add any additional validation about bounds on generics or any other lang item restrictions. Fixes one of the ICEs in #87573 cc `@FabianWolff`
2021-08-24Move `named_asm_labels` to a HIR lintasquared31415-0/+1
2021-08-23Detect incorrect number of lang item genericsasquared31415-151/+163