Commit Graph

270500 Commits

Author SHA1 Message Date
Matthias Krüger
6e05afd744
Rollup merge of #132745 - RalfJung:pointee-info-inside-enum, r=DianQK
pointee_info_at: fix logic for recursing into enums

Fixes https://github.com/rust-lang/rust/issues/131834

The logic in `pointee_info_at` was likely written at a time when the null pointer optimization was the *only* enum layout optimization -- and as `Variant::Multiple` kept getting expanded, nobody noticed that the logic is now unsound.

The job of this function is to figure out whether there is a dereferenceable-or-null and aligned pointer at a given offset inside a type. So when we recurse into a multi-variant enum, we better make sure that all the other enum variants must be null! This is the part that was forgotten, and this PR adds it.

The reason this didn't explode in many ways so far is that our references only have 1 niche value (null), so it's not possible on stable to have a multi-variant enum with a dereferenceable pointer and other enum variants that are not null. But with `rustc_layout_scalar_valid_range` attributes one can force such a layout, and if `@the8472's` work on alignment niches ever lands, that will make this possible on stable.
2024-11-09 10:52:03 +01:00
Matthias Krüger
b9d4ef16c9
Rollup merge of #132552 - taiki-e:sparc-target-feature, r=workingjubilee
Add v9, v8plus, and leoncasa target feature to sparc and use v8plus in create_object_file

This adds the following three unstable target features:

- `v9`: SPARC-V9 instructions ([LLVM definition][sparc-v9])
  - Relevant to https://github.com/rust-lang/rust/pull/131222#issuecomment-2453310963
  - Relevant to https://github.com/rust-lang/rust/pull/132472#discussion_r1832606081
  - This is also needed to implement https://github.com/taiki-e/atomic-maybe-uninit/pull/31 (depends on inline assembly support) more robustly.
- `v8plus`: SPARC-V8+ ABI ([LLVM definition][sparc-v8plus])
  - This is added in LLVM 20. In LLVM 19 and older, it is emulated to work the same way as LLVM in each LLVM version.
  - See https://github.com/rust-lang/rust/issues/132585#issuecomment-2453926257 for more.
- `leoncasa`: CASA instruction[^1] of LEON3 and LEON4 processors ([LLVM definition][sparc-leoncasa], LLVM feature name: `hasleoncasa`)
  - This is needed to implement https://github.com/taiki-e/atomic-maybe-uninit/pull/31 (depends on inline assembly support) more robustly.

[^1]: Atomic CAS instruction

[sparc-v9]: f5e4ffaa49/llvm/lib/Target/Sparc/Sparc.td (L37-L39)
[sparc-v8plus]: f5e4ffaa49/llvm/lib/Target/Sparc/Sparc.td (L37-L39)
[sparc-leoncasa]: https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/Sparc/LeonFeatures.td#L32-L37
2024-11-09 10:52:03 +01:00
bors
62bb2ac03e Auto merge of #132798 - workingjubilee:rollup-qxvmmqo, r=workingjubilee
Rollup of 5 pull requests

Successful merges:

 - #132755 (Do not reveal opaques in the param-env, we got lazy norm instead)
 - #132757 (Get rid of `check_opaque_type_well_formed`)
 - #132760 (Don't suggest `.into_iter()` on iterators)
 - #132778 (update io::Error::into_inner to acknowledge io::Error::other)
 - #132780 (use verbose for path separator suggestion)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-09 07:11:33 +00:00
Jubilee
c4922f12fd
Rollup merge of #132780 - compiler-errors:verbose, r=estebank
use verbose for path separator suggestion

A single `-` of suggestion underlining that is adjacent to a much more significant `^^^` underlying of the LHS path component is hard to distinguish. IMO this presents much more cleanly when it's verbose, especially because it's a *replacment* suggestion.

r? estebank
2024-11-08 20:46:15 -08:00
Jubilee
dc647392d6
Rollup merge of #132778 - lolbinarycat:io-Error-into_inner-docs, r=cuviper
update io::Error::into_inner to acknowledge io::Error::other
2024-11-08 20:46:13 -08:00
Jubilee
b598849941
Rollup merge of #132760 - dianne:iter-into-iter, r=lcnr
Don't suggest `.into_iter()` on iterators

This makes the the suggestion to call `.into_iter()` only consider unsatisfied `Iterator` bounds for the receiver type itself. That way, it ignores predicates generated by trying to auto-ref the receiver (the result of which usually won't implement `Iterator`).

Fixes #127511

Unfortunately, the error in that case is still confusing: it labels `Iterator` as an unsatisfied bound because `&impl Iterator: Iterator` can't be satisfied, despite that not being required or helpful. I'd like to handle that in a separate PR. ~~I'm hoping fixing #124802 will fix it too.~~ It doesn't look connected to that issue. Still, I think it'd be clearest to visually distinguish unsatisfied predicates from different attempts at `pick_method`; I'll make a PR for that soon.
2024-11-08 20:46:12 -08:00
Jubilee
7a4970476e
Rollup merge of #132757 - compiler-errors:yeet-check-wf, r=lcnr
Get rid of `check_opaque_type_well_formed`

Instead, replicate it by improving the span of the opaque in `check_opaque_meets_bounds`.

This has two consequences:
1. We now prefer "concrete type differs" errors, since we'll hit those first before we check the opaque is WF.
2. Spans have gotten slightly worse.

Specifically, (2.) could be improved by adding a new obligation cause that explains that the definition's environment has stronger assumptions than the declaration.

r? lcnr
2024-11-08 20:46:12 -08:00
Jubilee
1077c08ad5
Rollup merge of #132755 - compiler-errors:reveal-param, r=lcnr
Do not reveal opaques in the param-env, we got lazy norm instead

r? lcnr
2024-11-08 20:46:11 -08:00
bors
012ae13d6a Auto merge of #132549 - Zalathar:rust-string, r=cuviper
Make `RustString` an extern type to avoid `improper_ctypes` warnings

Currently, any FFI function that uses `&RustString` needs to also add `#[ignore(improper_ctypes)]` to silence a warning.

The warning is not _completely_ bogus, because `RustString` contains `Vec<u8>` and therefore does not have a guaranteed layout. But we have no way of telling the lint that this doesn't matter, because the C++ code only uses that pointer opaquely and never relies on its underlying layout.

Ideally there would be some way to silence `improper_ctypes` at the type-definition site. But because there isn't, casting to and from a separate extern type is better than having to annotate every single use site.
2024-11-09 04:43:51 +00:00
Michael Goulet
13ab08d7dc Do not reveal opaques in the param-env, we got lazy norm instead 2024-11-09 03:55:07 +00:00
dianne
cea82ed162 Don't suggest .into_iter() on iterators 2024-11-08 17:43:13 -08:00
Zalathar
89d7efaf8f Make RustString an extern type to avoid improper_ctypes warnings 2024-11-09 11:07:44 +11:00
bors
328b759142 Auto merge of #132764 - MikaelUrankar:freebsd_armv7, r=workingjubilee
Drop "gnu" in the target env for FreeBSD armv6/7

FreeBSD is not a GNU system
2024-11-08 21:42:45 +00:00
Taiki Endo
c059eb7750 Add v8plus target feature to sparc and use it in create_object_file 2024-11-09 03:22:09 +09:00
Taiki Endo
400a690b5f Add v9 and leoncasa target feature to sparc 2024-11-09 03:17:24 +09:00
Michael Goulet
0e481b44f5 use verbose for path separator suggestion 2024-11-08 16:58:19 +00:00
bors
59cec72a57 Auto merge of #132746 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update

r? `@Manishearth`
2024-11-08 16:49:13 +00:00
binarycat
b004cac72e update io::Error::into_inner to acknowlage io::Error::other 2024-11-08 10:43:34 -06:00
Zalathar
730626dbd9 Don't use LLVMRustStringWriteImpl outside of RawRustStringOstream 2024-11-08 22:31:32 +11:00
bors
209799f3b9 Auto merge of #132717 - RalfJung:rustc_safe_intrinsic, r=compiler-errors
remove support for rustc_safe_intrinsic attribute; use rustc_intrinsic functions instead

This brings us one step closer towards removing support for `extern "rust-intrinsic"` blocks, in favor of `#[rustc_intrinsic]` functions.

Also move `#[rustc_intrinsic]` under the `intrinsics` feature gate, to match the `extern "rust-intrinsic"` style.
2024-11-08 10:28:47 +00:00
Philipp Krones
0aafd6552b
Clippy: cfg out validate_diag on release builds 2024-11-08 10:49:54 +01:00
Mikael Urankar
f7580c6f48 Drop "gnu" in the target env for FreeBSD armv6/7
FreeBSD is not a GNU system
2024-11-08 09:29:52 +01:00
Ralf Jung
e3010e84db remove support for rustc_safe_intrinsic attribute; use rustc_intrinsic functions instead 2024-11-08 09:16:00 +01:00
bors
6295686a37 Auto merge of #132762 - Zalathar:rollup-qfgz165, r=Zalathar
Rollup of 5 pull requests

Successful merges:

 - #132161 ([StableMIR] A few fixes to pretty printing)
 - #132389 (coverage: Simplify parts of coverage graph creation)
 - #132452 (coverage: Extract safe FFI wrapper functions to `llvm_cov`)
 - #132590 (Simplify FFI calls for `-Ztime-llvm-passes` and `-Zprint-codegen-stats`)
 - #132738 (Initialize channel `Block`s directly on the heap)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-08 08:00:08 +00:00
Stuart Cook
4b904ceb46
Rollup merge of #132738 - cuviper:channel-heap-init, r=ibraheemdev
Initialize channel `Block`s directly on the heap

The channel's `Block::new` was causing a stack overflow because it held
32 item slots, instantiated on the stack before moving to `Box::new`.
The 32x multiplier made modestly-large item sizes untenable.

That block is now initialized directly on the heap.

Fixes #102246

try-job: test-various
2024-11-08 18:51:30 +11:00
Stuart Cook
3a48d80155
Rollup merge of #132590 - Zalathar:z-timings-stats, r=jieyouxu
Simplify FFI calls for `-Ztime-llvm-passes` and `-Zprint-codegen-stats`

The existing code for these unstable LLVM-infodump flags was jumping through hoops to pass an allocated C string across the FFI boundary, when it's much simpler to just write to a `&RustString` instead.
2024-11-08 18:51:30 +11:00
Stuart Cook
758a904764
Rollup merge of #132452 - Zalathar:llvm-cov-wrappers, r=jieyouxu
coverage: Extract safe FFI wrapper functions to `llvm_cov`

This PR takes all of the inline `unsafe` calls in coverage codegen, and all the safe wrapper functions in `coverageinfo/mod.rs`, and moves them to a new `llvm_cov` submodule that is dedicated to safe FFI wrapper functions. This reduces the mixing of abstraction levels in the rest of coverage codegen.

As a follow-up, this PR also tidies up the names and signatures of several of the coverage FFI functions.
2024-11-08 18:51:29 +11:00
Stuart Cook
1b55244aa2
Rollup merge of #132389 - Zalathar:graph-tweaks, r=jieyouxu
coverage: Simplify parts of coverage graph creation

This is a combination of three semi-related simplifications to how coverage graphs are created, grouped into one PR to avoid conflicts.

There are no observable changes to the output of any of the coverage tests.
2024-11-08 18:51:29 +11:00
Stuart Cook
5043c574ac
Rollup merge of #132161 - celinval:smir-fix-indent, r=compiler-errors
[StableMIR] A few fixes to pretty printing

Improve identation, and a few other rvalue printing

try-job: x86_64-msvc
try-job: test-various
2024-11-08 18:51:28 +11:00
Ralf Jung
35a913b968 pointee_info_at: fix logic for recursing into enums 2024-11-08 07:35:29 +01:00
Michael Goulet
97dfe8b871 Manually register some bounds for a better span 2024-11-08 04:56:08 +00:00
Michael Goulet
e4c1a0016c Get rid of check_opaque_type_well_formed 2024-11-08 03:46:27 +00:00
bors
78bb5ee79e Auto merge of #132756 - workingjubilee:rollup-bed2akn, r=workingjubilee
Rollup of 10 pull requests

Successful merges:

 - #130586 (Set "symbol name" in raw-dylib import libraries to the decorated name)
 - #131913 (Add `{ignore,needs}-{rustc,std}-debug-assertions` directive support)
 - #132095 (Fix #131977 parens mangled in shared mut static lint suggestion)
 - #132131 ([StableMIR] API to retrieve definitions from crates)
 - #132639 (core: move intrinsics.rs into intrinsics folder)
 - #132696 (Compile `test_num_f128` conditionally on `reliable_f128_math` config)
 - #132737 (bootstrap: Print better message if lock pid isn't available)
 - #132739 (Fix `librustdoc/scrape_examples.rs` formatting)
 - #132740 (Update test for LLVM 20's new vector splat syntax)
 - #132741 (Update mips64 data layout to match LLVM 20 change)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-08 03:32:51 +00:00
Jubilee
97dbab9124
Rollup merge of #132741 - zmodem:mips_data_layout, r=nikic
Update mips64 data layout to match LLVM 20 change

LLVM changed the data layout in https://github.com/llvm/llvm-project/pull/112084
2024-11-07 18:48:26 -08:00
Jubilee
e2d429e22f
Rollup merge of #132740 - zmodem:simd_syntax_update, r=durin42
Update test for LLVM 20's new vector splat syntax

that was introduced in https://github.com/llvm/llvm-project/pull/112548
2024-11-07 18:48:25 -08:00
Jubilee
a1c4d9e42f
Rollup merge of #132739 - GuillaumeGomez:cleanup-scrape-code, r=notriddle
Fix `librustdoc/scrape_examples.rs` formatting

Still working on the intra-doc link feature. This time I encountered this file and it bothered me a bit so fixing formatting. :3

r? ````@notriddle````
2024-11-07 18:48:25 -08:00
Jubilee
5b554613ed
Rollup merge of #132737 - clubby789:lock-no-pid, r=jieyouxu
bootstrap: Print better message if lock pid isn't available

Not actually sure why, but sometimes the PID isn't available so we print
```
WARNING: build directory locked by process , waiting for lock
```
This makes the message a bit nicer in this case
2024-11-07 18:48:24 -08:00
Jubilee
c9009ae8c8
Rollup merge of #132696 - fortanix:raoul/rte-235-fix_fmodl_missing_symbol_issue, r=tgross35
Compile `test_num_f128` conditionally on `reliable_f128_math` config

With #132434 merged, our internal SGX CI started failing with:
```
05:27:34   = note: rust-lld: error: undefined symbol: fmodl
05:27:34           >>> referenced by arith.rs:617 (core/src/ops/arith.rs:617)
05:27:34           >>>               /home/jenkins/workspace/rust-sgx-ci/rust/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-fortanix-unknown-sgx/release/deps/std-5d5f11eb008c9091.std.d8141acc61ab7ac8-cgu.10.rcgu.o:(std::num::test_num::h7dd9449f6c01fde8)
05:27:34           >>> did you mean: fmodf
05:27:34           >>> defined in: /home/jenkins/workspace/rust-sgx-ci/rust/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-fortanix-unknown-sgx/release/deps/libcompiler_builtins-0376f439a2ebf305.rlib(compiler_builtins-0376f439a2ebf305.compiler_builtins.c22db39d25d6f802-cgu.148.rcgu.o)
```
This originated from the `test_num_f128` test not having the required conditional compilation. This PR fixes that issue.

cc: ````@jethrogb,```` ````@workingjubilee````
2024-11-07 18:48:23 -08:00
Jubilee
0683e031a8
Rollup merge of #132639 - RalfJung:intrinsics, r=workingjubilee,Amanieu
core: move intrinsics.rs into intrinsics folder

This makes the rustbot notification we have set up for this folder in `triagebot.toml` actually work. Also IMO it makes more sense to have it all in one folder.
2024-11-07 18:48:23 -08:00
Jubilee
4036472749
Rollup merge of #132131 - celinval:smir-crate-defs, r=compiler-errors
[StableMIR] API to retrieve definitions from crates

Add functions to retrieve function definitions and static items from all crates (local and external).

For external crates, we're still missing items from trait implementation and primitives.

r? ````@compiler-errors:```` Do you know what is the best way to retrieve the associated items for primitives and trait implementations for external crates? Thanks!
2024-11-07 18:48:22 -08:00
Jubilee
6c0e8ef86a
Rollup merge of #132095 - gechelberger:fix-131977, r=wesleywiser
Fix #131977 parens mangled in shared mut static lint suggestion

Resolves #131977 for static mut references after discussion with
Esteban & Jieyou on [t-compiler/help](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/linting.20with.20parens.20in.20the.20HIR).

This doesn't do anything to change the underlying issue if there are other expressions that generate lint suggestions which need to be applied within parentheses.
2024-11-07 18:48:21 -08:00
Jubilee
93e9ec05a9
Rollup merge of #131913 - jieyouxu:only_debug_assertions, r=onur-ozkan
Add `{ignore,needs}-{rustc,std}-debug-assertions` directive support

Add `{ignore,needs}-{rustc,std}-debug-assertions` compiletest directives and retire the old `{ignore,only}-debug` directives. The old `{ignore,only}-debug` directives were ambiguous because you could have std built with debug assertions but rustc not built with debug assertions or vice versa. If we want to support the use case of controlling test run based on if rustc was built with debug assertions, then having `{ignore,only}-debug` will be very confusing.

cc ````@matthiaskrgr````

Closes #123987.

r? bootstrap (or compiler tbh)
2024-11-07 18:48:21 -08:00
Jubilee
60e8ab6ba8
Rollup merge of #130586 - dpaoliello:fixrawdylib, r=wesleywiser
Set "symbol name" in raw-dylib import libraries to the decorated name

`windows-rs` received a bug report that mixing raw-dylib generated and the Windows SDK import libraries was causing linker failures: <https://github.com/microsoft/windows-rs/issues/3285>

The root cause turned out to be #124958, that is we are not including the decorated name in the import library and so the import name type is also not being correctly set.

This change modifies the generation of import libraries to set the "symbol name" to the fully decorated name and correctly marks the import as being data vs function.

Note that this also required some changes to how the symbol is named within Rust: for MSVC we now need to use the decorated name but for MinGW we still need to use partially decorated (or undecorated) name.

Fixes #124958

Passing i686 MSVC and MinGW build: <https://github.com/rust-lang/rust/actions/runs/11000433888?pr=130586>

r? `@ChrisDenton`
2024-11-07 18:48:20 -08:00
Josh Stone
9827c6dc2c This test needs threads 2024-11-07 18:18:34 -08:00
bors
5b20c45999 Auto merge of #128849 - estebank:issue-89143, r=jackh726
Tweak detection of multiple crate versions to be more encompassing

Previously, we only emitted the additional context if the type was in the same crate as the trait that appeared multiple times in the dependency tree. Now, we look at all traits looking for two with the same name in different crates with the same crate number, and we are more flexible looking for the types involved. This will work even if the type that implements the wrong trait version is from a different crate entirely.

```
error[E0277]: the trait bound `CustomErrorHandler: ErrorHandler` is not satisfied because the trait comes from a different crate version
 --> src/main.rs:5:17
  |
5 |     cnb_runtime(CustomErrorHandler {});
  |                 ^^^^^^^^^^^^^^^^^^^^^ the trait `ErrorHandler` is not implemented for `CustomErrorHandler`
  |
note: there are multiple different versions of crate `c` in the dependency graph
 --> /home/gh-estebank/testcase-rustc-crate-version-mismatch/c-v0.2/src/lib.rs:1:1
  |
1 | pub trait ErrorHandler {}
  | ^^^^^^^^^^^^^^^^^^^^^^ this is the required trait
  |
 ::: src/main.rs:1:5
  |
1 | use b::CustomErrorHandler;
  |     - one version of crate `c` is used here, as a dependency of crate `b`
2 | use c::cnb_runtime;
  |     - one version of crate `c` is used here, as a direct dependency of the current crate
  |
 ::: /home/gh-estebank/testcase-rustc-crate-version-mismatch/b/src/lib.rs:1:1
  |
1 | pub struct CustomErrorHandler {}
  | ----------------------------- this type doesn't implement the required trait
  |
 ::: /home/gh-estebank/testcase-rustc-crate-version-mismatch/c-v0.1/src/lib.rs:1:1
  |
1 | pub trait ErrorHandler {}
  | ---------------------- this is the found trait
  = note: two types coming from two different versions of the same crate are different types even if they look the same
  = help: you can use `cargo tree` to explore your dependency tree
```

Fix #89143.
2024-11-08 00:34:48 +00:00
Celina G. Val
dd6ddcb18e [StableMIR] A few fixes to pretty printing
Improve identation, and a few other rvalue printing
2024-11-07 16:16:38 -08:00
Philipp Krones
2ab848b756
Update Cargo.lock 2024-11-07 22:37:09 +01:00
Philipp Krones
40aec58abb
Merge commit 'f712eb5cdccd121d0569af12f20e6a0fabe4364d' into clippy-subtree-update 2024-11-07 22:37:01 +01:00
Celina G. Val
0ce579f6f3 [StableMIR] API to retrieve definitions from crates
Add functions to retrieve function definitions and static items from
all crates (local and external).

For external crates, add a query to retrieve the number of defs in a
foreign crate.
2024-11-07 13:11:46 -08:00
bors
b91a3a0560 Auto merge of #132472 - taiki-e:sparc-asm, r=Amanieu
Basic inline assembly support for SPARC and SPARC64

This implements asm_experimental_arch (tracking issue https://github.com/rust-lang/rust/issues/93335) for SPARC and SPARC64.

This PR includes:

- General-purpose registers `r[0-31]` (`reg` register class, LLVM/GCC constraint `r`)
  Supported types: i8, i16, i32, i64 (SPARC64-only)
  Aliases: `g[0-7]` (`r[0-7]`), `o[0-7]` (`r[8-15]`), `l[0-7]` (`r[16-23]`), `i[0-7]` (`r[24-31]`)
- `y` register (clobber-only, needed for clobber_abi)
- preserves_flags: Integer condition codes (`icc`, `xcc`) and floating-point condition codes (`fcc*`)

The following are *not* included:

- 64-bit integer support on SPARC-V8+'s global or out registers (`g[0-7]`, `o[0-7]`): GCC's `h` constraint (it seems that there is no corresponding constraint in LLVM?)
- Floating-point registers (LLVM/GCC constraint `e`/`f`):
  I initially tried to implement this, but postponed it for now because there seemed to be several parts in LLVM that behaved differently than in the LangRef's description.
- clobber_abi: Support for floating-point registers is needed.

Refs:
- LLVM
  - Reserved registers https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/Sparc/SparcRegisterInfo.cpp#L52
  - Register definitions https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/Sparc/SparcRegisterInfo.td
  - Supported constraints https://llvm.org/docs/LangRef.html#supported-constraint-code-list
- GCC
  - Reserved registers 63b6967b06/gcc/config/sparc/sparc.h (L633-L658)
  - Supported constraints https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html
- SPARC ISA/ABI
  - (64-bit ISA) The SPARC Architecture Manual, Version 9
    (32-bit ISA) The SPARC Architecture Manual, Version 8
    (64-bit ABI) System V Application Binary Interface SPARC Version 9 Processor Supplement, Rev 1.35
    (32-bit ABI) System V Application Binary Interface SPARC Processor Supplement, Third Edition
    The above docs can be downloaded from https://sparc.org/technical-documents
  - (32-bit V8+ ABI) The V8+ Technical Specification
    https://temlib.org/pub/SparcStation/Standards/V8plus.pdf

cc `@thejpster` (sparc-unknown-none-elf target maintainer)
(AFAIK, other sparc/sprac64 targets don't have target maintainers)

r? `@Amanieu`

`@rustbot` label +O-SPARC +A-inline-assembly
2024-11-07 21:07:06 +00:00