about summary refs log tree commit diff
path: root/compiler/rustc_middle
AgeCommit message (Collapse)AuthorLines
2024-01-05Auto merge of #117213 - oli-obk:check_item_type_cleanup, r=estebankbors-4/+0
Reorder check_item_type diagnostics so they occur next to the corresponding `check_well_formed` diagnostics The first commit is just a cleanup. The second commit moves most checks from `check_mod_item_types` into `check_well_formed`, invoking the checks in lockstep per-item instead of iterating over all items twice.
2024-01-04Make iteration order of collect_return_position_impl_trait_in_trait_tys ↵Michael Woerister-8/+9
query stable
2024-01-04Make iteration order of supported_target_features query stableMichael Woerister-1/+1
2024-01-04Make iteration order of trimmed_def_paths query stableMichael Woerister-4/+4
2024-01-04Make iteration order of region_scope_tree query stableMichael Woerister-25/+4
2024-01-04Make iteration order of named_variable_map, late_bound_vars_map, and ↵Michael Woerister-5/+5
resolve_bound_vars queries stable
2024-01-04Make iteration order of stability_index query stableMichael Woerister-6/+5
2024-01-04Make iteration order of wasm_import_module_map query stableMichael Woerister-1/+1
2024-01-04Make iteration order of inferred_outlives_crate query stableMichael Woerister-1/+1
2024-01-04Make iteration order of upstream_monomorphizations query stableMichael Woerister-2/+2
2024-01-04Make iteration order of crate_inherent_impls query result stable.Michael Woerister-1/+2
2024-01-04Replace a number of FxHashMaps/Sets with stable-iteration-order alternatives.Michael Woerister-10/+12
2024-01-04Split StableCompare trait out of StableOrd trait.Michael Woerister-1/+1
StableCompare is a companion trait to `StableOrd`. Some types like `Symbol` can be compared in a cross-session stable way, but their `Ord` implementation is not stable. In such cases, a `StableOrd` implementation can be provided to offer a lightweight way for stable sorting. (The more heavyweight option is to sort via `ToStableHashKey`, but then sorting needs to have access to a stable hashing context and `ToStableHashKey` can also be expensive as in the case of `Symbol` where it has to allocate a `String`.)
2024-01-04Remove `is_lint` field from `Level::Error`.Nicholas Nethercote-1/+1
Because it's redundant w.r.t. `Diagnostic::is_lint`, which is present for every diagnostic level. `struct_lint_level_impl` was the only place that set the `Error` field to `true`, and it's also the only place that calls `Diagnostic::is_lint()` to set the `is_lint` field.
2024-01-04Remove `-Zdump-mir-spanview`Zalathar-654/+0
2024-01-04Check yield terminator's resume type in borrowckMichael Goulet-0/+17
2024-01-04Remove unused `struct_error` function.Nicholas Nethercote-15/+6
2024-01-03Track `HirId` instead of `Span` in `ObligationCauseCode::SizedArgumentType`Esteban Küber-1/+1
This gets us more accurate suggestions.
2024-01-03Rollup merge of #119476 - fmease:pp-always-const-trait-preds, r=compiler-errorsLeón Orell Valerian Liehr-12/+21
Pretty-print always-const trait predicates correctly Follow-up to #119099. r? fee1-dead
2024-01-03Rollup merge of #119444 - compiler-errors:closure-or-coroutine, r=oli-obkLeón Orell Valerian Liehr-12/+13
Rename `TyCtxt::is_closure` to `TyCtxt::is_closure_or_coroutine` This function has always been used to test whether the def-id was a closure **or** coroutine: https://github.com/rust-lang/rust/pull/118311/files#diff-69ebec59f7d38331dd1be84ede7957977dcaa39e30ed2869b04aa8c99b2079ccR552 -- the name is just confusing because it disagrees with other fns named `is_closure`, like `Ty::is_closure`. So let's rename it.
2024-01-03Rename some `Diagnostic` setters.Nicholas Nethercote-3/+3
`Diagnostic` has 40 methods that return `&mut Self` and could be considered setters. Four of them have a `set_` prefix. This doesn't seem necessary for a type that implements the builder pattern. This commit removes the `set_` prefixes on those four methods.
2024-01-02Merge check_for_entry_fn fully into check_mod_type_wfOli Scherer-4/+0
2024-01-02Reorder `check_item_type` diagnostics so they occur next to the ↵Oli Scherer-2/+2
corresponding `check_well_formed` diagnostics
2024-01-01Pretty-print always-const trait predicates correctlyLeón Orell Valerian Liehr-12/+21
2023-12-31Avoid specialization for AttrId deserializationbjorn3-0/+4
2023-12-31Remove almost all uses of specialization from the metadata encoding codebjorn3-93/+65
2023-12-31Avoid specialization for the Span Encodable and Decodable implsbjorn3-32/+33
2023-12-31rustc_lint: Make `LintLevelsProvider::current_specs()` return `&FxIndexMap`Martin Nordholts-2/+2
So that lint iteration order becomes predicitable. Discovered with `rustc::potential_query_instability`.
2023-12-31Auto merge of #119447 - Nilstrieb:STACKOVERFLOW, r=compiler-errorsbors-1/+2
Fix `<BoundConstness as Display>` There was infinite recursion, which is not very good. I'm not sure what the best way to implement this is, I just did something that felt right. r? `@fmease`
2023-12-31Inline utils.Camille GILLOT-0/+19
2023-12-31Inline successor_within_block.Camille GILLOT-0/+1
2023-12-31Inline dominator check.Camille GILLOT-0/+2
2023-12-30Update to bitflags 2 in the compilerNilstrieb-7/+13
This involves lots of breaking changes. There are two big changes that force changes. The first is that the bitflag types now don't automatically implement normal derive traits, so we need to derive them manually. Additionally, bitflags now have a hidden inner type by default, which breaks our custom derives. The bitflags docs recommend using the impl form in these cases, which I did.
2023-12-30Use the right type for upvarsMichael Goulet-6/+4
2023-12-30Fix `<BoundConstness as Display>`Nilstrieb-1/+2
There was infinite recursion, which is not very good. I'm not sure what the best way to implement this is, I just did something that felt right.
2023-12-30is_coroutine -> is_coroutine_or_closureMichael Goulet-7/+10
2023-12-29Auto merge of #119392 - compiler-errors:args-parts, r=Nilstriebbors-58/+48
make `ClosureArgsParts` and `CoroutineArgsParts` not generic I hope a few extra calls to `expect_ty` will not affect perf...
2023-12-28make ClosureArgsParts not genericMichael Goulet-58/+48
2023-12-28Movability doesn't need to be a query anymoreMichael Goulet-9/+8
2023-12-28Remove movability from TyKind::CoroutineMichael Goulet-35/+33
2023-12-28rustc_middle: Pretty-print negative bounds correctlyLeón Orell Valerian Liehr-21/+51
2023-12-27Auto merge of #119099 - fmease:always-const-trait-bounds, r=fee1-deadbors-11/+10
Introduce `const Trait` (always-const trait bounds) Feature `const_trait_impl` currently lacks a way to express “always const” trait bounds. This makes it impossible to define generic items like fns or structs which contain types that depend on const method calls (\*). While the final design and esp. the syntax of effects / keyword generics isn't set in stone, some version of “always const” trait bounds will very likely form a part of it. Further, their implementation is trivial thanks to the `effects` backbone. Not sure if this needs t-lang sign-off though. (\*): ```rs #![feature(const_trait_impl, effects, generic_const_exprs)] fn compute<T: const Trait>() -> Type<{ T::generate() }> { /*…*/ } struct Store<T: const Trait> where Type<{ T::generate() }>:, { field: Type<{ T::generate() }>, } ``` Lastly, “always const” trait bounds are a perfect fit for `generic_const_items`. ```rs #![feature(const_trait_impl, effects, generic_const_items)] const DEFAULT<T: const Default>: T = T::default(); ``` Previously, we (oli, fee1-dead and I) wanted to reinterpret `~const Trait` as `const Trait` in generic const items which would've been quite surprising and not very generalizable. Supersedes #117530. --- cc `@oli-obk` As discussed r? fee1-dead (or compiler)
2023-12-27Introduce `const Trait` (always-const trait bounds)León Orell Valerian Liehr-11/+10
2023-12-26Auto merge of #118431 - sjwang05:issue-44695, r=estebankbors-1/+18
Emit better suggestions for `&T == T` and `T == &T` Fixes #40660 Fixes #44695
2023-12-26Rollup merge of #119307 - compiler-errors:pat-lifetimes, r=NadrierilMichael Goulet-12/+27
Clean up some lifetimes in `rustc_pattern_analysis` This PR removes some redundant lifetimes. I figured out that we were shortening the lifetime of an arena-allocated `&'p DeconstructedPat<'p>` to `'a DeconstructedPat<'p>`, which forced us to carry both lifetimes when we could otherwise carry just one. This PR also removes and elides some unnecessary lifetimes. I also cherry-picked 0292eb9bb9b897f5c0926c6a8530877f67e7cc9b, and then simplified more lifetimes in `MatchVisitor`, which should make #119233 a very simple PR! r? Nadrieril
2023-12-26Auto merge of #119129 - jyn514:verbose, r=compiler-errors,estebankbors-10/+18
rework `-Zverbose` implements the changes described in https://github.com/rust-lang/compiler-team/issues/706 the first commit is only a name change from `-Zverbose` to `-Zverbose-internals` and does not change behavior. the second commit changes diagnostics. possible follow up work: - `ty::pretty` could print more info with `--verbose` than it does currently. `-Z verbose-internals` shows too much info in a way that's not helpful to users. michael had ideas about this i didn't fully understand: https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/uplift.20some.20-Zverbose.20calls.20and.20rename.20to.E2.80.A6.20compiler-team.23706/near/408984200 - `--verbose` should imply `-Z write-long-types-to-disk=no`. the code in `ty_string_with_limit` should take `--verbose` into account (apparently this affects `Ty::sort_string`, i'm not familiar with this code). writing a file to disk should suggest passing `--verbose`. r? `@compiler-errors` cc `@estebank`
2023-12-26Auto merge of #119258 - compiler-errors:closure-kind, r=eholkbors-23/+9
Make closures carry their own ClosureKind Right now, we use the "`movability`" field of `hir::Closure` to distinguish a closure and a coroutine. This is paired together with the `CoroutineKind`, which is located not in the `hir::Closure`, but the `hir::Body`. This is strange and redundant. This PR introduces `ClosureKind` with two variants -- `Closure` and `Coroutine`, which is put into `hir::Closure`. The `CoroutineKind` is thus removed from `hir::Body`, and `Option<Movability>` no longer needs to be a stand-in for "is this a closure or a coroutine". r? eholk
2023-12-26`thir::Visitor` only needs to visit `&'thir` dataNadrieril-12/+27
2023-12-26Auto merge of #119146 - nnethercote:rm-DiagCtxt-api-duplication, ↵bors-39/+44
r=compiler-errors Remove `DiagCtxt` API duplication `DiagCtxt` defines the internal API for creating and emitting diagnostics: methods like `struct_err`, `struct_span_warn`, `note`, `create_fatal`, `emit_bug`. There are over 50 methods. Some of these methods are then duplicated across several other types: `Session`, `ParseSess`, `Parser`, `ExtCtxt`, and `MirBorrowckCtxt`. `Session` duplicates the most, though half the ones it does are unused. Each duplicated method just calls forward to the corresponding method in `DiagCtxt`. So this duplication exists to (in the best case) shorten chains like `ecx.tcx.sess.parse_sess.dcx.emit_err()` to `ecx.emit_err()`. This API duplication is ugly and has been bugging me for a while. And it's inconsistent: there's no real logic about which methods are duplicated, and the use of `#[rustc_lint_diagnostic]` and `#[track_caller]` attributes vary across the duplicates. This PR removes the duplicated API methods and makes all diagnostic creation and emission go through `DiagCtxt`. It also adds `dcx` getter methods to several types to shorten chains. This approach scales *much* better than API duplication; indeed, the PR adds `dcx()` to numerous types that didn't have API duplication: `TyCtxt`, `LoweringCtxt`, `ConstCx`, `FnCtxt`, `TypeErrCtxt`, `InferCtxt`, `CrateLoader`, `CheckAttrVisitor`, and `Resolver`. These result in a lot of changes from `foo.tcx.sess.emit_err()` to `foo.dcx().emit_err()`. (You could do this with more types, but it gets into diminishing returns territory for types that don't emit many diagnostics.) After all these changes, some call sites are more verbose, some are less verbose, and many are the same. The total number of lines is reduced, mostly because of the removed API duplication. And consistency is increased, because calls to `emit_err` and friends are always preceded with `.dcx()` or `.dcx`. r? `@compiler-errors`
2023-12-25Only regular coroutines have movabilityMichael Goulet-9/+9