about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2023-06-17Simplify even more candidatesMichael Goulet-111/+26
2023-06-17Simplify an ObjectData fieldMichael Goulet-6/+6
2023-06-17Simplify some impl source candidatesMichael Goulet-57/+0
2023-06-17Remove some ImplSource candidatesMichael Goulet-31/+10
2023-06-17Auto merge of #108860 - oli-obk:tait_alias, r=compiler-errorsbors-3/+19
Add `AliasKind::Weak` for type aliases. `type Foo<T: Debug> = Bar<T>;` does not check `T: Debug` at use sites of `Foo<NotDebug>`, because in contrast to a ```rust trait Identity { type Identity; } impl<T: Debug> Identity for T { type Identity = T; } <NotDebug as Identity>::Identity ``` type aliases do not exist in the type system, but are expanded to their aliased type immediately when going from HIR to the type layer. Similarly: * a private type alias for a public type is a completely fine thing, even though it makes it a bit hard to write out complex times sometimes * rustdoc expands the type alias, even though often times users use them for documentation purposes * diagnostics show the expanded type, which is confusing if the user wrote a type alias and the diagnostic talks about another type that they don't know about. For type alias impl trait, these issues do not actually apply in most cases, but sometimes you have a type alias impl trait like `type Foo<T: Debug> = (impl Debug, Bar<T>);`, which only really checks it for `impl Debug`, but by accident prevents `Bar<T>` from only being instantiated after proving `T: Debug`. This PR makes sure that we always check these bounds explicitly and don't rely on an implementation accident. To not break all the type aliases out there, we only use it when the type alias contains an opaque type. We can decide to do this for all type aliases over an edition. Or we can later extend this to more types if we figure out the back-compat concerns with suddenly checking such bounds. As a side effect, easily allows fixing https://github.com/rust-lang/rust/issues/108617, which I did. fixes https://github.com/rust-lang/rust/issues/108617
2023-06-16Rollup merge of #112706 - WaffleLapkin:syntax_context_is_root, r=petrochenkovMichael Goulet-2/+2
Add `SyntaxContext::is_root` Makes the code a tad nicer.
2023-06-16Rollup merge of #112665 - compiler-errors:assumption-takes-clause, r=lcnrMichael Goulet-0/+66
Make assumption functions in new solver take `Binder<'tcx, Clause<'tcx>>` We just use an if-let to match on an optional clause at all the places where we transition from `Predicate` -> `Clause`, but I assume that when things like item-bounds and param-env start to only store `Clause`s then those can just be trivially dropped. r? ``@lcnr``
2023-06-16Add `AliasKind::Weak` for type aliases.Oli Scherer-3/+19
Only use it when the type alias contains an opaque type. Also does wf-checking on such type aliases.
2023-06-16Add `SyntaxContext::is_root`Maybe Waffle-2/+2
2023-06-16Rollup merge of #112443 - ↵Dylan DPC-8/+33
compiler-errors:next-solver-opportunistically-resolve-regions, r=lcnr Opportunistically resolve regions in new solver Use `opportunistic_resolve_var` during canonicalization to collapse some regions. We have to start using `CanonicalVarValues::is_identity_modulo_regions`. We also have to modify that function to consider responses like `['static, ^0, '^1, ^2]` to be an "identity" response, since because we opportunistically resolve regions, there's no longer a 1:1 mapping between canonical var values and bound var indices in the response... There's one nasty side-effect -- one test (`tests/ui/dyn-star/param-env-infer.rs`) starts to ICE because the certainty goes from `Yes` to `Maybe(Overflow)`... Not exactly sure why, though? Putting this up for discussion/investigation. r? ```@lcnr```
2023-06-16Auto merge of #112346 - saethlin:no-comment, r=oli-obkbors-50/+71
Remove comments from mir-opt MIR dumps See https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Line.20numbers.20in.20mir-opt.20tests/near/363849874 In https://github.com/rust-lang/rust/pull/99780 there is mention that "there has been a zulip conversation about disabling line numbers with mixed opinions" which to me means that some people opposed this. I can't find the referenced conversation so... here we go. The current situation is quite chaotic. It's not hard to find MIR diffs which contain * Absolute line numbers * Relative line numbers * Substituted line numbers (LL) For example: https://github.com/rust-lang/rust/blob/408bbd040613f6776e0a7d05d582c81f4ddc189a/tests/mir-opt/inline/inline_shims.drop.Inline.diff#L10-L17 And sometimes adding a comment at the top of a mir-opt test generates a diff in the test because a line number changed: https://github.com/rust-lang/rust/pull/98112/files#diff-b8cf4bcce95078e6a3faf075e9abf6864872fb28a64d95c04f04513b9e3bbd81 And irrelevant changes to the standard library can generate diffs in mir-opt tests: https://github.com/rust-lang/rust/pull/110694/files#diff-bf96b0e7c67b8b272814536888fd9428c314991e155beae1f0a2a67f0ac47b2c https://github.com/rust-lang/rust/commit/769886cc35ce08b76839f4cf72b8af1161c432e1 I think we should, specifically in mir-opt tests, completely remove the comments, or insert placeholders for all line and column numbers.
2023-06-15Rollup merge of #112614 - lukas-code:apit-unsized-suggestion, r=compiler-errorsGuillaume Gomez-17/+31
tweak suggestion for argument-position `impl ?Sized` fixes this invalid suggestion: ```text help: consider removing the `?Sized` bound to make the type parameter `Sized` | 1 - fn foo(_: impl ?Sized) {} 1 + fn foo(_: impl ) {} | ```
2023-06-15Remove comments from mir-opt MIR dumpsBen Kimock-50/+71
2023-06-15privacy: Rename some variables for clarityVadim Petrochenkov-3/+3
2023-06-15privacy: Do not mark items reachable farther than their nominal visibilityVadim Petrochenkov-13/+16
This commit reverts a change made in #111425. It was believed that this change was necessary for implementing type privacy lints, but #111801 showed that it was not necessary. Quite opposite, the revert fixes some issues.
2023-06-15Make assumption functions in new solver take clauseMichael Goulet-0/+66
2023-06-15Rollup merge of #112634 - mj10021:issue-112438-fix, r=compiler-errorsMatthias Krüger-1/+4
add InlineConst check add check to close #112438
2023-06-15change `std::marker::Sized` to just `Sized`Lukas Markeffsky-5/+2
2023-06-15tweak suggestion for argument-position `impl ?Sized`Lukas Markeffsky-12/+29
2023-06-14remove unused postorder CFG cacheRémy Rakic-9/+0
2023-06-14make `traversal::postorder` traverse RPO cache backwardsRémy Rakic-4/+36
2023-06-14add InlineConst checkJames Dietz-1/+4
2023-06-14make `traversal::reverse_postorder` use RPO cacheRémy Rakic-29/+6
2023-06-14add RPO to BB CFG cacheRémy Rakic-0/+12
2023-06-14s/drain_filter/extract_if/ for Vec, Btree{Map,Set} and LinkedListThe 8472-2/+2
2023-06-13opportunistically resolve regionsMichael Goulet-8/+33
2023-06-08Rollup merge of #109953 - thomcc:thomcc/typeid128, r=WaffleLapkinMatthias Krüger-2/+11
Use 128 bits for TypeId hash Preliminary/Draft impl of https://github.com/rust-lang/compiler-team/issues/608 Prior art (probably incomplete list) - https://github.com/rust-lang/rust/pull/75923 - https://github.com/rust-lang/rust/pull/95845
2023-06-07Auto merge of #109005 - Nilstrieb:dont-forgor-too-much-from-cfg, r=petrochenkovbors-1/+12
Remember names of `cfg`-ed out items to mention them in diagnostics # Examples ## `serde::Deserialize` without the `derive` feature (a classic beginner mistake) I had to slightly modify serde so that it uses explicit re-exports instead of a glob re-export. (Update: a serde PR was merged that adds the manual re-exports) ``` error[E0433]: failed to resolve: could not find `Serialize` in `serde` --> src/main.rs:1:17 | 1 | #[derive(serde::Serialize)] | ^^^^^^^^^ could not find `Serialize` in `serde` | note: crate `serde` has an item named `Serialize` but it is inactive because its cfg predicate evaluated to false --> /home/gh-Nilstrieb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.160/src/lib.rs:343:1 | 343 | #[cfg(feature = "serde_derive")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 344 | pub use serde_derive::{Deserialize, Serialize}; | ^^^^^^^^^ = note: the item is gated behind the `serde_derive` feature = note: see https://doc.rust-lang.org/cargo/reference/features.html for how to activate a crate's feature ``` (the suggestion is not ideal but that's serde's fault) I already tested the metadata size impact locally by compiling the `windows` crate without any features. `800k` -> `809k` r? `@ghost`
2023-06-07Rollup merge of #112122 - compiler-errors:next-coherence, r=lcnrDylan DPC-1/+9
Add `-Ztrait-solver=next-coherence` Flag that conditionally uses the trait solver *only* during coherence, for more testing and/or eventual partial-migration onto the trait solver (in the medium- to long-term). * This still uses the selection context in some of the coherence methods I think, so it's not "complete". Putting this up for review and/or for further work in-tree. * I probably need to spend a bit more time making sure that we don't sneakily create any other infcx's during coherence that also need the new solver enabled. r? `@lcnr`
2023-06-07Auto merge of #111047 - compiler-errors:rtn-no-ty-ct-params, r=spastorinobors-1/+0
Emit an error when return-type-notation is used with type/const params These are not intended to be supported initially, even though the compiler supports them internally...
2023-06-06Auto merge of #112361 - matthiaskrgr:rollup-39zxrw1, r=matthiaskrgrbors-12/+0
Rollup of 8 pull requests Successful merges: - #111250 (Add Terminator conversion from MIR to SMIR, part #2) - #112310 (Add new Tier-3 targets: `loongarch64-unknown-none*`) - #112334 (Add myself to highfive rotation) - #112340 (remove `TyCtxt::has_error_field` helper method) - #112343 (Prevent emitting `missing_docs` for `pub extern crate`) - #112350 (Avoid duplicate type sanitization of local decls in borrowck) - #112356 (Fix comment for `get_region_var_origins`) - #112358 (Remove default visitor impl in region constraint generation) r? `@ghost` `@rustbot` modify labels: rollup
2023-06-06Add -Ztrait-solver=next-coherenceMichael Goulet-0/+8
2023-06-06New trait solver is a property of inference contextMichael Goulet-1/+1
2023-06-06remove `has_error_field` helper methodlcnr-12/+0
2023-06-05cleanup some skip_binder -> subst_identityKyle Matsuda-1/+1
2023-06-05Remove redundant InferCtxtExt::fresh_item_substsMichael Goulet-1/+0
2023-06-04Use 128 bits for TypeId hashThom Chiovoloni-2/+11
- Switch TypeId to 128 bits - Hack around the fact that tracing-subscriber dislikes how TypeId is hashed - Remove lowering of type_id128 from rustc_codegen_llvm - Remove unnecessary `type_id128` intrinsic (just change return type of `type_id`) - Only hash the lower 64 bits of the TypeId - Reword comment
2023-06-02Rollup merge of #112183 - compiler-errors:new-solver-anon-ct, r=BoxyUwUMichael Goulet-9/+0
Normalize anon consts in new solver We don't do any of that `expand_abstract_consts` stuff so this isn't sufficient to make GCE work, but it does allow, e.g. `[(); 1]: Default`, to solve. r? `@BoxyUwU`
2023-06-02Rollup merge of #112168 - scottmcm:lower-div-rem-unchecked-to-mir, r=oli-obkMichael Goulet-4/+9
Lower `unchecked_div`/`_rem` to MIR's `BinOp::Div`/`Rem` As described in <https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/enum.BinOp.html#variant.Div>, the ordinary `BinOp`s for these are already UB for division by zero ([or overflow](https://llvm.org/docs/LangRef.html#sdiv-instruction), [demo](https://rust.godbolt.org/z/71e7P7Exh)), as MIR building is responsible for inserting code to panic for those cases regardless of whether the overflow checks are enabled. So we can lower these in the same arm that lowers `wrapping_add` to MIR `BinOp::Add` and such, as all these cases turn into ordinary `Rvalue::BinaryOp`s.
2023-06-02No more TyCtxt::lazy_normalizationMichael Goulet-9/+0
2023-06-02Separate AnonConst from ConstBlock in HIR.Camille GILLOT-9/+10
2023-06-02Rollup merge of #112189 - compiler-errors:bad-gen, r=cjgillotMatthias Krüger-4/+14
Debug-assert that closures and generators are made with the right number of substitutions Just in case.
2023-06-02Rollup merge of #112165 - fee1-dead-contrib:rn-defualtness, r=compiler-errorsMatthias Krüger-4/+5
Rename `impl_defaultness` to `defaultness` Since this isn't just about the `impl`.
2023-06-02Auto merge of #112198 - compiler-errors:rollup-o2xe4of, r=compiler-errorsbors-0/+15
Rollup of 7 pull requests Successful merges: - #111670 (Require that const param tys implement `ConstParamTy`) - #111914 (CFI: Fix cfi with async: transform_ty: unexpected GeneratorWitness(Bi…) - #112030 (Migrate `item_trait_alias` to Askama) - #112150 (Support 128-bit atomics on all x86_64 Apple targets) - #112174 (Fix broken link) - #112190 (Improve comments on `TyCtxt` and `GlobalCtxt`.) - #112193 (Check tuple elements are `Sized` in `offset_of`) Failed merges: - #112071 (Group rfcs tests) r? `@ghost` `@rustbot` modify labels: rollup
2023-06-01Rollup merge of #112190 - nnethercote:improve-comments-TyCtxt-GlobalCtxt, ↵Michael Goulet-0/+12
r=compiler-errors Improve comments on `TyCtxt` and `GlobalCtxt`. By adding some non-obvious information that took me a little while to figure out. r? `@compiler-errors`
2023-06-01Rollup merge of #111670 - compiler-errors:const-param-ty, r=BoxyUwUMichael Goulet-0/+3
Require that const param tys implement `ConstParamTy` 1. Require that const param tys implement `ConstParamTy` instead of using `search_for_adt_const_param_violation` 2. Add `StructuralPartialEq` as a supertrait for `ConstParamTy`, since we need to make sure that we derive *both* `PartialEq` and `Eq` 3. Implement `ConstParamTy` for tuples up to 12 (or whatever the default for tuples is) 4. Add some custom diagnostics to `ConstParamTy` errors, to avoid regressions from (1.). It's still not as great as it could be -- will point out inline in comments. r? `@BoxyUwU`
2023-06-02Auto merge of #111677 - fee1-dead-contrib:rustc_const_eval-translatable, ↵bors-359/+399
r=oli-obk,RalfJung Use translatable diagnostics in `rustc_const_eval` This PR: * adds a `no_span` parameter to `note` / `help` attributes when using `Subdiagnostic` to allow adding notes/helps without using a span * has minor tweaks and changes to error messages
2023-06-01Clarify when MIR `Div`/`Rem` trigger UBScott McMurray-4/+9
2023-06-02Improve comments on `TyCtxt` and `GlobalCtxt`.Nicholas Nethercote-0/+12
2023-06-01Assert that closures and generators are made with the right number of ↵Michael Goulet-4/+14
substitutions