Commit Graph

20719 Commits

Author SHA1 Message Date
klensy
cce2f5f772 fix typo LocalItemId -> ItemLocalId 2023-01-11 15:45:52 +03:00
Yuki Okushi
c2d1cac36b
Rollup merge of #106671 - tmiasko:opt-bool, r=wesleywiser
Change flags with a fixed default value from Option<bool> to bool
2023-01-11 14:18:57 +09:00
Yuki Okushi
0e92e1dd99
Rollup merge of #106669 - ozkanonur:helper-function-for-lint-level, r=Nilstrieb
create helper function for `rustc_lint_defs::Level` and remove it's duplicated code

Signed-off-by: ozkanonur <work@onurozkan.dev>
2023-01-11 14:18:57 +09:00
Yuki Okushi
8f57062970
Rollup merge of #106653 - ehuss:allow-features-help, r=nilstrieb
Fix help docs for -Zallow-features

The arguments for -Zallow-features are comma-separated (`parse_opt_comma_list`), not space separated (`parse_list`).
2023-01-11 14:18:55 +09:00
Yuki Okushi
e078d82711
Rollup merge of #106645 - c410-f3r:rfc-2397-1, r=oli-obk
[RFC 2397] Initial implementation

cc #51992

Because of previous experiences where ppl didn't have the time to review large PRs (or any at all), the implementation of this feature will be delivered in small chunks to hopefully make things faster.

In this initial PR, only the attribute is being declared and gated with ordinary tests.
2023-01-11 14:18:55 +09: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
Yuki Okushi
8d7a06aece
Rollup merge of #105194 - tmiasko:cleanup-kinds, r=davidtwco
Add comment to cleanup_kinds

based on the original commit message 1ae7ae0c1c
2023-01-11 14:18:52 +09:00
Tomasz Miąsko
72f8d6a659 Change type of box_noalias to bool 2023-01-10 10:14:59 +01:00
Tomasz Miąsko
78075e1e26 Change type of mutable_noalias to bool 2023-01-10 10:14:51 +01:00
Tomasz Miąsko
836ef6162d Add comment to cleanup_kinds
based on the original commit message 1ae7ae0c1c
2023-01-10 09:53:18 +01:00
ozkanonur
5fb9ca3c5e create helper function for rustc_lint_defs::Level and remove it's duplicated code r=ozkanonur
Signed-off-by: ozkanonur <work@onurozkan.dev>
2023-01-10 10:56:17 +03:00
bors
0442fbabe2 Auto merge of #106607 - compiler-errors:be-more-accurate-abt-method-suggestions, r=oli-obk
Consider return type when giving various method suggestions

1. Fix a bug in method probe where we weren't normalizing `xform_ret_ty` for non-`impl` method candidates. This shouldn't affect happy-path code, since we only use `xform_ret_ty` when probing methods for diagnostics (I think).
2. Pass the return type expectation down to `lookup_probe`/`probe_for_name` usages in diagnostics. Added a few UI tests to gate against bad suggestions.
3. Make a `FnCtxt::lookup_probe_for_diagnostic` which properly passes down `IsSuggestion(true)`. Should help suppress other weird notes in some corner cases.
2023-01-10 06:22:01 +00:00
bowlerman
f75eb24f4f remove E0280 and ICE instead 2023-01-10 03:04:28 +01:00
Caio
c43faf110d [RFC 2397] Initial implementation 2023-01-09 20:51:01 -03:00
Yuki Okushi
96e53c0c6c
Rollup merge of #106636 - djkoloski:accept_old_fuchsia_triple, r=tmandry
Accept old spelling of Fuchsia target triples

The old spelling of Fuchsia target triples was changed in #106429 to add a proper vendor. Because the old spelling is widely used, some projects may need time to migrate their uses to the new triple spelling. The old spelling may eventually be removed altogether.

r? ``@tmandry``
2023-01-10 08:05:35 +09: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
Yuki Okushi
684a3717cb
Rollup merge of #106175 - compiler-errors:bad-import-sugg, r=oli-obk
Fix bad import suggestion with nested `use` tree

Fixes #105566
Fixes #105373

Ideally, we'd find some way to turn these into structured suggestions -- perhaps on a separate line as a different `use` statement, but I have no idea how to access the span for the whole `use` from this point in the import resolution code.
2023-01-10 08:05:34 +09:00
Yuki Okushi
5773e8baf0
Rollup merge of #105708 - tomerze:enable-atomic-cas-bpf, r=nagisa
Enable atomic cas for bpf targets

It seems like LLVM now supports it.

https://reviews.llvm.org/D72184 - the PR in LLVM
2023-01-10 08:05:33 +09:00
Eric Huss
d0c47bdcc9 Fix help docs for -Zallow-features 2023-01-09 14:20:34 -08:00
Tyler Mandry
9c23629158
Add issue number to FIXMEs 2023-01-09 13:23:50 -05:00
bors
3020239de9 Auto merge of #106637 - fee1-dead-contrib:rollup-ticvmsd, r=fee1-dead
Rollup of 10 pull requests

Successful merges:

 - #105292 (Change a commit_if_ok call to probe)
 - #105655 (Remove invalid case for mutable borrow suggestion)
 - #106047 (Fix ui constant tests for big-endian platforms)
 - #106061 (Enable Shadow Call Stack for Fuchsia on AArch64)
 - #106164 (Move `check_region_obligations_and_report_errors` to `TypeErrCtxt`)
 - #106291 (Fix incorrect suggestion for extra `&` in pattern)
 - #106389 (Simplify some canonical type alias names)
 - #106468 (Use FxIndexSet when updating obligation causes in `adjust_fulfillment_errors_for_expr_obligation`)
 - #106549 (Use fmt named parameters in rustc_borrowck)
 - #106614 (error-code docs improvements (No. 2))

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-09 18:20:00 +00:00
Michael Goulet
f769d34291 Assert defining anchor is set in take_opaque_types 2023-01-09 18:14:28 +00:00
Michael Goulet
1d66a675bb review comment 2023-01-09 18:07:34 +00:00
Michael Goulet
4f15034b55 hack: don't normalize xform_ret_ty for trait/object candidates unless needed 2023-01-09 17:48:22 +00:00
Michael Goulet
2600d6245b Add lookup_probe_for_diagnostic 2023-01-09 17:48:22 +00:00
Michael Goulet
38491c6579 Consider method return type for various method suggestions 2023-01-09 17:48:22 +00:00
Michael Goulet
5132e13f13 No need to take opaques in check_type_bounds 2023-01-09 17:27:42 +00:00
Michael Goulet
7ee6cebd8a Unconditionally normalize xform_ret_ty in probe 2023-01-09 17:26:00 +00:00
David Koloski
42aa075310 Accept old spelling of Fuchsia target triples
Because the old spelling is widely used, some projects may need time to
migrate their uses to the new triple spelling. The old spelling may
eventually be removed altogether.
2023-01-09 12:18:12 -05:00
fee1-dead
77f529bb0a
Rollup merge of #106614 - Ezrashaw:ui-test-fixups-2, r=GuillaumeGomez
error-code docs improvements (No. 2)

- Added empty error-code docs for `E0208`, `E0640` and `E0717` with the "internal" header as discussed on Discord.
- Wrote docs and UI test for `E0711`, again with the header.
- `tidy` changes are common-sense and make everything pass, `style.rs` hack is annoying though.

r? ```@GuillaumeGomez```
2023-01-09 23:35:32 +08:00
fee1-dead
99529b0cd2
Rollup merge of #106549 - wcampbell0x2a:use-fmt-named-parameters-borrowck, r=estebank
Use fmt named parameters in rustc_borrowck
2023-01-09 23:35:31 +08:00
fee1-dead
357128ad23
Rollup merge of #106468 - compiler-errors:err-instability, r=lcnr
Use FxIndexSet when updating obligation causes in `adjust_fulfillment_errors_for_expr_obligation`

I have no idea how to test this reliably, but I've **manually** verified it fixes the instability in #106417 that isn't due to dtolnay/trybuild#212.

Fixes #106417
2023-01-09 23:35:31 +08: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
37c1d6dc09
Rollup merge of #106291 - obeis:issue-106182, r=oli-obk
Fix incorrect suggestion for extra `&` in pattern

Closes #106182
2023-01-09 23:35:29 +08:00
fee1-dead
7779386a3a
Rollup merge of #106164 - compiler-errors:check-region-tweak, r=oli-obk
Move `check_region_obligations_and_report_errors` to `TypeErrCtxt`

Makes sense for this function to live with its sibling `resolve_regions_and_report_errors`, around which it's basically just a wrapper.
2023-01-09 23:35:29 +08:00
fee1-dead
fd75cfef66
Rollup merge of #106061 - ilovepi:fuchsia-scs, r=oli-obk
Enable Shadow Call Stack for Fuchsia on AArch64

Fuchsia already uses SCS by default for C/C++ code on ARM hardware. This patch allows SCS to be used for Rust code as well.
2023-01-09 23:35:28 +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
fee1-dead
b7587f1867
Rollup merge of #105292 - JulianKnodt:no_eager_commit, r=BoxyUwU
Change a commit_if_ok call to probe

Removes an over-eager `commit_if_ok` which makes inference worse.

I'm not entirely sure whether it's ok to remove the check that types are the same, because casting seems to cause equality checks with incorrect types?

Fixes #105037

r? ```@BoxyUwU```
2023-01-09 23:35:26 +08:00
bors
af58fc8699 Auto merge of #101947 - aliemjay:astconv-normalize, r=lcnr
Don't normalize in AstConv

See individual commits.

Fixes #101350
Fixes #54940
2023-01-09 15:29:59 +00:00
bors
89e0576bd3 Auto merge of #106340 - saethlin:propagate-operands, r=oli-obk
Always permit ConstProp to exploit arithmetic identities

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

Initially, I thought I would need to enable operand propagation then do something else, but actually https://github.com/rust-lang/rust/pull/74491 already has the fix for the issue in question! It looks like this optimization was put under MIR opt level 3 due to possible soundness/stability implications, then demoted further to MIR opt level 4 when MIR opt level 2 became associated with `--release`.

Perhaps in the past we were doing CTFE on optimized MIR? We aren't anymore, so this optimization has no stability implications.

r? `@oli-obk`
2023-01-09 11:59:51 +00: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
bors
c54c8cbac8 Auto merge of #106582 - compiler-errors:better-spans-on-bad-tys, r=lcnr
Improve spans of non-WF implied bound types

Fixes #60980
2023-01-09 08:40:08 +00:00
Michael Goulet
5e8e97f981
Rollup merge of #106606 - estebank:bad-nested-turbofish, r=compiler-errors
Do not emit structured suggestion for turbofish with wrong span

Fix #79161.
2023-01-08 19:57:56 -08:00
Michael Goulet
29420a8e7a
Rollup merge of #106600 - compiler-errors:no-private-field-ty-err, r=estebank
Suppress type errors that come from private fields

Fixes #57320

There was some discussion here (https://github.com/rust-lang/rust/issues/57320#issuecomment-451308420), but I honestly think the second error is worth suppressing regardless.

I would be open to feedback though -- perhaps we can suppress the `.len()` suggestion if there's type error (since we have access to [`Expectation`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_typeck/enum.Expectation.html), we can determine that).

r? ``@estebank``
2023-01-08 19:57:55 -08: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
334426b7a8
Rollup merge of #106363 - estebank:mutability-mismatch-arg, r=Nilstrieb
Structured suggestion for `&mut dyn Iterator` when possible

Fix #37914.
2023-01-08 19:57:53 -08:00