about summary refs log tree commit diff
path: root/compiler/rustc_middle
AgeCommit message (Collapse)AuthorLines
2023-12-25Remove unnecessary body_expr_countMichael Goulet-14/+0
2023-12-24Auto merge of #119139 - michaelwoerister:cleanup-stable-source-file-id, ↵bors-23/+16
r=cjgillot Unify SourceFile::name_hash and StableSourceFileId This PR adapts the existing `StableSourceFileId` type so that it can be used instead of the `name_hash` field of `SourceFile`. This simplifies a few things that were kind of duplicated before. The PR should also fix issues https://github.com/rust-lang/rust/issues/112700 and https://github.com/rust-lang/rust/issues/115835, but I was not able to reproduce these issues in a regression test. As far as I can tell, the root cause of these issues is that the id of the originating crate is not hashed in the `HashStable` impl of `Span` and thus cache entries that should have been considered invalidated were loaded. After this PR, the `stable_id` field of `SourceFile` includes information about the originating crate, so that ICE should not occur anymore.
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-2/+2
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-37/+42
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-24/+53
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-22Rollup merge of #119171 - nnethercote:cleanup-errors-4, r=compiler-errorsMichael Goulet-28/+15
Cleanup error handlers: round 4 More `rustc_errors` cleanups. A sequel to #118933. r? `@compiler-errors`
2023-12-23Give `DiagnosticBuilder` a default type.Nicholas Nethercote-5/+2
`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-23Streamline `struct_lint_level`.Nicholas Nethercote-23/+13
We can just get the error level in the `match` and then use `DiagnosticBuilder::new`. This then means a number of `DiagCtxt` functions are no longer needed, because this was the one place that used them. Note: the commit changes the treatment of spans for `Expect`, which was different to all the other cases, but this has no apparent effect.
2023-12-22Split coroutine desugaring kind from sourceMichael Goulet-24/+53
2023-12-22update cfg(bootstrap)sPietro Albini-1/+0
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-20Auto merge of #119136 - petrochenkov:feedvis3, r=WaffleLapkinbors-4/+21
resolve: Eagerly feed closure visibilities Also factor out all tcx-dependent operations performed for every created definition into `TyCtxt::create_def`. Addresses https://github.com/rust-lang/rust/pull/118657#discussion_r1421424277
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-20Rollup merge of #119071 - lcnr:overflowo, r=compiler-errorsMatthias Krüger-4/+31
-Znext-solver: adapt overflow rules to avoid breakage Do not erase overflow constraints if they are from equating the impl header when normalizing[^1]. This should be the minimal change to not break crates depending on the old project behavior of "apply impl constraints while only lazily evaluating any nested goals". Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/70, see https://hackmd.io/ATf4hN0NRY-w2LIVgeFsVg for the reasoning behind this. Only keeping constraints on overflow for `normalize-to` goals as that's the only thing needed for backcompat. It also allows us to not track the origin of root obligations. The issue with root goals would be something like the following: ```rust trait Foo {} trait Bar {} trait FooBar {} impl<T: Foo + Bar> FooBar for T {} // These two should behave the same, rn we can drop constraints for both, // but if we don't drop `Misc` goals we would only drop the constraints for // `FooBar` unless we track origins of root obligations. fn func1<T: Foo + Bar>() {} fn func2<T: FooBaz>() {} ``` [^1]: mostly, the actual rules are slightly different r? ``@compiler-errors``
2023-12-20Hide foreign `#[doc(hidden)]` paths in import suggestionsJules Bertholet-1/+1
2023-12-19Unify SourceFile::name_hash and StableSourceFileIdMichael Woerister-23/+16
2023-12-19rename to verbose-internalsjyn-10/+18
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-19Auto merge of #119093 - michaelwoerister:mcp533-18, r=petrochenkovbors-3/+3
Replace some instances of FxHashMap/FxHashSet with stable alternatives (mostly in rustc_hir and rustc_ast_lowering) Part of https://github.com/rust-lang/compiler-team/issues/533. We should be getting close to being able to remove the HashStable impl of HashMap.
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-18Check FnPtr/FnDef built-in fn traits correctly with effectsMichael Goulet-1/+1
2023-12-18Replace some instances of FxHashMap/FxHashSet with stable alternatives ↵Michael Woerister-3/+3
(mostly in rustc_hir and rustc_ast_lowering) Part of https://github.com/rust-lang/compiler-team/issues/533
2023-12-18dont discard overflow from normalizes-to goalslcnr-0/+3
2023-12-18track the source of nested goalslcnr-4/+28
2023-12-18Rename many `DiagCtxt` arguments.Nicholas Nethercote-3/+3
2023-12-18Rename `Session::span_diagnostic` as `Session::dcx`.Nicholas Nethercote-5/+5
2023-12-18Rename `HandlerInner` as `DiagCtxtInner`.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-2/+5
Also feed missing visibilities for import stems and trait impl items, which were previously evaluated lazily.
2023-12-16Provide better suggestions for T == &T and &T == Tsjwang05-1/+18
2023-12-16Remove unnecessary constness from ProjectionCandidateMichael Goulet-4/+2
2023-12-15Rollup merge of #119003 - matthiaskrgr:nein_clone, r=NadrierilJubilee-4/+4
NFC: do not clone types that are copy
2023-12-15NFC: do not clone types that are copyMatthias Krüger-4/+4
2023-12-15Rollup merge of #118727 - compiler-errors:lint-decorate, r=WaffleLapkinJubilee-46/+13
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-26/+3
2023-12-15Don't pass lint back out of lint decoratorMichael Goulet-20/+10
2023-12-15Annotate some more bugsMichael Goulet-7/+4
2023-12-15Rollup merge of #118888 - compiler-errors:uplift-more-things, r=jackh726Matthias Krüger-98/+33
Uplift `TypeAndMut` and `ClosureKind` to `rustc_type_ir` Uplifts `TypeAndMut` and `ClosureKind` I know I said I was just going to get rid of `TypeAndMut` (https://github.com/rust-lang/types-team/issues/124) but I think this is much simpler, lol r? `@jackh726` or `@lcnr`
2023-12-14Rollup merge of #118933 - nnethercote:cleanup-errors-even-more, ↵Jubilee-2/+4
r=compiler-errors Cleanup errors handlers even more A sequel to #118587. r? `@compiler-errors`
2023-12-15Change `msg: impl Into<String>` for bug diagnostics.Nicholas Nethercote-2/+4
To `msg: impl Into<DiagnosticMessage>`, like all the other diagnostics. For consistency.
2023-12-14Move special methods from ClosureKind back into rustcMichael Goulet-24/+20
2023-12-14update use of feature flagslcnr-2/+2
2023-12-14rename `-Ztrait-solver` to `-Znext-solver`lcnr-6/+2
2023-12-14Auto merge of #117749 - aliemjay:perf-canon-cache, r=lcnrbors-3/+70
cache param env canonicalization Canonicalize ParamEnv only once and store it. Then whenever we try to canonicalize `ParamEnvAnd<'tcx, T>` we only have to canonicalize `T` and then merge the results. Prelimiary results show ~3-4% savings in diesel and serde benchmarks. Best to review commits individually. Some commits have a short description. Initial implementation had a soundness bug (https://github.com/rust-lang/rust/pull/117749#issuecomment-1840453387) due to cache invalidation: - When canonicalizing `Ty<'?0>` we first try to resolve region variables in the current InferCtxt which may have a constraint `?0 == 'static`. This means that we register `Ty<'?0> => Canonical<Ty<'static>>` in the cache, which is obviously incorrect in another inference context. - This is fixed by not doing region resolution when canonicalizing the query *input* (vs. response), which is the only place where ParamEnv is used, and then in a later commit we *statically* guard against any form of inference variable resolution of the cached canonical ParamEnv's. r? `@ghost`
2023-12-14make infcx optional in canonicalizerAli MJ Al-Nasrawy-2/+10
This doesn't change behavior. It should prevent unintentional resolution of inference variables during canonicalization, which previously caused a soundness bug. See PR description for more.