Commit Graph

170975 Commits

Author SHA1 Message Date
Nicholas Nethercote
ccd956aca6 Remove Cursor::append.
It's a weird function: it lets you modify the token stream in the middle
of iteration. There is only one call site, and it is only used for the
rare `ProceduralMasquerade` legacy case.
2022-06-20 09:19:10 +10:00
Yuki Okushi
761f83f683
Rollup merge of #98257 - kadiwa4:into_future_doc_typos, r=Dylan-DPC
Fix typos in `IntoFuture` docs
2022-06-20 07:37:43 +09:00
Yuki Okushi
bfa6cd9c68
Rollup merge of #98225 - bjorn3:stable_target_json_hash, r=nagisa
Make debug_triple depend on target json file content rather than file path

This ensures that changes to target json files will force a recompilation. And more importantly that moving the files doesn't force a recompilation.

This should fix https://github.com/Rust-for-Linux/linux/issues/792 (cc ``@ojeda)``
2022-06-20 07:37:42 +09:00
Yuki Okushi
77316a4aaa
Rollup merge of #97912 - Kixunil:stabilize_path_try_exists, r=dtolnay
Stabilize `Path::try_exists()` and improve doc

This stabilizes the `Path::try_exists()` method which returns
`Result<bool, io::Error>` instead of `bool` allowing handling of errors
unrelated to the file not existing. (e.g permission errors)

Along with the stabilization it also:

* Warns that the `exists()` method is error-prone and suggests to use
  the newly stabilized one.
* Suggests it instead of `metadata()` to handle errors.
* Mentions TOCTOU bugs to avoid false assumption that `try_exists()` is
  completely safe fixed version of `exists()`.
* Renames the feature of still-unstable `std::fs::try_exists()` to
  `fs_try_exists` to avoid name conflict.

The tracking issue #83186 remains open to track `fs_try_exists`.
2022-06-20 07:37:41 +09:00
Yuki Okushi
9d4e08e725
Rollup merge of #95534 - jyn514:std-mem-copy, r=joshtriplett
Add `core::mem::copy` to complement `core::mem::drop`.

This is useful for combinators. I didn't add `clone` since you can already
use `Clone::clone` in its place; copy has no such corresponding function.
2022-06-20 07:37:40 +09:00
bors
611e7b9cea Auto merge of #97268 - jyn514:faster-assemble, r=Mark-Simulacrum
Make "Assemble stage1 compiler" orders of magnitude faster (take 2)

This used to take upwards of 5 seconds for me locally. I found that the culprit was copying the downloaded LLVM shared object:
```
[22:28:03] Install "/home/jnelson/rust-lang/rust/build/x86_64-unknown-linux-gnu/ci-llvm/lib/libLLVM-14-rust-1.62.0-nightly.so" to "/home/jnelson/rust-lang/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libLLVM-14-rust-1.62.0-nightly.so"
[22:28:09]   c Sysroot { compiler: Compiler { stage: 1, host: x86_64-unknown-linux-gnu(x86_64-unknown-linux-gnu) } }
```

It turned out that `install()` used full copies unconditionally. Change it to try using a hard-link before falling back to copying.

- Panic if we generate a symbolic link in a tarball
- Change install to use copy internally, like in my previous PR
- Change copy to dereference symbolic links, which avoids the previous regression in #96803.

I also took the liberty of fixing `x dist llvm-tools` to work even if you don't call `x build` previously.
2022-06-19 22:22:07 +00:00
Michael Goulet
4400a26e31 Make missing argument placeholder more obvious that it's a placeholder 2022-06-19 15:10:42 -07:00
Joshua Nelson
9ac6277bad Add core::mem::copy to complement core::mem::drop.
This is useful for combinators. I didn't add `clone` since you can already
use `Clone::clone` in its place; copy has no such corresponding function.
2022-06-19 16:43:19 -05:00
Camille GILLOT
4b79b8bfa1 Only use special async fn case for actual async fns in borrowck diagnostics. 2022-06-19 23:30:43 +02:00
Joshua Nelson
057eab7ae9 Make "Assemble stage1 compiler" orders of magnitude faster
This used to take upwards of 5 seconds for me locally. I found that the
culprit was copying the downloaded LLVM shared object:
```
[22:28:03] Install "/home/jnelson/rust-lang/rust/build/x86_64-unknown-linux-gnu/ci-llvm/lib/libLLVM-14-rust-1.62.0-nightly.so" to "/home/jnelson/rust-lang/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libLLVM-14-rust-1.62.0-nightly.so"
[22:28:09]   c Sysroot { compiler: Compiler { stage: 1, host: x86_64-unknown-linux-gnu(x86_64-unknown-linux-gnu) } }
```

It turned out that `install()` used full copies unconditionally. Change
it to use `copy()` internally, which uses hard links instead when
available.

Note that this has a change in behavior: Installing a file will also
change permissions on the source, not just the destination, if hard
links are used.

To avoid changing the behavior on symlinks for existing code, I
introduce a new function `copy_internal` which only dereferences
symlinks when told to do so.
2022-06-19 15:54:31 -05:00
Joshua Nelson
b9eedea4b0 Panic if dist generates a symbolic link in a generated tarball
This avoids regressions in rustup-toolchain-install-master
2022-06-19 15:54:31 -05:00
Camille GILLOT
bc6a2c11ee Leave the responsibility to create Fresh lifetimes to lowering. 2022-06-19 22:32:43 +02:00
Joshua Nelson
1deca0425d Greatly improve error reporting for futures and generators in note_obligation_cause_code
Most futures don't go through this code path, because they're caught by
`maybe_note_obligation_cause_for_async_await`. But all generators do,
and `maybe_note` is imperfect and doesn't catch all futures. Improve the error message for those it misses.

At some point, we may want to consider unifying this with the code for `maybe_note_async_await`,
so that `async_await` notes all parent constraints, and `note_obligation` can point to yield points.
But both functions are quite complicated, and it's not clear to me how to combine them;
this seems like a good incremental improvement.
2022-06-19 15:31:22 -05:00
Camille GILLOT
dc614b90ca Make matches exhaustive. 2022-06-19 22:30:30 +02:00
Camille GILLOT
87c841e190 Remove the region terminology. 2022-06-19 22:28:53 +02:00
bors
bb8c2f4117 Auto merge of #98247 - jackh726:regionkind-rustc-type-ir, r=compiler-errors
Move RegionKind to rustc_type_ir

(Also UniverseIndex)

r? rust-lang/types
2022-06-19 19:55:45 +00:00
jmaargh
95dc353006 Fix documentation for with_capacity and reserve families of methods
Documentation for the following methods

    with_capacity
    with_capacity_in
    with_capacity_and_hasher
    reserve
    reserve_exact
    try_reserve
    try_reserve_exact

was inconsistent and often not entirely correct where they existed on the following types

    Vec
    VecDeque
    String
    OsString
    PathBuf
    BinaryHeap
    HashSet
    HashMap
    BufWriter
    LineWriter

since the allocator is allowed to allocate more than the requested capacity in all such cases, and will frequently "allocate" much more in the case of zero-sized types (I also checked BufReader, but there the docs appear to be accurate as it appears to actually allocate the exact capacity).

Some effort was made to make the documentation more consistent between types as well.

Fix with_capacity* methods for Vec

Fix *reserve*  methods for Vec

Fix docs for *reserve* methods of VecDeque

Fix docs for String::with_capacity

Fix docs for *reserve* methods of String

Fix docs for OsString::with_capacity

Fix docs for *reserve* methods on OsString

Fix docs for with_capacity* methods on HashSet

Fix docs for *reserve methods of HashSet

Fix docs for with_capacity* methods of HashMap

Fix docs for *reserve methods on HashMap

Fix expect messages about OOM in doctests

Fix docs for BinaryHeap::with_capacity

Fix docs for *reserve* methods of BinaryHeap

Fix typos

Fix docs for with_capacity on BufWriter and LineWriter

Fix consistent use of `hasher` between `HashMap` and `HashSet`

Fix warning in doc test

Add test for capacity of vec with ZST

Fix doc test error
2022-06-19 20:46:49 +01:00
bors
2b646bd533 Auto merge of #98224 - eddyb:proc-macro-spurious-repr, r=bjorn3
proc_macro/bridge: remove `#[repr(C)]` from non-ABI-relevant types.

Not sure how this happened, maybe some of these were passed through the bridge a long time ago?

r? `@bjorn3`
2022-06-19 17:32:12 +00:00
bjorn3
b4b536d34d Preserve the path of the target spec json file for usage by rustdoc 2022-06-19 15:33:09 +00:00
KaDiWa4
f0144aea74
typos in IntoFuture docs 2022-06-19 17:13:48 +02:00
bors
68d0b29098 Auto merge of #98255 - Dylan-DPC:rollup-hr129rg, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #98105 (rustdoc: remove tuple link on round braces)
 - #98136 (Rename `impl_constness` to `constness`)
 - #98146 (Remove --memory-init-file flag when linking with Emscripten)
 - #98219 (Skip late bound regions in GATSubstCollector)
 - #98233 (Remove accidental uses of `&A: Allocator`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-06-19 14:51:28 +00:00
Dylan DPC
6a2a56da45
Rollup merge of #98233 - RalfJung:ref-alloc, r=thomcc
Remove accidental uses of `&A: Allocator`

Cc https://github.com/rust-lang/rust/issues/98232

Fixes https://github.com/rust-lang/rust/issues/98176 (for real this time)
2022-06-19 15:26:31 +02:00
Dylan DPC
cf3245e7c3
Rollup merge of #98219 - eggyal:gatsubstcollector-without-folding, r=jackh726
Skip late bound regions in GATSubstCollector

#93227 liberated late bound regions when collecting GAT substs in wfcheck.  It should simply skip late bound regions instead.

r? ``@compiler-errors``
2022-06-19 15:26:30 +02:00
Dylan DPC
88cb597e7a
Rollup merge of #98146 - hoodmane:remove-memory-init-flag, r=petrochenkov
Remove --memory-init-file flag when linking with Emscripten

This flag does nothing. It only applies when generating asmjs JavaScript.
``@sbc100``
2022-06-19 15:26:29 +02:00
Dylan DPC
6e8f541fff
Rollup merge of #98136 - fee1-dead-contrib:rename_impl_constness, r=oli-obk
Rename `impl_constness` to `constness`

The current code is a basis for `is_const_fn_raw`, and `impl_constness`
is no longer a valid name, which is previously used for determining the
constness of impls, and not items in general.

r? `@oli-obk`
2022-06-19 15:26:28 +02:00
Dylan DPC
3174a694e0
Rollup merge of #98105 - notriddle:notriddle/tuple-links, r=jsha
rustdoc: remove tuple link on round braces

This is #98069 but for tuples. The reasoning is the same:

* This PR also changes it so that tuples with all-generic elements still link to the primitive.tuple.html page, just like slices. So there still plenty of on-ramps for anybody who doesn't know about it.
* It's too hard to see when round braces are a separate link from the type inside of them.
* It's too hard to click even if you do notice them.

Before:

* impl [ToSocketAddrs](https://doc.rust-lang.org/nightly/std/net/trait.ToSocketAddrs.html) for [(](https://doc.rust-lang.org/nightly/std/primitive.tuple.html)[IpAddr](https://doc.rust-lang.org/nightly/std/net/enum.IpAddr.html), [u16](https://doc.rust-lang.org/nightly/std/primitive.u16.html)[)](https://doc.rust-lang.org/nightly/std/primitive.tuple.html)
* impl<K, V> [FromIterator](https://notriddle.com/notriddle-rustdoc-test/std/iter/trait.FromIterator.html)<[(](https://notriddle.com/notriddle-rustdoc-test/std/primitive.tuple.html)K, V[)](https://notriddle.com/notriddle-rustdoc-test/std/primitive.tuple.html)> for [BTreeMap](https://notriddle.com/notriddle-rustdoc-test/std/collections/struct.BTreeMap.html)<K, V>

After:

* impl [ToSocketAddrs](https://doc.rust-lang.org/nightly/std/net/trait.ToSocketAddrs.html) for ([IpAddr](https://doc.rust-lang.org/nightly/std/net/enum.IpAddr.html), [u16](https://doc.rust-lang.org/nightly/std/primitive.u16.html))
* impl<K, V> [FromIterator](https://notriddle.com/notriddle-rustdoc-test/std/iter/trait.FromIterator.html)<[(K, V)](https://notriddle.com/notriddle-rustdoc-test/std/primitive.tuple.html)> for [BTreeMap](https://notriddle.com/notriddle-rustdoc-test/std/collections/struct.BTreeMap.html)<K, V>
2022-06-19 15:26:27 +02:00
bjorn3
7643f82e01 Small refactoring 2022-06-19 12:56:31 +00:00
bjorn3
18c6fe5798 Remove the source archive functionality of ArchiveWriter
We now build archives through strictly additive means rather than taking
an existing archive and potentially substracting parts.
2022-06-19 12:56:31 +00:00
bjorn3
7ff0df5102 Fix "Remove src_files and remove_file" 2022-06-19 12:56:31 +00:00
bors
67404f7200 Auto merge of #98238 - cjgillot:lint-mod, r=oli-obk
Make some lints incremental.

Those lints do not track a state, so don't need to be performed for the full crate at once.
2022-06-19 12:28:59 +00:00
Takayuki Maeda
094d8cc954 fix tests including dead_code warnings 2022-06-19 21:00:25 +09:00
Robin Raymond
43c6f9c691 Make sure we don't match noalias in later lines 2022-06-19 11:07:35 +00:00
Robin Raymond
cb20e252ad Add test to verify noalias is not being added 2022-06-19 10:38:17 +00:00
Takayuki Maeda
3a023e7e58 collapse dead code warnings into a single diagnostic
add comments in `store_dead_field_or_variant`

support multiple log level

add a item ident label

fix ui tests

fix a ui test

fix a rustdoc ui test

use let chain

refactor: remove `store_dead_field_or_variant`

fix a tiny bug
2022-06-19 18:32:56 +09:00
Takayuki Maeda
da27551f3a emit only one note per unused struct field 2022-06-19 18:32:56 +09:00
bors
15fc228d0d Auto merge of #97791 - m-ou-se:const-locks, r=m-ou-se
Make {Mutex, Condvar, RwLock}::new() const.

This makes it possible to have `static M: Mutex<_> = Mutex::new(..);` 🎉

Our implementations [on Linux](https://github.com/rust-lang/rust/pull/95035), [on Windows](https://github.com/rust-lang/rust/pull/77380), and various BSDs and some tier 3 platforms have already been using a non-allocating const-constructible implementation. As of https://github.com/rust-lang/rust/pull/97647, the remaining platforms (most notably macOS) now have a const-constructible implementation as well. This means we can finally make these functions publicly const.

Tracking issue: https://github.com/rust-lang/rust/issues/93740
2022-06-19 08:20:36 +00:00
Camille GILLOT
1e7ec943a8 Bless 32bit ui tests. 2022-06-19 09:53:00 +02:00
Camille GILLOT
47b8d26eff Use ensure for UnusedBrokenConst. 2022-06-19 09:44:32 +02:00
Robin Raymond
09d937ed5f Add comment explaining why we use NonNull 2022-06-19 09:23:35 +02:00
Robin Raymond
fa1656e8ae Add safety comments 2022-06-19 09:23:35 +02:00
Robin Raymond
0157593c74 Documentation typo 2022-06-19 09:23:35 +02:00
Robin Raymond
08650fbb50 *const to NonNull plus documentation 2022-06-19 09:23:32 +02:00
Robin Raymond
cf1238e799 Address comments 2022-06-19 09:22:40 +02:00
Robin Raymond
391f800705 More formatting 2022-06-19 09:22:40 +02:00
Robin Raymond
0b6e6e3d63 Formatting 2022-06-19 09:22:32 +02:00
Robin Raymond
7cefa8f995 Make RwLockReadGuard covariant 2022-06-19 09:21:28 +02:00
bors
5fb8a39266 Auto merge of #97367 - WaffleLapkin:stabilize_checked_slice_to_str_conv, r=dtolnay
Stabilize checked slice->str conversion functions

This PR stabilizes the following APIs as `const` functions in Rust 1.63:
```rust
// core::str

pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error>;

impl Utf8Error {
    pub const fn valid_up_to(&self) -> usize;
    pub const fn error_len(&self) -> Option<usize>;
}
```

Note that the `from_utf8_mut` function is not stabilized as unique references (`&mut _`) are [unstable in const context].

FCP: https://github.com/rust-lang/rust/issues/91006#issuecomment-1134593095

[unstable in const context]: https://github.com/rust-lang/rust/issues/57349
2022-06-19 05:51:42 +00:00
Jack Huey
1e9f8df6bb Move RegionKind to rustc_type_ir 2022-06-19 00:20:27 -04:00
bors
6c9be6e4e9 Auto merge of #97944 - nikic:freebsd-update, r=Mark-Simulacrum
Update FreeBSD toolchain to 12.3

Update the FreeBSD toolchain to 12.3. FreeBSD 11 is EOL since September 30, 2021.

I've locally verified that the `dist-x86_64-freebsd` docker image builds successfully.

r? `@Mark-Simulacrum`
2022-06-19 03:30:05 +00:00
Hood Chatham
3fb6d45af9 ENH Move --memory-init-file flag from EmLinker to asmjs target spec 2022-06-18 17:48:00 -07:00