Commit graph

170824 commits

Author SHA1 Message Date
Dylan DPC 99620ad721
Rollup merge of #94855 - m-ou-se:advance-slice-panic-docs, r=kennytm
Panic when advance_slices()'ing too far and update docs.

This updates advance_slices() to panic when advancing too far, like advance() already does. And updates the docs to say so.

See https://github.com/rust-lang/rust/issues/62726#issuecomment-1065253213
2022-06-20 14:56:34 +02:00
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
Chris Denton 740a54c69b
Windows: CommandExt::async_pipes 2022-06-20 12:21:39 +01:00
bors 1d6010816c Auto merge of #97674 - nnethercote:oblig-forest-tweaks, r=nikomatsakis
Obligation forest tweaks

A few minor improvements to the code.

r? `@nikomatsakis`
2022-06-20 10:58:56 +00:00
Chris Denton 8b93147f7e
Stdio::make_pipe 2022-06-20 11:58:38 +01:00
Wei Liu c5f4880e91 Drop magic value 3 from code
Magic value 3 is used to create state for a yield point. It is in fact
the number of reserved variants.

Lift RESERVED_VARIANTS out to module scope and use it instead.
2022-06-20 10:05:04 +00:00
zhangyunhao 98507f202d Optimize heapsort 2022-06-20 08:30:27 +00: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
Takayuki Maeda 1e7ab0bbd7 point at private fields in struct literal 2022-06-20 16:29:05 +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
Nicholas Nethercote 69f45b7860 Add blank lines between methods in proc_macro_server.rs.
Because that's the standard way of doing it.
2022-06-20 13:52:48 +10:00
Preston From f725b97014 Include ForeignItem when visiting types for WF check
Addresses Issue 95665 by including `hir::Node::ForeignItem` as a valid
type to visit in `diagnostic_hir_wf_check`.

Fixes #95665
2022-06-19 21:47:52 -06:00
Nicholas Nethercote 2a5487afb4 Merge TokenStreamBuilder::push into TokenStreamBuilder::build.
Both functions do some modifying of streams using `make_mut`:
- `push` sometimes glues the first token of the next stream to the last
  token of the first stream.
- `build` appends tokens to the first stream.

By doing all of this in the one place, things are simpler. The first
stream can be modified in both ways (if necessary) in the one place, and
any next stream with the first token removed doesn't need to be stored.
2022-06-20 13:46:11 +10:00
Michael Goulet 5373d738e8 Mention formatting macros when encountering ArgumentV1::new in const 2022-06-19 20:18:08 -07: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
Michael Goulet 3d16c22864 Be more hygenic with spans 2022-06-19 16:47:21 -07:00
Michael Goulet 52c9906c4b Use Span::eq_ctxt method instead of .ctxt() == .ctxt() 2022-06-19 16:46:59 -07:00
Michael Goulet 2c3bb42ebd Only omit trailing comma if block doesn't come from macro expansion 2022-06-19 16:46:37 -07:00
Nicholas Nethercote f6b57883e0 Remove TokenStream::from_streams.
By inlining it into the only non-test call site. The one test call site
is changed to use `TokenStreamBuilder`.
2022-06-20 09:33:08 +10:00
Nicholas Nethercote 178b746d04 Remove Cursor::index.
It's unused.
2022-06-20 09:27:58 +10:00
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