Commit Graph

233487 Commits

Author SHA1 Message Date
bors
bfcc360afe Auto merge of #115707 - weihanglo:update-cargo, r=weihanglo
Update cargo

14 commits in d14c85f4e6e7671673b1a1bc87231ff7164761e1..2fc85d15a542bfb610aff7682073412cf635352f
2023-09-05 22:28:10 +0000 to 2023-09-09 01:49:46 +0000
- feat: Stabilize lints (rust-lang/cargo#12648)
- Ues strip_prefix for cleaner code (rust-lang/cargo#12631)
- fix: don't print _TOKEN suggestion when not applicable (rust-lang/cargo#12644)
- Bump cargo-credential-1password to v0.4.0 (rust-lang/cargo#12641)
- refactor: put `Source` trait under `cargo::sources` (rust-lang/cargo#12527)
- Error out if `cargo clean --doc` is mixed with `-p`. (rust-lang/cargo#12637)
- Add wrappers around std::fs::metadata (rust-lang/cargo#12636)
- Add with_stdout_unordered. (rust-lang/cargo#12635)
- Fix example for creating a git project test. (rust-lang/cargo#12632)
- Read/write the encoded `cargo update --precise` in the same place (rust-lang/cargo#12629)
- docs(guide): Apply feedback on CI (rust-lang/cargo#12630)
- fix: improve warning for both token & credential-provider (rust-lang/cargo#12626)
- Skip clean up `profile.release.package."*"` (rust-lang/cargo#12624)
- Add MSRV validation GitHub Action for cargo-credential (rust-lang/cargo#12623)
2023-09-09 14:33:14 +00:00
Weihang Lo
252fb60eb4
Update cargo 2023-09-09 21:06:07 +08:00
bors
6cc1898f5f Auto merge of #115594 - nnethercote:span-tweaks, r=cjgillot
Span tweaks

Some minor improvements to code clarity.

r? `@cjgillot`
2023-09-09 10:56:24 +00:00
bors
38bbc2ce03 Auto merge of #115657 - Zoxc:source-span-avoid-query, r=cjgillot
Avoid a `source_span` query when encoding Spans into query results

This avoids a `source_span` query when encoding `Span`s into query results. It's not sound to execute queries here as the query caches can be locked and the dep graph is no longer writable.

r? `@cjgillot`
2023-09-09 09:08:54 +00:00
bors
5ede940894 Auto merge of #115669 - GuillaumeGomez:js-anonymous-functions, r=notriddle
rustdoc: Change syntax for anonymous functions set in JS

This function is not very useful in itself but it slightly reduces the JS size so it's always that I suppose... No changes in behaviour.

r? `@notriddle`
2023-09-09 01:57:54 +00:00
bors
b0b8c52649 Auto merge of #115685 - matthiaskrgr:rollup-t31gowy, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #113807 (Tests crash from inappropriate use of common linkage)
 - #115358 (debuginfo: add compiler option to allow compressed debuginfo sections)
 - #115630 (Dont suggest use between `use` and cfg attr)
 - #115662 (Improve "associated type not found" diagnostics)
 - #115673 (Fix sanitize/cfg.rs test)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-08 22:47:40 +00:00
Matthias Krüger
2ae5dc9b65
Rollup merge of #115673 - tmiasko:sanitizer-cfg, r=compiler-errors
Fix sanitize/cfg.rs test

* Move needs-sanitizer conditions to specific revisions that require them (otherwise the conditions are mutually exclusive with needs-sanitizer-kcfi and test is always ignored).
* Add missing revisions
2023-09-09 00:28:21 +02:00
Matthias Krüger
69044a1693
Rollup merge of #115662 - ShE3py:E0220-note, r=compiler-errors
Improve "associated type not found" diagnostics

```rs
use core::ops::Deref;

fn foo<T>() where T: Deref<Output = u32> {}
```

Before:
```
error[E0220]: associated type `Output` not found for `Deref`
 --> E0220.rs:5:28
  |
5 | fn foo<T>() where T: Deref<Output = u32> {}
  |                            ^^^^^^ associated type `Output` not found
```

After:
```
error[E0220]: associated type `Output` not found for `Deref`
 --> E0220.rs:5:28
  |
5 | fn foo<T>() where T: Deref<Output = u32> {}
  |                            ^^^^^^ help: `Deref` has the following associated type: `Target`
```

---

`@rustbot` label +A-diagnostics +D-papercut
2023-09-09 00:28:20 +02:00
Matthias Krüger
b33ac52106
Rollup merge of #115630 - compiler-errors:dont-suggest-use-btw-use-and-attr, r=wesleywiser
Dont suggest use between `use` and cfg attr

Fixes #115618
2023-09-09 00:28:20 +02:00
Matthias Krüger
aa78b4c368
Rollup merge of #115358 - durin42:compress-debuginfo, r=oli-obk
debuginfo: add compiler option to allow compressed debuginfo sections

LLVM already supports emitting compressed debuginfo. In debuginfo=full builds, the debug section is often a large amount of data, and it typically compresses very well (3x is not unreasonable.) We add a new knob to allow debuginfo to be compressed when the matching LLVM functionality is present. Like clang, if a known-but-disabled compression mechanism is requested, we disable compression and emit uncompressed debuginfo sections.

The API is different enough on older LLVMs we just pretend the support
is missing on LLVM older than 16.
2023-09-09 00:28:19 +02:00
Matthias Krüger
6b65d377c5
Rollup merge of #113807 - mojingran:master, r=WaffleLapkin
Tests crash from inappropriate use of common linkage

Follows up my proposal under the [tracking issue for the linkage feature](https://github.com/rust-lang/rust/issues/29603#issuecomment-1597662999). Adds test for [issue 109681](https://github.com/rust-lang/rust/issues/109681).
2023-09-09 00:28:19 +02:00
bors
62ebe3a2b1 Auto merge of #115417 - dpaoliello:fixdi, r=wesleywiser
Use the same DISubprogram for each instance of the same inlined function within a caller

# Issue Details:
The call to `panic` within a function like `Option::unwrap` is translated to LLVM as a `tail call` (as it will never return), when multiple calls to the same function like this are inlined LLVM will notice the common `tail call` block (i.e., loading the same panic string + location info and then calling `panic`) and merge them together.

When merging these instructions together, LLVM will also attempt to merge the debug locations as well, but this fails (i.e., debug info is dropped) as Rust emits a new `DISubprogram` at each inline site thus LLVM doesn't recognize that these are actually the same function and so thinks that there isn't a common debug location.

As an example of this, consider the following program:
```rust
#[no_mangle]
fn add_numbers(x: &Option<i32>, y: &Option<i32>) -> i32 {
    let x1 = x.unwrap();
    let y1 = y.unwrap();

    x1 + y1
}
```

 When building for x86_64 Windows using 1.72 it generates (note the lack of `.cv_loc` before the call to `panic`, thus it will be attributed to the same line at the `addq` instruction):

```llvm
	.cv_loc	0 1 3 0                        # src\lib.rs:3:0
	addq	$40, %rsp
	retq
	leaq	.Lalloc_f570dea0a53168780ce9a91e67646421(%rip), %rcx
	leaq	.Lalloc_629ace53b7e5b76aaa810d549cc84ea3(%rip), %r8
	movl	$43, %edx
	callq	_ZN4core9panicking5panic17h12e60b9063f6dee8E
	int3
```

# Fix Details:
Cache the `DISubprogram` emitted for each inlined function instance within a caller so that this can be reused if that instance is encountered again.

Ideally, we would also deduplicate child scopes and variables, however my attempt to do that with #114643 resulted in asserts when building for Linux (#115156) which would require some deep changes to Rust to fix (#115455).

Instead, when using an inlined function as a debug scope, we will also create a new child scope such that subsequent child scopes and variables do not collide (from LLVM's perspective).

After this change the above assembly now (with <https://reviews.llvm.org/D159226> as well) shows the `panic!` was inlined from `unwrap` in `option.rs` at line 935 into the current function in `lib.rs` at line 0 (line 0 is emitted since it is ambiguous which line to use as there were two inline sites that lead to this same code):

```llvm
	.cv_loc	0 1 3 0                        # src\lib.rs:3:0
	addq	$40, %rsp
	retq
	.cv_inline_site_id 6 within 0 inlined_at 1 0 0
	.cv_loc	6 2 935 0                       # library\core\src\option.rs:935:0
	leaq	.Lalloc_5f55955de67e57c79064b537689facea(%rip), %rcx
	leaq	.Lalloc_e741d4de8cb5801e1fd7a6c6795c1559(%rip), %r8
	movl	$43, %edx
	callq	_ZN4core9panicking5panic17hde1558f32d5b1c04E
	int3
```
2023-09-08 20:56:01 +00:00
bors
ffc48e3eda Auto merge of #115641 - durin42:llvm-18-fatlto-take-2, r=nikic
lto: load bitcode sections by name

Upstream change
llvm/llvm-project@6b539f5eb8 changed `isSectionBitcode` works and it now only respects `.llvm.lto` sections instead of also `.llvmbc`, which it says was never intended to be used for LTO. We instead load sections by name, and sniff for raw bitcode by hand.

This is an alternative approach to #115136, where we tried the same thing using the `object` crate, but it got too fraught to continue.

r? `@nikic`
`@rustbot` label: +llvm-main
2023-09-08 19:07:17 +00:00
bors
26f4b72724 Auto merge of #115418 - Zoxc:freeze-source, r=oli-obk
Use `Freeze` for `SourceFile`

This uses the `Freeze` type in `SourceFile` to let accessing `external_src` and `lines` be lock-free.

Behavior of `add_external_src` is changed to set `ExternalSourceKind::AbsentErr` on a hash mismatch which matches the documentation. `ExternalSourceKind::Unneeded` was removed as it's unused.

Based on https://github.com/rust-lang/rust/pull/115401.
2023-09-08 17:20:23 +00:00
bors
3cd97ed3c3 Auto merge of #115612 - cjgillot:const-prop-int, r=oli-obk
Improvements to dataflow const-prop

Partially cherry-picked from https://github.com/rust-lang/rust/pull/110719

r? `@oli-obk`
cc `@jachris`
2023-09-08 15:32:54 +00:00
Augie Fackler
78d805cd87 tests: use warning output from rustc to catch missing compression
Using `ld.lld` may have been clever, but that was getting the /system/
ld.lld, not one we may have built as part of building llvm. By using the
warning message coming directly from rustc we now correctly skip the
zlib and zstd tests when the support is missing.
2023-09-08 11:30:24 -04:00
Augie Fackler
a52990b8d5 sort 2023-09-08 10:45:29 -04:00
Augie Fackler
ed17b568e3 options: fix indentation
rustfmt didn't save me here, sigh
2023-09-08 10:45:29 -04:00
Augie Fackler
af9e55068c debuginfo: add compiler option to allow compressed debuginfo sections
LLVM already supports emitting compressed debuginfo. In debuginfo=full
builds, the debug section is often a large amount of data, and it
typically compresses very well (3x is not unreasonable.) We add a new
knob to allow debuginfo to be compressed when the matching LLVM
functionality is present. Like clang, if a known-but-disabled
compression mechanism is requested, we disable compression and emit
uncompressed debuginfo sections.

The API is different enough on older LLVMs we just pretend the support
is missing on LLVM older than 16.
2023-09-08 10:45:29 -04:00
Augie Fackler
9ad0396a34 lto: handle Apple platforms correctly by eliding __LLVM, from section name 2023-09-08 10:45:22 -04:00
Augie Fackler
942bdf910c lto: load bitcode sections by name
Upstream change
llvm/llvm-project@6b539f5eb8 changed
`isSectionBitcode` works and it now only respects `.llvm.lto` sections
instead of also `.llvmbc`, which it says was never intended to be used
for LTO. We instead load sections by name, and sniff for raw bitcode by
hand.

r? @nikic
@rustbot label: +llvm-main
2023-09-08 10:45:22 -04:00
bors
309af3442a Auto merge of #115672 - GuillaumeGomez:rollup-mjiy56f, r=GuillaumeGomez
Rollup of 6 pull requests

Successful merges:

 - #104299 (Clarify stability guarantee for lifetimes in enum discriminants)
 - #115088 (Fix Step Skipping Caused by Using the `--exclude` Option)
 - #115201 (rustdoc: list matching impls on type aliases)
 - #115633 (Lint node for `PRIVATE_BOUNDS`/`PRIVATE_INTERFACES` is the item which names the private type)
 - #115638 (`-Cllvm-args` usability improvement)
 - #115643 (fix: return early when has tainted in mir-lint)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-08 13:43:08 +00:00
Tomasz Miąsko
7f45d16cb2 Fix sanitize/cfg.rs test
* Move needs-sanitizer conditions to specific revisions that
  require them (otherwise the conditions are mutually exclusive
  with needs-sanitizer-kcfi and test is always ignored).
* Add missing revisions
2023-09-08 15:12:17 +02:00
John Kåre Alsaker
c83eba9251 Add Freeze::clone 2023-09-08 14:14:57 +02:00
Guillaume Gomez
60327bb8b0
Rollup merge of #115643 - bvanjoi:fix-115203, r=RalfJung,oli-obk
fix: return early when has tainted in mir-lint

Fixes #115203

`a[..]` is of indeterminate size, it had been reported error during borrow check, therefore we skip the mir lint process.
2023-09-08 14:10:52 +02:00
Guillaume Gomez
575c3633f8
Rollup merge of #115638 - ldm0:ldm/llvm-args-fix, r=nikic
`-Cllvm-args` usability improvement

fixes: #26338
fixes: #115564

Two problems were found during playing with `-Cllvm-args`

1. When `llvm.link-shared` is set to `false` in `config.toml`, output of `rustc -C llvm-args='--help-list-hidden'` doesn't contain `--emit-dwarf-unwind` and `--emulated-tls`. When it is set to `true`, `rustc -C llvm-args='--help-list-hidden'` emits `--emit-dwarf-unwind`, but `--emulated-tls` is still missing.
2. Setting `-Cllvm-args=--emit-dwarf-unwind=always` doesn't take any effect, but `-Cllvm-args=-machine-outliner-reruns=3` does work.

### 1

Adding `RegisterCodeGenFlags` to register codegen flags fixed the first problem. `rustc -C llvm-args='--help-list-hidden'` emits full codegen flags including `--emit-dwarf-unwind` and `--emulated-tls`.

### 2

Constructing `TargetOptions` from `InitTargetOptionsFromCodeGenFlags` in `LLVMRustCreateTargetMachine` fixed the second problem. The `LLVMRustSetLLVMOptions` calls `ParseCommandLineOptions` which parses given `llvm-args`. For options like `machine-outliner-reruns`, it just works, since the codegen logic directly consumes the parsing result:

[machine-outliner-reruns register](0537f6354c/llvm/lib/CodeGen/MachineOutliner.cpp (L114))
[machine-outliner-reruns consumption](0537f6354c/llvm/lib/CodeGen/MachineOutliner.cpp (L1138))

But for flags defined in `TargetOptions` and `MCTargetOptions` to take effect, constructing them with `InitTargetOptionsFromCodeGenFlags` is essential, or the parsing result is just not consumed. Similar patterns can be observed in [lli](0537f6354c/llvm/tools/llc/llc.cpp (L494)), [llc](0537f6354c/llvm/tools/lli/lli.cpp (L517)), etc.
2023-09-08 14:10:52 +02:00
Guillaume Gomez
e3b6122530
Rollup merge of #115633 - compiler-errors:PRIVATE_BOUNDS-lint-node, r=petrochenkov
Lint node for `PRIVATE_BOUNDS`/`PRIVATE_INTERFACES` is the item which names the private type

The HIR that the `PRIVATE_BOUNDS` lint should be attached to is the item that has the *bounds*, not the private type. This PR also aligns this behavior with the `EXPORTED_PRIVATE_DEPENDENCIES` lint, which also requires putting the `allow` on the item that names the private type.

Fixes #115475

r? petrochenkov
2023-09-08 14:10:51 +02:00
Guillaume Gomez
1fb672c738
Rollup merge of #115201 - notriddle:notriddle/type-alias-impl-list, r=GuillaumeGomez
rustdoc: list matching impls on type aliases

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

Fixes #99952

Remake of https://github.com/rust-lang/rust/pull/112429

Partially reverts https://github.com/rust-lang/rust/pull/112543, but keeps the test case.

This version of the PR avoids the infinite loop by structurally matching types instead of using full unification. This version does not support type alias trait bounds, but the compiler does not enforce those anyway (https://github.com/rust-lang/rust/issues/21903).

r? `@GuillaumeGomez`

CC `@lcnr`
2023-09-08 14:10:51 +02:00
Guillaume Gomez
dcb465995d
Rollup merge of #115088 - LuuuXXX:issue-112009, r=albertlarsan68
Fix Step Skipping Caused by Using the `--exclude` Option

The original code was overreacting to the `--exclude` option,
eadf69a6c6/src/bootstrap/builder.rs (L257-L260)
For example:
When `x test --exclude alloc` or `x test --exclude library/alloc` is passed, the entire libraray test is skipped.

Related issues:
https://github.com/rust-lang/rust/issues/112009
2023-09-08 14:10:50 +02:00
Guillaume Gomez
2cceedd0ef
Rollup merge of #104299 - mkrasnitski:discriminant-transmute-docs, r=oli-obk
Clarify stability guarantee for lifetimes in enum discriminants

Since `std::mem::Discriminant` erases lifetimes, it should be clarified that changing the concrete value of a lifetime parameter does not change the value of an enum discriminant for a given variant. This is useful as it guarantees that it is safe to transmute `Discriminant<Foo<'a>>` to `Discriminant<Foo<'b>>` for any combination of `'a` and `'b`. This also holds for type-generics as long as the type parameters do not change, e.g. `Discriminant<Foo<T, 'a>>` can be transmuted to `Discriminant<Foo<T, 'b>>`.

Side note: Is what I've written actually enough to imply soundness (or rather codify it), or should it specifically be spelled out that it's OK to transmute in the above way?
2023-09-08 14:10:49 +02:00
bors
cd71a37f32 Auto merge of #115372 - RalfJung:abi-assert-eq, r=davidtwco
add rustc_abi(assert_eq) to test some guaranteed or at least highly expected ABI compatibility guarantees

This new repr(transparent) test is super useful, it would have found https://github.com/rust-lang/rust/issues/115336 and found https://github.com/rust-lang/rust/issues/115404, https://github.com/rust-lang/rust/issues/115481, https://github.com/rust-lang/rust/issues/115509.
2023-09-08 11:56:08 +00:00
Ralf Jung
e726be21ab need to disable part of this test on arm 2023-09-08 13:25:51 +02:00
Guillaume Gomez
6ec8d71f9b Change syntax for anonymous functions set 2023-09-08 12:08:42 +02:00
bors
9be4eac264 Auto merge of #113492 - nebulark:pr_96475, r=petrochenkov
Add CL and CMD into to pdb debug info

Partial fix for https://github.com/rust-lang/rust/issues/96475

The Arg0 and CommandLineArgs of the MCTargetOptions cpp class are not set within bb548f9645/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp (L378)

This causes LLVM to not  neither output any compiler path (cl) nor the arguments that were used when invoking it (cmd) in the PDB file.

This fix adds the missing information to the target machine so LLVM can use it.
2023-09-08 10:06:40 +00:00
LuuuX
45abd8caf2 Fix Issue 112009
modify fuction clond() -> cloned()

optimize the code

Handle the problem that the pathset is empty and modify the judgment of the builder::tests::test_exclude_kind

Delete unnecessary judegment conditions

skip test for library/std duo to OOM in benches as library/alloc

Add FIXME for WASM32
2023-09-08 17:10:32 +08:00
bors
de4cba3a98 Auto merge of #115665 - matthiaskrgr:rollup-azdjs2r, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #115345 (MCP661: Move wasm32-wasi-preview1-threads target to Tier 2)
 - #115604 (rustdoc: Render private fields in tuple struct as `/* private fields */`)
 - #115624 (Print the path of a return-position impl trait in trait when `return_type_notation` is enabled)
 - #115629 (Don't suggest dereferencing to unsized type)
 - #115634 (Use `newtype_index` for `IntVid` and `FloatVid`.)
 - #115649 (diagnostics: add test case for trait bounds diagnostic)
 - #115655 (rustdoc: remove unused ID `mainThemeStyle`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-08 07:47:32 +00:00
Ralf Jung
b0cf4c28ea turns out Layout has some more things to worry about -- move ABI comparison into helper function
like is_bool, and some special magic extra fields
2023-09-08 09:14:07 +02:00
Ralf Jung
28d152935e the wasm ABI behavior is a bug 2023-09-08 09:14:07 +02:00
Ralf Jung
243ef313a5 add a testcase for another MIPS64 bug 2023-09-08 08:59:55 +02:00
Ralf Jung
a53c6ee0ba also ensure that size and alignment are the same 2023-09-08 08:59:55 +02:00
Ralf Jung
f6ef555823 merge transparent-abi test into general abi compatibility test, and test repr(transparent) unions 2023-09-08 08:59:55 +02:00
Ralf Jung
02217d1a16 add tests for RFC 3391 2023-09-08 08:59:55 +02:00
Ralf Jung
c3e14edd8b accept some differences for rustc_abi(assert_eq), so that we can test more things to be compatible 2023-09-08 08:59:55 +02:00
Nicholas Nethercote
5790372736 Optimize Span::is_dummy.
It's quite hot, and worth having a version that works directly at the
`Span` level, rather than first converting to the `SpanData` level.
2023-09-08 16:54:02 +10:00
Nicholas Nethercote
e525e4f10a Span tweaks.
`Span` has undergone some changes over the years (addition of an optional
parent, and possible inlining of the context in interned spans) but the
comments and identifiers used haven't kept up. As a result, I find it
harder to understand than I should.

This commit reworks the comments, renames some identifiers, and
restructures the code slightly, all to make things clearer. I now feel
like I understand this code again.
2023-09-08 16:53:57 +10:00
Lieselotte
a0e0a3261e
E0220: only suggests associated types if there's only one candidate 2023-09-08 08:44:23 +02:00
Matthias Krüger
dfa662253a
Rollup merge of #115655 - notriddle:notriddle/rustdoc-fe-cleanup, r=GuillaumeGomez
rustdoc: remove unused ID `mainThemeStyle`

This was added in https://github.com/rust-lang/rust/pull/47620 and used to build the URL of the theme stylesheets. It isn't used any more, because https://github.com/rust-lang/rust/pull/101702 changed it so that the URL was supplied in a `<meta>` tag, which also provides the hashes of the files.
2023-09-08 08:23:05 +02:00
Matthias Krüger
7ec813643a
Rollup merge of #115649 - notriddle:notriddle/82038, r=compiler-errors
diagnostics: add test case for trait bounds diagnostic

Closes #82038

It was fixed by https://github.com/rust-lang/rust/pull/89580, a wide-reaching obligation tracking improvement. This commit adds a test case.
2023-09-08 08:23:04 +02:00
Matthias Krüger
1979772772
Rollup merge of #115634 - nnethercote:IntVid-FloatVid, r=oli-obk
Use `newtype_index` for `IntVid` and `FloatVid`.

`TyVid` already uses `newtype_index`.
2023-09-08 08:23:04 +02:00
Matthias Krüger
38adedc598
Rollup merge of #115629 - compiler-errors:sugg-deref-unsize, r=oli-obk
Don't suggest dereferencing to unsized type

Rudimentary check that the self type is Sized. I don't really like any of this diagnostics code -- it's really messy and also really prone to false positives and negatives, but oh well.

Fixes #115569
2023-09-08 08:23:03 +02:00