Commit Graph

838 Commits

Author SHA1 Message Date
Michael Goulet
d4b59a0da2 Propagate expected return type instead of real return type in check_binop 2023-03-09 17:24:07 +00:00
Michael Goulet
1b6d6f92d1 Fix canonicalizer bug for int/float vars too 2023-03-09 17:24:07 +00:00
Michael Goulet
3aea46979a Emit alias-eq when equating numeric var and projection 2023-03-09 16:42:56 +00:00
bors
39f2657d11 Auto merge of #108920 - matthiaskrgr:rollup-qrr9a0u, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #108754 (Retry `pred_known_to_hold_modulo_regions` with fulfillment if ambiguous)
 - #108759 (1.41.1 supported 32-bit Apple targets)
 - #108839 (Canonicalize root var when making response from new solver)
 - #108856 (Remove DropAndReplace terminator)
 - #108882 (Tweak E0740)
 - #108898 (Set `LIBC_CHECK_CFG=1` when building Rust code in bootstrap)
 - #108911 (Improve rustdoc-gui/tester.js code a bit)
 - #108916 (Remove an unused return value in `rustc_hir_typeck`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-09 08:21:17 +00:00
Matthias Krüger
e6e82db307
Rollup merge of #108882 - compiler-errors:E0740, r=eholk
Tweak E0740

Also drive-by suppress E0740 if it's an unresolved type.
2023-03-08 21:26:52 +01:00
Matthias Krüger
2428083558
Rollup merge of #108839 - compiler-errors:canonicalize-the-root-var, r=lcnr
Canonicalize root var when making response from new solver

During trait solving, if we equate two inference variables `?0` and `?1` but don't equate them with any rigid types, then `InferCtxt::probe_ty_var` will return `Err` for both of these. The canonicalizer code will then canonicalize the variables independently(!), and the response will not reflect the fact that these two variables have been made equal.

This hinders inference and I also don't think it's sound? I haven't thought too much about it past that, so let's talk about it.

r? ``@lcnr``
2023-03-08 21:26:51 +01:00
Matthias Krüger
33c3036826
Rollup merge of #108901 - LYF1999:yf/108897, r=lcnr
fix: evaluate with wrong obligation stack

fix #108897
r? ``@lcnr``
2023-03-08 21:24:53 +01:00
Matthias Krüger
031b528052
Rollup merge of #108884 - compiler-errors:tweak-illegal-copy-impl-message, r=WaffleLapkin
Tweak illegal `Copy` impl message

The phrase "may not" can both mean "is not able to" and "possibly does not". Disambiguate this by just using "cannot".
``@Lokathor`` expressed being annoyed by this [here](https://twitter.com/Lokathor/status/1633200313544089602?s=20).

Also drive-by fix for this extremely noisy message: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=6a37275bc810f7846bfe191845b7d11d.

r? diagnostics
2023-03-08 21:24:52 +01:00
Matthias Krüger
f6b8a9f6db
Rollup merge of #108883 - compiler-errors:post-norm-copy-err, r=BoxyUwU
Suppress copy impl error when post-normalized type references errors

Suppress spurious errors from the `Copy` impl validity check when fields have bad types *post*-normalization, instead of just pre-normalization.

----

The const-generics test regressed recently due to #107965, cc `````@BoxyUwU.`````
 * I think it's because `[_; 0u32]: Copy` now fails to hold because a nested obligation `ConstArgHasType(0u32, usize)` fails.
 * It's interesting that `[const_error]` shows up in the type only after normalization, though, but I'm pretty sure that it's due to the evaluate call that happens when normalizing unevaluated consts.
2023-03-08 21:24:51 +01:00
bors
7c306f6dcd Auto merge of #108121 - aliemjay:resolve-var-region, r=lcnr
always resolve to universal regions if possible

`RegionConstraintCollector::opportunistic_resolve_var`, which is used in canonicalization and projection logic, doesn't resolve the region var to an equal universal region. So if we have equated `'static == '1 == '2`, it doesn't resolve `'1` or `'2` to `'static`. Now it does!

Addresses review comment https://github.com/rust-lang/rust/pull/107376#discussion_r1093233687.

r? `@lcnr`
2023-03-08 12:33:21 +00:00
yifei
204ba3224e fix: evaluate with wrong obligation stack 2023-03-08 20:12:46 +08:00
Michael Goulet
64eea3c47a Tweak E0740 2023-03-08 01:58:15 +00:00
Michael Goulet
08e5a77b06 Don't report E0740 for type error 2023-03-08 01:55:32 +00:00
Michael Goulet
8a99ffc344 Suppress copy impl error when post-normalized type references errors 2023-03-08 00:12:33 +00:00
Michael Goulet
0f4255ece2 Dedup copy field errors for identical types 2023-03-08 00:00:19 +00:00
Michael Goulet
a439c0293c may not => cannot 2023-03-08 00:00:18 +00:00
Matthias Krüger
63635880f6
Rollup merge of #108583 - compiler-errors:rpitit-default-method-with-nested-rpitits, r=spastorino
Account for binders correctly when adding default RPITIT method assumption

As of #108203, we install extra projection predicates into the param-env of a default trait method when it has return-position `impl Trait` (or is async).

The implementation didn't account for the fact that it's walking into and out of binders, so we just need to shift all the debruijn indices accordingly when constructing the projection predicates.

Fixes #108579

r? types
2023-03-07 19:57:44 +01:00
Michael Goulet
8d13454498 Canonicalize the ROOT VAR 2023-03-07 17:11:35 +00:00
bors
1a521db67e Auto merge of #108863 - JohnTitor:rollup-haydnsw, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #108619 (Remove the option to disable `llvm-version-check`)
 - #108728 (infer: fix and improve comments)
 - #108731 (feat: impl better help for `.poll()` not found on `impl Future`)
 - #108774 (Greatly improve the error messages when `run-make/translation` fails)
 - #108805 (Update askama to 0.12 and improve whitespace control)
 - #108823 (Add tracking issue for cf-protection to unstable book)
 - #108855 (Custom MIR: Support `as` casts)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-07 15:58:38 +00:00
Yuki Okushi
8f775dc7a6
Rollup merge of #108731 - Ezrashaw:pin-suggestion-on-impl-future, r=petrochenkov
feat: impl better help for `.poll()` not found on `impl Future`

Partially address #108572

I'd like to also address suggestions for generalized `Self` parameters as well. That'll be a separate PR.
2023-03-07 23:06:22 +09:00
bors
160c2ebeca Auto merge of #108763 - scottmcm:indexing-nuw-lengths, r=cuviper
Use `nuw` when calculating slice lengths from `Range`s

An `assume` would definitely not be worth it, but since the flag is almost free we might as well tell LLVM this, especially on `_unchecked` calls where there's no obvious way for it to deduce it.

(Today neither safe nor unsafe indexing gets it: <https://rust.godbolt.org/z/G1jYT548s>)
2023-03-07 13:17:59 +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
Matthias Krüger
567cab93d5
Rollup merge of #108812 - albertlarsan68:test-98444, r=Nilstrieb
Add regression test for #98444

cc #108730 this will need to be changed to a `check-fail` test once it lands.

Fixes #98444
2023-03-06 16:42:01 +01:00
Matthias Krüger
3279f7ed77
Rollup merge of #108807 - MU001999:lint/suspicious_auto_trait_impls, r=lcnr
Emit the suspicious_auto_trait_impls for negative impls as well

Fixes #108804
2023-03-06 16:42:00 +01:00
Matthias Krüger
ab7dd09fc2
Rollup merge of #108803 - cjgillot:const-prop-normalize, r=oli-obk
Do not ICE when failing to normalize in ConstProp.

There is no reason to delay a bug there, as we bubble up the failure as TooGeneric.

Fixes https://github.com/rust-lang/rust/issues/97728
2023-03-06 16:41:59 +01:00
Matthias Krüger
3ae047b8f1
Rollup merge of #108790 - cjgillot:mono-cast, r=oli-obk
Do not ICE when interpreting a cast between non-monomorphic types

Fixes https://github.com/rust-lang/rust/issues/101596
2023-03-06 16:41:59 +01:00
Matthias Krüger
1866ea136c
Rollup merge of #108780 - Zeegomo:close-70919, r=WaffleLapkin
Add regression tests for issue 70919

Desugaring DropAndReplace at MIR build (#107844) fixed #70919.
Add regressions tests, borrowed from #102078, to ensure we check for this in the future.

cc ``@Aaron1011``
2023-03-06 16:41:57 +01:00
Matthias Krüger
9c99a4ca2b
Rollup merge of #107801 - davidtwco:stability-implies-const, r=Nilstrieb
const_eval: `implies_by` in `rustc_const_unstable`

Fixes #107605.

Extend support for `implies_by` (from `#[stable]` and `#[unstable]`) to `#[rustc_const_stable]` and `#[rustc_const_unstable]`.

cc ``@steffahn``
2023-03-06 16:41:56 +01:00
Albert Larsan
33d7fad7e5
Add regression test for 98444 2023-03-06 13:41:07 +00:00
Mu42
717f93cec5 Bless the suspicious-negative-impls-lint.rs 2023-03-06 21:25:43 +08:00
Mu42
23ba4ceb9e Bless the remaining ui tests 2023-03-06 21:05:35 +08:00
Mu42
5c0f55d508 Moves the negative impls into a separate test file 2023-03-06 21:05:23 +08:00
Mu42
2fe288fd29 emit the suspicious_auto_trait_impls for negative impls as well 2023-03-06 20:04:33 +08:00
Camille GILLOT
8c0cbd8767 Do not ICE when failing to normalize in ConstProp. 2023-03-06 09:28:49 +00:00
Scott McMurray
3554036280 Use nuw when calculating slice lengths from Ranges
An `assume` would definitely not be worth it, but since the flag is almost free we might as well tell LLVM this, especially on `_unchecked` calls where there's no obvious way for it to deduce it.

(Today neither safe nor unsafe indexing gets it: <https://rust.godbolt.org/z/G1jYT548s>)
2023-03-05 15:15:22 -08:00
Camille GILLOT
5d7234abb6 Add test. 2023-03-05 20:55:29 +00:00
Matthias Krüger
5c49f0885e
Rollup merge of #108775 - cjgillot:issue-107860, r=compiler-errors
Use the correct bound vars in return type suggestion.

Fixes https://github.com/rust-lang/rust/issues/107860
2023-03-05 20:57:23 +01:00
Matthias Krüger
1c2f641e15
Rollup merge of #108764 - cjgillot:dpm-adapt, r=compiler-errors
Tweaks to -Zdrop-tracking-mir

Split from https://github.com/rust-lang/rust/pull/107421

3 commits: 1 diagnostic improvement and 2 ICEs.
2023-03-05 20:57:21 +01:00
Matthias Krüger
b8762321a2
Rollup merge of #108746 - compiler-errors:rpitit-dont-project-default-w-no-valu, r=cjgillot
Don't project to RPITIT that has no default value

Replicates this behavior, but for RPITIT projection logic (which currently is separate)

b1719530f4/compiler/rustc_trait_selection/src/traits/project.rs (L2105-L2115)

Fixes #108738
2023-03-05 20:57:20 +01:00
Matthias Krüger
ced9cd19c8
Rollup merge of #108244 - lukas-code:semicolon-recovery-span, r=cjgillot
Add test for semicolon recovery ICE

closes https://github.com/rust-lang/rust/issues/108242
2023-03-05 20:57:20 +01:00
Camille GILLOT
1e9b58bdf8 Use the correct bound vars in return type suggestion. 2023-03-05 16:08:06 +00:00
Giacomo Pasini
beebd3a4c6
Add regression tests for issue 70919
Desugaring DropAndReplace at MIR build (#107844) fixed issue
70919. Add regressions tests, borrowed from #102078, to ensure we
check for this in the future.

Co-authored-by: Aaron Hill <aa1ronham@gmail.com>
2023-03-05 16:56:57 +01:00
Matthias Krüger
ec162703dc
Rollup merge of #108744 - compiler-errors:non_lifetime_binders-bad-copy-clone, r=jackh726
Don't ICE when encountering bound var in builtin copy/clone bounds

Fixes #108742
2023-03-05 14:29:10 +01:00
Lukas Markeffsky
a435b3c0cd add test for https://github.com/rust-lang/rust/issues/108242 2023-03-05 14:23:43 +01:00
Ali MJ Al-Nasrawy
bfd35016e4 fix the new unsoundness 2023-03-05 12:49:01 +03:00
Ali MJ Al-Nasrawy
eea560494c oops! new unsoundness
Bless tests and show an introduced unsoundness related to
exits<'a> { forall<'b> { 'a == 'b } }.
We now resolve the var ?a in U0 to the placeholder !b in U1.
2023-03-05 12:49:01 +03:00
Camille GILLOT
0916616fec drop_tracking_mir: diagnose recursive generator. 2023-03-05 08:29:35 +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
Ezra Shaw
aaaffa9a3e
feat: impl better help for .poll() not found on impl Future 2023-03-05 09:34:00 +13:00
Matthias Krüger
60f54b1025
Rollup merge of #108627 - estebank:suggestion-hightlight, r=WaffleLapkin
Properly colorize multi-part suggestions in the same line

Fix #108547.
2023-03-04 20:48:16 +01:00