Commit Graph

41547 Commits

Author SHA1 Message Date
Zalathar
2748009aad coverage: Identify source files by ID, not by interned filename 2024-11-24 23:46:41 +11:00
Zalathar
b9fb1a69d2 coverage: Store coverage source regions as Span until codegen 2024-11-24 23:46:39 +11:00
Taiki Endo
c024d8ccdf Make s390x non-clobber-only vector register support unstable 2024-11-24 21:42:22 +09:00
Zalathar
87fe7def12 coverage: Rename some FFI fields from span to cov_span
This will avoid confusion with actual `Span` spans.
2024-11-24 23:29:02 +11:00
Zalathar
619a272612 coverage: Ignore functions that end up having no mappings
A used function with no mappings has historically indicated a bug, but that
will no longer be the case after moving some fallible span-processing steps
into codegen.
2024-11-24 23:28:02 +11: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
Zalathar
972663d8ec Allow injecting a profiler runtime into #![no_core] crates
Now that the profiler runtime is itself `#![no_core]`, it can be a dependency
of other no_core crates, including core.
2024-11-24 21:12:40 +11: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
5d42f64ad2 target check_consistency: ensure target feature string makes some basic sense 2024-11-24 09:55:07 +01:00
Ralf Jung
b9a0e57b0c add a test for target-feature-ABI warnings in closures 2024-11-24 09:20:10 +01:00
Ralf Jung
6484420e5d the emscripten OS no longer exists on non-wasm targets 2024-11-24 09:16:59 +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
Michael Goulet
28970a2cb0 Simplify array length mismatch error reporting 2024-11-24 03:32:11 +00:00
Zalathar
e6f1ca6752 Clarify logic for whether a profiler runtime is needed 2024-11-24 11:35:32 +11:00
Michael Goulet
cfa8fcbf58 Dont create trait object if it has errors in it 2024-11-23 23:31:30 +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
Michael Goulet
898ccdb754 Dont create object type when more than one principal is present 2024-11-23 18:54:08 +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
50fb40a987 Delay a bug when encountering an impl with unconstrained generics in codegen_select 2024-11-23 05:27:45 +00: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
b5fc3a10d3 No need to re-sort existential preds 2024-11-23 02:21:21 +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
Michael Goulet
9455373d20 Don't type error if we fail to coerce Pin because it doesnt contain a ref 2024-11-23 01:41:18 +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
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
许杰友 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
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
Nicholas Nethercote
ae9ac0e383 Remove the DefinitelyInitializedPlaces analysis.
Its only use is in the `tests/ui/mir-dataflow/def_inits-1.rs` where it
is tested via `rustc_peek_definite_init`.

Also, it's probably buggy. It's supposed to be the inverse of
`MaybeUninitializedPlaces`, and it mostly is, except that
`apply_terminator_effect` is a little different, and
`apply_switch_int_edge_effects` is missing. Unlike
`MaybeUninitializedPlaces`, which is used extensively in borrow
checking, any bugs in `DefinitelyInitializedPlaces` are easy to overlook
because it is only used in one small test.

This commit removes the analysis. It also removes
`rustc_peek_definite_init`, `Dual` and `MeetSemiLattice`, all of which
are no longer needed.
2024-11-22 17:02:04 +11:00
Michael Goulet
8dfed4ec98 Bail in effects in old solver if self ty is ty var 2024-11-22 03:12:50 +00:00
Michael Goulet
357665dae9 Simplify fulfill_implication 2024-11-22 01:03:17 +00:00
michirakara
de741d2093
distinguish overflow and unimplemented in Step::steps_between 2024-11-21 15:49:55 -08:00
bors
5d3c6ee9b3 Auto merge of #132362 - mustartt:aix-dylib-detection, r=jieyouxu
[AIX] change system dynamic library format

Historically on AIX, almost all dynamic libraries are distributed in `.a` Big Archive Format which can consists of both static and shared objects in the same archive (e.g. `libc++abi.a(libc++abi.so.1)`). During the initial porting process, the dynamic libraries are kept as `.a` to simplify the migration, but semantically having an XCOFF object under the archive extension is wrong. For crate type `cdylib` we want to be able to distribute the libraries as archives as well.

We are migrating to archives with the following format:
```
$ ar -t lib<name>.a
lib<name>.so
```
where each archive contains a single member that is a shared XCOFF object that can be loaded.
2024-11-21 21:36:47 +00:00
Taiki Endo
2c8f6de1ba Support input/output in vector registers of s390x inline assembly 2024-11-22 04:18:14 +09:00
Luca Versari
9022bb2d6f Implement the unsafe-fields RFC.
Co-Authored-By: Jacob Pratt <jacob@jhpratt.dev>
2024-11-21 19:32:07 +01:00
Martin Nordholts
a0e5aea0d2 inject_panic_runtime(): Avoid double negation for 'any non rlib' 2024-11-21 19:16:31 +01:00
Xing Xue
02f51ec2bd Change to pass "strip" options in an array of string slices and add option "-X32_64" for AIX. 2024-11-21 12:16:06 -05:00
Rémy Rakic
764e3e264f Revert "Remove less relevant info from diagnostic"
This reverts commit 8a568d9f15.
2024-11-21 17:09:51 +00:00
Henry Jiang
0db9059726 aix: fix archive format
fmt

fix cfg for windows

remove unused imports

address comments

update libc to 0.2.164

fmt

remove unused imports
2024-11-21 10:33:07 -05:00
bors
75703c1a78 Auto merge of #133287 - matthiaskrgr:rollup-ab9j3pu, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #130236 (unstable feature usage metrics)
 - #131544 (Make asm label blocks safe context)
 - #131586 (Support s390x z13 vector ABI)
 - #132489 (Fix closure arg extraction in `extract_callable_info`, generalize it to async closures)
 - #133078 (tests: ui/inline-consts: add issue number to a test, rename other tests)
 - #133283 (Don't exclude relnotes from `needs-triage` label)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-21 14:08:40 +00:00
Matthias Krüger
c064f6e1fc
Rollup merge of #132489 - compiler-errors:fn-sugg-tweaks, r=BoxyUwU
Fix closure arg extraction in `extract_callable_info`, generalize it to async closures

* Fix argument extraction in `extract_callable_info`
* FIx `extract_callable_info` to work for async closures
* Remove redundant `is_fn_ty` which is just a less general `extract_callable_info`
* More precisely name what is being called (i.e. call it a "closure" not a "function")

Review this without whitespace -- I ended up reformatting `extract_callable_info` because some pesky `//` comments were keeping the let-chains from being formatted.
2024-11-21 11:58:39 +01:00
Matthias Krüger
379b22123c
Rollup merge of #131586 - taiki-e:s390x-vector-abi, r=compiler-errors,uweigand
Support s390x z13 vector ABI

cc #130869

This resolves the following fixmes:
- 58420a065b/compiler/rustc_target/src/abi/call/s390x.rs (L1-L2)
- 58420a065b/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_gnu.rs (L9-L11)

Refs: Section 1.2.3 "Parameter Passing" and section 1.2.5 "Return Values" in ELF Application Binary Interface s390x Supplement, Version 1.6.1 (lzsabi_s390x.pdf in https://github.com/IBM/s390x-abi/releases/tag/v1.6.1)

This PR extends ~~https://github.com/rust-lang/rust/pull/127731~~ https://github.com/rust-lang/rust/pull/132173 (merged) 's ABI check to handle cases where `vector` target feature is disabled.
If we do not do ABI check, we run into the ABI problems as described in https://github.com/rust-lang/rust/issues/116558 and https://github.com/rust-lang/rust/issues/130869#issuecomment-2408268044, and the problem of the compiler generating strange code (https://github.com/rust-lang/rust/pull/131586#discussion_r1799003554).

cc `@uweigand`

`@rustbot` label +O-SystemZ +A-ABI
2024-11-21 11:58:38 +01:00
Matthias Krüger
395649558a
Rollup merge of #131544 - nbdd0121:asm_goto_safe_block, r=petrochenkov
Make asm label blocks safe context

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

`asm!()` is forced to be wrapped inside unsafe. If there's no special treatment, the label blocks would also always be unsafe with no way of opting out. It was suggested that a simple fix is to make asm label blocks safe: https://github.com/rust-lang/rust/issues/119364#issuecomment-2316037703.

`@rustbot` labels: +A-inline-assembly +F-asm
2024-11-21 11:58:37 +01:00
Matthias Krüger
fe5403f517
Rollup merge of #130236 - yaahc:unstable-feature-usage, r=estebank
unstable feature usage metrics

example output

```
test-lib on  master [?] is 📦 v0.1.0 via 🦀 v1.80.1
❯ cat src/lib.rs
───────┬───────────────────────────────────────────────────────
       │ File: src/lib.rs
───────┼───────────────────────────────────────────────────────
   1   │ #![feature(unix_set_mark)]
   2   │ pub fn add(left: u64, right: u64) -> u64 {
   3   │     left + right
   4   │ }
   5   │
   6   │ #[cfg(test)]
   7   │ mod tests {
   8   │     use super::*;
   9   │
  10   │     #[test]
  11   │     fn it_works() {
  12   │         let result = add(2, 2);
  13   │         assert_eq!(result, 4);
  14   │     }
  15   │ }
───────┴───────────────────────────────────────────────────────

test-lib on  master [?] is 📦 v0.1.0 via 🦀 v1.80.1
❯ cargo +stage1 rustc -- -Zmetrics-dir=$PWD/metrics
   Compiling test-lib v0.1.0 (/home/yaahc/tmp/test-lib)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.08s

test-lib on  master [?] is 📦 v0.1.0 via 🦀 v1.80.1
❯ cat metrics/unstable_feature_usage.json
───────┬─────────────────────────────────────────────────────────────────────
       │ File: metrics/unstable_feature_usage.json
───────┼─────────────────────────────────────────────────────────────────────
   1   │ {"lib_features":[{"symbol":"unix_set_mark"}],"lang_features":[]}
   ```

   related to https://github.com/rust-lang/rust/issues/129485
2024-11-21 11:58:36 +01:00
bors
717f5df2c3 Auto merge of #132629 - nnethercote:124141-preliminaries, r=petrochenkov
#124141 preliminaries

Preliminary changes required to start removing `Nonterminal` (https://github.com/rust-lang/rust/pull/124141).

r? `@petrochenkov`
2024-11-21 10:57:22 +00:00
Jieyou Xu
5d30436d24 Re-delay a resolve bug
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 target tested case.
2024-11-21 18:40:36 +08:00
Matthias Krüger
c83b6a3d0e
Rollup merge of #133228 - nnethercote:rewrite-show_md_content_with_pager, r=tgross35
Rewrite `show_md_content_with_pager`

`show_md_content_with_pager` is complex and has a couple of bugs. This PR improves it.

r? ``@tgross35``
2024-11-21 07:56:13 +01:00
Matthias Krüger
920092531f
Rollup merge of #133218 - compiler-errors:const-opaque, r=fee1-dead
Implement `~const` item bounds in RPIT

an RPIT in a `const fn` is allowed to be conditionally const itself :)

r? fee1-dead or reroll
2024-11-21 07:56:13 +01:00
Matthias Krüger
9d70af54e4
Rollup merge of #133153 - maxcabrajac:flat_maps, r=petrochenkov
Add visits to nodes that already have flat_maps in ast::MutVisitor

This PR aims to add `visit_` methods for every node that has a `flat_map_` in MutVisitor, giving implementers free choice over overriding `flat_map` for 1-to-n conversions or `visit` for a 1-to-1.

There is one major problem: `flat_map_stmt`.
While all other default implementations of `flat_map`s are 1-to-1 conversion, as they either only call visits or a internal 1-to-many conversions are natural, `flat_map_stmt` doesn't follow this pattern.

`flat_map_stmt`'s default implementation is a 1-to-n conversion that panics if n > 1 (effectively being a 1-to-[0;1]). This means that it cannot be used as is for a default `visit_stmt`, which would be required to be a 1-to-1.

Implementing `visit_stmt` without runtime checks would require it to reach over a potential `flat_map_item` or `filter_map_expr` overrides and call for their `visit` counterparts directly.
Other than that, if we want to keep the behavior of `flat_map_stmt` it cannot call `visit_stmt` internally.

To me, it seems reasonable to make all default implementations 1-to-1 conversions and let implementers handle `visit_stmt` if they need it, but I don't know if calling `visit` directly when a 1-to-1 is required is ok or not.

related to #128974 & #127615

r? ``@petrochenkov``
2024-11-21 07:56:12 +01:00
Matthias Krüger
b1008d1370
Rollup merge of #132207 - compiler-errors:tweak-res-mod-segment, r=petrochenkov
Store resolution for self and crate root module segments

Let's make sure to record the segment resolution for `self::`, `crate::` and `$crate::`.

I'm actually somewhat surprised that the only diagnostic that uses this is the one that errors on invalid generics on a module segment... but seems strictly more correct regardless, and there may be other diagnostics using these segments resolutions that just haven't been tested for `self`. Also includes a drive-by on `report_prohibit_generics_error`.
2024-11-21 07:56:12 +01:00
Matthias Krüger
61878ec254
Rollup merge of #131736 - hoodmane:emscripten-wasm-bigint, r=workingjubilee
Emscripten: link with -sWASM_BIGINT

When linking an executable without dynamic linking, this is a pure improvement. It significantly reduces code size and avoids a lot of buggy behaviors. It is supported in all browsers for many years and in all maintained versions of Node.

It does change the ABI, so people who are dynamically linking with a library or executable that uses the old ABI may need to turn it off. It can be disabled if needed by passing `-Clink-arg -sWASM_BIGINT=0` to `rustc`. But few people will want to turn it off.

Note this includes a libc bump to 0.2.162!
2024-11-21 07:56:11 +01:00
Michael Goulet
0465f71d60 Stop being so bail-y in candidate assembly 2024-11-21 01:35:34 +00:00
Eric Huss
993e084eb1 Use edition of macro_rules when compiling the macro 2024-11-20 17:28:47 -08:00
bors
2d0ea7956c Auto merge of #133261 - matthiaskrgr:rollup-ekui4we, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #129838 (uefi: process: Add args support)
 - #130800 (Mark `get_mut` and `set_position` in `std::io::Cursor` as const.)
 - #132708 (Point at `const` definition when used instead of a binding in a `let` statement)
 - #133226 (Make `PointerLike` opt-in instead of built-in)
 - #133244 (Account for `wasm32v1-none` when exporting TLS symbols)
 - #133257 (Add `UnordMap::clear` method)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-20 21:58:38 +00:00
Nicholas Nethercote
525e1919f7 Rewrite show_md_content_with_pager.
I think the control flow in this function is complicated and confusing,
largely due to the use of two booleans `print_formatted` and
`fallback_to_println` that are set in multiple places and then used to
guide proceedings.

As well as hurting readability, this leads to at least one bug: if the
`write_termcolor_buf` call fails and the pager also fails, the function
will try to print color output to stdout, but that output will be empty
because `write_termcolor_buf` failed. I.e. the `if fallback_to_println`
body fails to check `print_formatted`.

This commit rewrites the function to be neater and more Rust-y, e.g. by
putting the result of `write_termcolor_buf` into an `Option` so it can
only be used on success, and by using `?` more. It also changes
terminology a little, using "pretty" to mean "formatted and colorized".
The result is a little shorter, more readable, and less buggy.
2024-11-21 08:42:01 +11:00
Nicholas Nethercote
03159d4bff Remove ErrorGuaranteed retval from error_unexpected_after_dot.
It was added in #130349, but it's not used meaningfully, and causes
difficulties for Nonterminal removal in #124141.
2024-11-21 08:22:17 +11:00
Nicholas Nethercote
cee88f7a3f Prepare for invisible delimiters.
Current places where `Interpolated` is used are going to change to
instead use invisible delimiters. This prepares for that.
- It adds invisible delimiter cases to the `can_begin_*`/`may_be_*`
  methods and the `failed_to_match_macro` that are equivalent to the
  existing `Interpolated` cases.
- It adds panics/asserts in some places where invisible delimiters
  should never occur.
- In `Parser::parse_struct_fields` it excludes an ident + invisible
  delimiter from special consideration in an error message, because
  that's quite different to an ident + paren/brace/bracket.
2024-11-21 08:22:11 +11:00
Nicholas Nethercote
91164957ec Remove redundant is_terminal check.
It's not necessary because `show_md_content_with_pager` is only ever
called if `is_terminal` is true.
2024-11-21 08:21:01 +11:00
Nicholas Nethercote
15528b2d6c Fix catbat pager typo.
`bat` is known as `batcat` on Ubuntu and Debian, not `catbat`.
2024-11-21 08:21:01 +11:00
Nicholas Nethercote
cfafa9380b Add metavariables to TokenDescription.
Pasted metavariables are wrapped in invisible delimiters, which
pretty-print as empty strings, and changing that can break some proc
macros. But error messages saying "expected identifer, found ``" are
bad. So this commit adds support for metavariables in `TokenDescription`
so they print as "metavariable" in error messages, instead of "``".

It's not used meaningfully yet, but will be needed to get rid of
interpolated tokens.
2024-11-21 08:16:55 +11:00
Nicholas Nethercote
afe238f66f Introduce InvisibleOrigin on invisible delimiters.
It's not used meaningfully yet, but will be needed to get rid of
interpolated tokens.
2024-11-21 08:16:54 +11:00
maxcabrajac
01b26e6198 Use visit_item instead of flat_map_item in test_harness.rs 2024-11-20 16:47:00 -03:00
maxcabrajac
1dc12367b9 Items 2024-11-20 16:42:18 -03:00
Ralf Jung
666bcbdb2e aarch64 softfloat target: always pass floats in int registers 2024-11-20 20:41:28 +01:00
Jane Losare-Lusby
dc97db105a unstable feature usage metrics 2024-11-20 11:31:40 -08:00
Matthias Krüger
71d07dd030
Rollup merge of #133257 - GuillaumeGomez:unordmap-clear, r=lcnr
Add `UnordMap::clear` method

I need it for something I'm working on and I was surprised to see this method was not implemented.
2024-11-20 20:10:15 +01:00
Matthias Krüger
1099bc8e73
Rollup merge of #133244 - daxpedda:wasm32v1-none-atomic, r=alexcrichton
Account for `wasm32v1-none` when exporting TLS symbols

Exporting TLS related symbols was limited to `wasm32-unknown-unknown` because WASI and Emscripten (?) have their own infrastructure to deal with TLS. However, the introduction of `wasm32v1-none` is in the same boat as `wasm32-unknown-unknown`.

This PR adjust the mechanism to account for `wasm32v1-none` as well.

See https://github.com/rust-lang/rust/pull/102385 and https://github.com/rust-lang/rust/pull/102440.

r? ``@alexcrichton``
2024-11-20 20:10:14 +01:00
Matthias Krüger
fbed195b4d
Rollup merge of #133226 - compiler-errors:opt-in-pointer-like, r=lcnr
Make `PointerLike` opt-in instead of built-in

The `PointerLike` trait currently is a built-in trait that computes the layout of the type. This is a bit problematic, because types implement this trait automatically. Since this can be broken due to semver-compatible changes to a type's layout, this is undesirable. Also, calling `layout_of` in the trait system also causes cycles.

This PR makes the trait implemented via regular impls, and adds additional validation on top to make sure that those impls are valid. This could eventually be `derive()`d for custom smart pointers, and we can trust *that* as a semver promise rather than risking library authors accidentally breaking it.

On the other hand, we may never expose `PointerLike`, but at least now the implementation doesn't invoke `layout_of` which could cause ICEs or cause cycles.

Right now for a `PointerLike` impl to be valid, it must be an ADT that is `repr(transparent)` and the non-1zst field needs to implement `PointerLike`. There are also some primitive impls for `&T`/ `&mut T`/`*const T`/`*mut T`/`Box<T>`.
2024-11-20 20:10:13 +01:00
Matthias Krüger
7fc2b33722
Rollup merge of #132708 - estebank:const-as-binding, r=Nadrieril
Point at `const` definition when used instead of a binding in a `let` statement

Modify `PatKind::InlineConstant` to be `ExpandedConstant` standing in not only for inline `const` blocks but also for `const` items. This allows us to track named `const`s used in patterns when the pattern is a single binding. When we detect that there is a refutable pattern involving a `const` that could have been a binding instead, we point at the `const` item, and suggest renaming. We do this for both `let` bindings and `match` expressions missing a catch-all arm if there's at least one single binding pattern referenced.

After:

```
error[E0005]: refutable pattern in local binding
  --> $DIR/bad-pattern.rs:19:13
   |
LL |     const PAT: u32 = 0;
   |     -------------- missing patterns are not covered because `PAT` is interpreted as a constant pattern, not a new variable
...
LL |         let PAT = v1;
   |             ^^^ pattern `1_u32..=u32::MAX` not covered
   |
   = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
   = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
   = note: the matched value is of type `u32`
help: introduce a variable instead
   |
LL |         let PAT_var = v1;
   |             ~~~~~~~
```

Before:

```
error[E0005]: refutable pattern in local binding
  --> $DIR/bad-pattern.rs:19:13
   |
LL |         let PAT = v1;
   |             ^^^
   |             |
   |             pattern `1_u32..=u32::MAX` not covered
   |             missing patterns are not covered because `PAT` is interpreted as a constant pattern, not a new variable
   |             help: introduce a variable instead: `PAT_var`
   |
   = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
   = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
   = note: the matched value is of type `u32`
```

CC #132582.
2024-11-20 20:10:12 +01:00
Michael Goulet
b33a0d3292 we should not be reporting generic error if there is not a segment to deny 2024-11-20 18:57:02 +00:00
Michael Goulet
19b528b8a0 Store resolution for self and crate root module segments 2024-11-20 18:57:02 +00:00
bors
3fee0f12e4 Auto merge of #131326 - dingxiangfei2009:issue-130836-attempt-2, r=nikomatsakis
Reduce false positives of tail-expr-drop-order from consumed values (attempt #2)

r? `@nikomatsakis`

Tracked by #123739.

Related to #129864 but not replacing, yet.

Related to #130836.

This is an implementation of the approach suggested in the [Zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/temporary.20drop.20order.20changes). A new MIR statement `BackwardsIncompatibleDrop` is added to the MIR syntax. The lint now works by inspecting possibly live move paths before at the `BackwardsIncompatibleDrop` location and the actual drop under the current edition, which should be one before Edition 2024 in practice.
2024-11-20 18:51:54 +00:00
Esteban Küber
2487765b88 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-20 17:55:18 +00:00
Guillaume Gomez
186e282a43 Add UnordMap::clear method 2024-11-20 18:11:37 +01:00
Michael Goulet
228068bc6e Make PointerLike opt-in as a trait 2024-11-20 16:36:12 +00:00
Michael Goulet
06e66d78c3 Rip out built-in PointerLike impl 2024-11-20 16:13:57 +00:00
Matthias Krüger
b1413e0583
Rollup merge of #133241 - RalfJung:typing-env, r=lcnr
interpret: make typing_env field private

This was made public in https://github.com/rust-lang/rust/pull/133212 but IMO it should remain private. (Specifically, this prevents it from being mutated.)

r? `@lcnr`
2024-11-20 15:48:29 +01:00
Matthias Krüger
d3326564b2
Rollup merge of #133239 - kleisauke:fix-llvm-triple-x86_64-win7-windows-msvc, r=ChrisDenton
Fix LLVM target triple for `x86_64-win7-windows-msvc`

The vendor field needs to be `pc` rather than `win7`.
2024-11-20 15:48:28 +01:00
daxpedda
f37d021d6c
Account for wasm32v1-none when exporting TLS symbols 2024-11-20 14:02:25 +01:00
Ding Xiang Fei
297b618944
reduce false positives of tail-expr-drop-order from consumed values
take 2

open up coroutines

tweak the wordings

the lint works up until 2021

We were missing one case, for ADTs, which was
causing `Result` to yield incorrect results.

only include field spans with significant types

deduplicate and eliminate field spans

switch to emit spans to impl Drops

Co-authored-by: Niko Matsakis <nikomat@amazon.com>

collect drops instead of taking liveness diff

apply some suggestions and add explantory notes

small fix on the cache

let the query recurse through coroutine

new suggestion format with extracted variable name

fine-tune the drop span and messages

bugfix on runtime borrows

tweak message wording

filter out ecosystem types earlier

apply suggestions

clippy

check lint level at session level

further restrict applicability of the lint

translate bid into nop for stable mir

detect cycle in type structure
2024-11-20 20:53:11 +08:00
Ralf Jung
d04088fa36 interpret: make typing_env field private 2024-11-20 11:05:53 +01:00
Kleis Auke Wolthuizen
57ed8e8436 Fix LLVM target triple for x86_64-win7-windows-msvc
The vendor field needs to be `pc` rather than `win7`.
2024-11-20 10:47:28 +01:00
bors
fda6892747 Auto merge of #133234 - jhpratt:rollup-42dmg4p, r=jhpratt
Rollup of 5 pull requests

Successful merges:

 - #132732 (Use attributes for `dangling_pointers_from_temporaries` lint)
 - #133108 (lints_that_dont_need_to_run: never skip future-compat-reported lints)
 - #133190 (CI: use free runner in dist-aarch64-msvc)
 - #133196 (Make rustc --explain compatible with BusyBox less)
 - #133216 (Implement `~const Fn` trait goal in the new solver)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-20 09:27:56 +00:00
Deadbeef
030ddeecab don't require const stability for const impls 2024-11-20 17:04:05 +08:00
Jacob Pratt
b9cd5eb190
Rollup merge of #133216 - compiler-errors:const-fn, r=lcnr
Implement `~const Fn` trait goal in the new solver

Split out from https://github.com/rust-lang/rust/pull/132329 since this should be easier to review on its own.

r? lcnr
2024-11-20 01:54:27 -05:00
Jacob Pratt
cd36973a13
Rollup merge of #133196 - omnivagant:correct-less-r-flag, r=tgross35
Make rustc --explain compatible with BusyBox less

busybox less does not support the -r flag and less(1) says:

  USE OF THE -r OPTION IS NOT RECOMMENDED.
2024-11-20 01:54:26 -05:00
Jacob Pratt
a175db1424
Rollup merge of #133108 - RalfJung:future-compat-needs-to-run, r=lcnr
lints_that_dont_need_to_run: never skip future-compat-reported lints

Follow-up to https://github.com/rust-lang/rust/pull/125116: future-compat lints show up with `--json=future-incompat` even if they are otherwise allowed in the crate. So let's ensure we do not skip those as part of the `lints_that_dont_need_to_run` logic.

I could not find a current future compat lint that is emitted by a lint pass, so there's no clear way to add a test for this.

Cc `@blyxyas` `@cjgillot`
2024-11-20 01:54:25 -05:00
Jacob Pratt
25dc4d0394
Rollup merge of #132732 - gavincrawford:as_ptr_attribute, r=Urgau
Use attributes for `dangling_pointers_from_temporaries` lint

Checking for dangling pointers by function name isn't ideal, and leaves out certain pointer-returning methods that don't follow the `as_ptr` naming convention. Using an attribute for this lint cleans things up and allows more thorough coverage of other methods, such as `UnsafeCell::get()`.
2024-11-20 01:54:24 -05:00
bors
70e814bd9e Auto merge of #133212 - lcnr:questionable-uwu, r=compiler-errors
continue `ParamEnv` to `TypingEnv` transition

cc #132279

r? `@compiler-errors`
2024-11-20 06:22:01 +00:00
bors
bcfea1f8d2 Auto merge of #133194 - khuey:master, r=jieyouxu
Drop debug info instead of panicking if we exceed LLVM's capability to represent it

Recapping a bit of history here:

In #128861 I made debug info correctly represent parameters to inline functions by removing a fake lexical block that had been inserted to suppress LLVM assertions and by deduplicating those parameters.

LLVM, however, expects to see a single parameter _with distinct locations_, particularly distinct inlinedAt values on the DILocations. This generally worked because no matter how deep the chain of inlines it takes two different call sites in the original function to result in the same function being present multiple times, and a function call requires a non-zero number of characters, but macros threw a wrench in that in #131944. At the time I thought the issue there was limited to proc-macros, where an arbitrary amount of code can be generated at a single point in the source text.

In #132613 I added discriminators to DILocations that would otherwise be the same to repair #131944[^1]. This works, but LLVM's capacity for discriminators is not infinite (LLVM actually only allocates 12 bits for this internally). At the time I thought it would be very rare for anyone to hit the limit, but #132900 proved me wrong. In the relatively-minimized test case it also became clear to me that the issue affects regular macros too, because the call to the inlined function will (without collapse_debuginfo on the macro) be attributed to the (repeated, if the macro is used more than once) textual callsite in the macro definition.

This PR fixes the panic by dropping debug info when we exceed LLVM's maximum discriminator value. There's also a preceding commit for a related but distinct issue: macros that use collapse_debuginfo should in fact have their inlinedAts collapsed to the macro callsite and thus not need discriminators at all (and not panic/warn accordingly when the discriminator limit is exhausted).

Fixes #132900

r? `@jieyouxu`

[^1]: Editor's note: `fix` is a magic keyword in PR description that apparently will close the linked issue (it's closed already in this case, but still).
2024-11-20 02:10:50 +00:00
bors
875df370be Auto merge of #133219 - matthiaskrgr:rollup-hnuq0zf, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #123947 (Add vec_deque::Iter::as_slices and friends)
 - #125405 (Add std:🧵:add_spawn_hook.)
 - #133175 (ci: use free runner in dist-i686-msvc)
 - #133183 (Mention std::fs::remove_dir_all in std::fs::remove_dir)
 - #133188 (Add `visit` methods to ast nodes that already have `walk`s on ast visitors)
 - #133201 (Remove `TokenKind::InvalidPrefix`)
 - #133207 (Default-enable `llvm_tools_enabled` when no `config.toml` is present)
 - #133213 (Correct the tier listing of `wasm32-wasip2`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-19 23:04:44 +00:00
Matthias Krüger
49aec06ab0
Rollup merge of #133207 - jieyouxu:macos-objcopy, r=Kobzol,bjorn3
Default-enable `llvm_tools_enabled` when no `config.toml` is present

Fixes #133195. cc `@wesleywiser` could you double check if with this patch and no `config.toml` that you can run `./x test tests/ui --stage 1`?

`llvm-objcopy` is usually required by cg_ssa on macOS to workaround bad `strip`s.

cc `@bjorn3` I hope this doesn't break cg_clif...

r? bootstrap
2024-11-19 22:24:47 +01:00
Matthias Krüger
841243f319
Rollup merge of #133201 - nnethercote:rm-TokenKind-InvalidPrefix, r=compiler-errors
Remove `TokenKind::InvalidPrefix`

It's not needed. Best reviewed one commit at a time.

r? `@estebank`
2024-11-19 22:24:47 +01:00
Matthias Krüger
022bb9c3bb
Rollup merge of #133188 - maxcabrajac:walk_no_visit, r=petrochenkov
Add `visit` methods to ast nodes that already have `walk`s on ast visitors

Some `walk` functions are called directly, because there were no correspondent visit functions.

related to #128974 & #127615

r? `@petrochenkov`
2024-11-19 22:24:46 +01:00
Michael Goulet
def7ed08e7 Implement ~const Fn trait goals in the new solver 2024-11-19 21:22:17 +00:00
Ralf Jung
df94818366 lints_that_dont_need_to_run: never skip future-compat-reported lints 2024-11-19 22:04:10 +01:00
lcnr
002efeb72a additional TypingEnv cleanups 2024-11-19 21:36:23 +01:00
lcnr
d61effe58f resolve_instance: stop relying on Reveal 2024-11-19 21:36:23 +01:00
lcnr
7a90e84f4d InterpCx store TypingEnv instead of a ParamEnv 2024-11-19 21:36:23 +01:00
Michael Goulet
5eeaf2ec33 Implement ~const opaques 2024-11-19 20:31:05 +00:00
Michael Goulet
588c4c45d5 Rename implied_const_bounds to explicit_implied_const_bounds 2024-11-19 20:30:58 +00:00
bors
ee612c45f0 Auto merge of #132761 - nnethercote:resolve-tweaks, r=petrochenkov
Resolve tweaks

A couple of small perf improvements, and some minor refactorings, all in `rustc_resolve`.

r? `@petrochenkov`
2024-11-19 19:54:35 +00:00
lcnr
b9dea31ea9 TypingMode::from_param_env begone 2024-11-19 19:32:52 +01:00
lcnr
4813fda2e6 rustdoc: yeet TypingEnv::from_param_env 2024-11-19 18:35:41 +01:00
lcnr
f74951fdf1 generic_const_exprs: yeet TypingEnv::from_param_env 2024-11-19 18:06:20 +01:00
lcnr
ffd7a50314 impl trait overcaptures, yeet TypingMode::from_param_env 2024-11-19 18:06:20 +01:00
lcnr
07a5272476 pattern lowering, yeet TypingEnv::from_param_env 2024-11-19 18:06:20 +01:00
lcnr
decf37bd16 liveness checking, yeet TypingEnv::from_param_env 2024-11-19 18:06:20 +01:00
lcnr
1ec964873e unconditional recursion, yeet TypingEnv::from_param_env 2024-11-19 18:06:20 +01:00
lcnr
948cec0fad move fn is_item_raw to TypingEnv 2024-11-19 18:06:20 +01:00