Commit Graph

233106 Commits

Author SHA1 Message Date
Matthias Krüger
639116505a
Rollup merge of #114704 - bvanjoi:fix-114636, r=compiler-errors
parser: not insert dummy field in struct

Fixes #114636

This PR eliminates the dummy field, initially introduced in #113999, thereby enabling unrestricted use of `ident.unwrap()`. A side effect of this action is that we can only report the error of the first macro invocation field within the struct node.

An alternative solution might be giving a virtual name to the macro, but it appears more complex.(https://github.com/rust-lang/rust/issues/114636#issuecomment-1670228715). Furthermore, if you think https://github.com/rust-lang/rust/issues/114636#issuecomment-1670228715 is a better solution, feel free to close this PR.
2023-08-30 07:18:10 +02:00
Matthias Krüger
dafea5f919
Rollup merge of #113565 - workingjubilee:better-signal-handler-message, r=pnkfelix
Make SIGSEGV handler emit nicer backtraces

This annotates the code heavily with comments to explain what is going on, for the benefit of other compiler contributors. The backtrace also emits appropriate comments to clarify, to a programmer who may not know why a bunch of file paths and hexadecimal blather was just dumped into stderr, what is going on. Finally, it detects cycles and uses their regularity to avoid repeating a bunch of text. The previous backtraces we were emitting was extremely unfriendly, potentially confusing, and often alarming, and this makes things almost "nice".

We can't necessarily make them much nicer than this, because a signal handler must use "signal-safe" functions. This precludes conveniences like dynamic allocations. Fortunately, Rust's stdlib has allocation-free formatting, but it may hinder integrating this error with our localization middleware, as I wasn't able to clearly ascertain, at a glance, whether there was a zero-alloc path through it.

r? `@Nilstrieb`
2023-08-30 07:18:10 +02:00
bors
82c2eb48ee Auto merge of #114908 - cjgillot:no-let-under, r=compiler-errors
Do not compute unneeded query results.

r? `@ghost`
2023-08-30 04:29:17 +00:00
John Kåre Alsaker
d35179f665 Don't use wait_for_query without the Rayon thread pool 2023-08-30 06:10:02 +02:00
John Kåre Alsaker
5739349e96 Use conditional synchronization for Lock 2023-08-30 06:10:02 +02:00
bors
d64c84562f Auto merge of #113542 - saethlin:adaptive-tables, r=b-naber
Adapt table sizes to the contents

This is an implementation of https://github.com/rust-lang/compiler-team/issues/666

The objective of this PR is to permit the rmeta format to accommodate larger crates that need offsets larger than a `u32` can store without compromising performance for crates that do not need such range. The second commit is a number of tiny optimization opportunities I noticed while looking at perf recordings of the first commit.

The rmeta tables need to have fixed-size elements to permit lazy random access. But the size only needs to be fixed _per table_, not per element type. This PR adds another `usize` to the table header which indicates the table element size. As each element of a table is set, we keep track of the widest encoded table value, then don't bother encoding all the unused trailing bytes on each value. When decoding table elements, we copy them to a full-width array if they are not already full-width.

`LazyArray` needs some special treatment. Most other values that are encoded in tables are indexes or offsets, and those tend to be small so we get to drop a lot of zero bytes off the end. But `LazyArray` encodes _two_ small values in a fixed-width table element: A position of the table and the length of the table. The treatment described above could trim zero bytes off the table length, but any nonzero length shields the position bytes from the optimization. To improve this, we interleave the bytes of position and length. This change is responsible for about half of the crate metadata win on many crates.

Fixes https://github.com/rust-lang/rust/issues/112934 (probably)
Fixes https://github.com/rust-lang/rust/issues/103607
2023-08-30 02:40:37 +00:00
Gurinder Singh
136f0579d8 Make get_return_block() return Some only for HIR nodes in body
Fixes # 114918
2023-08-30 07:40:08 +05:30
Michael Goulet
f1679f7dd6 Capture lifetimes for associated type bounds destined to be lowered to opaques 2023-08-30 00:31:00 +00:00
Ben Kimock
225b3c0556 Document in the code how this scheme works 2023-08-29 20:16:57 -04:00
Kevin Reid
4e9a2a6ff6 Remove allow_private entirely. 2023-08-29 16:36:13 -07:00
bors
6e8f677c6a Auto merge of #115365 - weihanglo:update-cargo, r=weihanglo
Update cargo

18 commits in 925280f028db3a322935e040719a0754703947cf..96fe1c9e1aecd8f57063e3753969bb6418fd2fd5
2023-08-25 21:16:44 +0000 to 2023-08-29 20:10:34 +0000
- fix(lints): Fail when overriding inherited lints (rust-lang/cargo#12584)
- cargo install: suggest --git when package name is url (rust-lang/cargo#12575)
- chore: remove unstable-options for logout (rust-lang/cargo#12588)
- Improve logout message for asymmetric tokens (rust-lang/cargo#12587)
- fix(update): Remove references to -p in help (rust-lang/cargo#12586)
- fix(update): Make `-p` more convenient by being positional (rust-lang/cargo#12545)
- Set tracing target for networking messages. (rust-lang/cargo#12582)
- Retry docs (rust-lang/cargo#12583)
- feat(resolver): **Very** preliminary MSRV resolver support (rust-lang/cargo#12560)
- Update git2 (rust-lang/cargo#12580)
- Explain how `version` works for `git` dependencies (rust-lang/cargo#12270)
- Improve deserialization errors of untagged enums (rust-lang/cargo#12574)
- Add support for `target.'cfg(..)'.linker` (rust-lang/cargo#12535)
- Improve resolver version mismatch warning (rust-lang/cargo#12573)
- Stabilize `--keep-going` (rust-lang/cargo#12568)
- Define {{command}} for use in src/doc/man/includes (rust-lang/cargo#12570)
- Update serde (rust-lang/cargo#12569)
- chore: add missing `windows-sys` features back (rust-lang/cargo#12563)

r? ghost
2023-08-29 23:02:44 +00:00
Weihang Lo
bba0ae1f18
Update cargo 2023-08-29 23:23:12 +01:00
Kevin Reid
7b837e075a Don't suggest adding parentheses to call an inaccessible method.
Previously, the test code would emit E0615, thus revealing the existence
of private methods that the programmer probably does not care about.
Now it ignores their existence instead, producing error E0609 (no field).

The motivating example is:

```rust
let x = std::rc::Rc::new(());
x.inner;
```

which would previously mention the private method `Rc::inner()`, even
though `Rc<T>` intentionally has no public methods so that it can be a
transparent smart pointer for any `T`.
2023-08-29 14:47:28 -07:00
bors
84a9f4c6e6 Auto merge of #114114 - keith:ks/always-add-lc_build_version-for-metadata-object-files, r=wesleywiser
Always add LC_BUILD_VERSION for metadata object files

As of Xcode 15 Apple's linker has become a bit more strict about the warnings it produces. One of those new warnings requires all valid Mach-O object files in an archive to have a LC_BUILD_VERSION load command:

```
ld: warning: no platform load command found in 'ARCHIVE[arm64][2106](lib.rmeta)', assuming: iOS-simulator
```

This was already being done for Mac Catalyst so this change expands this logic to include it for all Apple platforms. I filed this behavior change as FB12546320 and was told it was the new intentional behavior.
2023-08-29 21:17:13 +00:00
bors
83995f320c Auto merge of #115354 - matthiaskrgr:rollup-4cotcxz, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #111580 (Don't ICE on layout computation failure)
 - #114923 (doc: update lld-flavor ref)
 - #115174 (tests: add test for #67992)
 - #115187 (Add new interface to smir)
 - #115300 (Tweaks and improvements on SMIR around generics_of and predicates_of)
 - #115340 (some more is_zst that should be is_1zst)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-29 19:24:47 +00:00
Rémy Rakic
325b585259 add non-regression test for issue 115351 2023-08-29 19:03:08 +00:00
Rémy Rakic
7762ac7bb5 handle edge-case of a recursion limit of 0 2023-08-29 19:02:24 +00:00
Matthias Krüger
a644f37163
Rollup merge of #115340 - RalfJung:more_is_1zst, r=oli-obk
some more is_zst that should be is_1zst

Follow-up to https://github.com/rust-lang/rust/pull/115277
2023-08-29 20:49:05 +02:00
Matthias Krüger
a51e8308c8
Rollup merge of #115300 - spastorino:smir-tweaks, r=oli-obk
Tweaks and improvements on SMIR around generics_of and predicates_of

r? `@oli-obk`

This allows an API like the following ...

```rust
    let trait_decls = stable_mir::all_trait_decls().iter().map(|trait_def| {
        let trait_decl = stable_mir::trait_decl(trait_def);
        let generics = trait_decl.generics_of();
        let predicates = trait_decl.predicates_of().predicates;
```

I didn't like that much `trait_def.trait_decl()` which is it possible but adding a method to a def_id that loads up a whole trait definition looks backwards to me.
2023-08-29 20:49:05 +02:00
Matthias Krüger
61c367cd1f
Rollup merge of #115187 - ouz-a:smir_wrap, r=oli-obk
Add new interface to smir

Removes the boiler plate from `crate-info.rs`, and creates new interface for the smir.

Addressing https://github.com/rust-lang/project-stable-mir/issues/23

r? `@spastorino`
2023-08-29 20:49:04 +02:00
Matthias Krüger
d5b12a22be
Rollup merge of #115174 - davidtwco:needs-test-bad-location-list-67992, r=wesleywiser
tests: add test for #67992

Fixes #67992.

Just adding a regression test for this issue.
2023-08-29 20:49:03 +02:00
Matthias Krüger
2dfb67b483
Rollup merge of #114923 - cuishuang:master, r=wesleywiser
doc: update lld-flavor ref
2023-08-29 20:49:03 +02:00
Matthias Krüger
56d7d93a4b
Rollup merge of #111580 - atsuzaki:layout-ice, r=oli-obk
Don't ICE on layout computation failure

Fixes #111176 regression.

r? `@oli-obk`
2023-08-29 20:49:02 +02:00
y21
507f10baee suggest removing impl in generic trait bound position 2023-08-29 20:27:38 +02:00
bors
b2515fa741 Auto merge of #115183 - flip1995:clippyup, r=Manishearth,oli-obk
Update Clippy

r? `@oli-obk` Assigning you, because something broke with ui_test:

```
tests/ui/crashes/ice-7272.rs FAILED:
command: "<unknown>"

A bug in `ui_test` occurred: called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }

full stderr:

```

(and that 103 times)

Thought I would ping you, before starting to investigate. Maybe you know what's going on.
2023-08-29 17:03:26 +00:00
bors
bb90f81070 Auto merge of #112775 - c410-f3r:t3st3ss, r=petrochenkov
Move tests

r? `@petrochenkov`
2023-08-29 13:53:34 +00:00
Oli Scherer
4fdb4edf9b Bump ui_test 2023-08-29 13:47:06 +00:00
ouz-a
c2fe0bf253 Create StableMir replacer for SMirCalls 2023-08-29 16:30:50 +03:00
Ralf Jung
d1c4fe94c3 some more is_zst that should be is_1zst 2023-08-29 14:11:27 +02:00
bors
6d32b298ed Auto merge of #114894 - Zoxc:sharded-cfg-cleanup2, r=cjgillot
Remove conditional use of `Sharded` from query state

`Sharded` is already a zero cost abstraction, so it shouldn't affect the performance of the single thread compiler if LLVM does its job.

r? `@cjgillot`
2023-08-29 12:04:37 +00:00
Santiago Pastorino
5ab9616d03
Call these methods from high level stable_mir::trait_decl(trait_def) and so on 2023-08-29 08:34:34 -03:00
Santiago Pastorino
079e3732cc
Implement generics_of and predicates_of only for TraitDecl for now 2023-08-29 08:34:33 -03:00
Santiago Pastorino
0c301e9d36
Deduplicate GenericPredicates 2023-08-29 08:34:28 -03:00
Santiago Pastorino
17ffb59d39
Index def_ids directly 2023-08-29 08:34:27 -03:00
Santiago Pastorino
af6299a1f7
Add stable_mir::DefId as new type wrapper 2023-08-29 08:28:48 -03:00
bors
0b84f18b24 Auto merge of #115277 - RalfJung:is_1zst, r=davidtwco
fix some issues around ZST handling

This fixes two bugs:
- We used to entirely skip enum variants like `B([u16; 0], !)`, even failing to properly align the enum!  Honoring the alignment of uninhabited variants is important for the same reason that we must reserve space for their fields -- see [here](https://github.com/rust-lang/rust/issues/49298#issuecomment-380615281) for why.
- ~~We uses to reject `repr(transparent)` on `struct MyType([u16; 0])`, which is weird because a one-field struct should always be allowed to be transparent around that field.~~ (moved to separate PR)

I also found two places in the layout code that did something special for ZST without explaining why, and removing those special cases doesn't seem to have any effect except for reordering some zero-sized fields which shouldn't be an issue... maybe PR CI will explain why those cases were needed, or maybe they became obsolete at some point.
2023-08-29 10:22:35 +00:00
bors
f6faef4475 Auto merge of #114795 - RalfJung:cell-swap, r=dtolnay
make Cell::swap panic if the Cells partially overlap

The following function ought to be sound:
```rust
fn as_cell_of_array<T, const N: usize>(c: &[Cell<T>; N]) -> &Cell<[T; N]> {
    unsafe { transmute(c) }
}
```
However, due to `Cell::swap`, it currently is not -- safe code can [cause a use-after-free](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=c9415799722d985ff7d2c2c997b724ca). This PR fixes that.

Fixes https://github.com/rust-lang/rust/issues/80778
2023-08-29 07:53:56 +00:00
Ralf Jung
b2ebf1c23f const_eval and codegen: audit uses of is_zst 2023-08-29 09:03:46 +02:00
Ralf Jung
bf91321e0f there seems to be no reason to treat ZST specially in these cases 2023-08-29 08:58:58 +02:00
Ralf Jung
0da9409e08 rustc_abi: audit uses of is_zst; fix a case of giving an enum insufficient alignment 2023-08-29 08:58:58 +02:00
Ralf Jung
0360b6740b add is_1zst helper method 2023-08-29 08:58:21 +02:00
bors
cedbe5c715 Auto merge of #113859 - Manishearth:vec-as-mut-ptr-stacked-borrow, r=dtolnay
Add note that Vec::as_mut_ptr() does not materialize a reference to the internal buffer

See discussion on https://github.com/thomcc/rust-typed-arena/issues/62 and [t-opsem](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/is.20this.20typed_arena.20code.20sound.20under.20stacked.2Ftree.20borrows.3F)

This method already does the correct thing here, but it is worth guaranteeing that it does so it can be used more freely in unsafe code without having to worry about potential Stacked/Tree Borrows violations. This moves one more unsafe usage pattern from the "very likely sound but technically not fully defined" box into "definitely sound", and currently our surface area of the latter is woefully small.

I'm not sure how best to word this, opening this PR as a way to start discussion.
2023-08-29 06:04:55 +00:00
bors
d9c11c65ee Auto merge of #3042 - rust-lang:rustup-2023-08-29, r=RalfJung
Automatic sync from rustc
2023-08-29 05:55:46 +00:00
The Miri Conjob Bot
fb3565a848 fmt 2023-08-29 05:45:20 +00:00
The Miri Conjob Bot
650294cdc2 Merge from rustc 2023-08-29 05:43:09 +00:00
The Miri Conjob Bot
ca7acd48e6 Preparing for merge from rustc 2023-08-29 05:36:35 +00:00
bors
a517049d8c Auto merge of #115312 - hermitcore:hermit-is_interrupted, r=thomcc
fix(sys/hermit): add is_interrupted

https://github.com/rust-lang/rust/pull/115228 broke compilation for Hermit by not adding a Hermit implementation of is_interrupted.
2023-08-29 04:11:13 +00:00
bors
f3284dc3ad Auto merge of #115260 - scottmcm:not-quite-so-cold, r=WaffleLapkin
Use `preserve_mostcc` for `extern "rust-cold"`

As experimentation in #115242 has shown looks better than `coldcc`.  Notably, clang exposes `preserve_most` (https://clang.llvm.org/docs/AttributeReference.html#preserve-most) but not `cold`, so this change should put us on a better-supported path.

And *don't* use a different convention for cold on Windows, because that actually ends up making things worse. (See comment in the code.)

cc tracking issue #97544
2023-08-29 02:23:43 +00:00
bors
fef2f5907f Auto merge of #115309 - hermitcore:hermit-net-init, r=cuviper
fix(sys/hermit): remove obsolete network initialization

This function does not exist as of hermit-sys 0.4.1 ([`e38f246`]). Once std does not call this function, we can remove it entirely.

CC: `@stlankes`

[`e38f246`]: e38f246e04 (diff-a9b7fa816defab285f0d4fe69d4df4a0cbbcf1c89913000df3273aded949f257R10)
2023-08-29 00:37:48 +00:00
bors
191dc54dbf Auto merge of #115182 - RalfJung:abi-compat-sign, r=b-naber
miri ABI compatibility check: accept u32 and i32

If only the sign differs, then surely these types are compatible. (We do still check that `arg_ext` is the same, just in case.)

Also I made it so that the ABI check must *imply* that size and alignment are the same, but it doesn't actively check that itself. With how crazy ABI constraints get, having equal size and align really shouldn't be used as a signal for anything I think...
2023-08-28 22:56:10 +00:00