Commit Graph

5476 Commits

Author SHA1 Message Date
Gil Shoshan
bf8756d2dd
Don't lint snake-case on executable crate name
Co-authored-by: Jieyou Xu <jieyouxu@outlook.com>
2024-02-28 16:55:00 +00:00
Ryan Levick
f115064631 Add the wasm32-wasi-preview2 target
Signed-off-by: Ryan Levick <me@ryanlevick.com>
2024-02-27 09:58:04 -05:00
bors
71ffdf7ff7 Auto merge of #121655 - matthiaskrgr:rollup-qpx3kks, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #121598 (rename 'try' intrinsic to 'catch_unwind')
 - #121639 (Update books)
 - #121648 (Update Vec and String `{from,into}_raw_parts`-family docs)
 - #121651 (Properly emit `expected ;` on `#[attr] expr`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-27 00:55:14 +00:00
Matthias Krüger
ec5c5b7da8
Rollup merge of #121651 - ShE3py:issue-121647, r=estebank
Properly emit `expected ;` on `#[attr] expr`

Fixes #121647

See #118182, #120586

---
r? estebank
2024-02-27 00:40:01 +01:00
Matthias Krüger
d95c321062
Rollup merge of #121598 - RalfJung:catch_unwind, r=oli-obk
rename 'try' intrinsic to 'catch_unwind'

The intrinsic has nothing to do with `try` blocks, and corresponds to the stable `catch_unwind` function, so this makes a lot more sense IMO.

Also rename Miri's special function while we are at it, to reflect the level of abstraction it works on: it's an unwinding mechanism, on which Rust implements panics.
2024-02-27 00:40:00 +01:00
bors
5c786a7fe3 Auto merge of #121516 - RalfJung:platform-intrinsics-begone, r=oli-obk
remove platform-intrinsics ABI; make SIMD intrinsics be regular intrinsics

`@Amanieu` `@workingjubilee` I don't think there is any reason these need to be "special"? The [original RFC](https://rust-lang.github.io/rfcs/1199-simd-infrastructure.html) indicated eventually making them stable, but I think that is no longer the plan, so seems to me like we can clean this up a bit.

Blocked on https://github.com/rust-lang/stdarch/pull/1538, https://github.com/rust-lang/rust/pull/121542.
2024-02-26 22:24:16 +00:00
Lieselotte
1658ca082a
Properly emit expected ; on #[attr] expr 2024-02-26 21:47:10 +01:00
Matthias Krüger
218be2771d
Rollup merge of #121628 - gurry:121534-ice-asymm-binop, r=oli-obk
Do not const prop unions

Unions can produce values whose types don't match their underlying layout types which can lead to ICEs on eval.

Fixes #121534
2024-02-26 16:06:04 +01:00
Matthias Krüger
4f167b4baf
Rollup merge of #121617 - compiler-errors:async-closure-kind-check, r=oli-obk
Actually use the right closure kind when checking async Fn goals

Dumb copy-paste mistake on my part from #120712. Sorry!

r? oli-obk

Fixes #121599
2024-02-26 16:06:04 +01:00
bors
b8de591b65 Auto merge of #119106 - lcnr:decrement-universes, r=BoxyUwU
avoid generalization inside of aliases

The basic idea of this PR is that we don't generalize aliases when the instantiation could fail later on, either due to the *occurs check* or because of a universe error. We instead replace the whole alias with an inference variable and emit a nested `AliasRelate` goal. This `AliasRelate` then fully normalizes the alias before equating it with the inference variable, at which point the alias can be treated like any other rigid type.

We now treat aliases differently depending on whether they are *rigid* or not. To detect whether an alias is rigid we check whether `NormalizesTo` fails. While we already do so inside of `AliasRelate` anyways, also doing so when instantiating a query response would be both ugly/difficult and likely inefficient. To avoid that I change `instantiate_and_apply_query_response` to relate types completely structurally. This change generally removes a lot of annoying complexity, which is nice. It's implemented by adding a flag to `Equate` to change it to structurally handle aliases.

We currently always apply constraints from canonical queries right away. By providing all the necessary information to the canonical query, we can guarantee that instantiating the query response never fails, which further simplifies the implementation. This does add the invariant that *any information which could cause instantiating type variables to fail must also be available inside of the query*.

While it's acceptable for canonicalization to result in more ambiguity, we must not cause the solver to incompletely structurally relate aliases by erasing information. This means we have to be careful when merging universes during canonicalization. As we only generalize for type and const variables we have to make sure that anything nameable by such a type or const variable inside of the canonical query is also nameable outside of it. Because of this we both stop merging universes of existential variables when canonicalizing inputs, we put all uniquified regions into a higher universe which is not nameable by any type or const variable.

I will look into always replacing aliases with inference variables when generalizing in a later PR unless the alias references bound variables. This should both pretty much fix https://github.com/rust-lang/trait-system-refactor-initiative/issues/4. This may allow us to merge the universes of existential variables again by changing generalize to not consider their universe when deciding whether to generalize aliases. This requires some additional non-trivial changes to alias-relate, so I am leaving that as future work.

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/79. While it would be nice to decrement universe indices when existing a `forall`, that was surprisingly difficult and not necessary to fix this issue. I am really happy with the approach in this PR think it is the correct way forward to also fix the remaining cases of https://github.com/rust-lang/trait-system-refactor-initiative/issues/8.
2024-02-26 12:11:58 +00:00
Ralf Jung
b4ca582b89 rename 'try' intrinsic to 'catch_unwind' 2024-02-26 11:10:18 +01:00
lcnr
1c264ca9ca add regression tests 2024-02-26 11:01:31 +01:00
lcnr
2c7ede8f52 update tests 2024-02-26 10:57:46 +01:00
Gurinder Singh
633c92cd6d Do not const pop unions
as they can made to produce values whose types don't
match their underlying layout types which can lead to
ICEs on eval
2024-02-26 15:22:22 +05:30
Guillaume Gomez
76f303d658
Rollup merge of #121620 - nnethercote:fix-even-more-121208-fallout, r=lcnr
Fix more #121208 fallout (round 3)

#121208 converted lots of delayed bugs to bugs. Unsurprisingly, there were a few invalid conversion found via fuzzing.

r? `@lcnr`
2024-02-26 10:27:43 +01:00
Guillaume Gomez
5bd909227d
Rollup merge of #121554 - Enselic:sigaction, r=oli-obk
Don't unnecessarily change `SIGPIPE` disposition in `unix_sigpipe` tests

In `auxiliary/sigpipe-utils.rs`, all we want to know is the current `SIGPIPE` disposition. We should not change it. So use `libc::sigaction` instead of `libc::signal`. That way we can also remove the code that restores it.

Part of https://github.com/rust-lang/rust/issues/97889.
2024-02-26 10:27:42 +01:00
Guillaume Gomez
91d337dfa8
Rollup merge of #120840 - HTGAzureX1212:HTGAzureX1212/unicode-identifier-types, r=fmease,Manishearth
Split Diagnostics for Uncommon Codepoints: Add Individual Identifier Types

This pull request further modifies the `uncommon_codepoints` lint, adding the individual identifier types of `Technical`, `Not_NFKC`, `Exclusion` and `Limited_Use` to the diagnostic message.

Example rendered diagnostic:
```
error: identifier contains a Unicode codepoint that is not used in normalized strings: 'ij'
  --> $DIR/lint-uncommon-codepoints.rs:6:4
   |
LL | fn dijkstra() {}
   |    ^^^^^^^
   = note: this character is included in the Not_NFKC Unicode general security profile
```

Second step of #120228.
2024-02-26 10:27:41 +01:00
HTGAzureX1212.
8bccceb8fc separate messages for individual categories 2024-02-26 10:09:03 +08:00
Michael Goulet
ff07f55db5 Actually use the right closure kind when checking async Fn goals 2024-02-26 01:36:14 +00:00
bors
0250ef2571 Auto merge of #121461 - reitermarkus:generic-nonzero-tests, r=dtolnay
Use generic `NonZero` in tests.

Tracking issue: https://github.com/rust-lang/rust/issues/120257

r? `@dtolnay`
2024-02-26 01:16:16 +00:00
Nicholas Nethercote
edda2a7d3e Revert some span_bugs to span_delayed_bug.
Fixes #121503.
Fixes #121597.
2024-02-26 10:57:30 +11:00
bors
b0d3e04ca9 Auto merge of #120393 - Urgau:rfc3373-non-local-defs, r=WaffleLapkin
Implement RFC 3373: Avoid non-local definitions in functions

This PR implements [RFC 3373: Avoid non-local definitions in functions](https://github.com/rust-lang/rust/issues/120363).
2024-02-25 19:11:06 +00:00
Matthias Krüger
a4423884c1
Rollup merge of #121586 - gurry:121532-ice-unwrap-on-none, r=cjgillot
Don't use `unwrap()` in `ArrayIntoIter` lint when typeck fails

Fixes #121532
2024-02-25 17:05:23 +01:00
Matthias Krüger
4d442f5a58
Rollup merge of #121409 - compiler-errors:atb-cycle, r=cjgillot
Prevent cycle in implied predicates computation

Makes #65913 from hang -> fail. I believe fail is the correct state for this test to remain for the long term.
2024-02-25 17:05:22 +01:00
Matthias Krüger
c99902e2f9
Rollup merge of #120805 - RalfJung:const-pat-partial-eq, r=oli-obk
make non-PartialEq-typed consts as patterns a hard error

This lint was introduced in https://github.com/rust-lang/rust/pull/115893, for Rust 1.74, so we just had the third stable release where this is shown as a future-compat lint (which is shown for dependencies). Not a single comment or backreference showed up in the tracking issue, https://github.com/rust-lang/rust/issues/116122. So this seems fairly safe to turn into a hard error.

Of course we should do a crater run first.

This is part of https://github.com/rust-lang/rust/issues/120362.
Closes https://github.com/rust-lang/rust/issues/116122.
2024-02-25 17:05:20 +01:00
Matthias Krüger
e13f454874
Rollup merge of #119590 - ChrisDenton:cfg-target-abi, r=Nilstrieb
Stabilize `cfg_target_abi`

This stabilizes the `cfg` option called `target_abi`:

```rust
#[cfg(target_abi = "eabihf")]
```

Tracking issue: #80970

fixes #78791
resolves #80970
2024-02-25 17:05:19 +01:00
Gurinder Singh
fa7557181f Don't use unwrap() in ArrayIntoIter lint when typeck fails 2024-02-25 17:51:56 +05:30
Markus Reiter
b2fbb8a053
Use generic NonZero in tests. 2024-02-25 12:03:48 +01:00
Ralf Jung
5b7786cd1d make non-PartialEq-typed consts as patterns a hard error 2024-02-25 11:30:10 +01:00
Ralf Jung
c1d0e489e5 fix use of platform_intrinsics in tests 2024-02-25 08:15:44 +01:00
bors
2ae1bb6711 Auto merge of #121569 - matthiaskrgr:rollup-awglrax, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #121343 (Add examples for some methods on slices)
 - #121374 (match lowering: Split off `test_candidates` into several functions and improve comments)
 - #121474 (Ignore compiletest test directive migration commits)
 - #121515 (promotion: don't promote int::MIN / -1)
 - #121530 (Fix incorrect doc of ScopedJoinHandle::is_finished)
 - #121551 (Forbid use of `extern "C-unwind"` inside standard library)
 - #121556 (Use `addr_of!`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-24 23:08:21 +00:00
Chris Denton
93ec0e6299
Stabilize cfg_target_abi 2024-02-24 17:52:03 -03:00
Martin Nordholts
f5b9eaf18f Don't unnecessarily change SIGPIPE disposition in unix_sigpipe tests
In `auxiliary/sigpipe-utils.rs`, all we want to know is the current
`SIGPIPE` disposition. We should not change it. So use `libc::sigaction`
instead of `libc::signal`. That way we can also remove the code that
restores it.
2024-02-24 16:18:34 +01:00
Matthias Krüger
b87a713b9d
Rollup merge of #121522 - RalfJung:insert-extract-boundscheck, r=oli-obk
check that simd_insert/extract indices are in-bounds

Fixes https://github.com/rust-lang/rust/issues/77477
r? `@oli-obk`
2024-02-24 15:35:14 +01:00
Matthias Krüger
b10ef3c6bc
Rollup merge of #121435 - estebank:rpitit-static-119773, r=compiler-errors
Account for RPITIT in E0310 explicit lifetime constraint suggestion

When given

```rust
trait Original {
    fn f() -> impl Fn();
}

trait Erased {
    fn f(&self) -> Box<dyn Fn()>;
}

impl<T: Original> Erased for T {
    fn f(&self) -> Box<dyn Fn()> {
        Box::new(<T as Original>::f())
    }
}
```

emit do not emit an invalid suggestion restricting the `Trait::{opaque}` type in a `where` clause:

```
error[E0310]: the associated type `<T as Original>::{opaque#0}` may not live long enough
  --> $DIR/missing-static-bound-from-impl.rs:11:9
   |
LL |         Box::new(<T as Original>::f())
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |         |
   |         the associated type `<T as Original>::{opaque#0}` must be valid for the static lifetime...
   |         ...so that the type `impl Fn()` will meet its required lifetime bounds
```

Partially address #119773. Ideally we'd suggest modifying `Erased::f` instead.

r? `@compiler-errors`
2024-02-24 15:35:12 +01:00
Ralf Jung
f32095cd8d promotion: don't promote int::MIN / -1 2024-02-24 12:17:37 +01:00
Ralf Jung
8e0dd993d6 check that simd_insert/extract indices are in-bounds 2024-02-23 19:43:59 +01:00
Matthias Krüger
06e54f8d49
Rollup merge of #121510 - RalfJung:lint-overflowing-ops, r=oli-obk
lint-overflowing-ops: unify cases and remove redundancy

Follow-up to https://github.com/rust-lang/rust/pull/121432
r? `@oli-obk`
2024-02-23 17:02:06 +01:00
Matthias Krüger
4d5c4e5205
Rollup merge of #121470 - clubby789:anon-struct-in-enum, r=fmease
Don't ICE on anonymous struct in enum variant

Fixes #121446

Computing `adt_def` for the anon struct calls `adt_def` on the parent to find its repr. If the parent is a non-item (e.g. an enum variant) we should have already emitted at least one error, so we just use the repr of the anonymous struct to avoid an ICE.

cc ``@frank-king``
2024-02-23 17:02:04 +01:00
Matthias Krüger
26cb6c7287
Rollup merge of #120742 - Nadrieril:use-min_exh_pats, r=compiler-errors
mark `min_exhaustive_patterns` as complete

This is step 1 and 2 of my [proposal](https://github.com/rust-lang/rust/issues/119612#issuecomment-1918097361) to move `min_exhaustive_patterns` forward. The vast majority of in-tree use cases of `exhaustive_patterns` are covered by `min_exhaustive_patterns`. There are a few cases that still require `exhaustive_patterns` in tests and they're all behind references.

r? ``@ghost``
2024-02-23 17:02:03 +01:00
Ralf Jung
9a2d550050 lint-overflowing-ops: unify cases and remove redundancy 2024-02-23 15:29:33 +01:00
clubby789
35a9e73521 Don't ICE on anonymous struct in enum variant 2024-02-23 12:25:23 +00:00
Matthias Krüger
52805b0cb4
Rollup merge of #121482 - nnethercote:fix-121455, r=oli-obk
Allow for a missing `adt_def` in `NamePrivacyVisitor`.

This was caused by 72b172bdf6 in #121206. That commit removed an early return from `analysis` when there are stashed errors. As a result, it's possible to reach privacy analysis when there are stashed errors, which means more code paths can be reached. One such code path was handled in that commit, where a `span_bug` was changed to a `span_delayed_bug`.

This commit handles another such code path uncovered by fuzzing, in much the same way.

Fixes #121455.

r? `@oli-obk`
2024-02-23 09:42:13 +01:00
Matthias Krüger
5de3a4ce0e
Rollup merge of #121480 - nnethercote:fix-more-121208-fallout, r=lcnr
Fix more #121208 fallout

#121208 converted lots of delayed bugs to bugs. Unsurprisingly, there were a few invalid conversion found via fuzzing.

r? `@lcnr`
2024-02-23 09:42:12 +01:00
Matthias Krüger
86727df4ed
Rollup merge of #121471 - estebank:lint-clone, r=TaKO8Ki
When encountering `<&T as Clone>::clone(x)` because `T: Clone`, suggest `#[derive(Clone)]`

CC #40699.

```
warning: call to `.clone()` on a reference in this situation does nothing
  --> $DIR/noop-method-call.rs:23:71
   |
LL |     let non_clone_type_ref_clone: &PlainType<u32> = non_clone_type_ref.clone();
   |                                                                       ^^^^^^^^
   |
   = note: the type `PlainType<u32>` does not implement `Clone`, so calling `clone` on `&PlainType<u32>` copies the reference, which does not do anything and can be removed
help: remove this redundant call
   |
LL -     let non_clone_type_ref_clone: &PlainType<u32> = non_clone_type_ref.clone();
LL +     let non_clone_type_ref_clone: &PlainType<u32> = non_clone_type_ref;
   |
help: if you meant to clone `PlainType<u32>`, implement `Clone` for it
   |
LL + #[derive(Clone)]
LL | struct PlainType<T>(T);
   |
```
2024-02-23 09:42:11 +01:00
Matthias Krüger
6e00f0d189
Rollup merge of #121434 - nnethercote:fix-121208-fallout, r=lcnr
Fix #121208 fallout

#121208 converted lots of delayed bugs to bugs. Unsurprisingly, there were a few invalid conversion found via fuzzing.

r? `@lcnr`
2024-02-23 09:42:10 +01:00
bors
dda102c190 Auto merge of #121432 - mj10021:issue-119851-fix, r=nnethercote
Move as many tests from tests/ui/numbers-arithmetic to tests/ui/lint as possible

Fixes #119851 , and also consolidates as many individual tests as possible from numbers-arithmetic.  I might have moved the tests in too aggressively, so let me know
2024-02-23 05:42:20 +00:00
bors
a28d221a4b Auto merge of #120730 - estebank:confusable-api, r=oli-obk
Provide suggestions through `rustc_confusables` annotations

Help with common API confusion, like asking for `push` when the data structure really has `append`.

```
error[E0599]: no method named `size` found for struct `Vec<{integer}>` in the current scope
  --> $DIR/rustc_confusables_std_cases.rs:17:7
   |
LL |     x.size();
   |       ^^^^
   |
help: you might have meant to use `len`
   |
LL |     x.len();
   |       ~~~
help: there is a method with a similar name
   |
LL |     x.resize();
   |       ~~~~~~
```

Fix #59450 (we can open subsequent tickets for specific cases).

Fix #108437:

```
error[E0599]: `Option<{integer}>` is not an iterator
   --> f101.rs:3:9
    |
3   |     opt.flat_map(|val| Some(val));
    |         ^^^^^^^^ `Option<{integer}>` is not an iterator
    |
   ::: /home/gh-estebank/rust/library/core/src/option.rs:571:1
    |
571 | pub enum Option<T> {
    | ------------------ doesn't satisfy `Option<{integer}>: Iterator`
    |
    = note: the following trait bounds were not satisfied:
            `Option<{integer}>: Iterator`
            which is required by `&mut Option<{integer}>: Iterator`
help: you might have meant to use `and_then`
    |
3   |     opt.and_then(|val| Some(val));
    |         ~~~~~~~~
```

On type error of method call arguments, look at confusables for suggestion. Fix #87212:

```
error[E0308]: mismatched types
    --> f101.rs:8:18
     |
8    |     stuff.append(Thing);
     |           ------ ^^^^^ expected `&mut Vec<Thing>`, found `Thing`
     |           |
     |           arguments to this method are incorrect
     |
     = note: expected mutable reference `&mut Vec<Thing>`
                           found struct `Thing`
note: method defined here
    --> /home/gh-estebank/rust/library/alloc/src/vec/mod.rs:2025:12
     |
2025 |     pub fn append(&mut self, other: &mut Self) {
     |            ^^^^^^
help: you might have meant to use `push`
     |
8    |     stuff.push(Thing);
     |           ~~~~
```
2024-02-23 00:42:56 +00:00
Nicholas Nethercote
21bb1a4359 Allow for a missing adt_def in NamePrivacyVisitor.
This was caused by 72b172bdf6 in #121206. That commit removed an early
return from `analysis` when there are stashed errors. As a result, it's
possible to reach privacy analysis when there are stashed errors, which
means more code paths can be reached. One such code path was handled in
that commit, where a `span_bug` was changed to a `span_delayed_bug`.

This commit handles another such code path uncovered by fuzzing, in much
the same way.

Fixes #121455.
2024-02-23 10:57:11 +11:00
Nicholas Nethercote
109321ac47 Revert some span_bugs to span_delayed_bug.
Fixes #121445.
Fixes #121457.
2024-02-23 10:04:32 +11:00