about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis
AgeCommit message (Collapse)AuthorLines
2024-09-20Flesh out some TODOsMichael Goulet-18/+94
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/+23
2024-09-20Auto merge of #124895 - obeis:static-mut-hidden-ref, r=compiler-errorsbors-77/+0
Disallow hidden references to mutable static Closes #123060 Tracking: - https://github.com/rust-lang/rust/issues/123758
2024-09-20TL note: current means targetJubilee Young-1/+1
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-77/+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.
2024-09-12Implement a Method to Seal `DiagInner`'s SuggestionsVeera-2/+2
2024-09-12Rollup merge of #130250 - compiler-errors:useless-conversion, r=jieyouxuStuart Cook-2/+2
Fix `clippy::useless_conversion` Self-explanatory. Probably the last clippy change I'll actually put up since this is the only other one I've actually seen in the wild.
2024-09-12Rollup merge of #130235 - compiler-errors:nested-if, r=michaelwoeristerStuart Cook-83/+71
Simplify some nested `if` statements Applies some but not all instances of `clippy::collapsible_if`. Some ended up looking worse afterwards, though, so I left those out. Also applies instances of `clippy::collapsible_else_if` Review with whitespace disabled please.
2024-09-11Rollup merge of #130114 - eduardosm:needless-returns, r=compiler-errorsJubilee-2/+2
Remove needless returns detected by clippy in the compiler
2024-09-11clippy::useless_conversionMichael Goulet-2/+2
2024-09-11Also fix if in elseMichael Goulet-54/+48
2024-09-11Simplify some nested if statementsMichael Goulet-29/+23
2024-09-10Auto merge of #129403 - scottmcm:only-array-simd, r=compiler-errorsbors-20/+22
Ban non-array SIMD Nearing the end of https://github.com/rust-lang/compiler-team/issues/621 ! Currently blocked on ~~https://github.com/rust-lang/compiler-builtins/pull/673~~ ~~https://github.com/rust-lang/compiler-builtins/pull/674~~ ~~https://github.com/rust-lang/rust/pull/129400~~ ~~https://github.com/rust-lang/rust/pull/129481~~ for windows.
2024-09-11rescope temp lifetime in let-chain into IfElseDing Xiang Fei-2/+12
apply rules by span edition
2024-09-09Ban non-array SIMDScott McMurray-20/+22
2024-09-09Rollup merge of #130149 - GrigorenkoPV:lifetime-suggestion, r=cjgillotJubilee-17/+1
Helper function for formatting with `LifetimeSuggestionPosition`
2024-09-09Rollup merge of #130064 - folkertdev:fix-issue-129983, r=compiler-errorsMatthias Krüger-3/+9
fix ICE in CMSE type validation fixes #129983 tracking issue: https://github.com/rust-lang/rust/issues/81391 r? ``@compiler-errors``
2024-09-09Helper function for formatting with `LifetimeSuggestionPosition`Pavel Grigorenko-17/+1
2024-09-09Remove needless returns detected by clippy in the compilerEduardo Sánchez Muñoz-2/+2
2024-09-09do `PolyFnSig` -> `FnSig` conversion laterFolkert de Vries-5/+8
2024-09-08Auto merge of #130036 - weiznich:diagnostic_unstable_tracking, r=compiler-errorsbors-2/+0
Correctly handle stability of `#[diagnostic]` attributes This commit changes the way we treat the stability of attributes in the `#[diagnostic]` namespace. Instead of relaying on ad-hoc checks to ensure at call side that a certain attribute is really usable at that location it centralises the logic to one place. For diagnostic attributes comming from other crates it just skips serializing attributes that are not stable and that do not have the corresponding feature enabled. For attributes from the current crate we can just use the feature information provided by `TyCtx`. r​? `@compiler-errors`
2024-09-07Auto merge of #126161 - Bryanskiy:delegation-generics-4, r=petrochenkovbors-120/+357
Delegation: support generics in associated delegation items This is a continuation of https://github.com/rust-lang/rust/pull/125929. [design](https://github.com/Bryanskiy/posts/blob/master/delegation%20in%20generic%20contexts.md) Generic parameters inheritance was implemented in all contexts. Generic arguments are not yet supported. r? `@petrochenkov`
2024-09-07fix ICE in CMSE type validationFolkert de Vries-5/+8
2024-09-06Auto merge of #128776 - Bryanskiy:deep-reject-ctxt, r=lcnrbors-2/+3
Use `DeepRejectCtxt` to quickly reject `ParamEnv` candidates The description is on the [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/144729-t-types/topic/.5Basking.20for.20help.5D.20.60DeepRejectCtxt.60.20for.20param.20env.20candidates) r? `@lcnr`
2024-09-06Revert ed7bdbb17b9c03fe3530e5e3f21b7c6c7879dbcaGeorg Semmler-2/+0
2024-09-05Delegation: support generics in associated delegation itemsBryanskiy-71/+204
2024-09-05Rollup merge of #129664 - ↵Matthias Krüger-19/+63
adetaylor:arbitrary-self-types-pointers-feature-gate, r=wesleywiser Arbitrary self types v2: pointers feature gate. The main `arbitrary_self_types` feature gate will shortly be reused for a new version of arbitrary self types which we are amending per [this RFC](https://github.com/rust-lang/rfcs/blob/master/text/3519-arbitrary-self-types-v2.md). The main amendments are: * _do_ support `self` types which can't safely implement `Deref` * do _not_ support generic `self` types * do _not_ support raw pointers as `self` types. This PR relates to the last of those bullet points: this strips pointer support from the current `arbitrary_self_types` feature. We expect this to cause some amount of breakage for crates using this unstable feature to allow raw pointer self types. If that's the case, we want to know about it, and we want crate authors to know of the upcoming changes. For now, this can be resolved by adding the new `arbitrary_self_types_pointers` feature to such crates. If we determine that use of raw pointers as self types is common, then we may maintain that as an unstable feature even if we come to stabilize the rest of the `arbitrary_self_types` support in future. If we don't hear that this PR is causing breakage, then perhaps we don't need it at all, even behind an unstable feature gate. [Tracking issue](https://github.com/rust-lang/rust/issues/44874) This is [step 4 of the plan outlined here](https://github.com/rust-lang/rust/issues/44874#issuecomment-2122179688)
2024-09-03Rollup merge of #127692 - veera-sivarajan:bugfix-125139, r=estebankMatthias Krüger-23/+55
Suggest `impl Trait` for References to Bare Trait in Function Header Fixes #125139 This PR suggests `impl Trait` when `&Trait` is found as a function parameter type or return type. This makes use of existing diagnostics by adding `peel_refs()` when checking for type equality. Additionaly, it makes a few other improvements: 1. Checks if functions inside impl blocks have bare trait in their headers. 2. Introduces a trait `NextLifetimeParamName` similar to the existing `NextTypeParamName` for suggesting a lifetime name. Also, abstracts out the common logic between the two trait impls. ### Related Issues I ran into a bunch of related diagnostic issues but couldn't fix them within the scope of this PR. So, I have created the following issues: 1. [Misleading Suggestion when Returning a Reference to a Bare Trait from a Function](https://github.com/rust-lang/rust/issues/127689) 2. [Verbose Error When a Function Takes a Bare Trait as Parameter](https://github.com/rust-lang/rust/issues/127690) 3. [Incorrect Suggestion when Returning a Bare Trait from a Function](https://github.com/rust-lang/rust/issues/127691) r​? ```@estebank``` since you implemented #119148
2024-09-03Delegation refactoring: add builders for generics inheritanceBryanskiy-80/+184
2024-09-02Use `DeepRejectCtxt` to quickly reject `ParamEnv` candidatesBryanskiy-2/+3
2024-09-02chore: Fix typos in 'compiler' (batch 1)Alexander Cyon-6/+6
2024-08-31Rollup merge of #129767 - nnethercote:rm-extern-crate-tracing-4, r=jieyouxuMatthias Krüger-3/+31
Remove `#[macro_use] extern crate tracing`, round 4 Because explicit importing of macros via use items is nicer (more standard and readable) than implicit importing via #[macro_use]. Continuing the work from #124511, #124914, and #125434. After this PR no `rustc_*` crates use `#[macro_use] extern crate tracing` except for `rustc_codegen_gcc` which is a special case and I will do separately. r? ```@jieyouxu```
2024-08-30Some code review suggestions.Adrian Taylor-20/+18
2024-08-30Remove `#[macro_use] extern crate tracing` from `rustc_hir_analysis`.Nicholas Nethercote-3/+31
2024-08-29Stop using ty::GenericPredicates for non-predicates_of queriesMichael Goulet-35/+34
2024-08-28Auto merge of #129546 - compiler-errors:no-pred-on, r=fee1-deadbors-34/+22
Get rid of `predicates_defined_on` This is the uncontroversial part of #129532. This simply inlines the `predicates_defined_on` into into `predicates_of`. Nothing should change here logically.
2024-08-27Auto merge of #128506 - compiler-errors:by-move-body, r=cjgillotbors-5/+2
Stop storing a special inner body for the coroutine by-move body for async closures ...and instead, just synthesize an item which is treated mostly normally by the MIR pipeline. This PR does a few things: * We synthesize a new `DefId` for the by-move body of a closure, which has its `mir_built` fed with the output of the `ByMoveBody` MIR transformation, and some other relevant queries. * This has the `DefKind::ByMoveBody`, which we use to distinguish it from "real" bodies (that come from HIR) which need to be borrowck'd. Introduce `TyCtxt::is_synthetic_mir` to skip over `mir_borrowck` which is called by `mir_promoted`; borrowck isn't really possible to make work ATM since it heavily relies being called on a body generated from HIR, and is redundant by the construction of the by-move-body. * Remove the special `PassManager` hacks for handling the inner `by_move_body` stored within the coroutine's mir body. Instead, this body is fed like a regular MIR body, so it's goes through all of the `tcx.*_mir` stages normally (build -> promoted -> ...etc... -> optimized) ✨. * Remove the `InstanceKind::ByMoveBody` shim, since now we have a "regular" def id, we can just use `InstanceKind::Item`. This also allows us to remove the corresponding hacks from codegen, such as in `fn_sig_for_fn_abi` ✨. Notable remarks: * ~~I know it's kind of weird to be using `DefKind::Closure` here, since it's not a distinct closure but just a new MIR body. I don't believe it really matters, but I could also use a different `DefKind`... maybe one that we could use for synthetic MIR bodies in general?~~ edit: We're doing this now.
2024-08-27Arbitrary self types v2: pointers feature gate.Adrian Taylor-19/+65
The main `arbitrary_self_types` feature gate will shortly be reused for a new version of arbitrary self types which we are amending per [this RFC](https://github.com/rust-lang/rfcs/blob/master/text/3519-arbitrary-self-types-v2.md). The main amendments are: * _do_ support `self` types which can't safely implement `Deref` * do _not_ support generic `self` types * do _not_ support raw pointers as `self` types. This PR relates to the last of those bullet points: this strips pointer support from the current `arbitrary_self_types` feature. We expect this to cause some amount of breakage for crates using this unstable feature to allow raw pointer self types. If that's the case, we want to know about it, and we want crate authors to know of the upcoming changes. For now, this can be resolved by adding the new `arbitrary_self_types_pointers` feature to such crates. If we determine that use of raw pointers as self types is common, then we may maintain that as an unstable feature even if we come to stabilize the rest of the `arbitrary_self_types` support in future. If we don't hear that this PR is causing breakage, then perhaps we don't need it at all, even behind an unstable feature gate. [Tracking issue](https://github.com/rust-lang/rust/issues/44874) This is [step 4 of the plan outlined here](https://github.com/rust-lang/rust/issues/44874#issuecomment-2122179688)
2024-08-27Add `warn(unreachable_pub)` to `rustc_hir_analysis`.Nicholas Nethercote-145/+155
2024-08-26Stop using a special inner body for the coroutine by-move body for async ↵Michael Goulet-5/+2
closures
2024-08-26Rollup merge of #129590 - compiler-errors:ref-tykind, r=fmeaseMatthias Krüger-2/+2
Avoid taking reference of &TyKind It's already a ref anyways. Just a tiny cleanup here.