Commit Graph

169202 Commits

Author SHA1 Message Date
Ralf Jung
4291332175 implement ptr.addr() via transmute 2022-06-03 16:45:35 -04:00
bors
5e6bb83268 Auto merge of #96737 - ChrisDenton:win-manifest, r=wesleywiser
Add Windows application manifest to rustc-main

Windows allows setting some runtime options using a manifest file. The format of the XML file is documented here: https://docs.microsoft.com/en-us/windows/win32/sbscs/application-manifests

The manifest file in this PR does three things:

* Declares which Windows versions we support. This may help avoid unnecessary compatibility shims.
* Uses the UTF-8 code page. While Rust itself uses UTF-16 APIs, other code may rely on the code page.
* Makes the application long path aware (if also enabled by the user). This allows for the current directory to be longer than `PATH_MAX`.

These changes only affect the `rustc` process and not any other DLLs or compiled programs.
2022-06-02 07:58:29 +00:00
bors
fb1976011e Auto merge of #97414 - LYF1999:yf/cachealign, r=Mark-Simulacrum
use 128 cache align for aarch64

the cache line size of m1 mac is 128.
so use `align(128)` for m1 mac

here is `sysctl -a hw machdep.cpu` output on m1 mac
```
hw.ncpu: 10
hw.byteorder: 1234
hw.memsize: 68719476736
hw.activecpu: 10
hw.perflevel0.physicalcpu: 8
hw.perflevel0.physicalcpu_max: 8
hw.perflevel0.logicalcpu: 8
hw.perflevel0.logicalcpu_max: 8
hw.perflevel0.l1icachesize: 196608
hw.perflevel0.l1dcachesize: 131072
hw.perflevel0.l2cachesize: 12582912
hw.perflevel0.cpusperl2: 4
hw.perflevel1.physicalcpu: 2
hw.perflevel1.physicalcpu_max: 2
hw.perflevel1.logicalcpu: 2
hw.perflevel1.logicalcpu_max: 2
hw.perflevel1.l1icachesize: 131072
hw.perflevel1.l1dcachesize: 65536
hw.perflevel1.l2cachesize: 4194304
hw.perflevel1.cpusperl2: 2
hw.optional.arm.FEAT_FlagM: 1
hw.optional.arm.FEAT_FlagM2: 1
hw.optional.arm.FEAT_FHM: 1
hw.optional.arm.FEAT_DotProd: 1
hw.optional.arm.FEAT_SHA3: 1
hw.optional.arm.FEAT_RDM: 1
hw.optional.arm.FEAT_LSE: 1
hw.optional.arm.FEAT_SHA256: 1
hw.optional.arm.FEAT_SHA512: 1
hw.optional.arm.FEAT_SHA1: 1
hw.optional.arm.FEAT_AES: 1
hw.optional.arm.FEAT_PMULL: 1
hw.optional.arm.FEAT_SPECRES: 0
hw.optional.arm.FEAT_SB: 1
hw.optional.arm.FEAT_FRINTTS: 1
hw.optional.arm.FEAT_LRCPC: 1
hw.optional.arm.FEAT_LRCPC2: 1
hw.optional.arm.FEAT_FCMA: 1
hw.optional.arm.FEAT_JSCVT: 1
hw.optional.arm.FEAT_PAuth: 1
hw.optional.arm.FEAT_PAuth2: 0
hw.optional.arm.FEAT_FPAC: 0
hw.optional.arm.FEAT_DPB: 1
hw.optional.arm.FEAT_DPB2: 1
hw.optional.arm.FEAT_BF16: 0
hw.optional.arm.FEAT_I8MM: 0
hw.optional.arm.FEAT_ECV: 1
hw.optional.arm.FEAT_LSE2: 1
hw.optional.arm.FEAT_CSV2: 1
hw.optional.arm.FEAT_CSV3: 1
hw.optional.arm.FEAT_FP16: 1
hw.optional.arm.FEAT_SSBS: 1
hw.optional.arm.FEAT_BTI: 0
hw.optional.floatingpoint: 1
hw.optional.neon: 1
hw.optional.neon_hpfp: 1
hw.optional.neon_fp16: 1
hw.optional.armv8_1_atomics: 1
hw.optional.armv8_2_fhm: 1
hw.optional.armv8_2_sha512: 1
hw.optional.armv8_2_sha3: 1
hw.optional.armv8_3_compnum: 1
hw.optional.watchpoint: 4
hw.optional.breakpoint: 6
hw.optional.armv8_crc32: 1
hw.optional.armv8_gpi: 1
hw.optional.AdvSIMD: 1
hw.optional.AdvSIMD_HPFPCvt: 1
hw.optional.ucnormal_mem: 1
hw.optional.arm64: 1
hw.features.allows_security_research: 0
hw.physicalcpu: 10
hw.physicalcpu_max: 10
hw.logicalcpu: 10
hw.logicalcpu_max: 10
hw.cputype: 16777228
hw.cpusubtype: 2
hw.cpu64bit_capable: 1
hw.cpufamily: 458787763
hw.cpusubfamily: 5
hw.cacheconfig: 10 1 2 0 0 0 0 0 0 0
hw.cachesize: 3373957120 65536 4194304 0 0 0 0 0 0 0
hw.pagesize: 16384
hw.pagesize32: 16384
hw.cachelinesize: 128
hw.l1icachesize: 131072
hw.l1dcachesize: 65536
hw.l2cachesize: 4194304
hw.tbfrequency: 24000000
hw.packages: 1
hw.osenvironment:
hw.ephemeral_storage: 0
hw.use_recovery_securityd: 0
hw.use_kernelmanagerd: 1
hw.serialdebugmode: 0
hw.nperflevels: 2
hw.targettype: J316c
machdep.cpu.cores_per_package: 10
machdep.cpu.core_count: 10
machdep.cpu.logical_per_package: 10
machdep.cpu.thread_count: 10
machdep.cpu.brand_string: Apple M1 Max
```
2022-06-02 04:14:02 +00:00
bors
e838059d66 Auto merge of #97632 - JohnTitor:rollup-d2ucrjw, r=JohnTitor
Rollup of 6 pull requests

Successful merges:

 - #95594 (Additional `*mut [T]` methods)
 - #97130 (rustdoc: avoid including impl blocks with filled-in generics)
 - #97166 (Move conditions out of recover/report functions.)
 - #97605 (Mention filename in suggestion when it differs from primary span)
 - #97613 (rustdoc: Improve calculation of "Impls on Foreign Types")
 - #97626 (rename PointerAddress → PointerExposeAddress)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-06-01 22:34:38 +00:00
Yuki Okushi
b78c118b09
Rollup merge of #97626 - RalfJung:expose, r=tmiasko
rename PointerAddress → PointerExposeAddress

`PointerAddress` sounds a bit too much like `ptr.addr()`, but this corresponds to `ptr.expose_addr()`.

r? `@tmiasko`
2022-06-02 06:44:29 +09:00
Yuki Okushi
a96e71c752
Rollup merge of #97613 - jsha:implementation-is-on-local-type, r=GuillaumeGomez
rustdoc: Improve calculation of "Impls on Foreign Types"

The existing code to calculate whether an implementation was on a "Foreign Type" was duplicated across the sidebar generation and the page generation. It also came to the wrong conclusion for some cases where both the trait and the "for" type were re-exports.

This PR extracts the logic into a method of `Impl`, breaks it into a multi-line method so it can be commented, and adds a case for when the trait and the "for" type came from the same crate. This fixes some cases - like the platform-specific integer types (`__m256`, `__m128`, etc). But it doesn't fix all cases. See the screenshots below.

[Before](https://doc.rust-lang.org/nightly/std/clone/trait.Clone.html#foreign-impls):

<img src="https://user-images.githubusercontent.com/220205/171338226-59ce6daf-3d76-4bad-bc8d-72a8259a8f43.png" width=200>

[After](https://rustdoc.crud.net/jsha/implementation-is-on-local-type/std/clone/trait.Clone.html):

<img src="https://user-images.githubusercontent.com/220205/171338147-28308a65-1597-4223-be47-9550062404dd.png" width=200>

The remaining types (`CString`, `NulError`, etc) are all from the `alloc` crate, while the `Clone` trait is from the `core` crate. Since `CString` and `Clone` are both re-exported by `std`, they are logically local to each other, but I couldn't figure out a good way to detect that in this code. I figure this is still a good step forward.

Related: #97610

r? `@camelid`
2022-06-02 06:44:29 +09:00
Yuki Okushi
2c1990d0b8
Rollup merge of #97605 - estebank:suggestion-filename, r=oli-obk
Mention filename in suggestion when it differs from primary span
2022-06-02 06:44:28 +09:00
Yuki Okushi
d126de111b
Rollup merge of #97166 - nnethercote:move-conditions-out, r=estebank
Move conditions out of recover/report functions.

`Parser` has six recover/report functions that are passed a boolean, and
nothing is done if the boolean has a particular value.

This PR moves the tests outside the functions. This has the following effects.
- The number of lines of code goes down.
- Some `use` items become shorter.
- Avoids the strangeness whereby 11 out of 12 calls to
  `maybe_recover_from_bad_qpath` pass `true` as the second argument.
- Makes it clear at the call site that only one of
  `maybe_recover_from_bad_type_plus` and `maybe_report_ambiguous_plus` will be
  run.

r? `@estebank`
2022-06-02 06:44:27 +09:00
Yuki Okushi
9fc3fc3a0c
Rollup merge of #97130 - notriddle:notriddle/collect-trait-impls-dup, r=GuillaumeGomez
rustdoc: avoid including impl blocks with filled-in generics

Fixes #94937

# Before

![image](https://user-images.githubusercontent.com/1593513/168933282-02ccc4ae-9c89-4836-ba34-e2bd83946105.png)

# After

![image](https://user-images.githubusercontent.com/1593513/168933255-4c17407d-d8d1-406e-87f5-9ea809437173.png)
2022-06-02 06:44:26 +09:00
Yuki Okushi
3ed9bbe970
Rollup merge of #95594 - the8472:raw_slice_methods, r=yaahc
Additional `*mut [T]` methods

Split out from #94247

This adds the following methods to raw slices that already exist on regular slices

* `*mut [T]::is_empty`
* `*mut [T]::split_at_mut`
* `*mut [T]::split_at_mut_unchecked`

These methods reduce the amount of unsafe code needed to migrate `ChunksMut` and related iterators
to raw slices (#94247)

r? `@m-ou-se`
2022-06-02 06:44:25 +09:00
bors
12cd71f4d3 Auto merge of #97612 - ehuss:update-cargo, r=ehuss
Update cargo

5 commits in 39ad1039d9e3e1746177bf5d134af4c164f95528..38472bc19f2f76e245eba54a6e97ee6821b3c1db
2022-05-25 00:50:02 +0000 to 2022-05-31 02:03:24 +0000
- Emit warning upon encountering multiple packages with the same name (rust-lang/cargo#10701)
- Guide new users to add use `super::*;` to `mod test` (rust-lang/cargo#10706)
- Document how to debug change detection events (rust-lang/cargo#10708)
- fix(publish): add more check when use `publish -p &lt;SPEC&gt;` (rust-lang/cargo#10677)
- fix key formatting when switching to a dotted `WorkspaceSource` (rust-lang/cargo#10705)
2022-06-01 20:06:14 +00:00
Ralf Jung
4dc5d457d8 rename PointerAddress → PointerExposeAddress 2022-06-01 14:08:17 -04:00
Michael Howell
434adfff42 rustdoc: add test case for auto traits on slice primitive 2022-06-01 11:00:25 -07:00
bors
b5a2d27f8f Auto merge of #97624 - matthiaskrgr:rollup-rtcqjx9, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #96271 (suggest `?` when method is missing on `Result<T, _>` but found on `T`)
 - #97264 (Suggest `extern crate foo` when failing to resolve `use foo`)
 - #97592 (rustdoc: also index impl trait and raw pointers)
 - #97621 (update Miri)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-06-01 17:25:29 +00:00
Michael Howell
57450c637c Update src/librustdoc/passes/collect_trait_impls.rs
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2022-06-01 09:55:33 -07:00
Esteban Küber
310b1a9062 Mention filename in suggestion when it differs from primary span 2022-06-01 09:52:03 -07:00
Jacob Hoffman-Andrews
37d363879e Improve calculation of "Impls on Foreign Types" 2022-06-01 09:11:50 -07:00
Matthias Krüger
89e765fb56
Rollup merge of #97621 - RalfJung:miri, r=RalfJung
update Miri

Fixes https://github.com/rust-lang/rust/issues/97563
Cc ``@rust-lang/miri`` r? ``@ghost``
2022-06-01 17:11:07 +02:00
Matthias Krüger
1730b62c45
Rollup merge of #97592 - notriddle:notriddle/impl-trait, r=GuillaumeGomez
rustdoc: also index impl trait and raw pointers

Revives #92339
2022-06-01 17:11:06 +02:00
Matthias Krüger
daedae7b23
Rollup merge of #97264 - TaKO8Ki:suggest-extern-crate-when-failing-to-resolve-use-crate, r=estebank
Suggest `extern crate foo` when failing to resolve `use foo`

closes #97095

r? ``@estebank``
2022-06-01 17:11:05 +02:00
Matthias Krüger
7d4cf710e2
Rollup merge of #96271 - compiler-errors:suggest-question-mark, r=estebank
suggest `?` when method is missing on `Result<T, _>` but found on `T`

The wording needs help, I think.

Fixes #95729
2022-06-01 17:11:04 +02:00
bors
8256e97231 Auto merge of #97622 - JohnTitor:rollup-4qoxrjn, r=JohnTitor
Rollup of 9 pull requests

Successful merges:

 - #94647 (Expose `get_many_mut` and `get_many_unchecked_mut` to HashMap)
 - #97216 (Ensure we never consider the null pointer dereferencable)
 - #97399 (simplify code of finding arg index in `opt_const_param_of`)
 - #97470 (rustdoc: add more test coverage)
 - #97498 (Corrected EBNF grammar for from_str)
 - #97562 (Fix comment in `poly_project_and_unify_type`)
 - #97580 (Add regression test for #71546)
 - #97611 (Tweak insert docs)
 - #97616 (Remove an unnecessary `Option`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-06-01 14:44:20 +00:00
Yuki Okushi
85fdef087c
Rollup merge of #97616 - TaKO8Ki:remove-unnecessary-option, r=Dylan-DPC
Remove an unnecessary `Option`
2022-06-01 23:36:53 +09:00
Yuki Okushi
2c3a8cf0a4
Rollup merge of #97611 - azdavis:master, r=Dylan-DPC
Tweak insert docs

For `{Hash, BTree}Map::insert`, I always have to take a few extra seconds to think about the slight weirdness about the fact that if we "did not" insert (which "sounds" false), we return true, and if we "did" insert, (which "sounds" true), we return false.

This tweaks the doc comments for the `insert` methods of those types (as well as what looks like a rustc internal data structure that I found just by searching the codebase for "If the set did") to first use the "Returns whether _something_" pattern used in e.g. `remove`, where we say that `remove` "returns whether the value was present".
2022-06-01 23:36:52 +09:00
Yuki Okushi
a7bd0d0e07
Rollup merge of #97580 - JohnTitor:issue-71546, r=compiler-errors
Add regression test for #71546

Closes #71546
r? `@compiler-errors`
2022-06-01 23:36:51 +09:00
Yuki Okushi
2f99f1b3a4
Rollup merge of #97562 - compiler-errors:comment-poly_project_and_unify_type, r=lcnr
Fix comment in `poly_project_and_unify_type`

Renamed some variants to match `ProjectAndUnifyResult`
2022-06-01 23:36:50 +09:00
Yuki Okushi
e1d2e65463
Rollup merge of #97498 - ijchen:master, r=Mark-Simulacrum
Corrected EBNF grammar for from_str

Hello! This is my first time contributing to an open-source project. I'm excited to have the chance to contribute to the rust community 🥳

I noticed an issue with the documentation for `from_str` in `f32` and `f64`. It states that "All strings that adhere to the following [EBNF](https://www.w3.org/TR/REC-xml/#sec-notation) grammar when lowercased will result in an `Ok` being returned. I believe this is incorrect for the string `"."`, which is valid for the given EBNF grammar, but does not result in an `Ok` being returned ([playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=09f891aa87963a56d3b0d715d8cbc2b4)). I have simplified the grammar in a way which fixes that, but is otherwise identical.

Previously, the `Number` part of the EBNF grammar had an option for `'.' Digit*`, which would include the string `"."`. This is not valid, and does not return an Ok as stated. The corrected version removes this, and still allows for the `'.' Digit+` case with the already existing `Digit* '.' Digit+` case.
2022-06-01 23:36:49 +09:00
Yuki Okushi
a1dc541c69
Rollup merge of #97470 - notriddle:notriddle/test-cases, r=GuillaumeGomez
rustdoc: add more test coverage

https://github.com/rust-lang/rust/issues/91113
2022-06-01 23:36:48 +09:00
Yuki Okushi
9c61f817eb
Rollup merge of #97399 - SparrowLii:arg_index, r=oli-obk
simplify code of finding arg index in `opt_const_param_of`

From the FIXME in the impl of `opt_const_param_of`. Part of the code is simplified by blending two iterator statements and using `let...else` statement.
2022-06-01 23:36:47 +09:00
Yuki Okushi
2ab919ad9c
Rollup merge of #97216 - RalfJung:null-ptr-check, r=oli-obk
Ensure we never consider the null pointer dereferencable

This replaces the checks that are being removed in https://github.com/rust-lang/rust/pull/97188. Those checks were too early and hence incorrect.
2022-06-01 23:36:46 +09:00
Yuki Okushi
9ddae15532
Rollup merge of #94647 - Urgau:hash-map-many-mut, r=Amanieu
Expose `get_many_mut` and `get_many_unchecked_mut` to HashMap

This pull-request expose the function [`get_many_mut`](https://docs.rs/hashbrown/0.12.0/hashbrown/struct.HashMap.html#method.get_many_mut) and [`get_many_unchecked_mut`](https://docs.rs/hashbrown/0.12.0/hashbrown/struct.HashMap.html#method.get_many_unchecked_mut) from `hashbrown` to the standard library `HashMap` type. They obviously keep the same API and are added under the (new) `map_many_mut` feature.

- `get_many_mut`: Attempts to get mutable references to `N` values in the map at once.
- `get_many_unchecked_mut`: Attempts to get mutable references to `N` values in the map at once, without validating that the values are unique.
2022-06-01 23:36:45 +09:00
Ralf Jung
9f2b69d344 update Miri 2022-06-01 09:31:04 -04:00
Yuki Okushi
ea50d773e3
Add regression test for #71546 2022-06-01 20:04:57 +09:00
Takayuki Maeda
8d007aa06d remove an unnecessary Option 2022-06-01 17:06:07 +09:00
Eric Huss
3fb5df026f Update cargo 2022-05-31 22:50:43 -07:00
Ariel Davis
b02146a370 Tweak insert docs 2022-05-31 22:08:14 -07:00
bors
395a09c3da Auto merge of #97553 - nbdd0121:lib, r=Mark-Simulacrum
Add `#[inline]` to `Vec`'s `Deref/DerefMut`

This should help #97552 (although I haven't verified).
2022-06-01 04:52:11 +00:00
yifei
1446bce35e use 128 cache align for m1 mac 2022-06-01 12:07:30 +08:00
bors
02916c4c75 Auto merge of #97435 - Patryk27:bump-compiler-builtins, r=Dylan-DPC
library/std: Bump compiler_builtins

Some neat changes include faster float conversions & fixes for AVR 🙂

(note that's it's my first time upgrading `compiler_builtins`, so I'm not 100% sure if bumping `library/std/Cargo.toml` is enough; certainly seems to be so, though.)
2022-06-01 01:49:04 +00:00
bors
6f481f8b71 Auto merge of #97600 - matthiaskrgr:rollup-yivyeu5, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #97316 (Put a bound on collection misbehavior)
 - #97578 (alloc: remove repeated word in comment)
 - #97593 (⬆️ rust-analyzer)
 - #97596 (Fixup feature name to be more consistent with others)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-05-31 23:24:39 +00:00
Loïc BRANSTETT
0a6001b5a0 Expose get_many_mut and get_many_unchecked_mut to HashMap 2022-06-01 00:16:23 +02:00
Matthias Krüger
31fccd1a44
Rollup merge of #97596 - WaffleLapkin:fixup_feature_name, r=compiler-errors
Fixup feature name to be more consistent with others

`slice_from_mut_ptr_range_const` -> `const_slice_from_mut_ptr_range`, we usually have `const` in the front.

I've made a typo in  #97419
2022-05-31 23:11:37 +02:00
Matthias Krüger
1998aefc0a
Rollup merge of #97593 - lnicola:rust-analyzer-2022-05-31, r=lnicola
⬆️ rust-analyzer

r? `@ghost`
2022-05-31 23:11:36 +02:00
Matthias Krüger
0d1e5465f3
Rollup merge of #97578 - ojeda:checkpatch, r=JohnTitor
alloc: remove repeated word in comment

Linux's `checkpatch.pl` reports:

```txt
#42544: FILE: rust/alloc/vec/mod.rs:2692:
WARNING: Possible repeated word: 'to'
+            // - Elements are :Copy so it's OK to to copy them, without doing
```

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2022-05-31 23:11:35 +02:00
Matthias Krüger
4f4a819fa9
Rollup merge of #97316 - CAD97:bound-misbehavior, r=dtolnay
Put a bound on collection misbehavior

As currently written, when a logic error occurs in a collection's trait parameters, this allows *completely arbitrary* misbehavior, so long as it does not cause undefined behavior in std. However, because the extent of misbehavior is not specified, it is allowed for *any* code in std to start misbehaving in arbitrary ways which are not formally UB; consider the theoretical example of a global which gets set on an observed logic error. Because the misbehavior is only bound by not resulting in UB from safe APIs and the crate-level encapsulation boundary of all of std, this makes writing user unsafe code that utilizes std theoretically impossible, as it now relies on undocumented QOI (quality of implementation) that unrelated parts of std cannot be caused to misbehave by a misuse of std::collections APIs.

In practice, this is a nonconcern, because std has reasonable QOI and an implementation that takes advantage of this freedom is essentially a malicious implementation and only compliant by the most langauage-lawyer reading of the documentation.

To close this hole, we just add a small clause to the existing logic error paragraph that ensures that any misbehavior is limited to the collection which observed the logic error, making it more plausible to prove the soundness of user unsafe code.

This is not meant to be formal; a formal refinement would likely need to mention that values derived from the collection can also misbehave after a logic error is observed, as well as define what it means to "observe" a logic error in the first place. This fix errs on the side of informality in order to close the hole without complicating a normal reading which can assume a reasonable nonmalicious QOI.

See also [discussion on IRLO][1].

[1]: https://internals.rust-lang.org/t/using-std-collections-and-unsafe-anything-can-happen/16640

r? rust-lang/libs-api ```@rustbot``` label +T-libs-api -T-libs

This technically adds a new guarantee to the documentation, though I argue as written it's one already implicitly provided.
2022-05-31 23:11:34 +02:00
bors
e094492200 Auto merge of #97582 - tmiasko:pointer-address-cast, r=oli-obk
Add a pointer to address cast kind

A pointer to address cast are often special-cased. Introduce a dedicated cast kind to make them easy distinguishable.
2022-05-31 21:06:11 +00:00
Maybe Waffle
2aef6c5436 Fixup feature name to be more consistent with others
`slice_from_mut_ptr_range_const` -> `const_slice_from_mut_ptr_range`,
we usually have `const` in the front.
2022-05-31 23:12:28 +04:00
Laurențiu Nicola
145a558785 ⬆️ rust-analyzer 2022-05-31 21:32:15 +03:00
Michael Howell
14d8baf365 rustdoc: also index raw pointers
Co-authored-by: Noah Lev <camelidcamel@gmail.com>
2022-05-31 11:21:55 -07:00
Michael Howell
59d35d6e90 rustdoc: also index impl trait 2022-05-31 11:13:24 -07:00