about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2023-07-17Auto merge of #113336 - compiler-errors:new-solver-iat, r=lcnrbors-1/+1
Add support for inherent projections in new solver Not hard to support these, and it cuts out a really big chunk of failing UI tests with `--compare-mode=next-solver` r? `@lcnr` (feel free to reassign, anyone can review this)
2023-07-17Remove `instance_def_size_estimate` query.Nicholas Nethercote-11/+12
It doesn't seem worthwhile now that `MonoItem::size_estimate` is called much less often.
2023-07-17Store item size estimate in `MonoItemData`.Nicholas Nethercote-5/+6
This means we call `MonoItem::size_estimate` (which involves a query) less often: just once per mono item, and then once more per inline item placement. After that we can reuse the stored value as necessary. This means `CodegenUnit::compute_size_estimate` is cheaper.
2023-07-17Introduce `MonoItemData`.Nicholas Nethercote-5/+12
It replaces `(Linkage, Visibility)`, making the code nicer. Plus the next commit will add another field.
2023-07-17Rollup merge of #113539 - agnarrarendelle:master, r=workingjubileeMatthias Krüger-1/+1
fixed typo Hi, I have fixed a few typos in commands. Please review my pr.
2023-07-16Querify unused trait check.Camille GILLOT-0/+4
2023-07-16Add support for inherent projectionsMichael Goulet-1/+1
2023-07-15Auto merge of #112157 - erikdesjardins:align, r=nikicbors-0/+2
Resurrect: rustc_target: Add alignment to indirectly-passed by-value types, correcting the alignment of byval on x86 in the process. Same as #111551, which I [accidentally closed](https://github.com/rust-lang/rust/pull/111551#issuecomment-1571222612) :/ --- This resurrects PR #103830, which has sat idle for a while. Beyond #103830, this also: - fixes byval alignment for types containing vectors on Darwin (see `tests/codegen/align-byval-vector.rs`) - fixes byval alignment for overaligned types on x86 Windows (see `tests/codegen/align-byval.rs`) - fixes ABI for types with 128bit requested alignment on ARM64 Linux (see `tests/codegen/aarch64-struct-align-128.rs`) r? `@nikic` --- `@pcwalton's` original PR description is reproduced below: Commit 88e4d2c from five years ago removed support for alignment on indirectly-passed arguments because of problems with the `i686-pc-windows-msvc` target. Unfortunately, the `memcpy` optimizations I recently added to LLVM 16 depend on this to forward `memcpy`s. This commit attempts to fix the problems with `byval` parameters on that target and now correctly adds the `align` attribute. The problem is summarized in [this comment] by `@eddyb.` Briefly, 32-bit x86 has special alignment rules for `byval` parameters: for the most part, their alignment is forced to 4. This is not well-documented anywhere but in the Clang source. I looked at the logic in Clang `TargetInfo.cpp` and tried to replicate it here. The relevant methods in that file are `X86_32ABIInfo::getIndirectResult()` and `X86_32ABIInfo::getTypeStackAlignInBytes()`. The `align` parameter attribute for `byval` parameters in LLVM must match the platform ABI, or miscompilations will occur. Note that this doesn't use the approach suggested by eddyb, because I felt it was overkill to store the alignment in `on_stack` when special handling is really only needed for 32-bit x86. As a side effect, this should fix #80127, because it will make the `align` parameter attribute for `byval` parameters match the platform ABI on LLVM x86-64. [this comment]: #80822 (comment)
2023-07-14i686-windows: make requested alignment > 4 special case apply transitivelyErik Desjardins-1/+1
2023-07-14Use u64 for incr comp allocation offsetsBen Kimock-4/+7
2023-07-14Rollup merge of #113698 - compiler-errors:rpitit-check, r=spastorinoMatthias Krüger-0/+4
Make it clearer that we're just checking for an RPITIT Tiny nit to use `is_impl_trait_in_trait` more, to make it clearer that we're just checking whether a def-id is an RPITIT, rather than doing something meaningful with the `opt_rpitit_info`. r? `@spastorino`
2023-07-14Rollup merge of #113599 - chenyukang:yukang-fix-use-maybe_body_owned_by, ↵Matthias Krüger-0/+27
r=cjgillot Use maybe_body_owned_by for multiple suggestions This is a continued work from https://github.com/rust-lang/rust/pull/113567 We have several other suggestions not working for closure, this PR use `maybe_body_owned_by` to fix them and add test cases for them.
2023-07-14Make it clearer that we're just checking for an RPITITMichael Goulet-0/+4
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-999/+996
2023-07-14Introduce ExtentUnord trait for collections that can safely consume UnordItems.Michael Woerister-2/+2
2023-07-14Enable potential_query_instability lint in rustc_hir_typeck.Michael Woerister-16/+15
Fix linting errors by using FxIndex(Map|Set) and Unord(Map|Set) as appropriate.
2023-07-14Auto merge of #113609 - nnethercote:maybe_lint_level_root_bounded-cache, ↵bors-20/+0
r=cjgillot Add a cache for `maybe_lint_level_root_bounded` `maybe_lint_level_root_bounded` is called many times and traces node sub-paths many times. This PR adds a cache that lets many of these tracings be skipped, avoiding lots of calls to functions like `Map::attrs` and `Map::parent_id`. r? `@cjgillot`
2023-07-14fix the issue of shorthand in suggest_cloningyukang-0/+27
2023-07-13Rollup merge of #113570 - lcnr:inspect-format, r=BoxyUwUMatthias Krüger-57/+63
refactor proof tree formatting mostly: - handle indentation via a separate formatter - change nested to use a closure tested it after rebasing on top of #113536 and everything looks good. r? `````@BoxyUwU`````
2023-07-13typolcnr-1/+1
2023-07-13refactor proof tree formattinglcnr-57/+63
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-4/+9
2023-07-12Flip cfg's for bootstrap bumpMark Rousskov-1/+1
2023-07-12Auto merge of #113569 - RalfJung:miri, r=oli-obkbors-4/+10
miri: protect Move() function arguments during the call This gives `Move` operands a meaning specific to function calls: - for the duration of the call, the place the operand comes from is protected, making all read and write accesses insta-UB. - the contents of that place are reset to `Uninit`, so looking at them again after the function returns, we cannot observe their contents Turns out we can replace the existing "retag return place" hack with the exact same sort of protection on the return place, which is nicely symmetric. Fixes https://github.com/rust-lang/rust/issues/112564 Fixes https://github.com/rust-lang/miri/issues/2927 This starts with a Miri rustc-push, since we'd otherwise conflict with a PR that recently landed in Miri. (The "miri tree borrows" commit is an unrelated cleanup I noticed while doing the PR. I can remove it if you prefer.) r? `@oli-obk`
2023-07-12Auto merge of #113573 - lcnr:typeck-results, r=compiler-errorsbors-7/+4
remove unnecessary `Rc` the typeck results are already in a `RefCell`, so we don't need to wrap its fields in an `Rc`
2023-07-12Move `maybe_lint_level_root_bounded`.Nicholas Nethercote-20/+0
From `TyCtxt` to the MIR `Builder`. This will allow us to add a cache to `Builder` and use it from `maybe_lint_level_root_bounded`.
2023-07-11Auto merge of #112984 - BoxyUwU:debug_with_infcx, r=compiler-errorsbors-33/+207
Introduce `trait DebugWithInfcx` to debug format types with universe info Seeing universes of infer vars is valuable for debugging but currently we have no way of easily debug formatting a type with the universes of all the infer vars shown. In the future I hope to augment the new solver's proof tree output with a `DebugWithInfcx` impl so that it can show universes but I left that out of this PR as it would be non trivial and this is already large and complex enough. The goal here is to make the various abstractions taking `T: Debug` able to use the codepath for printing out universes, that way we can do `debug!("{:?}", my_x)` and have `my_x` have universes shown, same for the `write!` macro. It's not possible to put the `Infcx: InferCtxtLike<I>` into the formatter argument to `Debug::fmt` so it has to go into the self ty. For this we introduce the type `OptWithInfcx<I: Interner, Infcx: InferCtxtLike<I>, T>` which has the data `T` optionally coupled with the infcx (more on why it's optional later). Because of coherence/orphan rules it's not possible to write the impl `Debug for OptWithInfcx<..., MyType>` when `OptWithInfcx` is in a upstream crate. This necessitates a blanket impl in the crate defining `OptWithInfcx` like so: `impl<T: DebugWithInfcx> Debug for OptWithInfcx<..., T>`. It is not intended for people to manually call `DebugWithInfcx::fmt`, the `Debug` impl for `OptWithInfcx` should be preferred. The infcx has to be optional in `OptWithInfcx` as otherwise we would end up with a large amount of code duplication. Almost all types that want to be used with `OptWithInfcx` do not themselves need access to the infcx so if we were to not optional we would end up with large `Debug` and `DebugWithInfcx` impls that were practically identical other than that when formatting their fields we wrap the field in `OptWithInfcx` instead of formatting it alone. The only types that need access to the infcx themselves are ty/const/region infer vars, everything else is implemented by having the `Debug` impl defer to `OptWithInfcx` with no infcx available. The `DebugWithInfcx` impl is pretty much just the standard `Debug` impl except that instead of recursively formatting fields with `write!(f, "{x:?}")` we must do `write!(f, "{:?}", opt_infcx.wrap(x))`. This is some pretty rough boilerplate but I could not think of an alternative unfortunately. `OptWithInfcx::wrap` is an eager `Option::map` because 99% of callsites were discarding the existing data in `OptWithInfcx` and did not need lazy evaluation. A trait `InferCtxtLike` was added instead of using `InferCtxt<'tcx>` as we need to implement `DebugWithInfcx` for types living in `rustc_type_ir` which are generic over an interner and do not have access to `InferCtxt` since it lives in `rustc_infer`. Additionally I suspect that adding universe info to new solver proof tree output will require an implementation of `InferCtxtLike` for something that is not an `InferCtxt` although this is not the primary motivaton. --- To summarize: - There is a type `OptWithInfcx` which bundles some data optionally with an infcx with allows us to pass an infcx into a `Debug` impl. It's optional instead of being there unconditionally so that we can share code for `Debug` and `DebugWithInfcx` impls that don't care about whether there is an infcx available but have fields that might care. - There is a trait `DebugWithInfcx` which allows downstream crates to add impls of the form `Debug for OptWithInfcx<...>` which would normally be forbidden by orphan rules/coherence. - There is a trait `InferCtxtLike` to allow us to implement `DebugWithInfcx` for types that live in `rustc_type_ir` This allows debug formatting various `ty::*` structures with universes shown by using the `Debug` impl for `OptWithInfcx::new(ty, infcx)` --- This PR does not add `DebugWithInfcx` impls to absolutely _everything_ that should realistically have them, for example you cannot use `OptWithInfcx<Obligation<Predicate>>`. I am leaving this to a future PR to do so as it would likely be a lot more work to do.
2023-07-11update Operand::Move docsRalf Jung-4/+10
2023-07-12fixed typosagnarrarendelle-1/+1
2023-07-11remove unnecessary `Rc`lcnr-7/+4
2023-07-10aarch64-linux: properly handle 128bit aligned aggregatesErik Desjardins-0/+1
2023-07-10repr(align) <= 4 should still be byvalErik Desjardins-1/+1
2023-07-10move has_repr to layout, handle repr(transparent) properlyErik Desjardins-9/+1
2023-07-10i686-windows: pass arguments with requested alignment > 4 indirectlyErik Desjardins-0/+9
2023-07-08Replace RPITIT current impl with new strategy that lowers as a GATSantiago Pastorino-52/+12
2023-07-08Auto merge of #113376 - ↵bors-12/+13
Nilstrieb:pointer-coercions-are-not-casts-because-that-sounds-way-to-general-aaaa, r=oli-obk Rename `adjustment::PointerCast` and variants using it to `PointerCoercion` It makes it sounds like the `ExprKind` and `Rvalue` are supposed to represent all pointer related casts, when in reality their just used to share a little enum variants. Make it clear there these are only coercions and that people who see this and think "why are so many pointer related casts not in these variants" aren't insane. This enum was added in #59987. I'm not sure whether the variant sharing is actually worth it, but this at least makes it less confusing. r? oli-obk
2023-07-07Rollup merge of #113467 - nbdd0121:unwind, r=compiler-errorsMichael Goulet-11/+5
Fix comment of `fn_can_unwind` Reopen of #113213
2023-07-07Rename `adjustment::PointerCast` and variants using it to `PointerCoercion`Nilstrieb-12/+13
It makes it sound like the `ExprKind` and `Rvalue` are supposed to represent all pointer related casts, when in reality their just used to share a some enum variants. Make it clear there these are only coercion to make it clear why only some pointer related "casts" are in the enum.
2023-07-07Auto merge of #113245 - lukas-code:unsizing-sanity-check, r=the8472bors-2/+18
sanity check field offsets in unsizeable structs As promised in https://github.com/rust-lang/rust/pull/112062#issuecomment-1567494994, this PR extends the layout sanity checks to ensure that structs fields don't move around when unsizing and prevent issues like https://github.com/rust-lang/rust/issues/112048 in the future. Like most other layout sanity checks, this only runs on compilers with debug assertions enabled. Here is how it looks when it fails: ```text error: internal compiler error: compiler/rustc_ty_utils/src/layout.rs:533:21: unsizing GcNode<std::boxed::Box<i32>> changed field order! Layout { size: Size(32 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, abi: Aggregate { sized: true }, fields: Arbitrary { offsets: [Size(0 bytes), Size(8 bytes), Size(24 bytes)], memory_index: [0, 1, 2] }, largest_niche: Some(Niche { offset: Size(24 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), variants: Single { index: 0 } } Layout { size: Size(24 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, abi: Aggregate { sized: false }, fields: Arbitrary { offsets: [Size(16 bytes), Size(0 bytes), Size(24 bytes)], memory_index: [1, 0, 2] }, largest_niche: None, variants: Single { index: 0 } } ``` r? `@the8472`
2023-07-06get rid of a bit more calls to poly_selectMichael Goulet-3/+3
2023-07-06Separate select calls that don't need a binderMichael Goulet-0/+7
2023-07-06add helper methods for accessing struct tailLukas Markeffsky-2/+18
2023-07-06Add a new trait to `Debug` things with an infcx availableBoxy-33/+207
2023-07-06Auto merge of #113377 - BoxyUwU:move_ty_ctors_to_ty, r=compiler-errorsbors-465/+510
Move `TyCtxt::mk_x` to `Ty::new_x` where applicable Part of rust-lang/compiler-team#616 turns out there's a lot of places we construct `Ty` this is a ridiculously huge PR :S r? `@oli-obk`
2023-07-06Fix up doc linksOli Scherer-2/+2
2023-07-06Auto merge of #113291 - oli-obk:pretty_print_mir_const, r=RalfJungbors-60/+48
Specialize `try_destructure_mir_constant` for its sole user (pretty printing) We can't remove the query, as we need to invoke it from rustc_middle, but can only implement it in mir interpretation/const eval. r? `@RalfJung` for a first round. While we could move all the logic into pretty printing, that would end up duplicating a bit of code with const eval, which doesn't seem great either.
2023-07-05Change comment on `TyCtxt::mk_ty_from_kind`Michael Goulet-1/+1
2023-07-05Move `TyCtxt::mk_x` to `Ty::new_x` where applicableBoxy-463/+508
2023-07-05Auto merge of #113370 - compiler-errors:rollup-8gvyy8e, r=compiler-errorsbors-237/+209
Rollup of 8 pull requests Successful merges: - #113010 (rust-installer & rls: remove exclusion from rustfmt & tidy ) - #113317 ( -Ztrait-solver=next: stop depending on old solver) - #113319 (`TypeParameterDefinition` always require a `DefId`) - #113320 (Add some extra information to opaque type cycle errors) - #113321 (Move `ty::ConstKind` to `rustc_type_ir`) - #113337 (Winnow specialized impls during selection in new solver) - #113355 (Move most coverage code out of `rustc_codegen_ssa`) - #113356 (Add support for NetBSD/riscv64 aka. riscv64gc-unknown-netbsd.) r? `@ghost` `@rustbot` modify labels: rollup
2023-07-05Document magic booleanOli Scherer-1/+3