Commit Graph

227000 Commits

Author SHA1 Message Date
Michael Goulet
a5f8859937
Rollup merge of #112684 - saethlin:ignore-windows-alignment, r=wesleywiser
Disable alignment checks on i686-pc-windows-msvc

r? `@wesleywiser` Because you were in the Zulip discussion of this: https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202023-06-15

cc #112480
2023-06-16 12:53:23 -07:00
Michael Goulet
cef94ecedf
Rollup merge of #112665 - compiler-errors:assumption-takes-clause, r=lcnr
Make assumption functions in new solver take `Binder<'tcx, Clause<'tcx>>`

We just use an if-let to match on an optional clause at all the places where we transition from `Predicate` -> `Clause`, but I assume that when things like item-bounds and param-env start to only store `Clause`s then those can just be trivially dropped.

r? ``@lcnr``
2023-06-16 12:53:23 -07:00
Michael Goulet
38fc6be325
Rollup merge of #112662 - Vanille-N:symbol_unique, r=RalfJung
`#[lang_item]` for `core::ptr::Unique`

Tree Borrows is about to introduce experimental special handling of `core::ptr::Unique` in Miri to give it a semantics.
As of now there does not seem to be a clean way (i.e. other than `&format!("{adt:?}") == "std::ptr::Unique"`) to check if an `AdtDef` represents a `Unique`.

r? `@RalfJung`

Draft: making a lang item
2023-06-16 12:53:22 -07:00
Michael Goulet
3eb8c2ae10
Rollup merge of #112474 - ldm0:ldm_enum_debuginfo_128_support, r=compiler-errors
Support 128-bit enum variant in debuginfo codegen

fixes #111600
2023-06-16 12:53:22 -07:00
Michael Goulet
4d5e7cdc03
Rollup merge of #112226 - devnexen:netbsd_affinity, r=cuviper
std: available_parallelism using native netbsd api first

before falling back to existing code paths like FreeBSD does.
2023-06-16 12:53:21 -07:00
Michael Goulet
c55af41e7a
Rollup merge of #111074 - WaffleLapkin:🌟unsizes_your_buf_reader🌟, r=Amanieu
Relax implicit `T: Sized` bounds on `BufReader<T>`, `BufWriter<T>` and `LineWriter<T>`

TL;DR:
```diff,rust
-pub struct BufReader<R> { /* ... */ }
+pub struct BufReader<R: ?Sized> { /* ... */ }

-pub struct BufWriter<W: Write> { /* ... */ }
+pub struct BufWriter<W: ?Sized + Write> { /* ... */ }

-pub struct LineWriter<W: Write> { /* ... */ }
+pub struct LineWriter<W: ?Sized + Write> { /* ... */ }
```

This allows using `&mut BufReader<dyn Read>`, for example.

**This is an insta-stable change**.
2023-06-16 12:53:21 -07:00
Oli Scherer
79c2c986a2 Pacify tidy 2023-06-16 19:39:48 +00:00
Oli Scherer
f3b7dd6388 Add AliasKind::Weak for type aliases.
Only use it when the type alias contains an opaque type.

Also does wf-checking on such type aliases.
2023-06-16 19:39:48 +00:00
Guillaume Gomez
ea55d25465 Add regression test for #112676 2023-06-16 20:41:00 +02:00
Guillaume Gomez
f4316392a7 Fix invalid handling of "going back in history" when "Directly go to item in search if there is only one result" setting is set to true 2023-06-16 20:38:48 +02:00
bors
6bba061467 Auto merge of #112294 - saethlin:inline-me-maybe, r=oli-obk
Ignore the always part of #[inline(always)] in MIR inlining

`#[inline(always)]` is used in two cases: for functions that are so trivial it is always profitable to inline them, but also for functions which LLVM thinks are a bad inlining candidate, but which actually turn out to be profitable to inline. That second justification doesn't apply to the MIR inliner, so ignoring our cost estimation for these functions is not necessarily the right right thing to do.

This is basically a wash on non-check runs and a perf benefit in check runs. There are some notable regressions, and I think we might be able to claw those back by turning `#[inline(always)]` into a stronger hint. But I think this PR stands decently on its own as a tidy simplification.
2023-06-16 18:21:22 +00:00
Oli Scherer
4fdd07fe88 Merge the orphan logic for all alias kinds 2023-06-16 16:16:41 +00:00
Ben Kimock
c153f3a356 Ignore the always part of #[inline(always)] in MIR inlining 2023-06-16 11:36:02 -04:00
bors
6a94e87a54 Auto merge of #110688 - GuillaumeGomez:result-search-type, r=notriddle,jsha
rustdoc: Add search result item types after their name

Here what it looks like:

![Screenshot from 2023-04-22 15-16-58](https://user-images.githubusercontent.com/3050060/233789566-b5f3f625-3b78-4c56-a7ee-0a4f2d62e667.png)

The idea is to improve accessibility by providing this information directly in the text and not only in the text color. Currently we already use it for doc aliases and for primitive types, so I extended it to all types.

r? `@notriddle`
2023-06-16 15:02:22 +00:00
Wesley Wiser
4ef316f397
Update compiler/rustc_mir_transform/src/check_alignment.rs 2023-06-16 09:55:23 -04:00
Maybe Waffle
73c5c97de7 Add SyntaxContext::is_root 2023-06-16 13:47:42 +00:00
Neven Villani
dc3e91c6c2
#[lang_item] for core::ptr::Unique 2023-06-16 15:22:18 +02:00
Ben Kimock
7a2490eba3 Launch a non-unwinding panic for misaligned pointer deref 2023-06-16 09:20:33 -04:00
Ben Kimock
c54672e25f Disable alignment checks on i686-pc-windows-msvc 2023-06-16 09:06:12 -04:00
bors
2304917aad Auto merge of #112702 - Dylan-DPC:rollup-12d6qay, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #112163 (fix: inline `predicate_may_hold_fatal` and remove expect call in it)
 - #112399 (Instantiate closure synthetic substs in root universe)
 - #112443 (Opportunistically resolve regions in new solver)
 - #112535 (reorder attributes to make miri-test-libstd work again)
 - #112579 (Fix building libstd documentation on FreeBSD.)
 - #112639 (Fix `dead_code_cgu` computation)
 - #112642 (Handle interpolated literal errors)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-16 11:51:43 +00:00
Guillaume Gomez
9f509429cd Unify history interactions in search 2023-06-16 13:43:55 +02:00
Dylan DPC
c2e109744d
Rollup merge of #112642 - compiler-errors:interp-lit-err, r=nnethercote
Handle interpolated literal errors

Not sure why it was doing a whole dance to re-match on the token kind when it seems like `Lit::from_token` does the right thing for both macro-arg and regular literals. Nothing seems to have regressed diagnostics-wise from the change, though.

Fixes #112622

r? ``@nnethercote``
2023-06-16 14:46:17 +05:30
Dylan DPC
2c850691c1
Rollup merge of #112639 - nnethercote:fix-dead_code_cgu, r=wesleywiser
Fix `dead_code_cgu` computation

This PR fixes a bug in `dead_code_cgu` computation, and also does some refactoring.

r? ```@wesleywiser```
2023-06-16 14:46:16 +05:30
Dylan DPC
48b645e0ea
Rollup merge of #112579 - MikaelUrankar:freebsd_docs, r=cuviper
Fix building libstd documentation on FreeBSD.

It fixes the following error:
```
error[E0412]: cannot find type `sockcred2` in module `libc`
   --> library/std/src/os/unix/net/ancillary.rs:211:29
    |
211 | pub struct SocketCred(libc::sockcred2);
    |                             ^^^^^^^^^ not found in `libc`
```
2023-06-16 14:46:16 +05:30
Dylan DPC
627f85cd5a
Rollup merge of #112535 - RalfJung:miri-test-libstd, r=cuviper
reorder attributes to make miri-test-libstd work again

Fixes fallout from https://github.com/rust-lang/rust/pull/110141
2023-06-16 14:46:15 +05:30
Dylan DPC
64f6c00772
Rollup merge of #112443 - compiler-errors:next-solver-opportunistically-resolve-regions, r=lcnr
Opportunistically resolve regions in new solver

Use `opportunistic_resolve_var` during canonicalization to collapse some regions.

We have to start using `CanonicalVarValues::is_identity_modulo_regions`. We also have to modify that function to consider responses like `['static, ^0, '^1, ^2]` to be an "identity" response, since because we opportunistically resolve regions, there's no longer a 1:1 mapping between canonical var values and bound var indices in the response...

There's one nasty side-effect -- one test (`tests/ui/dyn-star/param-env-infer.rs`) starts to ICE because the certainty goes from `Yes` to `Maybe(Overflow)`... Not exactly sure why, though? Putting this up for discussion/investigation.

r? ```@lcnr```
2023-06-16 14:46:15 +05:30
Dylan DPC
b41db841e8
Rollup merge of #112399 - compiler-errors:closure-substs-root-universe, r=lcnr
Instantiate closure synthetic substs in root universe

In the UI test example, we end up generalizing an associated type (something like `<Map<Option<i32>, [closure upvars=?0]> as IntoIterator>::Item` generalizes into `<Map<Option<i32>, [closure upvars=?1]> as IntoIterator>::Item`) then assigning it to itself, emitting an alias-relate goal. This trivially holds via one of the normalizes-to candidates, instead of relating substs, so when closure analysis eventually sets `?0` to the actual upvars, `?1` never gets constrained. This ends up being reported as an ambiguity error during writeback.

Instead, we can take advantage of the fact that we *know* the closure substs live in the root universe. This will prevent them being generalized, since they always can be named, and the alias-relate above never gets emitted at all.

We can probably do this to a handful of other `next_ty_var` calls in typeck for variables that are clearly associated with the body of the program, but I wanted to limit this for now. Eventually, if we end up representing universes more faithfully like a tree or whatever, we can remove this and turn it back to just a call to `next_ty_var`.

Note: This is incredibly order-dependent -- we need to be assigning a type variable that was created *before* the closure substs, and we also need to actually have an unnormalized type at the time of the assignment. This currently seems easiest to trigger during call argument analysis just due to the fact that we instantiate the call's substs, normalize, THEN check args.

r? ```@lcnr```
2023-06-16 14:46:14 +05:30
Dylan DPC
c563296a4f
Rollup merge of #112163 - bvanjoi:fix-105231-2, r=compiler-errors
fix: inline `predicate_may_hold_fatal` and remove expect call in it

- Fixes #105231
- Discussion: https://github.com/rust-lang/rust/pull/111985#discussion_r1208888821

r? ``@compiler-errors``
2023-06-16 14:46:14 +05:30
bors
99b334696f Auto merge of #112597 - danakj:map-linker-paths, r=michaelwoerister
Use the relative sysroot path in the linker command line to specify sysroot rlibs

This addresses https://github.com/rust-lang/rust/issues/112586
2023-06-16 09:02:50 +00:00
bors
0966f3202d Auto merge of #112673 - scottmcm:enough-stack, r=compiler-errors
Add an `ensure_sufficient_stack` to `LateContextAndPass::visit_expr`

This is [apparently](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/.60-alt.60-only.20failures.3F/near/365396801) where it's busting stack in #112238, and the comments for `ensure_sufficient_stack` say that

> E.g. almost any call to visit_expr or equivalent can benefit from this.

So this seems like a reasonable change.

Hopefully it'll keep this from happening in other places too -- https://github.com/rust-lang/rust/pull/111818#issuecomment-1585023914 hit something similar when updating a lint (bors failure is https://github.com/rust-lang-ci/rust/actions/runs/5199591324/jobs/9377196369), so with any luck this will keep small permutations of things from tripping over the limit.
2023-06-16 05:48:08 +00:00
bohan
b7921981d5 fix: inline predicate_may_hold_fatal 2023-06-16 11:09:53 +08:00
bors
c84d5e7078 Auto merge of #112346 - saethlin:no-comment, r=oli-obk
Remove comments from mir-opt MIR dumps

See https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Line.20numbers.20in.20mir-opt.20tests/near/363849874

In https://github.com/rust-lang/rust/pull/99780 there is mention that "there has been a zulip conversation about disabling line numbers with mixed opinions" which to me means that some people opposed this. I can't find the referenced conversation so... here we go.

The current situation is quite chaotic. It's not hard to find MIR diffs which contain

* Absolute line numbers
* Relative line numbers
* Substituted line numbers (LL)
For example: 408bbd0406/tests/mir-opt/inline/inline_shims.drop.Inline.diff (L10-L17)

And sometimes adding a comment at the top of a mir-opt test generates a diff in the test because a line number changed: https://github.com/rust-lang/rust/pull/98112/files#diff-b8cf4bcce95078e6a3faf075e9abf6864872fb28a64d95c04f04513b9e3bbd81

And irrelevant changes to the standard library can generate diffs in mir-opt tests: https://github.com/rust-lang/rust/pull/110694/files#diff-bf96b0e7c67b8b272814536888fd9428c314991e155beae1f0a2a67f0ac47b2c
769886cc35

I think we should, specifically in mir-opt tests, completely remove the comments, or insert placeholders for all line and column numbers.
2023-06-16 01:55:34 +00:00
Josh Stone
886085a4d5 std: only depend on dlmalloc for wasm*-unknown
It was already filtered out for emscripten, but wasi doesn't need dlmalloc
either since it reuses `unix/alloc.rs`.
2023-06-15 15:56:00 -07:00
bors
0252b4093f Auto merge of #112681 - GuillaumeGomez:rollup-rwn4086, r=GuillaumeGomez
Rollup of 8 pull requests

Successful merges:

 - #112403 (Prevent `.eh_frame` from being emitted for `-C panic=abort`)
 - #112517 (`suspicious_double_ref_op`: don't lint on `.borrow()`)
 - #112529 (Extend `unused_must_use` to cover block exprs)
 - #112614 (tweak suggestion for argument-position `impl ?Sized`)
 - #112654 (normalize closure output in equate_inputs_and_outputs)
 - #112660 (Migrate GUI colors test to original CSS color format)
 - #112664 (Add support for test tmpdir to fuchsia test runner)
 - #112669 (Fix comment for ptr alignment checks in codegen)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-15 22:54:43 +00:00
Guillaume Gomez
05d5449522
Rollup merge of #112669 - Nilstrieb:typo, r=jyn514
Fix comment for ptr alignment checks in codegen
2023-06-15 22:04:58 +02:00
Guillaume Gomez
56a5b7e504
Rollup merge of #112664 - djkoloski:fuchsia_test_runner_tmpdir, r=tmandry
Add support for test tmpdir to fuchsia test runner

Also format the script to keep the code nice.

This fixes the `tests/ui/std/switch-stdout.rs` test on Fuchsia.

r? `@tmandry`
2023-06-15 22:04:58 +02:00
Guillaume Gomez
b36ddeedc0
Rollup merge of #112660 - GuillaumeGomez:migrate-gui-test-color-15, r=notriddle
Migrate GUI colors test to original CSS color format

Follow-up of https://github.com/rust-lang/rust/pull/111459.

r? `@notriddle`
2023-06-15 22:04:57 +02:00
Guillaume Gomez
6b9b55ac98
Rollup merge of #112654 - aliemjay:closure-output-normalize, r=compiler-errors
normalize closure output in equate_inputs_and_outputs

Fixes #112604
2023-06-15 22:04:57 +02:00
Guillaume Gomez
af955a647e
Rollup merge of #112614 - lukas-code:apit-unsized-suggestion, r=compiler-errors
tweak suggestion for argument-position `impl ?Sized`

fixes this invalid suggestion:
```text
help: consider removing the `?Sized` bound to make the type parameter `Sized`
  |
1 - fn foo(_: impl ?Sized) {}
1 + fn foo(_: impl ) {}
  |
```
2023-06-15 22:04:56 +02:00
Guillaume Gomez
d233522418
Rollup merge of #112529 - jieyouxu:block-expr-unused-must-use, r=oli-obk
Extend `unused_must_use` to cover block exprs

Given code like

```rust
#[must_use]
fn foo() -> i32 {
    42
}

fn warns() {
    {
        foo();
    }
}

fn does_not_warn() {
    {
        foo()
    };
}

fn main() {
    warns();
    does_not_warn();
}
```

### Before This PR

```
warning: unused return value of `foo` that must be used
 --> test.rs:8:9
  |
8 |         foo();
  |         ^^^^^
  |
  = note: `#[warn(unused_must_use)]` on by default
help: use `let _ = ...` to ignore the resulting value
  |
8 |         let _ = foo();
  |         +++++++

warning: 1 warning emitted
```

### After This PR

```
warning: unused return value of `foo` that must be used
 --> test.rs:8:9
  |
8 |         foo();
  |         ^^^^^
  |
  = note: `#[warn(unused_must_use)]` on by default
help: use `let _ = ...` to ignore the resulting value
  |
8 |         let _ = foo();
  |         +++++++

warning: unused return value of `foo` that must be used
  --> test.rs:14:9
   |
14 |         foo()
   |         ^^^^^
   |
help: use `let _ = ...` to ignore the resulting value
   |
14 |         let _ = foo();
   |         +++++++      +

warning: 2 warnings emitted
```

Fixes #104253.
2023-06-15 22:04:56 +02:00
Guillaume Gomez
db7d8374c1
Rollup merge of #112517 - fee1-dead-contrib:sus-op-no-borrow, r=compiler-errors
`suspicious_double_ref_op`: don't lint on `.borrow()`

closes #112489
2023-06-15 22:04:55 +02:00
Guillaume Gomez
ab314a57fa
Rollup merge of #112403 - nbdd0121:eh_frame, r=Nilstrieb
Prevent `.eh_frame` from being emitted for `-C panic=abort`

Since `CheckAlignment` pass is after the `AbortUnwindingCalls` pass, the `UnwindAction::Terminate` inserted in it has no chance to be converted to `UnwindAction::Unreachable` anymore, causing us to emit landing pads that are not necessary. Although these landing pads can themselves be eliminated by LLVM, `.eh_frame` sections are still generated. This causes trouble for Rust-for-Linux project recently.

This PR changes it to generate `UnwindAction::Terminate` when we opt for `-Cpanic=unwind`, and `UnwindAction::Unreachable` for `-Cpanic=abort`.

`@ojeda`
2023-06-15 22:04:55 +02:00
Ben Kimock
0a1fa411ed Remove comments from mir-opt MIR dumps 2023-06-15 15:19:11 -04:00
bors
114fb86ca0 Auto merge of #112671 - bjorn3:sync_cg_clif-2023-06-15, r=bjorn3
Sync rustc_codegen_cranelift

The main highlights this time are a cranelift update, some x86 vendor intrinsic implementations and preparations for testing cg_clif in CI here.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2023-06-15 19:04:13 +00:00
bjorn3
8a120cc867 Update tidy allowed deps list 2023-06-15 17:56:46 +00:00
bjorn3
82b497286d Merge commit '8830dccd1d4c74f1f69b0d3bd982a3f1fcde5807' into sync_cg_clif-2023-06-15 2023-06-15 17:56:01 +00:00
bjorn3
8830dccd1d Rustup to rustc 1.72.0-nightly (8c74a5d27 2023-06-14) 2023-06-15 17:45:30 +00:00
bjorn3
c1fa3cf6c4 Sync from rust 8c74a5d27c 2023-06-15 17:40:32 +00:00
bjorn3
f2895f3143
Merge pull request #1357 from bjorn3/build_system_rework6
Support testing of cg_clif in rust's CI
2023-06-15 19:37:23 +02:00
Nilstrieb
465e4d9c9c Fix comment for ptr alignment checks in codegen 2023-06-15 19:27:31 +02:00