Commit Graph

29304 Commits

Author SHA1 Message Date
Jubilee
577f86dacd
Rollup merge of #117259 - dtolnay:macho, r=Nilstrieb
Declare rustc_target's dependency on object/macho

Without this, `cargo check` fails in crates that depend on rustc_target.

<details>
<summary>`cargo check` diagnostics</summary>

```console
    Checking rustc_target v0.0.0
error[E0433]: failed to resolve: could not find `macho` in `object`
   --> compiler/rustc_target/src/spec/apple_base.rs:176:17
    |
176 |         object::macho::PLATFORM_MACOS => Some((13, 1)),
    |                 ^^^^^ could not find `macho` in `object`

error[E0433]: failed to resolve: could not find `macho` in `object`
   --> compiler/rustc_target/src/spec/apple_base.rs:177:17
    |
177 |         object::macho::PLATFORM_IOS
    |                 ^^^^^ could not find `macho` in `object`

error[E0433]: failed to resolve: could not find `macho` in `object`
   --> compiler/rustc_target/src/spec/apple_base.rs:178:19
    |
178 |         | object::macho::PLATFORM_IOSSIMULATOR
    |                   ^^^^^ could not find `macho` in `object`

error[E0433]: failed to resolve: could not find `macho` in `object`
   --> compiler/rustc_target/src/spec/apple_base.rs:179:19
    |
179 |         | object::macho::PLATFORM_TVOS
    |                   ^^^^^ could not find `macho` in `object`

error[E0433]: failed to resolve: could not find `macho` in `object`
   --> compiler/rustc_target/src/spec/apple_base.rs:180:19
    |
180 |         | object::macho::PLATFORM_TVOSSIMULATOR
    |                   ^^^^^ could not find `macho` in `object`

error[E0433]: failed to resolve: could not find `macho` in `object`
   --> compiler/rustc_target/src/spec/apple_base.rs:181:19
    |
181 |         | object::macho::PLATFORM_MACCATALYST => Some((16, 2)),
    |                   ^^^^^ could not find `macho` in `object`

error[E0433]: failed to resolve: could not find `macho` in `object`
   --> compiler/rustc_target/src/spec/apple_base.rs:182:17
    |
182 |         object::macho::PLATFORM_WATCHOS | object::macho::PLATFORM_WATCHOSSIMULATOR => Some((9, 1)),
    |                 ^^^^^ could not find `macho` in `object`

error[E0433]: failed to resolve: could not find `macho` in `object`
   --> compiler/rustc_target/src/spec/apple_base.rs:182:51
    |
182 |         object::macho::PLATFORM_WATCHOS | object::macho::PLATFORM_WATCHOSSIMULATOR => Some((9, 1)),
    |                                                   ^^^^^ could not find `macho` in `object`

error[E0433]: failed to resolve: could not find `macho` in `object`
   --> compiler/rustc_target/src/spec/apple_base.rs:189:33
    |
189 |         ("macos", _) => object::macho::PLATFORM_MACOS,
    |                                 ^^^^^ could not find `macho` in `object`

error[E0433]: failed to resolve: could not find `macho` in `object`
   --> compiler/rustc_target/src/spec/apple_base.rs:190:38
    |
190 |         ("ios", "macabi") => object::macho::PLATFORM_MACCATALYST,
    |                                      ^^^^^ could not find `macho` in `object`

error[E0433]: failed to resolve: could not find `macho` in `object`
   --> compiler/rustc_target/src/spec/apple_base.rs:191:35
    |
191 |         ("ios", "sim") => object::macho::PLATFORM_IOSSIMULATOR,
    |                                   ^^^^^ could not find `macho` in `object`

error[E0433]: failed to resolve: could not find `macho` in `object`
   --> compiler/rustc_target/src/spec/apple_base.rs:192:31
    |
192 |         ("ios", _) => object::macho::PLATFORM_IOS,
    |                               ^^^^^ could not find `macho` in `object`

error[E0433]: failed to resolve: could not find `macho` in `object`
   --> compiler/rustc_target/src/spec/apple_base.rs:193:39
    |
193 |         ("watchos", "sim") => object::macho::PLATFORM_WATCHOSSIMULATOR,
    |                                       ^^^^^ could not find `macho` in `object`

error[E0433]: failed to resolve: could not find `macho` in `object`
   --> compiler/rustc_target/src/spec/apple_base.rs:194:35
    |
194 |         ("watchos", _) => object::macho::PLATFORM_WATCHOS,
    |                                   ^^^^^ could not find `macho` in `object`

error[E0433]: failed to resolve: could not find `macho` in `object`
   --> compiler/rustc_target/src/spec/apple_base.rs:195:36
    |
195 |         ("tvos", "sim") => object::macho::PLATFORM_TVOSSIMULATOR,
    |                                    ^^^^^ could not find `macho` in `object`

error[E0433]: failed to resolve: could not find `macho` in `object`
   --> compiler/rustc_target/src/spec/apple_base.rs:196:32
    |
196 |         ("tvos", _) => object::macho::PLATFORM_TVOS,
    |                                ^^^^^ could not find `macho` in `object`
```
</details>

`rustc_target` unconditionally contains its `spec` module (i.e. there is no `#[cfg]` on the `mod spec;`). The `spec/mod.rs` also does not start with `#![cfg]`.

aa91057796/compiler/rustc_target/src/lib.rs (L37)

Similarly, the `spec` module unconditionally contains `apple_base`.

aa91057796/compiler/rustc_target/src/spec/mod.rs (L62)

And, `apple_base` unconditionally refers to `object::macho`.

aa91057796/compiler/rustc_target/src/spec/apple_base.rs (L176)

So I figure there is no way `object::macho` isn't needed by rustc.

`object::macho` only exists if the `object` crate's "macho" feature is enabled. https://github.com/gimli-rs/object/blob/0.32.0/src/lib.rs#L111-L112
2023-10-28 17:10:30 -07:00
Jubilee
78b04b54f8
Rollup merge of #117170 - he32:netbsd-i586, r=bjorn3
Add support for i586-unknown-netbsd as target.

This restricts instructions to those offered by Pentium, to support e.g. AMD Geode.

There is already an entry for this target in the NetBSD platform support page at

  src/doc/rustc/src/platform-support/netbsd.md

...so this should forestall its removal.

Additional fixes are needed for some vendored modules, this is the changes in the rust compiler core itself.
2023-10-28 17:10:29 -07:00
bors
6b78377245 Auto merge of #117123 - Zalathar:bad-counter-ids, r=petrochenkov
coverage: Consistently remove unused counter IDs from expressions/mappings

If some coverage counters were removed by MIR optimizations, we need to take care not to refer to those counter IDs in coverage mappings, and instead replace them with a constant zero value. If we don't, `llvm-cov` might see a too-large counter ID and silently discard the entire function from its coverage reports.

Fixes #117012.
2023-10-28 17:43:07 +00:00
bors
6a66ca215b Auto merge of #81746 - bjorn3:cg_clif_rustup_component, r=Mark-Simulacrum
Distribute cg_clif as rustup component on the nightly channel

This makes it possible to use cg_clif using:

```bash
$ rustup component add rustc-codegen-cranelift-preview --toolchain nightly
$ RUSTFLAGS="-Zcodegen-backend=cranelift" cargo +nightly build
```

cc https://github.com/rust-lang/compiler-team/issues/405.
r? `@Mark-Simulacrum`
2023-10-28 15:16:27 +00:00
Havard Eidnes
a510288f0a i586_unknown_netbsd.rs: drop "-m32" flag insertion to gcc.
This triggers a consistency check in rust (that all linker flavours
must have identical arguments), and on NetBSD/i386, the 32-bitness
is implicitly chosen through the chosen toolchain, and appears to
not be required.  So drop it, and also drop the imports of the
now-no-longer-used identifiers.
2023-10-28 12:14:30 +00:00
bors
3089c315b1 Auto merge of #116609 - eduardosm:bump-stdarch, r=workingjubilee
Bump stdarch submodule and remove special handling for LLVM intrinsics that are no longer needed

Bumps stdarch to pull https://github.com/rust-lang/stdarch/pull/1477, which reimplemented some functions with portable SIMD intrinsics instead of arch specific LLVM intrinsics.

Handling of those LLVM intrinsics is removed from cranelift codegen and miri.

cc `@RalfJung` `@bjorn3`
2023-10-28 11:26:34 +00:00
Jubilee
09fd68d9ee
Rollup merge of #117277 - RalfJung:too-big-with-padding, r=oli-obk
fix failure to detect a too-big-type after adding padding

Fixes https://github.com/rust-lang/rust/issues/117265
2023-10-28 01:07:39 -07:00
Jubilee
48a3865218
Rollup merge of #117268 - nnethercote:rustc_interface, r=oli-obk
`rustc_interface` cleanups

Particularly in and around `--cfg` and `--check-cfg` handling.

r? `@oli-obk`
2023-10-28 01:07:38 -07:00
Jubilee
1db8c9d6e2
Rollup merge of #117256 - dtolnay:currentversion, r=compiler-errors
Parse rustc version at compile time

This PR eliminates a couple awkward codepaths where it was not clear how the compiler should proceed if its own version number is incomprehensible.

dab715641e/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs (L385)

dab715641e/compiler/rustc_attr/src/builtin.rs (L630)

We can guarantee that every compiled rustc comes with a working version number, so the ICE codepaths above shouldn't need to be written.
2023-10-28 01:07:38 -07:00
Jubilee
87a564d271
Rollup merge of #117025 - Urgau:cleanup-improve-check-cfg-impl, r=petrochenkov
Cleanup and improve `--check-cfg` implementation

This PR removes some indentation in the code, as well as preventing some bugs/misusages and fix a nit in the doc.

r? ```@petrochenkov``` (maybe)
2023-10-28 01:07:37 -07:00
Jubilee
9f631d0c23
Rollup merge of #116945 - estebank:sealed-trait-impls, r=petrochenkov
When encountering sealed traits, point types that implement it

```
error[E0277]: the trait bound `S: d::Hidden` is not satisfied
  --> $DIR/sealed-trait-local.rs:53:20
   |
LL | impl c::Sealed for S {}
   |                    ^ the trait `d::Hidden` is not implemented for `S`
   |
note: required by a bound in `c::Sealed`
  --> $DIR/sealed-trait-local.rs:17:23
   |
LL |     pub trait Sealed: self::d::Hidden {
   |                       ^^^^^^^^^^^^^^^ required by this bound in `Sealed`
   = note: `Sealed` is a "sealed trait", because to implement it you also need to implement `c::d::Hidden`, which is not accessible; this is usually done to force you to use one of the provided types that already implement it
   = help: the following types implement the trait:
            - c::X
            - c::Y
```

The last `help` is new.
2023-10-28 01:07:37 -07:00
Jubilee
471e33f907
Rollup merge of #116739 - Milo123459:milo/short-paths, r=estebank
Make `E0277` use short paths

Fixes #116616
2023-10-28 01:07:36 -07:00
Jubilee
975d042d4c
Rollup merge of #116534 - cjgillot:no-dep-tasks, r=davidtwco
Remove -Zdep-tasks.

This option is not useful any more, we can use `tracing` and `RUSTC_LOG` to debug the dep-graph.
2023-10-28 01:07:35 -07:00
bors
17659c71ba Auto merge of #117253 - antoyo:subtree-update_cg_gcc_2023-10-25, r=bjorn3,GuillaumeGomez
subtree update cg_gcc 2023/10/25
2023-10-28 04:57:15 +00:00
Zalathar
230dd5b8c7 coverage: Consistently remove unused counter IDs from expressions/mappings 2023-10-28 09:33:48 +11:00
Nicholas Nethercote
5438004766 Change Cfg<T> to an FxIndexSet.
Despite what I claimed in an earlier commit, the ordering does matter to
some degree. Using `FxIndexSet` prevents changes to the error message
order in `tests/ui/check-cfg/mix.rs`.
2023-10-28 09:24:32 +11:00
Nicholas Nethercote
5e54997157 Clean up config mess.
`parse_cfgspecs` and `parse_check_cfg` run very early, before the main
interner is running. They each use a short-lived interner and convert
all interned symbols to strings in their output data structures. Once
the main interner starts up, these data structures get converted into
new data structures that are identical except with the strings converted
to symbols.

All is not obvious from the current code, which is a mess, particularly
with inconsistent naming that obscures the parallel string/symbol data
structures. This commit clean things up a lot.

- The existing `CheckCfg` type is generic, allowing both
  `CheckCfg<String>` and `CheckCfg<Symbol>` forms. This is really
  useful, but it defaults to `String`. The commit removes the default so
  we have to use `CheckCfg<String>` and `CheckCfg<Symbol>` explicitly,
  which makes things clearer.

- Introduces `Cfg`, which is generic over `String` and `Symbol`, similar
  to `CheckCfg`.

- Renames some things.
  - `parse_cfgspecs` -> `parse_cfg`
  - `CfgSpecs` -> `Cfg<String>`, plus it's used in more places, rather
    than the underlying `FxHashSet` type.
  - `CrateConfig` -> `Cfg<Symbol>`.
  - `CrateCheckConfig` -> `CheckCfg<Symbol>`

- Adds some comments explaining the string-to-symbol conversions.

- `to_crate_check_config`, which converts `CheckCfg<String>` to
  `CheckCfg<Symbol>`, is inlined and removed and combined with the
  overly-general `CheckCfg::map_data` to produce
  `CheckCfg::<String>::intern`.

- `build_configuration` now does the `Cfg<String>`-to-`Cfg<Symbol>`
  conversion, so callers don't need to, which removes the need for
  `to_crate_config`.

The diff for two of the fields in `Config` is a good example of the
improved clarity:
```
-    pub crate_cfg: FxHashSet<(String, Option<String>)>,
-    pub crate_check_cfg: CheckCfg,
+    pub crate_cfg: Cfg<String>,
+    pub crate_check_cfg: CheckCfg<String>,
```
Compare that with the diff for the corresponding fields in `ParseSess`,
and the relationship to `Config` is much clearer than before:
```
-    pub config: CrateConfig,
-    pub check_config: CrateCheckConfig,
+    pub config: Cfg<Symbol>,
+    pub check_config: CheckCfg<Symbol>,
```
2023-10-28 09:03:51 +11:00
Nicholas Nethercote
75e415ba86 Optimize parse_cfgspecs.
In `parse_cfg`, we now construct a `FxHashSet<String>` directly instead of
constructing a `FxHashSet<Symbol>` and then immediately converting it to a
`FxHashSet<String>`(!)

(The type names made this behaviour non-obvious. The next commit will
make the type names clearer.)
2023-10-28 09:03:51 +11:00
Nicholas Nethercote
32986d895f Change CrateConfig from FxIndexSet to FxHashSet.
Because its order doesn't matter. This is well demonstrated by
`to_crate_config`, which creates a `CrateConfig` from an `FxHashSet`.
2023-10-28 09:03:51 +11:00
Nicholas Nethercote
2142d014ab Streamline rustc_interface tests.
In `test_edition_parsing`, change the
`build_session_options_and_crate_config` call to
`build_session_options`, because the config isn't used.

That leaves a single call site for
`build_session_options_and_crate_config`, so just inline and remove it.
2023-10-28 09:03:51 +11:00
Nicholas Nethercote
3feec48d70 Fix a comment. 2023-10-28 09:03:51 +11:00
Nicholas Nethercote
98c469ce93 Remove an unneeded dependency. 2023-10-28 09:03:51 +11:00
bors
2f1bd0729b Auto merge of #117294 - matthiaskrgr:rollup-xylsec7, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #116834 (Remove `rustc_symbol_mangling/messages.ftl`.)
 - #117212 (Properly restore snapshot when failing to recover parsing ternary)
 - #117246 (Fix ICE: Restrict param constraint suggestion)
 - #117247 (NVPTX: Allow PassMode::Direct for ptx kernels for now)
 - #117270 (Hide internal methods from documentation)
 - #117281 (std::thread : add SAFETY comment)
 - #117287 (fix miri target information for Test step)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-27 21:11:52 +00:00
Antoni Boucher
f0aaf2ff11 Merge commit '09ce29d0591a21e1abae22eac4d41ffd32993af8' into subtree-update_cg_gcc_2023-10-25 2023-10-27 16:07:01 -04:00
Milo
a65d99d087
Update type_err_ctxt_ext.rs
Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2023-10-27 20:14:49 +01:00
bors
59bb9505bc Auto merge of #103208 - cjgillot:match-fake-read, r=oli-obk,RalfJung
Allow partially moved values in match

This PR attempts to unify the behaviour between `let _ = PLACE`, `let _: TY = PLACE;` and `match PLACE { _ => {} }`.
The logical conclusion is that the `match` version should not check for uninitialised places nor check that borrows are still live.

The `match PLACE {}` case is handled by keeping a `FakeRead` in the unreachable fallback case to verify that `PLACE` has a legal value.

Schematically, `match PLACE { arms }` in surface rust becomes in MIR:
```rust
PlaceMention(PLACE)
match PLACE {
  // Decision tree for the explicit arms
  arms,
  // An extra fallback arm
  _ => {
    FakeRead(ForMatchedPlace, PLACE);
    unreachable
  }
}
```

`match *borrow { _ => {} }` continues to check that `*borrow` is live, but does not read the value.
`match *borrow {}` both checks that `*borrow` is live, and fake-reads the value.

Continuation of ~https://github.com/rust-lang/rust/pull/102256~ ~https://github.com/rust-lang/rust/pull/104844~

Fixes https://github.com/rust-lang/rust/issues/99180 https://github.com/rust-lang/rust/issues/53114
2023-10-27 18:51:43 +00:00
Matthias Krüger
c3d56be6b6
Rollup merge of #117247 - kjetilkjeka:nvptx_direct_passmode_exception, r=workingjubilee,RalfJung
NVPTX: Allow PassMode::Direct for ptx kernels for now

Upgrading the nvptx toolchain to the newest nightly makes it hit the assert that links to https://github.com/rust-lang/rust/issues/115666

It seems like most targets get around this by using `PassMode::Indirect`. That is impossible for the kernel as it's not a normal call, but instead the arguments are copied from CPU to GPU and the passed pointer would be invalid when it reached the GPU.

I also made an experiment with `PassMode::Cast` but at least the most simple version of this broke the assembly API tests.

I added  fixing the pass mode in my unofficial tracking issue list (I do not have the necessary permissions to update to official one). https://github.com/rust-lang/rust/issues/38788#issuecomment-1079021853

Since the ptx_abi is currently unstable and have been working with `PassMode::Direct` for more than a year now, the steps above is hopefully sufficient to enable it as an exception until I can prioritize to fix it. I'm currently looking at steps to enable the CI for nvptx64 again and would prefer to finish that first.
2023-10-27 19:46:09 +02:00
Matthias Krüger
a77f743239
Rollup merge of #117246 - estebank:issue-117209, r=petrochenkov
Fix ICE: Restrict param constraint suggestion

When encountering an associated item with a type param that could be constrained, do not look at the parent item if the type param comes from the associated item.

Fix #117209, fix #89868.
2023-10-27 19:46:08 +02:00
Matthias Krüger
b2295375f8
Rollup merge of #117212 - clubby789:fix-ternary-recover, r=compiler-errors
Properly restore snapshot when failing to recover parsing ternary

If the recovery parsed an expression, then failed to eat a `:`, it would return `false` without restoring the snapshot. Fix this by always restoring the snapshot when returning `false`.

Draft for now because I'd like to try and improve this recovery further.

Fixes #117208
2023-10-27 19:46:07 +02:00
Matthias Krüger
df8852a934
Rollup merge of #116834 - nnethercote:rustc_symbol_mangling, r=davidtwco
Remove `rustc_symbol_mangling/messages.ftl`.

It contains a single message that (a) doesn't contain any natural language, and (b) is only used in tests.

r? `@davidtwco`
2023-10-27 19:46:06 +02:00
Esteban Küber
6dbad23641 When encountering sealed traits, point types that implement it
```
error[E0277]: the trait bound `S: d::Hidden` is not satisfied
  --> $DIR/sealed-trait-local.rs:53:20
   |
LL | impl c::Sealed for S {}
   |                    ^ the trait `d::Hidden` is not implemented for `S`
   |
note: required by a bound in `c::Sealed`
  --> $DIR/sealed-trait-local.rs:17:23
   |
LL |     pub trait Sealed: self::d::Hidden {
   |                       ^^^^^^^^^^^^^^^ required by this bound in `Sealed`
   = note: `Sealed` is a "sealed trait", because to implement it you also need to implement `c::d::Hidden`, which is not accessible; this is usually done to force you to use one of the provided types that already implement it
   = help: the following types implement the trait:
            - c::X
            - c::Y
```

The last `help` is new.
2023-10-27 17:40:52 +00:00
Esteban Küber
7449478c2f Account for type param from other item in note_and_explain
Fix #89868.
2023-10-27 16:24:01 +00:00
Ralf Jung
2ef5897a89 fix failure to detect a too-big-type after adding padding 2023-10-27 18:07:53 +02:00
bors
10143e781b Auto merge of #117166 - oli-obk:mir_const_qualif_perf, r=petrochenkov
Only call `mir_const_qualif` if absolutely necessary

Pull the perf change out of https://github.com/rust-lang/rust/pull/113617

This should not have any impact on behaviour (if it does, we'll see an ICE)
2023-10-27 16:06:02 +00:00
bors
9d6d5d4894 Auto merge of #116751 - Nadrieril:lint-overlap-per-column, r=davidtwco
Lint overlapping ranges as a separate pass

This reworks the [`overlapping_range_endpoints`](https://doc.rust-lang.org/beta/nightly-rustc/rustc_lint_defs/builtin/static.OVERLAPPING_RANGE_ENDPOINTS.html) lint. My motivations are:

- It was annoying to have this lint entangled with the exhaustiveness algorithm, especially wrt librarification;
- This makes the lint behave consistently.

Here's the consistency story. Take the following matches:
```rust
match (0u8, true) {
    (0..=10, true) => {}
    (10..20, true) => {}
    (10..20, false) => {}
    _ => {}
}
match (true, 0u8) {
    (true, 0..=10) => {}
    (true, 10..20) => {}
    (false, 10..20) => {}
    _ => {}
}
```
There are two semantically consistent options: option 1 we lint all overlaps between the ranges, option 2 we only lint the overlaps that could actually occur (i.e. the ones with `true`). Option 1 is what this PR does. Option 2 is possible but would require the exhaustiveness algorithm to track more things for the sake of the lint. The status quo is that we're inconsistent between the two.

Option 1 generates more false postives, but I prefer it from a maintainer's perspective. I do think the difference is minimal; cases where the difference is observable seem rare.

This PR adds a separate pass, so this will have a perf impact. Let's see how bad, it looked ok locally.
2023-10-27 14:10:42 +00:00
bors
688892938e Auto merge of #116858 - estebank:issue-22488, r=petrochenkov
Suggest assoc fn `new` when trying to build tuple struct with private fields

Fix #22488.
2023-10-27 12:16:01 +00:00
bjorn3
d89582c8e5 Update target-lexicon to 0.12.12
This adds support for loongarch and a bunch of other targets
2023-10-27 11:56:39 +00:00
bjorn3
344752ab53 Update Cranelift to 0.101.2 and disable host-arch feature of cranelift-codegen
This ensures that cg_clif can be built for targets that aren't natively
supported by Cranelift. It will not be possible to compile for the host
in this case, but cross-compilation will still be possible.

We won't distribute cg_clif as rustup component for any targets that
aren't natively supported by Cranelift, but will still build it if
codegen-backends lists "cranelift".
2023-10-27 11:56:39 +00:00
bors
95f6a01e8f Auto merge of #117272 - matthiaskrgr:rollup-upg122z, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #114998 (feat(docs): add cargo-pgo to PGO documentation 📝)
 - #116868 (Tweak suggestion span for outer attr and point at item following invalid inner attr)
 - #117240 (Fix documentation typo in std::iter::Iterator::collect_into)
 - #117241 (Stash and cancel cycle errors for auto trait leakage in opaques)
 - #117262 (Create a new ConstantKind variant (ZeroSized) for StableMIR)
 - #117266 (replace transmute by raw pointer cast)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-27 10:19:35 +00:00
Urgau
84a1a689cc Better guard against wrong input with check-cfg any() 2023-10-27 12:02:54 +02:00
Matthias Krüger
33744804fe
Rollup merge of #117262 - celinval:issue-38-norm, r=oli-obk
Create a new ConstantKind variant (ZeroSized) for StableMIR

ZeroSized constants can be represented as `mir::Const::Val` even if their layout is not yet known. In those cases, CrateItem::body() was crashing when trying to convert a `ConstValue::ZeroSized` into its stable counterpart  `ConstantKind::Allocated`.

Instead, we now map `ConstValue::ZeroSized` into a new variant: `ConstantKind::ZeroSized`.

**Note:** I didn't add any new test here since we already have covering tests in our project repository which I manually confirmed that will fix the issue.
2023-10-27 11:48:07 +02:00
Matthias Krüger
5459333ffc
Rollup merge of #117241 - compiler-errors:auto-trait-leak-cycle, r=oli-obk
Stash and cancel cycle errors for auto trait leakage in opaques

We don't need to emit a traditional cycle error when we have a selection error that explains what's going on but in more detail.

We may want to augment this error to actually point out the cycle, now that the cycle error is not being emitted. We could do that by storing the set of opaques that was in the `CyclePlaceholder` that gets returned from `type_of_opaque`.

r? `@oli-obk` cc `@estebank` #117235
2023-10-27 11:48:06 +02:00
Matthias Krüger
a69fb480a4
Rollup merge of #116868 - estebank:suggestion, r=petrochenkov
Tweak suggestion span for outer attr and point at item following invalid inner attr

After:

```
error: `unix_sigpipe` attribute cannot be used at crate level
  --> $DIR/unix_sigpipe-crate.rs:2:1
   |
LL | #![unix_sigpipe = "inherit"]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL |
LL | fn main() {}
   | ------------ the inner attribute doesn't annotate this function
   |
help: perhaps you meant to use an outer attribute
   |
LL - #![unix_sigpipe = "inherit"]
LL + #[unix_sigpipe = "inherit"]
   |
```

Before:

```
error: `unix_sigpipe` attribute cannot be used at crate level
  --> $DIR/unix_sigpipe-crate.rs:2:1
   |
LL | #![unix_sigpipe = "inherit"]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
help: perhaps you meant to use an outer attribute
   |
LL | #[unix_sigpipe = "inherit"]
   | ~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

CC #89566.
2023-10-27 11:48:05 +02:00
Kjetil Kjeka
bb45c812e0 Link to correct issue in PassMode::Direct ptx-kernel exception 2023-10-27 11:39:20 +02:00
Havard Eidnes
0f04e2dd8f For i586/NetBSD: fix another formatting insistence. 2023-10-27 09:37:25 +00:00
bors
54e57e66ff Auto merge of #116205 - WaffleLapkin:stabilize_pointer_byte_offsets, r=dtolnay
Stabilize `[const_]pointer_byte_offsets`

Closes #96283
Awaiting FCP completion: https://github.com/rust-lang/rust/issues/96283#issuecomment-1735835331

r? libs-api
2023-10-27 08:24:54 +00:00
Havard Eidnes
893e726637 i586_unknown_netbsd.rs: fix formatting.
This hopefully fixes the CI run after integration of this
target.
2023-10-27 07:25:01 +00:00
Celina G. Val
613e6181a6 Specialize ZeroSized constants
ZeroSized constants can be represented as `mir::Const::Val` even if
their layout is not yet known. In those cases, CrateItem::body() was
crashing when trying to convert a `ConstValue::ZeroSized` into its
stable counterpart `ConstantKind::Allocated`.

Instead, we now map `ConstValue::ZeroSized` into a new variant:
`ConstantKind::ZeroSized`.
2023-10-26 20:17:44 -07:00
Nadrieril
3fa2e71ce1 Handle ty::Opaque correctly 2023-10-27 05:16:26 +02:00
Nadrieril
d5070e32ea Lint overlapping ranges as a separate pass 2023-10-27 05:16:26 +02:00