Commit Graph

246921 Commits

Author SHA1 Message Date
Pavel Grigorenko
613cb3262d
compiler: use addr_of! 2024-02-24 18:53:48 +03:00
Pavel Grigorenko
ff187a92d8
library: use addr_of! 2024-02-24 16:02:17 +03:00
bors
8f359beca4 Auto merge of #119536 - Jules-Bertholet:const-barrier, r=dtolnay
Make `Barrier::new()` const

I guess this was just missed in #97791?

`@rustbot` label T-libs-api -T-libs
2024-02-23 20:54:02 +00:00
bors
2dbd6233cc Auto merge of #121303 - GrigorenkoPV:static_mut_refs, r=oli-obk,RalfJung
Get rid of some `#![allow(static_mut_refs)]`
2024-02-23 18:52:47 +00:00
bors
21033f637e Auto merge of #121514 - matthiaskrgr:rollup-5f0vhv7, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #120742 (mark `min_exhaustive_patterns` as complete)
 - #121470 (Don't ICE on anonymous struct in enum variant)
 - #121492 (coverage: Rename `is_closure` to `is_hole`)
 - #121495 (remove repetitive words)
 - #121498 (Make QNX/NTO specific "timespec capping" public to crate::sys)
 - #121510 (lint-overflowing-ops: unify cases and remove redundancy)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-23 16:26:49 +00: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
2e8177a208
Rollup merge of #121498 - flba-eb:make_timespec_capping_public, r=Nilstrieb
Make QNX/NTO specific "timespec capping" public to crate::sys

It is used in:

- `library/std/src/sys/locks/condvar/pthread.rs`
- `library/std/src/sys/pal/unix/thread_parking/pthread.rs`

This is probably required due to introduction of `sys/pal` and #121177

`@rustbot` label +O-neutrino
CC: `@jonathanpallant` `@japaric` `@gh-tr`
2024-02-23 17:02:05 +01:00
Matthias Krüger
15b77953d7
Rollup merge of #121495 - cuishuang:master, r=clubby789
remove repetitive words
2024-02-23 17:02:05 +01:00
Matthias Krüger
13b9bf5024
Rollup merge of #121492 - Zalathar:hole, r=fmease
coverage: Rename `is_closure` to `is_hole`

Extracted from #121433, since I was having second thoughts about some of the other changes bundled in that PR, but these changes are still fine.

---

When refining covspans, we don't specifically care which ones represent closures; we just want to know which ones represent "holes" that should be carved out of other spans and then discarded.

(Closures are currently the only source of hole spans, but in the future we might want to also create hole spans for nested items and inactive `#[cfg(..)]` regions.)

``@rustbot`` label +A-code-coverage
2024-02-23 17:02:04 +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
Pavel Grigorenko
58c8c0853f
Get rid of some #[allow(static_mut_refs)] 2024-02-23 18:02:25 +03:00
Ralf Jung
9a2d550050 lint-overflowing-ops: unify cases and remove redundancy 2024-02-23 15:29:33 +01:00
bors
b6a23b8537 Auto merge of #121454 - reitermarkus:generic-nonzero-library, r=dtolnay
Use generic `NonZero` everywhere in `library`.

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

Use generic `NonZero` everywhere (except stable examples).

r? `@dtolnay`
2024-02-23 14:27:33 +00:00
clubby789
35a9e73521 Don't ICE on anonymous struct in enum variant 2024-02-23 12:25:23 +00:00
bors
52cea084bd Auto merge of #121491 - matthiaskrgr:rollup-wkzqawy, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #121434 (Fix #121208 fallout)
 - #121471 (When encountering `<&T as Clone>::clone(x)` because `T: Clone`, suggest `#[derive(Clone)]`)
 - #121476 (remove `llvm.assertions=true` in compiler profile)
 - #121479 (fix generalizer unsoundness)
 - #121480 (Fix more #121208 fallout)
 - #121482 (Allow for a missing `adt_def` in `NamePrivacyVisitor`.)
 - #121484 (coverage: Use variable name `this` in `CoverageGraph::from_mir`)
 - #121487 (Explicitly call `emit_stashed_diagnostics`.)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-23 12:12:49 +00:00
Florian Bartels
4f66783240 Make timespec capping public to crate::sys
It is used in:

- `library/std/src/sys/locks/condvar/pthread.rs`
- `library/std/src/sys/pal/unix/thread_parking/pthread.rs`
2024-02-23 11:43:27 +01:00
cui fliter
824d75c22e remove repetitive words
Signed-off-by: cui fliter <imcusg@gmail.com>
2024-02-23 18:26:01 +08:00
bors
ea2cc4368e Auto merge of #121442 - lcnr:region-var-universe-uwu, r=compiler-errors
region unification: update universe of region vars

necessary for #119106. see inline comment for why this is necessary

r? `@compiler-errors` `@BoxyUwU`
2024-02-23 10:13:35 +00:00
Zalathar
44c8f55a6b coverage: Rename is_closure to is_hole
When refining covspans, we don't specifically care which ones represent
closures; we just want to know which ones represent "holes" that should be
carved out of other spans and then discarded.

(Closures are currently the only source of hole spans, but in the future we
might want to also create hole spans for nested items and inactive `#[cfg(..)]`
regions.)
2024-02-23 19:56:00 +11:00
Zalathar
8bd33e332b coverage: Remove some lingering references to pending_dups 2024-02-23 19:51:23 +11:00
Matthias Krüger
6ee43bc7de
Rollup merge of #121487 - nnethercote:fix-121450, r=oli-obk
Explicitly call `emit_stashed_diagnostics`.

Commit 72b172b in #121206 changed things so that
`emit_stashed_diagnostics` is only called from `run_compiler`. But rustfmt doesn't use `run_compiler`, so it needs to call `emit_stashed_diagnostics` itself to avoid an abort in `DiagCtxtInner::drop` when stashed diagnostics occur.

Fixes #121450.

r? `@oli-obk`
2024-02-23 09:42:14 +01:00
Matthias Krüger
3f693a1320
Rollup merge of #121484 - Zalathar:this, r=oli-obk
coverage: Use variable name `this` in `CoverageGraph::from_mir`

A tiny little improvement, extracted from #120013.

This makes it easier to see that we're manipulating the instance that is being constructed, and is a lot less verbose than `basic_coverage_blocks`.
2024-02-23 09:42:13 +01: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
7ae95b266e
Rollup merge of #121479 - lcnr:fix-generalize, r=compiler-errors
fix generalizer unsoundness

I ended up getting confused while trying to flip the variances when flipping the order. Should be all right now.

This is only exploitable when generalizing if the `ambient_variance` of the relation is `Contravariant`. This can currently only be the case in the NLL generalizer which only rarely generalizes, causing us to miss this regression. Very much an issue with #121462 however.
2024-02-23 09:42:12 +01:00
Matthias Krüger
977bbb4d50
Rollup merge of #121476 - onur-ozkan:update-compiler-profile, r=compiler-errors
remove `llvm.assertions=true` in compiler profile

Having this set to true disrupts compiler development workflows for people who use `llvm.download-ci-llvm = true` because we don't provide ci-llvm on the `rustc-alt-builds` server. Therefore, it is kept off by default.

cc `@Nilstrieb` `@compiler-errors`

For more context, see https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/CI.20LLVM.20for.20aarch64
2024-02-23 09:42:11 +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
6dadb6eb23 Auto merge of #121448 - klensy:bump-22-02-24, r=clubby789
bump few deps

Bumps `sysinfo`, `tabled`; dedupes `env_logger`; drops `is-terminal`
https://github.com/zhiburt/tabled/blob/v0.15.1/CHANGELOG.md
https://github.com/GuillaumeGomez/sysinfo/blob/v0.30.5/CHANGELOG.md
2024-02-23 07:42:50 +00: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
Nicholas Nethercote
41da3d6f2f Explicitly call emit_stashed_diagnostics.
Commit 72b172b in #121206 changed things so that
`emit_stashed_diagnostics` is only called from `run_compiler`. But
rustfmt doesn't use `run_compiler`, so it needs to call
`emit_stashed_diagnostics` itself to avoid an abort in
`DiagCtxtInner::drop` when stashed diagnostics occur.

Fixes #121450.
2024-02-23 16:09:51 +11:00
bors
71ff1c6246 Auto merge of #121341 - GrigorenkoPV:bootstrap-rustup-cargo, r=onur-ozkan
bootstrap: don't resolve symlinks for initial_cargo

I have put the following in my `config.toml`:

```toml
# Includes one of the default files in src/bootstrap/defaults
profile = "compiler"
change-id = 121203

[build]
cargo = "/usr/bin/cargo"
rustc = "/usr/bin/rustc"
rustfmt = "/usr/bin/rustfmt"
```

I have rustup installed from Arch's repos, which has all of the above paths be symlinks to `/usr/bin/rustup`. This works just fine with the `argv[0]` trick that rustup uses.

However, `bootstrap` resolves symlinks to check whether `cargo` exists and then uses the resolved path, so it ends up calling `rustup` directly expecting it to behave like `cargo`. Which it doesn't.

This PR removes the canonicalization step, in turn fixing the issue, but sacrificing a pretty error message. However, this exact thing is checked by `x.py` in advance, so I hope it is not a big deal?
2024-02-23 03:44:47 +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
Zalathar
9137c1e01e coverage: Use variable name this in CoverageGraph::from_mir
This makes it easier to see that we're manipulating the instance that is being
constructed, and is a lot less verbose than `basic_coverage_blocks`.
2024-02-23 11:42:28 +11:00
Nicholas Nethercote
938e594d62 Remove an unnecessary if let. 2024-02-23 11:12:04 +11: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
lcnr
dabacb7431 fix CI 2024-02-22 23:10:46 +01:00
Nicholas Nethercote
4f83e50f98 Revert some span_bugs to span_delayed_bug.
Fixes #121410.
Fixes #121414.
Fixes #121418.
Fixes #121431.
2024-02-23 08:35:18 +11:00
lcnr
fa2921bdca woops, soundly generalizing is hard
I ended up getting confused while trying to flip the
variances when flipping the order. Should be
all right now
2024-02-22 22:24:12 +01:00
bors
397937d812 Auto merge of #119989 - lcnr:sub_relations-bye-bye, r=compiler-errors
remove `sub_relations` from the `InferCtxt`

While doing so, I tried to remove the `delay_span_bug` in `rematch_impl` again, which lead me to discover another `freshen` bug, fixing that one in the second commit. See commit descriptions for the reasoning behind each change.

r? `@compiler-errors`
2024-02-22 20:45:24 +00:00
onur-ozkan
52227edfaf set llvm.assertions to false in compiler profile
Having this set to true disrupts compiler development workflows for people who use `llvm.download-ci-llvm = true`
because we don't provide ci-llvm on the `rustc-alt-builds` server. Therefore, it is kept off by default.

Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-02-22 22:15:05 +03:00
bors
d9ae43c787 Auto merge of #121469 - matthiaskrgr:rollup-oaoxuo2, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #120598 (No need to `validate_alias_bound_self_from_param_env` in `assemble_alias_bound_candidates`)
 - #121386 (test that we do not support higher-ranked regions in opaque type inference)
 - #121393 (match lowering: Introduce a `TestCase` enum to replace most matching on `PatKind`)
 - #121401 (Fix typo in serialized.rs)
 - #121427 (Fix panic when compiling `Rocket`.)
 - #121439 (Fix typo in metadata.rs doc comment)
 - #121441 (`DefId`  to `LocalDefId`)
 - #121452 (Add new maintainers to nto-qnx.md)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-22 18:39:34 +00:00
Esteban Küber
91d0b371ef Fix rebase 2024-02-22 18:38:10 +00:00
Esteban Küber
d67dcf5a8b review comment: remove unnused return value 2024-02-22 18:05:28 +00:00
Esteban Küber
fdaaaa1951 fix test 2024-02-22 18:05:28 +00:00
Esteban Küber
28c028737d Deduplicate some logic and reword output 2024-02-22 18:05:28 +00:00
Esteban Küber
b59bd7fd16 review comments: clean up 2024-02-22 18:05:28 +00:00
Esteban Küber
f566867ace Add flatmap/flat_map -> and_then suggestions 2024-02-22 18:05:28 +00:00