Commit Graph

170591 Commits

Author SHA1 Message Date
Dylan DPC fd9ca0c25e
Rollup merge of #93080 - SkiFire13:itermut-as_mut_slice, r=m-ou-se
Implement `core::slice::IterMut::as_mut_slice` and `impl<T> AsMut<[T]> for IterMut<'_, T>`

As per [the zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/.60std.3A.3Aslice.3A.3AIterMut.3A.3Aas_mut_slice.60), the `AsMut` impl has been commented out, with a comment near the `#[unstable(...)]` to uncomment it when `as_mut_slice` gets stabilized.
2022-06-20 14:56:33 +02:00
bors 4104596251 Auto merge of #98284 - JohnTitor:rollup-7lbs143, r=JohnTitor
Rollup of 5 pull requests

Successful merges:

 - #98183 (Fix pretty printing of empty bound lists in where-clause)
 - #98268 (Improve `lifetime arguments are not allowed on` error message)
 - #98273 (Fix minor documentation typo)
 - #98274 (Minor improvements on error for `Self` type in items that don't allow it)
 - #98281 (Fix typo in `HashMap::drain` docs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-06-20 08:18:07 +00:00
Mara Bos c867529461
Show #![feature] in example. 2022-06-20 10:00:55 +02:00
Yuki Okushi 66dbc3fda7
Rollup merge of #98281 - Nilstrieb:map-drain-typo, r=JohnTitor
Fix typo in `HashMap::drain` docs

It's a map, not a vector.

Fixes #98275.
2022-06-20 16:41:50 +09:00
Yuki Okushi 1888499be3
Rollup merge of #98274 - compiler-errors:self-type-error, r=cjgillot
Minor improvements on error for `Self` type in items that don't allow it

Fixes #93796
2022-06-20 16:41:49 +09:00
Yuki Okushi f459d8d6b9
Rollup merge of #98273 - Piturnah:patch-1, r=compiler-errors
Fix minor documentation typo

Fixes incorrect pluralisation of `crate` in documentation for rustc_trait_selection
2022-06-20 16:41:48 +09:00
Yuki Okushi e635704643
Rollup merge of #98268 - compiler-errors:disallowed-generics-better, r=lcnr
Improve `lifetime arguments are not allowed on` error message

Actually mention what thing we're improperly trying to add lifetime generics to.
2022-06-20 16:41:47 +09:00
Yuki Okushi b6fb582cb7
Rollup merge of #98183 - dtolnay:emptybound, r=lcnr
Fix pretty printing of empty bound lists in where-clause

Repro:

```rust
macro_rules! assert_item_stringify {
    ($item:item $expected:literal) => {
        assert_eq!(stringify!($item), $expected);
    };
}

fn main() {
    assert_item_stringify! {
        fn f<'a, T>() where 'a:, T: {}
        "fn f<'a, T>() where 'a:, T: {}"
    }
}
```

Previously this assertion would fail because rustc renders the where-clause as `where 'a, T` which is invalid syntax.

This PR makes the above assertion pass.

This bug also affects `-Zunpretty=expanded`. The intention is for that to emit syntactically valid code, but the buggy output is not valid Rust syntax.

```console
$ rustc <(echo "fn f<'a, T>() where 'a:, T: {}") -Zunpretty=expanded
#![feature(prelude_import)]
#![no_std]
#[prelude_import]
use ::std::prelude::rust_2015::*;
#[macro_use]
extern crate std;
fn f<'a, T>() where 'a, T {}
```

```console
$ rustc <(echo "fn f<'a, T>() where 'a:, T: {}") -Zunpretty=expanded | rustc -
error: expected `:`, found `,`
 --> <anon>:7:23
  |
7 | fn f<'a, T>() where 'a, T {}
  |                       ^ expected `:`
```
2022-06-20 16:41:46 +09:00
nils 2ead0d7457 Fix typo in `HashMap::drain` docs
It's a map, not a vector.
2022-06-20 09:17:08 +02:00
bors a5c039cdb7 Auto merge of #98264 - compiler-errors:missing-arg-placeholder, r=jackh726
Make missing argument placeholder more obvious that it's a placeholder

Use `/* ty */` instead of `{ty}`, since people might be misled into thinking that this is valid syntax, and not just a diagnostic placeholder.

Fixes #96880
2022-06-20 05:37:17 +00:00
bors 9a0b774966 Auto merge of #97931 - xldenis:fix-if-let-source-scopes, r=nagisa
Fix `SourceScope` for `if let` bindings.

Fixes #97799.

I'm not sure how to test this properly, is there any way to observe the difference in behavior apart from `ui` tests? I'm worried that they would be overlooked in the case of a regression.
2022-06-20 03:08:52 +00:00
Michael Goulet 047de83e02 Don't suggest adding Self as a type parameter 2022-06-19 19:44:00 -07:00
Michael Goulet 018c319b21 Mention what item is using an invalid `Self` type 2022-06-19 19:43:40 -07:00
Peter Hebden 3ce6e125fa
Fix minor documentation typo
Incorrect pluralisation of `crate`
2022-06-20 03:30:21 +01:00
Michael Goulet 2762d62990 Be more specific for what lifetimes are not allowed on 2022-06-19 18:08:29 -07:00
bors 17c6bde14e Auto merge of #98265 - JohnTitor:rollup-wtfqc4g, r=JohnTitor
Rollup of 4 pull requests

Successful merges:

 - #95534 (Add `core::mem::copy` to complement `core::mem::drop`.)
 - #97912 (Stabilize `Path::try_exists()` and improve doc)
 - #98225 (Make debug_triple depend on target json file content rather than file path)
 - #98257 (Fix typos in `IntoFuture` docs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-06-20 00:40:07 +00: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
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
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
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
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
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
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
bors 3b98c08288 Auto merge of #98242 - matthiaskrgr:rollup-qbbkwtf, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #97511 (Don't build the compiler before building rust-demangler)
 - #98165 (once cell renamings)
 - #98207 (Update cargo)
 - #98229 (Add new eslint checks)
 - #98230 (Fix weird js condition)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-06-19 00:25:25 +00:00
Matthias Krüger 267fe3bf81
Rollup merge of #98230 - GuillaumeGomez:weird-js-condition, r=notriddle
Fix weird js condition

While going around the code, I found this weird condition. Fixing also affects the generated results in some cases apparently (could only find this one).

Any idea maybe `@notriddle?`

r? `@notriddle`
2022-06-19 00:17:16 +02:00
Matthias Krüger 0a66e3a552
Rollup merge of #98229 - GuillaumeGomez:eslint-checks, r=Dylan-DPC
Add new eslint checks

r? ```@Dylan-DPC```
2022-06-19 00:17:15 +02:00
Matthias Krüger d13bead874
Rollup merge of #98207 - arlosi:update-cargo, r=Dylan-DPC
Update cargo

4 commits in 4d92f07f34ba7fb7d7f207564942508f46c225d3..8d42b0e8794ce3787c9f7d6d88b02ae80ebe8d19
2022-06-10 01:11:04 +0000 to 2022-06-17 16:46:26 +0000
- Use specific terminology for sparse HTTP-based registry (rust-lang/cargo#10764)
- chore: Upgrade to clap 3.2 (rust-lang/cargo#10753)
- Improve testing framework for http registries (rust-lang/cargo#10738)
- doc: Improve example of using the links field (rust-lang/cargo#10728)
2022-06-19 00:17:14 +02:00
Matthias Krüger f351f347b8
Rollup merge of #98165 - WaffleLapkin:once_things_renamings, r=m-ou-se
once cell renamings

This PR does the renamings proposed in https://github.com/rust-lang/rust/issues/74465#issuecomment-1153703128

- Move/rename `lazy::{OnceCell, Lazy}` to `cell::{OnceCell, LazyCell}`
- Move/rename `lazy::{SyncOnceCell, SyncLazy}` to `sync::{OnceLock, LazyLock}`

(I used `Lazy...` instead of `...Lazy` as it seems to be more consistent, easier to pronounce, etc)

```@rustbot``` label +T-libs-api -T-libs
2022-06-19 00:17:13 +02:00
Matthias Krüger e6d28d2ea2
Rollup merge of #97511 - jyn514:faster-cargo-build, r=Mark-Simulacrum
Don't build the compiler before building rust-demangler

This saves a lot of time compiling, since rust-demangler doesn't actually use any unstable features.

This is not quite ideal because it uses ToolStd, not ToolBootstrap, so rust-demangler would be able to add unstable library features in the future. But it's a lot better than before, and `builder.cargo` doesn't currently know how to handle stages other than 0.
2022-06-19 00:17:12 +02:00
Camille GILLOT dae1d97468 Make some lints incremental. 2022-06-19 00:00:36 +02:00