about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src
AgeCommit message (Collapse)AuthorLines
2024-10-04Simplify bound var resolution.Camille GILLOT-29/+27
2024-10-04Remove stray fixmes.Camille GILLOT-3/+0
2024-10-04WfCheck opaques.Camille GILLOT-12/+31
2024-10-04rm `ItemKind::OpaqueTy`Noah Lev-211/+145
This introduce an additional collection of opaques on HIR, as they can no longer be listed using the free item list.
2024-10-04Account for `impl Trait {` when `impl Trait for Type {` was intendedEsteban Küber-7/+10
On editions where bare traits are never allowed, detect if the user has written `impl Trait` with no type, silence any dyn-compatibility errors, and provide a structured suggestion for the potentially missing type: ``` error[E0782]: trait objects must include the `dyn` keyword --> $DIR/missing-for-type-in-impl.rs:8:6 | LL | impl Foo<i64> { | ^^^^^^^^ | help: add `dyn` keyword before this trait | LL | impl dyn Foo<i64> { | +++ help: you might have intended to implement this trait for a given type | LL | impl Foo<i64> for /* Type */ { | ++++++++++++++ ```
2024-10-04Elaborate supertrait span correctly to label the error betterMichael Goulet-5/+15
2024-10-04Check elaborated projections from dyn don't mention unconstrained late bound ↵Michael Goulet-0/+50
lifetimes
2024-10-04Rollup merge of #130518 - scottmcm:stabilize-controlflow-extra, r=dtolnayJubilee-1/+0
Stabilize the `map`/`value` methods on `ControlFlow` And fix the stability attribute on the `pub use` in `core::ops`. libs-api in https://github.com/rust-lang/rust/issues/75744#issuecomment-2231214910 seemed reasonably happy with naming for these, so let's try for an FCP. Summary: ```rust impl<B, C> ControlFlow<B, C> { pub fn break_value(self) -> Option<B>; pub fn map_break<T>(self, f: impl FnOnce(B) -> T) -> ControlFlow<T, C>; pub fn continue_value(self) -> Option<C>; pub fn map_continue<T>(self, f: impl FnOnce(C) -> T) -> ControlFlow<B, T>; } ``` Resolves #75744 ``@rustbot`` label +needs-fcp +t-libs-api -t-libs --- Aside, in case it keeps someone else from going down the same dead end: I looked at the `{break,continue}_value` methods and tried to make them `const` as part of this, but that's disallowed because of not having `const Drop`, so put it back to not even unstably-const.
2024-10-04Rollup merge of #131202 - Urgau:wide-ptrs-compiler, r=jieyouxuGuillaume Gomez-2/+2
Use wide pointers consistenly across the compiler This PR replace every use of "fat pointer" for the more recent "wide pointer" terminology. Since some time T-lang as preferred the "wide pointer" terminology, as can be seen on [the last RFCs](https://github.com/search?q=repo%3Arust-lang%2Frfcs+%22wide+pointer%22&type=code), on some [lints](https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#ambiguous-wide-pointer-comparisons), but also in [the reference](https://doc.rust-lang.org/stable/reference/expressions/operator-expr.html?highlight=wide%20pointer#pointer-to-pointer-cast). Currently we have a [mix of both](https://github.com/search?q=repo%3Arust-lang%2Frust+%22wide+pointer%22&type=code) (including in error messages), which isn't great, but with this PR no more. r? `@jieyouxu` (feel free to re-roll)
2024-10-04Use wide pointers consistenly across the compilerUrgau-2/+2
2024-10-03Rollup merge of #131183 - compiler-errors:opaque-ty-origin, r=estebankMatthias Krüger-59/+89
Refactoring to `OpaqueTyOrigin` Pulled out of a larger PR that uses these changes to do cross-crate encoding of opaque origin, so we can use them for edition 2024 migrations. These changes should be self-explanatory on their own, tho 😄
2024-10-02Move in_trait into OpaqueTyOriginMichael Goulet-55/+83
2024-10-02Use named fields for OpaqueTyOriginMichael Goulet-16/+18
2024-10-02Remove redundant in_trait from hir::TyKind::OpaqueDefMichael Goulet-4/+4
2024-10-02Handle `rustc-hir-analysis` cases of `rustc::potential_query_instability` lintismailarilik-16/+15
2024-10-01Remove unnamed field featureMichael Goulet-198/+4
2024-09-30Rollup merge of #131038 - onkoe:fix/adt_const_params_leak_118179, ↵Matthias Krüger-5/+12
r=compiler-errors Fix `adt_const_params` leaking `{type error}` in error msg Fixes the confusing diagnostic described in #118179. (users would see `{type error}` in some situations, which is pretty weird) `adt_const_params` tracking issue: #95174
2024-09-30Validate ExistentialPredicate argsMichael Goulet-2/+1
2024-09-29fix(hir_analysis/wfcheck): don't leak {type error}Barrett Ray-5/+12
avoid `{type error}` being leaked in user-facing messages, particularly when using the `adt_const_params` feature
2024-09-30Auto merge of #129499 - fee1-dead-contrib:supereffects, r=compiler-errorsbors-31/+42
properly elaborate effects implied bounds for super traits Summary: This PR makes it so that we elaborate `<T as Tr>::Fx: EffectsCompat<somebool>` into `<T as SuperTr>::Fx: EffectsCompat<somebool>` when we know that `trait Tr: ~const SuperTr`. Some discussion at https://github.com/rust-lang/project-const-traits/issues/2. r? project-const-traits `@rust-lang/project-const-traits:` how do we feel about this approach?
2024-09-27Rollup merge of #130826 - fmease:compiler-mv-obj-safe-dyn-compat, ↵Matthias Krüger-42/+46
r=compiler-errors Compiler: Rename "object safe" to "dyn compatible" Completed T-lang FCP: https://github.com/rust-lang/lang-team/issues/286#issuecomment-2338905118. Tracking issue: https://github.com/rust-lang/rust/issues/130852 Excludes `compiler/rustc_codegen_cranelift` (to be filed separately). Includes Stable MIR. Regarding https://github.com/rust-lang/rust/labels/relnotes, I guess I will manually open a https://github.com/rust-lang/rust/labels/relnotes-tracking-issue since this change affects everything (compiler, library, tools, docs, books, everyday language). r? ghost
2024-09-27properly elaborate effects implied bounds for super traitsDeadbeef-31/+42
2024-09-26Make new information notes instead of labelsJonathan Birk-6/+6
2024-09-25Stabilize the `map`/`value` methods on `ControlFlow`Scott McMurray-1/+0
And fix the stability attribute on the `pub use` in `core::ops`.
2024-09-25Add a few more tests, commentsMichael Goulet-0/+6
2024-09-25Pull out into helper functionMichael Goulet-99/+112
2024-09-25Collect relevant item bounds from trait clauses for nested rigid ↵Michael Goulet-10/+216
projections, GATs
2024-09-25Compiler: Rename "object safe" to "dyn compatible"León Orell Valerian Liehr-42/+46
2024-09-24Separate collection of crate-local inherent impls from error reportingMichael Goulet-22/+27
2024-09-23Check ABI target compatibility for function pointersTamme Dittrich-15/+37
This check was previously only performed on functions not function pointers. Co-authored-by: Folkert <folkert@folkertdev.nl>
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-206/+168
2024-09-21Rollup merge of #130666 - compiler-errors:super-bounds, r=fee1-dead,fmeaseMichael Goulet-11/+84
Assert that `explicit_super_predicates_of` and `explicit_item_super_predicates` truly only contains bounds for the type itself We distinguish _implied_ predicates (anything that is implied from elaborating a trait bound) from _super_ predicates, which are are the subset of implied predicates that share the same self type as the trait predicate we're elaborating. This was originally done in #107614, which fixed a large class of ICEs and strange errors where the compiler expected the self type of a trait predicate not to change when elaborating super predicates. Specifically, super predicates are special for various reasons: they're the valid candidates for trait upcasting, are the only predicates we elaborate when doing closure signature inference, etc. So making sure that we get this list correct and don't accidentally "leak" any other predicates into this list is quite important. This PR adds some debug assertions that we're in fact not doing so, and it fixes an oversight in the effect desugaring rework.
2024-09-21Don't elaborate effects predicates into bounds list unless we're actually ↵Michael Goulet-1/+8
collecting implied bounds, not super bounds
2024-09-21Assert that explicit_super_predicates_of and explicit_item_bounds truly only ↵Michael Goulet-10/+76
bounds for the type itself
2024-09-21More tests and tweak commentsMichael Goulet-4/+15
2024-09-20Resolve self type alias in impl for RTNMichael Goulet-1/+25
2024-09-20Add missing diagnostics and flesh out testsMichael Goulet-12/+35
2024-09-20Flesh out some TODOsMichael Goulet-17/+93
2024-09-20Implement RTN in resolve_bound_vars and HIR ty loweringMichael Goulet-132/+398
2024-09-20Conditionally allow lowering RTN (..) in pathsMichael Goulet-1/+21
2024-09-20Auto merge of #124895 - obeis:static-mut-hidden-ref, r=compiler-errorsbors-58/+0
Disallow hidden references to mutable static Closes #123060 Tracking: - https://github.com/rust-lang/rust/issues/123758
2024-09-18Explicitly mark a hack as a HACK and elaborate its commentLeón Orell Valerian Liehr-7/+8
2024-09-18Do not ICE with incorrect empty suggestionEsteban Küber-1/+11
When we have two types with the same name, one without type parameters and the other with type parameters and a derive macro, we were before incorrectly suggesting to remove type parameters from the former, which ICEd because we were suggesting to remove nothing. We now gate against this. The output is still not perfect. E0107 should explicitly detect this case and provide better context, but for now let's avoid the ICE.
2024-09-18Rollup merge of #130116 - veera-sivarajan:freeze-suggestions, r=chenyukangMatthias Krüger-2/+2
Implement a Method to Seal `DiagInner`'s Suggestions This PR adds a method on `DiagInner` called `.seal_suggestions()` to prevent new suggestions from being added while preserving existing suggestions. This is useful because currently there is no way to prevent new suggestions from being added to a diagnostic. `.disable_suggestions()` is the closest but it gets rid of all suggestions before and after the call. Therefore, `.seal_suggestions()` can be used when, for example, misspelled keyword is detected and reported. In such cases, we may want to prevent other suggestions from being added to the diagnostic, as they would likely be meaningless once the misspelled keyword is identified. For context: https://github.com/rust-lang/rust/pull/129899#discussion_r1741307132 To store an additional state, the type of the `suggestions` field in `DiagInner` was changed into a three variant enum. While this change affects files across different crates, care was taken to preserve the existing code's semantics. This is validated by the fact that all UI tests pass without any modifications. r? chenyukang
2024-09-16Auto merge of #130439 - matthiaskrgr:rollup-1lkzo74, r=matthiaskrgrbors-5/+10
Rollup of 4 pull requests Successful merges: - #123436 (linker: Allow MSVC to use import libraries following the Meson/MinGW convention) - #130410 (Don't ICE when generating `Fn` shim for async closure with borrowck error) - #130412 (Don't ICE when RPITIT captures more method args than trait definition) - #130436 (Ignore reduce-fadd-unordered on SGX platform) r? `@ghost` `@rustbot` modify labels: rollup
2024-09-16Don't ICE when RPITIT captures more method args than trait definitionMichael Goulet-5/+10
2024-09-16Introduce distinct error codes for precise capturingMichael Goulet-1/+2
2024-09-16Do precise capturing arg validation in resolveMichael Goulet-6/+4
2024-09-13Disallow hidden references to mutable staticObei Sideg-58/+0
2024-09-13Auto merge of #107251 - dingxiangfei2009:let-chain-rescope, r=jieyouxubors-2/+12
Rescope temp lifetime in if-let into IfElse with migration lint Tracking issue #124085 This PR shortens the temporary lifetime to cover only the pattern matching and consequent branch of a `if let`. At the expression location, means that the lifetime is shortened from previously the deepest enclosing block or statement in Edition 2021. This warrants an Edition change. Coming with the Edition change, this patch also implements an edition lint to warn about the change and a safe rewrite suggestion to preserve the 2021 semantics in most cases. Related to #103108. Related crater runs: https://github.com/rust-lang/rust/pull/129466.