Commit Graph

41424 Commits

Author SHA1 Message Date
许杰友 Jieyou Xu (Joe)
c50e19b69c
Rollup merge of #133384 - RalfJung:vector-abi-check-tests, r=jieyouxu
add a test for target-feature-ABI warnings in closures and when calling extern fn

Also update the comment regarding the inheritance of target features into closures, to make it more clear that we really shouldn't do this right now.
2024-11-25 00:39:06 +08:00
许杰友 Jieyou Xu (Joe)
8d20d71256
Rollup merge of #133297 - DianQK:embed-bitcode-ios, r=nikic
Remove legacy bitcode for iOS

Follow #117364.
2024-11-25 00:39:05 +08:00
许杰友 Jieyou Xu (Joe)
6b07382b59
Rollup merge of #133105 - bvanjoi:issue-132743, r=petrochenkov
only store valid proc macro item for doc link

Fixes #132743

The definition item can be detected if it is exported in the doc, so store these items rather than skipping.

r? `@petrochenkov`
2024-11-25 00:39:04 +08:00
bors
f5d1857685 Auto merge of #133415 - matthiaskrgr:rollup-n1ivyd5, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #133300 (inject_panic_runtime(): Avoid double negation for 'any non rlib')
 - #133301 (Add code example for `wrapping_neg` method for signed integers)
 - #133371 (remove is_trivially_const_drop)
 - #133389 (Stabilize `const_float_methods`)
 - #133398 (rustdoc: do not call to_string, it's already impl Display)
 - #133405 (tidy: Distinguish between two different meanings of "style file")

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-24 10:21:07 +00:00
Matthias Krüger
5d1c99275d
Rollup merge of #133371 - RalfJung:is_trivially_const_drop, r=compiler-errors
remove is_trivially_const_drop

I'm not sure this still brings any perf benefits, so let's benchmark this.

r? `@compiler-errors`
2024-11-24 11:08:19 +01:00
Matthias Krüger
4ad97f2a9a
Rollup merge of #133300 - Enselic:build-std-instrument-coverage, r=jieyouxu
inject_panic_runtime(): Avoid double negation for 'any non rlib'

<details>

<summary>This PR originally did more things .Click to expand to see.</summary>

By not trying to inject a profiler runtime when only building an rlib. This logic already exists for the panic runtime.

This makes

    RUSTFLAGS="-Cinstrument-coverage" cargo build -Zbuild-std=std,profiler_builtins

work. Note that you probably also need
`RUST_COMPILER_RT_FOR_PROFILER=$src/llvm-project/compiler-rt` in your environment.

cc #79401

# Demonstration

Before this fix you get these errors:

```console
$ rm -rf target ; RUST_COMPILER_RT_FOR_PROFILER=/home/martin/src/llvm-project/compiler-rt RUSTFLAGS="-Cinstrument-coverage" cargo +nightly build --release -Zbuild-std=std,profiler_builtins
error: `profiler_builtins` crate (required by compiler options) is not compatible with crate attribute `#![no_core]`
error[E0152]: found duplicate lang item `manually_drop`
    = note: first definition in `core` loaded from /home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-d453bab70303062c.rlib
    = note: second definition in the local crate (`core`)
```

With the fix the build succeeds:

```console
$ rm -rf target ; RUST_COMPILER_RT_FOR_PROFILER=/home/martin/src/llvm-project/compiler-rt RUSTFLAGS="-Cinstrument-coverage" cargo +stage1 build --release -Zbuild-std=std,profiler_builtins
    Finished `release` profile [optimized] target(s) in 45.57s
```

And we can check code coverage. My example program looks like this:

```rs
fn main() {
    if std::env::args_os().nth(1) == Some("write-file".into()) {
        std::fs::write("hello.txt", "Hello, world!").unwrap();
    } else {
        println!("Hello, world!");
    }
}
```

when the program prints to stdout:

```
$ LLVM_PROFILE_FILE=stdout.profraw ./target/release/hello-world
Hello, world!
```

we can see that `fs::write()` is not being used (note the `0`'s):

```console
$ /home/martin/src/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-profdata merge -sparse stdout.profraw -o stdout.profdata
$ /home/martin/src/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-cov show target/release/hello-world --sources /home/martin/src/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/src/rust/library/std/src/fs.rs --instr-profile stdout.profdata --color | grep -A 3 'pub fn write(&mut self, write: b
ool) -> &mut Self {'
 1357|      0|    pub fn write(&mut self, write: bool) -> &mut Self {
 1358|      0|        self.0.write(write);
 1359|      0|        self
 1360|      0|    }
```

but when we print to a file:

```console
$ LLVM_PROFILE_FILE=file.profraw ./target/release/hello-world write-file
```

the code coverage shows `fs::write()` as being used (note the `1`'s):

```console
$ /home/martin/src/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-profdata merge -sparse file.profraw -o file.profdata
$ /home/martin/src/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-cov show target/release/hello-world --sources /home/martin/src/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/src/rust/library/std/src/fs.rs --instr-profile file.profdata --color | grep -A 3 'pub fn write(&mut self, write: bool) -> &mut Self {'
 1357|      1|    pub fn write(&mut self, write: bool) -> &mut Self {
 1358|      1|        self.0.write(write);
 1359|      1|        self
 1360|      1|    }
```
</summary>
2024-11-24 11:08:18 +01:00
Ralf Jung
b9a0e57b0c add a test for target-feature-ABI warnings in closures 2024-11-24 09:20:10 +01:00
DianQK
7cc5feea4d
Remove forces_embed_bitcode 2024-11-24 15:51:47 +08:00
DianQK
3a23669787
embed-bitcode is no longer used in iOS 2024-11-24 15:51:47 +08:00
bors
ab3cf268b5 Auto merge of #132791 - tyilo:big-file-fail-fast, r=compiler-errors
rustc: Fail fast when compiling a source file larger than 4 GiB

Currently if you try to compile a file that is larger than 4 GiB, `rustc` will first read the whole into memory before failing.

If we can read the metadata of the file, we can fail before reading the file.
2024-11-24 07:37:32 +00:00
bors
e48241b5d1 Auto merge of #131859 - chriskrycho:update-trpl, r=onur-ozkan
Update TRPL to add new Chapter 17: Async and Await

- Add support to `rustbook` to pass through the `-L`/`--library-path` flag to `mdbook` so that references to the `trpl` crate
- Build the `trpl` crate as part of the book tests. Make it straightforward to add other such book dependencies in the future if needed by implementing that in a fairly general way.
- Update the submodule for the book to pull in the new chapter on async and await, as well as a number of other fixes. This will happen organically/automatically in a week, too, but this lets me group this change with the next one:
- Update the compiler messages which reference the existing chapters 17–20, which are now chapters 18-21. There are only two, both previously referencing chapter 18.
- Update the UI tests which reference the compiler message outputs.
2024-11-23 23:26:19 +00:00
bors
15b663e684 Auto merge of #133379 - jieyouxu:rollup-00jxo71, r=jieyouxu
Rollup of 4 pull requests

Successful merges:

 - #133217 ([AIX] Add option -X32_64 to the "strip" command)
 - #133237 (Minimally constify `Add`)
 - #133355 (Add language tests for aggregate types)
 - #133374 (show abi_unsupported_vector_types lint in future breakage reports)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-23 20:45:19 +00:00
bors
386a7c7ae2 Auto merge of #133242 - lcnr:questionable-uwu, r=compiler-errors,BoxyUwU
finish `Reveal` removal

After #133212 changed the `TypingMode` to be the only source of truth, this entirely rips out `Reveal`.

cc #132279

r? `@compiler-errors`
2024-11-23 18:01:21 +00:00
Chris Krycho
d4275e08e7
Update tests for new TRPL chapter order 2024-11-23 08:57:25 -07:00
Chris Krycho
5e3607626d
Update messages which reference book chs. 17-20
With the insertion of a new chapter 17 on async and await to _The Rust
Programming Language_, references in compiler output to later chapters
need to be updated to avoid confusing users. Redirects exist so that
users who click old links will end up in the right place anyway, but
this way users will be directed to the right URL in the first place.
2024-11-23 08:57:24 -07:00
lcnr
776731dc3f rebase 2024-11-23 13:52:57 +01:00
lcnr
8c7c83d6ef review 2024-11-23 13:52:56 +01:00
lcnr
795ff6576c global old solver cache: use TypingEnv 2024-11-23 13:52:56 +01:00
lcnr
a8c8ab1acd remove remaining references to Reveal 2024-11-23 13:52:56 +01:00
lcnr
319843d8cd no more Reveal :( 2024-11-23 13:52:54 +01:00
lcnr
f4b516b10c thir building: use typing_env directly 2024-11-23 13:51:57 +01:00
许杰友 Jieyou Xu (Joe)
f5cfb90082
Rollup merge of #133374 - RalfJung:abi_unsupported_vector_types, r=jieyouxu
show abi_unsupported_vector_types lint in future breakage reports

The lint is now riding the train to 1.84. Given that crater found no case of this lint triggering at all, IMO it's fine to make it "report in deps" already for 1.85.

Part of https://github.com/rust-lang/rust/issues/116558.
2024-11-23 20:50:16 +08:00
许杰友 Jieyou Xu (Joe)
75b8f433e3
Rollup merge of #133237 - fee1-dead-contrib:constadd, r=compiler-errors
Minimally constify `Add`

* This PR removes the requirement for `impl const` to have a const stability attribute. cc ``@RalfJung`` I believe you mentioned that it would make much more sense to require `const_trait`s to have const stability instead. I agree with that sentiment but I don't think that is _required_ for a small scale experimentation like this PR. https://github.com/rust-lang/project-const-traits/issues/16 should definitely be prioritized in the future, but removing the impl check should be good for now as all callers need `const_trait_impl` enabled for any const impl to work.
* This PR is intentionally minimal as constifying other traits can become more complicated (`PartialEq`, for example, would run into requiring implementing it for `str` as that is used in matches, which runs into the implementation for slice equality which uses specialization)

Per the reasons above, anyone who is interested in making traits `const` in the standard library are **strongly encouraged** to reach out to us on the [Zulip channel](https://rust-lang.zulipchat.com/#narrow/channel/419616-t-compiler.2Fproject-const-traits) before proceeding with the work.

cc ``@rust-lang/project-const-traits``

I believe there is prior approval from libs that we can experiment, so

r? project-const-traits
2024-11-23 20:50:15 +08:00
许杰友 Jieyou Xu (Joe)
92f5144c9c
Rollup merge of #133217 - xingxue-ibm:fix-strip, r=compiler-errors
[AIX] Add option -X32_64 to the "strip" command

The AIX `strip` utility requires option `-X` to specify the object mode. This patch adds the `-X32_64` option to the `strip` command so that it can handle both 32-bit and 64-bit objects. The parameter `option` of function `strip_symbols_with_external_utility`, previously a single string, has been changed to `options`, an array of string slices, to accommodate multiple `strip` options.
2024-11-23 20:50:14 +08:00
lcnr
0f8405f702 ElaborateDrops: use typing_env directly 2024-11-23 13:46:07 +01:00
许杰友 Jieyou Xu (Joe)
96e8c7c7ba
Rollup merge of #133366 - compiler-errors:expected-found, r=dtolnay
Remove unnecessary bool from `ExpectedFound::new`

It's true almost everywhere, and the one place it's not can be replaced w/ an if statement.
2024-11-23 20:19:54 +08:00
许杰友 Jieyou Xu (Joe)
4d9cd661c7
Rollup merge of #133286 - jieyouxu:bug-ourselves, r=compiler-errors
Re-delay a resolve `bug` related to `Self`-ctor in patterns

For the code pattern reported in <https://github.com/rust-lang/rust/issues/133272>,

```rs
impl Foo {
   fn fun() {
        let S { ref Self } = todo!();
   }
}
```

<https://github.com/rust-lang/rust/pull/121208> converted this to a `span_bug` from a `span_delayed_bug` because this specific self-ctor code pattern lacked test coverage. It turns out this can be hit but we just lacked test coverage, so change it back to a `span_delayed_bug` and add a targeted test case.

Follow-up to #121208, cc ``@nnethercote`` (very good exercise to expose our test coverage gaps).
Fixes #133272.
2024-11-23 20:19:53 +08:00
许杰友 Jieyou Xu (Joe)
f7e3de36fc
Rollup merge of #132949 - clubby789:macro-rules-attr-derive, r=fmease
Add specific diagnostic for using macro_rules macro as attribute/derive

Fixes #132928
2024-11-23 20:19:53 +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
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
bohan
30d68eb9aa only store valid proc marco item for doc link 2024-11-23 13:41:27 +08: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
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
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
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
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