Commit Graph

3316 Commits

Author SHA1 Message Date
Matthias Krüger
8c9e516e6e
Rollup merge of #116082 - compiler-errors:default-assoc-ty-msg, r=estebank
Tweak expected message to explain what it's actually signifying

r? ``@estebank`` since you added this
2023-09-24 01:14:06 +02:00
Matthias Krüger
d92a1bd7cc
Rollup merge of #116073 - compiler-errors:poly-sigs, r=b-naber
Allow higher-ranked fn sigs in `ValuePairs`

For better bookkeeping -- only affects diagnostic path. Allow reporting signature mismatches like "signature"s and not "fn pointer"s.

Improves https://github.com/rust-lang/rust/pull/115897#discussion_r1331940846
2023-09-24 01:14:05 +02:00
Camille GILLOT
44ac8dcc71 Remove GeneratorWitness and rename GeneratorWitnessMIR. 2023-09-23 13:47:30 +00:00
Camille GILLOT
211d2ed07b Bless tests. 2023-09-23 13:47:30 +00:00
Camille GILLOT
a626caaad9 Revert duplication of tests. 2023-09-23 13:34:07 +00:00
bors
3050938abd Auto merge of #116081 - compiler-errors:closure-captures-sized, r=cjgillot
Check that closure/generator's interior/capture types are sized

check that closure upvars and generator interiors are sized. this check is only necessary when `unsized_fn_params` or `unsized_locals` is enabled, so only check if those are active.

Fixes #93622
Fixes #61335
Fixes #68543
2023-09-23 10:01:49 +00:00
bors
0237aa3d77 Auto merge of #116045 - notriddle:notriddle/issue-83556, r=cjgillot
diagnostics: avoid mismatch between variance index and hir generic

This happens because variances are constructed from ty generics, and ty generics are always constructed with lifetimes first.

b3aa8e7168/compiler/rustc_hir_analysis/src/collect/generics_of.rs (L248-L269)

Fixes #83556
2023-09-23 08:11:59 +00:00
bors
136d74fab8 Auto merge of #116071 - estebank:issue-115905, r=compiler-errors
Point at cause of expectation of `break` value when possible

When encountering a type error within the value of a `break` statement, climb the HIR tree to identify if the expectation comes from an assignment or a return type (if the loop is the tail expression of a `fn`).

Fix #115905.
2023-09-23 06:25:41 +00:00
Michael Howell
58ef3a0ec9 diagnostics: simpler 83556 handling by bailing out 2023-09-22 22:41:01 -07:00
Michael Goulet
79d685325c Check types live across yields in generators too 2023-09-23 04:19:14 +00:00
Michael Goulet
c21867f9f6 Check that closure's by-value captures are sized 2023-09-23 04:19:14 +00:00
Michael Goulet
82e7cec16d Tweak expected message to explain what it's actually signifying 2023-09-23 00:57:17 +00:00
bors
55b5c7bfde Auto merge of #115695 - tmiasko:compiletest-supported-sanitizers, r=oli-obk
compiletest: load supported sanitizers from target spec
2023-09-23 00:25:14 +00:00
Esteban Küber
d3dea30cb4 Point at cause of expectation of break value when possible
Fix #115905.
2023-09-22 22:20:53 +00:00
bors
e4133ba9b1 Auto merge of #116077 - matthiaskrgr:rollup-2y1buzg, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #115770 (Match on elem first while building move paths)
 - #115999 (Capture scrutinee of if let guards correctly)
 - #116056 (Make unsized casts illegal)
 - #116061 (Remove TaKO8Ki from review rotation)
 - #116062 (Change `start` to `#[start]` in some diagnosis)
 - #116067 (Open the FileEncoder file for reading and writing)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-22 21:46:07 +00:00
Matthias Krüger
efee13ab33
Rollup merge of #116067 - saethlin:meta-stats-ice, r=WaffleLapkin
Open the FileEncoder file for reading and writing

Maybe I just don't know `File` well enough, but the previous comment didn't make it clear enough to me that we can't use `File::create`. This one does.

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

r? `@WaffleLapkin`
2023-09-22 23:12:38 +02:00
Matthias Krüger
952d6608fc
Rollup merge of #116062 - eduardosm:start-fn-diag, r=WaffleLapkin
Change `start` to `#[start]` in some diagnosis

They refer to a function with the `start` attribute, but not necessarily named `start`.
2023-09-22 23:12:37 +02:00
Matthias Krüger
a38f2309fc
Rollup merge of #116056 - ouz-a:wide_ice, r=compiler-errors
Make unsized casts illegal

Weirdly enough this https://github.com/rust-lang/rust/issues/115998 issue seems to exist since Rust 1.0 (couldn't check before that) but it's only recently been noticed. This change makes those casts illegal.

Fixes https://github.com/rust-lang/rust/issues/115998
2023-09-22 23:12:36 +02:00
Matthias Krüger
e6f4b35d9f
Rollup merge of #115999 - matthewjasper:closure-capture-let-guards, r=b-naber
Capture scrutinee of if let guards correctly

Previously we were always capturing by value.

cc #51114
2023-09-22 23:12:35 +02:00
Ben Kimock
09960e0319 Open the FileEncoder file for reading and writing 2023-09-22 16:13:25 -04:00
bors
aadb5718dd Auto merge of #116001 - fmease:validate-crate-name-extern-cli-opt, r=est31
[breaking change] Validate crate name in `--extern` [MCP 650]

Reject non-ASCII-identifier crate names passed to the CLI option `--extern` (`rustc`, `rustdoc`).
Implements [MCP 650](https://github.com/rust-lang/compiler-team/issues/650) (except that we only allow ASCII identifiers not arbitrary Rust identifiers).
Fixes #113035.

[As mentioned on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Disallow.20non-identifier-valid.20--extern.20cr.E2.80.A6.20compiler-team.23650/near/376826988), doing a crater run probably doesn't make sense since it wouldn't yield anything. Most users don't interact with `rustc` directly but only ever through Cargo which always passes a valid crate name to `--extern` when it invokes `rustc` and `rustdoc`. In any case, the user wouldn't be able to use such a crate name in the source code anyway.

Note that I'm not using [`rustc_session::output::validate_crate_name`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_session/output/fn.validate_crate_name.html) (used for `--crate-name` and `#![crate_name]`) since the latter doesn't reject non-ASCII crate names and ones that start with a digit.

As an aside, I've also thought about getting rid of `validate_crate_name` entirely in a separate PR (with another MCP) in favor of `is_ascii_ident` to reject more weird `--crate-name`s, `#![crate_name]`s and file names but I think that would lead to a lot of actual breakage, namely because of file names starting with a digit. In `tests/ui` 9 tests would be impacted for example.

CC `@estebank`
r? `@est31`
2023-09-22 19:57:07 +00:00
Michael Goulet
8cfd249198 Allow higher-ranked fn sigs in ValuePairs 2023-09-22 19:47:41 +00:00
Tomasz Miąsko
9090ed8119 Fix test on targets with crt-static default 2023-09-22 18:13:00 +02:00
ouz-a
861448b426 make unsized cast illegal 2023-09-22 18:57:27 +03:00
bors
959b2c703d Auto merge of #115696 - RalfJung:closure-ty-print, r=oli-obk
adjust how closure/generator types are printed

I saw `&[closure@$DIR/issue-20862.rs:2:5]` and I thought it is a slice type, because that's usually what `&[_]` is... it took me a while to realize that this is just a confusing printer and actually there's no slice. Let's use something that cannot be mistaken for a regular type.
2023-09-22 15:19:38 +00:00
Eduardo Sánchez Muñoz
17dfabff9c Change start to #[start] in some diagnosis
They refer to a function with the `start` attribute, but not necessarily named `start`.
2023-09-22 15:58:43 +02:00
Matthew Jasper
d4ffb3b08a Capture scrutinee of if let guards correctly
Previously we were always capturing by value.
2023-09-22 13:04:44 +00:00
Matthias Krüger
fc4cfe01f6
Rollup merge of #116039 - estebank:nested-tait, r=compiler-errors
Account for nested `impl Trait` in TAIT

Fix #116031.

r? `@compiler-errors`
2023-09-22 12:15:27 +02:00
Matthias Krüger
06608c7860
Rollup merge of #116036 - Enselic:split-large_moves, r=oli-obk
tests/ui: Split large_moves.rs and move to lint/large_assignments

To make failing tests easier to debug with `--emit=mir`, etc.

Don't bother with `revisions: attribute option` for both tests though. Seems sufficient to just have that on one of the tests.

`git show -M --find-renames=40%` makes the diff easier to review. Or note that before this change we had one test with 4 errors, now we have 2 tests with 2 errors each.

r? `@oli-obk`

Part of https://github.com/rust-lang/rust/issues/83518
2023-09-22 12:15:26 +02:00
Matthias Krüger
d5e7df3dbf
Rollup merge of #116034 - chenyukang:yukang-98601-add-ui-testcase, r=estebank
add UI test for delimiter errors

Fixes #98601
from https://github.com/rust-lang/rust/issues/98601#issuecomment-1721515067
r? `@estebank`
2023-09-22 12:15:26 +02:00
bors
8759de0a49 Auto merge of #114776 - fee1-dead-contrib:enable-effects-in-libcore, r=oli-obk
Enable effects for libcore

~~r? `@oli-obk~~`

forgot you are on vacation, oops
2023-09-22 07:00:52 +00:00
bors
aace2dfa37 Auto merge of #115910 - eduardosm:lang-fns-target-features, r=cjgillot
Prevent using `#[target_feature]` on lang item functions

Fixes https://github.com/rust-lang/rust/issues/109411 and also prevents from using `#[target_feature]` on other `fn` lang items to mitigate the concerns from https://github.com/rust-lang/rust/issues/109411#issuecomment-1477030273.
2023-09-22 05:07:45 +00:00
Michael Howell
3799af3337 diagnostics: avoid mismatch between variance index and hir generic
This happens because variances are constructed from ty generics,
and ty generics are always constructed with lifetimes first.

See compiler/rustc_hir_analysis/src/collect/generics_of.rs:248-269

Fixes #83556
2023-09-21 17:21:07 -07:00
bors
99b63d068b Auto merge of #115897 - eduardosm:check-fn-sig, r=compiler-errors
rustc_hir_analysis: add a helper to check function the signature mismatches

This function is now used to check `#[panic_handler]`, `start` lang item, `main`, `#[start]` and intrinsic functions.

The diagnosis produced are now closer to the ones produced by trait/impl method signature mismatch.

This is the first time I do anything with rustc_hir_analysis/rustc_hir_typeck, so comments and suggestions about things I did wrong or that could be improved will be appreciated.
2023-09-21 22:59:13 +00:00
bors
b3aa8e7168 Auto merge of #115864 - compiler-errors:rpitit-sugg, r=estebank
Suggest desugaring to return-position `impl Future` when an `async fn` in trait fails an auto trait bound

First commit allows us to store the span of the `async` keyword in HIR.

Second commit implements a suggestion to desugar an `async fn` to a return-position `impl Future` in trait to slightly improve the `Send` situation being discussed in #115822.

This suggestion is only made when `#![feature(return_type_notation)]` is not enabled -- if it is, we should instead suggest an appropriate where-clause bound.
2023-09-21 21:12:32 +00:00
Ralf Jung
c4ec12f4b7 adjust how closure/generator types and rvalues are printed 2023-09-21 22:20:58 +02:00
bors
f73d376fb6 Auto merge of #115230 - Vtewari2311:mod-hurd-latest, r=b-naber
added support for GNU/Hurd

adding support for i686-unknown-hurd-gnu
2023-09-21 19:24:01 +00:00
Michael Goulet
9072415252 Suggest desugaring to RPITIT when AFIT is required to be an auto trait 2023-09-21 19:18:14 +00:00
Michael Goulet
087a571e70 Record asyncness span in HIR 2023-09-21 19:18:14 +00:00
Martin Nordholts
d016e9a686 tests/ui: Split large_moves.rs and move to lint/large_assignments
To make failing tests easier to debug with --emit=mir, etc.
2023-09-21 21:00:11 +02:00
Esteban Küber
f2ede49c2f Account for nested impl Trait in TAIT
Fix #116031.
2023-09-21 17:47:09 +00:00
Martin Nordholts
afdd468ab8 tests/ui: Fix large_moves attribute cfg
We only want the attribute for the attribute revision.
2023-09-21 18:38:24 +02:00
Samuel Thibault
dcea7709f2 added support for GNU/Hurd 2023-09-21 17:31:25 +02:00
yukang
f7cd892b5a add UI test for delimiter errors 2023-09-21 23:20:47 +08:00
Guillaume Gomez
d05c5fecde
Rollup merge of #115936 - oli-obk:inline_const_promotion, r=RalfJung
Prevent promotion of const fn calls in inline consts

We don't wanna make that mistake we did for statics and consts worse by letting more code use it.

r? ``@RalfJung``

cc https://github.com/rust-lang/rust/issues/76001
2023-09-21 13:25:38 +02:00
Guillaume Gomez
9ce64bae94
Rollup merge of #115257 - Urgau:invalid-utf8-walk-up-hir, r=Nilstrieb
Improve invalid UTF-8 lint by finding the expression initializer

This PR introduce a small mechanism to walk up the HIR through bindings, if/else, consts, ... when trying lint on invalid UTF-8.

Fixes https://github.com/rust-lang/rust/issues/115208
2023-09-21 13:25:38 +02:00
Oli Scherer
9c762b58ba Prevent promotion of const fn calls in inline consts 2023-09-21 09:00:22 +00:00
Oli Scherer
44e199bf30 Add regression test 2023-09-21 08:50:08 +00:00
Urgau
f156d3bc57 Improve invalid UTF-8 lint by finding the expression initializer 2023-09-21 10:16:29 +02:00
lcnr
8eade3aa71 update tests 2023-09-21 08:17:58 +02:00