Commit Graph

233112 Commits

Author SHA1 Message Date
Matthias Krüger
1df0c21af1
Rollup merge of #114845 - scottmcm:npo-align, r=WaffleLapkin
Add alignment to the NPO guarantee

This PR [changes](https://github.com/rust-lang/rust/pull/114845#discussion_r1294363357) "same size" to "same size and alignment" in the option module's null pointer optimization docs in <https://doc.rust-lang.org/std/option/#representation>.

As far as I know, this has been true for a long time in the actual rustc implementation, but it's not in the text of those docs, so I figured I'd bring this up to FCP it.

I also see no particular reason that we'd ever *want* to have higher alignment on these.  In many of the cases it's impossible, as the minimum alignment is already the size of the type, but even if we *could* do things like on 32-bit we could say that `NonZeroU64` is 4-align but `Option<NonZeroU64>` is 8-align, I just don't see any value in doing that, so feel completely fine closing this door for the few things on which the NPO is already guaranteed.  These are basically all primitives, and should end up with the same size & alignment as those primitives.

(There's no layout guarantee for something like `Option<[u8; 3]>`, where it'd be at least plausible to consider raising the alignment from 1 to 4 on, say, some hypothetical target that doesn't have efficient unaligned 4-byte load/stores.  And even if we ever did start to offer some kind of guarantee around such a type, I doubt we'd put it under the "null pointer" optimization header.)

Screenshots for the new examples:
![image](https://github.com/rust-lang/rust/assets/18526288/a7dbff42-50b4-462e-9e27-00d511b58763)
![image](https://github.com/rust-lang/rust/assets/18526288/dfd55288-80fb-419a-bc11-26198c27f9f9)
2023-09-02 07:48:21 +02:00
Matthias Krüger
4e2231803b
Rollup merge of #114349 - inferiorhumanorgans:dragonfly-link-libz, r=cuviper
rustc_llvm: Link to `zlib` on dragonfly and solaris

On native builds `llvm-config` picks up `zlib` and this gets pased into
the rust build tools, but on cross builds `llvm-config` is explicitly
ignored as it contains information for the host system and cannot be
trusted to be accurate for the target system.

Both DragonFly and Solaris contain `zlib` in the base system, so this is
both a safe assumption and required for a successful cross build unless
`zlib` support is disabled in LLVM.

This is more or less in the same vein as rust-lang#75713 and rust-lang#75655.
2023-09-02 07:48:21 +02:00
bors
9dc11a13fa Auto merge of #115422 - Zoxc:cache-once-lock, r=cjgillot
Use `OnceLock` for `SingleCache`

This uses `OnceLock` for `SingleCache` instead of `Lock<Option<T>>` so lookups are lock-free.

r? `@cjgillot`
2023-09-02 03:06:11 +00:00
bors
f9ba43ce14 Auto merge of #113295 - clarfonthey:ascii-step, r=cuviper
Implement Step for ascii::Char

This allows iterating over ranges of `ascii::Char`, similarly to ranges of `char`.

Note that `ascii::Char` is still unstable, tracked in #110998.
2023-09-02 00:02:50 +00:00
bors
35e416303e Auto merge of #115276 - fmease:rustdoc-obj-lt-defs-handle-self-ty-params, r=GuillaumeGomez
rustdoc: correctly deal with self ty params when eliding default object lifetimes

Fixes #115179.
2023-09-01 22:11:22 +00:00
bors
270eb58631 Auto merge of #115452 - matthiaskrgr:rollup-he30fhv, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #115411 (miri ABI check: fix handling of 1-ZST; don't accept sign differences)
 - #115424 (diagnostics: avoid wrong `unused_parens` on `x as (T) < y`)
 - #115425 (remove unnecessary heap allocation)
 - #115446 (fix version for abi_thiscall to 1.73.0, which was forgotten to change when stabilized and (later) moved to beta)
 - #115447 (Add comment so pub items are not removed)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-01 20:22:37 +00:00
Matthias Krüger
ead5f80deb
Rollup merge of #115447 - LegNeato:patch-2, r=oli-obk
Add comment so pub items are not removed

As suggested in https://github.com/rust-lang/rust/pull/115393, add a comment so someone doesn't clean these up.
2023-09-01 21:41:41 +02:00
Matthias Krüger
db450d2981
Rollup merge of #115446 - klensy:fixup-stable-version, r=cuviper
fix version for abi_thiscall to 1.73.0, which was forgotten to change when stabilized and (later) moved to beta

See:

https://github.com/rust-lang/rust/pull/114562#issuecomment-1669424749
https://github.com/rust-lang/rust/pull/115056#issuecomment-1686316608
https://rust-lang.zulipchat.com/#narrow/stream/241545-t-release/topic/1.2E72.2E0/near/387695644

Should be backported to beta too.
2023-09-01 21:41:40 +02:00
Matthias Krüger
cf24a9fdf6
Rollup merge of #115425 - thechampagne:master, r=oli-obk
remove unnecessary heap allocation
2023-09-01 21:41:40 +02:00
Matthias Krüger
888dc2e3b0
Rollup merge of #115424 - notriddle:notriddle/issue-106413, r=oli-obk
diagnostics: avoid wrong `unused_parens` on `x as (T) < y`

Fixes #106413
Fixes #80636
2023-09-01 21:41:39 +02:00
Matthias Krüger
db6ae0721b
Rollup merge of #115411 - RalfJung:miri-abi, r=oli-obk
miri ABI check: fix handling of 1-ZST; don't accept sign differences

r? `@oli-obk`
2023-09-01 21:41:39 +02:00
Christian Legnitto
6e6031e094
Add comment so pub items are not removed
As suggested in https://github.com/rust-lang/rust/pull/115393, add a comment so someone doesn't clean these up.
2023-09-01 13:22:03 -04:00
klensy
355ba433ee fix version for abi_thiscall to 1.73.0, which was forgotten to change when stabilized 2023-09-01 19:46:09 +03:00
bors
361f8ba847 Auto merge of #114065 - lukas-code:u16_from_char, r=dtolnay
`impl TryFrom<char> for u16`

This PR implements the final missing `char` -> unsigned integer conversion.

ACP: https://github.com/rust-lang/libs-team/issues/146

r? libs-api
`@rustbot` label +T-libs-api +needs-fcp -T-libs
2023-09-01 16:01:06 +00:00
León Orell Valerian Liehr
f5a68f63aa
rustdoc: correctly deal with self ty params when eliding default object lifetimes 2023-09-01 16:17:53 +02:00
bors
1accf068d8 Auto merge of #113126 - Bryanskiy:delete_old, r=petrochenkov
Replace old private-in-public diagnostic with type privacy lints

Next part of RFC https://github.com/rust-lang/rust/issues/48054.

r? `@petrochenkov`
2023-09-01 12:40:01 +00:00
bors
f4555ef5e1 Auto merge of #111752 - dingxiangfei2009:lower-or-pattern, r=cjgillot
Lower `Or` pattern without allocating place

cc `@azizghuloum` `@cjgillot`

Related to #111583 and #111644

While reviewing #111644, it occurs to me that while we directly lower conjunctive predicates, which are connected with `&&`, into the desirable control flow, today we don't directly lower the disjunctive predicates, which are connected with `||`, in the similar fashion. Instead, we allocate a place for the boolean temporary to hold the result of evaluating the `||` expression.

Usually I would expect optimization at later stages to "inline" the evaluation of boolean predicates into simple CFG, but #111583 is an example where `&&` is failing to be optimized away and the assembly shows that both the expensive operands are evaluated. Therefore, I would like to make a small change to make the CFG a bit more straight-forward without invoking the `as_temp` machinery, and plus avoid allocating the place to hold the boolean result as well.
2023-09-01 10:54:56 +00:00
bors
d6b4d35d5e Auto merge of #115415 - c410-f3r:t3st3ss, r=flip1995
[`Clippy`] Use symbols intended for `arithmetic_side_effects`

#115177 added the symbols for `arithmetic_side_effects` and now this PR actually uses them to prevent an eventual removal. All because #115183 was recently merged and next Clippy update will probably take some time to happen.

Fixes https://github.com/rust-lang/rust-clippy/issues/11392
2023-09-01 09:07:01 +00:00
Caio
0164f7e8b2
[clippy] Use symbols intended for arithmetic_side_effects 2023-09-01 10:28:55 +02:00
bors
96f62fce00 Auto merge of #113201 - oli-obk:recursive_type_alias, r=estebank,compiler-errors
Permit recursive weak type aliases

I saw #63097 and thought "we can do ~~better~~ funnier". So here it is. It's not useful, but it's certainly something. This may actually become feasible with lazy norm (so in 5 years (constant, not reducing over time)).

r? `@estebank`

cc `@GuillaumeGomez`
2023-09-01 07:10:21 +00:00
Michael Howell
ba9af10846
Use terminology more sensibly 2023-08-31 22:40:43 -07:00
bors
dc348dbd90 Auto merge of #114448 - SteveLauC:std_fs_read_doc, r=Mark-Simulacrum
docs: improve std::fs::read doc

#### What does this PR do

1. Rephrase a confusing sentence in the document of `std::fs::read()`

-----

Closes #114432

cc `@Dexus0` `@saethlin`
2023-09-01 05:25:44 +00:00
bors
88d9b37a15 Auto merge of #115400 - gurry:issue-115264-ice, r=compiler-errors
Return ident for ExprField and PatField HIR nodes

Fixes #115264
2023-09-01 03:36:48 +00:00
Michael Howell
62835c9531 diagnostics: avoid wrong unused_parens on x as (T) < y 2023-08-31 20:14:49 -07:00
Steve Lau
0e270b1a97 docs: improve std::fs::read doc 2023-09-01 10:54:37 +08:00
XXIV
9adc6a49aa
remove unnecessary heap allocation 2023-09-01 05:22:22 +03:00
John Kåre Alsaker
90f5f94699 Use OnceLock for SingleCache 2023-09-01 03:11:51 +02:00
Gurinder Singh
19574d216a Return ident for ExprField and PatField HIR nodes 2023-09-01 06:36:02 +05:30
bors
2f5df8a94b Auto merge of #115366 - compiler-errors:associated-type-bound-implicit-lifetimes, r=jackh726
Capture lifetimes for associated type bounds destined to be lowered to opaques

Some associated type bounds get lowered to opaques, but they're not represented in the AST as opaques.

That means that we never collect lifetimes for them (`record_lifetime_params_for_impl_trait`) which are used currently for RPITITs, which capture all of their in-scope lifetimes[^1]. This means that the nested RPITITs that arise from some type like `impl Foo<Type: Bar>` (~> `impl Foo<Type = impl Bar>`) don't capture any lifetimes, leading to ICEs.

This PR makes sure we collect the lifetimes for associated type bounds as well, and make sure that they are set up correctly for opaque type lowering later.

Fixes #115360

[^1]: #114489
2023-08-31 21:13:54 +00:00
Ding Xiang Fei
67553e8a11
update tests that are ignored by debug 2023-09-01 04:01:54 +08:00
bors
91942134c6 Auto merge of #115389 - bvanjoi:fix-115380, r=petrochenkov
fix(resolve): update def if binding is warning ambiguity

Fixes #115380
2023-08-31 16:57:11 +00:00
Ralf Jung
efc759238d miri ABI check: fix handling of 1-ZST; don't accept sign differences 2023-08-31 17:27:23 +02:00
Ralf Jung
cbe8a05903 update abi_compat.rs 2023-08-31 17:27:23 +02:00
bors
4b71f03039 Auto merge of #115384 - lqd:default-universe-info, r=matthewjasper
Work around ICE in diagnostics for local super-universes missing `UniverseInfo`s

In issue #114907, canonicalization of liveness dropck-outlives results (IIUC) encounters universes absent from the original query.  Some local universes [are created](f3a1bae88c/compiler/rustc_infer/src/infer/canonical/query_response.rs (L417-L425)) for the mapping, but importantly, they won't have associated causes.

These missing `UniverseInfo`s can be [needed](f3a1bae88c/compiler/rustc_borrowck/src/diagnostics/region_errors.rs (L376)) during diagnostics, [causing the `IndexMap: key not found` ICE](d55522aad8/compiler/rustc_borrowck/src/region_infer/mod.rs (L2252)) seen in the issue.

This PR works around this by returning the suboptimal catch-all cause, to avoid the ICE. It does results in suboptimal diagnostics right now, but it's better than an ICE.

r? `@matthewjasper.`

Let me know if there's a good easy-ish way to fix this, but I believe that for some of these erroneous cases and diagnostics, that inference/canonicalization/higher-ranked subtyping/etc may not behave exactly the same with the new trait solver? If that's the case then it'd probably be best to wait a bit more to do the correct fix.

Fixes #114907.

cc `@aliemjay`
2023-08-31 15:13:05 +00:00
bors
b30b535124 Auto merge of #115408 - RalfJung:miri, r=RalfJung
update Miri

r? `@ghost`
2023-08-31 13:01:59 +00:00
bohan
107152141b fix(resolve): update def if binding is warning ambiguity 2023-08-31 20:00:04 +08:00
Rémy Rakic
10ef8d9bf7 remove dummy UniverseInfo causes from type checker fully_perform_op
This was backfilling causes for new universes that may have been created
by an op, when there was no error info to use for improved
diagnostics. We don't need to do that anymore: `other()` is the default when
there is no registered universe cause.
2023-08-31 11:41:58 +00:00
bors
873a7a384f Auto merge of #3046 - RalfJung:rustup, r=RalfJung
Rustup

also more ABI compat tests
2023-08-31 11:22:30 +00:00
Ralf Jung
c2b0ca75aa more ABI compat tests 2023-08-31 13:21:55 +02:00
bors
784916ce24 Auto merge of #115290 - compiler-errors:ctor-unsafe, r=cjgillot
`rustc_layout_scalar_valid_range` makes ctors unsafe

We already validate this when we use the ctor in a call, e.g. `Variant(1)`, but not if we use the ctor as a fn ptr, e.g. `.map(Variant)`. The easiest way to fix the latter is (afaict) is by marking the ctor as unsafe itself.

Fixes #115284
2023-08-31 11:16:37 +00:00
Rémy Rakic
ae963b560f remove dummy UniverseInfo causes from type checker type_check
This was pre-filling causes for universes that could already exist in
the InferCtxt. We don't need to do that anymore: `other()` is the default when
there is no registered universe cause.
2023-08-31 11:16:35 +00:00
Rémy Rakic
407695132c remove dummy UniverseInfo causes from type checker instantiate_canonical_with_fresh_inference_vars
This was backfilling causes for the new universes that can be created by
the InferCtxt. We don't need to do that anymore: `other()` is the default when
there is no registered universe cause.
2023-08-31 11:10:54 +00:00
Ralf Jung
9db09c571f fmt 2023-08-31 11:34:43 +02:00
Ralf Jung
2de09d8ae4 Merge from rustc 2023-08-31 11:34:36 +02:00
Ralf Jung
4ea6a4bfe3 Preparing for merge from rustc 2023-08-31 11:32:11 +02:00
bors
2bd81316f2 Auto merge of #115346 - oli-obk:smir_const, r=spastorino
Some SMIR Const cleanups

Only e1def3bd41b021ce87a5d639b10cdf4a7df1d0b5 is new logic, everywhere else I just used the implementations that y'all had already written.

r? `@spastorino`

cc `@ouz-a`
2023-08-31 09:30:58 +00:00
bors
dca2d1ff00 Auto merge of #115374 - RalfJung:miri-fn-abi, r=oli-obk
miri function ABI check: accept repr(transparent) wrappers as compatible
2023-08-31 07:43:23 +00:00
bors
6f03674342 Auto merge of #3045 - RalfJung:tier1-ci, r=RalfJung
make sure we test all tier 1 targets

i686-pc-windows-gnu was missing (and i686-pc-windows-msvc was being tested twice, as host and foreign target).
2023-08-31 07:23:55 +00:00
Ralf Jung
d86be8d32e make sure we test all tier 1 targets: i686-pc-windows-gnu was missing 2023-08-31 09:21:12 +02:00
bors
2518c0ffeb Auto merge of #3044 - rust-lang:rustup-2023-08-31, r=RalfJung
Automatic sync from rustc
2023-08-31 06:20:39 +00:00