Commit Graph

1269 Commits

Author SHA1 Message Date
Vadim Petrochenkov
c697927f44 rustc: hir().local_def_id_to_hir_id() -> tcx.local_def_id_to_hir_id() cleanup 2023-11-26 12:41:21 +03:00
Michael Goulet
8dd8db5073
Rollup merge of #118288 - compiler-errors:is_some_and, r=lqd,dtolnay
Use `is_{some,ok}_and` more in the compiler

slightly more fluent-reading code
2023-11-25 17:23:34 -05:00
Michael Goulet
3b2f33ee28
Rollup merge of #118158 - nnethercote:reduce-fluent-boilerplate, r=compiler-errors
Reduce fluent boilerplate

Best reviewed one commit at a time.

r? `@davidtwco`
2023-11-25 17:23:33 -05:00
Nicholas Nethercote
57cd5e6551 Use rustc_fluent_macro::fluent_messages! directly.
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-26 08:38:40 +11:00
Nicholas Nethercote
a733082be9 Avoid need for {D,Subd}iagnosticMessage imports.
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-26 08:38:00 +11:00
Michael Goulet
079a2e865f is_{some,ok}_and 2023-11-25 18:47:16 +00:00
Michael Goulet
fa7633dda1 Remove HirId from QPath::LangItem 2023-11-25 18:02:11 +00:00
Santiago Pastorino
6713f295e2
We should call eq instead of sup as we're relating Ty directly and not Binder<TraitRef> 2023-11-24 16:38:32 -03:00
Michael Goulet
4ec548afbe
Rollup merge of #118161 - compiler-errors:coroutine-obligation-opaques, r=lcnr
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-22 09:28:52 -08:00
Nicholas Nethercote
7060fc8327 Replace no_ord_impl with orderable.
Similar to the previous commit, this replaces `newtype_index`'s opt-out
`no_ord_impl` attribute with the opt-in `orderable` attribute.
2023-11-22 18:38:17 +11:00
Nicholas Nethercote
3ef9d4d0ed Replace custom_encodable with encodable.
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-22 18:37:14 +11:00
Michael Goulet
4f958a4802 Allow defining opaques in check_coroutine_obligations 2023-11-22 03:44:13 +00:00
Nilstrieb
21a870515b Fix clippy::needless_borrow in the compiler
`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-21 20:13:40 +01:00
Michael Goulet
6388c0ef04
Rollup merge of #118000 - compiler-errors:placeholder-ty-outlives, r=aliemjay
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-19 19:14:35 -08:00
Michael Goulet
b39791aec2
Rollup merge of #117828 - Nilstrieb:astconv-hashmaps, r=petrochenkov
Avoid iterating over hashmaps in astconv
2023-11-19 19:14:32 -08:00
Michael Goulet
8f267e2b87 Make regionck care about placeholders in outlives components 2023-11-19 19:12:20 +00:00
Esteban Küber
f1ae02f4bd Don't sort span_suggestions, leave that to caller 2023-11-19 17:50:45 +00:00
Nilstrieb
13959bf376 Avoid iterating over hashmaps in astconv 2023-11-19 17:45:02 +01:00
bors
33688d2467 Auto merge of #117525 - GKFX:remove_option_payload_ptr, r=petrochenkov
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-18 12:45:42 +00:00
lcnr
40b154e53c rename bound region instantiation
- `erase_late_bound_regions` -> `instantiate_bound_regions_with_erased`
- `replace_late_bound_regions_X` -> `instantiate_bound_regions_X`
2023-11-17 09:29:48 +00:00
lcnr
41cfb20abb replace unnecessary folder impls with fold_region 2023-11-17 08:58:18 +00:00
George Bateman
661df4fd55
Remove option_payload_ptr; redundant to offset_of 2023-11-16 22:56:25 +00:00
Mark Rousskov
917f6540ed Re-format code with new rustfmt 2023-11-15 21:45:48 -05:00
Mark Rousskov
db3e2bacb6 Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
lcnr
15f21562e6 finish RegionKind rename
- `ReFree` -> `ReLateParam`
- `ReEarlyBound` -> `ReEarlyParam`
2023-11-14 13:13:27 +00:00
bors
531cb83fcf Auto merge of #117881 - TaKO8Ki:rollup-n7jtmgj, r=TaKO8Ki
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-13 17:29:00 +00:00
Takayuki Maeda
826b181cef
Rollup merge of #117830 - Nilstrieb:object-lifetime-default-nits, r=cjgillot
Small improvements in object lifetime default code

I found those while trying to understand how the code works.
2023-11-14 00:54:16 +09:00
bors
4bd2fd5c83 Auto merge of #117876 - lcnr:region-kind-rename, r=BoxyUwU
`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-13 15:33:01 +00:00
lcnr
86fa1317a3 rename ReLateBound to ReBound
other changes:
- `Region::new_late_bound` -> `Region::new_bound`
- `Region::is_late_bound` -> `Region::is_bound`
2023-11-13 14:13:54 +00:00
Mu001999
62b6529e03 Turn assert_eq into a delay_span_bug 2023-11-13 08:36:12 +08:00
Nilstrieb
8bcd221b4c Small improvements in object lifetime default code
I found those while trying to understand how the code works.
2023-11-12 11:59:01 +01:00
Michael Goulet
97c9d8f405 Only use normalize_param_env when normalizing predicate in check_item_bounds 2023-11-08 02:35:25 +00:00
Rémy Rakic
2beca157c9 check binders with bound vars for global bounds that don't hold
(instead of just late bound vars)
2023-11-06 15:46:17 +00:00
bors
f1b104f523 Auto merge of #117540 - matthiaskrgr:baby_dont_clone_me_dont_clone_me_no_more, r=est31
clone less
2023-11-04 00:29:52 +00:00
bors
9c20ddd956 Auto merge of #117507 - nnethercote:rustc_span, r=Nilstrieb
`rustc_span` cleanups

Just some things I found while looking over this crate.

r? `@oli-obk`
2023-11-03 14:57:40 +00:00
Matthias Krüger
1ba97cb1cc clone less 2023-11-03 13:23:26 +01:00
Michael Goulet
dd571e472a Add all RPITITs when augmenting param-env with GAT bounds in check_type_bounds 2023-11-02 20:47:10 +00:00
Michael Goulet
bb74d7e97d Use the normalizing param-env always in check_type_bounds 2023-11-02 20:47:05 +00:00
Nicholas Nethercote
f405ce86c2 Minimize pub usage in source_map.rs.
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-11-02 19:35:00 +11:00
Matthias Krüger
8daa317a4b
Rollup merge of #117416 - compiler-errors:tait-in-bad-body, r=oli-obk
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-31 12:55:09 +01:00
bors
a395214a3a Auto merge of #116405 - estebank:issue-103155, r=davidtwco
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-30 22:47:48 +00:00
Esteban Küber
b8a8ba9c91 Sort errors 2023-10-30 22:19:17 +00:00
Esteban Küber
17a6ae2df3 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-30 22:12:07 +00:00
bors
31bc7e2c47 Auto merge of #117415 - matthiaskrgr:rollup-jr2p1t2, r=matthiaskrgr
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-30 20:50:14 +00:00
Michael Goulet
48491c182b Also consider TAIT to be uncomputable if the MIR body is tainted 2023-10-30 20:16:22 +00:00
Matthias Krüger
3e95c6ab03
Rollup merge of #117411 - oli-obk:query_merge_immobile_game, 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-30 21:03:39 +01:00
Oli Scherer
455cf5a4f6 Improve some diagnostics around ?Trait bounds 2023-10-30 17:47:07 +00:00
Oli Scherer
ff3a818554 Poison check_well_formed if method receivers are invalid to prevent typeck from running on it 2023-10-30 16:11:52 +00:00
Nicholas Nethercote
8ff624a9f2 Clean up rustc_*/Cargo.toml.
- Sort dependencies and features sections.
- Add `tidy` markers to the sorted sections so they stay sorted.
- Remove empty `[lib`] sections.
- Remove "See more keys..." comments.

Excluded files:
- rustc_codegen_{cranelift,gcc}, because they're external.
- rustc_lexer, because it has external use.
- stable_mir, because it has external use.
2023-10-30 08:46:02 +11:00
bors
698db856de Auto merge of #117171 - fee1-dead-contrib:deny-explicit-effect-params, r=oli-obk
Deny providing explicit effect params

r? `@oli-obk`

cc https://github.com/rust-lang/rust/issues/110395
2023-10-26 14:50:23 +00:00