Commit Graph

2053 Commits

Author SHA1 Message Date
Yuki Okushi
d4ad96cf6e
Rollup merge of #106754 - compiler-errors:ty-infer-method-is-confusing, r=lcnr
Rename `Ty::is_ty_infer` -> `Ty::is_ty_or_numeric_infer`

Makes sure people are aware that they may have a type variable *or* an int/float variable.

r? `@oli-obk` https://github.com/rust-lang/rust/pull/106322#issuecomment-1376913539 but I could instead implement your solution, let me know.

(This will conflict with #106322 for now, ignore that 😄)
2023-01-13 16:54:23 +09:00
bors
279f1c9d8c Auto merge of #106004 - fee1-dead-contrib:const-closures, r=oli-obk
Const closures

cc https://github.com/rust-lang/rust/issues/106003
2023-01-13 05:04:48 +00:00
Michael Goulet
8e27211dbc is_ty_infer -> is_ty_or_numeric_infer 2023-01-12 23:57:41 +00:00
nils
35cf81d707
Rollup merge of #106322 - compiler-errors:CollectAllMismatches-infer-vars, r=oli-obk
Handle inference variables in `CollectAllMismatches` correctly

1. Fix #106240
2. Treat int/float type variables correctly (see `src/test/ui/iterators/invalid-iterator-chain-with-int-infer.rs`), so we can point out things like "`Iterator::Item` changed to `{integer}` here"
2023-01-12 15:44:51 +01:00
bors
606c390725 Auto merge of #106760 - compiler-errors:rollup-0bogyco, r=compiler-errors
Rollup of 8 pull requests

Successful merges:

 - #103236 (doc: rewrite doc for signed int::{carrying_add,borrowing_sub})
 - #103800 (Stabilize `::{core,std}::pin::pin!`)
 - #106097 (Migrate mir_build diagnostics 2 of 3)
 - #106170 (Move autoderef to `rustc_hir_analysis`)
 - #106323 (Stabilize f16c_target_feature)
 - #106360 (Tweak E0277 `&`-removal suggestions)
 - #106524 (Label `struct/enum constructor` instead of `fn item`, mention that it should be called on type mismatch)
 - #106739 (Remove `<dyn AstConv<'tcx>>::fun(c, ...)` calls in favour of `c.astconv().fun(...)`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-12 10:46:19 +00:00
Michael Goulet
54f6fea818
Rollup merge of #106360 - estebank:remove-borrow-suggestion, r=compiler-errors
Tweak E0277 `&`-removal suggestions

Fix #64068, fix #84837.
2023-01-11 22:25:49 -08:00
Michael Goulet
9928b14772
Rollup merge of #106170 - compiler-errors:autoderef-to-analysis, r=lcnr
Move autoderef to `rustc_hir_analysis`

Not sure if this is a change we actually want, but autoderef really is only (functionally) used by `rustc_hir_analysis` and `rustc_hir_typeck`, so it probably should live there.

Instead, implement a separate autoderef helper in `TypeErrCtxt` for the one use-case that  goes against the ordering of the crate graph..
2023-01-11 22:25:48 -08:00
Matthias Krüger
e8ef83e4c0
Rollup merge of #106748 - clubby789:on-unimplemented-fmt-verify, r=compiler-errors
Clean up `OnUnimplementedFormatString::verify`

Lift the always-allowed symbols to a static array and replace a `match iter().find(...)` with `iter().any(...)`
2023-01-12 06:52:39 +01:00
Matthias Krüger
890bc3ca90
Rollup merge of #106596 - estebank:verbose-e0271, r=compiler-errors
Hide more of long types in E0271

Fix #40186.
2023-01-12 06:52:36 +01:00
Matthias Krüger
9b538e8e62
Rollup merge of #106309 - compiler-errors:prefer-non-err-candidates, r=oli-obk
Prefer non-`[type error]` candidates during selection

Fixes #102130
Fixes #106351

r? types

note: Alternatively we could filter out error where-clauses during param-env construction? But we still need to filter out impls with errors during `match_impl`, I think.
2023-01-12 06:52:34 +01:00
Deadbeef
b0aa859c24 fix fmt and bless 2023-01-12 02:28:38 +00:00
Deadbeef
6e63f7be54 attempt to make a minimal example work 2023-01-12 02:28:37 +00:00
clubby789
b78a571ce1 Clean up OnUnimplementedFormatString::verify 2023-01-11 22:54:46 +00:00
Esteban Küber
f1ffe823cf Hide more of long types in E0271
Fix #40186.
2023-01-11 21:40:39 +00:00
Esteban Küber
8b8cce16bf Use the root trait predicate to determine whether to remove references
Fix #84837.
2023-01-11 21:39:07 +00:00
Esteban Küber
bb7211702e fix rebase 2023-01-11 21:38:56 +00:00
Esteban Küber
ce83be4af8 Account for type params 2023-01-11 21:38:56 +00:00
Esteban Küber
2024aa48b4 Make &-removal suggestion verbose 2023-01-11 21:38:54 +00:00
Michael Goulet
c8334ce60c Move autoderef to rustc_hir_analysis 2023-01-11 20:12:57 +00:00
Matthias Krüger
865d83e87a
Rollup merge of #106705 - compiler-errors:new-solver-err-properly, r=lcnr
Report fulfillment errors in new trait solver

Causes fewer ICEs when testing the new solver 😄
2023-01-11 21:08:09 +01:00
Matthias Krüger
90f9c681d4
Rollup merge of #106703 - compiler-errors:impl-derived-span, r=estebank
Note predicate span on `ImplDerivedObligation`

Seems obvious to point out the where-clause that introduces the `ImplDerivedObligation` :)

r? `@estebank`
2023-01-11 21:08:08 +01:00
Michael Goulet
83fbc71d02 Filter impl and where-clause candidates that reference errors 2023-01-11 20:03:29 +00:00
Michael Goulet
959616ef44 Handle inference variables in CollectAllMismatches correctly 2023-01-11 20:01:24 +00:00
Michael Goulet
9a39d7e441 Note predicate span on ImplDerivedObligation 2023-01-11 19:46:45 +00:00
Michael Goulet
104ec48c64 Report fulfillment errors in new trait solver 2023-01-11 18:05:50 +00:00
nils
16938915a4
Rollup merge of #106397 - compiler-errors:new-solver-impl-wc, r=lcnr
Check `impl`'s `where` clauses in `consider_impl_candidate` in experimental solver

Check impl's nested predicates as part of the recursive evaluate in `consider_impl_candidate`.

<sub>Unless, for some reason, these are intentionally **not** checked here -- in which case, I really don't understand where they're being checked...<sub>

r? ```@lcnr```
2023-01-11 17:30:53 +01:00
Albert Larsan
40ba0e84d5
Change src/test to tests in source files, fix tidy and tests 2023-01-11 09:32:13 +00:00
Yuki Okushi
12b124283c
Rollup merge of #106521 - oskgo:remove-E0280, r=jackh726
remove E0280

After looking at #61137 I tried my hand at E0280. I'm unable to find a reasonable example that emits the error. There are a couple of old examples that compile with the current compiler ([#26217](https://github.com/rust-lang/rust/issues/26217), [#42114](https://github.com/rust-lang/rust/issues/42114), [#27113](https://github.com/rust-lang/rust/issues/27113)) and there is a [bug with chalk](b7cdb635c4/src/test/ui/chalkify/bugs/async.rs) that makes it emit the error, with a couple more chalk bugs on zulip.

It seems like the error is supposed to be emitted from unfulfilled where bounds, of which two are related to borrow checking (error in where T: 'a or where 'a: 'b) and thus tend to emit errors like "lifetime may not live long enough" from borrow checking instead. The final case is with type equality constraints (where <T as Iterator>::Item == u32), which is unimplemented ([#20041](https://github.com/rust-lang/rust/issues/20041)). That such different problems are supposed to have the same error code also seems strange to me.

Since the error seems to only be emitted when using chalk I propose to remove it and replace it with an ICE instead. A crater run might be warranted.

Pinging `@jackh726` due to removal of chalk test that now ICEs.
2023-01-11 14:18:53 +09:00
bowlerman
f75eb24f4f remove E0280 and ICE instead 2023-01-10 03:04:28 +01:00
Yuki Okushi
e5e116dca9
Rollup merge of #106204 - compiler-errors:no-take-opaques-in-compare, r=oli-obk
No need to take opaques in `check_type_bounds`

`InferCtxt` already has its defining use anchor set to err

r? ``@oli-obk``
2023-01-10 08:05:34 +09:00
Michael Goulet
f769d34291 Assert defining anchor is set in take_opaque_types 2023-01-09 18:14:28 +00:00
Michael Goulet
36ee66c6c5 Check impl's where clauses in consider_impl_candidate in experimental solver 2023-01-09 17:24:36 +00:00
fee1-dead
f8319bb403
Rollup merge of #106389 - compiler-errors:no-canonicalized, r=lcnr
Simplify some canonical type alias names

* delete the `Canonicalized<'tcx>` type alias in favor for `Canonical<'tcx>`
* `CanonicalizedQueryResponse` -> `CanonicalQueryResponse`

I don't particularly care about the latter, but it should be consistent. We could alternatively delete the first alias and rename the struct to `Canonicalized`, and then keep the name of `CanonicalizedQueryResponse` untouched.
2023-01-09 23:35:30 +08:00
fee1-dead
c1f8a3ffb2
Rollup merge of #105655 - RedDocMD:bug-105645, r=oli-obk
Remove invalid case for mutable borrow suggestion

If we have a call such as `foo(&mut buf)` and after reference
collapsing the type is inferred as `&T` where-as the required type is
`&mut T`, don't suggest `foo(&mut mut buf)`. This is wrong syntactically
and the issue lies elsewhere, not in the borrow.

Fixes #105645
2023-01-09 23:35:27 +08:00
kadmin
21c5ffe008 Clean up
Simplify match statement

Add multiple tests
- 1 test for checking `N + 1 + 1` does not unify with `N+1`
- 2 tests for checking that a function that uses two parameters only returns the parameter that
  is actually used.
- Check exact repeat predicates
2023-01-09 08:41:21 +00:00
kadmin
7c5cb73735 Check for duplicates 2023-01-09 08:41:21 +00:00
kadmin
b79a9a0900 Set !const_evaluatable if ambig. and not inferred
This prevents an ICE due to a value not actually being evaluatable later.
2023-01-09 08:41:21 +00:00
kadmin
77b61379b6 Change based on comments
Instead of just switching to a probe, check for different matches, and see how many there are.
If one, unify it, otherwise return true and let it be unified later.
2023-01-09 08:41:21 +00:00
kadmin
abe040d876 Change commit_if_ok to probe 2023-01-09 08:41:21 +00:00
Michael Goulet
eefc44b7e2
Rollup merge of #106497 - chenyukang:yukang/fix-106443-sugg-clone, r=estebank
Suggest using clone when we have &T and T implemented Clone

Fixes #106443
2023-01-08 19:57:54 -08:00
Michael Goulet
3c41003873 Add type flags support for Ty and Const late-bound regions 2023-01-08 03:37:20 +00:00
bors
a2112fcb0a Auto merge of #106519 - estebank:tail-unit, r=cjgillot
Detect bindings assigned blocks without tail expressions

Fix #44173.
2023-01-07 13:24:12 +00:00
Michael Goulet
258257a029
Rollup merge of #106525 - compiler-errors:new-solver-wf, r=jackh726
Report WF error for chalk *and* new solver

addressing this nit https://github.com/rust-lang/rust/pull/106385#discussion_r1062571070

No test yet because new solver is currently unusable, lol

r? `@lcnr`
2023-01-06 21:53:59 -08:00
yukang
6082729646 use type_implements_trait to check Param clone 2023-01-07 09:20:05 +08:00
yukang
ce4afed2ef comments feedback 2023-01-07 05:00:49 +08:00
yukang
e7a777805a Suggest possible clone when we have &T 2023-01-07 04:43:57 +08:00
Dylan DPC
a8f7ec2c48
Rollup merge of #106499 - lyming2007:issue-105946-fix, r=estebank
fix [type error] for error E0029 and E0277

check explicitly for the type references error
if ty.references_error() is true change the error to be err.delay_as_bug() and prevent the error E0029 and E0277 from emitting out this fix #105946
2023-01-06 11:38:57 +05:30
Yiming Lei
10dbcf0630 fix [type error] for error E0029 and E0277
check explicitly for the type references error
if ty.references_error() is true change the error to be err.delay_as_bug()
and prevent the error E0029 and E0277 from emitting out
this fix #105946
2023-01-05 21:21:13 -08:00
Esteban Küber
031e085450 Tweak output 2023-01-06 04:37:29 +00:00
Michael Goulet
a9d093bd6b Report WF error for new solver too 2023-01-06 04:09:44 +00:00