summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2022-08-15Revert let_chains stabilizationNilstrieb-1/+1
This reverts commit 326646074940222d602f3683d0559088690830f4. It was discovered that they are not implemented correctly, which does not make them ready for stabilization.
2022-08-05Auto merge of #99867 - spastorino:refactor-remap-lifetimes, r=nikomatsakisbors-0/+5
Split create_def and lowering of lifetimes for opaque types and bare async fns r? `@cjgillot` This work is kind of half-way, but I think it could be merged anyway. I think we should be able to remove all the vacant arms in `new_named_lifetime_with_res`, if I'm not wrong that requires visiting more nodes. We can do that as a follow up. In follow-up PRs, besides the thing mentioned previously, I'll be trying to remove `LifetimeCaptureContext`, `captured_lifetimes` as a global data structure, global `binders_to_ignore` and all their friends :). Also try to remap in a more general way based on def-ids.
2022-08-04Rollup merge of #100095 - jackh726:early-binder, r=lcnrMatthias Krüger-3/+27
More EarlyBinder cleanups Each commit is independent r? types
2022-08-04Document generics_def_id_map field and record/get methods on itSantiago Pastorino-1/+4
2022-08-04Implement def_id based remappingSantiago Pastorino-0/+2
2022-08-03Add bound_impl_subject and bound_return_tyJack Huey-0/+10
2022-08-03Change sized_constraints to return EarlyBinderJack Huey-3/+3
2022-08-02Add bound_predicates_of and bound_explicit_predicates_ofJack Huey-0/+14
2022-08-02Avoid invalidating the CFG in MirPatch.Jakob Degen-35/+30
As a part of this change, we adjust MirPatch to not needlessly create unnecessary resume blocks.
2022-08-02Auto merge of #92268 - jswrenn:transmute, r=oli-obkbors-1/+94
Initial implementation of transmutability trait. *T'was the night before Christmas and all through the codebase, not a miri was stirring — no hint of `unsafe`!* This PR provides an initial, **incomplete** implementation of *[MCP 411: Lang Item for Transmutability](https://github.com/rust-lang/compiler-team/issues/411)*. The `core::mem::BikeshedIntrinsicFrom` trait provided by this PR is implemented on-the-fly by the compiler for types `Src` and `Dst` when the bits of all possible values of type `Src` are safely reinterpretable as a value of type `Dst`. What this PR provides is: - [x] [support for transmutations involving primitives](https://github.com/jswrenn/rust/tree/transmute/src/test/ui/transmutability/primitives) - [x] [support for transmutations involving arrays](https://github.com/jswrenn/rust/tree/transmute/src/test/ui/transmutability/arrays) - [x] [support for transmutations involving structs](https://github.com/jswrenn/rust/tree/transmute/src/test/ui/transmutability/structs) - [x] [support for transmutations involving enums](https://github.com/jswrenn/rust/tree/transmute/src/test/ui/transmutability/enums) - [x] [support for transmutations involving unions](https://github.com/jswrenn/rust/tree/transmute/src/test/ui/transmutability/unions) - [x] [support for weaker validity checks](https://github.com/jswrenn/rust/blob/transmute/src/test/ui/transmutability/unions/should_permit_intersecting_if_validity_is_assumed.rs) (i.e., `Assume::VALIDITY`) - [x] visibility checking What isn't yet implemented: - [ ] transmutability options passed using the `Assume` struct - [ ] [support for references](https://github.com/jswrenn/rust/blob/transmute/src/test/ui/transmutability/references.rs) - [ ] smarter error messages These features will be implemented in future PRs.
2022-08-02Auto merge of #100032 - BoxyUwU:no_ty_in_placeholder_const, r=compiler-errorsbors-4/+4
make `PlaceholderConst` not store the type of the const Currently the `Placeholder` variant on `ConstKind` is 28 bytes when with this PR its 8 bytes, i am not sure this is really useful at all rn since `Unevaluated` and `Value` variants are huge still but eventually it should be possible to get both down to 16 bytes :thinking:. Mostly opening this to see if this change has any perf impact when done before it can make `ConstKind`/`ConstS` smaller
2022-08-01Remove trait_of_item query.Camille GILLOT-9/+20
2022-08-01Remove DefId from AssocItemContainer.Camille GILLOT-41/+34
2022-08-01Remove visibility from AssocItem.Camille GILLOT-1/+5
2022-08-01Store associated item defaultness in impl_defaultness.Camille GILLOT-4/+8
2022-08-01Rollup merge of #100003 - nnethercote:improve-size-assertions, r=lqdMatthias Krüger-21/+23
Improve size assertions. - For any file with four or more size assertions, move them into a separate module (as is already done for `hir.rs`). - Add some more for AST nodes and THIR nodes. - Put the `hir.rs` ones in alphabetical order. r? `@lqd`
2022-08-01Rollup merge of #99340 - GoldsteinE:fix-localdefid-debug-ice, r=lcnrMatthias Krüger-2/+2
Fix ICE in Definitions::create_def `Debug` implementation for `LocalDefId` uses global `Definitions`. Normally it’s ok, but we can’t do it while holding a mutable reference to `Definitions`, since it causes ICE or deadlock (depending on whether `parallel_compiler` is enabled). This PR effectively copies the `Debug` implementation into the problematic method. I don’t particularly love this solution (since it creates code duplication), but I don’t see any other options. This issue was discovered when running `rustdoc` with `RUSTDOC_LOG=trace` on the following file: ```rust pub struct SomeStruct; fn asdf() { impl SomeStruct { pub fn qwop(&self) { println!("hidden function"); } } } ``` I’m not sure how to create a test for this behavior.
2022-08-01make `PlaceholderConst` not store the type of the constEllen-4/+4
2022-08-01fix ICE in Definitions::create_defGoldstein-2/+2
2022-08-01Improve size assertions.Nicholas Nethercote-21/+23
- For any file with four or more size assertions, move them into a separate module (as is already done for `hir.rs`). - Add some more for AST nodes and THIR nodes. - Put the `hir.rs` ones in alphabetical order.
2022-07-31Rollup merge of #99973 - RalfJung:layout-things, r=eddybMatthias Krüger-0/+4
Layout things These two commits are pretty independent, but didn't seem worth doing individual PRs for: - Always check that size is a multiple of align, even without debug assertions - Change Layout debug printing to put `variants` last, since it often huge and not usually the part we are most interested in Cc `@eddyb`
2022-07-31Rollup merge of #99186 - camsteffen:closure-localdefid, r=cjgillotDylan DPC-55/+54
Use LocalDefId for closures more
2022-07-31check 'size multiple of align' for all layoutsRalf Jung-0/+4
2022-07-30Auto merge of #99959 - cuviper:niche-size, r=eddybbors-2/+8
Fix the size of niche enums with ZST alignment For enums with an aligned ZST variant, like `[T; 0]`, the niche layout was not computing a sufficient size to be consistent with alignment. Now we pad that size up to the alignment, and also make sure to only use the niche variant's ABI when the size and alignment still match. Fixes #99836 r? `@eddyb`
2022-07-30Use LocalDefId for closures moreCameron Steffen-55/+54
2022-07-30Fix the size of niche enums with ZST alignmentJosh Stone-2/+8
For enums with an aligned ZST variant, like `[T; 0]`, the niche layout was not computing a sufficient size to be consistent with alignment. Now we pad that size up to the alignment, and also make sure to only use the niche variant's ABI when the size and alignment still match.
2022-07-30Rollup merge of #99900 - lcnr:hash-stable-fun, r=cjgillotDylan DPC-89/+10
remove some manual hash stable impls
2022-07-30Rollup merge of #99311 - kckeiks:clean-up-body-owner-methods, r=cjgillotDylan DPC-12/+14
change maybe_body_owned_by to take local def id Issue https://github.com/rust-lang/rust/issues/96341 r? `@cjgillot`
2022-07-29Change enclosing_body_owner to return LocalDefIdMiguel Guarniz-4/+4
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-29Rename local_did to def_idMiguel Guarniz-3/+3
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-29Change maybe_body_owned_by to take local def idMiguel Guarniz-9/+11
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-29Auto merge of #99730 - lcnr:bound-vars-anon, r=jackh726bors-72/+154
anonymize all bound vars, not just regions fixes #98702 r? types
2022-07-29remove some manual hash stable implslcnr-89/+10
2022-07-29optimize bound vars replacement :3lcnr-18/+22
2022-07-28anonymize all bound vars, not just regionslcnr-7/+75
2022-07-28`BoundVarReplacer`: trait object instead of 3 fnslcnr-66/+76
2022-07-28Use line numbers relative to function in mir opt testsNilstrieb-6/+12
This adds a new option, `-Zmir-pretty-relative-line-numbers`, that is then used in compiletest for the mir-opt tests.
2022-07-27safe transmute: revise `Hash`, `PartialEq` impls on `VariantDef`, `FieldDef`Jack Wrenn-12/+61
Exhaustively destructure parameter(s) so that changes to type definitions will lead to compile errors, thus reminding contributors to re-assess the assumptions underpinning these impls. ref: https://github.com/rust-lang/rust/pull/92268/#discussion_r925241377 ref: https://github.com/rust-lang/rust/pull/92268/#discussion_r925241718
2022-07-27Initial (incomplete) implementation of transmutability trait.Jack Wrenn-1/+45
This initial implementation handles transmutations between types with specified layouts, except when references are involved. Co-authored-by: Igor null <m1el.2027@gmail.com>
2022-07-27Rollup merge of #99728 - cjgillot:ast-lifetimes-anon-clean, r=petrochenkovGuillaume Gomez-1/+0
Clean up HIR-based lifetime resolution Based on https://github.com/rust-lang/rust/pull/97313. Fixes #98932. r? `@petrochenkov`
2022-07-27Rollup merge of #99651 - compiler-errors:fn-and-raw-ptr-in-const-generics, ↵Guillaume Gomez-1/+1
r=oli-obk Deeply deny fn and raw ptrs in const generics I think this is right -- just because we wrap a fn ptr in a wrapper type does not mean we should allow it in a const parameter. We now reject both of these in the same way: ``` #![feature(adt_const_params)] #[derive(Eq, PartialEq)] struct Wrapper(); fn foo<const W: Wrapper>() {} fn foo2<const F: fn()>() {} ``` This does regress one test (`src/test/ui/consts/refs_check_const_eq-issue-88384.stderr`), but I'm not sure it should've passed in the first place. cc: ``@b-naber`` who introduced that test^ fixes #99641
2022-07-27Rollup merge of #99358 - compiler-errors:issue-99325, r=oli-obkGuillaume Gomez-21/+15
Allow `ValTree::try_to_raw_bytes` on `u8` array Fixes #99325 cc `@b-naber` I think who touched this last in 705d818bd52a6324d5e7693cc4306457395eebc8
2022-07-27Rollup merge of #99704 - fee1-dead-contrib:add_self_tilde_const_trait, r=oli-obkYuki Okushi-1/+9
Add `Self: ~const Trait` to traits with `#[const_trait]` r? `@oli-obk`
2022-07-26Auto merge of #99574 - durin42:allocator-patch-redux, r=nikicbors-1/+7
codegen: use new {re,de,}allocator annotations in llvm This obviates the patch that teaches LLVM internals about _rust_{re,de}alloc functions by putting annotations directly in the IR for the optimizer. The sole test change is required to anchor FileCheck to the body of the `box_uninitialized` method, so it doesn't see the `allocalign` on `__rust_alloc` and get mad about the string `alloca` showing up. Since I was there anyway, I added some checks on the attributes to prove the right attributes got set. r? `@nikic`
2022-07-26Stop creating anonymous late lifetimes.Camille GILLOT-1/+0
2022-07-26Fix diagnostics for unfulfilled obligationsDeadbeef-0/+8
2022-07-26Add `Self: ~const Trait` to traits with `#[const_trait]`Deadbeef-1/+1
2022-07-26codegen: use new {re,de,}allocator annotations in llvmAugie Fackler-1/+7
This obviates the patch that teaches LLVM internals about _rust_{re,de}alloc functions by putting annotations directly in the IR for the optimizer. The sole test change is required to anchor FileCheck to the body of the `box_uninitialized` method, so it doesn't see the `allocalign` on `__rust_alloc` and get mad about the string `alloca` showing up. Since I was there anyway, I added some checks on the attributes to prove the right attributes got set. While we're here, we also emit allocator attributes on __rust_alloc_zeroed. This should allow LLVM to perform more optimizations for zeroed blocks, and probably fixes #90032. [This comment](https://github.com/rust-lang/rust/issues/24194#issuecomment-308791157) mentions "weird UB-like behaviour with bitvec iterators in rustc_data_structures" so we may need to back this change out if things go wrong. The new test cases require LLVM 15, so we copy them into LLVM 14-supporting versions, which we can delete when we drop LLVM 14.
2022-07-26Rollup merge of #99748 - compiler-errors:better-impl-trait-printing, r=fee1-deadDylan DPC-4/+4
Use full type name instead of just saying `impl Trait` in "captures lifetime" error I think this is very useful, especially when there's >1 `impl Trait`, and it just means passing around a bit more info that we already have access to.
2022-07-26Allow try_to_raw_bytes on u8 arrayMichael Goulet-21/+15