Commit Graph

1408 Commits

Author SHA1 Message Date
Rémy Rakic
459a616c4f extract polonius universal regions fact generation 2023-11-26 12:00:32 +00:00
Rémy Rakic
3de68e074a extract polonius move fact generation 2023-11-26 12:00:32 +00:00
Rémy Rakic
eca2789f57 remove useless local variables 2023-11-26 12:00:32 +00:00
bors
3acb261e21 Auto merge of #118256 - petrochenkov:nohir, r=compiler-errors
rustc: `hir().local_def_id_to_hir_id()` -> `tcx.local_def_id_to_hir_id()` cleanup

Noticed this while working on https://github.com/rust-lang/rust/pull/118188.

The history here is that the method was moved from HIR map to tcx in https://github.com/rust-lang/rust/pull/93373 as a part of incremental compilation work, so it's unlikely to go back.
2023-11-26 10:43:41 +00:00
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
bors
274b5249eb Auto merge of #117880 - lqd:liveness-values, r=cjgillot
Refactor borrowck liveness values

This PR starts cleaning up `rustc_borrowck`, in particular around liveness values:
- refactors simple names that make no sense anymore: either referring to older structures using region elements, or to bitset containers and values.
- improves comments and fixes others
- removes unused return values and unneeded generic arguments

r? `@matthewjasper`
2023-11-26 08:44:28 +00:00
r0cky
91aee2de15 Clean dead codes 2023-11-26 09:25:07 +08: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
fa7633dda1 Remove HirId from QPath::LangItem 2023-11-25 18:02:11 +00:00
bors
e2e978f713 Auto merge of #118203 - nnethercote:rustc_mir_dataflow, r=cjgillot
Minor `rustc_mir_dataflow` cleanups

r? `@cjgillot`
2023-11-25 07:10:46 +00:00
Nicholas Nethercote
118308ee03 Remove unused EverInitializedPlaces::tcx field. 2023-11-24 06:15:32 +11:00
Nicholas Nethercote
f450bf49c0 Use 'mir lifetime name more.
Some types have a `body: &'mir Body<'tcx>` and some have `body: &'a
Body<'tcx>`. The former is more readable, so this commit converts some
fo the latter to the former.
2023-11-23 18:49:58 +11: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
bors
cc4bb0de20 Auto merge of #117928 - nnethercote:rustc_ast_pretty, r=fee1-dead
`rustc_ast_pretty` cleanups

Some improvements I found while looking at this code.

r? `@fee1-dead`
2023-11-22 05:09:33 +00:00
Nicholas Nethercote
3eadc6844b Update itertools to 0.11.
Because the API for `with_position` improved in 0.11 and I want to use
it.
2023-11-22 08:13:21 +11: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
Nilstrieb
4bb3ae39b7
Rollup merge of #118035 - ouz-a:november_ice2, r=compiler-errors
Fix early param lifetimes in generic_const_exprs

In cases like below, we never actually be able to capture region name for two reasons, first `'static` becomes anonymous lifetime and second we never capture region if it doesn't have a name so this results in ICE.
```
struct DataWrapper<'static> {
    data: &'a [u8; Self::SIZE],
}

impl DataWrapper<'a> {
```

Fixes https://github.com/rust-lang/rust/issues/118021
2023-11-21 14:36:14 +01:00
ouz-a
f68c6c9528 Fix early param lifetimes in generic_const_exprs 2023-11-20 23:13:36 +03:00
Matthias Krüger
87540879f4
Rollup merge of #117835 - Nilstrieb:note-object-lifetime-defaults, r=compiler-errors
Note about object lifetime defaults in does not live long enough error

This is a aspect of Rust that frequently trips up people who are not aware of it yet. This diagnostic attempts to explain what's happening and why the lifetime constraint, that was never mentioned in the source, arose.

The implementation feels a bit questionable, I'm not sure whether there are better ways to do this. There probably are.

fixes #117835

r? types
2023-11-20 20:56:40 +01:00
bors
069a4af48b Auto merge of #117944 - lcnr:region-refactor-uwu, r=BoxyUwU
some additional region refactorings

the commits are selfcontained 

r? `@BoxyUwU`
2023-11-17 14:27:20 +00:00
bors
4d7f952a02 Auto merge of #112422 - aliemjay:implied-bounds-placeholders, r=lcnr
ignore implied bounds with placeholders

given the following code:
```rust
trait Trait {
    type Ty<'a> where Self: 'a;
}

impl<T> Trait for T {
    type Ty<'a> = () where Self: 'a;
}

struct Foo<T: Trait>(T)
where
    for<'x> T::Ty<'x>: Sized;
```

when computing the implied bounds from `Foo<X>` we incorrectly get the bound `X: !x` from the normalization of ` for<'x> <X as Trait>::Ty::<'x>: Sized`. This is a a known bug! we shouldn't use the constraints that arise from normalization as implied bounds. See #109628.

Ignore these bounds for now. This should prevent later ICEs.

Fixes #112250
Fixes #107409
2023-11-17 12:16:53 +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
bors
820f06b21f Auto merge of #116097 - jackh726:higher-ranked-lifetime-error-backup, r=compiler-errors
Try to use approximate placeholder regions when outputting an AscribeUserType error in borrowck

Fixes #114866

Hi from GOSIM :)
2023-11-16 19:12:35 +00:00
Ali MJ Al-Nasrawy
af79fd109b ignore implied bounds with placeholders 2023-11-16 14:25:35 +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
Rémy Rakic
d203476c4f rename debugging support functions 2023-11-14 11:22:13 +00:00
Rémy Rakic
84a002cc42 LivenessValues does not need to be generic over regions 2023-11-14 11:22:13 +00:00
Rémy Rakic
79c5e913d3 introduce is_live_anywhere instead of peeking into points
and refactor misnamed `get_elements`
2023-11-14 11:22:13 +00:00
Rémy Rakic
b4c7d1dd05 fix doc 2023-11-13 16:28:28 +00:00
Rémy Rakic
23bc9c6a62 regions do not contain liveness elements 2023-11-13 16:28:28 +00:00
Rémy Rakic
c8feeb6ced refer to points and not "elements", and remove unused return value 2023-11-13 16:28:28 +00:00
Rémy Rakic
fb94626431 add locations instead of "element"s, and remove unused return value 2023-11-13 16:28:28 +00:00
Rémy Rakic
3e3e7a023f iterate over regions and not "rows" in liveness values 2023-11-13 16:28:28 +00:00
Rémy Rakic
4e5fe71ca6 stop referring to a region as a "row" in liveness values 2023-11-13 16:27:42 +00:00
lcnr
dd0739aabe continue renaming
- `RegionVariableOrigin::~~Late~~BoundRegion`
- `~~Late~~BoundRegionConversionTime`
2023-11-13 14:13:54 +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
lcnr
28328c8389 remove unnecessary _ in variable name 2023-11-13 14:13:54 +00:00
lcnr
85883503c3 add fixme to RegionCtxt 2023-11-13 14:13:54 +00:00
Nilstrieb
e5c330ac48 Note about object lifetime defaults in does not live long enough error
This is a aspect of Rust that frequently trips up people who are not
aware of it yet. This diagnostic attempts to explain what's happening
and why the lifetime constraint, that was never mentioned in the source,
arose.
2023-11-12 13:51:16 +01:00
bors
b7583d38b7 Auto merge of #117712 - lcnr:expand-coroutine, r=jackh726
generator layout: ignore fake borrows

fixes #117059

We emit fake shallow borrows in case the scrutinee place uses a `Deref` and there is a match guard. This is necessary to prevent the match guard from mutating the scrutinee: fab1054e17/compiler/rustc_mir_build/src/build/matches/mod.rs (L1250-L1265)

These fake borrows end up impacting the generator witness computation in `mir_generator_witnesses`, which causes the issue in #117059. This PR now completely ignores fake borrows during this computation. This is sound as thse are always removed after analysis and the actual computation of the generator layout happens afterwards.

Only the second commit impacts behavior, and could be backported by itself.

r? types
2023-11-09 14:23:45 +00:00
lcnr
992d93f687 rename BorrowKind::Shallow to Fake
also adds some comments
2023-11-08 22:55:28 +01:00
bors
341efb1017 Auto merge of #117560 - lqd:issue-117146, r=matthewjasper
Compute polonius loan scopes over the region graph

In issue #117146 a loan flows into an SCC containing a placeholder, and whose representative is an existential region. Since we currently compute loan scopes by looking at SCCs and their representatives only, polonius would compute kill points for this loan here whereas NLLs would not of course.

There are a few ways to fix this:
- don't try to be efficient by doing the computation over SCCs, and simply look for free regions and placeholders in the successors of the issuing region.
- change how the SCC representatives are picked, biasing towards placeholders over existential regions. They *shouldn't* matter much, but some downstream code may subtly depend on the current scheme (though no tests fail if we do such a change). This is for unrelated reasons also the way #116891 changes the representative computation. So that PR would also fix issue #117146.
- try to remove placeholders from the main path, and contain them to a pre-pass + a post-pass kind of polonius leak check. If possible, it would fix this issue by turning an outlives constraints to a placeholder into a constraint to 'static. This should also fix the issue, as the representative would be the free region in the SCC. We want to prototype this change to see if it's possible to try to simplify the borrowck main path from having to deal with placeholders and higher-ranked subtyping 🤞.

I'd like to take advantage of fuzzing and a crater run sooner rather than later, so that we grow more confidence that the 2 models are indeed equivalent empirically. Therefore this PR implements option 1 to fix the issue now.

We can take care of efficiency later after validation, and once we implement option 3 (which could also impact option 2 and that associated PR, maybe the lack of placeholders could remove the need to change the representative computation) to traverse SCCs and their representative again.

(Or we maybe will have some kind of naive position-dependent outlives propagation by then and this code would have been changed)

Fixes #117146.

r? `@matthewjasper`
2023-11-08 16:13:37 +00:00
bors
7b97a5ca84 Auto merge of #117511 - gurry:117406-err-packed-structs, r=compiler-errors
Emit explanatory note for move errors in packed struct derives

Derive expansions for packed structs with non-`Copy` fields cause move errors because they prefer copying over borrowing since borrowing the fields of a packed struct can result in unaligned access.

This underlying cause of the errors, however, is not apparent to the user. This PR adds a diagnostic note to make it clear to the user (the new note is on the second last line):

```
tests/ui/derives/deriving-with-repr-packed-move-errors.rs:13:16
   |
12 | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Default)]
   |          ----- in this derive macro expansion
13 | struct StructA(String);
   |                ^^^^^^ move occurs because `self.0` has type `String`, which does not implement the `Copy` trait
   |
   = note: `#[derive(Debug)]` triggers a move because taking references to the fields of a packed struct is undefined behaviour
   = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
```

Fixes #117406

Partially addresses #110777
2023-11-07 00:03:53 +00:00
Rémy Rakic
de7a8305ae traverse region graph instead of SCCs to compute polonius loan scopes
By using SCC for better performance, we also have to take into account
SCCs whose representative is an existential region but also contains a
placeholder.

By only checking the representative, we may miss that the loan escapes
the function. This can be fixed by picking a better representative, or
removing placeholders from the main path.

This is the simplest fix: forgo efficiency and traverse the region graph
instead of the SCCs.
2023-11-04 01:04:12 +00:00
Gurinder Singh
4b3ece475d Emit explanatory note for move errors in packed struct derives
Derive expansions for packed structs cause move errors because
they prefer copying over borrowing since borrowing the fields of a
packed struct can result in unaligned access and therefore undefined
behaviour.

This underlying cause of the errors, however, is not apparent
to the user. We add a diagnostic note here to remedy that.
2023-11-03 07:32:10 +05:30
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
lcnr
078144e3e8 prepopulate opaque ty storage before using it :> 2023-10-31 11:50:30 +01:00
Guillaume Gomez
5ac999f133
Rollup merge of #117357 - tmiasko:terminate, r=wesleywiser
Rename a few remaining references to abort terminator

Follow up to e3f2edc75b
2023-10-30 17:33:17 +01: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
ec2b311914 Auto merge of #116733 - compiler-errors:alias-liveness-but-this-time-sound, r=aliemjay
Consider alias bounds when computing liveness in NLL (but this time sound hopefully)

This is a revival of #116040, except removing the changes to opaque lifetime captures check to make sure that we're not triggering any unsoundness due to the lack of general existential regions and the currently-existing `ReErased` hack we use instead.

r? `@aliemjay` -- I appreciate you pointing out the unsoundenss in the previous iteration of this PR, and I'd like to hear that you're happy with this iteration of this PR before this goes back into FCP :>

Fixes #116794 as well

---

(mostly copied from #116040 and reworked slightly)

# Background

Right now, liveness analysis in NLL is a bit simplistic. It simply walks through all of the regions of a type and marks them as being live at points. This is problematic in the case of aliases, since it requires that we mark **all** of the regions in their args[^1] as live, leading to bugs like #42940.

In reality, we may be able to deduce that fewer regions are allowed to be present in the projected type (or "hidden type" for opaques) via item bounds or where clauses, and therefore ideally, we should be able to soundly require fewer regions to be live in the alias.

For example:
```rust
trait Captures<'a> {}
impl<T> Captures<'_> for T {}

fn capture<'o>(_: &'o mut ()) -> impl Sized + Captures<'o> + 'static {}

fn test_two_mut(mut x: ()) {
    let _f1 = capture(&mut x);
    let _f2 = capture(&mut x);
    //~^ ERROR cannot borrow `x` as mutable more than once at a time
}
```

In the example above, we should be able to deduce from the `'static` bound on `capture`'s opaque that even though `'o` is a captured region, it *can never* show up in the opaque's hidden type, and can soundly be ignored for liveness purposes.

# The Fix

We apply a simple version of RFC 1214's `OutlivesProjectionEnv` and `OutlivesProjectionTraitDef` rules to NLL's `make_all_regions_live` computation.

Specifically, when we encounter an alias type, we:
1. Look for a unique outlives bound in the param-env or item bounds for that alias. If there is more than one unique region, bail, unless any of the outlives bound's regions is `'static`, and in that case, prefer `'static`. If we find such a unique region, we can mark that outlives region as live and skip walking through the args of the opaque.
2. Otherwise, walk through the alias's args recursively, as we do today.

## Limitation: Multiple choices

This approach has some limitations. Firstly, since liveness doesn't use the same type-test logic as outlives bounds do, we can't really try several options when we're faced with a choice.

If we encounter two unique outlives regions in the param-env or bounds, we simply fall back to walking the opaque via its args. I expect this to be mostly mitigated by the special treatment of `'static`, and can be fixed in a forwards-compatible by a more sophisticated analysis in the future.

## Limitation: Opaque hidden types

Secondly, we do not employ any of these rules when considering whether the regions captured by a hidden type are valid. That causes this code (cc #42940) to fail:

```rust
trait Captures<'a> {}
impl<T> Captures<'_> for T {}

fn a() -> impl Sized + 'static {
    b(&vec![])
}

fn b<'o>(_: &'o Vec<i32>) -> impl Sized + Captures<'o> + 'static {}
```

We need to have existential regions to avoid [unsoundness](https://github.com/rust-lang/rust/pull/116040#issuecomment-1751628189) when an opaque captures a region which is not represented in its own substs but which outlives a region that does.

## Read more

Context: https://github.com/rust-lang/rust/pull/115822#issuecomment-1731153952 (for the liveness case)
More context: https://github.com/rust-lang/rust/issues/42940#issuecomment-455198309 (for the opaque capture case, which this does not fix)

[^1]: except for bivariant region args in opaques, which will become less relevant when we move onto edition 2024 capture semantics for opaques.
2023-10-29 18:42:02 +00:00
bors
2cad938a81 Auto merge of #116447 - oli-obk:gen_fn, r=compiler-errors
Implement `gen` blocks in the 2024 edition

Coroutines tracking issue https://github.com/rust-lang/rust/issues/43122
`gen` block tracking issue https://github.com/rust-lang/rust/issues/117078

This PR implements `gen` blocks that implement `Iterator`. Most of the logic with `async` blocks is shared, and thus I renamed various types that were referring to `async` specifically.

An example usage of `gen` blocks is

```rust
fn foo() -> impl Iterator<Item = i32> {
    gen {
        yield 42;
        for i in 5..18 {
            if i.is_even() { continue }
            yield i * 2;
        }
    }
}
```

The limitations (to be resolved) of the implementation are listed in the tracking issue
2023-10-29 00:03:52 +00:00
Tomasz Miąsko
552abdce50 Rename a few remaining references to abort terminator
Follow up to e3f2edc75b
2023-10-29 00:00:00 +00:00
Oli Scherer
bb90c4bf35 Use targetted diagnostic for borrow across yield error 2023-10-27 13:05:49 +00:00
Oli Scherer
4ac25faf9f Handle move generators 2023-10-27 13:05:48 +00:00
Oli Scherer
d572729d59 Quietly fail if an error has already occurred 2023-10-26 11:14:53 +00:00
Oli Scherer
14423080f1 Add hir::GeneratorKind::Gen 2023-10-26 07:10:25 +00:00
Oli Scherer
af8a998b1e Rename AsyncCoroutineKind to CoroutineSource
similar to how we have `MatchSource`, it explains where the desugaring came from.
2023-10-25 16:14:05 +00:00
Matthias Krüger
61ff4dbedd
Rollup merge of #116792 - JonasAlaif:renumber-fix, r=b-naber
Avoid unnecessary renumbering during borrowck

Currently, after renumbering there are always unused `RegionVid`s if the return type contains any regions, this is due to `visit_ty` being called twice on the same `Ty`: once with `TyContext::ReturnTy` and once with `TyContext::LocalDecl { local: _0 }`. This PR skips renumbering the first time around.
2023-10-24 19:29:54 +02:00
bors
cd674d6179 Auto merge of #116300 - cjgillot:split-move, r=petrochenkov
Separate move path tracking between borrowck and drop elaboration.

The primary goal of this PR is to skip creating a `MovePathIndex` for path that do not need dropping in drop elaboration.

The 2 first commits are cleanups.

The next 2 commits displace `move` errors from move-path builder to borrowck. Move-path builder keeps the same logic, but does not carry error information any more.

The remaining commits allow to filter `MovePathIndex` creation according to types. This is used in drop elaboration, to avoid computing dataflow for paths that do not need dropping.
2023-10-24 00:25:32 +00:00
Matthias Krüger
8af4a3f9cd
Rollup merge of #116859 - Nilstrieb:more-more-funny-pretty-printers, r=oli-obk
Make `ty::print::Printer` take `&mut self` instead of `self`

based on #116815

This simplifies the code by removing all the `self` assignments and
makes the flow of data clearer - always into the printer.
Especially in v0 mangling, which already used  `&mut self` in some
places, it gets a lot more uniform.
2023-10-23 22:26:29 +02:00
Matthias Krüger
726709bca4
Rollup merge of #116960 - lqd:applied-member-constraints-scope, r=matthewjasper
Location-insensitive polonius: consider a loan escaping if an SCC has member constraints applied only

The location-insensitive analysis considered loans to escape if there were member constraints, which makes *some* sense for scopes and matches the scopes that NLL computes on all the tests.

However, polonius and NLLs differ on the fuzzed case #116657, where an SCC has member constraints but no applied ones (and is kinda surprising). The existing UI tests with member constraints impacting scopes all have some constraint applied.

This PR changes the location-insensitive analysis to consider a loan to escape if there are applied member constraints, and for extra paranoia/insurance via fuzzing and crater: actually checks the constraint's min choice is indeed a universal region as we expect. (This could be turned into a `debug_assert` and early return as a slight optimization after these periods of verification)

The 4 UI tests where member constraints are meaningful for computing scopes still pass obviously, and this also fixes #116657.

r? `@matthewjasper`
2023-10-23 16:23:52 +02:00
Camille GILLOT
abb723dea2 Remove redundant checks. 2023-10-21 12:10:30 +00:00
Camille GILLOT
252c64722f Parametrize gather_moves by filter. 2023-10-21 10:31:39 +00:00
Camille GILLOT
4bedd7de6e Stop computing error info in move path builder. 2023-10-21 10:30:58 +00:00
Camille GILLOT
90e6d29955 Avoid using a magic value for untracked locals. 2023-10-21 10:30:16 +00:00
Camille GILLOT
8d535070a2 Do not report errors from move path builder. 2023-10-21 10:29:40 +00:00
Nilstrieb
5acf26b97e Make ty::print::Printer take &mut self instead of self
This simplifies the code by removing all the `self` assignments and
makes the flow of data clearer - always into the printer.
Especially in v0 mangling, which already used  `&mut self` in some
places, it gets a lot more uniform.
2023-10-21 11:33:05 +02:00
Matthias Krüger
dd66bc86be
Rollup merge of #116990 - estebank:issue-68445, r=cjgillot
Mention `into_iter` on borrow errors suggestions when appropriate

If we encounter a borrow error on `vec![1, 2, 3].iter()`, suggest `into_iter`.

Fix #68445.
2023-10-21 10:08:18 +02:00
Oli Scherer
2d91c76d5d Rename CoroutineKind::Gen to ::Coroutine 2023-10-20 21:14:01 +00:00
Oli Scherer
e96ce20b34 s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
Oli Scherer
60956837cf s/Generator/Coroutine/ 2023-10-20 21:10:38 +00:00
Rémy Rakic
fa45efaafb consider a loan escapes the function via applied member constraints 2023-10-20 20:59:20 +00:00
Esteban Küber
88bccf454f Mention into_iter on borrow errors suggestions when appropriate
If we encounter a borrow error on `vec![1, 2, 3].iter()`, suggest
`into_iter`.

Fix #68445.
2023-10-20 18:50:25 +00:00
Rémy Rakic
c69bd9480a make applied_member_constraints accept an SCC instead of a region 2023-10-19 21:25:12 +00:00
Ali MJ Al-Nasrawy
a1e274f172 revert rust-lang/rust#114586 2023-10-18 06:19:04 +00:00
bors
631a116cd3 Auto merge of #116822 - notriddle:notriddle/rust-logo, r=fmease
docs: add Rust logo to more compiler crates

c6e6ecb1af added it to some of the compiler's crates, but avoided adding it to all of them to reduce bit-rot. This commit adds to more.

r? `@GuillaumeGomez`
2023-10-17 04:41:20 +00:00
Michael Goulet
1005970485 Use a visitor that could be reused by opaque type capture check later 2023-10-17 01:26:46 +00:00
Michael Howell
2ff2624722 docs: add Rust logo to more compiler crates
c6e6ecb1af added it to some of the
compiler's crates, but avoided adding it to all of them to reduce
bit-rot. This commit adds to more.
2023-10-16 15:38:08 -07:00
Michael Goulet
743e6d1601 Remove DefiningAnchor::Bubble from opaque wf check 2023-10-16 15:50:31 +00:00
Jonáš Fiala
2bba98b121 Avoid unnecessary renumbering 2023-10-16 14:29:36 +02:00
Michael Goulet
371d8a8215 Consider static specially 2023-10-14 15:35:01 +01:00
Michael Goulet
e425d85518 Consider param-env candidates, too 2023-10-14 15:35:01 +01:00
Michael Goulet
184d5ef107 Consider alias bounds when considering lliveness for alias types in NLL 2023-10-14 15:35:01 +01:00
Michael Goulet
b2d2184ede Format all the let chains in compiler 2023-10-13 08:59:36 +00:00
bors
3d575a2f2e Auto merge of #113487 - estebank:sugg-113174, r=oli-obk
Use structured suggestion for #113174

When encountering a for loop that is rejected by the borrow checker because it is being advanced within its body, provide a structured suggestion for `while let Some(pat) = iter.next()`.
2023-10-12 02:34:07 +00:00
Esteban Küber
9d2eb66e1a Use structured suggestion for #113174
When encountering a for loop that is rejected by the borrow checker
because it is being advanced within its body, provide a structured
suggestion for `while let Some(pat) = iter.next()`.
2023-10-11 18:26:44 +00:00
bors
c1691db366 Auto merge of #113218 - lqd:polonius-scopes, r=jackh726
Compute NLL loan scopes using the polonius model

For a *location-insensitive* analysis (that is, without expressiveness improvements for users yet), this PR implements loans going out of scope using reachability and liveness, rather than checking if the issuing region's values contain a given CFG point. This is equivalent to NLL scopes and computes the same data.

r? `@matthewjasper`

A couple of notes:
- there are some assumptions about SCC representatives, placeholders, free regions, and member constraints that I believe hold, and they're documented in the code
- this passes all the UI tests with `-Zpolonius=next` -- the perf is [not terrible](https://github.com/rust-lang/rust/pull/112432#issuecomment-1749685862) and there are a bunch of ways to improve it in the future.
- there's a fixme left, hopefully Matthew you know a clean way to get the information it mentions.
2023-10-11 16:46:03 +00:00
bors
94bc9c737e Auto merge of #114811 - estebank:impl-ambiguity, r=wesleywiser
Show more information when multiple `impl`s apply

- When there are `impl`s without type params, show only those (to avoid showing overly generic `impl`s).
```
error[E0283]: type annotations needed
  --> $DIR/multiple-impl-apply.rs:34:9
   |
LL |     let y = x.into();
   |         ^     ---- type must be known at this point
   |
note: multiple `impl`s satisfying `_: From<Baz>` found
  --> $DIR/multiple-impl-apply.rs:14:1
   |
LL | impl From<Baz> for Bar {
   | ^^^^^^^^^^^^^^^^^^^^^^
...
LL | impl From<Baz> for Foo {
   | ^^^^^^^^^^^^^^^^^^^^^^
   = note: required for `Baz` to implement `Into<_>`
help: consider giving `y` an explicit type
   |
LL |     let y: /* Type */ = x.into();
   |          ++++++++++++
```

- Lower the importance of `T: Sized`, `T: WellFormed` and coercion errors, to prioritize more relevant errors. The pre-existing deduplication logic deals with hiding redundant errors better that way, and we show errors with more metadata that is useful to the user.

- Show `<SelfTy as Trait>::assoc_fn` suggestion in more cases.
```
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
  --> $DIR/cross-return-site-inference.rs:38:16
   |
LL |     return Err(From::from("foo"));
   |                ^^^^^^^^^^ cannot call associated function of trait
   |
help: use a fully-qualified path to a specific available implementation
   |
LL |     return Err(</* self type */ as From>::from("foo"));
   |                +++++++++++++++++++     +
```

Fix #88284.
2023-10-06 18:44:32 +00:00
Rémy Rakic
3dcff0051a compute NLL loan scopes with liveness in -Zpolonius=next 2023-10-05 15:56:20 +00:00
Rémy Rakic
a7f1f24823 allow access to liveness' PointIndexes 2023-10-05 15:25:46 +00:00
Rémy Rakic
af8a318aa1 add note why a function is pub 2023-10-05 15:25:46 +00:00
Jubilee
ea3454eabb
Rollup merge of #116223 - catandcoder:master, r=cjgillot
Fix misuses of a vs an

Fixes the misuse of "a" vs "an", according to English grammatical
expectations and using https://www.a-or-an.com/
2023-10-05 00:56:29 -07:00
Rémy Rakic
a946fabd48 document Borrows dataflow analysis 2023-10-04 16:16:12 +00:00
Rémy Rakic
43cdf39d89 rename ancient regioncx 2023-10-04 16:16:12 +00:00
Rémy Rakic
4f7a27b225 introduce Polonius enum for -Zpolonius
this allows to opt into using the legacy version or the in-tree
prototype
2023-10-04 16:16:12 +00:00
Esteban Küber
91b9ffeab0 Reorder fullfillment errors to keep more interesting ones first
In `report_fullfillment_errors` push back `T: Sized`, `T: WellFormed`
and coercion errors to the end of the list. The pre-existing
deduplication logic eliminates redundant errors better that way, keeping
the resulting output with fewer errors than before, while also having
more detail.
2023-10-04 02:04:14 +00:00
cui fliter
f44d116e1f Fix misuses of a vs an
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-10-04 08:01:11 +08:00
ouz-a
5d753abb30 have better explanation for relate_types 2023-10-02 23:39:45 +03:00
ouz-a
6f0c5ee2d4 change is_subtype to relate_types 2023-10-02 23:39:45 +03:00
ouz-a
cd7f471931 Add docs, remove code, change subtyper code 2023-10-02 23:39:44 +03:00
ouz-a
3148e6a993 subtyping_projections 2023-10-02 23:37:49 +03:00
Matthias Krüger
fd95627134 fix clippy::{redundant_guards, useless_format} 2023-09-27 23:49:15 +02:00
bors
6b99cf1d35 Auto merge of #116163 - compiler-errors:lazyness, r=oli-obk
Don't store lazyness in `DefKind::TyAlias`

1. Don't store lazyness of a type alias in its `DefKind`, but instead via a query.
2. This allows us to treat type aliases as lazy if `#[feature(lazy_type_alias)]` *OR* if the alias contains a TAIT, rather than having checks for both in separate parts of the codebase.

r? `@oli-obk` cc `@fmease`
2023-09-27 01:48:53 +00:00
lcnr
3c52a3e280 subst -> instantiate 2023-09-26 09:37:55 +02:00
Michael Goulet
d6ce9ce115 Don't store lazyness in DefKind 2023-09-26 02:53:59 +00:00
Camille GILLOT
26cb34cd18 Remove span from BrAnon. 2023-09-24 09:46:55 +00:00
Jack Huey
35dd0c9049 Try to use approximate placeholder regions when outputting an AscribeUserType error in borrowck 2023-09-24 02:10:30 -04:00
Michael Goulet
087a571e70 Record asyncness span in HIR 2023-09-21 19:18:14 +00:00
Guillaume Gomez
208f6ed95c
Rollup merge of #115972 - RalfJung:const-consistency, r=oli-obk
rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const

Also, be more consistent with the `to/eval_bits` methods... we had some that take a type and some that take a size, and then sometimes the one that takes a type is called `bits_for_ty`.

Turns out that `ty::Const`/`mir::ConstKind` carry their type with them, so we don't need to even pass the type to those `eval_bits` functions at all.

However this is not properly consistent yet: in `ty` we have most of the methods on `ty::Const`, but in `mir` we have them on `mir::ConstKind`. And indeed those two types are the ones that correspond to each other. So `mir::ConstantKind` should actually be renamed to `mir::Const`. But what to do with `mir::Constant`? It carries around a span, that's really more like a constant operand that appears as a MIR operand... it's more suited for `syntax.rs` than `consts.rs`, but the bigger question is, which name should it get if we want to align the `mir` and `ty` types? `ConstOperand`? `ConstOp`? `Literal`? It's not a literal but it has a field called `literal` so it would at least be consistently wrong-ish...

``@oli-obk`` any ideas?
2023-09-21 13:25:39 +02:00
Oli Scherer
9c762b58ba Prevent promotion of const fn calls in inline consts 2023-09-21 09:00:22 +00:00
Ralf Jung
c94410c145 rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const 2023-09-21 08:12:30 +02:00
Nicholas Nethercote
1281d43942 Remove RegionHighlightMode::tcx.
It's easier to pass it in to the one method that needs it
(`highlighting_region_vid`) than to store it in the type. This means
`RegionHighlightMode` can impl `Default`.
2023-09-18 09:37:09 +10:00
yukang
f9a9ff20a2 cleanup on messages 2023-09-12 07:27:17 +08:00
bors
e2b3676733 Auto merge of #114586 - oli-obk:patch_tait_rpit_order_check, r=lcnr,compiler-errors
Bubble up opaque <eq> opaque operations instead of picking an order

In case we are in `Bubble` mode (meaning every opaque type that is defined in the current crate is treated as if it were in its defining scope), we don't try to register an opaque type as the hidden type of another opaque type, but instead bubble up an obligation to equate them at the query caller site. Usually that means we have a `DefiningAnchor::Bind` and thus can reliably figure out whether an opaque type is in its defining scope. Where we can't, we'll error out, so the default is sound.

With this change we start using `AliasTyEq` predicates in the old solver, too.

fixes https://github.com/rust-lang/rust/issues/108498

But also regresses `tests/ui/impl-trait/anon_scope_creep.rs`. Our use of `Bubble` for `check_opaque_type_well_formed` is going to keep biting us.

r? `@lcnr` `@compiler-errors`
2023-09-11 19:01:38 +00:00
Oli Scherer
930affa39d Bubble up opaque <eq> opaque operations instead of picking an order 2023-09-11 16:53:39 +00:00
bors
3ebb5629d1 Auto merge of #115595 - surechen:114896, r=davidtwco
Fix incorrect mutable suggestion information for binding in ref pattern like:  `let &b = a;`

fixes #114896

I find we have to get pat_span but not local_decl.source_info.span for suggestion. In `let &b = a;`  pat_span is &b. I think check `let &b = a` in hir to make sure it is hir::Node::Local(hir::Local {pat: hir::Pat{kind: hir::PatKind::Ref(.......   can distinguish it from other situation, but I'm not sure.

If my processing method is not accurate, please guide me to modify it, thank you.

r? `@davidtwco`
2023-09-11 15:02:59 +00:00
bors
68c2f5ba0f Auto merge of #115308 - chenyukang:yukang-fix-62387-iter-mut, r=davidtwco
suggest iter_mut() where trying to modify elements from .iter()

Fixes https://github.com/rust-lang/rust/issues/115259
Fixes https://github.com/rust-lang/rust/issues/62387
2023-09-11 12:41:30 +00:00
Nicholas Nethercote
64ea8eb1a9 Disentangle Debug and Display for Ty.
The `Debug` impl for `Ty` just calls the `Display` impl for `Ty`. This
is surprising and annoying. In particular, it means `Debug` doesn't show
as much information as `Debug` for `TyKind` does. And `Debug` is used in
some user-facing error messages, which seems bad.

This commit changes the `Debug` impl for `Ty` to call the `Debug` impl
for `TyKind`. It also does a number of follow-up changes to preserve
existing output, many of which involve inserting
`with_no_trimmed_paths!` calls. It also adds `Display` impls for
`UserType` and `Canonical`.

Some tests have changes to expected output:
- Those that use the `rustc_abi(debug)` attribute.
- Those that use the `EMIT_MIR` annotation.

In each case the output is slightly uglier than before. This isn't
ideal, but it's pretty weird (particularly for the attribute) that the
output is using `Debug` in the first place. They're fairly obscure
attributes (I hadn't heard of them) so I'm not worried by this.

For `async-is-unwindsafe.stderr`, there is one line that now lacks a
full path. This is a consistency improvement, because all the other
mentions of `Context` in this test lack a path.
2023-09-11 12:51:07 +10:00
bors
c5775a776f Auto merge of #115602 - oli-obk:lower_intrinsics, r=petrochenkov
Don't report any errors in `lower_intrinsics`.

Intrinsics should have been type checked earlier.

This is part of moving all mir-opt diagnostics early enough so that they are reliably emitted even in check builds: https://github.com/rust-lang/rust/issues/49292#issuecomment-1692212095
2023-09-07 11:02:54 +00:00
surechen
a8f3c7684d fixes #114896 2023-09-07 11:07:33 +08:00
Matthias Krüger
b046541b62
Rollup merge of #114511 - chenyukang:yukang-fix-114374-fmt-args, r=b-naber
Remove the unhelpful let binding diag comes from FormatArguments

Fixes #114374
2023-09-06 19:31:48 +02:00
yukang
3988ff25bc suggest iter_mut() where trying to modify elements from .iter() 2023-09-07 00:20:38 +08:00
Oli Scherer
65f25fe194 Don't report any errors in lower_intrinsics. They should have been typecked before. 2023-09-06 09:38:15 +00:00
Jason Newcomb
f686bd8949 Take &mut Results in ResultsVisitor 2023-09-02 19:35:51 -04:00
Rémy Rakic
10ef8d9bf7 remove dummy UniverseInfo causes from type checker fully_perform_op
This was backfilling causes for new universes that may have been created
by an op, when there was no error info to use for improved
diagnostics. We don't need to do that anymore: `other()` is the default when
there is no registered universe cause.
2023-08-31 11:41:58 +00:00
Rémy Rakic
ae963b560f remove dummy UniverseInfo causes from type checker type_check
This was pre-filling causes for universes that could already exist in
the InferCtxt. We don't need to do that anymore: `other()` is the default when
there is no registered universe cause.
2023-08-31 11:16:35 +00:00
Rémy Rakic
407695132c remove dummy UniverseInfo causes from type checker instantiate_canonical_with_fresh_inference_vars
This was backfilling causes for the new universes that can be created by
the InferCtxt. We don't need to do that anymore: `other()` is the default when
there is no registered universe cause.
2023-08-31 11:10:54 +00:00
Rémy Rakic
a725436c29 return default UniverseInfo cause in RegionInferenceContext
Query canonicalization can create local super-universes without causes,
creating ICEs when accessed during diagnostics.
2023-08-30 13:51:09 +00:00
bors
b60f7b51a2 Auto merge of #115045 - RalfJung:unwind-terminate-reason, r=davidtwco
when terminating during unwinding, show the reason why

With this, the output on double-panic becomes something like that:
```
thread 'main' panicked at src/tools/miri/tests/fail/panic/double_panic.rs:15:5:
first
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at src/tools/miri/tests/fail/panic/double_panic.rs:10:9:
second
stack backtrace:
   0:           0xbe273a - std::backtrace_rs::backtrace::miri::trace_unsynchronized::<&mut [closure@std::sys_common::backtrace::_print_fmt::{closure#1}]>
                               at /home/r/src/rust/rustc.3/library/std/src/../../backtrace/src/backtrace/miri.rs:99:5
   1:           0xbe22e6 - std::backtrace_rs::backtrace::miri::trace::<&mut [closure@std::sys_common::backtrace::_print_fmt::{closure#1}]>
                               at /home/r/src/rust/rustc.3/library/std/src/../../backtrace/src/backtrace/miri.rs:62:14
   2:           0xbe1086 - std::backtrace_rs::backtrace::trace_unsynchronized::<[closure@std::sys_common::backtrace::_print_fmt::{closure#1}]>
                               at /home/r/src/rust/rustc.3/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   3:           0xba3afd - std::sys_common::backtrace::_print_fmt
                               at /home/r/src/rust/rustc.3/library/std/src/sys_common/backtrace.rs:67:5
   4:           0xba2471 - <std::sys_common::backtrace::_print::DisplayBacktrace as std::fmt::Display>::fmt
                               at /home/r/src/rust/rustc.3/library/std/src/sys_common/backtrace.rs:44:22
   5:           0xbcf754 - core::fmt::rt::Argument::<'_>::fmt
                               at /home/r/src/rust/rustc.3/library/core/src/fmt/rt.rs:138:9
   6:           0x9b8f81 - std::fmt::write
                               at /home/r/src/rust/rustc.3/library/core/src/fmt/mod.rs:1094:17
   7:           0x21391d - <std::sys::unix::stdio::Stderr as std::io::Write>::write_fmt
                               at /home/r/src/rust/rustc.3/library/std/src/io/mod.rs:1714:15
   8:           0xba37b1 - std::sys_common::backtrace::_print
                               at /home/r/src/rust/rustc.3/library/std/src/sys_common/backtrace.rs:47:5
   9:           0xba365b - std::sys_common::backtrace::print
                               at /home/r/src/rust/rustc.3/library/std/src/sys_common/backtrace.rs:34:9
  10:           0x143c67 - std::panic_hook_with_disk_dump::{closure#1}
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:278:22
  11:           0x144187 - std::panic_hook_with_disk_dump
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:312:9
  12:           0x143659 - std::panicking::default_hook
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:239:5
  13:           0x1482a7 - std::panicking::rust_panic_with_hook
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:729:13
  14:           0x1475d5 - std::rt::begin_panic::<&str>::{closure#0}
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:650:9
  15:           0xba496a - std::sys_common::backtrace::__rust_end_short_backtrace::<[closure@std::rt::begin_panic<&str>::{closure#0}], !>
                               at /home/r/src/rust/rustc.3/library/std/src/sys_common/backtrace.rs:170:18
  16:           0x147599 - std::rt::begin_panic::<&str>
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:649:12
  17:            0x31916 - <Foo as std::ops::Drop>::drop
                               at src/tools/miri/tests/fail/panic/double_panic.rs:10:9
  18:           0x1a2b5e - std::ptr::drop_in_place::<Foo> - shim(Some(Foo))
                               at /home/r/src/rust/rustc.3/library/core/src/ptr/mod.rs:497:1
  19:            0x202bf - main
                               at src/tools/miri/tests/fail/panic/double_panic.rs:16:1
  20:            0xcc6a8 - <fn() as std::ops::FnOnce<()>>::call_once - shim(fn())
                               at /home/r/src/rust/rustc.3/library/core/src/ops/function.rs:250:5
  21:           0xba47d9 - std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>
                               at /home/r/src/rust/rustc.3/library/std/src/sys_common/backtrace.rs:154:18
  22:           0x141a6a - std::rt::lang_start::<()>::{closure#0}
                               at /home/r/src/rust/rustc.3/library/std/src/rt.rs:166:18
  23:            0xcca18 - std::ops::function::impls::<impl std::ops::FnOnce<()> for &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>::call_once
                               at /home/r/src/rust/rustc.3/library/core/src/ops/function.rs:284:13
  24:           0x146469 - std::panicking::try::do_call::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:524:40
  25:           0x145e09 - std::panicking::try::<i32, &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:488:19
  26:            0x7b0ac - std::panic::catch_unwind::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>
                               at /home/r/src/rust/rustc.3/library/std/src/panic.rs:142:14
  27:           0x14189b - std::rt::lang_start_internal::{closure#2}
                               at /home/r/src/rust/rustc.3/library/std/src/rt.rs:148:48
  28:           0x146481 - std::panicking::try::do_call::<[closure@std::rt::lang_start_internal::{closure#2}], isize>
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:524:40
  29:           0x145e2c - std::panicking::try::<isize, [closure@std::rt::lang_start_internal::{closure#2}]>
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:488:19
  30:            0x7b0d5 - std::panic::catch_unwind::<[closure@std::rt::lang_start_internal::{closure#2}], isize>
                               at /home/r/src/rust/rustc.3/library/std/src/panic.rs:142:14
  31:           0x1418b0 - std::rt::lang_start_internal
                               at /home/r/src/rust/rustc.3/library/std/src/rt.rs:148:20
  32:           0x141a97 - std::rt::lang_start::<()>
                               at /home/r/src/rust/rustc.3/library/std/src/rt.rs:165:17
thread 'main' panicked at /home/r/src/rust/rustc.3/library/core/src/panicking.rs:126:5:
panic in a destructor during cleanup
stack backtrace:
   0:           0xe9f6d7 - std::backtrace_rs::backtrace::miri::trace_unsynchronized::<&mut [closure@std::sys_common::backtrace::_print_fmt::{closure#1}]>
                               at /home/r/src/rust/rustc.3/library/std/src/../../backtrace/src/backtrace/miri.rs:99:5
   1:           0xe9f27d - std::backtrace_rs::backtrace::miri::trace::<&mut [closure@std::sys_common::backtrace::_print_fmt::{closure#1}]>
                               at /home/r/src/rust/rustc.3/library/std/src/../../backtrace/src/backtrace/miri.rs:62:14
   2:           0xe9e016 - std::backtrace_rs::backtrace::trace_unsynchronized::<[closure@std::sys_common::backtrace::_print_fmt::{closure#1}]>
                               at /home/r/src/rust/rustc.3/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   3:           0xba3afd - std::sys_common::backtrace::_print_fmt
                               at /home/r/src/rust/rustc.3/library/std/src/sys_common/backtrace.rs:67:5
   4:           0xba2471 - <std::sys_common::backtrace::_print::DisplayBacktrace as std::fmt::Display>::fmt
                               at /home/r/src/rust/rustc.3/library/std/src/sys_common/backtrace.rs:44:22
   5:           0xbcf754 - core::fmt::rt::Argument::<'_>::fmt
                               at /home/r/src/rust/rustc.3/library/core/src/fmt/rt.rs:138:9
   6:           0x9b8f81 - std::fmt::write
                               at /home/r/src/rust/rustc.3/library/core/src/fmt/mod.rs:1094:17
   7:           0x4d0895 - <std::sys::unix::stdio::Stderr as std::io::Write>::write_fmt
                               at /home/r/src/rust/rustc.3/library/std/src/io/mod.rs:1714:15
   8:           0xba37b1 - std::sys_common::backtrace::_print
                               at /home/r/src/rust/rustc.3/library/std/src/sys_common/backtrace.rs:47:5
   9:           0xba365b - std::sys_common::backtrace::print
                               at /home/r/src/rust/rustc.3/library/std/src/sys_common/backtrace.rs:34:9
  10:           0x400bd4 - std::panic_hook_with_disk_dump::{closure#1}
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:278:22
  11:           0x144187 - std::panic_hook_with_disk_dump
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:312:9
  12:           0x143659 - std::panicking::default_hook
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:239:5
  13:           0x1482a7 - std::panicking::rust_panic_with_hook
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:729:13
  14:           0x40403b - std::panicking::begin_panic_handler::{closure#0}
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:619:13
  15:           0xe618b3 - std::sys_common::backtrace::__rust_end_short_backtrace::<[closure@std::panicking::begin_panic_handler::{closure#0}], !>
                               at /home/r/src/rust/rustc.3/library/std/src/sys_common/backtrace.rs:170:18
  16:           0x403fc8 - std::panicking::begin_panic_handler
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:617:5
  17:           0xee23e9 - core::panicking::panic_nounwind_fmt
                               at /home/r/src/rust/rustc.3/library/core/src/panicking.rs:96:14
  18:           0xee29e6 - core::panicking::panic_nounwind
                               at /home/r/src/rust/rustc.3/library/core/src/panicking.rs:126:5
  19:           0xee365e - core::panicking::panic_in_cleanup
                               at /home/r/src/rust/rustc.3/library/core/src/panicking.rs:206:5
  20:            0x2028a - main
                               at src/tools/miri/tests/fail/panic/double_panic.rs:13:1
  21:           0x3895ee - <fn() as std::ops::FnOnce<()>>::call_once - shim(fn())
                               at /home/r/src/rust/rustc.3/library/core/src/ops/function.rs:250:5
  22:           0xe61725 - std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>
                               at /home/r/src/rust/rustc.3/library/std/src/sys_common/backtrace.rs:154:18
  23:           0x3fe9aa - std::rt::lang_start::<()>::{closure#0}
                               at /home/r/src/rust/rustc.3/library/std/src/rt.rs:166:18
  24:           0x389962 - std::ops::function::impls::<impl std::ops::FnOnce<()> for &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>::call_once
                               at /home/r/src/rust/rustc.3/library/core/src/ops/function.rs:284:13
  25:           0x4033b9 - std::panicking::try::do_call::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:524:40
  26:           0x402d58 - std::panicking::try::<i32, &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:488:19
  27:           0x337ff7 - std::panic::catch_unwind::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>
                               at /home/r/src/rust/rustc.3/library/std/src/panic.rs:142:14
  28:           0x3fe7e7 - std::rt::lang_start_internal::{closure#2}
                               at /home/r/src/rust/rustc.3/library/std/src/rt.rs:148:48
  29:           0x4033d6 - std::panicking::try::do_call::<[closure@std::rt::lang_start_internal::{closure#2}], isize>
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:524:40
  30:           0x402d7f - std::panicking::try::<isize, [closure@std::rt::lang_start_internal::{closure#2}]>
                               at /home/r/src/rust/rustc.3/library/std/src/panicking.rs:488:19
  31:           0x338028 - std::panic::catch_unwind::<[closure@std::rt::lang_start_internal::{closure#2}], isize>
                               at /home/r/src/rust/rustc.3/library/std/src/panic.rs:142:14
  32:           0x1418b0 - std::rt::lang_start_internal
                               at /home/r/src/rust/rustc.3/library/std/src/rt.rs:148:20
  33:           0x3fe9dc - std::rt::lang_start::<()>
                               at /home/r/src/rust/rustc.3/library/std/src/rt.rs:165:17
thread caused non-unwinding panic. aborting.
```
If we also land https://github.com/rust-lang/rust/pull/115020, the 2nd backtrace disappears, hopefully making the "panic in a destructor during cleanup" easier to see.

Fixes https://github.com/rust-lang/rust/issues/114954.
2023-08-25 08:47:18 +00:00
bors
aa5dbee3eb Auto merge of #115147 - estebank:issue-114311, r=davidtwco
Suggest mutable borrow on read only for-loop that should be mutable

```
error[E0596]: cannot borrow `*test` as mutable, as it is behind a `&` reference
  --> $DIR/suggest-mut-iterator.rs:22:9
   |
LL |     for test in &tests {
   |                 ------ this iterator yields `&` references
LL |         test.add(2);
   |         ^^^^ `test` is a `&` reference, so the data it refers to cannot be borrowed as mutable
   |
help: use a mutable iterator instead
   |
LL |     for test in &mut tests {
   |                  +++
```

Fix #114311.
2023-08-24 15:05:17 +00:00
Ralf Jung
4c53783f3c when terminating during unwinding, show the reason why 2023-08-24 13:28:26 +02:00
Mark Rousskov
0a916062aa Bump cfg(bootstrap) 2023-08-23 20:05:14 -04:00
Esteban Küber
c1a7af0f2a Suggest mutable borrow on read only for-loop that should be mutable
```
error[E0596]: cannot borrow `*test` as mutable, as it is behind a `&` reference
  --> $DIR/suggest-mut-iterator.rs:22:9
   |
LL |     for test in &tests {
   |                 ------ this iterator yields `&` references
LL |         test.add(2);
   |         ^^^^ `test` is a `&` reference, so the data it refers to cannot be borrowed as mutable
   |
help: use a mutable iterator instead
   |
LL |     for test in &mut tests {
   |                  +++
```

Address #114311.
2023-08-23 21:46:18 +00:00
yukang
1f107b1ef3 Remove the unhelpful let binding diag comes from FormatArguments 2023-08-23 12:35:00 +08:00
Ralf Jung
818ec8e23a give some unwind-related terminators a more clear name 2023-08-20 15:52:38 +02:00
Kyle Lin
297ff8c97e Fix redundant explicit link in rustc_borrowck 2023-08-19 02:22:13 +08:00
Camille GILLOT
388f6a6413 Make TerminatorEdge plural. 2023-08-16 18:12:18 +00:00
Camille GILLOT
5173d85043 Allow apply_terminator_effect to customize edges. 2023-08-16 18:12:17 +00:00
Camille GILLOT
934a99eb65 Move domain_size to GenKillAnalysis. 2023-08-16 18:12:17 +00:00
lcnr
e04f582e56 review 2023-08-14 15:27:14 +02:00
lcnr
95fddbc501 check for non-defining uses of RPIT 2023-08-14 15:25:20 +02:00
Matthias Krüger
3cd0a109a8
Rollup merge of #114566 - fmease:type-alias-laziness-is-crate-specific, r=oli-obk
Store the laziness of type aliases in their `DefKind`

Previously, we would treat paths referring to type aliases as *lazy* type aliases if the current crate had lazy type aliases enabled independently of whether the crate which the alias was defined in had the feature enabled or not.

With this PR, the laziness of a type alias depends on the crate it is defined in. This generally makes more sense to me especially if / once lazy type aliases become the default in a new edition and we need to think about *edition interoperability*:

Consider the hypothetical case where the dependency crate has an older edition (and thus eager type aliases), it exports a type alias with bounds & a where-clause (which are void but technically valid), the dependent crate has the latest edition (and thus lazy type aliases) and it uses that type alias. Arguably, the bounds should *not* be checked since at any time, the dependency crate should be allowed to change the bounds at will with a *non*-major version bump & without negatively affecting downstream crates.

As for the reverse case (dependency: lazy type aliases, dependent: eager type aliases), I guess it rules out anything from slight confusion to mild annoyance from upstream crate authors that would be caused by the compiler ignoring the bounds of their type aliases in downstream crates with older editions.

---

This fixes #114468 since before, my assumption that the type alias associated with a given weak projection was lazy (and therefore had its variances computed) did not necessarily hold in cross-crate scenarios (which [I kinda had a hunch about](https://github.com/rust-lang/rust/pull/114253#discussion_r1278608099)) as outlined above. Now it does hold.

`@rustbot` label F-lazy_type_alias
r? `@oli-obk`
2023-08-08 03:30:56 +02:00
León Orell Valerian Liehr
5468336d6b
Store the laziness of type aliases in the DefKind 2023-08-07 15:54:31 +02:00
Matthias Krüger
35b271306f
Rollup merge of #114477 - estebank:arc-clone, r=compiler-errors
Account for `Rc` and `Arc` when suggesting to clone

When suggesting to clone a reference-counted value, be less uncertain.
2023-08-04 21:32:00 +02:00
Matthias Krüger
99e4127d85
Rollup merge of #114434 - Nilstrieb:indexing-spans, r=est31
Improve spans for indexing expressions

fixes #114388

Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location.

This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the `fn_span` field in THIR.

r? compiler-errors
2023-08-04 21:31:57 +02:00
Esteban Küber
edc3e26773 Account for Rc and Arc when suggesting to clone
When suggesting to clone a reference-counted value, be less uncertain.
2023-08-04 17:50:12 +00:00
Ali MJ Al-Nasrawy
d55522aad8 don't ICE on higher ranked hidden types 2023-08-04 15:11:09 +00:00
Nilstrieb
5706be1854 Improve spans for indexing expressions
Indexing is similar to method calls in having an arbitrary
left-hand-side and then something on the right, which is the main part
of the expression. Method calls already have a span for that right part,
but indexing does not. This means that long method chains that use
indexing have really bad spans, especially when the indexing panics and
that span in coverted into a panic location.

This does the same thing as method calls for the AST and HIR, storing an
extra span which is then put into the `fn_span` field in THIR.
2023-08-04 13:17:39 +02:00
Matthias Krüger
576bf82702
Rollup merge of #114022 - oli-obk:tait_ice_alias_field_projection, r=cjgillot
Perform OpaqueCast field projection on HIR, too.

fixes #105819

This is necessary for closure captures in 2021 edition, as they capture individual fields, not the full mentioned variables. So it may try to capture a field of an opaque (because the hidden type is known to be something with a field).

See https://github.com/rust-lang/rust/pull/99806 for when and why we added OpaqueCast to MIR.
2023-08-04 09:18:58 +02:00
Nilstrieb
5830ca216d Add internal_features lint
It lints against features that are inteded to be internal to the
compiler and standard library. Implements MCP #596.

We allow `internal_features` in the standard library and compiler as those
use many features and this _is_ the standard library from the "internal to the compiler and
standard library" after all.

Marking some features as internal wasn't exactly the most scientific approach, I just marked some
mostly obvious features. While there is a categorization in the macro,
it's not very well upheld (should probably be fixed in another PR).

We always pass `-Ainternal_features` in the testsuite
About 400 UI tests and several other tests use internal features.
Instead of throwing the attribute on each one, just always allow them.
There's nothing wrong with testing internal features^^
2023-08-03 14:50:50 +02:00
Deadbeef
4fec845c3f Remove constness from TraitPredicate 2023-08-02 15:38:00 +00:00
Nilstrieb
46f6b05eb7
Rollup merge of #114079 - compiler-errors:closure-upvars, r=oli-obk
Use `upvar_tys` in more places, make it return a list

Just a cleanup that fell out of a PR that I was gonna write, but that PR kinda got stuck.
2023-08-02 13:46:54 +02:00
bors
7a5d2d0138 Auto merge of #114358 - matthiaskrgr:rollup-d810m9e, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #114178 (Account for macros when suggesting a new let binding)
 - #114199 (Don't unsize coerce infer vars in select in new solver)
 - #114301 (Don't check unnecessarily that impl trait is RPIT)
 - #114314 (Tweaks to `adt_sized_constraint`)
 - #114322 (Fix invalid slice coercion suggestion reported in turbofish)
 - #114340 ([rustc_attr][nit] Replace `filter` + `is_some` with `map_or`.)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-02 04:30:51 +00:00
Matthias Krüger
9cdca18840
Rollup merge of #114178 - estebank:let-binding-macro, r=petrochenkov
Account for macros when suggesting a new let binding

Provide a structured suggestion when the expression comes from a macro expansion:

```
error[E0716]: temporary value dropped while borrowed
  --> $DIR/borrowck-let-suggestion.rs:2:17
   |
LL |     let mut x = vec![1].iter();
   |                 ^^^^^^^       - temporary value is freed at the end of this statement
   |                 |
   |                 creates a temporary value which is freed while still in use
LL |
LL |     x.use_mut();
   |     - borrow later used here
   |
   = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider using a `let` binding to create a longer lived value
   |
LL ~     let binding = vec![1];
LL ~     let mut x = binding.iter();
   |
```
2023-08-02 06:22:47 +02:00
bors
90bb4184f8 Auto merge of #114170 - lcnr:add-commmentz, r=compiler-errors
add `dropck_outlives` comments
2023-08-02 02:45:47 +00:00
Michael Goulet
99969d282b Use upvar_tys in more places, make it a list 2023-08-01 23:19:31 +00:00
bors
866710c552 Auto merge of #111753 - cjgillot:simp-place-conflict, r=compiler-errors
Only consider places with the same local in each_borrow_involving_path.

This avoids having a busy loop that repeatedly checks for equality of locals.
2023-08-01 03:53:19 +00:00
lcnr
fc98c5a098 update comment 2023-07-31 12:47:24 +02:00
Esteban Küber
66d23793f0 Account for macros when suggesting a new let binding 2023-07-28 14:44:03 +00:00
lcnr
84043589a6 dropck_outlives comments 2023-07-28 13:16:36 +02:00
Deadbeef
e6b423aebb Remove constness from ParamEnv 2023-07-27 15:50:42 +00:00
Matthias Krüger
fa21a8c6f8
Rollup merge of #114075 - matthiaskrgr:fmt_args_rustc_3, r=wesleywiser
inline format!() args from rustc_codegen_llvm to the end (4)

r? `@WaffleLapkin`
2023-07-27 06:04:13 +02:00
Matthias Krüger
0b13deb548
Rollup merge of #113661 - oli-obk:tait_wtf, r=lcnr
Double check that hidden types match the expected hidden type

Fixes https://github.com/rust-lang/rust/issues/113278 specifically, but I left a TODO for where we should also add some hardening.

It feels a bit like papering over the issue, but at least this way we don't get unsoundness, but just surprising errors. Errors will be improved and given spans before this PR lands.

r? `@compiler-errors` `@lcnr`
2023-07-25 23:34:07 +02:00
Matthias Krüger
c64ef5e070 inline format!() args from rustc_codegen_llvm to the end (4)
r? @WaffleLapkin
2023-07-25 23:20:28 +02:00
David Wood
3857d9c2da
borrowck/errors: fix i18n error in delayed bug
During borrowck, the `MultiSpan` from a buffered diagnostic is cloned and
used to emit a delayed bug indicating a diagnostic was buffered - when
the buffered diagnostic is translated, then the cloned `MultiSpan` may
contain labels which can only render with the diagnostic's arguments, but
the delayed bug being emitted won't have those arguments. Adds a function
which clones `MultiSpan` without also cloning the contained labels, and
use this function when creating the buffered diagnostic delayed bug.

Signed-off-by: David Wood <david@davidtw.co>
2023-07-24 15:47:03 +01:00
Oli Scherer
1d45658329 Some tracing changes 2023-07-24 14:19:26 +00:00
Oli Scherer
44e21503a8 Double check that hidden types match the expected hidden type 2023-07-21 13:19:36 +00:00
Michael Goulet
05f6890b3e Rename arg_iter to iter_instantiated 2023-07-17 21:04:12 +00:00
Matthias Krüger
f6dbf7d69b
Rollup merge of #113599 - chenyukang:yukang-fix-use-maybe_body_owned_by, r=cjgillot
Use maybe_body_owned_by for multiple suggestions

This is a continued work from https://github.com/rust-lang/rust/pull/113567

We have several other suggestions not working for closure, this PR use `maybe_body_owned_by` to fix them and add test cases for them.
2023-07-14 19:33:26 +02:00
Mahdi Dibaiee
e55583c4b8 refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
yukang
bdd04a62f9 fix the issue of shorthand in suggest_cloning 2023-07-14 07:12:38 +08:00
yukang
3ddf6f7c17 use maybe_body_owned_by for closure 2023-07-14 07:12:35 +08:00
Mark Rousskov
cc907f80b9 Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
bors
da1d099f91 Auto merge of #112945 - compiler-errors:tighten-span-of-adjustment-error, r=oli-obk
(re-)tighten sourceinfo span of adjustments in MIR

Diagnostics rely on the spans of MIR statements being (approximately) correct in order to give suggestions relative to that span (i.e. `shrink_to_hi` and `shrink_to_lo`).

I discovered that we're *intentionally* lowering THIR exprs with their parent expr's span if they come from adjustments that are due to a parent expression. While I understand why that may be desirable to demonstrate the relationship of an adjustment and the expression that requires it, it leads to

1. very verbose borrowck output
2. incorrect spans for suggestions

Some diagnostics get around that by giving suggestions relative to other spans we've collected during MIR lowering, such as the span of the method's identifier (e.g. `name` in `.name()`), but this doesn't work too well when things come from desugaring.

I assume it also has lead to numerous tweaks and complications to diagnostics code down the road, which this PR doesn't necessarily aim to fix but may open the gates to fixing later... The last three commits are simplifications due to the fact that we can assume that the move span actually points to what is being moved (and a test).

This regressed in #89110, which was debated somewhat in #90286. cc `@Aaron1011` who originally made this change.

r? diagnostics

Fixes #113547
Fixes #111016
2023-07-12 12:11:09 +00:00
bors
5b733e2bca Auto merge of #113316 - DrMeepster:underefer_perf, r=oli-obk
Rewrite `UnDerefer`, again

This PR is intended to improve the perf regression introduced by #112882.

`UnDerefer` has been separated out again for borrowck reasons. It was a bit overzealous to remove it in the previous PR.

r? `@oli-obk`
2023-07-11 06:52:53 +00:00
Michael Goulet
a74db1abb3 Fix another strange suggestion span 2023-07-10 20:09:28 +00:00
Michael Goulet
3a3f4a2144 Don't use method span on clone suggestion 2023-07-10 20:09:28 +00:00
Nilstrieb
2beabbbf6f Rename adjustment::PointerCast and variants using it to PointerCoercion
It makes it sound like the `ExprKind` and `Rvalue` are supposed to represent all pointer related
casts, when in reality their just used to share a some enum variants. Make it clear there these
are only coercion to make it clear why only some pointer related "casts" are in the enum.
2023-07-07 18:17:16 +02:00
Boxy
12138b8e5e Move TyCtxt::mk_x to Ty::new_x where applicable 2023-07-05 20:27:07 +01:00
DrMeepster
d1c9696b7d bring back un_derefer and rewrite it again 2023-07-04 13:45:23 -07:00
bors
d5a74249c8 Auto merge of #112882 - DrMeepster:new_un_derefer, r=oli-obk
Rewrite `UnDerefer`

Currently, `UnDerefer` is used by drop elaboration to undo the effects of the `Derefer` pass. However, it just recreates the original places with derefs in the middle of the projection. Because `ProjectionElem::Deref` is intended to be removed completely in the future, this will not work forever.

This PR introduces a `deref_chain` method that returns the places behind `DerefTemp` locals in a place and rewrites the move path code to use this. In the process, `UnDerefer` was merged into `MovePathLookup`. Now that move paths use the same places as in the MIR, the other uses of `UnDerefer` no longer require it.

See #98145
cc `@ouz-a`
r? `@oli-obk`
2023-07-03 02:46:39 +00:00
Matthias Krüger
9082287213
Rollup merge of #113174 - chenyukang:yukang-fix-102972-loop-next, r=compiler-errors
Better messages for next on a iterator inside for loops

Fixes #102972
2023-07-01 13:46:01 +02:00
yukang
4189faa21e add typecheck for iterator 2023-06-30 14:50:27 +08:00
yukang
44a8a8d0ca Better messages for next in a iterator inside for loops 2023-06-30 14:02:02 +08:00
Matthias Krüger
6c22e0419f
Rollup merge of #111403 - y21:suggest-slice-swap, r=compiler-errors
suggest `slice::swap` for `mem::swap(&mut x[0], &mut x[1])` borrowck error

Recently saw someone ask why this code (example slightly modified):
```rs
fn main() {
  let mut foo = [1, 2];
  std::mem::swap(&mut foo[0], &mut foo[1]);
}
```
triggers this error and how to fix it:
```
error[E0499]: cannot borrow `foo[_]` as mutable more than once at a time
 --> src/main.rs:4:33
  |
4 |     std::mem::swap(&mut foo[0], &mut foo[1]);
  |     -------------- -----------  ^^^^^^^^^^^ second mutable borrow occurs here
  |     |              |
  |     |              first mutable borrow occurs here
  |     first borrow later used by call
  |
  = help: consider using `.split_at_mut(position)` or similar method to obtain two mutable non-overlapping sub-slices
```
The current help message is nice and goes in the right direction, but I think we can do better for this specific instance and suggest `slice::swap`, which makes this compile
2023-06-30 08:01:12 +02:00
DrMeepster
4fbd6d5af4 Merge un_derefer into MovePathLookup 2023-06-29 22:14:27 -07:00
y21
679c5be405 add slice::swap suggestion 2023-06-29 19:19:59 +02:00
Lukas Markeffsky
5e83ddd279 don't suggest move for borrows that aren't closures 2023-06-28 23:56:58 +02:00
Dylan DPC
dabcbae535
Rollup merge of #112236 - cjgillot:interval-kill, r=davidtwco
Simplify computation of killed borrows

Follow-up to https://github.com/rust-lang/rust/pull/111759

Processing the first block manually once makes the pre-order walk simpler.
2023-06-28 18:28:46 +05:30
Camille GILLOT
b7989393a4 Extract the local != local case in borrow_conflicts_with_place. 2023-06-27 18:19:09 +00:00
Camille GILLOT
372366d686 Only consider places with the same local in each_borrow_involving_path. 2023-06-27 17:57:10 +00:00
bors
b5e51db16d Auto merge of #112938 - compiler-errors:clause-3, r=oli-obk
Migrate `TyCtxt::predicates_of` and `ParamEnv::caller_bounds` to `Clause`

The last big change in the series.

I will follow-up with additional filed issues once this PR lands:
- [ ] Investigate making `TypeFoldable<TyCtxt<'tcx>> for ty::Clause<'tcx>` implementation less weird: 2efe091705/compiler/rustc_middle/src/ty/structural_impls.rs (L672)
- [ ] Clean up the elaborator since it should only be emitting child clauses, not predicates
- [ ] Rename identifiers like `pred` and `predicates` to `clause` if they're actually clauses around the codebase
- [ ] Validate that all of the `ToPredicate` impls are acutally still needed, or prune them if they're not

r? `@ghost` until the other branch lands
2023-06-27 03:14:45 +00:00
bors
b9ad9b78a2 Auto merge of #112693 - ericmarkmartin:use-more-placeref, r=spastorino
Use PlaceRef abstractions more often

Associated issue: https://github.com/rust-lang/rust/issues/80647

r? `@spastorino`
2023-06-27 00:34:49 +00:00
Michael Goulet
fbdef58414 Migrate predicates_of and caller_bounds to Clause 2023-06-26 23:12:03 +00:00
Eric Mark Martin
c07c10d1e4 use PlaceRef abstractions more consistently 2023-06-25 20:38:01 -04:00