about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2024-02-12check uniqueness of nested fieldsFrank King-1/+6
2024-02-12Lower anonymous structs or unions to HIRFrank King-5/+48
2024-02-12Auto merge of #120951 - matthiaskrgr:rollup-0nnm7dv, r=matthiaskrgrbors-51/+40
Rollup of 8 pull requests Successful merges: - #110483 (Create try_new function for ThinBox) - #120740 (Make cmath.rs a single file) - #120872 (hir: Refactor getters for HIR parents) - #120880 (add note on comparing vtables / function pointers) - #120885 (interpret/visitor: ensure we only see normalized types) - #120888 (assert_unsafe_precondition cleanup) - #120897 (Encode `coroutine_for_closure` for foreign crates) - #120937 ([docs] Update armv6k-nintendo-3ds platform docs for outdated info) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-11Rollup merge of #120872 - petrochenkov:opthirpar, r=cjgillotMatthias Krüger-51/+40
hir: Refactor getters for HIR parents See individual commits. I ended up removing on of the FIXMEs from https://github.com/rust-lang/rust/pull/120206 instead of addressing it.
2024-02-11Auto merge of #120619 - compiler-errors:param, r=lcnrbors-2/+8
Assert that params with the same *index* have the same *name* Found this bug when trying to build libcore with the new solver, since it will canonicalize two params with the same index into *different* placeholders if those params differ by name.
2024-02-11is_closure_likeMichael Goulet-15/+14
2024-02-11Rollup merge of #120896 - compiler-errors:coro-closure-kind, r=oli-obkMatthias Krüger-1/+18
Print kind of coroutine closure Make sure that we print "async closure" when we have an async closure, rather than calling it generically a ["coroutine-closure"](https://github.com/rust-lang/rust/pull/120361). Fixes #120886 r? oli-obk
2024-02-11Rollup merge of #120883 - RalfJung:extern-static-err, r=oli-obkMatthias Krüger-1/+1
interpret: rename ReadExternStatic → ExternStatic This error shows up for reads and writes, so `ReadExternStatic` is misleading.
2024-02-11Rollup merge of #120882 - RalfJung:set-discriminant, r=compiler-errorsMatthias Krüger-0/+2
interpret/write_discriminant: when encoding niched variant, ensure the stored value matches Cc https://github.com/rust-lang/unsafe-code-guidelines/issues/487
2024-02-11Rollup merge of #120874 - gurry:120838-extra-where-in-suggestion, r=fmeaseMatthias Krüger-1/+7
Take empty `where` bounds into account when suggesting predicates Fixes #120838
2024-02-10Print kind of coroutine closureMichael Goulet-1/+18
2024-02-10detect consts that reference extern staticsRalf Jung-0/+1
2024-02-10validation: descend from consts into staticsRalf Jung-0/+1
2024-02-10interpret: rename ReadExternStatic → ExternStaticRalf Jung-1/+1
2024-02-10interpret/write_discriminant: when encoding niched variant, ensure the ↵Ralf Jung-0/+2
stored value matches
2024-02-10Take empty `where` into account when suggesting predicatesGurinder Singh-1/+7
2024-02-10hir: Remove `hir::Map::{opt_parent_id,parent_id,get_parent,find_parent}`Vadim Petrochenkov-27/+10
2024-02-10hir: Introduce `TyCtxt::parent_hir_{id,node}`Vadim Petrochenkov-28/+34
Remove the FIXME and keep `CRATE_HIR_ID` being its own parent. This scheme turned out to be more practical than having an `Option` on closer inspection. Also make `hir_owner_parent` more readable.
2024-02-09Auto merge of #120852 - matthiaskrgr:rollup-01pr8gj, r=matthiaskrgrbors-16/+32
Rollup of 11 pull requests Successful merges: - #120351 (Implement SystemTime for UEFI) - #120354 (improve normalization of `Pointee::Metadata`) - #120776 (Move path implementations into `sys`) - #120790 (better error message on download CI LLVM failure) - #120806 (Clippy subtree update) - #120815 (Improve `Option::inspect` docs) - #120822 (Emit more specific diagnostics when enums fail to cast with `as`) - #120827 (Print image input file and checksum in CI only) - #120836 (hide impls if trait bound is proven from env) - #120844 (Build DebugInfo for async closures) - #120851 (Remove duplicate release note) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-09Rollup merge of #120354 - lukas-code:metadata-normalize, r=lcnrMatthias Krüger-16/+32
improve normalization of `Pointee::Metadata` This PR makes it so that `<Wrapper<Tail> as Pointee>::Metadata` is normalized to `<Tail as Pointee>::Metadata` if we don't know `Wrapper<Tail>: Sized`. With that, the trait solver can prove projection predicates like `<Wrapper<Tail> as Pointee>::Metadata == <Tail as Pointee>::Metadata`, which makes it possible to use the metadata APIs to cast between the tail and the wrapper: ```rust #![feature(ptr_metadata)] use std::ptr::{self, Pointee}; fn cast_same_meta<T: ?Sized, U: ?Sized>(ptr: *const T) -> *const U where T: Pointee<Metadata = <U as Pointee>::Metadata>, { let (thin, meta) = ptr.to_raw_parts(); ptr::from_raw_parts(thin, meta) } struct Wrapper<T: ?Sized>(T); fn cast_to_wrapper<T: ?Sized>(ptr: *const T) -> *const Wrapper<T> { cast_same_meta(ptr) } ``` Previously, this failed to compile: ``` error[E0271]: type mismatch resolving `<Wrapper<T> as Pointee>::Metadata == <T as Pointee>::Metadata` --> src/lib.rs:16:5 | 15 | fn cast_to_wrapper<T: ?Sized>(ptr: *const T) -> *const Wrapper<T> { | - found this type parameter 16 | cast_same_meta(ptr) | ^^^^^^^^^^^^^^ expected `Wrapper<T>`, found type parameter `T` | = note: expected associated type `<Wrapper<T> as Pointee>::Metadata` found associated type `<T as Pointee>::Metadata` = note: an associated type was expected, but a different one was found ``` (Yes, you can already do this with `as` casts. But using functions is so much :sparkles: *safer* :sparkles:, because you can't change the metadata on accident.) --- This PR essentially changes the built-in impls of `Pointee` from this: ```rust // before impl Pointee for u8 { type Metadata = (); } impl Pointee for [u8] { type Metadata = usize; } // ... impl Pointee for Wrapper<u8> { type Metadata = (); } impl Pointee for Wrapper<[u8]> { type Metadata = usize; } // ... // This impl is only selected if `T` is a type parameter or unnormalizable projection or opaque type. fallback impl<T: ?Sized> Pointee for Wrapper<T> where Wrapper<T>: Sized { type Metadata = (); } // This impl is only selected if `T` is a type parameter or unnormalizable projection or opaque type. fallback impl<T /*: Sized */> Pointee for T { type Metadata = (); } ``` to this: ```rust // after impl Pointee for u8 { type Metadata = (); } impl Pointee for [u8] { type Metadata = usize; } // ... impl<T: ?Sized> Pointee for Wrapper<T> { // in the old solver this will instead project to the "deep" tail directly, // e.g. `Wrapper<Wrapper<T>>::Metadata = T::Metadata` type Metadata = <T as Pointee>::Metadata; } // ... // This impl is only selected if `T` is a type parameter or unnormalizable projection or opaque type. fallback impl<T /*: Sized */> Pointee for T { type Metadata = (); } ```
2024-02-09Auto merge of #120676 - Mark-Simulacrum:bootstrap-bump, r=clubby789bors-1/+1
Bump bootstrap compiler to just-built 1.77 beta https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2024-02-09Auto merge of #120843 - matthiaskrgr:rollup-med37z5, r=matthiaskrgrbors-1/+3
Rollup of 8 pull requests Successful merges: - #113671 (Make privacy visitor use types more (instead of HIR)) - #120308 (core/time: avoid divisions in Duration::new) - #120693 (Invert diagnostic lints.) - #120704 (A drive-by rewrite of `give_region_a_name()`) - #120809 (Use `transmute_unchecked` in `NonZero::new`.) - #120817 (Fix more `ty::Error` ICEs in MIR passes) - #120828 (Fix `ErrorGuaranteed` unsoundness with stash/steal.) - #120831 (Startup objects disappearing from sysroot) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-09Rollup merge of #120693 - nnethercote:invert-diagnostic-lints, r=davidtwcoMatthias Krüger-1/+3
Invert diagnostic lints. That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has been converted to use translated diagnostics. This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted. r? ````@davidtwco````
2024-02-09Auto merge of #120594 - saethlin:delayed-debug-asserts, r=oli-obkbors-0/+4
Toggle assert_unsafe_precondition in codegen instead of expansion The goal of this PR is to make some of the unsafe precondition checks in the standard library available in debug builds. Some UI tests are included to verify that it does that. The diff is large, but most of it is blessing mir-opt tests and I've also split up this PR so it can be reviewed commit-by-commit. This PR: 1. Adds a new intrinsic, `debug_assertions` which is lowered to a new MIR NullOp, and only to a constant after monomorphization 2. Rewrites `assume_unsafe_precondition` to check the new intrinsic, and be monomorphic. 3. Skips codegen of the `assume` intrinsic in unoptimized builds, because that was silly before but with these checks it's *very* silly 4. The checks with the most overhead are `ptr::read`/`ptr::write` and `NonNull::new_unchecked`. I've simply added `#[cfg(debug_assertions)]` to the checks for `ptr::read`/`ptr::write` because I was unable to come up with any (good) ideas for decreasing their impact. But for `NonNull::new_unchecked` I found that the majority of callers can use a different function, often a safe one. Yes, this PR slows down the compile time of some programs. But in our benchmark suite it's never more than 1% icount, and the average icount change in debug-full programs is 0.22%. I think that is acceptable for such an improvement in developer experience. https://github.com/rust-lang/rust/issues/120539#issuecomment-1922687101
2024-02-08Rollup merge of #120801 - oli-obk:drop_recursion_ice, r=NilstriebMatthias Krüger-0/+1
Avoid ICE in drop recursion check in case of invalid drop impls fixes #120787
2024-02-08Rollup merge of #120590 - compiler-errors:dead, r=NilstriebMatthias Krüger-2/+1
Remove unused args from functions `#[instrument]` suppresses the unused arguments from a function, *and* suppresses unused methods too! This PR removes things which are only used via `#[instrument]` calls, and fixes some other errors (privacy?) that I will comment inline. It's possible that some of these arguments were being passed in for the purposes of being instrumented, but I am unconvinced by most of them.
2024-02-08Avoid ICE in drop recursion check in case of invalid drop implsOli Scherer-0/+1
2024-02-08Add a new debug_assertions instrinsic (compiler)Ben Kimock-0/+4
And in clippy
2024-02-08Auto merge of #120544 - BoxyUwU:enter_forall, r=lcnrbors-0/+1
Introduce `enter_forall` to supercede `instantiate_binder_with_placeholders` r? `@lcnr` Long term we'd like to experiment with decrementing the universe count after "exiting" binders so that we do not end up creating infer vars in non-root universes even when they logically reside in the root universe. The fact that we dont do this currently results in a number of issues in the new trait solver where we consider goals to be ambiguous because otherwise it would require lowering the universe of an infer var. i.e. the goal `?x.0 eq <T as Trait<?y.1>>::Assoc` where the alias is rigid would not be able to instantiate `?x` with the alias as there would be a universe error. This PR is the first-ish sort of step towards being able to implement this as eventually we would want to decrement the universe in `enter_forall`. Unfortunately its Difficult to actually implement decrementing universes nicely so this is a separate step which moves us closer to the long term goal :sparkles:
2024-02-08introduce `enter_forall`Boxy-0/+1
2024-02-08Step all bootstrap cfgs forwardMark Rousskov-1/+1
This also takes care of other bootstrap-related changes.
2024-02-08Rollup merge of #120739 - lukas-code:pp-dyn-assoc, r=compiler-errorsMatthias Krüger-33/+81
improve pretty printing for associated items in trait objects * Don't print a binder in front of associated items, because it's not valid syntax. * e.g. print `dyn for<'a> Trait<'a, Assoc = &'a u8>` instead of `dyn for<'a> Trait<'a, for<'a> Assoc = &'a u8>`. * Don't print associated items that are implied by a supertrait bound. * e.g. if we have `trait Sub: Super<Assoc = u8> {}`, then just print `dyn Sub` instead of `dyn Sub<Assoc = u8>`. I've added the test in the first commit, so you can see the diff of the compiler output in the second commit.
2024-02-08Rollup merge of #120206 - petrochenkov:somehir, r=compiler-errorsMatthias Krüger-79/+61
hir: Make sure all `HirId`s have corresponding HIR `Node`s And then remove `tcx.opt_hir_node(hir_id)` in favor of `tcx.hir_node(hir_id)`.
2024-02-08Auto merge of #120381 - fee1-dead-contrib:reconstify-add, r=compiler-errorsbors-0/+4
Reconstify `Add` r? project-const-traits I'm not happy with the ui test changes (or failures because I did not bless them and include the diffs in this PR). There is at least some bugs I need to look and try fix: 1. A third duplicated diagnostic when a consumer crate that does not have `effects` enabled has a trait selection error for an upstream const_trait trait. See tests/ui/ufcs/ufcs-qpath-self-mismatch.rs. 2. For some reason, making `Add` a const trait would stop us from suggesting `T: Add` when we try to add two `T`s without that bound. See tests/ui/suggestions/issue-97677.rs
2024-02-07Do not create param types that differ only by name when comparing intrinsic ↵Michael Goulet-1/+1
signatures
2024-02-07Assert that ParamTy and ParamConst have identical names for identical indicesMichael Goulet-2/+8
2024-02-07address review comments and add more testsLukas Markeffsky-10/+15
2024-02-07Rollup merge of #120746 - compiler-errors:kind-ty, r=oli-obkGuillaume Boisseau-1/+8
Record coroutine kind in coroutine generics Oops, added a new substitution (the "kind" ty) to coroutines but forgot to record it in the `generics_of`. I'm surprised I left this out of the coroutine-closure PR -- I thought I made this change; I possibly rebased it out by accident. Fixes #120732 r? oli-obk
2024-02-07Rollup merge of #120733 - klensy:trait-const-fn, r=oli-obkGuillaume Boisseau-2/+23
MirPass: make name more const Continues #120161, this time applied to `MirPass` instead of `MirLint`, locally shaves few (very few) instructions off. r? ``@cjgillot``
2024-02-07Record coroutine kind in genericsMichael Goulet-1/+8
2024-02-07improve pretty printing for trait objectsLukas Markeffsky-32/+75
2024-02-07MirPass: make name more constklensy-2/+23
2024-02-07hir: Add some FIXMEs for future workVadim Petrochenkov-0/+3
2024-02-07hir: Remove `fn opt_hir_id` and `fn opt_span`Vadim Petrochenkov-79/+54
2024-02-07hir: Make sure all `HirId`s have corresponding HIR `Node`sVadim Petrochenkov-4/+8
2024-02-06Rollup merge of #120707 - compiler-errors:suitable-region, r=nnethercoteMatthias Krüger-1/+1
Don't expect early-bound region to be local when reporting errors in RPITIT well-formedness The implicit lifetime in the example code gets replaced with `ReError`, which fails a `sub_regions` check in the lexical region solver. Error reporting ends up calling `is_suitable_region` on an early bound region in the *trait* definition. This causes an ICE because we `expect_local()`. This is kind of a bad explanation, but this code just makes diagnostics reporting a bit more gracefully fallible. If the reviewer wants a thorough investigation of exactly where we get this region outlives obligation, I can write one up. Doesn't really seem worth it, though, imo. Fixes #120638 Fixes #120648
2024-02-06Rollup merge of #120502 - clubby789:remove-ffi-returns-twice, r=compiler-errorsMatthias Krüger-13/+10
Remove `ffi_returns_twice` feature The [tracking issue](https://github.com/rust-lang/rust/issues/58314) and [RFC](https://github.com/rust-lang/rfcs/pull/2633) have been closed for a couple of years. There is also an attribute gate in R-A which should be removed if this lands.
2024-02-06Rollup merge of #120423 - RalfJung:indirect-structural-match, r=petrochenkovMatthias Krüger-2/+1
update indirect structural match lints to match RFC and to show up for dependencies This is a large step towards implementing https://github.com/rust-lang/rfcs/pull/3535. We currently have five lints related to "the structural match situation": - nontrivial_structural_match - indirect_structural_match - pointer_structural_match - const_patterns_without_partial_eq - illegal_floating_point_literal_pattern This PR concerns the first 3 of them. (The 4th already is set up to show for dependencies, and the 5th is removed by https://github.com/rust-lang/rust/pull/116284.) nontrivial_structural_match is being removed as per the RFC; the other two are enabled to show up in dependencies. Fixes https://github.com/rust-lang/rust/issues/73448 by removing the affected analysis.
2024-02-06Rollup merge of #120670 - lcnr:effect-var-storage, r=fee1-deadMatthias Krüger-19/+23
cleanup effect var handling r? types
2024-02-06Don't expect early-bound region to be local in RPITIT well-formednessMichael Goulet-1/+1