summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty
AgeCommit message (Collapse)AuthorLines
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/+21
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/+4
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-02Auto merge of #92268 - jswrenn:transmute, r=oli-obkbors-1/+90
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-1/+1
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-1/+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-3/+7
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-1/+1
2022-08-01fix ICE in Definitions::create_defGoldstein-2/+2
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-5/+5
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-5/+5
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-64/+9
remove some manual hash stable impls
2022-07-29remove some manual hash stable implslcnr-64/+9
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-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/+41
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 #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-26Fix diagnostics for unfulfilled obligationsDeadbeef-0/+8
2022-07-26Add `Self: ~const Trait` to traits with `#[const_trait]`Deadbeef-1/+1
2022-07-26Allow try_to_raw_bytes on u8 arrayMichael Goulet-21/+15
2022-07-26Rollup merge of #99353 - compiler-errors:gat-where-clause-mismatch, r=cjgillotYuki Okushi-6/+13
Slightly improve mismatched GAT where clause error This makes the error reporting a bit more standardized between `where` on GATs and functions. cc #99206 (`@BoxyUwU),` don't want to mark this as as "fixed" because they're still not perfect, but this is still an improvement IMO so I want to land it incrementally. regarding "consider adding where clause to trait definition", we don't actually do that for methods as far as i can tell? i could file an issue to look into that maybe.
2022-07-25Auto merge of #99600 - tmiasko:subst-folder, r=petrochenkovbors-55/+72
Tweak `SubstFolder` implementation
2022-07-25Deeply deny fn and raw ptrs in const genericsMichael Goulet-1/+1
2022-07-24Combine redundant obligation cause codesMichael Goulet-6/+13
2022-07-23Rollup merge of #99580 - fmease:fix-issue-99565, r=estebankMatthias Krüger-5/+13
Don't suggest unnameable generic arguments Fixes #99565. `@rustbot` label T-compiler A-diagnostics r? `@rust-lang/wg-diagnostics`
2022-07-22do not mark interior mutable shared refs as dereferenceableRalf Jung-5/+10
2022-07-22rename PointerKind::Shared → SharedMutable to indicate this is NOT the ↵Ralf Jung-4/+4
usual shared reference
2022-07-22Outline `SubstFolder` bug reporting code pathsTomasz Miąsko-55/+70
Bug reporting macro `span_bug!` generates quite a bit of code, we don't expect to execute. Outline it into a separate function.
2022-07-22Inline `SubstFolder::tcx`Tomasz Miąsko-0/+1
2022-07-22Inline `Predicate::has_vars_bound_at_or_above`Tomasz Miąsko-0/+1
2022-07-22Auto merge of #99521 - fee1-dead-contrib:const_fix_hax, r=oli-obkbors-0/+13
Fix hack that remaps env constness. WARNING: might have perf implications. Are there any more problems with having a constness in the `ParamEnv` now? :) r? `@oli-obk`
2022-07-22Rollup merge of #99393 - ↵Dylan DPC-1/+1
Logarithmus:feature/99255-omit-const-generic-suffixes, r=petrochenkov feat: omit suffixes in const generics (e.g. `1_i32`) Closes #99255
2022-07-22Don't suggest unnameable generic argumentsLeón Orell Valerian Liehr-5/+13
2022-07-22Auto merge of #99420 - RalfJung:vtable, r=oli-obkbors-16/+19
make vtable pointers entirely opaque This implements the scheme discussed in https://github.com/rust-lang/unsafe-code-guidelines/issues/338: vtable pointers should be considered entirely opaque and not even readable by Rust code, similar to function pointers. - We have a new kind of `GlobalAlloc` that symbolically refers to a vtable. - Miri uses that kind of allocation when generating a vtable. - The codegen backends, upon encountering such an allocation, call `vtable_allocation` to obtain an actually dataful allocation for this vtable. - We need new intrinsics to obtain the size and align from a vtable (for some `ptr::metadata` APIs), since direct accesses are UB now. I had to touch quite a bit of code that I am not very familiar with, so some of this might not make much sense... r? `@oli-obk`
2022-07-21Rollup merge of #99558 - fee1-dead-contrib:remap_constness_fix, r=oli-obkMatthias Krüger-10/+3
Fix `remap_constness` `~const Drop` was renamed to `~const Destruct` and this special case should be removed
2022-07-21Rollup merge of #99528 - matthiaskrgr:2022_07_perf, r=estebankMatthias Krüger-6/+4
couple of clippy::perf fixes