Commit Graph

127115 Commits

Author SHA1 Message Date
Ralf Jung e27ef130c1
grammar nit 2020-10-03 12:15:26 +02:00
CAD97 3d07108d36 Add tests for weak into/from raw 2020-09-12 10:38:33 -05:00
CAD97 9d9903c5a5 Allow Weak::as_ptr and friends for unsized T 2020-09-12 10:38:33 -05:00
CAD97 5e7406c956 Adjust sync::Weak::from_raw to support unsized T 2020-09-12 10:38:32 -05:00
CAD97 0c61ce2cf0 ?Sized bounds for rc::Weak::as_ptr and friends 2020-09-12 10:38:22 -05:00
CAD97 728938346b Adjust rc::Weak::from_raw to support unsized T 2020-09-12 10:27:43 -05:00
bors 85109afee9 Auto merge of #76561 - Thomasdezeeuw:iov-constant-limits, r=Amanieu
Use IOV_MAX and UIO_MAXIOV constants in limit vectored I/O

Also updates the libc dependency to 0.2.77 (from 0.2.74) as the
constants were only recently added.

Related #68042, #75005

r? `@Amanieu` (also reviewed #75005)
2020-09-12 12:06:12 +00:00
bors 2d6cbd21b2 Auto merge of #76637 - RalfJung:rollup-eaykf93, r=RalfJung
Rollup of 7 pull requests

Successful merges:

 - #76114 (Add saturating methods for `Duration`)
 - #76297 (rustdoc: fix min_const_generics with ty::Param)
 - #76484 (Add MaybeUninit::assume_init_drop.)
 - #76530 (Eliminate mut reference UB in Drop impl for Rc<T>)
 - #76583 (Update `std::os` module documentation.)
 - #76599 (Finish off revisions for const generics UI tests.)
 - #76615 (Add missing examples on binary core traits)

Failed merges:

r? `@ghost`
2020-09-12 09:34:37 +00:00
Ralf Jung 0ed4bc5993
Rollup merge of #76615 - GuillaumeGomez:missing-examples-binary-ops, r=jyn514
Add missing examples on binary core traits

r? @jyn514
2020-09-12 10:43:24 +02:00
Ralf Jung 90c5b8fad5
Rollup merge of #76599 - hameerabbasi:const-generics-revs, r=lcnr
Finish off revisions for const generics UI tests.

This time it really does fix it. 😅 The only ones left are `min-and-full-same-time.rs`, which doesn't need it, and `array-impls/` which check the feature indirectly.

Fixes #75279.

r? @lcnr
2020-09-12 10:43:22 +02:00
Ralf Jung 2477f070fc
Rollup merge of #76583 - CDirkx:os-doc, r=jonas-schievink
Update `std::os` module documentation.

Adds missing descriptions for the modules `std::os::linux::fs` and `std::os::windows::io`.
Also adds punctuation for consistency with other descriptions.
2020-09-12 10:43:20 +02:00
Ralf Jung a49451c805
Rollup merge of #76530 - carbotaniuman:fix-rc, r=RalfJung
Eliminate mut reference UB in Drop impl for Rc<T>

This changes `self.ptr.as_mut()` with `get_mut_unchecked` which
does not use an intermediate reference.  Arc<T> already handled this
case properly.

Fixes #76509
2020-09-12 10:43:18 +02:00
Ralf Jung c20356e96b
Rollup merge of #76484 - fusion-engineering-forks:maybe-uninit-drop, r=RalfJung
Add MaybeUninit::assume_init_drop.

`ManuallyDrop`'s documentation tells the user to use `MaybeUninit` instead when handling uninitialized data. However, the main functionality of `ManuallyDrop` (`drop`) is not available directly on `MaybeUninit`. Adding it makes it easier to switch from one to the other.

I re-used the `maybe_uninit_extra` feature and tracking issue number (#63567), since it seems very related. (And to avoid creating too many features tracking issues for `MaybeUninit`.)
2020-09-12 10:43:17 +02:00
Ralf Jung 5d90d6ee90
Rollup merge of #76297 - lcnr:const-ty-alias, r=varkor
rustdoc: fix min_const_generics with ty::Param

fixes #75913

r? @varkor cc @jyn514
2020-09-12 10:43:15 +02:00
Ralf Jung 7344f930c0
Rollup merge of #76114 - marmeladema:duration-saturating-ops, r=shepmaster
Add saturating methods for `Duration`

In some project, I needed a `saturating_add` method for `Duration`. I implemented it myself but i thought it would be a nice addition to the standard library as it matches closely with the integers types.

3 new methods have been introduced and are gated by the new `duration_saturating_ops` unstable feature:
* `Duration::saturating_add`
* `Duration::saturating_sub`
* `Duration::saturating_mul`

If have left the tracking issue to `none` for now as I want first to understand if those methods would be acceptable at all. If agreed, I'll update the PR with the tracking issue.

Further more, to match the behavior of integers types, I introduced 2 associated constants:
* `Duration::MIN`: this one is somehow a duplicate from `Duration::zero()` method, but at the time this method was added, `MIN` was rejected as it was considered a different semantic (see https://github.com/rust-lang/rust/pull/72790#issuecomment-636511743).
* `Duration::MAX`

Both have been gated by the already existing unstable feature `duration_constants`, I can introduce a new unstable feature if needed or just re-use the `duration_saturating_ops`.

We might have to decide whether:
* `MIN` should be replaced by `ZERO`?
* associated constants over methods?
2020-09-12 10:43:08 +02:00
bors 2e2e7dec73 Auto merge of #76222 - guswynn:const_diag, r=estebank
Give better suggestion when const Range*'s are used as patterns

Fixes #76191

let me know if there is more/different information you want to show in this case
2020-09-12 07:45:34 +00:00
bors 0f5c769513 Auto merge of #75756 - jyn514:diagnostic-suggestions, r=estebank
Improve suggestions for broken intra-doc links

~~Depends on #74489 and should not be merged before that PR.~~ Merged 🎉
~~Depends on #75916 and should not be merged before.~~ Merged

Fixes https://github.com/rust-lang/rust/issues/75305.

This does a lot of different things 😆.

- Add `PerNS::into_iter()` so I didn't have to keep rewriting hacks around it. Also add `PerNS::iter()` for consistency. Let me know if this should be `impl IntoIterator` instead.
- Make `ResolutionFailure` an enum instead of a unit variant. This was most of the changes: everywhere that said `ErrorKind::ResolutionFailure` now has to say _why_ the link failed to resolve.
- Store the resolution in case of an anchor failure. Previously this was implemented as variants on `AnchorFailure` which was prone to typos and had inconsistent output compared to the rest of the diagnostics.
- Turn some `Err`ors into unwrap() or panic()s, because they're rustdoc bugs and not user error. These have comments as to why they're bugs (in particular this would have caught #76073 as a bug a while ago).
- If an item is not in scope at all, say the first segment in the path that failed to resolve
- If an item exists but not in the current namespaces, say that and suggests linking to that namespace.
- If there is a partial resolution for an item (part of the segments resolved, but not all of them), say the partial resolution and why the following segment didn't resolve.
- Add the `DefId` of associated items to `kind_side_channel` so it can be used for diagnostics (tl;dr of the hack: the rest of rustdoc expects the id of the item, but for diagnostics we need the associated item).
- No longer suggests escaping the brackets for every link that failed to resolve; this was pretty obnoxious. Now it only suggests `\[ \]` if no segment resolved and there is no `::` in the link.
- Add `Suggestion`, which says _what_ to prefix the link with, not just 'prefix with the item kind'.

Places where this is currently buggy:

<details><summary>All outdated</summary>

~~1. When the link has the wrong namespace:~~ Now fixed.

<details>

```rust
/// [type@S::h]
impl S {
	pub fn h() {}
}

/// [type@T::g]
pub trait T {
	fn g() {}
}
```
```
error: unresolved link to `T::g`
  --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:53:6
   |
53 | /// [type@T::g]
   |      ^^^^^^^^^
   |
   = note: this link partially resolves to the trait `T`,
   = note: `T` has no field, variant, or associated item named `g`

error: unresolved link to `S::h`
  --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:48:6
   |
48 | /// [type@S::h]
   |      ^^^^^^^^^
   |
   = note: this link partially resolves to the struct `S`,
   = note: `S` has no field, variant, or associated item named `h`
```
Instead it should suggest changing the disambiguator, the way it currently does for macros:
```
error: unresolved link to `S`
  --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:38:6
   |
38 | /// [S!]
   |      ^^ help: to link to the unit struct, use its disambiguator: `value@S`
   |
   = note: this link resolves to the unit struct `S`, which is not in the macro namespace
```

</details>

2. ~~Associated items for values. It says that the value isn't in scope; instead it should say that values can't have associated items.~~ Fixed.

<details>

```
error: unresolved link to `f::A`
  --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:14:6
   |
14 | /// [f::A]
   |      ^^^^
   |
   = note: no item named `f` is in scope
   = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
```
This is _mostly_ fixed, it now says

```rust
warning: unresolved link to `f::A`
 --> /home/joshua/test-rustdoc/f.rs:1:6
  |
1 | /// [f::A]
  |      ^^^^
  |
  = note: this link partially resolves to the function `f`
  = note: `f` is a function, not a module
```

'function, not a module' seems awfully terse when what I actually mean is '`::` isn't allowed here', though.

</details>

It looks a lot nicer now, it says

```
error: unresolved link to `f::A`
  --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:13:6
   |
13 | /// [f::A]
   |      ^^^^
   |
   = note: `f` is a function, not a module or type, and cannot have associated items
```

3. ~~I'm also not very happy with the second note for this error:~~

<details>
```
error: unresolved link to `S::A`
  --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:19:6
   |
19 | /// [S::A]
   |      ^^^^
   |
   = note: this link partially resolves to the struct `S`,
   = note: `S` has no field, variant, or associated item named `A`
```

but I'm not sure how better to word it.

I ended up going with 'no `A` in `S`' to match `rustc_resolve` but that seems terse as well.

</details>

This now says

```
error: unresolved link to `S::A`
  --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:17:6
   |
17 | /// [S::A]
   |      ^^^^
   |
   = note: the struct `S` has no field or associated item named `A`
```

which I think looks pretty good :)

4. This is minor, but it would be nice to say that `path` wasn't found instead of the full thing:
```
error: unresolved link to `path::to::nonexistent::module`
 --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:8:6
  |
8 | /// [path::to::nonexistent::module]
  |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

It will now look at most 3 paths up (so it reports `path::to` as not in scope), but it doesn't work with arbitrarily many paths.

</details>

~~I recommend only reviewing the last few commits - the first 7 are all from #74489.~~ Rebased so that only the relevant commits are shown. Let me know if I should squash the history some more.

r? `@estebank`
2020-09-12 05:52:14 +00:00
bors 8b6838b6e1 Auto merge of #75021 - cuviper:array_chunks_mut, r=scottmcm
Add `slice::array_chunks_mut`

This follows `array_chunks` from #74373 with a mutable version, `array_chunks_mut`. The implementation is identical apart from mutability. The new tests are adaptations of the `chunks_exact_mut` tests, plus an inference test like the one for `array_chunks`.

I reused the unstable feature `array_chunks` and tracking issue #74985, but I can separate that if desired.

r? `@withoutboats`
cc `@lcnr`
2020-09-12 03:59:46 +00:00
bors 94a7ea271f Auto merge of #74328 - yoshuawuyts:stabilize-future-readiness-fns, r=sfackler
Stabilize core::future::{pending,ready}

This PR stabilizes `core::future::{pending,ready}`, tracking issue https://github.com/rust-lang/rust/issues/70921.

## Motivation

These functions have been on nightly for three months now, and have lived as part of the futures ecosystem for several years. In that time these functions have undergone several iterations, with [the `async-std` impls](https://docs.rs/async-std/1.6.2/async_std/future/index.html) probably diverging the most (using `async fn`, which in hindsight was a mistake).

It seems the space around these functions has been _thoroughly_ explored over the last couple of years, and the ecosystem has settled on the current shape of the functions. It seems highly unlikely we'd want to make any further changes to these functions, so I propose we stabilize.

## Implementation notes

This stabilization PR was fairly straightforward; this feature has already thoroughly been reviewed by the libs team already in https://github.com/rust-lang/rust/pull/70834. So all this PR does is remove the feature gate.
2020-09-12 02:13:28 +00:00
bors 12c10e34a4 Auto merge of #73951 - pickfire:liballoc-intoiter, r=Mark-Simulacrum
Liballoc intoiter refactor
2020-09-11 23:52:03 +00:00
Gus Wynn 5e126c944b better diag when const ranges are used in patterns 2020-09-11 15:02:15 -07:00
bors 99111606fc Auto merge of #73761 - rijenkii:master, r=KodrAus
Add `peek` and `peek_from` to `UnixStream` and `UnixDatagram`

This is my first PR, so I'm sure I've done some things wrong.

This PR:
  * adds `peek` function to `UnixStream`;
  * adds `peek` and `peek_from` to `UnixDatagram`;
  * moves `UnixDatagram::recv_from` implementation to a private function `recv_from_flags`, as `peek_from` uses the same code, just with different flags.

I've taken the documentation from `TcpStream` and `UdpStream`, so it may or may not make sense (I'm bad with english words).
Also, I'm not sure what I should write in the `unstable` attribute, so I've made up the name and set the issue to "none".

Closes #68565.
2020-09-11 21:54:31 +00:00
Guillaume Gomez bb9ce7cb01 Add missing examples on binary core traits 2020-09-11 23:43:37 +02:00
bors bc57bd8c7e Auto merge of #76499 - guswynn:priv_des, r=petrochenkov
Give better diagnostic when using a private tuple struct constructor

Fixes #75907

Some notes:
1. This required some deep changes, including removing a Copy impl for PatKind. If some tests fail, I would still appreciate review on the overall approach
2. this only works with basic patterns (no wildcards for example), and fails if there is any problems getting the visibility of the fields (i am not sure what the failure that can happen in resolve_visibility_speculative, but we check the length of our fields in both cases against each other, so if anything goes wrong, we fall back to the worse error. This could be extended to more patterns
3. this does not yet deal with #75906, but I believe it will be similar
4. let me know if you want more tests
5. doesn't yet at the suggestion that `@yoshuawuyts` suggested at the end of their issue, but that could be added relatively easily (i believe)
2020-09-11 20:01:31 +00:00
Joshua Nelson 5ea3eaf237 Name the current module
'not in scope' -> 'not in `module`'
2020-09-11 14:52:45 -04:00
Gus Wynn c63f634a4b Give better diagnostic when using a private tuple struct constructor 2020-09-11 11:36:42 -07:00
bors 141bb23be8 Auto merge of #76415 - Mark-Simulacrum:bootstrap-cross-compilation, r=alexcrichton
rustbuild: avoid trying to inversely cross-compile for build triple from host triples

This changes rustbuild's cross compilation logic to better match what users expect,
particularly, avoiding trying to inverse cross-compile for the build triple from host triples.
That is, if build=A, host=B, target=B, we do not want to try and compile for A from B.
Indeed, the only "known to run" triple when cross-compiling is the build triple A.
When testing for a particular target we need to be able to run binaries compiled for
that target though.

The last commit also modifies the default set of host/target triples to avoid producing
needless artifacts for the build triple:

The new behavior is to respect --host and --target when passed as the *only*
configured triples (no triples are implicitly added). The default for --host is
the build triple, and the default for --target is the host triple(s), either
configured or the default build triple.

Fixes #76333

r? `@alexcrichton` if possible, otherwise we'll need to hunt down a reviewer
2020-09-11 18:10:44 +00:00
Joshua Nelson b2a5a7a8c2 Remove unnecessary clone 2020-09-11 13:49:45 -04:00
Joshua Nelson 57250eff55 Use `span_label` instead of `note`
This puts the error message closer to the link, making it easier to see
what went wrong.
2020-09-11 13:42:56 -04:00
Joshua Nelson c213c68500 box ResolutionFailures on the heap
This decreases the size of the `Result`s being returned,
improving performance in the common case.
2020-09-11 13:29:55 -04:00
Thomas de Zeeuw c394624471 Ignore unnecessary unsafe warnings
This is a work-around for a libc issue:
https://github.com/rust-lang/libc/issues/1888.
2020-09-11 19:12:06 +02:00
rijenkii 64b8fd7920 Add `peek` and `peek_from` to `UnixStream` and `UnixDatagram` 2020-09-11 20:07:08 +07:00
Mark Rousskov 78125ec6b3 Stop implicitly appending triples to config.toml hosts and targets
Previously, the CLI --target/--host definitions and configured options differed
in their effect: when setting these on the CLI, only the passed triples would be
compiled for, while in config.toml we would also compile for the build triple
and any host triples. This is needlessly confusing; users expect --target and
--host to be identical to editing the configuration file.

The new behavior is to respect --host and --target when passed as the *only*
configured triples (no triples are implicitly added). The default for --host is
the build triple, and the default for --target is the host triple(s), either
configured or the default build triple.
2020-09-11 08:59:01 -04:00
Mark Rousskov b4eb099261 Verify we compile std without involving a b host compiler 2020-09-11 08:59:01 -04:00
Mark Rousskov 3193d52a21 Remove host parameter from step configurations
rustc is a natively cross-compiling compiler, and generally none of our steps
should care whether they are using a compiler built of triple A or B, just the
--target directive being passed to the running compiler. e.g., when building for
some target C, you don't generally want to build two stds: one with a host A
compiler and the other with a host B compiler. Just one std is sufficient.
2020-09-11 08:59:01 -04:00
carbotaniuman b729368d4e Address review comments 2020-09-11 07:25:28 -05:00
bors d778203da2 Auto merge of #76573 - Mark-Simulacrum:bootstrap-with-external-llvm, r=alexcrichton
Only copy LLVM into rust-dev with internal LLVM

This avoids needing to figure out where to locate each of the components with an
external LLVM. This component isn't manifested for rustup consumption and
generally shouldn't matter for anyone except Rust's CI, so it is fine for it to not be
complete elsewhere.

Fixes #76572.

r? `@alexcrichton`
2020-09-11 11:16:33 +00:00
Hameer Abbasi 5e188f5803 Add revisions to const generic type-dependent UI tests. 2020-09-11 11:48:44 +02:00
Hameer Abbasi 9abc6bd28d Add revisions to const generic const_evaluatable_checked tests. 2020-09-11 11:42:32 +02:00
bors a7425476e8 Auto merge of #75611 - JulianKnodt:cg_enum_err, r=lcnr
Add help note when using type in place of const

This adds a small help note when it might be possible that wrapping a parameter in braces might resolve the issue of having a type where a const was expected.

Currently, I am displaying the `HirId`, and I'm not particularly sure where to get the currently displayed path(?).

r? `@lcnr`
2020-09-11 08:40:07 +00:00
bors f5b7dd8181 Auto merge of #76381 - petrochenkov:nomingwcomp, r=Mark-Simulacrum
rustbuild: Do not use `rust-mingw` component when bootstrapping windows-gnu targets

Addresses https://github.com/rust-lang/rust/pull/76326#issuecomment-687273473 (ancient `x86_64-w64-mingw32-gcc` is selected as a linker wrapper, which is not usable in `use_lld=true` mode).

Perhaps the comment about incompatible mingw was true in the past, but many things changed since then.
With this change I was able to build everything successfully locally using a newer mingw toolchain, if it passes through the older toolchain on CI, then it should be good, I think.
2020-09-11 06:36:43 +00:00
bors 94b4de0e07 Auto merge of #75800 - Aaron1011:feature/full-nt-tokens, r=petrochenkov
Attach tokens to all AST types used in `Nonterminal`

We perform token capturing when we have outer attributes (for nonterminals that support attributes - e.g. `Stmt`), or when we parse a `Nonterminal` for a `macro_rules!` argument. The full list of `Nonterminals` affected by this PR is:

* `NtBlock`
* `NtStmt`
* `NtTy`
* `NtMeta`
* `NtPath`
* `NtVis`
* `NtLiteral`

Of these nonterminals, only `NtStmt` and `NtLiteral` (which is actually just an `Expr`), support outer attributes - the rest only ever have token capturing perform when they match a `macro_rules!` argument.

This makes progress towards solving https://github.com/rust-lang/rust/issues/43081 - we now collect tokens for everything that might need them. However, we still need to handle `#[cfg]`, inner attributes, and misc pretty-printing issues (e.g. #75734)

I've separated the changes into (mostly) independent commits, which could be split into individual PRs for each `Nonterminal` variant. The purpose of having them all in one PR is to do a single Crater run for all of them.

Most of the changes in this PR are trivial (adding `tokens: None` everywhere we construct the various AST structs). The significant changes are:

* `ast::Visibility` is changed from `type Visibility = Spanned<VisibilityKind>` to a `struct Visibility { kind, span, tokens }`.
* `maybe_collect_tokens` is made generic, and used for both `ast::Expr` and `ast::Stmt`.
* Some of the statement-parsing functions are refactored so that we can capture the trailing semicolon.
* `Nonterminal` and `Expr` both grew by 8 bytes, as some of the structs which are stored inline (rather than behind a `P`) now have an `Option<TokenStream>` field. Hopefully the performance impact of doing this is negligible.
2020-09-11 02:35:01 +00:00
Christiaan Dirkx 954361a3d4 Update `std::os` module documentation.
Adds missing descriptions for the modules std::os::linux::fs and std::os::windows::io.
Also adds punctuation for consistency with other descriptions.
2020-09-11 04:05:19 +02:00
bors ee04f9a4da Auto merge of #74437 - ssomers:btree_no_root_in_noderef, r=Mark-Simulacrum
BTreeMap: move up reference to map's root from NodeRef

Since the introduction of `NodeRef` years ago, it also contained a mutable reference to the owner of the root node of the tree (somewhat disguised as *const). Its intent is to be used only when the rest of the `NodeRef` is no longer needed. Moving this to where it's actually used, thought me 2 things:
- Some sort of "postponed mutable reference" is required in most places that it is/was used, and that's exactly where we also need to store a reference to the length (number of elements) of the tree, for the same reason. The length reference can be a normal reference, because the tree code does not care about tree length (just length per node).
- It's downright obfuscation in `from_sorted_iter` (transplanted to #75329)
- It's one of the reasons for the scary notice on `reborrow_mut`, the other one being addressed in #73971.

This does repeat the raw pointer code in a few places, but it could be bundled up with the length reference.

r? `@Mark-Simulacrum`
2020-09-10 23:29:57 +00:00
Aaron Hill fec0479075
Fully integrate token collection for additional AST structs
This commit contains miscellaneous changes that don't fit into any of
the other commits in this PR
2020-09-10 17:58:14 -04:00
Aaron Hill 156ef2bee8
Attach tokens to `ast::Stmt`
We currently only attach tokens when parsing a `:stmt` matcher for a
`macro_rules!` macro. Proc-macro attributes on statements are still
unstable, and need additional work.
2020-09-10 17:33:06 -04:00
Aaron Hill c1011165e6
Attach `TokenStream` to `ast::Visibility`
A `Visibility` does not have outer attributes, so we only capture tokens
when parsing a `macro_rules!` matcher
2020-09-10 17:33:06 -04:00
Aaron Hill 55082ce413
Attach `TokenStream` to `ast::Path` 2020-09-10 17:33:06 -04:00
Aaron Hill 3815e91ccd
Attach tokens to `NtMeta` (`ast::AttrItem`)
An `AttrItem` does not have outer attributes, so we only capture tokens
when parsing a `macro_rules!` matcher
2020-09-10 17:33:06 -04:00
Aaron Hill d5a04a9927
Collect tokens when handling `:literal` matcher
An `NtLiteral` just wraps an `Expr`, so we don't need to add a new `tokens`
field to an AST struct.
2020-09-10 17:33:06 -04:00