about summary refs log tree commit diff
path: root/compiler/rustc_hir
AgeCommit message (Collapse)AuthorLines
2023-03-31Auto merge of #109010 - compiler-errors:rtn, r=eholkbors-3/+19
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-31Auto merge of #98112 - saethlin:mir-alignment-checks, r=oli-obkbors-0/+1
Insert alignment checks for pointer dereferences when debug assertions are enabled Closes https://github.com/rust-lang/rust/issues/54915 - [x] Jake tells me this sounds like a place to use `MirPatch`, but I can't figure out how to insert a new basic block with a new terminator in the middle of an existing basic block, using `MirPatch`. (if nobody else backs up this point I'm checking this as "not actually a good idea" because the code looks pretty clean to me after rearranging it a bit) - [x] Using `CastKind::PointerExposeAddress` is definitely wrong, we don't want to expose. Calling a function to get the pointer address seems quite excessive. ~I'll see if I can add a new `CastKind`.~ `CastKind::Transmute` to the rescue! - [x] Implement a more helpful panic message like slice bounds checking. r? `@oli-obk`
2023-03-29Properly skip RPITITs from ModChild and give a name in AssocItemSantiago Pastorino-5/+1
2023-03-28Add `(..)` syntax for RTNMichael Goulet-3/+19
2023-03-27Add a builtin `FnPtr` traitlcnr-0/+3
2023-03-23A MIR transform that checks pointers are alignedBen Kimock-0/+1
2023-03-23Rollup merge of #109179 - llogiq:intrinsically-option-as-slice, r=eholkDylan DPC-0/+1
move Option::as_slice to intrinsic ````@scottmcm```` suggested on #109095 I use a direct approach of unpacking the operation in MIR lowering, so here's the implementation. cc ````@nikic```` as this should hopefully unblock #107224 (though perhaps other changes to the prior implementation, which I left for bootstrapping, are needed).
2023-03-21Use local key in providersMichael Goulet-0/+6
2023-03-18move Option::as_slice to intrinsicAndre Bogus-0/+1
2023-03-17Rollup merge of #108958 - clubby789:unbox-the-hir, r=compiler-errorsMatthias Krüger-8/+1
Remove box expressions from HIR After #108516, `#[rustc_box]` is used at HIR->THIR lowering and this is no longer emitted, so it can be removed. This is based on top of #108471 to help with conflicts, so 43490488ccacd1a822e9c621f5ed6fca99959a0b is the only relevant commit (sorry for all the duplicated pings!) ````@rustbot```` label +S-blocked
2023-03-14Remove box expressions from HIRclubby789-8/+1
2023-03-14Rollup merge of #108923 - spastorino:new-rpitit-9, r=compiler-errorsMatthias Krüger-1/+5
Make fns from other crates with RPITIT work for -Zlower-impl-trait-in-trait-to-assoc-ty Only the last two commits are meaningful. r? `@compiler-errors`
2023-03-14Make fns from other crates with RPITIT workSantiago Pastorino-1/+5
2023-03-14Auto merge of #104833 - Swatinem:async-identity-future, r=compiler-errorsbors-1/+0
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-08Remove `identity_future` indirectionArpad Borsos-1/+0
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-18/+17
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-02-28Only look for param in generics if it actually comes from genericsMichael Goulet-0/+15
2023-02-26Rollup merge of #108484 - ↵Matthias Krüger-2/+0
Nilstrieb:˂DiagnosticItem˂FromFn˃ as From˂˂LangItemFromFn˃˃˃꞉꞉from, r=cjgillot Remove `from` lang item It was probably a leftover from the old `?` desugaring but anyways, it's unused now except for clippy, which can just use a diagnostics item.
2023-02-26Remove `from_fn` lang itemNilstrieb-2/+0
It was probably a leftover from the old `?` desugaring but anyways, it's unused now except for clippy, which can just use a diagnostics item.
2023-02-25Add ErrorGuaranteed to HIR ExprKind::ErrMichael Goulet-5/+5
2023-02-25Add ErrorGuaranteed to HIR TyKind::ErrMichael Goulet-4/+4
2023-02-22diagnostics: if AssocFn has self argument, describe as methodMichael Howell-0/+9
Discussed in https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.22associated.20function.22.20vs.20.22method.22/near/329265515 This commit also changes the tooltips on rustdoc intra-doc links targeting methods.
2023-02-21Rollup merge of #108141 - spastorino:add_rpitit_queries, r=compiler-errorsDylan DPC-2/+4
Add rpitit queries This is part of the changes we are making to lower RPITITs as an associated type. The rest of the stuff will follow under a `-Z` flag. I still need to add comments to the code, explain stuff and also I'd need to avoid encoding in metadata when rpitit queries return `&[]` r? `@compiler-errors`
2023-02-20Rollup merge of #108255 - fee1-dead-contrib:fix-old-fixme, r=cjgillotMatthias Krüger-2/+0
Remove old FIXMEs referring to #19596 Having an inner function that accepts a mutable reference seems to be the only way this can be expressed. Taking a mutable reference would call the same function with a new type &mut F which then causes the infinite recursion error in #19596.
2023-02-20Remove old FIXMEs referring to #19596Deadbeef-2/+0
2023-02-19Add associated_items_for_impl_trait_in_trait querySantiago Pastorino-2/+4
2023-02-16`if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)`Maybe Waffle-7/+4
2023-02-14Add `of_trait` to DefKind::Impl.Camille GILLOT-6/+8
2023-02-13rustc_resolve: Remove `Resolver::clone_output`Vadim Petrochenkov-2/+2
And remove `Clone` impls and `Lrc`s that are no longer necessary
2023-02-10Resolve documentation links in rustc and store the results in metadataVadim Petrochenkov-1/+15
This commit implements MCP https://github.com/rust-lang/compiler-team/issues/584 It also removes code that is no longer used, and that includes code cloning resolver, so issue #83761 is fixed.
2023-02-07Rename PointerSized to PointerLikeMichael Goulet-1/+1
2023-01-30Rollup merge of #107125 - ↵Matthias Krüger-3/+360
WaffleLapkin:expect_an_item_in_your_hir_by_the_next_morning, r=Nilstrieb Add and use expect methods to hir. [The future has come](https://github.com/rust-lang/rust/pull/106090/files#r1070062462). r? `@Nilstrieb` tbh I'm not even sure if it's worth it
2023-01-30fix `TraitItemKind::expect_type` docsMaybe Waffle-1/+1
2023-01-30Improve ICE messages for `*::expect_*`Maybe Waffle-49/+69
2023-01-28Remove `HirId -> LocalDefId` map from HIR.Camille GILLOT-10/+2
2023-01-28Take a LocalDefId in hir::Visitor::visit_fn.Camille GILLOT-21/+27
2023-01-27Impl HashStable/Encodable/Decodable for ObligationCause.Camille GILLOT-2/+2
2023-01-26Auto merge of #106745 - m-ou-se:format-args-ast, r=oli-obkbors-0/+11
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-23Add hint for missing lifetime bound on trait object when type alias is usedyanchen4791-0/+7
2023-01-20Add and use expect methods to hir.Maybe Waffle-3/+340
2023-01-19Rollup merge of #106927 - Ezrashaw:e0606-make-machine-applicable, r=estebankGuillaume Gomez-0/+8
make `CastError::NeedsDeref` create a `MachineApplicable` suggestion Fixes #106903 Simple impl for the linked issue. I also made some other small changes: - `CastError::ErrorGuaranteed` now owns an actual `ErrorGuaranteed`. This better enforces the static guarantees of `ErrorGuaranteed`. - `CastError::NeedDeref` code simplified a bit, we now just suggest the `*`, instead of the whole expression as well.
2023-01-19Transform async ResumeTy in generator transformArpad Borsos-0/+1
- Eliminates all the `get_context` calls that async lowering created. - Replace all `Local` `ResumeTy` types with `&mut Context<'_>`. The `Local`s that have their types replaced are: - The `resume` argument itself. - The argument to `get_context`. - The yielded value of a `yield`. The `ResumeTy` hides a `&mut Context<'_>` behind an unsafe raw pointer, and the `get_context` function is being used to convert that back to a `&mut Context<'_>`. Ideally the async lowering would not use the `ResumeTy`/`get_context` indirection, but rather directly use `&mut Context<'_>`, however that would currently lead to higher-kinded lifetime errors. See <https://github.com/rust-lang/rust/issues/105501>. The async lowering step and the type / lifetime inference / checking are still using the `ResumeTy` indirection for the time being, and that indirection is removed here. After this transform, the generator body only knows about `&mut Context<'_>`.
2023-01-18special case removing `&` suggestionEzra Shaw-0/+8
2023-01-17Remove double spaces after dots in commentsMaybe Waffle-3/+3
2023-01-12parse const closuresDeadbeef-0/+2
2023-01-12Expand format_args!() in rust_ast_lowering.Mara Bos-0/+3
2023-01-11Turn format arguments types into lang items.Mara Bos-0/+8
2023-01-11fix typo LocalItemId -> ItemLocalIdklensy-2/+2
2023-01-05Fix `uninlined_format_args` for some compiler cratesnils-9/+7
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-04get_parent and find_parentMichael Goulet-1/+1