about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2024-02-16allow mutable references in const values when they point to no memoryRalf Jung-4/+5
2024-02-16Auto merge of #120486 - reitermarkus:use-generic-nonzero, r=dtolnaybors-33/+32
Use generic `NonZero` internally. Tracking issue: https://github.com/rust-lang/rust/issues/120257
2024-02-16Rollup merge of #121146 - compiler-errors:ignore-diverging-arms, r=estebankGuillaume Gomez-2/+1
Only point out non-diverging arms for match suggestions Fixes #121144 There is no reason to point at diverging arms, which will always coerce to whatever is the match block's evaluated type. This also removes the suggestion from #106601, since as I pointed out in https://github.com/rust-lang/rust/issues/72634#issuecomment-1946210898 the added suggestion is not firing in the right cases, but instead only when one of the match arms already *actually* evaluates to `()`. r? estebank
2024-02-16Rollup merge of #121141 - compiler-errors:closure-kind-docs, r=nnethercoteGuillaume Gomez-11/+26
Fix closure kind docs I didn't review this close enough lol -- the old code snippet didn't use substs correctly, and had a malformed `if let`
2024-02-15Fix closure kind docsMichael Goulet-11/+26
2024-02-15Remove a suggestion that is redundantMichael Goulet-1/+0
2024-02-15Only point out non-diverging arms for match suggestionsMichael Goulet-1/+1
2024-02-15Auto merge of #120931 - chenyukang:yukang-cleanup-hashmap, r=michaelwoeristerbors-5/+4
Clean up potential_query_instability with FxIndexMap and UnordMap From https://github.com/rust-lang/rust/pull/120485#issuecomment-1916437191 r? `@michaelwoerister`
2024-02-15Auto merge of #116564 - oli-obk:evaluated_static_in_metadata, ↵bors-59/+27
r=RalfJung,cjgillot Store static initializers in metadata instead of the MIR of statics. This means that adding generic statics would be even more difficult, as we can't evaluate statics from other crates anymore, but the subtle issue I have encountered make me think that having this be an explicit problem is better. The issue is that ```rust static mut FOO: &mut u32 = &mut 42; static mut BAR = unsafe { FOO }; ``` gets different allocations, instead of referring to the same one. This is also true for non-static mut, but promotion makes `static FOO: &u32 = &42;` annoying to demo. Fixes https://github.com/rust-lang/rust/issues/61345 ## Why is this being done? In order to ensure all crates see the same nested allocations (which is the last issue that needs fixing before we can stabilize [`const_mut_refs`](https://github.com/rust-lang/rust/issues/57349)), I am working on creating anonymous (from the Rust side, to LLVM it's like a regular static item) static items for the nested allocations in a static. If we evaluate the static item in a downstream crate again, we will end up duplicating its nested allocations (and in some cases, like the `match` case, even duplicate the main allocation).
2024-02-15Return ConstAllocation from eval_static_initializer query directlyOli Scherer-38/+9
2024-02-15Store static initializers in metadata instead of the MIR of statics.Oli Scherer-0/+2
2024-02-15Add new query just for static initializersOli Scherer-28/+23
2024-02-15Rollup merge of #121122 - compiler-errors:identical-layouts, r=oli-obkMatthias Krüger-2/+4
Enforce coroutine-closure layouts are identical Enforce that for an async closure, the by-ref and by-move coroutine layouts are identical. This is just a sanity check to make sure that optimizations aren't doing anything fishy. r? oli-obk
2024-02-15Rollup merge of #121084 - oli-obk:create_def_forever_red2, r=WaffleLapkinMatthias Krüger-13/+17
Make sure `tcx.create_def` also depends on the forever red node, instead of just `tcx.at(span).create_def` oversight from https://github.com/rust-lang/rust/pull/119136 Not actually an issue, because all uses of `tcx.create_def` were in the resolver, which is `eval_always`, but still good to harden against future uses of `create_def` cc `@petrochenkov` `@WaffleLapkin`
2024-02-15Replace `NonZero::<_>::new` with `NonZero::new`.Markus Reiter-23/+18
2024-02-15Use generic `NonZero` internally.Markus Reiter-29/+33
2024-02-15Enforce coroutine-closure layouts are identicalMichael Goulet-2/+4
2024-02-14Move all the heavy lifting from `TyCtxtAt::create_def` into `TyCtxt::create_def`Oli Scherer-13/+17
2024-02-14Rollup merge of #121084 - oli-obk:create_def_forever_red2, r=WaffleLapkinGuillaume Gomez-6/+6
Make sure `tcx.create_def` also depends on the forever red node, instead of just `tcx.at(span).create_def` oversight from https://github.com/rust-lang/rust/pull/119136 Not actually an issue, because all uses of `tcx.create_def` were in the resolver, which is `eval_always`, but still good to harden against future uses of `create_def` cc `@petrochenkov` `@WaffleLapkin`
2024-02-14Rollup merge of #121083 - GuillaumeGomez:doc-to_opt_closure_kind, ↵Guillaume Gomez-0/+14
r=compiler-errors Extend documentation for `Ty::to_opt_closure_kind` method This API was... surprising to use. With a little extra documentation, the weirdness can be reduced quite a lot. :) r? `@compiler-errors`
2024-02-14Extend documentation for `Ty::to_opt_closure_kind` methodGuillaume Gomez-0/+14
2024-02-14Make sure `tcx.create_def` also depends on the forever red node, instead of ↵Oli Scherer-6/+6
just `tcx.at(span).create_def`
2024-02-14Rollup merge of #121049 - estebank:issue-121009, r=fmeaseOli Scherer-0/+5
Do not point at `#[allow(_)]` as the reason for compat lint triggering Fix #121009.
2024-02-14Rollup merge of #120498 - compiler-errors:type-flags, r=lcnrOli Scherer-312/+69
Uplift `TypeVisitableExt` into `rustc_type_ir` This uplifts `TypeVisitableExt` into `rustc_type_ir` so it can be used in an interner-agnostic way. It also moves some `TypeSuperVisitable` bounds onto `Interner` since we don't expect to support libraries that have types which aren't foldable by default. This restores a couple of asserts in the canonicalizer code we uplifted, and also makes it so that we can use type-flags-based helpers in the solver code, which I'm interested in uplifting. r? lcnr
2024-02-14clean up potential_query_instability with FxIndexMap and UnordMapyukang-5/+4
2024-02-14Auto merge of #121018 - oli-obk:impl_unsafety, r=TaKO8Kibors-0/+1
Fully stop using the HIR in trait impl checks At least I hope I found all happy path usages. I'll need to check if I can figure out a way to make queries declare that they don't access the HIR except in error paths
2024-02-13Do not point at `#[allow(_)]` as the reason for compat lint triggeringEsteban Küber-0/+5
Fix #121009.
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