about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis
AgeCommit message (Collapse)AuthorLines
2023-11-25Rollup merge of #118288 - compiler-errors:is_some_and, r=lqd,dtolnayMichael Goulet-1/+1
Use `is_{some,ok}_and` more in the compiler slightly more fluent-reading code
2023-11-25Rollup merge of #118158 - nnethercote:reduce-fluent-boilerplate, ↵Michael Goulet-3/+1
r=compiler-errors Reduce fluent boilerplate Best reviewed one commit at a time. r? `@davidtwco`
2023-11-26Use `rustc_fluent_macro::fluent_messages!` directly.Nicholas Nethercote-2/+1
Currently we always do this: ``` use rustc_fluent_macro::fluent_messages; ... fluent_messages! { "./example.ftl" } ``` But there is no need, we can just do this everywhere: ``` rustc_fluent_macro::fluent_messages! { "./example.ftl" } ``` which is shorter.
2023-11-26Avoid need for `{D,Subd}iagnosticMessage` imports.Nicholas Nethercote-1/+0
The `fluent_messages!` macro produces uses of `crate::{D,Subd}iagnosticMessage`, which means that every crate using the macro must have this import: ``` use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage}; ``` This commit changes the macro to instead use `rustc_errors::{D,Subd}iagnosticMessage`, which avoids the need for the imports.
2023-11-25Get rid of infer vars in inherent assoc types selection by using probeSantiago Pastorino-47/+34
2023-11-25is_{some,ok}_andMichael Goulet-1/+1
2023-11-25Extract select_inherent_assoc_type_candidatesSantiago Pastorino-79/+95
2023-11-25Do not erase late bound regions, replace them with placeholdersSantiago Pastorino-114/+88
2023-11-25Remove HirId from QPath::LangItemMichael Goulet-1/+1
2023-11-24We should call eq instead of sup as we're relating Ty directly and not ↵Santiago Pastorino-4/+1
Binder<TraitRef>
2023-11-22Rollup merge of #118161 - compiler-errors:coroutine-obligation-opaques, r=lcnrMichael Goulet-4/+18
Allow defining opaques in `check_coroutine_obligations` In the new trait solver, when an obligation stalls on an unresolved coroutine witness, we will stash away the *root* obligation, even if the stalled obligation is only a distant descendent of the root obligation, since the new solver is purely recursive. This means that we may need to reprocess alias-relate obligations (and others) which may define opaque types in the new solver. Currently, we use the coroutine's def id as the defining anchor in `check_coroutine_obligations`, which will allow defining no opaque types, resulting in errors like: ``` error[E0271]: type mismatch resolving `{coroutine@<source>:6:5: 6:17} <: impl Clone` --> <source>:6:5 | 6 | / move |_: ()| { 7 | | let () = yield (); 8 | | } | |_____^ types differ ``` So this PR fixes the defining anchor and does the same trick as `check_opaque_well_formed`, where we manually compare opaques that were defined against their hidden types to make sure they weren't defined differently when processing these stalled coroutine obligations. r? `@lcnr` cc `@cjgillot`
2023-11-22Replace `no_ord_impl` with `orderable`.Nicholas Nethercote-0/+1
Similar to the previous commit, this replaces `newtype_index`'s opt-out `no_ord_impl` attribute with the opt-in `orderable` attribute.
2023-11-22Replace `custom_encodable` with `encodable`.Nicholas Nethercote-1/+0
By default, `newtype_index!` types get a default `Encodable`/`Decodable` impl. You can opt out of this with `custom_encodable`. Opting out is the opposite to how Rust normally works with autogenerated (derived) impls. This commit inverts the behaviour, replacing `custom_encodable` with `encodable` which opts into the default `Encodable`/`Decodable` impl. Only 23 of the 59 `newtype_index!` occurrences need `encodable`. Even better, there were eight crates with a dependency on `rustc_serialize` just from unused default `Encodable`/`Decodable` impls. This commit removes that dependency from those eight crates.
2023-11-22Allow defining opaques in check_coroutine_obligationsMichael Goulet-4/+18
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-59/+57
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-11-19Rollup merge of #118000 - compiler-errors:placeholder-ty-outlives, r=aliemjayMichael Goulet-0/+4
Make regionck care about placeholders in outlives components Currently, we don't consider a placeholder type `!T` to be a type component when it comes to processing type-outlives obligations. This means that they are essentially treated like unit values with no sub-components, and always outlive any region. This is problematic for `non_lifetime_binders`, and even more problematic for `with_negative_coherence`, since negative coherence uses placeholders as universals. This PR adds `Component::Placeholder` which acts much like `Component::Param`. This currently causes a regression in some non-lifetime-binders tests because `for<T> T: 'static` doesn't imply itself when processing outlives obligations, so code like this will fail: ``` fn foo() where for<T> T: 'static { foo() //~ fails } ``` Since the where clause doesn't imply itself. This requires making the `MatchAgainstHigherRankedOutlives` relation smarter when it comes to binders. r? types
2023-11-19Rollup merge of #117828 - Nilstrieb:astconv-hashmaps, r=petrochenkovMichael Goulet-10/+6
Avoid iterating over hashmaps in astconv
2023-11-19Make regionck care about placeholders in outlives componentsMichael Goulet-0/+4
2023-11-19Don't sort `span_suggestions`, leave that to callerEsteban Küber-1/+5
2023-11-19Avoid iterating over hashmaps in astconvNilstrieb-10/+6
2023-11-18Auto merge of #117525 - GKFX:remove_option_payload_ptr, r=petrochenkovbors-19/+0
Remove option_payload_ptr; redundant to offset_of The `option_payload_ptr` intrinsic is no longer required as `offset_of` supports traversing enums (#114208). This PR removes it in order to dogfood offset_of (as suggested at https://github.com/rust-lang/rust/issues/106655#issuecomment-1790907626). However, it will not build until those changes reach beta (which I think is within the next 8 days?) so I've opened it as a draft.
2023-11-17rename bound region instantiationlcnr-1/+1
- `erase_late_bound_regions` -> `instantiate_bound_regions_with_erased` - `replace_late_bound_regions_X` -> `instantiate_bound_regions_X`
2023-11-17replace unnecessary folder impls with fold_regionlcnr-24/+8
2023-11-16Remove option_payload_ptr; redundant to offset_ofGeorge Bateman-19/+0
2023-11-15Re-format code with new rustfmtMark Rousskov-17/+13
2023-11-15Bump cfg(bootstrap)sMark Rousskov-3/+3
2023-11-14finish `RegionKind` renamelcnr-35/+34
- `ReFree` -> `ReLateParam` - `ReEarlyBound` -> `ReEarlyParam`
2023-11-13Auto merge of #117881 - TaKO8Ki:rollup-n7jtmgj, r=TaKO8Kibors-3/+2
Rollup of 5 pull requests Successful merges: - #117737 (Remove `-Zkeep-hygiene-data`.) - #117830 (Small improvements in object lifetime default code) - #117858 (Compute layout with spans for better cycle errors in coroutines) - #117863 (Remove some unused stuff from `rustc_index`) - #117872 (Cranelift isn't available on non-nightly channels) r? `@ghost` `@rustbot` modify labels: rollup
2023-11-14Rollup merge of #117830 - Nilstrieb:object-lifetime-default-nits, r=cjgillotTakayuki Maeda-3/+2
Small improvements in object lifetime default code I found those while trying to understand how the code works.
2023-11-13Auto merge of #117876 - lcnr:region-kind-rename, r=BoxyUwUbors-19/+21
`ReLateBound` -> `ReBound` first step of https://github.com/rust-lang/types-team/issues/95 already fairly large xx there's some future work here I intentionally did not contribute as part of this PR, from my notes: - `DescriptionCtx` to `DescriptionCtxt` - what is `CheckRegions::Bound`? - `collect_late_bound_regions` et al - `erase_late_bound_regions` -> `instantiate_bound_regions_with_erased`? - `EraseEarlyRegions` should be removed, feels duplicate r? `@BoxyUwU`
2023-11-13rename `ReLateBound` to `ReBound`lcnr-19/+21
other changes: - `Region::new_late_bound` -> `Region::new_bound` - `Region::is_late_bound` -> `Region::is_bound`
2023-11-13Turn assert_eq into a delay_span_bugMu001999-1/+7
2023-11-12Small improvements in object lifetime default codeNilstrieb-3/+2
I found those while trying to understand how the code works.
2023-11-08Only use normalize_param_env when normalizing predicate in check_item_boundsMichael Goulet-2/+8
2023-11-06check binders with bound vars for global bounds that don't holdRémy Rakic-1/+2
(instead of just late bound vars)
2023-11-04Auto merge of #117540 - ↵bors-1/+1
matthiaskrgr:baby_dont_clone_me_dont_clone_me_no_more, r=est31 clone less
2023-11-03Auto merge of #117507 - nnethercote:rustc_span, r=Nilstriebbors-3/+2
`rustc_span` cleanups Just some things I found while looking over this crate. r? `@oli-obk`
2023-11-03clone lessMatthias Krüger-1/+1
2023-11-02Add all RPITITs when augmenting param-env with GAT bounds in check_type_boundsMichael Goulet-77/+103
2023-11-02Use the normalizing param-env always in check_type_boundsMichael Goulet-123/+143
2023-11-02Minimize `pub` usage in `source_map.rs`.Nicholas Nethercote-3/+2
Most notably, this commit changes the `pub use crate::*;` in that file to `use crate::*;`. This requires a lot of `use` items in other crates to be adjusted, because everything defined within `rustc_span::*` was also available via `rustc_span::source_map::*`, which is bizarre. The commit also removes `SourceMap::span_to_relative_line_string`, which is unused.
2023-10-31Rollup merge of #117416 - compiler-errors:tait-in-bad-body, r=oli-obkMatthias Krüger-3/+11
Also consider TAIT to be uncomputable if the MIR body is tainted Not totally sure if this is the best solution. We could, alternatively, look at the hir typeck results and try to take a type from there instead of just falling back to type error, inferring `u8` instead of `{type error}`. Not certain it really matters, though. Happy to iterate on this. Fixes #117413 r? ``@oli-obk`` cc ``@Nadrieril``
2023-10-30Auto merge of #116405 - estebank:issue-103155, r=davidtwcobors-10/+41
Detect object safety errors when assoc type is missing When an associated type with GATs isn't specified in a `dyn Trait`, emit an object safety error instead of only complaining about the missing associated type, as it will lead the user down a path of three different errors before letting them know that what they were trying to do is impossible to begin with. Fix #103155.
2023-10-30Sort errorsEsteban Küber-4/+6
2023-10-30Detect object safety errors when assoc type is missingEsteban Küber-11/+40
When an associated type with GATs isn't specified in a `dyn Trait`, emit an object safety error instead of only complaining about the missing associated type, as it will lead the user down a path of three different errors before letting them know that what they were trying to do is impossible to begin with. Fix #103155.
2023-10-30Auto merge of #117415 - matthiaskrgr:rollup-jr2p1t2, r=matthiaskrgrbors-40/+54
Rollup of 7 pull requests Successful merges: - #116862 (Detect when trait is implemented for type and suggest importing it) - #117389 (Some diagnostics improvements of `gen` blocks) - #117396 (Don't treat closures/coroutine types as part of the public API) - #117398 (Correctly handle nested or-patterns in exhaustiveness) - #117403 (Poison check_well_formed if method receivers are invalid to prevent typeck from running on it) - #117411 (Improve some diagnostics around `?Trait` bounds) - #117414 (Don't normalize to an un-revealed opaque when we hit the recursion limit) r? `@ghost` `@rustbot` modify labels: rollup
2023-10-30Also consider TAIT to be uncomputable if the MIR body is taintedMichael Goulet-3/+11
2023-10-30Rollup merge of #117411 - oli-obk:query_merge_immobile_game, ↵Matthias Krüger-27/+32
r=compiler-errors,Nilstrieb Improve some diagnostics around `?Trait` bounds * uses better spans * clarifies a message that was only talking about generic params, but applies to `dyn ?Trait` and `impl ?Trait` as well
2023-10-30Improve some diagnostics around `?Trait` boundsOli Scherer-27/+32
2023-10-30Poison check_well_formed if method receivers are invalid to prevent typeck ↵Oli Scherer-13/+22
from running on it