about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty
AgeCommit message (Collapse)AuthorLines
2024-01-05Rollup merge of #119151 - Jules-Bertholet:no-foreign-doc-hidden-suggest, ↵Matthias Krüger-1/+1
r=davidtwco Hide foreign `#[doc(hidden)]` paths in import suggestions Stops the compiler from suggesting to import foreign `#[doc(hidden)]` paths. ```@rustbot``` label A-suggestion-diagnostics
2024-01-04Make iteration order of collect_return_position_impl_trait_in_trait_tys ↵Michael Woerister-3/+4
query stable
2024-01-04Make iteration order of trimmed_def_paths query stableMichael Woerister-3/+3
2024-01-04Make iteration order of inferred_outlives_crate query stableMichael Woerister-1/+1
2024-01-04Make iteration order of crate_inherent_impls query result stable.Michael Woerister-1/+2
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-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-11/+12
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-01Pretty-print always-const trait predicates correctlyLeón Orell Valerian Liehr-12/+21
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-30Update to bitflags 2 in the compilerNilstrieb-4/+8
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-6/+9
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-2/+7
2023-12-28Remove movability from TyKind::CoroutineMichael Goulet-26/+22
2023-12-28rustc_middle: Pretty-print negative bounds correctlyLeón Orell Valerian Liehr-21/+51
2023-12-27Introduce `const Trait` (always-const trait bounds)León Orell Valerian Liehr-11/+10
2023-12-26Auto merge of #119129 - jyn514:verbose, r=compiler-errors,estebankbors-5/+5
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-5/+5
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-26Auto merge of #119146 - nnethercote:rm-DiagCtxt-api-duplication, ↵bors-21/+26
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-5/+5
2023-12-23Auto merge of #119218 - Nadrieril:nested-opaque-reveal, r=compiler-errorsbors-18/+73
Exhaustiveness: Reveal empty opaques in depth Follow-up to https://github.com/rust-lang/rust/pull/116821. As noted [there](https://github.com/rust-lang/rust/pull/116821#discussion_r1376673420), the current implementation doesn't detect emptiness of opaques when the opaque is nested inside a type. This doesn't matter for stable behavior (which ignores nested empty types anyway) but does matter for the [`exhaustive_patterns`](https://github.com/rust-lang/rust/issues/51085)/[`min_exhaustive_patterns`](https://github.com/rust-lang/rust/pull/118803) features. This PR fixes this behavior by adding `InhabitedPredicate::apply_reveal_opaque` that considers opaque types when determining inhabitedness. r? `@compiler-errors`
2023-12-24Remove more `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-1/+1
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-20/+25
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-23Remove an unused diagnostic structDeadbeef-8/+0
this is used at `rustc_middle::error`, is duplicated here somehow
2023-12-23Reveal empty opaques in depthNadrieril-18/+73
2023-12-22Rollup merge of #119198 - compiler-errors:desugaring, r=eholkMichael Goulet-11/+26
Split coroutine desugaring kind from source What a coroutine is desugared from (gen/async gen/async) should be separate from where it comes (fn/block/closure).
2023-12-23Give `DiagnosticBuilder` a default type.Nicholas Nethercote-1/+1
`IntoDiagnostic` defaults to `ErrorGuaranteed`, because errors are the most common diagnostic level. It makes sense to do likewise for the closely-related (and much more widely used) `DiagnosticBuilder` type, letting us write `DiagnosticBuilder<'a, ErrorGuaranteed>` as just `DiagnosticBuilder<'a>`. This cuts over 200 lines of code due to many multi-line things becoming single line things.
2023-12-22Split coroutine desugaring kind from sourceMichael Goulet-11/+26
2023-12-22Auto merge of #119097 - nnethercote:fix-EmissionGuarantee, r=compiler-errorsbors-5/+6
Fix `EmissionGuarantee` There are some problems with the `DiagCtxt` API related to `EmissionGuarantee`. This PR fixes them. r? `@compiler-errors`
2023-12-20resolve: Eagerly feed closure visibilitiesVadim Petrochenkov-4/+21
Also factor out all tcx-dependent operations performed for every created definition into `TyCtxt::create_def`
2023-12-20Hide foreign `#[doc(hidden)]` paths in import suggestionsJules Bertholet-1/+1
2023-12-19rename to verbose-internalsjyn-5/+5
2023-12-19Remove param env from relation altogetherMichael Goulet-6/+0
2023-12-19Remove unnecessary param-env from lexical region resolution and fully ↵Michael Goulet-4/+5
structural relations
2023-12-19Do not evaluate in structurally_relate_tysMichael Goulet-7/+3
2023-12-19Add `level` arg to `into_diagnostic`.Nicholas Nethercote-5/+6
And make all hand-written `IntoDiagnostic` impls generic, by using `DiagnosticBuilder::new(dcx, level, ...)` instead of e.g. `dcx.struct_err(...)`. This means the `create_*` functions are the source of the error level. This change will let us remove `struct_diagnostic`. Note: `#[rustc_lint_diagnostics]` is added to `DiagnosticBuilder::new`, it's necessary to pass diagnostics tests now that it's used in `into_diagnostic` functions.
2023-12-18Replace some instances of FxHashMap/FxHashSet with stable alternatives ↵Michael Woerister-1/+1
(mostly in rustc_hir and rustc_ast_lowering) Part of https://github.com/rust-lang/compiler-team/issues/533
2023-12-18Rename many `DiagCtxt` arguments.Nicholas Nethercote-3/+3
2023-12-18Rename `Session::span_diagnostic` as `Session::dcx`.Nicholas Nethercote-1/+1
2023-12-18Rename `Handler` as `DiagCtxt`.Nicholas Nethercote-2/+2
2023-12-18resolve: Replace visibility table in resolver outputs with query feedingVadim Petrochenkov-1/+1
Also feed missing visibilities for import stems and trait impl items, which were previously evaluated lazily.
2023-12-15Rollup merge of #119003 - matthiaskrgr:nein_clone, r=NadrierilJubilee-2/+2
NFC: do not clone types that are copy
2023-12-15NFC: do not clone types that are copyMatthias Krüger-2/+2
2023-12-15Rollup merge of #118727 - compiler-errors:lint-decorate, r=WaffleLapkinJubilee-12/+6
Don't pass lint back out of lint decorator Change the decorator function in the signature of the `emit_lint`/`span_lint`/etc family of methods from `impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>` to `impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>)`. I consider it easier to read this way, especially when there's control flow involved. r? nnethercote though feel free to reassign
2023-12-15Fix commentsMichael Goulet-4/+0
2023-12-15Don't pass lint back out of lint decoratorMichael Goulet-8/+6