Commit Graph

238029 Commits

Author SHA1 Message Date
bors
fee5518cdd Auto merge of #96979 - SabrinaJewson:waker-update, r=workingjubilee
Override `Waker::clone_from` to avoid cloning `Waker`s unnecessarily

This would be very useful for futures — I think it’s pretty much always what they want to do instead of `*waker = cx.waker().clone()`.

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

r? rust-lang/libs-api `@rustbot` label +T-libs-api -T-libs
2023-11-05 21:44:24 +00:00
bors
c1ccc29cd6 Auto merge of #117191 - Skgland:easy-beta-channels, r=Mark-Simulacrum
generate beta manifests as pre-requisit to rust-lang/rustup#1329

<https://github.com/rust-lang/rustup/issues/1329#issuecomment-1134946736> mentioned (a while ago) this would be the next step
2023-11-05 19:43:04 +00:00
bors
5103173af1 Auto merge of #117179 - Voultapher:fix-useless-comp-in-partition-equal, r=Mark-Simulacrum
Avoid unnecessary comparison in partition_equal

The branchy Hoare partition `partition_equal` as part of `slice::sort_unstable` has a bug that makes it perform a comparison of the last element twice.

Measuring inputs with a Zipfian distribution with characterizing exponent s == 1.0, yields a ~0.05% reduction in the total number of comparisons performed.
2023-11-05 17:41:36 +00:00
bors
6c7de3181b Auto merge of #117574 - onur-ozkan:fix-compiler-crate-linking, r=Mark-Simulacrum
improve compiler&tool documenting and re-enable cranelift on CI

First commit addresses the linking issue with compiler crates. Second one ensures that compiler crates are linked correctly (with later commits we added this check for tools as well), allowing us to detect these hard-to-catch bugs on CI. Following three commits cherry-picked from #117328 to re-enable the Cranelift backend on CI.

More info: https://github.com/rust-lang/rust/issues/117430

cc `@bjorn3` `@RalfJung`
2023-11-05 15:41:35 +00:00
onur-ozkan
b0df8216ed bootstrap: improve linking of tool docs
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-11-05 17:01:53 +03:00
bors
992943dbae Auto merge of #117537 - GKFX:offset-of-enum-feature, r=cjgillot
Feature gate enums in offset_of

As requested at https://github.com/rust-lang/rust/issues/106655#issuecomment-1790815262, put enums in offset_of behind their own feature gate.

`@rustbot` label F-offset_of
2023-11-05 13:44:59 +00:00
bors
04817ff00c Auto merge of #117608 - matthiaskrgr:rollup-g9fagmv, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #116017 (Don't pass `-stdlib=libc++` when building C files on macOS)
 - #117524 (bootstrap/setup: create hooks directory if non-existing)
 - #117588 (Remove unused LoadResult::DecodeIncrCache variant)
 - #117596 (Add diagnostic items for a few of core's builtin macros)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-05 11:47:38 +00:00
Matthias Krüger
a660516334
Rollup merge of #117596 - thomcc:core_macro_diag_items, r=Nilstrieb
Add diagnostic items for a few of core's builtin macros

Specifically, `env`, `option_env`, and `include`. There are a number of reasons why people might want to look at these in lints (For example, to ensure that things behave consistently, detect things that might make builds less reproducible, etc).

Concretely, in PL/Rust (well, `plrustc`) we have lints that forbid these (which I'd like to [add to clippy as restriction lints](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Landing.20a.20flotilla.20of.20lints.3F) eventually), and `dylint` also has [lints that look for `env!`/`option_env!`](109a07e9f2/examples/general/env_cargo_path/src/lib.rs) (although perhaps not `include`), which would benefit from this.

My experience is that it's pretty annoying to (robustly) check uses of builtin macros without these IME, although that's perhaps just my own fault (e.g. I could be doing it wrong).

At `@Nilstrieb's` suggestion, I've added a comment that explains why these are here, even though they are not used in the compiler. This is mostly to discourage removal, although it's not a big deal if it happens (I'm certainly not suggesting the presence of these be in any way stable).

---

In theory this is a library PR (in that it's in library/core), but I'm going to roll compiler because the existence of this or not is much more likely something they care about rather than libs. Hopefully nobody objects to this.

r? compiler
2023-11-05 12:41:48 +01:00
Matthias Krüger
629ee74337
Rollup merge of #117588 - bjorn3:remove_unused_error_variant, r=cjgillot
Remove unused LoadResult::DecodeIncrCache variant
2023-11-05 12:41:47 +01:00
Matthias Krüger
fb30270cdc
Rollup merge of #117524 - unleashed:bootstrap-create-hooks-dir, r=Mark-Simulacrum
bootstrap/setup: create hooks directory if non-existing

When running `./x setup` on a local repository I chose to install a `pre-push` git hook, but this happened:

```shell
Would you like to install the git hook?: [y/N] y
error: could not create hook .git/hooks/pre-push: do you already have the git hook installed?
No such file or directory (os error 2)
thread 'main' panicked at src/core/build_steps/setup.rs:462:9:
install_git_hook_maybe(&config) failed with No such file or directory (os error 2)
```

This was caused because the `.git/hooks` directory did not exist in my local repository. Creating it manually and re-running the command works fine.

This PR tests for the above directory and if it does not exist then it _tries_ to create it before hard linking the pre-push hook - we use `fs::create_dir()` and disregard the result (ie. it could fail if the directory was created in the meantime) and proceed to call `fs::hard_link()` all the same.
2023-11-05 12:41:47 +01:00
Matthias Krüger
db665980e9
Rollup merge of #116017 - Zalathar:darwin-stdlib, r=albertlarsan68
Don't pass `-stdlib=libc++` when building C files on macOS

When using *Command Line Tools for Xcode* version 15.0, clang will warn about `argument unused during compilation: '-stdlib=libc++'` if this flag is present when compiling C files only (i.e. no C++ files).

To avoid this warning, we can add the flag only to CXXFLAGS and not to CFLAGS.

---

[Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap/topic/clang.20warning.3A.20argument.20unused.20during.20compilation.20.28libc.2B.2B.29)
2023-11-05 12:41:46 +01:00
bors
513a48517e Auto merge of #117504 - pcc:android-link-libunwind, r=Mark-Simulacrum
Remove obsolete support for linking unwinder on Android

Linking libgcc is no longer supported (see #103673), so remove the related link attributes and the check in unwind's build.rs. The check was the last remaining significant piece of logic in build.rs, so remove build.rs as well.
2023-11-05 09:50:21 +00:00
bors
8acf40bd54 Auto merge of #117469 - cjgillot:filecheck-mir, r=Mark-Simulacrum
Add FileCheck annotations to a few MIR opt tests

const_debuginfo did not specify which passes were running.
const_prop_miscompile is renamed and moved to const_prop directory.
while_storage was broken.
2023-11-05 07:54:12 +00:00
bors
da1e0d1d75 Auto merge of #116218 - tgross35:const-maybe-uninit-zeroed, r=dtolnay
Stabilize `const_maybe_uninit_zeroed` and `const_mem_zeroed`

Make `MaybeUninit::zeroed` and `mem::zeroed` const stable. Newly stable API:

```rust
// core::mem
pub const unsafe fn zeroed<T>() ->;

impl<T> MaybeUninit<T> {
    pub const fn zeroed() -> MaybeUninit<T>;
}
```

This relies on features based around `const_mut_refs`. Per `@RalfJung,` this should be OK since we do not leak any `&mut` to the user.

For this to be possible, intrinsics `assert_zero_valid` and `assert_mem_uninitialized_valid` were made const stable.

Tracking issue: #91850
Zulip discussion: https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/.60const_mut_refs.60.20dependents

r? libs-api
`@rustbot` label -T-libs +T-libs-api +A-const-eval
cc `@RalfJung`  `@oli-obk` `@rust-lang/wg-const-eval`
2023-11-05 05:56:21 +00:00
bors
f64d028196 Auto merge of #117589 - compiler-errors:global-vars-bug, r=jackh726
Make sure that predicates with unmentioned bound vars are still considered global in the old solver

In the old solver, we consider predicates with late-bound vars to not be "global":
9c8a2694fa/compiler/rustc_trait_selection/src/traits/select/mod.rs (L1840-L1844)

The implementation of `has_late_bound_vars` was modified in #115834 so that we'd properly anonymize binders that had late-bound vars but didn't reference them. This fixed an ICE.

However, this also led to a behavioral change in https://github.com/rust-lang/rust/issues/117056#issuecomment-1775014545 for a couple of crates, which now consider `for<'a> GL33: Shader` (note the binder var that is *not* used in the predicate) to not be "global". This forces associated types to not be normalizable due to the old trait solver being dumb.

This PR distinguishes types which *reference* late-bound vars and binders which *have* late-bound vars. The latter is represented with the new type flag `TypeFlags::HAS_BINDER_VARS`, which is used when we only care about knowing whether binders have vars in their bound var list (even if they're not used, like for binder anonymization).

This should fix (after beta backport) the `luminance-gl` and `luminance-webgl` crates in #117056.

r? types
**(priority is kinda high on a review here given beta becomes stable on November 16.)**
2023-11-05 03:58:09 +00:00
bors
c3ae4707d5 Auto merge of #117581 - nicholasbishop:bishop-update-cb, r=Mark-Simulacrum
Bump compiler_builtins to 0.1.103
2023-11-05 01:59:32 +00:00
bors
f5ca57e153 Auto merge of #117503 - kornelski:hint-try-reserved, r=workingjubilee
Hint optimizer about try-reserved capacity

This is #116568, but limited only to the less-common `try_reserve` functions to reduce bloat in debug binaries from debug info, while still addressing the main use-case #116570
2023-11-05 00:03:41 +00:00
Thom Chiovoloni
65bec86b42
Add diagnostic items for a few of core's builtin macros 2023-11-04 17:00:51 -07:00
bors
4b85902b43 Auto merge of #117590 - matthiaskrgr:rollup-9cqh1q8, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #110340 (Deref docs: expand and remove "smart pointer" qualifier)
 - #116894 (Guarantee that `char` has the same size and alignment as `u32`)
 - #117534 (clarify that the str invariant is a safety, not validity, invariant)
 - #117562 (triagebot no-merges: exclude different case)
 - #117570 (fallback for `construct_generic_bound_failure`)
 - #117583 (Remove `'tcx` lifetime on `PlaceholderConst`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-04 21:15:09 +00:00
Matthias Krüger
8912a2b551
Rollup merge of #117583 - compiler-errors:placeholderconst-lifetime, r=cjgillot
Remove `'tcx` lifetime on `PlaceholderConst`

The `'tcx` lifetime is not needed for anything, so this is a continuation of #117139.
2023-11-04 21:38:30 +01:00
Matthias Krüger
a47c137f3a
Rollup merge of #117570 - bvanjoi:fix-117547, r=cjgillot
fallback for `construct_generic_bound_failure`

Fixes #117547

This case regressed at #115882.

In this context, `generic_param_scope` is produced by `RPITVisitor` and not included by `hir_owner`. Therefore, I've added a fallback to address this.
2023-11-04 21:38:29 +01:00
Matthias Krüger
b9dcbd4886
Rollup merge of #117562 - pitaj:triagebot_no-merges, r=Mark-Simulacrum
triagebot no-merges: exclude different case

"Subtree update" as well

To address [this on zulip](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/can't.20suppress.20merge.20commit.20warning)

cc `@bjorn3`

r? `@mark-simulacrum`
2023-11-04 21:38:29 +01:00
Matthias Krüger
1ee5e12710
Rollup merge of #117534 - RalfJung:str, r=Mark-Simulacrum
clarify that the str invariant is a safety, not validity, invariant

Updates these docs to match https://github.com/rust-lang/reference/pull/792
2023-11-04 21:38:29 +01:00
Matthias Krüger
805a56fc28
Rollup merge of #116894 - joshlf:patch-12, r=RalfJung
Guarantee that `char` has the same size and alignment as `u32`
2023-11-04 21:38:28 +01:00
Matthias Krüger
58645e06d9
Rollup merge of #110340 - jmaargh:jmaargh/deref-docs, r=Mark-Simulacrum
Deref docs: expand and remove "smart pointer" qualifier

**Ready for review**

~~This is an unpolished draft to be sanity-checked~~

Fixes #91004

~~Comments on substance and content of this are welcome. This is deliberately unpolished until ready to review so please try to stay focused on the big-picture.~~

~~Once this has been sanity checked, I will similarly update `DerefMut` and polish for review.~~
2023-11-04 21:38:28 +01:00
Michael Goulet
32294fc0ed Make sure that predicates with unmentioned bound vars are still considered global in the old solver 2023-11-04 20:36:21 +00:00
bjorn3
a3b964b9ea Remove unused LoadResult::DecodeIncrCache variant 2023-11-04 20:16:03 +00:00
George Bateman
00a9ed34b1
De-indent closing bracket
Co-authored-by: Camille Gillot <gillot.camille@gmail.com>
2023-11-04 19:50:21 +00:00
Trevor Gross
5e5f3341e3 Stabilize const_mem_zeroed
Make `core::mem::zeroed` const stable. Newly stable API:

    // core::mem
    pub const unsafe fn zeroed<T>() -> T;

This is stabilized with `const_maybe_uninit_zeroed` since it is a simple
wrapper.

In order to make this possible, intrinsics `assert_zero_valid` was made
const stable under `const_assert_type2`.
`assert_mem_uninitialized_valid` was also made const stable since it is
under the same gate.
2023-11-04 15:27:29 -04:00
Trevor Gross
f6ce646d3f Stabilize const_maybe_uninit_zeroed
Make `MaybeUninit::zeroed` const stable. Newly stable API:

    // core::mem
    impl<T> MaybeUninit<T> {
        pub const fn zeroed() -> MaybeUninit<T>;
    }

Use of `const_mut_refs` should be acceptable since we do not leak the
mutability.

Tracking issue: #91850
2023-11-04 15:27:25 -04:00
bors
a42d94ebb8 Auto merge of #113343 - saethlin:looser-alignment, r=RalfJung
Update the alignment checks to match rust-lang/reference#1387

Previously, we had a special case to not check `Rvalue::AddressOf` in this pass because we weren't quite sure if pointers needed to be aligned in the Place passed to it: https://github.com/rust-lang/rust/pull/112026

Since https://github.com/rust-lang/reference/pull/1387 merged, this PR updates this pass to match. The behavior of the check is nearly unchanged, except we also avoid inserting a check for creating references. Most of the changes in this PR are cleanup and new tests.
2023-11-04 19:17:02 +00:00
jmaargh
7a2f83fa3f Draft fleshed-out deref docs
Re-draft Deref docs

Make general advice more explicit and note the difference between
generic and specific implementations.

Re-draft DerefMut docs in-line with Deref

Fix Deref docs typos

Fix broken links

Clarify advice for specific-over-generic impls

Add comment addressing Issue #73682

x fmt

Copy faillibility warning to DerefMut
2023-11-04 17:47:25 +00:00
Michael Goulet
bcb97ea221 No lifetime on PlaceholderConst 2023-11-04 17:36:44 +00:00
bors
9c8a2694fa Auto merge of #117579 - RalfJung:miri, r=RalfJung
Miri subtree update

r? `@ghost`
2023-11-04 17:21:07 +00:00
Nicholas Bishop
5d3535c616 Bump compiler_builtins to 0.1.103 2023-11-04 13:11:10 -04:00
Ben Kimock
f9bd7dabcf Check alignment of pointers only when read/written through 2023-11-04 13:01:32 -04:00
bors
f81d6f0cb0 Auto merge of #117094 - Nadrieril:warn-lint-on-arm, r=cjgillot
Warn users who set `non_exhaustive_omitted_patterns` lint level on a match arm

Before https://github.com/rust-lang/rust/pull/116734, the recommended usage of the [`non_exhaustive_omitted_patterns` lint](https://github.com/rust-lang/rust/issues/89554) was:
```rust
match Bar::A {
    Bar::A => {},
    #[warn(non_exhaustive_omitted_patterns)]
    _ => {},
}
```
After https://github.com/rust-lang/rust/pull/116734 this no longer makes sense, and recommended usage is now:
```rust
#[warn(non_exhaustive_omitted_patterns)]
match Bar::A {
    Bar::A => {},
    _ => {},
}
```

As you can guess, this silently breaks all uses of the lint that used the previous form. This is a problem in particular because `syn` recommends usage of this lint to its users in the old way. This PR emits a warning when the previous form is used so users can update.

r? `@cjgillot`
2023-11-04 14:33:39 +00:00
bohan
a4768fea35 fallback for construct_generic_bound_failure 2023-11-04 22:15:22 +08:00
bors
2ef639d4fb Auto merge of #3145 - RalfJung:data-race-error, r=RalfJung
give some more help for the unusual data races

Fixes https://github.com/rust-lang/miri/issues/3142
2023-11-04 13:59:54 +00:00
bjorn3
52933e0bd2 Don't disable inline asm usage in compiler-builtins when the cranelift backend is enabled
This was a leftover from when inline asm wasn't universally supported by
the cranelift backend yet. It would cause the optimized inline asm
intrinsics to be avoided for the standard library distributed with
rustup now that we build the cranelift backend by default on nightly for
several tier 1 targets.
2023-11-04 16:49:39 +03:00
Nadrieril
f0e8330879 Suggest to set lint level on whole match 2023-11-04 14:44:00 +01:00
Nadrieril
61d0fc7cf5 Warn when lint level is set on a match arm 2023-11-04 14:44:00 +01:00
Nadrieril
7b19fb88be Add tests 2023-11-04 14:44:00 +01:00
onur-ozkan
55b49455e7 ensure doc directory is not empty
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-11-04 15:46:02 +03:00
Rémy Rakic
451778b551 handle dry runs in dist::CodegenBackend
self.number_of_times_dry_runs_have_caused_issues += 1;
2023-11-04 15:12:00 +03:00
bjorn3
a9913ebed0 Ensure the rustc-codegen-cranelift-preview component is never empty
Either generate it with the actual codegen backend dylib or omit it
entirely when the cranelift backend is disabled for this build.
2023-11-04 15:11:55 +03:00
Rémy Rakic
d82fdb6616 pass CODEGEN_BACKENDS to docker 2023-11-04 15:11:51 +03:00
onur-ozkan
fda009c858 add sanity check for compiler crate docs
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-11-04 15:11:43 +03:00
onur-ozkan
5e2de479fa Ensure compiler crate paths are generated before linking
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-11-04 15:11:19 +03:00
Ralf Jung
0550ba5f77 avoid acronyms when we don't really need them 2023-11-04 12:24:09 +01:00