Commit Graph

12316 Commits

Author SHA1 Message Date
许杰友 Jieyou Xu (Joe)
fdb64b9478 tests: add regression test to make sure cfg_attr isn't considered unhandled 2024-08-06 06:12:10 +00:00
Matthias Krüger
c53698b399
Rollup merge of #128697 - RalfJung:nullary-op, r=compiler-errors
interpret: move nullary-op evaluation into operator.rs

We call it an operator, so we might as well treat it like one. :)

Also use more consistent naming for the "evaluate intrinsic" functions. "emulate" is really the wrong term, this *is* a genuine implementation of the intrinsic semantics after all.
2024-08-05 23:35:24 +02:00
Matthias Krüger
77f57cbcac
Rollup merge of #128694 - compiler-errors:norm, r=WaffleLapkin
Normalize when equating `dyn` tails in MIR borrowck

See the explanation in the comment.

Fixes #128621
cc `@WaffleLapkin`
2024-08-05 23:35:23 +02:00
Matthias Krüger
83155b3900
Rollup merge of #128688 - RalfJung:custom-mir-tail-calls, r=compiler-errors
custom MIR: add support for tail calls

Cc ``@WaffleLapkin``
2024-08-05 23:35:23 +02:00
Matthias Krüger
9cb3688f1f
Rollup merge of #128580 - compiler-errors:cfi-param-env, r=lcnr
Use `ParamEnv::reveal_all` in CFI

I left a huge comment for why this ICEs in the test I committed.

`typeid_for_instance` should only be called on monomorphic instances during codegen, and we should just be using `ParamEnv::reveal_all()` rather than the param-env of the instance itself. I added an assertion to ensure that we only do this for fully substituted instances (this may break with polymorphization, but I kinda don't care lol).

Fixes #114160
cc `@rcvalle`
2024-08-05 23:35:22 +02:00
Ralf Jung
46896d6f66 interpret: move nullary-op evaluation into operator.rs 2024-08-05 22:42:34 +02:00
Michael Goulet
c6f8672dd5 Normalize when equating dyn tails in MIR borrowck 2024-08-05 14:28:06 -04:00
bors
f7eefec4e0 Auto merge of #128689 - matthiaskrgr:rollup-ukyn8wq, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #128385 (rustdoc-json: discard non-local inherent impls for primitives)
 - #128559 (Don't re-elaborated already elaborated caller bounds in method probe)
 - #128631 (handle crates when they are not specified for std docs)
 - #128664 (Add `Debug` impls to API types in `rustc_codegen_ssa`)
 - #128686 (fix the invalid argument type)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-05 17:03:58 +00:00
Matthias Krüger
376a6f9f43
Rollup merge of #128385 - its-the-shrimp:fix_114039, r=aDotInTheVoid
rustdoc-json: discard non-local inherent impls for primitives

Fixes #114039
at least it should
r? `@aDotInTheVoid`
2024-08-05 18:36:01 +02:00
Ralf Jung
212417b87f custom MIR: add support for tail calls 2024-08-05 18:23:14 +02:00
bors
2b78d92096 Auto merge of #124336 - compiler-errors:super-outlives, r=lcnr
Enforce supertrait outlives obligations hold when confirming impl

**TL;DR:** We elaborate super-predicates and apply any outlives obligations when proving an impl holds to fix a mismatch between implied bounds.

Bugs in implied bounds (and implied well-formedness) occur whenever there is a mismatch between the assumptions that some code can assume to hold, and the obligations that a caller/user of that code must prove. If the former is stronger than the latter, then unsoundness occurs.

Take a look at the example unsoundness:

```rust
use std::fmt::Display;

trait Static: 'static {}
impl<T> Static for &'static T {}
fn foo<S: Display>(x: S) -> Box<dyn Display>
where
    &'static S: Static,
{
    Box::new(x)
}

fn main() {
    let s = foo(&String::from("blah blah blah"));
    println!("{}", s);
}
```

This specific example occurs because we elaborate obligations in `fn foo`:

* `&'static S: Static`
    * `&'static S: 'static` <- super predicate
        * `S: 'static` <- elaborating outlives bounds

However, when calling `foo`, we only need to prove the direct set of where clauses. So at the call site for some substitution `S = &'not_static str`, that means only proving `&'static &'not_static str: Static`. To prove this, we apply the impl, which itself holds trivially since it has no where clauses.

This is the mismatch -- `foo` is allowed to assume that `S: 'static` via elaborating supertraits, but callers of `foo` never need to prove that `S: 'static`.

There are several approaches to fixing this, all of which have problems due to current limitations in our type system:
1. proving the elaborated set of predicates always - This leads to issues since we don't have coinductive trait semantics, so we easily hit new cycles.
    * This would fix our issue, since callers of `foo` would have to both prove `&'static &'not_static str: Static` and its elaborated bounds, which would surface the problematic `'not_static: 'static` outlives obligation.
    * However, proving supertraits when proving impls leads to inductive cycles which can't be fixed until we get coinductive trait semantics.
2. Proving that an impl header is WF when applying that impl:
    * This would fix our issue, since when we try to prove `&'static &'not_static str: Static`, we'd need to prove `WF(&'static &'not_static str)`, which would surface the problematic `'not_static: 'static` outlives obligation.
    * However, this leads to issues since we don't have higher-ranked implied bounds. This breaks things when trying to apply impls to higher-ranked trait goals.

To get around these limitations, we apply a subset of (1.), which is to elaborate the supertrait obligations of the impl but filter only the (region/type) outlives out of that set, since those can never participate in an inductive cycle. This is likely not sufficient to fix a pathological example of this issue, but it does clearly fill in a major gap that we're currently overlooking.

This can also result in 'unintended' errors due to missing implied-bounds on binders. We did not encounter this in the crater run and don't expect people to rely on this code in practice:
```rust
trait Outlives<'b>: 'b {}
impl<'b, T> Outlives<'b> for &'b T {}
fn foo<'b>()
where
    // This bound will break due to this PR as we end up proving
    // `&'b &'!a (): 'b` without the implied `'!a: 'b`
    // bound.
    for<'a> &'b &'a (): Outlives<'b>,
{}
```

Fixes #98117

---

Crater: https://github.com/rust-lang/rust/pull/124336#issuecomment-2209165320
Triaged: https://github.com/rust-lang/rust/pull/124336#issuecomment-2236321325

All of the fallout is due to generic const exprs, and can be ignored.
2024-08-05 14:39:32 +00:00
Michael Goulet
6a891ec4fe Enforce supertrait outlives obligations hold when confirming impl 2024-08-05 09:55:14 -04:00
bors
83e9b93c90 Auto merge of #127095 - Oneirical:testiary-education, r=jieyouxu
Migrate `reproducible-build-2` and `stable-symbol-names` `run-make` tests to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

Needs try-jobs.

try-job: x86_64-msvc
try-job: armhf-gnu
try-job: test-various
try-job: aarch64-apple
try-job: i686-msvc
try-job: x86_64-mingw
2024-08-05 12:16:05 +00:00
schvv31n
7499e21a1e rustdoc-json: discard non-local inherent impls 2024-08-05 11:19:22 +01:00
bors
9179d9b334 Auto merge of #117468 - daxpedda:wasm-relaxed-simd, r=alexcrichton
Stabilize Wasm relaxed SIMD

This PR stabilizes [Wasm relaxed SIMD](https://github.com/WebAssembly/relaxed-simd) which has already reached [phase 4](04fa8c810e (phase-4---standardize-the-feature-wg)).

Tracking issue: #111196
Implementation PR: https://github.com/rust-lang/stdarch/pull/1393
Documentation: https://github.com/rust-lang/reference/pull/1421
Stdarch: https://github.com/rust-lang/stdarch/pull/1494

Closes #111196.
2024-08-05 09:25:50 +00:00
bors
4d48a6be74 Auto merge of #128673 - matthiaskrgr:rollup-gtvpkm7, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #128026 (std:🧵 available_parallelism implementation for vxWorks proposal.)
 - #128471 (rustdoc: Fix handling of `Self` type in search index and refactor its representation)
 - #128607 (Use `object` in `run-make/symbols-visibility`)
 - #128609 (Remove unnecessary constants from flt2dec dragon)
 - #128611 (run-make: Remove cygpath)
 - #128619 (Correct the const stabilization of `<[T]>::last_chunk`)
 - #128630 (docs(resolve): more explain about `target`)
 - #128660 (tests: more crashes)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-05 06:55:50 +00:00
Matthias Krüger
5fa740f613
Rollup merge of #128660 - matthiaskrgr:niceice, r=compiler-errors
tests: more crashes

r? ``@jieyouxu``
2024-08-05 08:22:25 +02:00
Matthias Krüger
f231973941
Rollup merge of #128607 - ChrisDenton:visibility, r=jieyouxu
Use `object` in `run-make/symbols-visibility`

This is another case where we can simply use a rust library instead of wrangling nm.

try-job: x86_64-msvc
try-job: i686-msvc
try-job: test-various
2024-08-05 08:22:22 +02:00
Matthias Krüger
4adefa4334
Rollup merge of #128471 - camelid:rustdoc-self, r=notriddle
rustdoc: Fix handling of `Self` type in search index and refactor its representation

### Summary

- Add enum variant `clean::Type::SelfTy` and use it instead of `clean::Type::Generic(kw::SelfUpper)`.
- Stop treating `Self` as a generic in the search index.
- Remove struct formerly known as `clean::SelfTy` (constructed as representation of function receiver type). We're better off without it.

### Before

![image](https://github.com/user-attachments/assets/d257bdd8-3a62-4c71-84a5-9c950f2e4f00)

### After

![image](https://github.com/user-attachments/assets/8f6d3f22-92c1-41e3-9ab8-a881b66816c0)

r? ```@notriddle```
cc https://github.com/rust-lang/rust/pull/127589#issuecomment-2259715841
2024-08-05 08:22:21 +02:00
Matthias Krüger
20480075bd
Rollup merge of #128623 - jieyouxu:check-attr-ice, r=nnethercote
Do not fire unhandled attribute assertion on multi-segment `AttributeType::Normal` attributes with builtin attribute as first segment

### The Problem

In #128581 I introduced an assertion to check that all builtin attributes are actually checked via
`CheckAttrVisitor` and aren't accidentally usable on completely unrelated HIR nodes.
Unfortunately, the assertion had correctness problems as revealed in #128622.

The match on attribute path segments looked like

```rs,ignore
// Normal handler
[sym::should_panic] => /* check is implemented */
// Fallback handler
[name, ..] => match BUILTIN_ATTRIBUTE_MAP.get(name) {
    // checked below
    Some(BuiltinAttribute { type_: AttributeType::CrateLevel, .. }) => {}
    Some(_) => {
        if !name.as_str().starts_with("rustc_") {
            span_bug!(
                attr.span,
                "builtin attribute {name:?} not handled by `CheckAttrVisitor`"
            )
        }
    }
    None => (),
}
```

However, it failed to account for edge cases such as an attribute whose:

1. path segments *starts* with a segment matching the name of a builtin attribute such as `should_panic`, and
2. the first segment's symbol does not start with `rustc_`, and
3. the matched builtin attribute is also of `AttributeType::Normal` attribute type upon registration with the builtin attribute map.

These conditions when all satisfied cause the span bug to be issued for e.g.
`#[should_panic::skip]` because the `[sym::should_panic]` arm is not matched (since it's
`[sym::should_panic, sym::skip]`).

### Proposed Solution

This PR tries to remedy that by adjusting all normal/specific handlers to not match exactly on a single segment, but instead match a prefix segment.

i.e.

```rs,ignore
// Normal handler, notice the `, ..` rest pattern
[sym::should_panic, ..] => /* check is implemented */
// Fallback handler
[name, ..] => match BUILTIN_ATTRIBUTE_MAP.get(name) {
    // checked below
    Some(BuiltinAttribute { type_: AttributeType::CrateLevel, .. }) => {}
    Some(_) => {
        if !name.as_str().starts_with("rustc_") {
            span_bug!(
                attr.span,
                "builtin attribute {name:?} not handled by `CheckAttrVisitor`"
            )
        }
    }
    None => (),
}
```

### Review Remarks

This PR contains 2 commits:

1. The first commit adds a regression test. This will ICE without the `CheckAttrVisitor` changes.
2. The second commit adjusts `CheckAttrVisitor` assertion logic. Once this commit is applied, the test should no longer ICE and produce the expected bless stderr.

Fixes #128622.

r? ``@nnethercote`` (since you reviewed #128581)
2024-08-05 05:40:21 +02:00
Matthias Krüger
3c8b25905c
Rollup merge of #128500 - clubby789:122600-test, r=Mark-Simulacrum
Add test for updating enum discriminant through pointer

Closes #122600
2024-08-05 05:40:21 +02:00
Matthias Krüger
d10f2b32f0
Rollup merge of #127907 - RalfJung:byte_slice_in_packed_struct_with_derive, r=nnethercote
built-in derive: remove BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE hack and lint

Fixes https://github.com/rust-lang/rust/issues/107457 by turning the lint into a hard error. The lint has been shown in future breakage reports since Rust 1.69 (released in April 2023).

Let's see (via crater) if enough time has passed since https://github.com/rust-lang/rust/pull/104429, and https://github.com/unicode-org/icu4x/pull/2834 has propagated far enough to let us make this a hard error.

Cc ``@nnethercote`` ``@Manishearth``
2024-08-05 05:40:19 +02:00
Matthias Krüger
cc61dc8b2d
Rollup merge of #127655 - RalfJung:invalid_type_param_default, r=compiler-errors
turn `invalid_type_param_default` into a `FutureReleaseErrorReportInDeps`

`````@rust-lang/types````` I assume the plan is still to disallow this? It has been a future-compat lint for a long time, seems ripe to go for hard error.

However, turns out that outright removing it right now would lead to [tons of crater regressions](https://github.com/rust-lang/rust/pull/127655#issuecomment-2228285460), so for now this PR just makes this future-compat lint show up in cargo's reports, so people are warned when they use a dependency that is affected by this.

Fixes https://github.com/rust-lang/rust/issues/27336 by removing the feature gate (so there's no way to silence the lint even on nightly)
CC https://github.com/rust-lang/rust/issues/36887
2024-08-05 05:40:19 +02:00
Noah Lev
dac7f20e13 Add test for Self not being a generic in search index 2024-08-04 12:49:28 -07:00
Matthias Krüger
69de294c31 tests: more crashes 2024-08-04 21:25:49 +02:00
bors
176e545209 Auto merge of #128534 - bjorn3:split_stdlib_workspace, r=Mark-Simulacrum
Move the standard library to a separate workspace

This ensures that the Cargo.lock packaged for it in the rust-src component is up-to-date, allowing rust-analyzer to run cargo metadata on the standard library even when the rust-src component is stored in a read-only location as is necessary for loading crates.io dependencies of the standard library.

This also simplifies tidy's license check for runtime dependencies as it can now look at all entries in library/Cargo.lock without having to filter for just the dependencies of runtime crates. In addition this allows removing an exception in check_runtime_license_exceptions that was necessary due to the compiler enabling a feature on the object crate which pulls in a dependency not allowed for the standard library.

While cargo workspaces normally enable dependencies of multiple targets to be reused, for the standard library we do not want this reusing to prevent conflicts between dependencies of the sysroot and of tools that are built using this sysroot. For this reason we already use an unstable cargo feature to ensure that any dependencies which would otherwise be shared get a different -Cmetadata argument as well as using separate build dirs.

This doesn't change the situation around vendoring. We already have several cargo workspaces that need to be vendored. Adding another one doesn't change much.

There are also no cargo profiles that are shared between the root workspace and the library workspace anyway, so it doesn't add any extra work when changing cargo profiles.
2024-08-04 18:40:03 +00:00
bors
ebd08d8ed5 Auto merge of #128634 - matthiaskrgr:rollup-l5a2v5k, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #128305 (improve error message when `global_asm!` uses `asm!` operands)
 - #128526 (time.rs: remove "Basic usage text")
 - #128531 (Miri: add a flag to do recursive validity checking)
 - #128578 (rustdoc: Cleanup `CacheBuilder` code for building search index)
 - #128589 (allow setting `link-shared` and `static-libstdcpp` with CI LLVM)
 - #128615 (rustdoc: make the hover trail for doc anchors a bit bigger)
 - #128620 (Update rinja version to 0.3.0)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-04 11:57:59 +00:00
Matthias Krüger
b6b8330b9d
Rollup merge of #128305 - folkertdev:asm-parser-unsupported-operand, r=Amanieu
improve error message when `global_asm!` uses `asm!` operands

follow-up to https://github.com/rust-lang/rust/pull/128207

what was

```
error: expected expression, found keyword `in`
 --> src/lib.rs:1:31
  |
1 | core::arch::global_asm!("{}", in(reg));
  |                               ^^ expected expression
```

becomes

```
error: the `in` operand cannot be used with `global_asm!`
  --> $DIR/parse-error.rs:150:19
   |
LL | global_asm!("{}", in(reg));
   |                   ^^ the `in` operand is not meaningful for global-scoped inline assembly, remove it
```

the span of the error is just the keyword, which means that we can't create a machine-applicable suggestion here. The alternative would be to attempt to parse the full operand, but then if there are syntax errors in the operand those would  be presented to the user, even though the parser already knows that the output won't be valid. Also that would require more complexity in the parser.

So I think this is a nice improvement at very low cost.
2024-08-04 11:32:33 +02:00
bors
58fb508fe3 Auto merge of #127877 - Rejyr:migrate-print-rmake, r=jieyouxu
Migrate `print-target-list` to `rmake` and  `print-calling-convention` to ui-test

Part of #121876.

r? `@jieyouxu`

try-job: x86_64-gnu-llvm-18
try-job: test-various
try-job: armhf-gnu
try-job: aarch64-apple
try-job: i686-mingw
try-job: x86_64-msvc
2024-08-04 09:31:24 +00:00
daxpedda
80b74d397f
Implement a implicit target feature mechanism 2024-08-04 08:44:23 +02:00
daxpedda
90521399b4
Stabilize Wasm relaxed SIMD 2024-08-04 08:44:13 +02:00
Jerry Wang
36cf385e88
Ensure Rustc::print use in rmake tests 2024-08-03 22:36:08 -04:00
Jerry Wang
1ca959e3f0
Migrate print-target-list to rmake 2024-08-03 22:36:08 -04:00
bors
b389b0ab72 Auto merge of #128466 - sayantn:stdarch-update, r=tgross35
Update the stdarch submodule

cc `@tgross35` `@Amanieu`
r? `@tgross35`

try-job: dist-various-2
2024-08-04 02:11:27 +00:00
许杰友 Jieyou Xu (Joe)
9e5c9c14c7 tests: add regression test for incorrect "builtin attribute is checked" assertion ICE
See <https://github.com/rust-lang/rust/issues/128622>.
2024-08-04 01:50:55 +00:00
Jerry Wang
3a41a11a8f
Migrate run-make/print-calling-conventions to ui-test 2024-08-03 20:09:42 -04:00
Chris Denton
b94a9c1b12
Remove skipping symbols with the __imp_ prefix 2024-08-03 22:08:39 +00:00
sayantn
2cde11f2d1 Chore: add x86_amx_intrinsics feature flag to core/lib.rs and remove issue-120720-reduce-nan.rs 2024-08-04 03:08:18 +05:30
bors
64ebd39da5 Auto merge of #128614 - matthiaskrgr:rollup-d2fextz, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #127921 (Stabilize unsafe extern blocks (RFC 3484))
 - #128283 (bootstrap: fix bug preventing the use of custom targets)
 - #128530 (Implement `UncheckedIterator` directly for `RepeatN`)
 - #128551 (chore: refactor backtrace style in panic)
 - #128573 (Simplify `body` usage in rustdoc)
 - #128581 (Assert that all attributes are actually checked via `CheckAttrVisitor` and aren't accidentally usable on completely unrelated HIR nodes)
 - #128603 (Update run-make/used to use `any_symbol_contains`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-03 21:19:42 +00:00
Matthias Krüger
0655ed234f
Rollup merge of #128603 - ChrisDenton:used, r=jieyouxu
Update run-make/used to use `any_symbol_contains`

This makes it so we don't need `nm` or `llvm-nm`.

I also tested that `BAR` is removed. I'm not sure if this is wanted though.
2024-08-03 20:51:54 +02:00
Matthias Krüger
3a9d432589
Rollup merge of #128581 - jieyouxu:checked-attr, r=nnethercote
Assert that all attributes are actually checked via `CheckAttrVisitor` and aren't accidentally usable on completely unrelated HIR nodes

``@oli-obk's`` #128444 with unreachable case removed to avoid that PR bitrotting away.
Based on #128402.

This PR will make adding a new attribute ICE on any use of that attribute unless it gets a handler added in `rustc_passes::CheckAttrVisitor`.

r? ``@nnethercote`` (since you were the reviewer of the original PR)
2024-08-03 20:51:54 +02:00
Matthias Krüger
53a56190af
Rollup merge of #128530 - scottmcm:repeat-n-unchecked, r=joboet
Implement `UncheckedIterator` directly for `RepeatN`

This just pulls the code out of `next` into `next_unchecked`, rather than making the `Some` and `unwrap_unchecked`ing it.

And while I was touching it, I added a codegen test that `array::repeat` for something that's just `Clone`, not `Copy`, still ends up optimizing to the same thing as `[x; n]`: <https://rust.godbolt.org/z/YY3a5ajMW>.
2024-08-03 20:51:52 +02:00
Matthias Krüger
7d9ed2a864
Rollup merge of #127921 - spastorino:stabilize-unsafe-extern-blocks, r=compiler-errors
Stabilize unsafe extern blocks (RFC 3484)

# Stabilization report

## Summary

This is a tracking issue for the RFC 3484: Unsafe Extern Blocks

We are stabilizing `#![feature(unsafe_extern_blocks)]`, as described in [Unsafe Extern Blocks RFC 3484](https://github.com/rust-lang/rfcs/pull/3484). This feature makes explicit that declaring an extern block is unsafe. Starting in Rust 2024, all extern blocks must be marked as unsafe. In all editions, items within unsafe extern blocks may be marked as safe to use.

RFC: https://github.com/rust-lang/rfcs/pull/3484
Tracking issue: #123743

## What is stabilized

### Summary of stabilization

We now need extern blocks to be marked as unsafe and items inside can also have safety modifiers (unsafe or safe), by default items with no modifiers are unsafe to offer easy migration without surprising results.

```rust
unsafe extern {
    // sqrt (from libm) may be called with any `f64`
    pub safe fn sqrt(x: f64) -> f64;

    // strlen (from libc) requires a valid pointer,
    // so we mark it as being an unsafe fn
    pub unsafe fn strlen(p: *const c_char) -> usize;

    // this function doesn't say safe or unsafe, so it defaults to unsafe
    pub fn free(p: *mut core::ffi::c_void);

    pub safe static IMPORTANT_BYTES: [u8; 256];

    pub safe static LINES: SyncUnsafeCell<i32>;
}
```

## Tests

The relevant tests are in `tests/ui/rust-2024/unsafe-extern-blocks`.

## History

- https://github.com/rust-lang/rust/pull/124482
- https://github.com/rust-lang/rust/pull/124455
- https://github.com/rust-lang/rust/pull/125077
- https://github.com/rust-lang/rust/pull/125522
- https://github.com/rust-lang/rust/issues/126738
- https://github.com/rust-lang/rust/issues/126749
- https://github.com/rust-lang/rust/issues/126755
- https://github.com/rust-lang/rust/pull/126757
- https://github.com/rust-lang/rust/pull/126758
- https://github.com/rust-lang/rust/issues/126756
- https://github.com/rust-lang/rust/pull/126973
- https://github.com/rust-lang/rust/pull/127535
- https://github.com/rust-lang/rustfmt/pull/6204

## Unresolved questions

I am not aware of any unresolved questions.
2024-08-03 20:51:51 +02:00
bors
bbf60c897e Auto merge of #127324 - DianQK:match-br, r=cjgillot
Simplify match based on the cast result of `IntToInt`

Continue to complete #124150. The condition in #120614 is wrong, e.g. `-1i8` cannot be converted to `255i16`. I've rethought the issue and simplified the conditional judgment for a more straightforward approach. The new approach is to check **if the case value after the `IntToInt` conversion equals the target value**.

In different types, `IntToInt` uses different casting methods. This rule is as follows:

- `i8`/`u8` to `i8`/`u8`: do nothing.
- `i8` to `i16`/`u16`: sign extension.
- `u8` to `i16`/`u16`: zero extension.
- `i16`/`u16` to `i8`/`u8`: truncate to the target size.

The previous error was a mix of zext and sext.

r? mir-opt
2024-08-03 18:48:30 +00:00
clubby789
8497800abd Add test for updating enum discriminant through pointer 2024-08-03 16:41:49 +00:00
Chris Denton
f28d157091
Update rmake.rs 2024-08-03 16:04:37 +00:00
Chris Denton
c2523c9543
Use object in run-make/symbols-visibility 2024-08-03 14:56:16 +00:00
bors
1f47624f9a Auto merge of #128404 - compiler-errors:revert-dead-code-changes, r=pnkfelix
Revert recent changes to dead code analysis

This is a revert to recent changes to dead code analysis, namely:
* efdf219 Rollup merge of #128104 - mu001999-contrib:fix/128053, r=petrochenkov
* a70dc297a8 Rollup merge of #127017 - mu001999-contrib:dead/enhance, r=pnkfelix
* 31fe9628cf Rollup merge of #127107 - mu001999-contrib:dead/enhance-2, r=pnkfelix
* 2724aeaaeb Rollup merge of #126618 - mu001999-contrib:dead/enhance, r=pnkfelix
* 977c5fd419 Rollup merge of #126315 - mu001999-contrib:fix/126289, r=petrochenkov
* 13314df21b Rollup merge of #125572 - mu001999-contrib:dead/enhance, r=pnkfelix

There is an additional change stacked on top, which suppresses false-negatives that were masked by this work. I believe the functions that are touched in that code are legitimately unused functions and the types are not reachable since this `AnonPipe` type is not publically reachable -- please correct me if I'm wrong cc `@NobodyXu` who added these in ##127153.

Some of these reverts (#126315 and #126618) are only included because it makes the revert apply cleanly, and I think these changes were only done to fix follow-ups from the other PRs?

I apologize for the size of the PR and the churn that it has on the codebase (and for reverting `@mu001999's` work here), but I'm putting this PR up because I am concerned that we're making ad-hoc changes to fix bugs that are fallout of these PRs, and I'd like to see these changes reimplemented in a way that's more separable from the existing dead code pass. I am happy to review any code to reapply these changes in a more separable way.

cc `@mu001999`
r? `@pnkfelix`

Fixes #128272
Fixes #126169
2024-08-03 13:04:30 +00:00
Chris Denton
eb451464a7
Remove BAR for run-make/used.rs 2024-08-03 13:02:32 +00:00
Chris Denton
b564b70d1c
Update run-make/used to use any_symbol_contains 2024-08-03 12:40:53 +00:00