Commit Graph

271489 Commits

Author SHA1 Message Date
许杰友 Jieyou Xu (Joe)
f860f5bf90
Rollup merge of #131505 - madsmtm:darwin_user_temp_dir, r=dtolnay
use `confstr(_CS_DARWIN_USER_TEMP_DIR, ...)` as a `TMPDIR` fallback on Darwin

Rebased version of https://github.com/rust-lang/rust/pull/100824, FCP has completed there. Motivation from https://github.com/rust-lang/rust/pull/100824#issuecomment-1262264127:

> This is a behavioral change in an edge case on Darwin platforms (macOS, iOS, ...).
>
> Specifically, this changes it so that iff `TMPDIR` is unset in the environment, then we use `confstr(_CS_DARWIN_USER_TEMP_DIR, ...)` to query the user temporary directory (previously we just returned `"/tmp"`). If this fails (probably possible in a sandboxed program), only then do we fallback to `"/tmp"` (as before).
>
> The motivations here are two-fold:
>
> 1. This is better for security, and is in line with the [platform security recommendations](https://developer.apple.com/library/archive/documentation/Security/Conceptual/SecureCodingGuide/Articles/RaceConditions.html#//apple_ref/doc/uid/TP40002585-SW10), as it is unavailable to other users (although it is the same value as seen by all other processes run by the same user).
> 2. This is a more consistent fallback for when `getenv("TMPDIR")` is unavailable, as `$TMPDIR` is usually initialized to the `DARWIN_USER_TEMP_DIR`.
>
> It seems quite unlikely that anybody will break because of this, and I think it falls under the carve-out we have for platform specific behavior: https://doc.rust-lang.org/nightly/std/io/index.html#platform-specific-behavior.

Closes https://github.com/rust-lang/rust/issues/99608.
Closes https://github.com/rust-lang/rust/pull/100824.

``@rustbot`` label O-apple T-libs-api

r? Dylan-DPC
2024-11-23 20:19:52 +08:00
许杰友 Jieyou Xu (Joe)
c6d36256a6
Rollup merge of #127483 - BertalanD:no_sanitize-global-var, r=rcvalle
Allow disabling ASan instrumentation for globals

AddressSanitizer adds instrumentation to global variables unless the [`no_sanitize_address`](https://llvm.org/docs/LangRef.html#global-attributes) attribute is set on them.

This commit extends the existing `#[no_sanitize(address)]` attribute to set this; previously it only had the desired effect on functions.

(cc https://github.com/rust-lang/rust/issues/39699)
2024-11-23 20:19:51 +08:00
bors
ff1737bb00 Auto merge of #132994 - clubby789:cc-bisect, r=Kobzol
Update `cc` + bump bootstrap deps

https://github.com/rust-lang/rust/pull/132556#issuecomment-2471741435

note: The compiler/library/tools cc bumps have been tested with a try job, the bootstrap changes have not
2024-11-23 12:15:39 +00:00
Ralf Jung
d7303194b9 show abi_unsupported_vector_types lint in future breakage reports 2024-11-23 09:15:25 +01:00
bors
6e1c11591f Auto merge of #132915 - veluca93:unsafe-fields, r=jswrenn
Implement the unsafe-fields RFC.

RFC: rust-lang/rfcs#3458

Tracking:

- https://github.com/rust-lang/rust/issues/132922

r? jswrenn
2024-11-23 07:47:52 +00:00
Ralf Jung
bd00de7123 remove is_trivially_const_drop 2024-11-23 08:41:06 +01:00
Michael Goulet
d294e4746b Remove unnecessary bool from ExpectedFound 2024-11-23 04:51:31 +00:00
bors
c49a687d63 Auto merge of #133360 - compiler-errors:rollup-a2o38tq, r=compiler-errors
Rollup of 8 pull requests

Successful merges:

 - #132090 (Stop being so bail-y in candidate assembly)
 - #132658 (Detect const in pattern with typo)
 - #132911 (Pretty print async fn sugar in opaques and trait bounds)
 - #133102 (aarch64 softfloat target: always pass floats in int registers)
 - #133159 (Don't allow `-Zunstable-options` to take a value )
 - #133208 (generate-copyright: Now generates a library file too.)
 - #133215 (Fix missing submodule in `./x vendor`)
 - #133264 (implement OsString::truncate)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-23 04:44:26 +00:00
Michael Goulet
7b3e593fb1
Rollup merge of #133264 - lolbinarycat:os-string-truncate, r=joboet
implement OsString::truncate

part of #133262
2024-11-22 21:07:41 -05:00
Michael Goulet
469a219c8f
Rollup merge of #133215 - ehuss:fix-vendor-rustc-perf, r=kobzol
Fix missing submodule in `./x vendor`

The `src/tools/rustc-perf` submodule is needed for vendoring because it is included in the vendor set.

To test this:

1. Get a fresh clone of `rust-lang/rust`
2. `./x vendor`
2024-11-22 21:07:41 -05:00
Michael Goulet
ef433a3d4e
Rollup merge of #133208 - ferrocene:split-copyright-html, r=Kobzol
generate-copyright: Now generates a library file too.

We only run reuse once, so the output has to be filtered to find only the files that are relevant to the library tree.

Outputs COPYRIGHT.html and COPYRIGHT-library.html.

The license-metadata.json file is also now in the tree. We need a CI tool to check that it's correct.

r? kobzol

Remaining steps:

* [ ] Teach CI to double-check the license-metadata.json file is correct
* [ ] Add the COPYRIGHT.html and COPYRIGHT-license.html to the releases
2024-11-22 21:07:40 -05:00
Michael Goulet
bb92131dab
Rollup merge of #133159 - Zalathar:unstable-options-no-value, r=jieyouxu
Don't allow `-Zunstable-options` to take a value

Passing an explicit boolean value (`-Zunstable-options=on`, `off` etc.) sometimes appears to work, but actually puts the compiler into an unintended state where unstable _options_ are still forbidden, but unstable values of _some_ stable options are allowed.

This is a result of `-Zunstable-options` being checked in multiple different places, in slightly different ways. Fixing the checks in `config::nightly_options` to understand boolean values would be non-trivial, so for now it's easier to make things consistent by forbidding values in the `-Z` parser.

---

There were a few uses of this in tests, which happened to work because they were tests of unstable values.
2024-11-22 21:07:40 -05:00
Michael Goulet
7b40a9b7c6
Rollup merge of #133102 - RalfJung:aarch64-softfloat, r=davidtwco,wesleywiser
aarch64 softfloat target: always pass floats in int registers

This is a part of https://github.com/rust-lang/rust/issues/131058: on softfloat aarch64 targets, the float registers may be unavailable. And yet, LLVM will happily use them to pass float types if the corresponding target features are enabled. That's a problem as it means enabling/disabling `neon` instructions can change the ABI.

Other targets have a `soft-float` target feature that forces the use of the soft-float ABI no matter whether float registers are enabled or not; aarch64 has nothing like that.

So we follow the aarch64 [softfloat ABI](https://github.com/rust-lang/rust/issues/131058#issuecomment-2385027423) and treat floats like integers for `extern "C"` functions. For the "Rust" ABI, we do the same for scalars, and then just do something reasonable for ScalarPair that avoids the pointer indirection.

Cc ```@workingjubilee```
2024-11-22 21:07:39 -05:00
Michael Goulet
2a94e1c2e0
Rollup merge of #132911 - compiler-errors:async-fn-sugar, r=fmease
Pretty print async fn sugar in opaques and trait bounds

sudo r? fmease
2024-11-22 21:07:39 -05:00
Michael Goulet
d2fb8b5feb
Rollup merge of #132658 - estebank:const-in-pattern-typo, r=Nadrieril
Detect const in pattern with typo

When writing a constant name incorrectly in a pattern, the pattern will be identified as a new binding. We look for consts in the current crate, consts that where imported in the current crate and for local `let` bindings in case someone got them confused with `const`s.

```
error: unreachable pattern
  --> $DIR/const-with-typo-in-pattern-binding.rs:30:9
   |
LL |         GOOOD => {}
   |         ----- matches any value
LL |
LL |         _ => {}
   |         ^ no value can reach this
   |
help: you might have meant to pattern match against the value of similarly named constant `GOOD` instead of introducing a new catch-all binding
   |
LL |         GOOD => {}
   |         ~~~~
```

Fix #132582.
2024-11-22 21:07:38 -05:00
Michael Goulet
5a0086f351
Rollup merge of #132090 - compiler-errors:baily, r=lcnr
Stop being so bail-y in candidate assembly

A conceptual follow-up to #132084. We gotta stop bailing so much when there are errors; it's both unnecessary, leads to weird knock-on errors, and it's messing up the vibes lol
2024-11-22 21:07:38 -05:00
Connor Horman
8578ccc7ad
Remove #[cfg(test)] related stubs 2024-11-22 21:07:02 -05:00
bors
743003b1a6 Auto merge of #132329 - compiler-errors:fn-and-destruct, r=lcnr
Implement `~const Destruct` effect goal in the new solver

This also fixed a subtle bug/limitation of the `NeedsConstDrop` check. Specifically, the "`Qualif`" API basically treats const drops as totally structural, even though dropping something that has an explicit `Drop` implementation cannot be structurally decomposed. For example:

```rust
#![feature(const_trait_impl)]

#[const_trait] trait Foo {
    fn foo();
}

struct Conditional<T: Foo>(T);

impl Foo for () {
    fn foo() {
        println!("uh oh");
    }
}

impl<T> const Drop for Conditional<T> where T: ~const Foo {
    fn drop(&mut self) {
        T::foo();
    }
}

const FOO: () = {
    let _ = Conditional(());
    //~^ This should error.
};

fn main() {}
```

In this example, when checking if the `Conditional(())` rvalue is const-drop, since `Conditional` has a const destructor, we would previously recurse into the `()` value and determine it has nothing to drop, which means that it is considered to *not* need a const drop -- even though dropping `Conditional(())` would mean evaluating the destructor which relies on that `T: const Foo` bound to hold!

This could be fixed alternatively by banning any const conditions on `const Drop` impls, but that really sucks -- that means that basically no *interesting* const drop impls could be written. We have the capability to totally and intuitively support the right behavior, which I've implemented here.
2024-11-23 02:03:50 +00:00
Connor Horman
3d67fd4cf4
Add language tests for aggregate types 2024-11-22 19:32:02 -05:00
Asger Hautop Drewsen
5caf516cd0 rustc: Fail fast when compiling a source file larger than 4 GiB - 1 B
Fixes #132862
2024-11-23 00:25:03 +01:00
bors
f5be3ca1e3 Auto merge of #133349 - ehuss:stabilize-2024, r=traviscross,compiler-errors
Stabilize the 2024 edition

This stabilizes the 2024 edition for Rust 1.85, scheduled to be released on February 20, 2025. 🎉

cc tracking issue: https://github.com/rust-lang/rust/issues/117258

There is a fair amount of follow-up work after this that I am working on (various docs, cargo, rustfmt, etc.), and this is will unblock those other changes.
2024-11-22 21:17:35 +00:00
Guillaume Gomez
67bdc9b337 Add code example for wrapping_neg method for signed integers 2024-11-22 22:01:09 +01:00
Eric Huss
31c9222639 Stabilize the 2024 edition 2024-11-22 11:12:15 -08:00
Michael Goulet
69a38de977 Check drop is trivial before checking ty needs drop 2024-11-22 17:01:02 +00:00
Michael Goulet
4c53ad5f24 Pretty print AsyncFn traits too 2024-11-22 16:55:28 +00:00
Michael Goulet
af0d566e76 Deduplicate checking drop terminator 2024-11-22 16:54:41 +00:00
Michael Goulet
2088260852 Gate const drop behind const_destruct feature, and fix const_precise_live_drops post-drop-elaboration check 2024-11-22 16:54:40 +00:00
Michael Goulet
b75c1c3dd6 More comments, reverse polarity of structural check 2024-11-22 16:54:40 +00:00
Michael Goulet
59408add4d Implement ~const Destruct in new solver 2024-11-22 16:54:40 +00:00
clubby789
4627db2a10 Diagnostic for using macro_rules macro as attr/derive 2024-11-22 16:49:10 +00:00
Michael Goulet
7540306a49 Simplify logic a bit 2024-11-22 16:41:29 +00:00
bors
a47555110c Auto merge of #133339 - jieyouxu:rollup-gav0nvr, r=jieyouxu
Rollup of 8 pull requests

Successful merges:

 - #133238 (re-export `is_loongarch_feature_detected`)
 - #133288 (Support `each_ref` and `each_mut` in `[T; N]` in constant expressions.)
 - #133311 (Miri subtree update)
 - #133313 (Use arc4random of libc for RTEMS target)
 - #133319 (Simplify `fulfill_implication`)
 - #133323 (Bail in effects in old solver if self ty is ty var)
 - #133330 (library: update comment around close())
 - #133337 (Fix typo in `std:🧵:Scope::spawn` documentation.)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-22 16:27:07 +00:00
bors
a7d9ebdf08 Auto merge of #133338 - BoxyUwU:bump_1_85, r=BoxyUwU
Bump to 1.85

https://forge.rust-lang.org/release/process.html#bump-the-stable-version-number-friday-the-week-before
2024-11-22 13:35:21 +00:00
许杰友 Jieyou Xu (Joe)
874cf85674
Rollup merge of #133337 - ColinFinck:thread-scoped-fix-typo, r=joboet
Fix typo in `std:🧵:Scope::spawn` documentation.

Just a simple fix for a typo that caught my attention.
2024-11-22 20:32:38 +08:00
许杰友 Jieyou Xu (Joe)
bbc4cbe3e2
Rollup merge of #133330 - RalfJung:close, r=the8472
library: update comment around close()

r? `@the8472`
2024-11-22 20:32:38 +08:00
许杰友 Jieyou Xu (Joe)
74b8522855
Rollup merge of #133323 - compiler-errors:bail-if-self-var, r=lcnr
Bail in effects in old solver if self ty is ty var

Otherwise when we try to check something like `?t: ~const Trait` we'll immediately stick it to the first param-env candidate, lol.

r? lcnr
2024-11-22 20:32:37 +08:00
许杰友 Jieyou Xu (Joe)
8fdba31f8b
Rollup merge of #133319 - compiler-errors:simpler-fulfill, r=lcnr
Simplify `fulfill_implication`

calm before the storm
2024-11-22 20:32:36 +08:00
许杰友 Jieyou Xu (Joe)
b8453c9023
Rollup merge of #133313 - thesummer:fix-arc4random, r=cuviper
Use arc4random of libc for RTEMS target

Switch to the `arc4random` from libc. It is available since libc 0.2.162
2024-11-22 20:32:36 +08:00
许杰友 Jieyou Xu (Joe)
71440da2b3
Rollup merge of #133311 - RalfJung:miri-sync, r=RalfJung
Miri subtree update

r? `@ghost`
2024-11-22 20:32:35 +08:00
许杰友 Jieyou Xu (Joe)
2e93a759a3
Rollup merge of #133288 - bjoernager:const-array-each-ref, r=jhpratt
Support `each_ref` and `each_mut` in `[T; N]` in constant expressions.

Tracking issue: #133289

The methods `<[T; N]>::each_ref` and `<[T; N]>::each_mut` can easily be reimplemented to allow marking them with the `const` specifier.

This specific implementation takes a different approach than the original as to avoid using iterators (which are illegal in constant expressions).
2024-11-22 20:32:35 +08:00
许杰友 Jieyou Xu (Joe)
9eb67bb25c
Rollup merge of #133238 - heiher:loong-stdarch-rexport, r=Amanieu
re-export `is_loongarch_feature_detected`

r? ``@Amanieu``
2024-11-22 20:32:34 +08:00
Boxy
1355304a69 Bump to 1.85 2024-11-22 11:08:33 +00:00
bors
f1e0752404 Auto merge of #130867 - michirakara:steps_between, r=dtolnay
distinguish overflow and unimplemented in Step::steps_between
2024-11-22 10:54:22 +00:00
Colin Finck
d0384f3ba5
Fix typo in std:🧵:Scope::spawn documentation. 2024-11-22 11:51:38 +01:00
Jonathan Pallant
2932833414
generate-copyright: Fixup comment for get_metadata_and_notices. 2024-11-22 10:14:40 +00:00
Gabriel Bjørnager Jensen
c85a742cb1 Mark '<[T; N]>::as_mut_slice' as 'const'; 2024-11-22 09:49:30 +01:00
Ralf Jung
729d3aa0fe library: update comment around close() 2024-11-22 08:43:51 +01:00
Mads Marquart
f98d9dd334 Don't try to use confstr in Miri 2024-11-22 07:59:51 +01:00
bors
2cf7908998 Auto merge of #129238 - umgefahren:stabilize-ipv6-unique-local, r=dtolnay
Stabilize `Ipv6Addr::is_unique_local` and `Ipv6Addr::is_unicast_link_local`

Make `Ipv6Addr::is_unique_local` and `Ipv6Addr::is_unicast_link_local` stable (+const).

Newly stable API:

```rust
impl Ipv6Addr {
	// Newly stable under `ipv6_is_unique_local`
	const fn is_unique_local(&self) -> bool;

	// Newly stable under `ipv6_is_unique_local`
	const fn is_unicast_link_local(&self) -> bool;
}
```

These stabilise a subset of the following tracking issue:
- #27709

I have looked and could not find any issues with `is_unique_local` and `is_unicast_link_local`. There is a well received comment calling for stabilisation of the latter function.

Both functions are well defined and consistent with implementations in other languages:
- [Go](https://cs.opensource.google/go/go/+/refs/tags/go1.23.0:src/net/netip/netip.go;l=518)
- [Python](e9d1bf353c/Lib/ipaddress.py (L2319-L2321))
- [Ruby (unique local)](https://ruby-doc.org/stdlib-2.5.1/libdoc/ipaddr/rdoc/IPAddr.html#private-3F-source)
- [Ruby (unicast link local)](https://ruby-doc.org/stdlib-2.5.1/libdoc/ipaddr/rdoc/IPAddr.html#link_local-3F-source)

cc implementor `@little-dude`
(I can't find the original PR for `is_unqiue_local`)

r? libs-api
`@rustbot` label +T-libs-api +needs-fcp
2024-11-22 06:38:39 +00:00
Michael Goulet
8dfed4ec98 Bail in effects in old solver if self ty is ty var 2024-11-22 03:12:50 +00:00