Commit Graph

21431 Commits

Author SHA1 Message Date
Esteban Küber
fcf0ed9018 Do not erase regions 2023-01-23 14:47:00 +00:00
Esteban Küber
ddd9a9fb46 Add call in emit_type_mismatch_suggestions 2023-01-23 14:46:59 +00:00
Esteban Küber
d5a1609ec4 review comment: use fcx.infcx 2023-01-23 14:46:59 +00:00
Esteban Küber
e477cf9475 Suggest coercion of Result using ?
Fix #47560.
2023-01-23 14:46:59 +00:00
Oli Scherer
d924a8ca59 Evaluate output_filenames before one of its dependencies gets stolen 2023-01-23 14:22:33 +00:00
bors
c8e6a9e8b6 Auto merge of #107220 - JohnTitor:rollup-5pvuz0z, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #106796 (BPF: Disable atomic CAS)
 - #106886 (Make stage2 rustdoc and proc-macro-srv disableable in x.py install)
 - #107101 (Filter param-env predicates for errors before calling `to_opt_poly_trait_pred`)
 - #107109 (ThinBox: Add intra-doc-links for Metadata)
 - #107148 (remove error code from `E0789`, add UI test/docs)
 - #107151 (Instantiate dominators algorithm only once)
 - #107153 (Consistently use dominates instead of is_dominated_by)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-23 13:07:16 +00:00
Vincenzo Palazzo
7d2c1103d7 fix: use LocalDefId instead of HirId in trait res
use LocalDefId instead of HirId in trait resolution to simplify
the obligation clause resolution

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-01-23 11:42:18 +00:00
Oli Scherer
261bbd7dba Store the gctxt instead of fetching it twice. 2023-01-23 10:35:21 +00:00
Oli Scherer
3ddb54f155 Prefer queries over Compiler methods 2023-01-23 10:35:21 +00:00
Oli Scherer
bcc8b05d5c Make output_filenames a real query 2023-01-23 10:35:21 +00:00
Yuki Okushi
eae7f947b5
Rollup merge of #107153 - tmiasko:dominates, r=oli-obk
Consistently use dominates instead of is_dominated_by

There is a number of APIs that answer dominance queries. Previously they were named either "dominates" or "is_dominated_by". Consistently use the "dominates" form.

No functional changes.
2023-01-23 19:30:02 +09:00
Yuki Okushi
c0f80e7166
Rollup merge of #107151 - tmiasko:dominators-no-inline, r=compiler-errors
Instantiate dominators algorithm only once

Remove inline from BasicBlocks::dominators to instantiate the dominator algorithm only once - in the rustc_middle crate.
2023-01-23 19:30:01 +09:00
Yuki Okushi
809d4aa478
Rollup merge of #107148 - Ezrashaw:uncode-e0789, r=compiler-errors,GuillaumeGomez
remove error code from `E0789`, add UI test/docs

`E0789` shouldn't have an error code, it's explicitly internal-only and is tiny in scope. (I wonder if we can tighten the standard for this in the RFC?) I also added a UI test and error docs (done like `E0208`, they are "no longer emitted").

r? `@GuillaumeGomez` (shouldn't need a compiler review, it's pretty minor)
2023-01-23 19:30:00 +09:00
Yuki Okushi
17023496a2
Rollup merge of #107101 - compiler-errors:perf-106309-1, r=petrochenkov
Filter param-env predicates for errors before calling `to_opt_poly_trait_pred`

cc #106309 https://github.com/rust-lang/rust/pull/106757#issuecomment-1396616318

r? `@ghost`
2023-01-23 19:29:59 +09:00
Yuki Okushi
9e79642a7b
Rollup merge of #106796 - vadorovsky:revert-105708-enable-atomic-cas-bpf, r=bjorn3
BPF: Disable atomic CAS

Enabling CAS for BPF targets (https://github.com/rust-lang/rust/pull/105708) breaks the build of core library.
The failure occurs both when building rustc for BPF targets and when
building crates for BPF targets with the current nightly.

The LLVM BPF backend does not correctly lower all `atomicrmw` operations
and crashes for unsupported ones.

Before we can enable CAS for BPF in Rust, we need to fix the LLVM BPF
backend first.

Fixes #106795

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2023-01-23 19:29:58 +09:00
Oli Scherer
abee6137f7 Remove another unneeded use of the resolver 2023-01-23 10:18:45 +00:00
bors
5bef91c6e9 Auto merge of #107136 - petrochenkov:dochidden, r=cjgillot
rustc_metadata: Encode `doc(hidden)` flag to metadata

To retrieve these flags rustdoc currently has to mass decode full attributes for items in the whole crate tree, so it's better to pre-compute it in advance.

This is especially important for short-term performance of https://github.com/rust-lang/rust/pull/107054 because resolver cannot use memoization of query results yet.
2023-01-23 10:12:57 +00:00
Ezra Shaw
00ff718da8
add UI test + docs for E0789 2023-01-23 20:38:14 +13:00
Dylan DPC
66d6a0b5da
Rollup merge of #107203 - chenyukang:yukang/fix-106496-remove-deref, r=compiler-errors
Suggest remove deref for type mismatch

Fixes #106496
2023-01-23 11:52:07 +05:30
Dylan DPC
e4ed082579
Rollup merge of #107195 - smoelius:patch-2, r=Nilstrieb
Fix typo in universal_regions.rs comment
2023-01-23 11:52:06 +05:30
Dylan DPC
f4f3335114
Rollup merge of #107108 - sulami:issue-83968-doc-alias-typo-suggestions, r=compiler-errors
Consider doc(alias) when providing typo suggestions

This means that

```rust
impl Foo {
    #[doc(alias = "quux")]
    fn bar(&self) {}
}

fn main() {
    (Foo {}).quux();
}
```

will suggest `bar`. This currently uses the "there is a method with a similar name" help text, because the point where we choose and emit a suggestion is different from where we gather the suggestions. Changes have mainly been made to the latter.

The selection code will now fall back to aliased candidates, but generally only if there is no candidate that matches based on the existing Levenshtein methodology.

Fixes #83968.
2023-01-23 11:52:05 +05:30
Dylan DPC
3d4c3125be
Rollup merge of #104926 - spastorino:calculate_diverging_fallback-cleanups, r=lcnr
Move relationships from FulfillmentContext to Inherited

r? `@lcnr`
2023-01-23 11:52:04 +05:30
Erik Desjardins
009192b01b abi: add AddressSpace field to Primitive::Pointer
...and remove it from `PointeeInfo`, which isn't meant for this.

There are still various places (marked with FIXMEs) that assume all pointers
have the same size and alignment. Fixing this requires parsing non-default
address spaces in the data layout string, which will be done in a followup.
2023-01-22 23:41:39 -05:00
Erik Desjardins
96f8f99589 rustc_abi: remove Primitive::{is_float,is_int}
there were fixmes for this already

i am about to remove is_ptr (since callers need to properly distinguish
between pointers in different address spaces), so might as well do this
at the same time
2023-01-22 21:02:07 -05:00
Robin Schroer
f908f0be5a
Consider doc(alias) when providing typo suggestions
This means that

```rust
impl Foo {
    #[doc(alias = "quux")]
    fn bar(&self) {}
}

fn main() {
    (Foo {}).quux();
}
```

will suggest `bar`. This currently uses the "there is a method with a
similar name" help text, because the point where we choose and emit a
suggestion is different from where we gather the suggestions. Changes
have mainly been made to the latter.

The selection code will now fall back to aliased candidates, but
generally only if there is no candidate that matches based on the
existing Levenshtein methodology.

Fixes #83968.
2023-01-23 10:07:10 +09:00
bors
a5fa99eed2 Auto merge of #106975 - tmiasko:basic-blocks-cache, r=cjgillot
Refactor basic blocks control flow caches

No functional changes.
2023-01-22 21:35:21 +00:00
yukang
2aa5555ad3 Fix #106496, suggest remove deref for type mismatch 2023-01-23 00:42:20 +08:00
Santiago Pastorino
6155a80380
Rename relationships to infer_var_info 2023-01-22 11:02:28 -03:00
Santiago Pastorino
fb0a4e9589
Move relationships::update to Inherited::update_infer_var_info 2023-01-22 11:02:28 -03:00
Santiago Pastorino
7fe472223e
Store relationships on Inherent 2023-01-22 11:02:28 -03:00
Santiago Pastorino
81ee6aebaa
Remove duplicated debug call 2023-01-22 11:02:28 -03:00
Samuel Moelius
12a72f0329
Update universal_regions.rs 2023-01-22 07:38:02 -05:00
Konrad Borowski
f72e17f8fb Remove dependency on slice_internals feature in rustc_ast 2023-01-22 13:05:47 +01:00
Camille GILLOT
4d11206ee7 Tweak comments. 2023-01-22 11:13:19 +00:00
Camille GILLOT
6ecf30d67d Inline encode_enum_variant_info. 2023-01-22 11:04:53 +00:00
Camille GILLOT
d7f6564fdd Encode AdtDef in the def-id loop. 2023-01-22 11:04:52 +00:00
Matthias Krüger
d779a592dd
Rollup merge of #107127 - uweigand:s390x-sanitizer, r=Mark-Simulacrum
Enable sanitizers for s390x-linux

Include sanitizers supported by LLVM on s390x (asan, lsan, msan, tsan) in the target definition, as well as in the compiletest supported list.

Build sanitizer runtime for the target.  Enable sanitizers in the CI.
2023-01-22 11:43:07 +01:00
Matthias Krüger
6e79310c55
Rollup merge of #107111 - chenyukang:yukang/fix-107090-fluent-parameters, r=petrochenkov
Fix missing arguments issues and copy-paste bug for fluent

Fixes #107090
2023-01-22 11:43:06 +01:00
Matthias Krüger
d022013eb7
Rollup merge of #107102 - compiler-errors:new-solver-new-candidats-4, r=lcnr
Implement some more predicates in the new solver

Implement a few more goals. The subtype goal specifically is important, since it's required for this code to compile:

```
fn main() {
  let mut x = vec![];
  x.push(1i32);
}
```

(I think we emit a subtype goal here because of coercion).

Drive-by: Also implements `--compare-mode=next-solver` -- I've been using this locally a lot to find out what works and what doesn't. I'm also happy to split this out into another PR.

r? `@lcnr`
2023-01-22 11:43:05 +01:00
bors
940d00f2f6 Auto merge of #107185 - compiler-errors:rollup-wkomjma, r=compiler-errors
Rollup of 8 pull requests

Successful merges:

 - #103418 (Add `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` to future-incompat report)
 - #106113 (llvm-wrapper: adapt for LLVM API change)
 - #106144 (Improve the documentation of `black_box`)
 - #106578 (Label closure captures/generator locals that make opaque types recursive)
 - #106749 (Update cc to 1.0.77)
 - #106935 (Fix `SingleUseLifetime` ICE)
 - #107015 (Re-enable building rust-analyzer on riscv64)
 - #107029 (Add new bootstrap members to triagebot.toml)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-22 06:53:36 +00:00
Michael Goulet
8a830cf182
Rollup merge of #106935 - TaKO8Ki:fix-104440, r=cjgillot
Fix `SingleUseLifetime` ICE

Fixes #104440
cc: ``@matthiaskrgr``
2023-01-21 23:21:00 -05:00
Michael Goulet
1d2c9a84fa
Rollup merge of #106578 - compiler-errors:recursive-opaque-closure, r=TaKO8Ki
Label closure captures/generator locals that make opaque types recursive

cc https://github.com/rust-lang/rust/issues/46415#issuecomment-1374665828
2023-01-21 23:20:59 -05:00
Michael Goulet
2504c8d1ee
Rollup merge of #106113 - krasimirgg:llvm-16-ext-tyid, r=nikic
llvm-wrapper: adapt for LLVM API change

No functional changes intended.

The LLVM commit e6b02214c6 added `TargetExtTyID` to the `TypeID` enum. This adapts `RustWrapper` accordingly.
2023-01-21 23:20:58 -05:00
bors
85da15c016 Auto merge of #107133 - pnkfelix:revert-pr-84022-for-issue-106337, r=Mark-Simulacrum
Revert "Make PROC_MACRO_DERIVE_RESOLUTION_FALLBACK a hard error"

This reverts commit 7d82cadd97 aka PR #84022

I am doing this to buy us some time with respect to issue #106337 w.r.t. the 1.67 release.
2023-01-22 03:58:52 +00:00
Aaron Hill
dc8876196b
Add SEMICOLON_IN_EXPRESSIONS_FROM_MACROS to future-incompat report 2023-01-21 14:38:25 -06:00
Nilstrieb
f74ca88384 Use a type-alias-impl-trait in ObligationForest 2023-01-21 20:13:56 +01:00
Vadim Petrochenkov
415c14129b rustc_metadata: Encode doc(hidden) flag to metadata
To retrieve these flags rustdoc currently has to mass decode full attributes for items in the whole crate tree, so it's better to pre-compute it in advance.

This is especially for short-term performance of https://github.com/rust-lang/rust/pull/107054 because resolver cannot use memoization of query results yet.
2023-01-21 22:35:20 +04:00
Michael Goulet
444cbcd729 Address goal nits 2023-01-21 17:15:00 +00:00
Michael Goulet
d6a411c086 Implement some more predicates 2023-01-21 16:37:33 +00:00
bors
005fc0f00f Auto merge of #106977 - michaelwoerister:unord_id_collections, r=oli-obk
Use UnordMap and UnordSet for id collections (DefIdMap, LocalDefIdMap, etc)

This PR changes the `rustc_data_structures::define_id_collections!` macro to use `UnordMap` and `UnordSet` instead of `FxHashMap` and `FxHashSet`. This should account for a large portion of hash-maps being used in places where they can cause trouble.

The changes required are moderate but non-zero:
- In some places the collections are extracted into sorted vecs.
- There are a few instances where for-loops have been changed to extends.

~~Let's see what the performance impact is. With a bit more refactoring, we might be able to get rid of some of the additional sorting -- but the change set is already big enough. Unless there's a performance impact, I'd like to do further changes in subsequent PRs.~~

Performance does not seem to be negatively affected ([perf-run here](https://github.com/rust-lang/rust/pull/106977#issuecomment-1396776699)).

Part of [MCP 533](https://github.com/rust-lang/compiler-team/issues/533).

r? `@ghost`
2023-01-21 14:18:17 +00:00
Tomasz Miąsko
955e7fbb16 Consistently use dominates instead of is_dominated_by
There is a number of APIs that answer dominance queries. Previously they
were named either "dominates" or "is_dominated_by". Consistently use the
"dominates" form.

No functional changes.
2023-01-21 12:15:02 +01:00
Tomasz Miąsko
ae39ee23fe Instantiate dominators algorithm only once
Remove inline from BasicBlocks::dominators to instantiate the dominator
algorithm only once - in the rustc_middle crate.
2023-01-21 12:02:31 +01:00
bors
21f6839352 Auto merge of #106976 - tmiasko:borrowck-lazy-dominators, r=cjgillot
Lazy dominator tree construction in borrowck

Motivated by the observation that sometimes constructed dominator tree was never queried.
2023-01-21 11:02:29 +00:00
Nilstrieb
db305d0ca8 Use strict provenance APIs in ty::tls 2023-01-21 11:25:21 +01:00
Nilstrieb
0d11b77005 Some ty::tls cleanups
Putting the cfged functions into a seperate module and giving them
better names.
2023-01-21 11:24:58 +01:00
Nilstrieb
afd5307934 Move ty::tls to seperate file 2023-01-21 11:19:46 +01:00
bors
b22aa57fd5 Auto merge of #106884 - clubby789:fieldless-enum-debug, r=michaelwoerister
Simplify `derive(Debug)` output for fieldless enums

Fixes #106875
2023-01-21 07:49:09 +00:00
Michael Goulet
8742fd9c85 Label closure captures/generator locals that make opaque types recursive 2023-01-21 05:49:36 +00:00
Michael Goulet
7168aa5eb1
Rollup merge of #107112 - eltociear:patch-19, r=albertlarsan68
Fix typo in opaque_types.rs

paramters -> parameters
2023-01-20 21:33:23 -05:00
Michael Goulet
3452104715
Rollup merge of #107061 - compiler-errors:new-solver-new-candidates-3, r=lcnr
Implement some more new solver candidates and fix some bugs

First, fix some bugs:

1. `IndexVec::drain_enumerated(a..b)` does not give us an iterator of index keys + items enumerated from `a..b`, but from `0..(b-a)`... That caused a bug. See first commit for the fix.
2. Implement the `_: Trait` ambiguity hack. I put it in assemble, let me know if it should live elsewhere. This is important, since we otherwise consider `_: Sized` to have no solutions, and nothing passes!
3. Swap `Ambiguity` and `Unimplemented` cases for the new solver. Sorry for accidentally swapping them 😄
4. Check GATs' own predicates during projection confirmation.

Then implement a few builtin traits:

5. Implement `PointerSized`. Pretty independent.
6. Implement `Fn` family of traits for fnptr, fndef, and closures. Closures are currently broken because `FulfillCtxt::relationships` is intentionally left unimplemented. See comment in the test.

r? ```@lcnr```
2023-01-20 21:33:22 -05:00
Michael Goulet
bf75f8177b
Rollup merge of #104347 - notriddle:notriddle/import-macro-from-self-fixup, r=TaKO8Ki
diagnostics: suggest changing `s@self::{macro}@::macro` for exported

Fixes #99695
2023-01-20 21:33:21 -05:00
Michael Goulet
e6400693b8
Rollup merge of #104154 - timrobertsdev:deny-by-default-bindings_with_variant_name, r=scottmcm
Change `bindings_with_variant_name` to deny-by-default

Changed the `bindings_with_variant_name` lint to deny-by-default and fixed up the affected tests.

Addresses #103442.
2023-01-20 21:33:20 -05:00
Felix S. Klock II
5fa1347331 Revert "Make PROC_MACRO_DERIVE_RESOLUTION_FALLBACK a hard error"
This reverts commit 7d82cadd97.

I am doing this to buy us some time with respect to issue #106337 w.r.t. the
1.67 release.
2023-01-20 17:13:55 -05:00
Michael Howell
c07a722847 diagnostics: remvoe unnecessary use of source_map.start_point 2023-01-20 14:53:34 -07:00
Michael Howell
dca160a06a diagnostics: use module_path to check crate import instead of strings 2023-01-20 14:53:34 -07:00
Michael Howell
e237690a28 diagnostics: add }; only if { was added too 2023-01-20 14:53:33 -07:00
Michael Howell
e9d8d238ef diagnostics: suggest changing s@self::{macro}@::macro for exported
Fixes #99695
2023-01-20 14:52:24 -07:00
bors
94a300b9b8 Auto merge of #105102 - compiler-errors:copy-impl-considering-regions, r=lcnr
Check ADT fields for copy implementations considering regions

Fixes #88901
r? `@ghost`
2023-01-20 21:29:52 +00:00
Lukas Markeffsky
e415e2f1a2 fix overlapping spans for explicit_outlives_requirements in macros
also delete trailing comma if necessary
2023-01-20 20:16:37 +01:00
Lukas Markeffsky
31443c63b5 preserve delim spans during macro_rules! expansion if able 2023-01-20 20:16:37 +01:00
Lukas Markeffsky
b9e8286c85 add debug assertion for suggestions with overlapping parts 2023-01-20 20:16:37 +01:00
Ulrich Weigand
492d928e44 Enable sanitizers for s390x-linux
Include sanitizers supported by LLVM on s390x (asan, lsan, msan, tsan)
in the target definition, as well as in the compiletest supported list.

Build sanitizer runtime for the target.  Enable sanitizers in the CI.
2023-01-20 18:34:24 +01:00
bors
a6269dad38 Auto merge of #107106 - matthiaskrgr:rollup-g7r1ep0, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #106699 ([drop tracking] Visit break expressions )
 - #106738 (Fix known-bug annotations)
 - #106891 (Tweak "borrow closure argument" suggestion)
 - #106928 (add raw identifier for keyword in suggestion)
 - #107065 (Clippy: Make sure to include in beta: Move `unchecked_duration_subtraction` to pedantic)
 - #107068 (autoderive Subdiagnostic for AddtoExternBlockSuggestion)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-20 15:28:40 +00:00
bors
04a41f889f Auto merge of #107105 - matthiaskrgr:rollup-rkz9t7r, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #106783 (Recover labels written as identifiers)
 - #106973 (Don't treat closures from other crates as local)
 - #106979 (Document how to get the type of a default associated type)
 - #107053 (signal update string representation for haiku.)
 - #107058 (Recognise double-equals homoglyph)
 - #107067 (Custom MIR: Support storage statements)
 - #107076 (Added const-generic ui test case for issue #106419)
 - #107091 (Fix broken format strings in `infer.ftl`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-20 12:58:13 +00:00
Ikko Eltociear Ashimine
1adb4d6e5f
Fix typo in opaque_types.rs
paramters -> parameters
2023-01-20 17:56:29 +09:00
--global
1cbce729c7 Add compile_fail to doctest for bindings_with_variant_name 2023-01-20 02:26:12 -05:00
--global
734f375019 Change bindings_with_variant_name to deny-by-default 2023-01-20 02:26:12 -05:00
Matthias Krüger
c44c60caba
Rollup merge of #107068 - mejrs:use_derive, r=estebank
autoderive Subdiagnostic for AddtoExternBlockSuggestion
2023-01-20 07:25:30 +01:00
Matthias Krüger
da7a0c0b30
Rollup merge of #106928 - bvanjoi:print-keyword-raw-identifier, r=petrochenkov
add raw identifier for keyword in suggestion

fix https://github.com/rust-lang/rust/issues/106841
2023-01-20 07:25:29 +01:00
Matthias Krüger
5f2ad80e18
Rollup merge of #106891 - estebank:issue-45727, r=petrochenkov
Tweak "borrow closure argument" suggestion

Fix #45727.
2023-01-20 07:25:28 +01:00
Matthias Krüger
3d79cbc3c1
Rollup merge of #106699 - eholk:await-chains-drop-tracking, r=wesleywiser
[drop tracking] Visit break expressions

This fixes https://github.com/rust-lang/rust/issues/102383 by remembering to visit the expression in `break expr` when building the drop tracking CFG. Missing this step was causing an off-by-one error which meant after a number of awaits we'd be
looking for dropped values at the wrong point in the code.

Additionally, this changes the order of traversal for assignment expressions to visit the rhs and then the lhs. This matches what is done elsewhere.

Finally, this improves some of the debugging output (for example, the CFG visualizer) to make it easier to figure out these sorts of issues.
2023-01-20 07:25:27 +01:00
Matthias Krüger
c42fad8ff3
Rollup merge of #107091 - clubby789:infer-ftl-missing-dollar, r=compiler-errors
Fix broken format strings in `infer.ftl`

Fixes #107088
2023-01-20 07:16:12 +01:00
Matthias Krüger
66a9006759
Rollup merge of #107067 - tmiasko:custom-mir-storage-statements, r=oli-obk
Custom MIR: Support storage statements

r? `@oli-obk` `@JakobDegen`
2023-01-20 07:16:11 +01:00
Matthias Krüger
3693399ffc
Rollup merge of #107058 - clubby789:eqeq-homoglyph, r=wesleywiser
Recognise double-equals homoglyph

Recognise `⩵` as a homoglyph for `==`.

The first commit switches `char` to `&str`, as all previous homoglyphs corresponded to a single ASCII character, while the second implements the fix.

`@rustbot` label +A-diagnostics +A-parser
2023-01-20 07:16:10 +01:00
Matthias Krüger
a2712cb4b6
Rollup merge of #106979 - Nilstrieb:type-of-default-assoc-type, r=petrochenkov
Document how to get the type of a default associated type
2023-01-20 07:16:09 +01:00
Matthias Krüger
240cc81768
Rollup merge of #106973 - oli-obk:tait_ice_closure_in_impl_header, r=lcnr
Don't treat closures from other crates as local

fixes #104817

r? `@lcnr`

Specialization can prefer an impl for an opaque type over a blanket impls that also matches. If the blanket impl only applies if an auto-trait applies, we look at the hidden type of the opaque type to see if that implements the auto trait. The hidden type can be a closure or generator, and thus we will end up seeing these types in coherence and have to handle them properly.
2023-01-20 07:16:09 +01:00
Matthias Krüger
df88f7e02c
Rollup merge of #106783 - WaffleLapkin:break-my-ident, r=wesleywiser
Recover labels written as identifiers

This adds recovery for `break label expr` and `continue label`, as well as a test for `break label`.
2023-01-20 07:16:08 +01:00
bors
56ee85274e Auto merge of #106090 - WaffleLapkin:dereffffffffff, r=Nilstrieb
Remove some `ref` patterns from the compiler

Previous PR: https://github.com/rust-lang/rust/pull/105368

r? `@Nilstrieb`
2023-01-20 04:52:28 +00:00
Michael Goulet
096f454774 Filter predicates first for fast-path type flags 2023-01-20 03:20:17 +00:00
clubby789
f3cde8e9da Fix broken format strings in infer.ftl 2023-01-19 23:13:01 +00:00
Tomasz Miąsko
d3cfe97a8a Custom MIR: Support binary and unary operations 2023-01-19 22:00:33 +01:00
Esteban Küber
33e11a3b2e Tweak "borrow closure argument" suggestion
Fix #45727.
2023-01-19 19:35:49 +00:00
bors
4c83bd03a9 Auto merge of #107038 - compiler-errors:dont-wfcheck-non-local-rpit, r=oli-obk
Don't wf-check non-local RPITs

We were using `ty::is_impl_trait_defn(..).is_none()` to check if we need to add WF obligations for an opaque type.

This is *supposed* to be checking if the type is a TAIT, since RPITs' wfness is implied by wf checking its parent item, but since `is_impl_trait_defn` returns `None` for non-local RPIT and async futures, we unnecessarily consider wf predicates for an RPIT if it is coming from a foreign crate.

Fixes #107036

r? `@oli-obk` but feel free to reassign
2023-01-19 16:49:06 +00:00
Michael Woerister
f219771961 Clean up and document unord collections a bit. 2023-01-19 17:37:59 +01:00
bohan
97ae79ac9d add raw identifier for keyword in suggestion 2023-01-20 00:36:20 +08:00
Michael Goulet
ed6aebbfec trait solver: Implement Fn traits and tuple trait 2023-01-19 16:15:28 +00:00
Michael Goulet
69890b2df4 trait solver: PointerSized 2023-01-19 16:15:28 +00:00
Michael Goulet
f53f5b4463 swap Ambiguity and Unimplemented in new trait engine 2023-01-19 16:15:28 +00:00
Michael Goulet
aee75f25cb Assert goal is fully normalized during assemble 2023-01-19 16:15:28 +00:00
Michael Goulet
7e0b1f1115 Conditionally encode boolean 2023-01-19 16:09:10 +00:00
clubby789
95a824c02c Special case derive(Debug) for fieldless enums 2023-01-19 15:53:31 +00:00
Michael Goulet
200f466d1a Encode whether foreign opaques are TAITs or not 2023-01-19 15:45:49 +00:00
clubby789
97cf1713d1 Add enum for fieldless unification 2023-01-19 15:41:11 +00:00
Michael Goulet
c9c8e294d2 HACK: self ty ambiguity hack 2023-01-19 15:31:57 +00:00
Michael Goulet
280f69d858 Fix IndexVec::drain_enumerated 2023-01-19 15:25:33 +00:00
lcnr
0accf08e6b remove unnecessary check for opaque types 2023-01-19 16:06:25 +01:00
bors
19423b5944 Auto merge of #106910 - aliemjay:alias-ty-in-regionck, r=oli-obk
even more unify Projection/Opaque handling in region outlives code

edit: This continues ate the same pace as #106829. New changes are described in https://github.com/rust-lang/rust/pull/106910#issuecomment-1383251254.

~This touches `OutlivesBound`, `Component`, `GenericKind` enums.~

r? `@oli-obk` (because of overlap with #95474)
2023-01-19 14:05:07 +00:00
mejrs
cc5af33d64 Autoderive ExternBlockSuggestion 2023-01-19 13:52:15 +01:00
Ali MJ Al-Nasrawy
a7a842027c even more unify Projection/Opaque in outlives code 2023-01-19 15:31:53 +03:00
Oli Scherer
42f1f54a5e Don't treat closures from other crates as local 2023-01-19 11:29:40 +00:00
Tomasz Miąsko
ca3d55e32d Custom MIR: Support storage statements 2023-01-19 11:53:33 +01:00
Guillaume Gomez
dee88e0fa2
Rollup merge of #107037 - tmiasko:rank, r=oli-obk
Fix Dominators::rank_partial_cmp to match documentation

The only use site is also updated accordingly and there is no change in end-to-end behaviour.
2023-01-19 11:19:36 +01:00
Guillaume Gomez
246daa49ee
Rollup merge of #106931 - Ezrashaw:docs-e0208, r=compiler-errors
document + UI test `E0208` and make its output more user-friendly

Cleans up `E0208`'s output a lot. It could actually be useful for someone learning about variance now. I also added a UI test for it in `tests/ui/error-codes/` and wrote some docs for it.

r? `@GuillaumeGomez` another error code, can't be bothered to find the issue :P. Obviously there's some compiler stuff, so you'll have to hand it off.

Part of https://github.com/rust-lang/rust/issues/61137.
2023-01-19 11:19:35 +01:00
Guillaume Gomez
1a878df2b8
Rollup merge of #106927 - Ezrashaw:e0606-make-machine-applicable, r=estebank
make `CastError::NeedsDeref` create a `MachineApplicable` suggestion

Fixes #106903

Simple impl for the linked issue. I also made some other small changes:
- `CastError::ErrorGuaranteed` now owns an actual `ErrorGuaranteed`. This better enforces the static guarantees of `ErrorGuaranteed`.
- `CastError::NeedDeref` code simplified a bit, we now just suggest the `*`, instead of the whole expression as well.
2023-01-19 11:19:34 +01:00
Guillaume Gomez
30ddeefcf0
Rollup merge of #105977 - Swatinem:async-mir-context, r=oli-obk
Transform async `ResumeTy` in generator transform

- Eliminates all the `get_context` calls that async lowering created.
- Replace all `Local` `ResumeTy` types with `&mut Context<'_>`.

The `Local`s that have their types replaced are:
- The `resume` argument itself.
- The argument to `get_context`.
- The yielded value of a `yield`.

The `ResumeTy` hides a `&mut Context<'_>` behind an unsafe raw pointer, and the `get_context` function is being used to convert that back to a `&mut Context<'_>`.

Ideally the async lowering would not use the `ResumeTy`/`get_context` indirection, but rather directly use `&mut Context<'_>`, however that would currently lead to higher-kinded lifetime errors.
See <https://github.com/rust-lang/rust/issues/105501>.

The async lowering step and the type / lifetime inference / checking are still using the `ResumeTy` indirection for the time being, and that indirection is removed here. After this transform, the generator body only knows about `&mut Context<'_>`.

---

Fixes https://github.com/bjorn3/rustc_codegen_cranelift/issues/1330 CC `@bjorn3`

r? `@compiler-errors`
2023-01-19 11:19:34 +01:00
Michael Woerister
72ee14ce39 Allow for more efficient sorting when exporting Unord collections. 2023-01-19 10:40:54 +01:00
Michael Woerister
c3d2573120 Use UnordMap instead of FxHashMap in define_id_collections!(). 2023-01-19 10:40:47 +01:00
Michael Woerister
8a1de57a4a Use UnordSet instead of FxHashSet in define_id_collections!(). 2023-01-19 10:19:07 +01:00
Arpad Borsos
96931a787a
Transform async ResumeTy in generator transform
- Eliminates all the `get_context` calls that async lowering created.
- Replace all `Local` `ResumeTy` types with `&mut Context<'_>`.

The `Local`s that have their types replaced are:
- The `resume` argument itself.
- The argument to `get_context`.
- The yielded value of a `yield`.

The `ResumeTy` hides a `&mut Context<'_>` behind an unsafe raw pointer, and the
`get_context` function is being used to convert that back to a `&mut Context<'_>`.

Ideally the async lowering would not use the `ResumeTy`/`get_context` indirection,
but rather directly use `&mut Context<'_>`, however that would currently
lead to higher-kinded lifetime errors.
See <https://github.com/rust-lang/rust/issues/105501>.

The async lowering step and the type / lifetime inference / checking are
still using the `ResumeTy` indirection for the time being, and that indirection
is removed here. After this transform, the generator body only knows about `&mut Context<'_>`.
2023-01-19 09:03:05 +01:00
bors
65d2f2a5f9 Auto merge of #106810 - oli-obk:resolver_reverse_plumbing, r=petrochenkov
Various cleanups around pre-TyCtxt queries and functions

part of #105462

based on https://github.com/rust-lang/rust/pull/106776 (everything starting at [0e2b39f](0e2b39fd1f) is new in this PR)

r? `@petrochenkov`

I think this should be most of the uncontroversial part of #105462.
2023-01-19 05:23:40 +00:00
clubby789
1487aa9f9d Add double-equals homoglyph 2023-01-19 02:25:55 +00:00
clubby789
3520bba136 Use strings for homoglyph replacements 2023-01-19 02:24:51 +00:00
bors
6ba6d22bdf Auto merge of #107052 - compiler-errors:rollup-vxr22g5, r=compiler-errors
Rollup of 8 pull requests

Successful merges:

 - #105796 (rustdoc: simplify JS search routine by not messing with lev distance)
 - #106753 (Make sure that RPITITs are not considered suggestable)
 - #106917 (Encode const mir for closures if they're const)
 - #107004 (Implement some candidates for the new solver (redux))
 - #107023 (Stop using `BREAK` & `CONTINUE` in compiler)
 - #107030 (Correct typo)
 - #107042 (rustdoc: fix corner cases with "?" JS keyboard command)
 - #107045 (rustdoc: remove redundant CSS rule `#settings .setting-line`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-19 02:09:45 +00:00
Michael Goulet
5d562be33d
Rollup merge of #107030 - albertlarsan68:patch-3, r=lcnr
Correct typo

https://github.com/rust-lang/rust/pull/106718#discussion_r1073508490
2023-01-18 18:00:30 -05:00
Michael Goulet
2eef516b30
Rollup merge of #107023 - scottmcm:stop-shouting, r=Nilstrieb
Stop using `BREAK` & `CONTINUE` in compiler

Switching them to `Break(())` and `Continue(())` instead.

Entirely search-and-replace, though there's one spot where rustfmt insisted on a reformatting too.

libs-api would like to remove these constants (https://github.com/rust-lang/rust/pull/102697#issuecomment-1385705202), so stop using them in compiler to make the removal PR later smaller.
2023-01-18 18:00:30 -05:00
Michael Goulet
cf5068bd62
Rollup merge of #107004 - compiler-errors:new-solver-new-candidates-2, r=lcnr
Implement some candidates for the new solver (redux)

Based on #106718, so the diff is hard to read without it. See [here](98700cf481...compiler-errors:rust:new-solver-new-candidates-2) for an easier view until that one lands.

Of note:
* 44af916020fb43c12070125c45b6dee4ec303bbc fixes a bug where we need to make the query response *inside* of a probe, or else we make no inference progress (I think)
* 50daad5acd2f163d03e7ffab942534f09bc36e2e implements `consider_assumption` for traits and predicates. I'm not sure if using `sup` here is necessary or if `eq` is fine.
* We decided that all of the `instantiate_constituent_tys_for_*` functions are verbose but ok, since they need to be exhaustive and the logic between each of them is not similar enough, right?

r? ``@lcnr``
2023-01-18 18:00:29 -05:00
Michael Goulet
a637e2a950
Rollup merge of #106917 - compiler-errors:const-closure-foreign, r=tmiasko
Encode const mir for closures if they're const

Fixes #106913
2023-01-18 18:00:29 -05:00
Michael Goulet
685c77305c
Rollup merge of #106753 - compiler-errors:rpitit-not-suggestable, r=spastorino
Make sure that RPITITs are not considered suggestable

Makes no sense to suggest `where impl Future<Output = ()>: Send`, for example.
2023-01-18 18:00:28 -05:00
bors
8b11574ca0 Auto merge of #107041 - Nilstrieb:back-to-being-clueless-whether-it-really-is-a-literal, r=compiler-errors
Revert "Improve heuristics whether `format_args` string is a source literal"

This reverts commit e6c02aad93 (from #106195).

Keeps the code improvements from the PR and the test (as a known-bug).

Works around #106408 while a proper fix is discussed more thoroughly in #106505, as proposed by `@tmandry.`

Reopens #106191

r? compiler-errors
2023-01-18 22:58:30 +00:00
Nilstrieb
a8086cf9df Revert "Improve heuristics whether format_args string is a source literal"
This reverts commit e6c02aad93.

Keeps the code improvements from the PR and the test (as a known-bug).
2023-01-18 20:33:17 +01:00
Scott McMurray
7d57685682 Also remove #![feature(control_flow_enum)] where possible 2023-01-18 10:22:21 -08:00
bors
6d46b1ec87 Auto merge of #106503 - cjgillot:remap-nofilter, r=oli-obk
Do not filter substs in `remap_generic_params_to_declaration_params`.

The relevant filtering should have been performed by borrowck.

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

r? types
2023-01-18 16:37:33 +00:00
Tomasz Miąsko
b8c5821ad8 Fix Dominators::rank_partial_cmp to match documentation
The only use site is also updated accordingly and there is no change in
end-to-end behaviour.
2023-01-18 17:11:43 +01:00
Michael Goulet
f672436f04 Handle structural traits more gracefully 2023-01-18 14:59:15 +00:00
Michael Goulet
34127c5080 no subtyping in the new trait solver 2023-01-18 14:59:15 +00:00
Michael Goulet
685c32fd85 Sized, Copy/Clone 2023-01-18 14:59:15 +00:00
Michael Goulet
45aa5c0f90 Auto and alias traits 2023-01-18 14:59:15 +00:00
yukang
0368adb262 Fix #107090, fix missing arguments for fluent 2023-01-18 22:53:24 +08:00
Michael Goulet
3d87a8e848 Assemble object bound candidates 2023-01-18 14:28:14 +00:00
Michael Goulet
f99b273d57 implement consider_assumption 2023-01-18 14:28:14 +00:00
Michael Goulet
b84b1da2db Canonicalize trait solver response inside probe 2023-01-18 14:28:14 +00:00
Albert Larsan
5a685a10ec
Correct typo 2023-01-18 14:08:41 +01:00
Dylan DPC
6f5c3c9cdb
Rollup merge of #106718 - lcnr:solver-cycles, r=compiler-errors
finish trait solver skeleton work

### 648d661b4e0fcf55f7082894f577377eb451db4b

The previous implementation didn't remove provisional entries which depended on the current goal if we're forced to rerun in case the provisional result of that entry is different from the new result. For reference, see https://rust-lang.github.io/chalk/book/recursive/search_graph.html.

We should also treat inductive cycles as overflow, not ordinary ambiguity.

### 219a5de2517cebfe20a2c3417bd302f7c12db70c 6a1912be539dd5a3b3c10be669787c4bf0c1868a

These two commits move canonicalization to the start of the queries which simplifies a bunch of stuff. I originally intended to keep stuff canonicalized for a while because I expected us to add a additional caches the trait solver, either for candidate assembly or for projections. We ended up not adding (and expect to not need) any of them so this just ends up being easier to understand.

### d78d5ad0979e965afde6500bccfa119b47063506

adds a special `eq` for the solver which doesn't care about obligations or spans

### 18704e6a78b7703e1bbb3856f015cb76c0a07a06

implements https://rust-lang.zulipchat.com/#narrow/stream/364551-t-types.2Ftrait-system-refactor/topic/projection.20cache

r? `@compiler-errors`
2023-01-18 15:55:38 +05:30
Ezra Shaw
708861e5b7
remove error code from #[rustc_variance] and document its remains 2023-01-18 21:10:27 +13:00
Scott McMurray
925dc37313 Stop using BREAK & CONTINUE in compiler
Switching them to `Break(())` and `Continue(())` instead.

libs-api would like to remove these constants, so stop using them in compiler to make the removal PR later smaller.
2023-01-17 23:17:51 -08:00
lcnr
369f9aa099 add comment 2023-01-18 08:11:15 +01:00
lcnr
415aa663a2 add note about indirect cycles 2023-01-18 08:11:15 +01:00
lcnr
31ac29d989 update project to emulate a projection cache 2023-01-18 08:11:15 +01:00
lcnr
9a757d6ee4 add eq to InferCtxtExt 2023-01-18 08:11:15 +01:00
lcnr
660c28391c remove assembly context and impl a bit more 2023-01-18 08:11:15 +01:00
lcnr
bf7dbff921 instantiate canonical vars eagerly 2023-01-18 08:11:13 +01:00
lcnr
b738b06160 update cache 2023-01-18 08:09:01 +01:00
Matthias Krüger
9e46c24a90
Rollup merge of #106873 - BoxyUwU:ty_const_formatting, r=compiler-errors
dont randomly use `_` to print out const generic arguments

const generics seem to get printed out as `_` for no reason a lot of the time, as someone who spends a lot of time with const generics this has gotten  very annoying . Latest example would be #106423 where the ICE messaged formatted a `ty::Const` containing no infer vars, as `_`.

For some reason printing of the const argument on arrays was custom instead of using the existing logic for printing `ty::Const`. Additionally the existing logic for printing `ty::Const` would print out `_` for anon consts that are in a separate crate leading to weird diagnostics (see second commit). There ought to be less cases of consts randomly getting printed as `_` hiding valuable info now.
2023-01-18 06:59:20 +01:00
Matthias Krüger
d26e07b91a
Rollup merge of #106747 - yanchen4791:issue-105507-fix, r=estebank
Add 'static lifetime suggestion when GAT implied 'static requirement from HRTB

Fix for issue #105507

The problem:
When generic associated types (GATs) are from higher-ranked trait bounds (HRTB), they are implied 'static requirement (see
[Implied 'static requirement from higher-ranked trait bounds](https://blog.rust-lang.org/2022/10/28/gats-stabilization.html#implied-static-requirement-from-higher-ranked-trait-bounds) for more details). If the user did not explicitly specify the `'static` lifetime when using the GAT, the current error message will only point out the type `does not live long enough` where the type is used, but not where the GAT is specified and how to fix the problem.

The solution:
Add notes at the span where the problematic GATs are specified and suggestions of how to fix the problem by adding `'static` lifetime at the right spans.
2023-01-18 06:59:20 +01:00
Boxy
1171fe5c45 i am free 2023-01-18 04:45:43 +00:00
Boxy
a2a50f96f3 actually print out non local anon consts 2023-01-18 04:07:39 +00:00
Boxy
4ca5368a12 defer array len printing to const arg printing 2023-01-18 04:07:39 +00:00
Ezra Shaw
b73cdf1b29
special case removing & suggestion 2023-01-18 13:14:56 +13:00
Tomasz Miąsko
7fe68571fa Lazy dominator tree construction in borrowck
Motivated by the observation that sometimes constructed dominator tree
was never queried.
2023-01-17 22:00:41 +01:00
bors
edefa4189f Auto merge of #106998 - matthiaskrgr:rollup-hmfisji, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #104505 (Remove double spaces after dots in comments)
 - #106784 (prevent E0512 from emitting [type error] by checking the references_error)
 - #106834 (new trait solver: only consider goal changed if response is not identity)
 - #106889 (Mention the lack of `windows_mut` in `windows`)
 - #106963 (Use `scope_expr_id` from `ProbeCtxt`)
 - #106970 (Switch to `EarlyBinder` for `item_bounds` query)
 - #106980 (Hide `_use_mk_alias_ty_instead` in `<AliasTy as Debug>::fmt`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-17 20:53:05 +00:00
yanchen4791
aadd58ef7a Add 'static lifetime suggestion when GAT implied 'static requirement from HRTB 2023-01-17 11:52:45 -08:00
Matthias Krüger
48bd3ab81d
Rollup merge of #106980 - Nilstrieb:_use_mk_manual_debug_impl_instead, r=lcnr
Hide `_use_mk_alias_ty_instead` in `<AliasTy as Debug>::fmt`
2023-01-17 20:21:28 +01:00
Matthias Krüger
3d7677d91a
Rollup merge of #106970 - kylematsuda:earlybinder-item-bounds, r=lcnr
Switch to `EarlyBinder` for `item_bounds` query

Part of the work to finish #105779 (also see https://github.com/rust-lang/types-team/issues/78).

Several queries `X` have a `bound_X` variant that wraps the output in `EarlyBinder`. This adds `EarlyBinder` to the return type of the `item_bounds` query and removes `bound_item_bounds`.

r? `@lcnr`
2023-01-17 20:21:28 +01:00
Matthias Krüger
28081833c6
Rollup merge of #106963 - compiler-errors:scope-expr-dupe, r=michaelwoerister
Use `scope_expr_id` from `ProbeCtxt`

We already store it in the `ProbeCtxt`, so just retrieve it from there.
2023-01-17 20:21:27 +01:00
Matthias Krüger
fc9e2c1081
Rollup merge of #106834 - compiler-errors:new-solver-did-changed, r=lcnr
new trait solver: only consider goal changed if response is not identity

I think this is the right way of implementing it..

r? `@lcnr`
2023-01-17 20:21:26 +01:00
Matthias Krüger
4ee5e09e19
Rollup merge of #106784 - lyming2007:issue-106695-fix, r=WaffleLapkin
prevent E0512 from emitting [type error] by checking the references_error

but still emit E0512
this will fix #106695
2023-01-17 20:21:26 +01:00
Matthias Krüger
68f12338af
Rollup merge of #104505 - WaffleLapkin:no-double-spaces-in-comments, r=jackh726
Remove double spaces after dots in comments

Most of the comments do not have double spaces, so I assume these are typos.
2023-01-17 20:21:25 +01:00
Michael Goulet
148e4f73dc new trait solver: only consider goal changed if response is not identity 2023-01-17 17:40:38 +00:00
bors
3984bc5833 Auto merge of #106294 - Nilstrieb:noundef-everything, r=nikic
Put `noundef` on all scalars that don't allow uninit

Previously, it was only put on scalars with range validity invariants like bool, was uninit was obviously invalid for those.

Since then, we have normatively declared all uninit primitives to be undefined behavior and can therefore put `noundef` on them.

The remaining concern was the `mem::uninitialized` function, which cause quite a lot of UB in the older parts of the ecosystem. After #99182, this function now doesn't return uninit values anymore, making users of it safe from this change.

The only real sources of UB where people could encounter uninit primitives are `MaybeUninit::uninit().assume_init()`, which has always be clear in the docs about being UB and from heap allocations (like reading from the spare capacity of a vec). This is hopefully rare enough to not break anything.

cc `@nagisa` `@scottmcm` `@nikic`
2023-01-17 17:39:48 +00:00
Yiming Lei
d1478a5600 delay E0512 as a bug by checking the references_error
fix #106695
2023-01-17 09:20:15 -08:00
Kyle Matsuda
fc942eed7f change item_bounds query to return EarlyBinder; remove bound_item_bounds query 2023-01-17 08:55:28 -07:00
Dylan DPC
e6e7c3990e
Rollup merge of #106962 - compiler-errors:use-sugg-span, r=oli-obk
Fix use suggestion span

Fixes #106954
2023-01-17 20:33:05 +05:30
Dylan DPC
26c0a38994
Rollup merge of #106951 - tmiasko:rm-simplify-initial, r=oli-obk
Remove ineffective run of SimplifyConstCondition

There are no constant conditions at this stage.
2023-01-17 20:33:05 +05:30
Dylan DPC
f91f369949
Rollup merge of #106148 - chenyukang:yukang/fix-105061-unused, r=lcnr
Fix unused_parens issue for higher ranked function pointers

fixes #105061

r? `@lcnr`
2023-01-17 20:33:03 +05:30
nils
cb00bc035b Hide _use_mk_alias_ty_instead in <AliasTy as Debug>::fmt 2023-01-17 15:04:05 +01:00
nils
b7cb77fed9 Document how to get the type of a default associated type 2023-01-17 14:01:29 +01:00
mejrs
6fe4cf795b Migrate mir_build's borrow conflicts 2023-01-17 13:48:43 +01:00
Tomasz Miąsko
a6235a2006 Refactor basic blocks control flow caches 2023-01-17 12:36:58 +01:00
bors
f34cc658eb Auto merge of #106612 - JakobDegen:cleanup-wf, r=tmiasko
Document wf constraints on control flow in cleanup blocks

Was recently made aware of [this code](a377893da2/compiler/rustc_codegen_ssa/src/mir/analyze.rs (L247-L368)), which has this potential ICE: a377893da2/compiler/rustc_codegen_ssa/src/mir/analyze.rs (L308-L314)

Roughly speaking, the code there is attempting to partition the cleanup blocks into funclets that satisfy a "unique successor" property, and the ICE is set off if that's not possible. This PR documents the well-formedness constraints that MIR must satisfy to avoid setting off that ICE.

The constraints documented are slightly stronger than the cases in which the ICE would have been set off in that code. This is necessary though, since whether or not that ICE gets set off can depend on iteration order in some graphs.

This sort of constraint is kind of ugly, but I don't know a better alternative at the moment. It's worth knowing that two important optimizations are still correct:
 - Removing edges in the cfg: Fewer edges => fewer paths => stronger dominance relations => more contractions, and more contractions can't turn a forest into not-a-forest.
 - Contracting an edge u -> v when u only has one successor and v only has one predecessor: u already dominated v, so this contraction was going to happen anyway.

There is definitely a MIR opt somewhere that can run afoul of this, but I don't know where it is. `@saethlin` was able to set it off though, so maybe he'll be able to shed some light on it.

r? `@RalfJung` I suppose, and cc `@tmiasko` who might have insight/opinions on this
2023-01-17 11:34:35 +00:00
Oli Scherer
64e5f9129f Handle diagnostics customization on the fluent side 2023-01-17 08:21:34 +00:00
Maybe Waffle
6a28fb42a8 Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
Oli Scherer
1a6ab6c16a Empty regions don't exist anymore, remove them from fluent 2023-01-17 08:00:01 +00:00
Maybe Waffle
4a6d9de828 Untouch back perf sensetive code 😅 2023-01-17 07:48:20 +00:00
Maybe Waffle
c21b1f742e Self review suggestions
- add back accidentally removed new lines
- try to deref in patterns, rather than in expressions
  (maybe this was the reason of perf regression?...)
2023-01-17 07:48:20 +00:00
Maybe Waffle
8d3c90ae13 Review suggestions 2023-01-17 07:48:20 +00:00
Maybe Waffle
98f30e833a Undo questionable changes 2023-01-17 07:48:19 +00:00
Waffle Maybe
66751ea73e tidy
rustfmt, pleaaaaase, start supporting rust

Co-authored-by: nils <48135649+Nilstrieb@users.noreply.github.com>
2023-01-17 07:48:19 +00:00
Maybe Waffle
09485eaae1 rustc_hir_analysis: remove ref patterns 2023-01-17 07:48:19 +00:00
Maybe Waffle
d60e772e14 rustc_hir_analysis: some general code improvements 2023-01-17 07:48:19 +00:00
Maybe Waffle
360e978437 Don't call closures immediately, use try{} blocks 2023-01-17 07:48:19 +00:00
Maybe Waffle
bddbf38af2 rustc_expand: remove ref patterns 2023-01-17 07:48:19 +00:00
Maybe Waffle
fc6cda8603 rustc_data_structures: remove ref patterns and other artifacts of the past 2023-01-17 07:48:19 +00:00
Maybe Waffle
3dca58e249 rustc_const_eval: remove ref patterns (+some pattern matching imps) 2023-01-17 07:48:19 +00:00
bors
159ba8a92c Auto merge of #106627 - Ezrashaw:no-e0711-without-staged-api, r=Mark-Simulacrum
fix: don't emit `E0711` if `staged_api` not enabled

Fixes #106589

Simple fix, added UI test.

As an aside, it seems a lot of features are susceptible to this, `E0711` stands out to me because it's perma-unstable and we are effectively exposing an implementation detail.
2023-01-17 07:20:32 +00:00
Nilstrieb
af23ad93cd Improve comments 2023-01-17 08:14:35 +01:00
Nilstrieb
645c0fddd2 Put noundef on all scalars that don't allow uninit
Previously, it was only put on scalars with range validity invariants
like bool, was uninit was obviously invalid for those.

Since then, we have normatively declared all uninit primitives to be
undefined behavior and can therefore put `noundef` on them.

The remaining concern was the `mem::uninitialized` function, which cause
quite a lot of UB in the older parts of the ecosystem. This function now
doesn't return uninit values anymore, making users of it safe from this
change.

The only real sources of UB where people could encounter uninit
primitives are `MaybeUninit::uninit().assume_init()`, which has always
be clear in the docs about being UB and from heap allocations (like
reading from the spare capacity of a vec. This is hopefully rare enough
to not break anything.
2023-01-17 08:14:35 +01:00
Matthias Krüger
5162e39bff
Rollup merge of #106953 - kylematsuda:early-binder-docs, r=jackh726
Document `EarlyBinder::subst_identity` and `skip_binder`

Finishing implementing #105779 will change several commonly used queries to return `EarlyBinder` by default. This PR adds documentation for two of the methods used to access data inside the `EarlyBinder`. I tried to summarize some of the [discussion from the issue](https://github.com/rust-lang/rust/issues/105779#issuecomment-1375512647) in writing this.

r? `@lcnr`
2023-01-17 05:25:23 +01:00
Matthias Krüger
9bcc46ee90
Rollup merge of #106949 - compiler-errors:is-poly, r=BoxyUwU
ConstBlocks are poly if their substs are poly

r? `@BoxyUwU`

fixes #106926
2023-01-17 05:25:23 +01:00
Matthias Krüger
6b49435480
Rollup merge of #106829 - compiler-errors:more-alias-combine, r=spastorino
Unify `Opaque`/`Projection` handling in region outlives code

They share basically identical paths in most places which are even easier to unify now that they're both `ty::Alias`

r? types
2023-01-17 05:25:22 +01:00
Matthias Krüger
9cda9e0ab6
Rollup merge of #106712 - Ezrashaw:impl-ref-trait, r=estebank
make error emitted on `impl &Trait` nicer

Fixes #106694

Turned out to be simpler than I thought, also added UI test.

Before: ([playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=9bda53271ef3a8886793cf427b8cea91))
```text
error: expected one of `:`, ``@`,` or `|`, found `)`
 --> src/main.rs:2:22
  |
2 | fn foo(_: impl &Trait) {}
  |                      ^ expected one of `:`, ``@`,` or `|`
  |
  = note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
help: if this is a parameter name, give it a type
  |
2 | fn foo(_: impl Trait: &TypeName) {}
  |                ~~~~~~~~~~~~~~~~
help: if this is a type, explicitly ignore the parameter name
  |
2 | fn foo(_: impl _: &Trait) {}
  |                ++

error: expected one of `!`, `(`, `)`, `,`, `?`, `for`, `~`, lifetime, or path, found `&`
 --> src/main.rs:2:16
  |
2 | fn foo(_: impl &Trait) {}
  |               -^ expected one of 9 possible tokens
  |               |
  |               help: missing `,`

error: expected one of `!`, `(`, `,`, `=`, `>`, `?`, `for`, `~`, lifetime, or path, found `&`
 --> src/main.rs:3:11
  |
3 | fn bar<T: &Trait>(_: T) {}
  |           ^ expected one of 10 possible tokens
```

After:
```text
error: expected a trait, found type
 --> <anon>:2:16
  |
2 | fn foo(_: impl &Trait) {}
  |                -^^^^^
  |                |
  |                help: consider removing the indirection

error: expected a trait, found type
 --> <anon>:3:11
  |
3 | fn bar<T: &Trait>(_: T) {}
  |           -^^^^^
  |           |
  |           help: consider removing the indirection
```
2023-01-17 05:25:21 +01:00
Matthias Krüger
f74044259a
Rollup merge of #106591 - Ezrashaw:attempted-integer-identifer, r=Estebank
suggestion for attempted integer identifier in patterns

Fixes #106552

Implemented a suggestion on `E0005` that occurs when no bindings are present and the pattern is a literal integer.
2023-01-17 05:25:21 +01:00
Michael Goulet
21725774a2 note -> help 2023-01-17 03:09:49 +00:00
Michael Goulet
716ea5f19c Fix use suggestion span 2023-01-17 03:06:38 +00:00
Esteban Küber
7b8251e188 Account for method call and indexing when looking for inner-most path in expression 2023-01-17 02:52:43 +00:00
Esteban Küber
c6111e8d23 Account for field access when looking for inner-most path in expression 2023-01-17 02:47:50 +00:00
Esteban Küber
be2ec32b18 Account for * when looking for inner-most path in expression 2023-01-17 02:45:11 +00:00
Esteban Küber
c847a01a3b Emit fewer errors on patterns with possible type ascription 2023-01-17 01:58:37 +00:00
Esteban Küber
2d82420665 Teach parser to understand fake anonymous enum syntax
Parse `-> Ty | OtherTy`.
Parse type ascription in top level patterns.
2023-01-17 01:58:32 +00:00
Kyle Huey
783caf3702 Append .dwp to the binary filename instead of replacing the existing extension.
gdb et al. expect to find the dwp file at <binary>.dwp, even if <binary> already
has an extension (e.g. libfoo.so's dwp is expected to be at libfoo.so.dwp).
2023-01-16 17:49:16 -08:00
Tomasz Miąsko
cd92bca49d Omit needless funclet partitioning 2023-01-17 00:00:00 +00:00
Michael Goulet
e8ebd43eeb Use scope_expr_id from ProbeCtxt 2023-01-16 23:03:05 +00:00
Jakob Degen
4bc963eba6 Avoid trivial checks on cleanup control flow in MIR validator 2023-01-16 15:01:16 -08:00
Jakob Degen
ec3d993410 Add cycle checking to cleanup control flow validation 2023-01-16 14:51:33 -08:00
Jakob Degen
f49126e3d6 Document wf constraints on control flow in cleanup blocks
Also fixes a bug in dominator computation
2023-01-16 14:51:33 -08:00
Kyle Matsuda
1ae1c49c50 document EarlyBinder::subst_identity and skip_binder 2023-01-16 14:00:31 -07:00
Michael Goulet
9f6fef9657 Properly pluralize 'generic constants' 2023-01-16 20:21:29 +00:00
Michael Goulet
fdaac4e48e ConstBlocks are poly if their substs are poly 2023-01-16 20:09:31 +00:00
Matthias Krüger
d2a8a9fb36
Rollup merge of #106940 - oli-obk:tait_error, r=compiler-errors
Improve a TAIT error and add an error code plus documentation

cc https://github.com/rust-lang/rust/issues/106858
2023-01-16 20:29:39 +01:00
Matthias Krüger
37378ee7da
Rollup merge of #106912 - gftea:pr-106736, r=Nilstrieb
check -Z query-dep-graph is enabled if -Z dump-dep-graph (#106736)

PR to solve #106736, r? `@cjgillot`
2023-01-16 20:29:39 +01:00
Matthias Krüger
8ea26ca17f
Rollup merge of #106835 - compiler-errors:new-solver-gat-rebase-oops, r=lcnr
new trait solver: rebase impl substs for gats correctly

you might've caught this while working on projection code, if so then you can close this pr

r? `@lcnr`
2023-01-16 20:29:38 +01:00
Oli Scherer
6b69b5e460 Improve a TAIT error and add an error code plus documentation 2023-01-16 16:54:14 +00:00
bors
481725984b Auto merge of #106853 - TimNN:undo-remap, r=oli-obk
Heuristically undo path prefix mappings.

Because the compiler produces better diagnostics if it can find the source of (potentially remapped) dependencies.

The new test fails without the other changes in this PR. Let me know if you have better suggestions for the test directory. I moved the existing remapping test to be in the same location as the new one.

Some more context: I'm exploring running UI tests with remapped paths by default in https://github.com/rust-lang/rust/pull/105924 and this was one of the issues discovered.

This may also be useful in the context of https://github.com/rust-lang/rfcs/pull/3127 ("New rustc and Cargo options to allow path sanitisation by default").
2023-01-16 15:11:28 +00:00
Michael Goulet
3a4fdcf86c Encode const mir for closures if they're const 2023-01-16 14:59:27 +00:00
Oli Scherer
1355559367 Avoid an unnecessary allocation 2023-01-16 14:46:44 +00:00
Oli Scherer
44ef075aeb Remove a now-useless function call 2023-01-16 14:46:44 +00:00
Oli Scherer
c8a0561321 Avoid one more call site to Compiler::expansion 2023-01-16 14:46:44 +00:00
Oli Scherer
9f5cd03153 Move compiler input and ouput paths into session 2023-01-16 14:46:44 +00:00
Oli Scherer
42f75f1e46 Group some commonly passed together values into a struct 2023-01-16 14:46:40 +00:00
yukang
9d74bb832f comments feedback 2023-01-16 20:44:14 +08:00
bors
af669c2684 Auto merge of #106850 - cjgillot:issue-106141, r=oli-obk
Make the inlining destination a Local.

Fixes https://github.com/rust-lang/rust/issues/106141
2023-01-16 12:30:49 +00:00
Takayuki Maeda
fe96c11aba fix #104440 2023-01-16 21:06:34 +09:00
gftea
2c5583efbd check -Z query-dep-graph is enabled if -Z dump-dep-graph (#106736) 2023-01-16 11:09:53 +01:00
bors
a5bfc25c93 Auto merge of #106872 - dtolnay:nbsp, r=fee1-dead
Emit only one nbsp error per file

Fixes #106101.

See https://github.com/rust-lang/rust/issues/106098 for an explanation of how someone would end up with a large number of these nbsp characters in their source code, which is why I think rustc needs to handle this specific case in a friendlier way.
2023-01-16 09:37:08 +00:00
Oli Scherer
f5c601492e Remove redundant input_path field from Config 2023-01-16 08:03:06 +00:00
Oli Scherer
6b1a789fb6 remove some arguments that can also be fed at the caller side 2023-01-16 08:03:06 +00:00
Oli Scherer
9e9c871a78 Remove prepare_outputs 2023-01-16 08:03:06 +00:00
Ezra Shaw
ca1178f022
make CastError::NeedsDeref create a MachineApplicable suggestion + other misc fixes 2023-01-16 20:24:01 +13:00
bors
d12412c90f Auto merge of #106395 - compiler-errors:rework-predicates, r=eholk
Rework some `predicates_of`/`{Generic,Instantiated}Predicates` code

1. Make `instantiate_own` return an iterator, since it's a bit more efficient and easier to work with
2. Remove `bound_{explicit,}_predicates_of` -- these `bound_` methods in particular were a bit awkward to work with since `ty::GenericPredicates` *already* acts kinda like an `EarlyBinder` with its own `instantiate_*` methods, and had only a few call sites anyways.
3. Implement `IntoIterator` for `InstantiatedPredicates`, since it's *very* commonly being `zip`'d together.
2023-01-16 05:55:59 +00:00
Ezra Shaw
fcd5ed21b7
fix dropping diagnostic without emit 2023-01-16 16:18:56 +13:00
Tomasz Miąsko
d21696ae46 Remove ineffective run of SimplifyConstCondition
There are no constant conditions at this stage.
2023-01-16 00:00:00 +00:00
Ben Kimock
662199f125 InstCombine away intrinsic validity assertions 2023-01-15 16:51:42 -05:00
Matthias Krüger
fc78b1e7f9
Rollup merge of #106909 - compiler-errors:only-types-can-be, r=estebank
Only suggest adding type param if path being resolved was a type
2023-01-15 21:17:36 +01:00
Matthias Krüger
8bd67dd12d
Rollup merge of #106906 - matthiaskrgr:clone, r=Nilstrieb
remove redundant clones
2023-01-15 21:17:35 +01:00
Matthias Krüger
5321ad574d
Rollup merge of #106900 - clubby789:unused-braces-regression, r=estebank
Fix regression in `unused_braces` with macros

Fixes #106899
2023-01-15 21:17:35 +01:00
Matthias Krüger
5610231454
Rollup merge of #106896 - Ezrashaw:str-cast-bool-emptyness, r=compiler-errors
suggest `is_empty` for collections when casting to `bool`

Fixes #106883

Matches on slices, `String` and `str`. It would be nice to do this with something like `Deref<Target=str>` as well, but AFAIK it's not possible in this part of the compiler.
2023-01-15 21:17:34 +01:00
Esteban Küber
656db98bd9 Tweak E0597
CC #99430
2023-01-15 19:46:20 +00:00
Kyle Huey
2b99b9fd25 Preserve split DWARF files when building archives.
The optimization that removes artifacts when building libraries is correct
from the compiler's perspective but not from a debugger's perspective.
Unpacked split debuginfo is referred to by filename and debuggers need
the artifact that contains debuginfo to continue to exist at that path.

Ironically the test expects the correct behavior but it was not running.
2023-01-15 09:40:46 -08:00
Michael Goulet
566202b975 Only suggest adding type param if path being resolved was a type 2023-01-15 16:33:08 +00:00
Michael Goulet
90df86f474 Remove bound_{explicit,}_item_bounds 2023-01-15 15:36:06 +00:00
Michael Goulet
e1533a26f7 drive-by: assert when iterating through InstantiatedPredicates 2023-01-15 15:36:06 +00:00