Commit Graph

22849 Commits

Author SHA1 Message Date
Boxy
9df35a5050 fix bad assertion 2023-03-17 14:40:21 +00:00
Boxy
e624ef4d64 replace chain with two add_goal 2023-03-17 14:35:12 +00:00
Boxy
aa8de17928 fix let else unformatting 2023-03-17 14:13:10 +00:00
Boxy
e06c62cd5b UNACEPTABLE 2023-03-17 14:04:39 +00:00
Boxy
ce14a1eba0 add comments
Co-authored-by: lcnr <rust@lcnr.de>
2023-03-17 13:38:12 +00:00
Boxy
ea08d3a47c add assert 2023-03-17 13:37:47 +00:00
Boxy
ee31e5fc57 review nits 2023-03-17 13:33:57 +00:00
Boxy
ed63201224 replace usage of evaluate_goal with a new add_goal 2023-03-16 14:58:35 +00:00
Matthias Krüger
76962482e6
Rollup merge of #109180 - gimbles:master, r=compiler-errors
Unequal → Not equal

Fixes #109168
2023-03-16 08:57:09 +01:00
Matthias Krüger
113e815b36
Rollup merge of #109171 - oli-obk:normalization_cleanup, r=compiler-errors
Some cleanups in our normalization logic

Changed a match to be exhaustive and deduplicated some code.

r? ```@compiler-errors```

this pulls out the uncontroversial part of https://github.com/rust-lang/rust/pull/108860
2023-03-16 08:57:08 +01:00
Matthias Krüger
f0205d55ce
Rollup merge of #109166 - lcnr:define_opaque_types-explicit, r=oli-obk
make `define_opaque_types` fully explicit

based on the idea of #108389. Moved `define_opaque_types` into the actual operations, e.g. `eq`, instead of `infcx.at` because normalization doesn't use `define_opaque_types` and even creates it's own `At` with a different `define_opaque_types` internally.

Somewhat surprisingly, coherence actually relies on `DefineOpaqueTypes::Yes` for soundness which was revealed because I've incorrectly used `DefineOpaqueTypes::No` in `equate_impl_headers`. It feels concerning that even though this is the case, we still sometimes use `DefineOpaqueTypes::No` in coherence. I did not look into this as part of this PR as it is purely changing the structure of the code without changing behavior in any way.

r? ```@oli-obk```
2023-03-16 08:57:07 +01:00
Matthias Krüger
36b82373e0
Rollup merge of #109158 - Ezrashaw:expand-sugg-for-unused-lint, r=Nilstrieb
error-msg: expand suggestion for `unused_def` lint

Fixes #108885

Expands `let _ = ..` suggestion into more positions.
2023-03-16 08:57:07 +01:00
Matthias Krüger
9d5d447421
Rollup merge of #109151 - compiler-errors:debug-assert-alias, r=WaffleLapkin
Assert def-kind is correct for alias types

Make sure we're not constructing alias types for the wrong def-kind, at least for debug cases 😅
2023-03-16 08:57:06 +01:00
Matthias Krüger
1385a32b62
Rollup merge of #108971 - Ezrashaw:E0532-better-binding-names, r=WaffleLapkin
error-msg: impl better suggestion for `E0532`

Fixes #106862

No test as there is already a test which is nearly identical to the example in the linked issue.
2023-03-16 08:57:05 +01:00
bors
18e305dfca Auto merge of #109183 - lqd:revert-107376, r=compiler-errors
Revert #107376 to fix potential `bincode` breakage and `rustc-perf` benchmark.

#107376 caused `rustc-perf`'s `webrender` benchmark to break, by regressing on the `bincode-1.3.3` crate.

~~This PR is a draft revert in case we can't land a fix soon enough, and we'd like to land the revert instead~~

(Though I myself think it'd be safer to do the revert, and run crater when relanding #107376.)

cc `@aliemjay`
2023-03-16 02:56:24 +00:00
bors
c90eb4825a Auto merge of #108282 - cjgillot:mir-checked-sh, r=tmiasko
Implement checked Shl/Shr at MIR building.

This does not require any special handling by codegen backends,
as the overflow behaviour is entirely determined by the rhs (shift amount).

This allows MIR ConstProp to remove the overflow check for constant shifts.

~There is an existing different behaviour between cg_llvm and cg_clif (cc `@bjorn3).`
I took cg_llvm's one as reference: overflow if `rhs < 0 || rhs > number_of_bits_in_lhs_ty`.~

EDIT: `cg_llvm` and `cg_clif` implement the overflow check differently. This PR uses `cg_llvm`'s implementation based on a `BitAnd` instead of `cg_clif`'s one based on an unsigned comparison.
2023-03-15 21:31:06 +00:00
bors
ab654863c3 Auto merge of #109169 - bjorn3:sync_cg_clif-2023-03-15, r=bjorn3
Sync rustc_codegen_cranelift

Bunch of bug fixes this time. Also an update to Cranelift 0.93 which adds a brand new optimization pass which cg_clif exposes when using `--release`. And various improvements to cg_clif's test suite, making it faster to run. And finally two small perf improvements.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2023-03-15 18:30:04 +00:00
gimbles
e5a5b90afc unequal → not equal 2023-03-15 23:55:48 +05:30
Rémy Rakic
5ad1083e5b Revert "Auto merge of #107376 - aliemjay:remove-givens, r=lcnr"
This reverts commit e84e5ff04a, reversing
changes made to 1716932743.
2023-03-15 15:09:29 +00:00
bors
a167cbddac Auto merge of #109164 - Dylan-DPC:rollup-0bwxwos, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #108991 (add `enable-warnings` flag for llvm, and disable it by default.)
 - #109109 (Use `unused_generic_params` from crate metadata)
 - #109111 (Create dirs for build_triple)
 - #109136 (Simplify proc macro signature validity check)
 - #109150 (Update cargo)
 - #109154 (Fix MappingToUnit  to support no span of arg_ty)
 - #109157 (Remove mw from review rotation for a while)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-15 14:50:03 +00:00
bjorn3
fce629d2e9 Merge commit 'dec0daa8f6d0a0e1c702f169abb6bf3eee198c67' into sync_cg_clif-2023-03-15 2023-03-15 14:41:48 +00:00
lcnr
d2b7604db9 always make define_opaque_types explicit 2023-03-15 14:00:15 +01:00
Dylan DPC
19d575851a
Rollup merge of #109154 - chenyukang:yukang/fix-109152, r=compiler-errors
Fix MappingToUnit  to support no span of arg_ty

Fixes #109152
2023-03-15 17:51:33 +05:30
Dylan DPC
8c5ea6188f
Rollup merge of #109136 - compiler-errors:simplify-proc-macro-checking, r=oli-obk
Simplify proc macro signature validity check

Use an `ObligationCtxt` instead of `normalize_erasing_regions` + `DeepRejectCtxt`. This should both give us a more accurate error message, and also avoid issues like not-well-formed proc macro signatures. Also, let's fall back on the regular type mismatch error reporting for making these diagnostic notes, instead of hard-coding a bunch of specific diagnostics.

Fixes #109129
2023-03-15 17:51:32 +05:30
Dylan DPC
2aa3eea5fc
Rollup merge of #109109 - compiler-errors:polymorphize-foreign, r=Nilstrieb
Use `unused_generic_params` from crate metadata

Due to the way that `separate_provide_extern` interacted with the implementation of `<ty::InstanceDef<'tcx> as Key>::query_crate_is_local`, we actually never hit the foreign provider for `unused_generic_params`.

Additionally, since the *local* provider of `unused_generic_params` calls `should_polymorphize`, which always returns false if the def-id is foreign, this means that we never actually polymorphize monomorphic instances originating from foreign crates.

We don't actually encode `unused_generic_params` for items where all generics are used, so I had to tweak the foreign provider to fall back to `ty::UnusedGenericParams::new_all_used()` to avoid more ICEs when the above bugs were fixed.
2023-03-15 17:51:31 +05:30
Oli Scherer
d87fbb918c Deduplicate logic between projection normalization with and without escaping bound vars 2023-03-15 12:02:00 +00:00
Oli Scherer
d3d537b972 Exhaustively match over all alias kinds 2023-03-15 12:00:25 +00:00
bors
e4b9f86054 Auto merge of #109035 - scottmcm:ptr-read-should-know-undef, r=WaffleLapkin,JakobDegen
Ensure `ptr::read` gets all the same LLVM `load` metadata that dereferencing does

I was looking into `array::IntoIter` optimization, and noticed that it wasn't annotating the loads with `noundef` for simple things like `array::IntoIter<i32, N>`.  Trying to narrow it down, it seems that was because `MaybeUninit::assume_init_read` isn't marking the load as initialized (<https://rust.godbolt.org/z/Mxd8TPTnv>), which is unfortunate since that's basically its reason to exist.

The root cause is that `ptr::read` is currently implemented via the *untyped* `copy_nonoverlapping`, and thus the `load` doesn't get any type-aware metadata: no `noundef`, no `!range`.  This PR solves that by lowering `ptr::read(p)` to `copy *p` in MIR, for which the backends already do the right thing.

Fortuitiously, this also improves the IR we give to LLVM for things like `mem::replace`, and fixes a couple of long-standing bugs where `ptr::read` on `Copy` types was worse than `*`ing them.

Zulip conversation: <https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Move.20array.3A.3AIntoIter.20to.20ManuallyDrop/near/341189936>

cc `@erikdesjardins` `@JakobDegen` `@workingjubilee` `@the8472`

Fixes #106369
Fixes #73258
2023-03-15 11:44:12 +00:00
Ezra Shaw
35103fe8ab
error-msg: expand suggestion for unused lint 2023-03-15 23:30:12 +13:00
Ezra Shaw
bd1732240b
error-msg: impl better suggestion for E0532 2023-03-15 22:19:54 +13:00
bors
992d154f3a Auto merge of #109089 - compiler-errors:opt_rpitit_info-follow-up, r=spastorino
Encode `opt_rpitit_info` for associated types

Follow-up, only last commit matters

r? `@spastorino`

This needs a perf run after the parent pr lands
2023-03-15 08:13:23 +00:00
yukang
b3af5e2f8b Fix #109152, fix the scenario that we may can not get span of func 2023-03-15 14:07:39 +08:00
Scott McMurray
e7c6ad89cf Improved implementation and comments after code review feedback 2023-03-14 22:24:28 -07:00
bors
e84e5ff04a Auto merge of #107376 - aliemjay:remove-givens, r=lcnr
remove obsolete `givens` from regionck

Fixes #106567

r? `@lcnr` (feel free to reassign)
2023-03-15 02:50:58 +00:00
Michael Goulet
cf6424e881 Don't make projection tys out of anon consts 2023-03-14 23:12:42 +00:00
Michael Goulet
e482701998 Assert def-kind is correct for alias types 2023-03-14 22:56:24 +00:00
Michael Goulet
0404e264a2 Encode opt_rpitit_info for associated types 2023-03-14 22:10:09 +00:00
Michael Goulet
00dc3b24b7 Tighter spans 2023-03-14 19:12:42 +00:00
Michael Goulet
9eae77381e Simplify proc macro signature validity check 2023-03-14 19:05:21 +00:00
bors
1716932743 Auto merge of #109130 - matthiaskrgr:rollup-dm3jza6, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #108722 (Support for Fuchsia RISC-V target)
 - #108880 (Remove tests/ui/impl-trait/in-trait/new-lowering-strategy in favor of using revisions on existing tests)
 - #108909 (Fix object safety checks for new RPITITs)
 - #108915 (Remove some direct calls to local_def_id_to_hir_id on diagnostics)
 - #108923 (Make fns from other crates with RPITIT work for -Zlower-impl-trait-in-trait-to-assoc-ty)
 - #109101 (Fall back to old metadata computation when type references errors)
 - #109105 (Don't ICE for late-bound consts across `AnonConstBoundary`)
 - #109110 (Don't codegen impossible to satisfy impls)
 - #109116 (Emit diagnostic when calling methods on the unit type in method chains)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-14 17:40:52 +00:00
Matthias Krüger
b17ee106d8
Rollup merge of #109116 - MaciejWas:add-modifies-receiver-diagn-when-method-not-found, r=petrochenkov
Emit diagnostic when calling methods on the unit type in method chains

Fixes #104204.

What this PR does: If a method is not found somewhere in a call chain, we check if we called earlier a method with signature `(&mut T, ...) -> ()`. If this is the case then we emit a diagnostic message.

For example given input:

```
vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort();
```

the current output is:
```
error[E0599]: no method named `sort` found for unit type `()` in the current scope
 --> hello.rs:3:72
  |
3 |     vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort();
  |                                                                        ^^^^ method not found in `()`

```

after this PR it will be:
```
error[E0599]: no method named `sort` found for unit type `()` in the current scope
 --> ./hello.rs:3:72
  |
3 |     vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort();
  |                                                                        ^^^^ method not found in `()`
  |

note: method `sort_by_key` modifies its receiver in-place, it is not meant to be used in method chains.
 --> ./hello.rs:3:53
  |
3 |     vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort();
  |                                                     ^^^^^^^^^^^ this call modifies its receiver in-place
```
2023-03-14 17:40:07 +01:00
Matthias Krüger
b88c675946
Rollup merge of #109110 - compiler-errors:impossible-impl-mono, r=jackh726
Don't codegen impossible to satisfy impls

Fixes #109098
2023-03-14 17:40:06 +01:00
Matthias Krüger
4c6b680955
Rollup merge of #109105 - compiler-errors:late-ct-in-anon-ct, r=oli-obk
Don't ICE for late-bound consts across `AnonConstBoundary`

Fixes #108194
2023-03-14 17:40:06 +01:00
Matthias Krüger
1f159b4894
Rollup merge of #109101 - compiler-errors:layout-err, r=michaelwoerister
Fall back to old metadata computation when type references errors

Projection is a bit too aggressive normalizing `<dyn Trait<[type error]> as Pointee>::Metadata` to `[type error]`, rather than to `DynMetadata<..>`. Side-step that by just falling back to the old structural metadata computation.

Fixes #109078
2023-03-14 17:40:05 +01:00
Matthias Krüger
21d15db1df
Rollup merge of #108923 - spastorino:new-rpitit-9, r=compiler-errors
Make fns from other crates with RPITIT work for -Zlower-impl-trait-in-trait-to-assoc-ty

Only the last two commits are meaningful.

r? `@compiler-errors`
2023-03-14 17:40:05 +01:00
Matthias Krüger
6e3a3de778
Rollup merge of #108915 - spastorino:new-rpitit-8, r=compiler-errors
Remove some direct calls to local_def_id_to_hir_id on diagnostics

Was playing with `tests/ui/impl-trait/in-trait/default-body-with-rpit.rs` and was able to remove some ICEs. Still getting ...

```
error[E0277]: `impl Future<Output = Foo::{opaque#0}>` is not a future
  --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:28
   |
10 |     async fn baz(&self) -> impl Debug {
   |                            ^^^^^^^^^^ `impl Future<Output = Foo::{opaque#0}>` is not a future
   |
   = help: the trait `Future` is not implemented for `impl Future<Output = Foo::{opaque#0}>`
   = note: impl Future<Output = Foo::{opaque#0}> must be a future or must implement `IntoFuture` to be awaited
note: required by a bound in `Foo::{opaque#1}`
  --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:28
   |
10 |     async fn baz(&self) -> impl Debug {
   |                            ^^^^^^^^^^ required by this bound in `Foo::{opaque#1}`

error[E0277]: the size for values of type `impl Future<Output = Foo::{opaque#0}>` cannot be known at compilation time
  --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:28
   |
10 |     async fn baz(&self) -> impl Debug {
   |                            ^^^^^^^^^^ doesn't have a size known at compile-time
   |
   = help: the trait `Sized` is not implemented for `impl Future<Output = Foo::{opaque#0}>`
note: required by a bound in `Foo::{opaque#1}`
  --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:28
   |
10 |     async fn baz(&self) -> impl Debug {
   |                            ^^^^^^^^^^ required by this bound in `Foo::{opaque#1}`

error: internal compiler error: compiler/rustc_hir_typeck/src/closure.rs:724:18: async fn generator return type not an inference variable: Foo::{opaque#1}<'_>
  --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:39
   |
10 |       async fn baz(&self) -> impl Debug {
   |  _______________________________________^
11 | |         ""
12 | |     }
   | |_____^
```

But I guess this is a little bit of progress anyway.

This one goes on top of #108700 and #108945
r? `@compiler-errors`
2023-03-14 17:40:04 +01:00
Matthias Krüger
48934c48c6
Rollup merge of #108909 - spastorino:new-rpitit-7, r=compiler-errors
Fix object safety checks for new RPITITs

This one goes on top of #108869

r? `@compiler-errors`
2023-03-14 17:40:04 +01:00
Matthias Krüger
e006ee9be8
Rollup merge of #108722 - petrhosek:fuchsia-riscv, r=petrochenkov
Support for Fuchsia RISC-V target

Fuchsia is in the process of implementing the RISC-V support. This change implements the minimal Rust compiler support. The support for building runtime libraries will be implemented in follow up changes once Fuchsia SDK has the RISC-V support.
2023-03-14 17:40:03 +01:00
Michael Goulet
ee2d42882f Use unused_generic_params from crate metadata 2023-03-14 16:33:12 +00:00
Michael Goulet
b36bbb0266 Don't codegen impossible to satisfy impls 2023-03-14 16:19:57 +00:00