about summary refs log tree commit diff
path: root/compiler/rustc_middle
AgeCommit message (Collapse)AuthorLines
2024-02-13Rollup merge of #120959 - nnethercote:rm-good_path, r=oli-obkMatthias Krüger-6/+5
Remove good path delayed bugs Because they're not that useful, and kind of annoying. Details in the individual commits. r? ```@compiler-errors```
2024-02-13Move visitable bounds up into internerMichael Goulet-2/+2
2024-02-13Prefer `min_exhaustive_patterns` in compilerNadrieril-1/+2
2024-02-13Uplift TypeVisitableExt into rustc_type_irMichael Goulet-310/+67
2024-02-13Store impl unsafety in impl trait headerOli Scherer-0/+1
2024-02-13Rollup merge of #120696 - estebank:issue-115405, r=oli-obkMatthias Krüger-1/+1
Properly handle `async` block and `async fn` in `if` exprs without `else` When encountering a tail expression in the then arm of an `if` expression without an `else` arm, account for `async fn` and `async` blocks to suggest `return`ing the value and pointing at the return type of the `async fn`. We now also account for AFIT when looking for the return type to point at. Fix #115405.
2024-02-13Auto merge of #120919 - oli-obk:impl_polarity, r=compiler-errorsbors-18/+33
Merge `impl_polarity` and `impl_trait_ref` queries Hopefully this is perf neutral. I want to finish https://github.com/rust-lang/rust/pull/120835 and stop using the HIR in `coherent_trait`, which should then give us a perf improvement.
2024-02-13Remove `good_path_delayed_bug`.Nicholas Nethercote-6/+5
It's only has a single remaining purpose: to ensure that a diagnostic is printed when `trimmed_def_paths` is used. It's an annoying mechanism: weak, with odd semantics, badly named, and gets in the way of other changes. This commit replaces it with a simpler `must_produce_diag` mechanism, getting rid of a diagnostic `Level` along the way.
2024-02-12Rollup merge of #120958 - ShoyuVanilla:remove-subst, r=oli-obkMatthias Krüger-96/+97
Dejargonize `subst` In favor of #110793, replace almost every occurence of `subst` and `substitution` from rustc codes, but they still remains in subtrees under `src/tools/` like clippy and test codes (I'd like to replace them after this)
2024-02-12Rollup merge of #120950 - compiler-errors:miri-async-closurs, r=RalfJung,oli-obkMatthias Krüger-15/+14
Fix async closures in CTFE First commit renames `is_coroutine_or_closure` into `is_closure_like`, because `is_coroutine_or_closure_or_coroutine_closure` seems confusing and long. Second commit fixes some forgotten cases where we want to handle `TyKind::CoroutineClosure` the same as closures and coroutines. The test exercises the change to `ValidityVisitor::aggregate_field_path_elem` which is the source of #120946, but not the change to `UsedParamsNeedSubstVisitor`, though I feel like it's not that big of a deal. Let me know if you'd like for me to look into constructing a test for the latter, though I have no idea what it'd look like (we can't assert against `TooGeneric` anywhere?). Fixes #120946 r? oli-obk cc ``@RalfJung``
2024-02-12Properly handle `async` blocks and `fn`s in `if` exprs without `else`Esteban Küber-1/+1
When encountering a tail expression in the then arm of an `if` expression without an `else` arm, account for `async fn` and `async` blocks to suggest `return`ing the value and pointing at the return type of the `async fn`. We now also account for AFIT when looking for the return type to point at. Fix #115405.
2024-02-12Auto merge of #120980 - matthiaskrgr:rollup-dsjsqql, r=matthiaskrgrbors-14/+14
Rollup of 11 pull requests Successful merges: - #120765 (Reorder diagnostics API) - #120833 (More internal emit diagnostics cleanups) - #120899 (Gracefully handle non-WF alias in `assemble_alias_bound_candidates_recur`) - #120917 (Remove a bunch of dead parameters in functions) - #120928 (Add test for recently fixed issue) - #120933 (check_consts: fix duplicate errors, make importance consistent) - #120936 (improve `btree_cursors` functions documentation) - #120944 (Check that the ABI of the instance we are inlining is correct) - #120956 (Clean inlined type alias with correct param-env) - #120962 (Add myself to library/std review) - #120972 (fix ICE for deref coercions with type errors) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-12Remove impl_polarity queryOli Scherer-4/+5
2024-02-12Implement intrinsics with fallback bodiesOli Scherer-1/+2
2024-02-12Stop calling `impl_polarity` when `impl_trait_ref` was also calledOli Scherer-5/+6
2024-02-12Eagerly dismiss binderOli Scherer-8/+5
2024-02-12Unwrap an Option that can only be Some, as inherent impls can't overlapOli Scherer-6/+6
2024-02-12Use a struct instead of a tupleOli Scherer-5/+11
2024-02-12Make impl_trait_ref into a query also returning more information about the implOli Scherer-4/+14
2024-02-12Make `is_intrinsic` query return the intrinsic nameOli Scherer-6/+12
2024-02-12Tweak delayed bug mentions.Nicholas Nethercote-14/+14
Now that we have both `delayed_bug` and `span_delayed_bug`, it makes sense to use the generic term "delayed bug" more.
2024-02-12Dejargnonize substShoyu Vanilla-96/+97
2024-02-12Lowering field access for anonymous adtsFrank King-0/+24
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