Commit Graph

1119 Commits

Author SHA1 Message Date
Boxy c04106f9f1 check array type of repeat exprs is wf 2023-05-04 11:22:40 +01:00
bors 6f8c0557e0 Auto merge of #110806 - WaffleLapkin:unmkI, r=lcnr
Replace `tcx.mk_trait_ref` with `TraitRef::new`

First step in implementing https://github.com/rust-lang/compiler-team/issues/616
r? `@lcnr`
2023-05-04 05:54:09 +00:00
lcnr 0c5fe37786 remove `inside_canonicalization_ctxt` flag
we never reach the code checking for this flag while the
flag is enabled, so it does not change the behavior
of the code.
2023-05-03 21:03:19 +02:00
Nicholas Nethercote 6b62f37402 Restrict `From<S>` for `{D,Subd}iagnosticMessage`.
Currently a `{D,Subd}iagnosticMessage` can be created from any type that
impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static,
str>`, which are reasonable. It also includes `&String`, which is pretty
weird, and results in many places making unnecessary allocations for
patterns like this:
```
self.fatal(&format!(...))
```
This creates a string with `format!`, takes a reference, passes the
reference to `fatal`, which does an `into()`, which clones the
reference, doing a second allocation. Two allocations for a single
string, bleh.

This commit changes the `From` impls so that you can only create a
`{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static,
str>`. This requires changing all the places that currently create one
from a `&String`. Most of these are of the `&format!(...)` form
described above; each one removes an unnecessary static `&`, plus an
allocation when executed. There are also a few places where the existing
use of `&String` was more reasonable; these now just use `clone()` at
the call site.

As well as making the code nicer and more efficient, this is a step
towards possibly using `Cow<'static, str>` in
`{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing
the `From<&'a str>` impls to `From<&'static str>`, which is doable, but
I'm not yet sure if it's worthwhile.
2023-05-03 08:44:39 +10:00
Ben Kimock f08f903fa9 Box AssertKind 2023-05-01 23:12:41 -04:00
Matthias Krüger 1b262b8b56
Rollup merge of #110823 - compiler-errors:tweak-await-span, r=b-naber
Tweak await span to not contain dot

Fixes a discrepancy between method calls and await expressions where the latter are desugared to have a span that *contains* the dot (i.e. `.await`) but method call identifiers don't contain the dot. This leads to weird suggestions suggestions in borrowck -- see linked issue.

Fixes #110761

This mostly touches a bunch of tests to tighten their `await` span.
2023-05-01 01:09:47 +02:00
klensy 07266362c6 Lrc -> Rc 2023-04-30 13:24:10 +03:00
klensy a621ec35ae RegionInferenceContext: remove Rc from rev_scc_graph field 2023-04-30 12:18:40 +03:00
Camille GILLOT 9325a254f0 Make PlaceMention a non-mutating use. 2023-04-29 16:14:33 +00:00
Matthias Krüger 34ef13b15b
Rollup merge of #110960 - lukas-code:unused-mut, r=compiler-errors
fix false negative for `unused_mut`

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

We want to avoid double diagnostics for code like this, but only if an error actually occurs:
```rust
fn main() {
    let mut x: (i32, i32);
    x.0 = 1;
}
```

The first commit fixes the lint and the second one removes all the unused `mut`s it found.
2023-04-28 22:56:47 +02:00
Lukas Markeffsky fc63926e18 remove unused `mut`s 2023-04-28 20:19:48 +02:00
Maybe Waffle 754a62c306 Fix an ICE in conflict errors diagnostics 2023-04-28 17:37:56 +00:00
Lukas Markeffsky 69c71dacda fix false negative for `unused_mut` 2023-04-28 19:35:40 +02:00
Michael Goulet 6c9249f689 Don't call await a method 2023-04-27 17:18:12 +00:00
Maybe Waffle 4f2532fb53 Switch `ty::TraitRef::from_lang_item` from using `TyCtxtAt` to `TyCtxt` and a `Span` 2023-04-26 10:55:11 +00:00
Michael Goulet 183f1a6a70 Fix lifetime suggestion for type aliases with objects in them 2023-04-25 20:41:59 +00:00
Matthias Krüger 297b222066
Rollup merge of #110556 - kylematsuda:earlybinder-explicit-item-bounds, r=compiler-errors
Switch to `EarlyBinder` for `explicit_item_bounds`

Part of the work to finish https://github.com/rust-lang/rust/issues/105779.

This PR adds `EarlyBinder` to the return type of the `explicit_item_bounds` query and removes `bound_explicit_item_bounds`.

r? `@compiler-errors` (hope it's okay to request you, since you reviewed #110299 and #110498 😃)
2023-04-25 21:06:32 +02:00
Maybe Waffle 46b01abbcd Replace `tcx.mk_trait_ref` with `ty::TraitRef::new` 2023-04-25 16:12:44 +00:00
Maybe Waffle e496fbec92 Split `{Idx, IndexVec, IndexSlice}` into their own modules 2023-04-24 13:53:35 +00:00
bors 3462f79e94 Auto merge of #108118 - oli-obk:lazy_typeck, r=cjgillot
Run various queries from other queries instead of explicitly in phases

These are just legacy leftovers from when rustc didn't have a query system. While there are more cleanups of this sort that can be done here, I want to land them in smaller steps.

This phased order of query invocations was already a lie, as any query that looks at types (e.g. the wf checks run before) can invoke e.g. const eval which invokes borrowck, which invokes typeck, ...
2023-04-23 13:34:31 +00:00
bors 4396ceca05 Auto merge of #109753 - compiler-errors:replenish-region-constraints, r=aliemjay
Clone region var origins instead of taking them in borrowck

Fixes an issue with the new solver where reporting a borrow-checker error ICEs because it calls `InferCtxt::evaluate_obligation`.

This also removes a handful of unnecessary `tcx.infer_ctxt().build()` calls that are only there to mitigate this same exact issue, but with the old solver.

Fixes compiler-errors/next-solver-hir-issues#12.

----

This implements `@aliemjay's` solution where we just don't *take* the region constraints, but clone them. This potentially makes it easier to write a bug about taking region constraints twice or never at all, but again, not many folks are touching this code.
2023-04-22 15:15:51 +00:00
bors 21fab435da Auto merge of #104844 - cjgillot:mention-eval-place, r=jackh726,RalfJung
Evaluate place expression in `PlaceMention`

https://github.com/rust-lang/rust/pull/102256 introduces a `PlaceMention(place)` MIR statement which keep trace of `let _ = place` statements from surface rust, but without semantics.

This PR proposes to change the behaviour of `let _ =` patterns with respect to the borrow-checker to verify that the bound place is live.

Specifically, consider this code:
```rust
let _ = {
    let a = 5;
    &a
};
```

This passes borrowck without error on stable. Meanwhile, replacing `_` by `_: _` or `_p` errors with "error[E0597]: `a` does not live long enough", [see playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=c448d25a7c205dc95a0967fe96bccce8).

This PR *does not* change how `_` patterns behave with respect to initializedness: it remains ok to bind a moved-from place to `_`.

The relevant test is `tests/ui/borrowck/let_underscore_temporary.rs`. Crater check found no regression.

For consistency, this PR changes miri to evaluate the place found in `PlaceMention`, and report eventual dangling pointers found within it.

r? `@RalfJung`
2023-04-22 09:54:21 +00:00
bors 80a2ec49a4 Auto merge of #106934 - DrMeepster:offset_of, r=WaffleLapkin
Add offset_of! macro (RFC 3308)

Implements https://github.com/rust-lang/rfcs/pull/3308 (tracking issue #106655) by adding the built in macro `core::mem::offset_of`. Two of the future possibilities are also implemented:

* Nested field accesses (without array indexing)
* DST support (for `Sized` fields)

I wrote this a few months ago, before the RFC merged. Now that it's merged, I decided to rebase and finish it.

cc `@thomcc` (RFC author)
2023-04-22 00:10:44 +00:00
Oli Scherer 1ce80e210d Allow `LocalDefId` as the argument to `def_path_str` 2023-04-21 22:27:20 +00:00
Camille GILLOT ddfa2463e2 Evaluate place expression in `PlaceMention`. 2023-04-21 21:34:59 +00:00
DrMeepster 511e457c4b offset_of 2023-04-21 02:14:02 -07:00
Michael Goulet 964600b38e Clone region var origins instead of taking in borrowck 2023-04-21 00:31:43 +00:00
Kyle Matsuda f3b279fcc5 add EarlyBinder to output of explicit_item_bounds; replace bound_explicit_item_bounds usages; remove bound_explicit_item_bounds query 2023-04-20 12:36:50 -06:00
Camille GILLOT b275d2c30b Remove WithOptconstParam. 2023-04-20 17:48:32 +00:00
Maybe Waffle cac143f0e3 Extend and use `hir::Node::body_id` 2023-04-19 19:13:45 +00:00
Maybe Waffle 102c0af5a7 Add suggestion to use a closure arg instead of a capture on bck error 2023-04-19 19:13:35 +00:00
Maybe Waffle cfe5c3ca6c Add `#[track_caller]` to `struct_span_err_with_code` (drive-by cleanup)
We use caller information to track where a diagnostic was created,
so all "helper" diagnostic functions should use `#[track_caller]`
2023-04-19 19:10:37 +00:00
Maybe Waffle ceabcd83e6 Remove useless check (drive-by cleanup)
While it might *seem* that this does something, it actually doesn't.
`mut_borrow_of_mutable_ref` returns a `bool` that is ignored by the
let-else. This was basically
```rust
if !self.body.local_decls.get(local).is_some() {
    return
}
```
Which is pretty useless
2023-04-19 19:10:25 +00:00
bors d7f9e81650 Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwco
Add `rustc_fluent_macro` to decouple fluent from `rustc_macros`

Fluent, with all the icu4x it brings in, takes quite some time to compile. `fluent_messages!` is only needed in further downstream rustc crates, but is blocking more upstream crates like `rustc_index`. By splitting it out, we allow `rustc_macros` to be compiled earlier, which speeds up `x check compiler` by about 5 seconds (and even more after the needless dependency on `serde_json` is removed from `rustc_data_structures`).
2023-04-19 08:26:47 +00:00
Nilstrieb b5d3d970fa Add `rustc_fluent_macro` to decouple fluent from `rustc_macros`
Fluent, with all the icu4x it brings in, takes quite some time to
compile. `fluent_messages!` is only needed in further downstream rustc
crates, but is blocking more upstream crates like `rustc_index`. By
splitting it out, we allow `rustc_macros` to be compiled earlier, which
speeds up `x check compiler` by about 5 seconds (and even more after the
needless dependency on `serde_json` is removed from
`rustc_data_structures`).
2023-04-18 18:56:22 +00:00
Josh Soref e09d0d2a29 Spelling - compiler
* account
* achieved
* advising
* always
* ambiguous
* analysis
* annotations
* appropriate
* build
* candidates
* cascading
* category
* character
* clarification
* compound
* conceptually
* constituent
* consts
* convenience
* corresponds
* debruijn
* debug
* debugable
* debuggable
* deterministic
* discriminant
* display
* documentation
* doesn't
* ellipsis
* erroneous
* evaluability
* evaluate
* evaluation
* explicitly
* fallible
* fulfill
* getting
* has
* highlighting
* illustrative
* imported
* incompatible
* infringing
* initialized
* into
* intrinsic
* introduced
* javascript
* liveness
* metadata
* monomorphization
* nonexistent
* nontrivial
* obligation
* obligations
* offset
* opaque
* opportunities
* opt-in
* outlive
* overlapping
* paragraph
* parentheses
* poisson
* precisely
* predecessors
* predicates
* preexisting
* propagated
* really
* reentrant
* referent
* responsibility
* rustonomicon
* shortcircuit
* simplifiable
* simplifications
* specify
* stabilized
* structurally
* suggestibility
* translatable
* transmuting
* two
* unclosed
* uninhabited
* visibility
* volatile
* workaround

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-17 16:09:18 -04:00
Matthias Krüger 0790996a07
Rollup merge of #110394 - scottmcm:less-idx-new, r=WaffleLapkin
Various minor Idx-related tweaks

Nothing particularly exciting here, but a couple of things I noticed as I was looking for more index conversions to simplify.

cc https://github.com/rust-lang/compiler-team/issues/606
r? `@WaffleLapkin`
2023-04-17 18:13:35 +02:00
Matthias Krüger 91fe117418
Rollup merge of #104055 - AndyJado:bck_errors, r=davidtwco
Migrate diagnostics in `rustc_borrowck`

sorry for making a new PR, [#103559](https://github.com/rust-lang/rust/pull/103559) and [#103960](https://github.com/rust-lang/rust/pull/103960).

I am crawling, joyfully.
2023-04-17 18:13:33 +02:00
Nilstrieb 2109fe4e4e Move some utils out of `rustc_const_eval`
This allows us to get rid of the `rustc_const_eval->rustc_borrowck`
dependency edge which was delaying the compilation of borrowck.

The added utils in `rustc_middle` are small and should not affect
compile times there.
2023-04-16 12:05:54 +02:00
Scott McMurray c98895d9f2 Various minor Idx-related tweaks
Nothing particularly exciting here, but a couple of things I noticed as I was looking for more index conversions to simplify.
2023-04-16 02:42:50 -07:00
Matthias Krüger bcd79c222a fix clippy::{clone_on_copy, useless_conversion} 2023-04-15 19:02:26 +02:00
Nicholas Nethercote bbc400993e Remove `ToRegionVid`.
It is only implemented for `Region`, where it is equivalent to the
inherent `as_var` method.
2023-04-13 12:20:41 +10:00
Nicholas Nethercote 411422f2b9 Remove `impl ToRegionVid for RegionVid`.
It's weird and unnecessary.
2023-04-13 12:10:16 +10:00
Nicholas Nethercote c802694bda Make `Region::as_var` infallible.
It's what all the call sites require.
2023-04-13 12:10:16 +10:00
AndyJado bdf0e74777 migrate ftl msg accroding to #103042 2023-04-13 09:43:46 +08:00
AndyJado d0468a2283 rm var_span_label to var_subdiag & eager subdiag 2023-04-13 09:43:46 +08:00
bors 4087deaccd Auto merge of #110249 - matthiaskrgr:rollup-7iig04q, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #110153 (Fix typos in compiler)
 - #110165 (rustdoc: use CSS `overscroll-behavior` instead of JavaScript)
 - #110175 (Symbol cleanups)
 - #110203 (Remove `..` from return type notation)
 - #110205 (rustdoc: make settings radio and checks thicker, less contrast)
 - #110222 (Improve the error message when forwarding a matched fragment to another macro)
 - #110237 (Split out a separate feature gate for impl trait in associated types)
 - #110241 (tidy: Issue an error when UI test limits are too high)

Failed merges:

 - #110218 (Remove `ToRegionVid`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-12 20:01:36 +00:00
Matthias Krüger b4734f01fe
Rollup merge of #110175 - nnethercote:symbol-cleanups, r=jackh726
Symbol cleanups

r? ```@jackh726```

cc ```@b-naber```
2023-04-12 20:56:22 +02:00
Nicholas Nethercote 74463214a6 Rename `NllVisitor` as `RegionRenumberer`.
It's a more descriptive name.
2023-04-12 07:44:37 +10:00
Nicholas Nethercote 7975779918 Add `sym::anon`. 2023-04-11 14:56:42 +10:00
Nicholas Nethercote bd7f301b20 Use the existing `static` and `env` symbols instead of interning. 2023-04-11 14:56:11 +10:00
Nicholas Nethercote 1eb53902f3 Fix `RegionCtxt::preference_value`.
There's a bad pattern matching confusion present in this function.
`_anon` gets assigned to, and then `_anon` is used as an unbound
variable in the pattern, which is unrelated to the first `_anon`.
If the `_anon` didn't start with `_` the compiler would give warnings.

This was introduced in #104239.

I have rewritten the function to remove the confusion and preserve the
existing behaviour. This seems safest, because the original intent is
not clear.
2023-04-11 14:55:33 +10:00
Nicholas Nethercote 5716ae6982 Introduce `Region::get_name_or_anon`.
For a common pattern.
2023-04-11 14:18:53 +10:00
Nicholas Nethercote 7e8905cd18 Rename a variable. 2023-04-11 13:25:57 +10:00
Nicholas Nethercote 33527755a3 Inline and remove `renumber_regions`.
It has a single callsite.
2023-04-11 13:25:32 +10:00
DaniPopes 677357d32b
Fix typos in compiler 2023-04-10 22:02:52 +02:00
bors 94524020ea Auto merge of #110036 - jackh726:placeholder_boundvar, r=nnethercote
Remove u32 on BrAnon and BoundTyKind::Anon in favor of BoundVar on Placeholder types

r? `@nnethercote`

Better alternative to #110025
2023-04-07 14:26:24 +00:00
Jack Huey f0edcc8a6f Remove index from BrAnon 2023-04-06 23:01:40 -04:00
Jack Huey 4646b3df6a Use BoundTy and BoundRegion instead of kind of PlaceholderTy and PlaceholderRegion 2023-04-06 23:01:35 -04:00
Gary Guo e3f2edc75b Rename `Abort` terminator to `Terminate`
Unify terminology used in unwind action and terminator, and reflect
the fact that a nounwind panic is triggered instead of an immediate
abort is triggered for this terminator.
2023-04-06 09:34:16 +01:00
Gary Guo 0a5dac3062 Add `UnwindAction::Terminate` 2023-04-06 09:34:16 +01:00
Gary Guo 5e6ed132fa Add `UnwindAction::Unreachable`
This also makes eval machine's `StackPopUnwind`
redundant so that is replaced.
2023-04-06 09:34:16 +01:00
Gary Guo daeb844e0c Refactor unwind from Option to a new enum 2023-04-06 09:34:16 +01:00
Scott McMurray 5c3e5af2ed Doc-comment `IndexVec::from_elem` and use it in a few more places 2023-04-03 14:29:32 -07:00
Scott McMurray a2ee7592d6 Use `&IndexSlice` instead of `&IndexVec` where possible
All the same reasons as for `[T]`: more general, less pointer chasing, and `&mut IndexSlice` emphasizes that it doesn't change *length*.
2023-04-02 17:35:37 -07:00
Scott McMurray b5b6def021 Use `FieldIdx` in various things related to aggregates
Shrank `AggregateKind` by 8 bytes on x64, since the active field of a union is tracked as an `Option<FieldIdx>` instead of `Option<usize>`.
2023-04-01 20:32:50 -07:00
bors eb3e9c1f45 Auto merge of #109762 - scottmcm:variantdef-indexvec, r=WaffleLapkin
Update `ty::VariantDef` to use `IndexVec<FieldIdx, FieldDef>`

And while doing the updates for that, also uses `FieldIdx` in `ProjectionKind::Field` and `TypeckResults::field_indices`.

There's more places that could use it (like `rustc_const_eval` and `LayoutS`), but I tried to keep this PR from exploding to *even more* places.

Part 2/? of https://github.com/rust-lang/compiler-team/issues/606
2023-03-31 03:36:18 +00:00
Scott McMurray 4abb455529 Update `ty::VariantDef` to use `IndexVec<FieldIdx, FieldDef>`
And while doing the updates for that, also uses `FieldIdx` in `ProjectionKind::Field` and `TypeckResults::field_indices`.

There's more places that could use it (like `rustc_const_eval` and `LayoutS`), but I tried to keep this PR from exploding to *even more* places.

Part 2/? of https://github.com/rust-lang/compiler-team/issues/606
2023-03-30 09:23:40 -07:00
bors 8a7ca936e6 Auto merge of #105587 - tgross35:once-cell-min, r=m-ou-se
Partial stabilization of `once_cell`

This PR aims to stabilize a portion of the `once_cell` feature:

- `core::cell::OnceCell`
- `std::cell::OnceCell` (re-export of the above)
- `std::sync::OnceLock`

This will leave `LazyCell` and `LazyLock` unstabilized, which have been moved to the `lazy_cell` feature flag.

Tracking issue: https://github.com/rust-lang/rust/issues/74465 (does not fully close, but it may make sense to move to a new issue)

Future steps for separate PRs:
- ~~Add `#[inline]` to many methods~~ #105651
- Update cranelift usage of the `once_cell` crate
- Update rust-analyzer usage of the `once_cell` crate
- Update error messages discussing once_cell

## To be stabilized API summary

```rust
// core::cell (in core/cell/once.rs)

pub struct OnceCell<T> { .. }

impl<T> OnceCell<T> {
    pub const fn new() -> OnceCell<T>;
    pub fn get(&self) -> Option<&T>;
    pub fn get_mut(&mut self) -> Option<&mut T>;
    pub fn set(&self, value: T) -> Result<(), T>;
    pub fn get_or_init<F>(&self, f: F) -> &T where F: FnOnce() -> T;
    pub fn into_inner(self) -> Option<T>;
    pub fn take(&mut self) -> Option<T>;
}

impl<T: Clone> Clone for OnceCell<T>;
impl<T: Debug> Debug for OnceCell<T>
impl<T> Default for OnceCell<T>;
impl<T> From<T> for OnceCell<T>;
impl<T: PartialEq> PartialEq for OnceCell<T>;
impl<T: Eq> Eq for OnceCell<T>;
```

```rust
// std::sync (in std/sync/once_lock.rs)

impl<T> OnceLock<T> {
    pub const fn new() -> OnceLock<T>;
    pub fn get(&self) -> Option<&T>;
    pub fn get_mut(&mut self) -> Option<&mut T>;
    pub fn set(&self, value: T) -> Result<(), T>;
    pub fn get_or_init<F>(&self, f: F) -> &T where F: FnOnce() -> T;
    pub fn into_inner(self) -> Option<T>;
    pub fn take(&mut self) -> Option<T>;
}

impl<T: Clone> Clone for OnceLock<T>;
impl<T: Debug> Debug for OnceLock<T>;
impl<T> Default for OnceLock<T>;
impl<#[may_dangle] T> Drop for OnceLock<T>;
impl<T> From<T> for OnceLock<T>;
impl<T: PartialEq> PartialEq for OnceLock<T>
impl<T: Eq> Eq for OnceLock<T>;
impl<T: RefUnwindSafe + UnwindSafe> RefUnwindSafe for OnceLock<T>;
unsafe impl<T: Send> Send for OnceLock<T>;
unsafe impl<T: Sync + Send> Sync for OnceLock<T>;
impl<T: UnwindSafe> UnwindSafe for OnceLock<T>;
```

No longer planned as part of this PR, and moved to the `rust_cell_try` feature gate:

```rust
impl<T> OnceCell<T> {
    pub fn get_or_try_init<F, E>(&self, f: F) -> Result<&T, E> where F: FnOnce() -> Result<T, E>;
}

impl<T> OnceLock<T> {
    pub fn get_or_try_init<F, E>(&self, f: F) -> Result<&T, E> where F: FnOnce() -> Result<T, E>;
}
```

I am new to this process so would appreciate mentorship wherever needed.
2023-03-30 10:12:23 +00:00
Trevor Gross dc4ba57566 Stabilize a portion of 'once_cell'
Move items not part of this stabilization to 'lazy_cell' or 'once_cell_try'
2023-03-29 18:04:44 -04:00
Scott McMurray 5bbaeadc01 Move `mir::Field` → `abi::FieldIdx`
The first PR for https://github.com/rust-lang/compiler-team/issues/606

This is just the move-and-rename, because it's plenty big-and-bitrotty already.  Future PRs will start using `FieldIdx` more broadly, and concomitantly removing `FieldIdx::new`s.
2023-03-28 22:22:37 -07:00
Scott McMurray 0439d13176 Refactor: `VariantIdx::from_u32(0)` -> `FIRST_VARIANT`
Since structs are always `VariantIdx(0)`, there's a bunch of files where the only reason they had `VariantIdx` or `vec::Idx` imported at all was to get the first variant.

So this uses a constant for that, and adds some doc-comments to `VariantIdx` while I'm there, since it doesn't have any today.
2023-03-25 18:58:25 -07:00
bors e216300876 Auto merge of #108442 - scottmcm:mir-transmute, r=oli-obk
Add `CastKind::Transmute` to MIR

~~Nothing actually produces it in this commit, so I don't know how to test it, but it also means it shouldn't be possible for it to break anything.~~

Includes lowering `transmute` calls to it, so it's used.

Zulip Conversation: <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Good.20first.20isssue/near/321849610>
2023-03-23 18:43:04 +00:00
bors 84dd6dfd9d Auto merge of #109503 - matthiaskrgr:rollup-cnp7kdd, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #108954 (rustdoc: handle generics better when matching notable traits)
 - #109203 (refactor/feat: refactor identifier parsing a bit)
 - #109213 (Eagerly intern and check CrateNum/StableCrateId collisions)
 - #109358 (rustc: Remove unused `Session` argument from some attribute functions)
 - #109359 (Update stdarch)
 - #109378 (Remove Ty::is_region_ptr)
 - #109423 (Use region-erased self type during IAT selection)
 - #109447 (new solver cleanup + implement coherence)
 - #109501 (make link clickable)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-23 07:01:03 +00:00
bors 1c771fec33 Auto merge of #108861 - b-naber:eager-nll-type-relating, r=lcnr
Make NLL Type Relating Eager

We previously instantiated bound regions in nll type relating lazily. Making this eager is more consistent with how we handle type relating in [`higher_ranked_sub`](0a3b557d52/compiler/rustc_infer/src/infer/higher_ranked/mod.rs (L28)) and should allow us to short circuit in case there's structural equality.
2023-03-23 01:26:59 +00:00
Scott McMurray 64cce5fc7d Add `CastKind::Transmute` to MIR
Updates `interpret`, `codegen_ssa`, and `codegen_cranelift` to consume the new cast instead of the intrinsic.

Includes `CastTransmute` for custom MIR building, to be able to test the extra UB.
2023-03-22 15:15:41 -07:00
Matthias Krüger 2ee07a19b7
Rollup merge of #109378 - MU001999:master, r=scottmcm
Remove Ty::is_region_ptr

Fixes #109372
2023-03-22 22:44:42 +01:00
Dylan DPC 70918ecf06
Rollup merge of #109280 - compiler-errors:no-vec-map, r=Mark-Simulacrum
Remove `VecMap`

Not sure what the use of this data structure is over just using `FxIndexMap` or a `Vec`.

r? ```@ghost```
2023-03-23 00:00:32 +05:30
b-naber 8f4cf2e000 print sccs_info strings correctly 2023-03-22 18:13:18 +00:00
b-naber da0fe80137 assertion for only collection nll region variable information for debug in non-canonicalization contexts 2023-03-22 16:59:41 +00:00
bors 9bdb4881c7 Auto merge of #109119 - lcnr:trait-system-cleanup, r=compiler-errors
a general type system cleanup

removes the helper functions `traits::fully_solve_X` as they add more complexity then they are worth. It's confusing which of these helpers should be used in which context.

changes the way we deal with overflow to always add depth in `evaluate_predicates_recursively`. It may make sense to actually fully transition to not have `recursion_depth` on obligations but that's probably a bit too much for this PR.

also removes some other small - and imo unnecessary - helpers.

r? types
2023-03-22 05:33:18 +00:00
Michael Goulet 7e6506764b IdentitySubsts::identity_for_item takes Into<DefId> 2023-03-21 15:38:52 +00:00
lcnr 791ce0b7b5 remove some trait solver helpers
they add more complexity then they are worth. It's confusing
which of these helpers should be used in which context.
2023-03-21 09:57:20 +01:00
Mu42 20dc532085 Remove Ty::is_region_ptr 2023-03-20 15:32:21 +08:00
Michael Goulet 6639538575 Remove VecMap 2023-03-17 20:49:28 +00:00
Matthias Krüger a530f72268
Rollup merge of #109215 - est31:sort_by_key, r=Nilstrieb
Use sort_by_key instead of sort_by

I went over the cases where sort_by is used and in these two, one can use sort_by_key instead.
2023-03-17 08:42:40 +01:00
bors 511364e787 Auto merge of #108944 - cjgillot:clear-local-info, r=oli-obk
Wrap the whole LocalInfo in ClearCrossCrate.

MIR contains a lot of information about locals. The primary purpose of this information is the quality of borrowck diagnostics.

This PR aims to drop this information after MIR analyses are finished, ie. starting from post-cleanup runtime MIR.
2023-03-16 19:59:56 +00:00
est31 a8839c3de7 Use sort_by_key instead of sort_by
I went over the cases where sort_by is used and in these two,
one can use sort_by_key instead.
2023-03-16 13:06:31 +01:00
gimbles e5a5b90afc unequal → not equal 2023-03-15 23:55:48 +05:30
Camille GILLOT 50d0959a2f Remove LocalKind::Var. 2023-03-14 20:52:42 +01:00
Camille GILLOT d31386a52b Make is_block_tail a variant of LocalInfo. 2023-03-14 20:52:42 +01:00
Camille GILLOT bcb161def7 Wrap the whole LocalInfo in ClearCrossCrate. 2023-03-14 20:52:42 +01:00
est31 7e2ecb3cd8 Simplify message paths
This makes it easier to open the messages file while developing on features.

The commit was the result of automatted changes:

for p in compiler/rustc_*; do mv $p/locales/en-US.ftl $p/messages.ftl; rmdir $p/locales; done

for p in compiler/rustc_*; do sed -i "s#\.\./locales/en-US.ftl#../messages.ftl#" $p/src/lib.rs; done
2023-03-11 22:51:57 +01:00
bors 35a0961bbc Auto merge of #108977 - matthiaskrgr:rollup-1bnl1hu, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #108879 (Unconstrained terms should account for infer vars being equated)
 - #108936 (Rustdoc: don't hide anonymous reexport)
 - #108940 (Add myself to compiler reviewers list)
 - #108945 (Make some report and emit errors take DefIds instead of BodyIds)
 - #108946 (Document the resulting values produced when using `From<bool>` on floats)
 - #108956 (Make ptr::from_ref and ptr::from_mut in #106116 const.)
 - #108960 (Remove `body_def_id` from `Inherited`)
 - #108963 (only call git on git checkouts during bootstrap)
 - #108964 (Fix the docs for pointer method with_metadata_of)

Failed merges:

 - #108950 (Directly construct Inherited in typeck.)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-10 15:39:25 +00:00
Michael Goulet fd34549686 Remove body_def_id from Inherited 2023-03-09 23:25:23 +00:00
Camille GILLOT 45f2a1af3b Document borrowck behaviour. 2023-03-09 17:45:13 +00:00
Camille GILLOT 4462bb54e3 Introduce a no-op PlaceMention statement for `let _ =`. 2023-03-09 17:45:13 +00:00
Matthias Krüger 4e84fbf8a0
Rollup merge of #108856 - Zeegomo:remove-drop-and-rep, r=tmiasko
Remove DropAndReplace terminator

#107844 made DropAndReplace unused, let's remove it completely from the codebase.
2023-03-08 21:26:51 +01:00
Giacomo Pasini c5d4e4d907
Remove DropAndReplace terminator
PR 107844 made DropAndReplace unused, let's remove it completely
from the codebase.
2023-03-07 14:25:22 +01:00
bors 8f9e09ac3e Auto merge of #108735 - clubby789:borrowck-unstable, r=Nilstrieb
Remove `allow(potential_query_instability)` from `borrowck`

cc #84447

Replace uses of `FxHash*` with `FxIndex*`. One `#[allow]` for a HashMap in an external crate but the output is sorted afterwards.
2023-03-07 07:01:57 +00:00
bors 8824994ccd Auto merge of #108691 - aliemjay:closure-subject, r=jackh726
fix multiple issues when promoting type-test subject

Multiple interdependent fixes.  See linked issues for a short description of each.

When Promoting a type-test `T: 'a` from within the closure back to its parent function, there are a couple pre-existing bugs and limitations. They were exposed by the recent changes to opaque types because the type-test subject (`T`) is no longer a simple ParamTy.

Commit 1:
Fixes #108635
Fixes #107426

Commit 2:
Fixes #108639

Commit 3:
Fixes #107516
2023-03-07 03:50:22 +00:00
clubby789 3eeb3fd05a Remove `allow(potential_query_instability)` from `borrowck` 2023-03-05 18:59:19 +00:00
bors 0d439f8181 Auto merge of #108351 - petrochenkov:rmdit, r=cjgillot
rustc_middle: Remove trait `DefIdTree`

This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-03-05 10:37:02 +00:00
bors 14c54b637b Auto merge of #107844 - Zeegomo:no-drop-and-rep, r=cjgillot
Desugaring of drop and replace at MIR build

This commit desugars the drop and replace deriving from an
assignment at MIR build, avoiding the construction of the
`DropAndReplace` terminator (which will be removed in a following PR).

In order to retain the same error messages for replaces a new
`DesugaringKind::Replace` variant is introduced.

The changes in the borrowck are also useful for future work in moving drop elaboration
before borrowck, as no `DropAndReplace` would be present there anymore.

Notes on test diffs:
*  `tests/ui/borrowck/issue-58776-borrowck-scans-children`: the assignment deriving from the desugaring kills the borrow.
*  `tests/ui/async-await/async-fn-size-uninit-locals.rs`, `tests/mir-opt/issue_41110.test.ElaborateDrops.after.mir`,  `tests/mir-opt/issue_41888.main.ElaborateDrops.after.mir`:  drop elaboration generates (or reads from) a useless drop flag due to an issue with the dataflow analysis. Will be fixed independently by https://github.com/rust-lang/rust/pull/106430.

See https://github.com/rust-lang/rust/pull/104488 for more context
2023-03-05 07:56:26 +00:00
Ali MJ Al-Nasrawy 427dc18c25 tweak debug output and bless tests 2023-03-04 12:10:42 +03:00
Ali MJ Al-Nasrawy 97381d2f1e tweak ClosureOutlivesSubjectTy 2023-03-04 11:19:56 +03:00
Matthias Krüger 01fc5a7653
Rollup merge of #108694 - est31:backticks_matchmaking_comments, r=Nilstrieb
Match unmatched backticks in compiler/ comments

r? ``@Nilstrieb`` as per [advice](https://github.com/rust-lang/rust/pull/108685#issuecomment-1453018499)
2023-03-03 20:06:30 +01:00
Giacomo Pasini 9cf0ff26f8
use helper function for error reporting 2023-03-03 16:33:11 +01:00
Giacomo Pasini b3a47d9b6b
Desugars drop and replace at MIR build
This commit desugars the drop and replace deriving from an
assignment at MIR build, avoiding the construction of the
DropAndReplace terminator (which will be removed in a followign PR)

In order to retain the same error messages for replaces a new
DesugaringKind::Replace variant is introduced.
2023-03-03 16:33:11 +01:00
Ali MJ Al-Nasrawy 10da7710cd ignore bivariant regions in opaque types 2023-03-03 14:12:05 +03:00
Ali MJ Al-Nasrawy 9d74bff829 smarter algorithm for finding an equal region
Smarter and simpler!
2023-03-03 14:10:25 +03:00
Ali MJ Al-Nasrawy 09524bfd5a promote subject even if it has unnamed regions
Don't require a region to have an `external_name` in order to be
promoted.
2023-03-03 14:04:50 +03:00
est31 ef658907a5 Match end user facing unmatched backticks in compiler/ 2023-03-03 08:39:36 +01:00
est31 ff2c609d66 Match unmatched backticks in compiler/ that are part of rustdoc 2023-03-03 08:39:00 +01:00
Vadim Petrochenkov c83553da31 rustc_middle: Remove trait `DefIdTree`
This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-03-02 23:46:44 +04:00
bors 6290ae92b2 Auto merge of #108487 - cjgillot:no-typeck-mir, r=oli-obk
Avoid invoking typeck from borrowck

This PR attempts to reduce direct dependencies between typeck and MIR-related queries. The goal is to have all the information transit either through THIR or through dedicated queries that avoid depending on the whole `TypeckResults`.

In a first commit, we store the type information that MIR building requires into THIR. This avoids edges between mir_built and typeck.

In the second and third commit, we wrap informations around closures (upvars, kind origin and user-provided signature) to avoid borrowck depending on typeck information.

There should be a single remaining borrowck -> typeck edge in the good path, due to inline consts.
2023-02-27 21:48:10 +00:00
Takayuki Maeda 934c8c2299 avoid `&str` to `String` conversions 2023-02-27 14:27:13 +09:00
Camille GILLOT cb51d2da7a Avoid more calls to typeck. 2023-02-26 10:30:27 +00:00
Camille GILLOT 0915d55d87 Wrap more into into closure_typeinfo query. 2023-02-26 10:30:27 +00:00
Camille GILLOT 7dcc74eee5 Access upvars through a query. 2023-02-26 10:30:27 +00:00
Nicholas Nethercote 2200911616 Rename many interner functions.
(This is a large commit. The changes to
`compiler/rustc_middle/src/ty/context.rs` are the most important ones.)

The current naming scheme is a mess, with a mix of `_intern_`, `intern_`
and `mk_` prefixes, with little consistency. In particular, in many
cases it's easy to use an iterator interner when a (preferable) slice
interner is available.

The guiding principles of the new naming system:
- No `_intern_` prefixes.
- The `intern_` prefix is for internal operations.
- The `mk_` prefix is for external operations.
- For cases where there is a slice interner and an iterator interner,
  the former is `mk_foo` and the latter is `mk_foo_from_iter`.

Also, `slice_interners!` and `direct_interners!` can now be `pub` or
non-`pub`, which helps enforce the internal/external operations
division.

It's not perfect, but I think it's a clear improvement.

The following lists show everything that was renamed.

slice_interners
- const_list
  - mk_const_list -> mk_const_list_from_iter
  - intern_const_list -> mk_const_list
- substs
  - mk_substs -> mk_substs_from_iter
  - intern_substs -> mk_substs
  - check_substs -> check_and_mk_substs (this is a weird one)
- canonical_var_infos
  - intern_canonical_var_infos -> mk_canonical_var_infos
- poly_existential_predicates
  - mk_poly_existential_predicates -> mk_poly_existential_predicates_from_iter
  - intern_poly_existential_predicates -> mk_poly_existential_predicates
  - _intern_poly_existential_predicates -> intern_poly_existential_predicates
- predicates
  - mk_predicates -> mk_predicates_from_iter
  - intern_predicates -> mk_predicates
  - _intern_predicates -> intern_predicates
- projs
  - intern_projs -> mk_projs
- place_elems
  - mk_place_elems -> mk_place_elems_from_iter
  - intern_place_elems -> mk_place_elems
- bound_variable_kinds
  - mk_bound_variable_kinds -> mk_bound_variable_kinds_from_iter
  - intern_bound_variable_kinds -> mk_bound_variable_kinds

direct_interners
- region
  - intern_region (unchanged)
- const
  - mk_const_internal -> intern_const
- const_allocation
  - intern_const_alloc -> mk_const_alloc
- layout
  - intern_layout -> mk_layout
- adt_def
  - intern_adt_def -> mk_adt_def_from_data (unusual case, hard to avoid)
  - alloc_adt_def(!) -> mk_adt_def
- external_constraints
  - intern_external_constraints -> mk_external_constraints

Other
- type_list
  - mk_type_list -> mk_type_list_from_iter
  - intern_type_list -> mk_type_list
- tup
  - mk_tup -> mk_tup_from_iter
  - intern_tup -> mk_tup
2023-02-24 07:32:24 +11:00
bors 07c993eba8 Auto merge of #108369 - compiler-errors:ty-error-more, r=BoxyUwU
Use `tcx.ty_error_with_guaranteed` in more places, rename variants

1. Use `ty_error_with_guaranteed` more so we don't delay so many span bugs
2. Rename `ty_error_with_guaranteed` to `ty_error`, `ty_error` to `ty_error_misc`. This is to incentivize using the former over the latter in cases where we already are witness to a `ErrorGuaranteed` token.

Second commit is just name replacement, so the first commit can be reviewed on its own with more scrutiny.
2023-02-23 09:20:10 +00:00
Matthias Krüger d6077f895a
Rollup merge of #108350 - compiler-errors:assoc-type-bound-dogfooding, r=oli-obk
Use associated type bounds in some places in the compiler

Use associated type bounds for some nested `impl Trait<Assoc = impl Trait2>` cases. I'm generally keen to introduce new lang features that are more mature into the compiler, but maybe let's see what others think?

Side-note: I was surprised that the only use-cases of nested impl trait in the compiler are just iterator related?!
2023-02-23 06:18:07 +01:00
bors 0978711950 Auto merge of #108324 - notriddle:notriddle/assoc-fn-method, r=compiler-errors,davidtwco,estebank,oli-obk
diagnostics: if AssocFn has self argument, describe as method

Discussed in https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.22associated.20function.22.20vs.20.22method.22/near/329265515

This commit also changes the tooltips on rustdoc intra-doc links targeting methods.

For anyone not sure why this is being done, see the Reference definitions of these terms in <https://doc.rust-lang.org/1.67.1/reference/items/associated-items.html#methods>

> Associated functions whose first parameter is named `self` are called methods and may be invoked using the [method call operator](https://doc.rust-lang.org/1.67.1/reference/expressions/method-call-expr.html), for example, `x.foo()`, as well as the usual function call notation.

In particular, while this means it's technically correct for rustc to refer to a method as an associated function (and there are a few cases where it'll still do so), rustc *must never* use the term "method" to refer to an associated function that does not have a `self` parameter.
2023-02-23 00:19:12 +00:00
Michael Goulet 298ae8c721 Rename ty_error_with_guaranteed to ty_error, ty_error to ty_error_misc 2023-02-22 22:23:45 +00:00
Michael Goulet 1e7ef03b40 Use ty_error_with_guaranteed in many more places 2023-02-22 22:23:16 +00:00
bors fdbc4329cb Auto merge of #108340 - eggyal:remove_traversal_trait_aliases, r=oli-obk
Remove type-traversal trait aliases

#107924 moved the type traversal (folding and visiting) traits into the type library, but created trait aliases in `rustc_middle` to minimise both the API churn for trait consumers and the arising boilerplate.  As mentioned in that PR, an alternative approach of defining subtraits with blanket implementations of the respective supertraits was also considered at that time but was ruled out as not adding much value.

Unfortunately, it has since emerged that rust-analyzer has difficulty with these trait aliases at present, resulting in a degraded contributor experience (see the recent [r-a has become useless](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/r-a.20has.20become.20useless) topic on the #t-compiler/help Zulip stream).

This PR removes the trait aliases, and accordingly the underlying type library traits are now used directly; they are parameterised by `TyCtxt<'tcx>` rather than just the `'tcx` lifetime, and imports have been updated to reflect the fact that the trait aliases' explicitly named traits are no longer automatically brought into scope.  These changes also roll-back the (no-longer required) workarounds to #107747 that were made in b409329c62.

Since this PR is just a find+replace together with the changes necessary for compilation & tidy to pass, it's currently just one mega-commit.  Let me know if you'd like it broken up.

r? `@oli-obk`
2023-02-22 18:26:51 +00:00
Alan Egerton 695072daa6
Remove type-traversal trait aliases 2023-02-22 17:04:58 +00:00
Michael Howell 3d056c3125 diagnostics: if AssocFn has self argument, describe as method
Discussed in
https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.22associated.20function.22.20vs.20.22method.22/near/329265515

This commit also changes the tooltips on rustdoc intra-doc links
targeting methods.
2023-02-22 08:40:33 -07:00
David Wood d1fcf61117 errors: generate typed identifiers in each crate
Instead of loading the Fluent resources for every crate in
`rustc_error_messages`, each crate generates typed identifiers for its
own diagnostics and creates a static which are pulled together in the
`rustc_driver` crate and provided to the diagnostic emitter.

Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-22 09:15:53 +00:00
Matthias Krüger 314fe4d170
Rollup merge of #104239 - b-naber:sccs-info, r=jackh726
Better debug logs for borrowck constraint graph

It's really cumbersome to work with `RegionVar`s when trying to debug borrowck code or when trying to understand how the borrowchecker works. This PR collects some region information (behind `cfg(debug_assertions)`) for created `RegionVar`s (NLL region vars, this PR doesn't touch canonicalization) and prints the nodes and edges of the strongly connected constraints graph using representatives that use that region information (either lifetime names, locations in MIR or spans).
2023-02-21 23:01:58 +01:00
b-naber 8252a6eddf address review 2023-02-21 21:54:53 +00:00
Oli Scherer 88a7b6803b Make hidden type registration opt-in, so that each site can be reviewed on its own and we have the right defaults for trait solvers 2023-02-21 14:50:51 +00:00
Michael Goulet 729cd55688 Associated type bounds in some places in the compiler 2023-02-21 03:49:22 +00:00
b-naber c9843d6144 remove cfg attributes 2023-02-20 22:00:30 +00:00
bors e7eaed21d5 Auto merge of #107969 - b-naber:proj-relate-variance, r=lcnr
Use covariance on type relations of field projection types if possible

It's fine to use covariance here unless we're in a mutating context.

Fixes https://github.com/rust-lang/rust/issues/96514

Supersedes https://github.com/rust-lang/rust/pull/105958

r? `@lcnr`
2023-02-20 09:25:51 +00:00
b-naber 0725d0ceee add some cfgs back 2023-02-19 22:24:18 +00:00
b-naber aefc5ec110 remove cfgs 2023-02-19 22:16:22 +00:00
b-naber 2d2bccf751 rebase 2023-02-19 22:13:07 +00:00
b-naber 46bd77aa80 some conditional imports 2023-02-19 22:12:12 +00:00
b-naber e2bf960fe1 sccs info 2023-02-19 22:12:12 +00:00
b-naber 960ebaf899 collect existentials and placeholders 2023-02-19 22:12:09 +00:00
b-naber 2f79f73821 collect region contexts during mir renumbering 2023-02-19 22:11:27 +00:00
b-naber cb35a7b481 add BorrowckInferCtxt 2023-02-19 22:07:17 +00:00
Nicholas Nethercote bcf0ec0191 Replace `mk_foo` calls with `infer_foo` where possible.
There are several `mk_foo`/`intern_foo` pairs, where the former takes an
iterator and the latter takes a slice. (This naming convention is bad,
but that's a fix for another PR.)

This commit changes several `mk_foo` occurrences into `intern_foo`,
avoiding the need for some `.iter()`/`.into_iter()` calls. Affected
cases:
- mk_type_list
- mk_tup
- mk_substs
- mk_const_list
2023-02-17 22:24:31 +11:00
Kyle Matsuda c183110cc2 remove bound_type_of query; make type_of return EarlyBinder; change type_of in metadata 2023-02-16 17:05:56 -07:00
Kyle Matsuda d822b97a27 change usages of type_of to bound_type_of 2023-02-16 17:01:52 -07:00
bors 9a7cc6c32f Auto merge of #108127 - matthiaskrgr:rollup-kpzfc6j, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #106347 (More accurate spans for arg removal suggestion)
 - #108057 (Prevent some attributes from being merged with others on reexports)
 - #108090 (`if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)`)
 - #108092 (note issue for feature(packed_bundled_libs))
 - #108099 (use chars instead of strings where applicable)
 - #108115 (Do not ICE on unmet trait alias bounds)
 - #108125 (Add new people to the compiletest review rotation)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-16 19:21:02 +00:00
bors c5d1b3ea96 Auto merge of #108020 - nnethercote:opt-mk_region, r=compiler-errors
Optimize `mk_region`

PR #107869 avoiding some interning under `mk_ty` by special-casing `Ty` variants with simple (integer) bodies. This PR does something similar for regions.

r? `@compiler-errors`
2023-02-16 16:11:54 +00:00
Maybe Waffle 5bf6a46032 Replace some `then`s with some `then_some`s 2023-02-16 15:26:03 +00:00
Maybe Waffle 8751fa1a9a `if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)` 2023-02-16 15:26:00 +00:00
b-naber 758cc95763 exhaustive matching in get_ambient_variance 2023-02-15 21:13:12 +00:00
Matthias Krüger 8f65e25aec
Rollup merge of #108010 - compiler-errors:can_eq-returns-bool, r=lcnr
Make `InferCtxt::can_eq` and `InferCtxt::can_sub` return booleans

Nobody matches on the result, nor does the result return anything useful...
2023-02-15 21:30:56 +01:00
bors 2d14db321b Auto merge of #108006 - cjgillot:def-impl, r=oli-obk
Avoid accessing HIR when it can be avoided

Experiment to see if it helps some incremental cases.

Will be rebased once https://github.com/rust-lang/rust/pull/107942 gets merged.

r? `@ghost`
2023-02-15 16:14:10 +00:00
Dylan DPC 83f10ea5b7
Rollup merge of #105300 - aliemjay:member-lower, r=oli-obk
rework min_choice algorithm of member constraints

See [this comment](https://github.com/rust-lang/rust/pull/105300#issuecomment-1384312743) for the description of the new algorithm.

Fixes #63033
Fixes #104639

This uses a more general algorithm than #89056 that doesn't treat `'static` as a special case. It thus accepts more code. For example:
```rust
async fn test2<'s>(_: &'s u8, _: &'_ &'s u8, _: &'_ &'s u8) {}
```
I claim it's more correct as well because it fixes #104639.

cc ``@nikomatsakis`` ``@lqd`` ``@tmandry`` ``@eholk`` ``@chenyukang`` ``@oli-obk``

r? types
2023-02-15 12:24:53 +05:30
Nicholas Nethercote cef9004f5a Add specialized variants of `mk_region`.
Much like there are specialized variants of `mk_ty`. This will enable
some optimization in the next commit.

Also rename the existing `re_error*` functions as `mk_re_error*`, for
consistency.
2023-02-15 09:02:44 +11:00
Camille GILLOT 03dff82d59 Add `of_trait` to DefKind::Impl. 2023-02-14 19:55:44 +00:00
Oli Scherer 936bf29d4c s/eval_usize/eval_target_usize/ for clarity 2023-02-14 08:51:19 +00:00
Michael Goulet eb286dd070 Make can_eq and can_sub return booleans 2023-02-13 19:29:02 +00:00
Alan Egerton ba55a453eb
Alias folding/visiting traits instead of re-export 2023-02-13 10:24:46 +00:00
b-naber 6e1d228285 only require sub type relation on field projection types 2023-02-12 23:18:15 +01:00
bors 1623ab0246 Auto merge of #107507 - BoxyUwU:deferred_projection_equality, r=lcnr
Implement `deferred_projection_equality` for erica solver

Somewhat of a revival of #96912. When relating projections now emit an `AliasEq` obligation instead of attempting to determine equality of projections that may not be as normalized as possible (i.e. because of lazy norm, or just containing inference variables that prevent us from resolving an impl). Only do this when the new solver is enabled
2023-02-11 05:46:24 +00:00
Boxy 1f89e2aef2 emit `AliasEq` when relating type and const aliases 2023-02-10 14:33:13 +00:00
bors d1ac43a9b9 Auto merge of #107652 - estebank:re_error, r=oli-obk
Introduce `ReError`

CC #69314

r? `@nagisa`
2023-02-10 10:10:12 +00:00
Jack Huey 0637b6b471 Update implied_outlives_bounds to properly register implied bounds behind normalization 2023-02-09 21:08:11 -05:00
Jack Huey 1a663c0f53 Cleanup free_region_relations a bit 2023-02-09 20:38:27 -05:00
Esteban Küber ed8651c7b8 Use 'static RegionVid for ReError 2023-02-09 10:26:50 +00:00
Esteban Küber 861f451235 Change to `ReError(ErrorGuaranteed)` 2023-02-09 10:26:49 +00:00
Esteban Küber 30cf7a3f51 Introduce `ReError`
CC #69314
2023-02-09 10:26:49 +00:00
Matthias Krüger ec65285fdd
Rollup merge of #107780 - compiler-errors:instantiate-binder, r=lcnr
Rename `replace_bound_vars_with_*` to `instantiate_binder_with_*`

Mentioning "binder" rather than "bound vars", imo, makes it clearer that we're doing something to the binder as a whole.

Also, "instantiate" is the verb that I'm always reaching for when I'm looking for these functions, and the name that we use in the new solver anyways.

r? types
2023-02-08 18:32:44 +01:00
Michael Goulet 03a8a4ff3e Replacing bound vars is actually instantiating a binder 2023-02-07 23:13:54 +00:00
bors 3f059f6046 Auto merge of #107768 - matthiaskrgr:rollup-9u4cal4, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #107719 (Remove `arena_cache` modifier from `upstream_monomorphizations_for`)
 - #107740 (Avoid locking the global context across the `after_expansion` callback)
 - #107746 (Split fn_ctxt/adjust_fulfillment_errors from fn_ctxt/checks)
 - #107749 (allow quick-edit convenience)
 - #107750 (make more readable)
 - #107755 (remove binder from query constraints)
 - #107756 (miri: fix ICE when running out of address space)
 - #107764 (llvm-16: Use Triple.h from new header location.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-07 20:58:20 +00:00
lcnr a04f31dc34 remove binder from query constraints 2023-02-07 10:59:18 +01:00
Edward Shen af5a37e844
Modify existing bounds if they exist 2023-02-06 11:26:36 -08:00
Matthias Krüger d381eca5dc
Rollup merge of #107646 - estebank:specific-span, r=compiler-errors
Provide structured suggestion for binding needing type on E0594

Partially address #45405.
2023-02-04 20:29:06 +01:00
bors 9dee4e4c42 Auto merge of #107267 - cjgillot:keep-aggregate, r=oli-obk
Do not deaggregate MIR

This turns out to simplify a lot of things.
I haven't checked the consequences for miri yet.

cc `@JakobDegen`
r? `@oli-obk`
2023-02-04 15:17:32 +00:00
Esteban Küber e6c56cda09 review comments 2023-02-03 23:41:39 +00:00
Esteban Küber da1360d981 Provide structured suggestion for binding needing type on E0594
Partially address #45405.
2023-02-03 18:53:27 +00:00
Matthias Krüger 6b94f4dccc
Rollup merge of #106575 - estebank:issue-64008, r=pnkfelix
Suggest `move` in nested closure when appropriate

Fix #64008.
2023-02-03 06:30:22 +01:00
Camille GILLOT 0241c29123 Put a DefId in AggregateKind. 2023-02-02 23:09:51 +00:00
Esteban Küber e6b84eb797 Suggest `move` in nested closure when appropriate
Fix #64008.
2023-02-02 16:26:01 +00:00
Matthias Krüger 3e0995a440
Rollup merge of #107532 - compiler-errors:erase-regions-in-uninhabited, r=jackh726
Erase regions before doing uninhabited check in borrowck

~Also, fingerprint query keys/values when debug assertions are enabled. This should make it easier to check for issues like this without `-Cincremental`, and make UI tests a bit cleaner.~ edit: moving that to a separate PR

Fixes #107505
2023-02-02 17:14:07 +01:00
Michael Goulet 2c23c7f0cd Erase regions before uninhabited check 2023-02-01 01:14:34 +00:00
Guillaume Gomez 53bb6322db
Rollup merge of #107467 - WaffleLapkin:uneq, r=oli-obk
Improve enum checks

Some light refactoring.
2023-01-31 23:38:52 +01:00
bors a64ef7d07d Auto merge of #100754 - davidtwco:translation-incremental, r=compiler-errors
incremental: migrate diagnostics

- Apply the diagnostic migration lints to more functions on `Session`, namely: `span_warn`, `span_warn_with_code`, `warn` `note_without_error`, `span_note_without_error`, `struct_note_without_error`.
- Add impls of `IntoDiagnosticArg` for `std::io::Error`, `std::path::Path` and `std::path::PathBuf`.
- Migrate the `rustc_incremental` crate's diagnostics to translatable diagnostic structs.

r? `@compiler-errors`
cc #100717
2023-01-31 10:20:58 +00:00
bors 001a77fac3 Auto merge of #107197 - aliemjay:patch-2, r=jackh726
assume MIR types are fully normalized in ascribe_user_type

This FIXME was introduced in c6a17bf8bc but it should've been restricted to `ascribe_user_type_skip_wf`.
2023-01-30 19:42:49 +00:00
David Wood 2575b1abc9 session: diagnostic migration lint on more fns
Apply the diagnostic migration lint to more functions on `Session`.

Signed-off-by: David Wood <david.wood@huawei.com>
2023-01-30 17:11:35 +00:00
David Wood f7b42102e6 errors: implement `IntoDiagnosticArg` for `&T`
Implement `IntoDiagnosticArg` for `&'a T` when `T` implements
`IntoDiagnosticArg` and `Clone`. Makes it easier to write diagnostic
structs that borrow something which implements `IntoDiagnosticArg`.

Signed-off-by: David Wood <david.wood@huawei.com>
2023-01-30 17:11:34 +00:00
Maybe Waffle 4d75f61832 Use `Mutability::{is_mut, is_not}` 2023-01-30 12:26:26 +00:00
bors a29efccb1e Auto merge of #107435 - matthiaskrgr:rollup-if5h6yu, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #106618 (Disable `linux_ext` in wasm32 and fortanix rustdoc builds.)
 - #107097 (Fix def-use dominance check)
 - #107154 (library/std/sys_common: Define MIN_ALIGN for m68k-unknown-linux-gnu)
 - #107397 (Gracefully exit if --keep-stage flag is used on a clean source tree)
 - #107401 (remove the usize field from CandidateSource::AliasBound)
 - #107413 (make more pleasant to read)
 - #107422 (Also erase substs for new infcx in pin move error)
 - #107425 (Check for missing space between fat arrow and range pattern)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-29 07:01:58 +00:00
bors 3cdd0197e7 Auto merge of #106227 - bryangarza:ctfe-limit, r=oli-obk
Use stable metric for const eval limit instead of current terminator-based logic

This patch adds a `MirPass` that inserts a new MIR instruction `ConstEvalCounter` to any loops and function calls in the CFG. This instruction is used during Const Eval to count against the `const_eval_limit`, and emit the `StepLimitReached` error, replacing the current logic which uses Terminators only.

The new method of counting loops and function calls should be more stable across compiler versions (i.e., not cause crates that compiled successfully before, to no longer compile when changes to the MIR generation/optimization are made).

Also see: #103877
2023-01-29 04:11:27 +00:00
Nilstrieb 832751fe1d Also erase substs for new infcx in pin move error
The code originally correctly erased the regions of the type it passed
to the newly created infcx. But after the `fn_sig` query was made to
return an `EarlyBinder<T>`, some substs that were around were
substituted there without erasing their regions. They were then passed
into the newly cerated infcx, which caused the ICE.
2023-01-28 20:43:16 +01:00
Kyle Matsuda 4a7d0e9754 add method_substs to CallKind 2023-01-26 20:28:31 -07:00
Kyle Matsuda a969c194d8 fix up subst_identity vs skip_binder; add some FIXMEs as identified in review 2023-01-26 20:28:31 -07:00
Kyle Matsuda c2414dfaa4 change fn_sig query to use EarlyBinder; remove bound_fn_sig query; add EarlyBinder to fn_sig in metadata 2023-01-26 20:28:25 -07:00
Kyle Matsuda e982971ff2 replace usages of fn_sig query with bound_fn_sig 2023-01-26 20:15:36 -07:00
Matthias Krüger 4b97f07534
Rollup merge of #106971 - oli-obk:tait_error, r=davidtwco
Handle diagnostics customization on the fluent side (for one specific diagnostic)

r? ```@davidtwco```
2023-01-26 15:02:19 +01:00
Matthias Krüger 9e3f330656
Rollup merge of #106897 - estebank:issue-99430, r=davidtwco
Tweak E0597

CC #99430
2023-01-25 22:19:52 +01:00
Matthias Krüger f21728fee4
Rollup merge of #105345 - yanchen4791:issue-103582-fix, r=jackh726
Add hint for missing lifetime bound on trait object when type alias is used

Fix issue #103582.

The problem: When a type alias is used to specify the return type of the method in a trait impl, the suggestion for fixing the problem of "missing lifetime bound on trait object" of the trait impl will not be created. The issue caused by the code which searches for the return trait objects when constructing the hint suggestion is not able to find the trait objects since they are specified in the type alias path instead of the return path of the trait impl.

The solution: Trace the trait objects in the type alias path and provide them along with the alias span to generate the suggestion in case the type alias is used in return type of the method in the trait impl.
2023-01-25 22:19:51 +01:00
Bryan Garza aae331d610 During MirBorrowck, ignore ConstEvalCounter 2023-01-23 23:56:22 +00:00