]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAuto merge of #85296 - bjorn3:plugin_cleanup, r=petrochenkov
bors [Thu, 12 Aug 2021 04:30:41 +0000 (04:30 +0000)]
Auto merge of #85296 - bjorn3:plugin_cleanup, r=petrochenkov

Plugin interface cleanup

The first commit performs two uncontroversial cleanups. The second commit removes `#[plugin_registrar]` and instead requires you to export a `__rustc_plugin_registrar` function, this will require a change to servo's script_plugins (cc `@jdm)`

2 years agoAuto merge of #87843 - kornelski:try_reserve, r=m-ou-se
bors [Thu, 12 Aug 2021 01:16:22 +0000 (01:16 +0000)]
Auto merge of #87843 - kornelski:try_reserve, r=m-ou-se

TryReserveErrorKind tests and inline

A small follow-up to #87408

2 years agoAuto merge of #86532 - estebank:delete-suggestion-underline, r=petrochenkov
bors [Wed, 11 Aug 2021 19:26:01 +0000 (19:26 +0000)]
Auto merge of #86532 - estebank:delete-suggestion-underline, r=petrochenkov

Make deleted code in a suggestion clearer

Show suggestions that include deletions in a way similar to `diff`'s output.

<img width="628" alt="" src="https://user-images.githubusercontent.com/1606434/123350316-9078e580-d50f-11eb-89b9-78431b85e23f.png">

For changes that do not have deletions, use `+` as an underline for additions and `~` as an underline for replacements.

<img width="631" alt="" src="https://user-images.githubusercontent.com/1606434/123701745-1ac68f80-d817-11eb-950b-09e5afd7532f.png">

For multiline suggestions, we now use `~` in the gutter to signal replacements and `+` to signal whole line replacements/additions.

<img width="834" alt="" src="https://user-images.githubusercontent.com/1606434/123701331-8eb46800-d816-11eb-9dcd-ef9098071afb.png">

In all cases we now use color to highlight the specific spans and snippets.

2 years agoupdate clippy
Esteban Kuber [Wed, 11 Aug 2021 14:21:33 +0000 (14:21 +0000)]
update clippy

2 years agoAuto merge of #87892 - rust-lang:spec-fill-size-one-bye, r=the8472
bors [Wed, 11 Aug 2021 11:40:20 +0000 (11:40 +0000)]
Auto merge of #87892 - rust-lang:spec-fill-size-one-bye, r=the8472

Remove size_of == 1 case from `fill` specialization.

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

See [discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/potential.20UB.20in.20slice.3A.3Afill/near/248875743).

2 years agoModify structured suggestion output
Esteban Küber [Tue, 22 Jun 2021 02:07:19 +0000 (19:07 -0700)]
Modify structured suggestion output

* On suggestions that include deletions, use a diff inspired output format
* When suggesting addition, use `+` as underline
* Color highlight modified span

2 years agoAuto merge of #87587 - oli-obk:lazy_tait, r=spastorino
bors [Wed, 11 Aug 2021 05:14:45 +0000 (05:14 +0000)]
Auto merge of #87587 - oli-obk:lazy_tait, r=spastorino

Various refactorings of the TAIT infrastructure

Before this PR we used to store the opaque type knowledge outside the `InferCtxt`, so it got recomputed on every opaque type instantiation.

I also removed a feature gate check that makes no sense in the planned lazy TAIT resolution scheme

Each commit passes all tests, so this PR is best reviewed commit by commit.

r? `@spastorino`

2 years agoAuto merge of #87254 - rusticstuff:rustc_codegen_llvm_dont_emit_zero_sized_padding...
bors [Wed, 11 Aug 2021 01:36:23 +0000 (01:36 +0000)]
Auto merge of #87254 - rusticstuff:rustc_codegen_llvm_dont_emit_zero_sized_padding, r=eddyb

LLVM codegen: Don't emit zero-sized padding for fields

Currently padding is emitted before fields of a struct and at the end of the struct regardless of the ABI. Even if no padding is required zero-sized padding fields are emitted. This is not useful and - more importantly - it make it impossible to generate the exact vector types that LLVM expects for certain ARM SIMD intrinsics. This change should unblock the implementation of many ARM intrinsics using the `unadjusted` ABI, see https://github.com/rust-lang/stdarch/issues/1143#issuecomment-827404092.

This is a proof of concept only because the field lookup now takes O(number of fields) time compared to O(1) before since it recalculates the mapping at every lookup. I would like to find out how big the performance impact actually is before implementing caching or restricting this behavior to the `unadjusted` ABI.

cc `@SparrowLii` `@bjorn3`

([Discussion on internals](https://internals.rust-lang.org/t/feature-request-add-a-way-in-rustc-for-generating-struct-type-llvm-ir-without-paddings/15007))

2 years agoAuto merge of #87923 - JohnTitor:rollup-id54fyz, r=JohnTitor
bors [Tue, 10 Aug 2021 22:37:57 +0000 (22:37 +0000)]
Auto merge of #87923 - JohnTitor:rollup-id54fyz, r=JohnTitor

Rollup of 14 pull requests

Successful merges:

 - #86840 (Constify implementations of `(Try)From` for int types)
 - #87582 (Implement `Printer` for `&mut SymbolPrinter`)
 - #87636 (Added the `Option::unzip()` method)
 - #87700 (Expand explanation of E0530)
 - #87811 (Do not ICE on HIR based WF check when involving lifetimes)
 - #87848 (removed references to parent/child from std::thread documentation)
 - #87854 (correctly handle enum variants in `opt_const_param_of`)
 - #87861 (Fix heading colours in Ayu theme)
 - #87865 (Clarify terms in rustdoc book)
 - #87876 (add `windows` count test)
 - #87880 (Remove duplicate trait bounds in `rustc_data_structures::graph`)
 - #87881 (Proper table row formatting in platform support)
 - #87889 (Use smaller spans when suggesting method call disambiguation)
 - #87895 (typeck: don't suggest inaccessible fields in struct literals and suggest ignoring inaccessible fields in struct patterns)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #87895 - TheWastl:issue-87872, r=estebank
Yuki Okushi [Tue, 10 Aug 2021 19:18:47 +0000 (04:18 +0900)]
Rollup merge of #87895 - TheWastl:issue-87872, r=estebank

typeck: don't suggest inaccessible fields in struct literals and suggest ignoring inaccessible fields in struct patterns

Fixes #87872.

This PR adjusts the missing field diagnostic logic in typeck so that when any of the missing fields in a struct literal or pattern is inaccessible then the error is less confusing, even if some of the missing fields are accessible.

See also #76524.

2 years agoRollup merge of #87889 - estebank:method-call-disambiguate, r=oli-obk
Yuki Okushi [Tue, 10 Aug 2021 19:18:46 +0000 (04:18 +0900)]
Rollup merge of #87889 - estebank:method-call-disambiguate, r=oli-obk

Use smaller spans when suggesting method call disambiguation

Use smaller spans when suggesting method call disambiguation.

2 years agoRollup merge of #87881 - badboy:platform-support-formatting, r=ehuss
Yuki Okushi [Tue, 10 Aug 2021 19:18:45 +0000 (04:18 +0900)]
Rollup merge of #87881 - badboy:platform-support-formatting, r=ehuss

Proper table row formatting in platform support

Also moves the target into alphabetical order

2 years agoRollup merge of #87880 - pierwill:graph-duplicate-trait-bound, r=LeSeulArtichaut
Yuki Okushi [Tue, 10 Aug 2021 19:18:44 +0000 (04:18 +0900)]
Rollup merge of #87880 - pierwill:graph-duplicate-trait-bound, r=LeSeulArtichaut

Remove duplicate trait bounds in `rustc_data_structures::graph`

Remove duplicate trait bounds in `rustc_data_structures::graph`.

2 years agoRollup merge of #87876 - lcnr:windows_no_panic, r=m-ou-se
Yuki Okushi [Tue, 10 Aug 2021 19:18:43 +0000 (04:18 +0900)]
Rollup merge of #87876 - lcnr:windows_no_panic, r=m-ou-se

add `windows` count test

cc #87767

2 years agoRollup merge of #87865 - tsoutsman:master, r=GuillaumeGomez
Yuki Okushi [Tue, 10 Aug 2021 19:18:41 +0000 (04:18 +0900)]
Rollup merge of #87865 - tsoutsman:master, r=GuillaumeGomez

Clarify terms in rustdoc book

Fixes #70898

I chose to completely remove the term directive over attribute because rustdoc has a lint called `invalid_codeblock_attributes` and the term attributes is used throughout the book. I slightly changed the introductory sentence to describe the relationship between annotations and attributes.

I also moved the text explaining the example from below the blocks to above the blocks which is more in line with the rest of the book. I also changed the description for the `should_panic` attribute as I found it a little confusing. Finally, some of the blocks were `text` and some were `rust` so I changed them all to `text` which is in line with the rest of the book.

2 years agoRollup merge of #87861 - tsoutsman:patch-1, r=GuillaumeGomez
Yuki Okushi [Tue, 10 Aug 2021 19:18:40 +0000 (04:18 +0900)]
Rollup merge of #87861 - tsoutsman:patch-1, r=GuillaumeGomez

Fix heading colours in Ayu theme

Closes #87828
The issue seems to stem from #87210 where code headings were changed from a heading containing a `code` element to a heading with the `code-header` class. `rustdoc.css` was updated, but `ayu.css` was missed.

2 years agoRollup merge of #87854 - BoxyUwU:var-None, r=oli-obk
Yuki Okushi [Tue, 10 Aug 2021 19:18:39 +0000 (04:18 +0900)]
Rollup merge of #87854 - BoxyUwU:var-None, r=oli-obk

correctly handle enum variants in `opt_const_param_of`

Fixes #87542

`opt_const_param_of` was returning `None` for args on an enum variant `Enum::Variant::<10>` because we called `generics_of` on the enum variant which has no generics.

r? `@oli-obk`

2 years agoRollup merge of #87848 - godmar:@godmar/thread-join-documentation-fix, r=joshtriplett
Yuki Okushi [Tue, 10 Aug 2021 19:18:38 +0000 (04:18 +0900)]
Rollup merge of #87848 - godmar:@godmar/thread-join-documentation-fix, r=joshtriplett

removed references to parent/child from std::thread documentation

- also clarifies how thread.join and detaching of threads works
- the previous prose implied that there is a relationship between a
spawning thread and the thread being spawned, and that "child" threads
couldn't outlive their "parents" unless detached, which is incorrect.

2 years agoRollup merge of #87811 - estebank:issue-87549, r=oli-obk
Yuki Okushi [Tue, 10 Aug 2021 19:18:37 +0000 (04:18 +0900)]
Rollup merge of #87811 - estebank:issue-87549, r=oli-obk

Do not ICE on HIR based WF check when involving lifetimes

Fix #87549.

2 years agoRollup merge of #87700 - kornelski:e530text, r=oli-obk
Yuki Okushi [Tue, 10 Aug 2021 19:18:36 +0000 (04:18 +0900)]
Rollup merge of #87700 - kornelski:e530text, r=oli-obk

Expand explanation of E0530

The explanation didn't cover a puzzling case of enum variants missing fields.

2 years agoRollup merge of #87636 - Kixiron:unzip-option, r=scottmcm
Yuki Okushi [Tue, 10 Aug 2021 19:18:34 +0000 (04:18 +0900)]
Rollup merge of #87636 - Kixiron:unzip-option, r=scottmcm

Added the `Option::unzip()` method

* Adds the `Option::unzip()` method to turn an `Option<(T, U)>` into `(Option<T>, Option<U>)` under the `unzip_option` feature
* Adds tests for both `Option::unzip()` and `Option::zip()`, I noticed that `.zip()` didn't have any
* Adds `#[inline]` to a few of `Option`'s methods that were missing it

2 years agoRollup merge of #87582 - tmiasko:symbol-printer, r=michaelwoerister
Yuki Okushi [Tue, 10 Aug 2021 19:18:33 +0000 (04:18 +0900)]
Rollup merge of #87582 - tmiasko:symbol-printer, r=michaelwoerister

Implement `Printer` for `&mut SymbolPrinter`

to avoid passing `SymbolPrinter` by value.

2 years agoRollup merge of #86840 - usbalbin:const_from, r=oli-obk
Yuki Okushi [Tue, 10 Aug 2021 19:18:33 +0000 (04:18 +0900)]
Rollup merge of #86840 - usbalbin:const_from, r=oli-obk

Constify implementations of `(Try)From` for int types

I believe this to be one of the (many?) things blocking const (Range) iterators.

~~If this is to be merged maybe that should wait until `#![feature(const_trait_impl)]` no longer needs `#![allow(incomplete_features)]`?~~ - Done

2 years agotypeck: better diagnostics for missing inaccessible fields in struct literals/patterns
TheWastl [Tue, 10 Aug 2021 14:17:45 +0000 (16:17 +0200)]
typeck: better diagnostics for missing inaccessible fields in struct literals/patterns

- typeck/expr: don't suggest adding fields in struct literals with inaccessible fields
- typeck/pat: suggest ignoring inaccessible fields in struct patterns

2 years agoReplace #[plugin_registrar] with exporting __rustc_plugin_registrar
bjorn3 [Fri, 14 May 2021 13:37:53 +0000 (15:37 +0200)]
Replace #[plugin_registrar] with exporting __rustc_plugin_registrar

2 years agoDon't collect into a `Vec` that is immediately being iterated on again.
Oli Scherer [Tue, 10 Aug 2021 11:03:10 +0000 (11:03 +0000)]
Don't collect into a `Vec` that is immediately being iterated on again.

2 years agoRemove size_of == 1 case from `fill` specialization.
Mara Bos [Mon, 9 Aug 2021 17:25:28 +0000 (19:25 +0200)]
Remove size_of == 1 case from `fill` specialization.

2 years agoUse smaller spans when suggesting method call disambiguation
Esteban Kuber [Mon, 9 Aug 2021 16:47:09 +0000 (16:47 +0000)]
Use smaller spans when suggesting method call disambiguation

2 years agoTest: Use smallvec directly instead of boxed.
Hans Kratz [Mon, 9 Aug 2021 15:42:37 +0000 (15:42 +0000)]
Test: Use smallvec directly instead of boxed.

2 years agoAdded tracking issue to unstable attribute
Chase Wilson [Thu, 5 Aug 2021 17:44:22 +0000 (12:44 -0500)]
Added tracking issue to unstable attribute

2 years agoEnabled unzip_option feature for core tests & unzip docs
Chase Wilson [Sat, 31 Jul 2021 23:16:34 +0000 (18:16 -0500)]
Enabled unzip_option feature for core tests & unzip docs

2 years agoAdded some basic tests for `Option::unzip()` and `Option::zip()` (I noticed that...
Chase Wilson [Fri, 30 Jul 2021 18:13:59 +0000 (13:13 -0500)]
Added some basic tests for `Option::unzip()` and `Option::zip()` (I noticed that zip had no tests)

2 years agoAdded the `Option::unzip()` method
Chase Wilson [Fri, 30 Jul 2021 18:11:25 +0000 (13:11 -0500)]
Added the `Option::unzip()` method

2 years agoProper table row formatting in platform support
Jan-Erik Rediger [Mon, 9 Aug 2021 14:09:11 +0000 (16:09 +0200)]
Proper table row formatting in platform support

Also moves the target into alphabetical order

2 years agoRemove duplicate trait bounds in `rustc_data_structures::graph`
pierwill [Mon, 9 Aug 2021 13:52:04 +0000 (08:52 -0500)]
Remove duplicate trait bounds in `rustc_data_structures::graph`

2 years agoAuto merge of #85357 - Andy-Python-Programmer:aarch64_uefi_target, r=petrochenkov
bors [Mon, 9 Aug 2021 13:16:51 +0000 (13:16 +0000)]
Auto merge of #85357 - Andy-Python-Programmer:aarch64_uefi_target, r=petrochenkov

Add `aarch64-unknown-uefi` target

This pull request adds the `aarch64-unknown-uefi` target.

2 years agoAvoid unnecessary allocation.
Hans Kratz [Mon, 9 Aug 2021 12:59:23 +0000 (12:59 +0000)]
Avoid unnecessary allocation.

2 years agoTEST: Use SmallVec<[u32; 4]> for field projection.
Hans Kratz [Mon, 9 Aug 2021 12:25:33 +0000 (12:25 +0000)]
TEST: Use SmallVec<[u32; 4]> for field projection.

2 years agoFix nits.
Hans Kratz [Mon, 9 Aug 2021 12:08:18 +0000 (12:08 +0000)]
Fix nits.

2 years agoadd `windows` count test
lcnr [Mon, 9 Aug 2021 09:08:39 +0000 (11:08 +0200)]
add `windows` count test

2 years agoAuto merge of #87820 - elichai:patch-2, r=kennytm
bors [Mon, 9 Aug 2021 08:19:19 +0000 (08:19 +0000)]
Auto merge of #87820 - elichai:patch-2, r=kennytm

Replace read_to_string with read_line in Stdin example

The current example results in infinitely reading from stdin, which can confuse newcomers trying to read from stdin.
(`@razmag` encountered this while learning the language from the docs)

2 years agoDo not ICE on HIR based WF check when involving lifetimes
Esteban Küber [Fri, 6 Aug 2021 09:36:54 +0000 (02:36 -0700)]
Do not ICE on HIR based WF check when involving lifetimes

Fix #87549.

2 years agoAdd the aarch64-unknown-uefi target
unknown [Sun, 16 May 2021 03:28:16 +0000 (13:28 +1000)]
Add the aarch64-unknown-uefi target

* This commit adds the aarch64-unknown-uefi target and also adds it into
the supported targets list under the tier-3 target table.
* Uses the small code model by default

Signed-off-by: Andy-Python-Programmer <andypythonappdeveloper@gmail.com>
2 years agoAuto merge of #87619 - 12101111:fix-native_link_modifiers_bundle, r=petrochenkov
bors [Mon, 9 Aug 2021 03:59:30 +0000 (03:59 +0000)]
Auto merge of #87619 - 12101111:fix-native_link_modifiers_bundle, r=petrochenkov

Fix feature gate checking of static-nobundle and native_link_modifiers

Feature native_link_modifiers_bundle don't need feature static-nobundle
to work.

Also check the feature gates when using native_link_modifiers from command line options. Current nighly compiler don't check those feature gate.

```
> touch lib.rs
> rustc +nightly lib.rs -L /usr/lib -l static:+bundle=dl --crate-type=rlib
> rustc +nightly lib.rs -L /usr/lib -l dylib:+as-needed=dl --crate-type=dylib -Ctarget-feature=-crt-static
> rustc +nightly lib.rs -L /usr/lib -l static:-bundle=dl --crate-type=rlib
error[E0658]: kind="static-nobundle" is unstable
  |
  = note: see issue #37403 <https://github.com/rust-lang/rust/issues/37403> for more information
  = help: add `#![feature(static_nobundle)]` to the crate attributes to enable

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.

```

First found this in https://github.com/rust-lang/rust/pull/85600#discussion_r676612655

2 years agoAuto merge of #87465 - audunhalland:refactor_typeck_primary_body_of, r=eddyb
bors [Mon, 9 Aug 2021 01:08:52 +0000 (01:08 +0000)]
Auto merge of #87465 - audunhalland:refactor_typeck_primary_body_of, r=eddyb

Simplify typeck/primary_body_of, fix comment to match return signature

Hi, new contributor here! I'm carefully reading through the various modules just to learn. I noticed this function, `primary_body_of`, which has gone through a couple of refactors over time, adding new `Option`s to its returned tuple. Observations:

1. the `fn`'s documentation was not all up to date with the the current return signature.
2. `FnHeader` and `FnDecl` are always both `Some` or `None`. So I figured it might just return a reference to the full `hir::FnSig`, for simplicity and more precise typing. It's a pure refactor.

I'm learning better by working with code than just reading it, so here goes! If you want to avoid pure refactor PRs that don't really fix anything, I can revert the code change to only update the comment instead.

2 years agoClarify terms in rustdoc book
Klim Tsoutsman [Sun, 8 Aug 2021 14:10:03 +0000 (00:10 +1000)]
Clarify terms in rustdoc book

Change code blocks to Rust

2 years agoAuto merge of #87235 - poliorcetics:issue-87217-fn-quali-order, r=nagisa
bors [Sun, 8 Aug 2021 22:28:01 +0000 (22:28 +0000)]
Auto merge of #87235 - poliorcetics:issue-87217-fn-quali-order, r=nagisa

Improve diagnostics for wrongly ordered keywords in function declaration

Fix #87217

`@rustbot` label A-diagnostics T-compiler

2 years agoAuto merge of #86879 - YohDeadfall:stabilize-vec-shrink-to, r=dtolnay
bors [Sun, 8 Aug 2021 19:37:02 +0000 (19:37 +0000)]
Auto merge of #86879 - YohDeadfall:stabilize-vec-shrink-to, r=dtolnay

Stabilize Vec<T>::shrink_to

This PR stabilizes `shrink_to` feature and closes the corresponding issue. The second point was addressed already, and no `panic!` should occur.

Closes #56431.

2 years agoBump shrink_to stabilization to Rust 1.56
David Tolnay [Sun, 8 Aug 2021 18:36:53 +0000 (11:36 -0700)]
Bump shrink_to stabilization to Rust 1.56

2 years agoAuto merge of #87697 - GuillaumeGomez:add-e0784, r=nagisa
bors [Sun, 8 Aug 2021 16:40:14 +0000 (16:40 +0000)]
Auto merge of #87697 - GuillaumeGomez:add-e0784, r=nagisa

Assign E0784 error code for union expression errors

2 years ago Fix feature gate checking of static-nobundle and native_link_modifiers
12101111 [Fri, 6 Aug 2021 13:51:59 +0000 (21:51 +0800)]
 Fix feature gate checking of static-nobundle and native_link_modifiers

2 years agoAuto merge of #87827 - eddyb:wrapperless-mem-replace, r=m-ou-se
bors [Sun, 8 Aug 2021 13:11:09 +0000 (13:11 +0000)]
Auto merge of #87827 - eddyb:wrapperless-mem-replace, r=m-ou-se

Avoid using the `copy_nonoverlapping` wrapper through `mem::replace`.

This is a much simpler way to achieve the pre-#86003 behavior of `mem::replace` not needing dynamically-sized `memcpy`s (at least before inlining), than re-doing #81238 (which needs #86699 or something similar).

I didn't notice it until recently, but `ptr::write` already explicitly avoided using the wrapper, while `ptr::read` just called the wrapper (and was the reason for us observing any behavior change from #86003 in Rust-GPU).

<hr/>

The codegen test I've added fails without the change to `core::ptr::read` like this (ignore the `v0` mangling, I was using a worktree with it turned on by default, for this):
```llvm
       13: ; core::intrinsics::copy_nonoverlapping::<u8>
       14: ; Function Attrs: inlinehint nonlazybind uwtable
       15: define internal void `@_RINvNtCscK5tvALCJol_4core10intrinsics19copy_nonoverlappinghECsaS4X3EinRE8_25mem_replace_direct_memcpy(i8*` %src, i8* %dst, i64 %count) unnamed_addr #0 {
       16: start:
       17:  %0 = mul i64 %count, 1
       18:  call void `@llvm.memcpy.p0i8.p0i8.i64(i8*` align 1 %dst, i8* align 1 %src, i64 %0, i1 false)
not:17      !~~~~~~~~~~~~~~~~~~~~~                                                                     error: no match expected
       19:  ret void
       20: }
```
With the `core::ptr::read` change, `core::intrinsics::copy_nonoverlapping` doesn't get instantiated and the test passes.

<hr/>

r? `@m-ou-se` cc `@nagisa` (codegen test) `@oli-obk` / `@RalfJung` (miri diagnostic changes)

2 years agoFix heading colours in Ayu theme
Klim Tsoutsman [Sun, 8 Aug 2021 12:35:51 +0000 (22:35 +1000)]
Fix heading colours in Ayu theme

Closes #87828
The issue seems to stem from #87210 where code headings were changed from a heading containing code to a heading with the `code-header` class. `rustdoc.css` was updated, but `ayu.css` was missed.

2 years agoAvoid using the `copy_nonoverlapping` wrapper through `mem::replace`.
Eduard-Mihai Burtescu [Fri, 6 Aug 2021 17:33:02 +0000 (20:33 +0300)]
Avoid using the `copy_nonoverlapping` wrapper through `mem::replace`.

2 years agoAuto merge of #87836 - tsoutsman:master, r=petrochenkov
bors [Sun, 8 Aug 2021 10:23:17 +0000 (10:23 +0000)]
Auto merge of #87836 - tsoutsman:master, r=petrochenkov

Change proc_macro::Diagnostics docs

With Rust 1.54 attributes can invoke function-like macros. This allows functions generated by macros to have non-generic documentation. This pull request changes the documentation of `proc_macro::Diagnostics` to be more specific and include a link to the level.
## Example
Before:
```markdown
Adds a new child diagnostic message to `self` with the level
identified by this method’s name with the given `message`.
```
After:
```markdown
Adds a new child diagnostic message to self with the [`Level::Error`]
level, and the given `message`.
```

2 years agoAuto merge of #87815 - BoxyUwU:cec-generics-of-ice, r=eddyb
bors [Sun, 8 Aug 2021 07:15:48 +0000 (07:15 +0000)]
Auto merge of #87815 - BoxyUwU:cec-generics-of-ice, r=eddyb

encode `generics_of` for fields and ty params

Fixes #87674
Fixes #87603

ICE was caused by calling `generics_of` on a `DefId` without any `generics_of` results. This was happening when we call `generics_of` on parent `DefId`s of an unevaluated const when we evaluate it.

r? `@lcnr`

2 years agoAuto merge of #87798 - durin42:llvm-14, r=nikic
bors [Sun, 8 Aug 2021 04:33:22 +0000 (04:33 +0000)]
Auto merge of #87798 - durin42:llvm-14, r=nikic

PassWrapper: handle move of OptimizationLevel class out of PassBuilder

This is the first build break of the LLVM 14 cycle, and was caused by
https://reviews.llvm.org/D107025. Mercifully an easy fix.

2 years agoMerge branch 'rust-lang:master' into master
Klim Tsoutsman [Sun, 8 Aug 2021 03:17:23 +0000 (13:17 +1000)]
Merge branch 'rust-lang:master' into master

2 years agoAuto merge of #86744 - ijackson:sink-default, r=dtolnay
bors [Sun, 8 Aug 2021 01:52:32 +0000 (01:52 +0000)]
Auto merge of #86744 - ijackson:sink-default, r=dtolnay

impl Default, Copy, Clone for std::io::Sink and Empty

The omission of `Sink: Default` is causing me a slight inconvenience in a test harness.  There seems little reason for this and `Empty` not to be `Clone` and `Copy` too.

I have made all three of these insta-stable, because:

AIUI `Copy` can only be derived, and I was not able to find any examples of how to unstably derive it.  I think it is probably not possible.

I hunted through the git history for precedent and found

79b8ad84c84481a43704213cd0948d2ba0ea63b4
> Implement `Copy` for `IoSlice`
> https://github.com/rust-lang/rust/pull/69403

which was also insta-stable.

2 years agoAuto merge of #87772 - npmccallum:naked_abi, r=Amanieu
bors [Sat, 7 Aug 2021 23:24:15 +0000 (23:24 +0000)]
Auto merge of #87772 - npmccallum:naked_abi, r=Amanieu

Move naked function ABI check to its own lint

This check was previously categorized under the lint named
`UNSUPPORTED_NAKED_FUNCTIONS`. That lint is future incompatible and will
be turned into an error in a future release. However, as defined in the
Constrained Naked Functions RFC, this check should only be a warning.
This is because it is possible for a naked function to be implemented in
such a way that it does not break even the undefined ABI. For example, a
`jmp` to a `const`.

Therefore, this patch defines a new lint named
`UNDEFINED_NAKED_FUNCTION_ABI` which contains just this single check.
Unlike `UNSUPPORTED_NAKED_FUNCTIONS`, `UNDEFINED_NAKED_FUNCTION_ABI`
will not be converted to an error in the future.

rust-lang/rfcs#2774
rust-lang/rfcs#2972

2 years agoAuto merge of #87743 - cuviper:opaque-calls, r=nikic
bors [Sat, 7 Aug 2021 20:43:25 +0000 (20:43 +0000)]
Auto merge of #87743 - cuviper:opaque-calls, r=nikic

Prepare call/invoke for opaque pointers

Rather than relying on `getPointerElementType()` from LLVM function
pointers, we now pass the function type explicitly when building `call`
or `invoke` instructions.

2 years agofmt
Ellen [Sat, 7 Aug 2021 19:55:37 +0000 (20:55 +0100)]
fmt

2 years agoAuto merge of #87851 - JohnTitor:rollup-odvmr47, r=JohnTitor
bors [Sat, 7 Aug 2021 18:21:04 +0000 (18:21 +0000)]
Auto merge of #87851 - JohnTitor:rollup-odvmr47, r=JohnTitor

Rollup of 6 pull requests

Successful merges:

 - #87744 (Add x.py option to --force-rerun compiletest tests)
 - #87789 (Make vec-shrink-panic test compatible with v0 mangling)
 - #87833 (Fix typo -- "The" -> "They")
 - #87834 (Fix small typo)
 - #87838 (Document that fs::read_dir skips . and ..)
 - #87842 (Fix intra doc link in hidden doc of Iterator::__iterator_get_unchecked)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoless opt in const param of
Ellen [Sat, 7 Aug 2021 17:44:36 +0000 (18:44 +0100)]
less opt in const param of

2 years agoAdd test for int to float
Albin Hedman [Sat, 7 Aug 2021 16:59:07 +0000 (18:59 +0200)]
Add test for int to float

2 years agoAdd tests
Albin Hedman [Sat, 13 Mar 2021 17:40:47 +0000 (18:40 +0100)]
Add tests

2 years agoimpl const From<num> for num
Albin Hedman [Sun, 27 Dec 2020 18:46:01 +0000 (19:46 +0100)]
impl const From<num> for num

2 years agoRollup merge of #87842 - steffahn:hidden_broken_intra_doc, r=dtolnay
Yuki Okushi [Sat, 7 Aug 2021 16:13:45 +0000 (01:13 +0900)]
Rollup merge of #87842 - steffahn:hidden_broken_intra_doc, r=dtolnay

Fix intra doc link in hidden doc of Iterator::__iterator_get_unchecked

Recently, I edited the import list of the `core::iter::traits::iterator` module (in #85874). This results in a broken intra doc link in a hidden documentation with the effect that `RUSTDOCFLAGS='--document-private-items --document-hidden-items' x doc library/std` fails. (This can be worked around by adding `-Arustdoc::broken-intra-doc-links`; still, it’s a broken link so let’s fix it.)

``@rustbot`` label C-cleanup, T-libs

2 years agoRollup merge of #87838 - jetomit:add-readdir-note, r=dtolnay
Yuki Okushi [Sat, 7 Aug 2021 16:13:44 +0000 (01:13 +0900)]
Rollup merge of #87838 - jetomit:add-readdir-note, r=dtolnay

Document that fs::read_dir skips . and ..

Hi,

I think this is worth noting in the docs since it differs from POSIX `readdir`. I didn’t put it under platform-specific notes because it seems to be consistent across platforms, and changing this behavior in the future could cause pretty nasty bugs.

Thanks!

2 years agoRollup merge of #87834 - camelid:span-typo, r=CraftSpider
Yuki Okushi [Sat, 7 Aug 2021 16:13:43 +0000 (01:13 +0900)]
Rollup merge of #87834 - camelid:span-typo, r=CraftSpider

Fix small typo

The closing backtick was outside the closing bracket,
which is why the intra-doc link wasn't working.

2 years agoRollup merge of #87833 - m-rsha:patch-1, r=Aaron1011
Yuki Okushi [Sat, 7 Aug 2021 16:13:43 +0000 (01:13 +0900)]
Rollup merge of #87833 - m-rsha:patch-1, r=Aaron1011

Fix typo -- "The" -> "They"

I was reading through source code to try to learn more about the language and how to make the most of it when I ran into a small typo, so I figured I'd offer up a fix! I'm pretty new now, but hopefully I can offer up more substantial changes later. :D

2 years agoRollup merge of #87789 - tmiasko:panik, r=Mark-Simulacrum
Yuki Okushi [Sat, 7 Aug 2021 16:13:42 +0000 (01:13 +0900)]
Rollup merge of #87789 - tmiasko:panik, r=Mark-Simulacrum

Make vec-shrink-panic test compatible with v0 mangling

The v0 mangling includes an instantiating crate in a mangled name,
which crates a false positive match for a word `panic`.
Rename crate name / test case to avoid the issue.

2 years agoRollup merge of #87744 - Smittyvb:xpy-test-force-rerun, r=Mark-Simulacrum
Yuki Okushi [Sat, 7 Aug 2021 16:13:41 +0000 (01:13 +0900)]
Rollup merge of #87744 - Smittyvb:xpy-test-force-rerun, r=Mark-Simulacrum

Add x.py option to --force-rerun compiletest tests

This can be used like `./x.py test src/test/ui/abi/ --force-rerun`, and is useful when verifying that newly blessed tests don't change between test runs (such as due to being dependent on the current time or memory layout or RNG), without needing to change the test file or find the right file in `build` to remove.

2 years agoAuto merge of #87849 - RalfJung:miri, r=RalfJung
bors [Sat, 7 Aug 2021 15:53:32 +0000 (15:53 +0000)]
Auto merge of #87849 - RalfJung:miri, r=RalfJung

update Miri

Fixes https://github.com/rust-lang/rust/issues/87778
r? `@ghost`

2 years agoupdate Miri
Ralf Jung [Sat, 7 Aug 2021 15:46:45 +0000 (17:46 +0200)]
update Miri

2 years agoremoved references to parent/child from std::thread documentation
Godmar Back [Sat, 7 Aug 2021 15:33:18 +0000 (11:33 -0400)]
removed references to parent/child from std::thread documentation

- also clarifies how thread.join and detaching of threads works
- the previous prose implied that there is a relationship between a
spawning thread and the thread being spawned, and that "child" threads
couldn't outlive their parents unless detached, which is incorrect.

2 years agoFix naked function test run on non-x86_64
Nathaniel McCallum [Sat, 7 Aug 2021 15:17:03 +0000 (11:17 -0400)]
Fix naked function test run on non-x86_64

2 years agoChange proc_macro::Diagnostics docs
Klim Tsoutsman [Sat, 7 Aug 2021 03:46:58 +0000 (13:46 +1000)]
Change proc_macro::Diagnostics docs

Add links

Fit 100-character limit

2 years agoUse assert_matches! instead of if let {} else
Kornel [Sat, 7 Aug 2021 11:51:58 +0000 (12:51 +0100)]
Use assert_matches! instead of if let {} else

2 years agoInline from of TryReserveErrorKind
Kornel [Sat, 7 Aug 2021 11:52:24 +0000 (12:52 +0100)]
Inline from of TryReserveErrorKind

2 years agoAuto merge of #87810 - devnexen:haiku_os_simpl, r=Mark-Simulacrum
bors [Sat, 7 Aug 2021 12:44:09 +0000 (12:44 +0000)]
Auto merge of #87810 - devnexen:haiku_os_simpl, r=Mark-Simulacrum

current_exe haiku code path simplification all of these part of libc

2 years agoFix intra doc link in hidden doc of Iterator::__iterator_get_unchecked
Frank Steffahn [Sat, 7 Aug 2021 11:42:15 +0000 (13:42 +0200)]
Fix intra doc link in hidden doc of Iterator::__iterator_get_unchecked

2 years agoDocument that fs::read_dir skips . and ..
Timotej Lazar [Sat, 7 Aug 2021 08:14:41 +0000 (10:14 +0200)]
Document that fs::read_dir skips . and ..

2 years agoAuto merge of #87796 - nielx:fix/socket2-0.4.1, r=Mark-Simulacrum
bors [Sat, 7 Aug 2021 05:33:21 +0000 (05:33 +0000)]
Auto merge of #87796 - nielx:fix/socket2-0.4.1, r=Mark-Simulacrum

Update socket2 dependency from 0.4.0 to 0.4.1

This update contains a fix for building the tools that depend on this package on Haiku (tier 3).

2 years agoAuto merge of #87408 - kornelski:try_reserve_error, r=yaahc
bors [Sat, 7 Aug 2021 01:26:15 +0000 (01:26 +0000)]
Auto merge of #87408 - kornelski:try_reserve_error, r=yaahc

Hide allocator details from TryReserveError

I think there's [no need for TryReserveError to carry detailed information](https://github.com/rust-lang/rust/issues/48043#issuecomment-825139280), but I wouldn't want that issue to delay stabilization of the `try_reserve` feature.

So I'm proposing to stabilize `try_reserve` with a `TryReserveError` as an opaque structure, and if needed, expose error details later.

This PR moves the `enum` to an unstable inner `TryReserveErrorKind` that lives under a separate feature flag. `TryReserveErrorKind` could possibly be left as an implementation detail forever, and the `TryReserveError` get methods such as `allocation_size() -> Option<usize>` or `layout() -> Option<Layout>` instead, or the details could be dropped completely to make try-reserve errors just a unit struct, and thus smaller and cheaper.

2 years agoFix small typo
Noah Lev [Fri, 6 Aug 2021 23:43:55 +0000 (16:43 -0700)]
Fix small typo

The closing backtick was outside the closing bracket,
which is why the intra-doc link wasn't working.

2 years agoFix typo -- "The" -> "They"
await Marsha [Fri, 6 Aug 2021 23:40:36 +0000 (18:40 -0500)]
Fix typo -- "The" -> "They"

I was reading through source code to try to learn more about the language and how to make the most of it when I ran into a small typo, so I figured I'd offer up a fix! I'm pretty new now, but hopefully I can offer up more substantial changes later. :D

2 years agoAuto merge of #87774 - camelid:process-typo, r=jyn514
bors [Fri, 6 Aug 2021 22:42:25 +0000 (22:42 +0000)]
Auto merge of #87774 - camelid:process-typo, r=jyn514

Fix typo

Add missing "by".

2 years agoPassWrapper: handle move of OptimizationLevel class out of PassBuilder
Augie Fackler [Thu, 5 Aug 2021 16:13:58 +0000 (12:13 -0400)]
PassWrapper: handle move of OptimizationLevel class out of PassBuilder

This is the first build break of the LLVM 14 cycle, and was caused by
https://reviews.llvm.org/D107025. Mercifully an easy fix.

2 years agoAuto merge of #87822 - JohnTitor:rollup-kxojii0, r=JohnTitor
bors [Fri, 6 Aug 2021 18:23:14 +0000 (18:23 +0000)]
Auto merge of #87822 - JohnTitor:rollup-kxojii0, r=JohnTitor

Rollup of 7 pull requests

Successful merges:

 - #85807 (bootstrap: Disable initial-exec TLS model on powerpc)
 - #87761 (Fix overflow in rustc happening if the `err_count()` is reduced in a stage.)
 - #87775 (Add hint for unresolved associated trait items if the trait has a single item)
 - #87779 (Remove special case for statement `NodeId` assignment)
 - #87787 (Use `C-unwind` ABI for `__rust_start_panic` in `panic_abort`)
 - #87809 (Fix typo in the ptr documentation)
 - #87816 (Sync rustc_codegen_cranelift)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoReplace read_to_string with read_line in Stdin example
Elichai Turkel [Fri, 6 Aug 2021 15:59:02 +0000 (18:59 +0300)]
Replace read_to_string with read_line in Stdin example

2 years agoRollup merge of #87816 - bjorn3:sync_cg_clif-2021-08-06, r=bjorn3
Yuki Okushi [Fri, 6 Aug 2021 16:46:37 +0000 (01:46 +0900)]
Rollup merge of #87816 - bjorn3:sync_cg_clif-2021-08-06, r=bjorn3

Sync rustc_codegen_cranelift

05677b6bd6c938ed760835d9b1f6514992654ae3 removes two assertions that should have been removed in https://github.com/rust-lang/rust/pull/87515. They are no longer correct and trigger while compiling the sysroot.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler

2 years agoRollup merge of #87809 - InnovativeInventor:pointer-typo, r=dtolnay
Yuki Okushi [Fri, 6 Aug 2021 16:46:36 +0000 (01:46 +0900)]
Rollup merge of #87809 - InnovativeInventor:pointer-typo, r=dtolnay

Fix typo in the ptr documentation

Spotted a minor typo in the docs ;). Pointers are cool!

2 years agoRollup merge of #87787 - hyd-dev:c-unwind, r=RalfJung
Yuki Okushi [Fri, 6 Aug 2021 16:46:35 +0000 (01:46 +0900)]
Rollup merge of #87787 - hyd-dev:c-unwind, r=RalfJung

Use `C-unwind` ABI for `__rust_start_panic` in `panic_abort`

The function originally has `C` ABI but is called using `C-unwind` ABI in `std`:
https://github.com/rust-lang/rust/blob/d4ad1cfc63ba5824196bfb2370451ddb5af2e020/library/std/src/panicking.rs#L49-L54
Which might be [problematic](https://github.com/rust-lang/miri/pull/1745#discussion_r596096876) and triggers this [Miri error](https://github.com/rust-lang/rust/issues/87778#issuecomment-893306222):
```
error: Undefined Behavior: calling a function with ABI C using caller ABI C-unwind
   --> /home/hyd-dev/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panicking.rs:672:9
    |
672 |         __rust_start_panic(obj)
    |         ^^^^^^^^^^^^^^^^^^^^^^^ calling a function with ABI C using caller ABI C-unwind
    |
    = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
    = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
```
Changing the ABI of the function to `C-unwind` fixes the error above.

2 years agoRollup merge of #87779 - Aaron1011:stmt-ast-id, r=petrochenkov
Yuki Okushi [Fri, 6 Aug 2021 16:46:34 +0000 (01:46 +0900)]
Rollup merge of #87779 - Aaron1011:stmt-ast-id, r=petrochenkov

Remove special case for statement `NodeId` assignment

We now let `noop_flat_map_stmt` assign `NodeId`s (via `visit_id`),
just as we do for other AST nodes.

2 years agoRollup merge of #87775 - Kobzol:single-associated-item-hint, r=oli-obk
Yuki Okushi [Fri, 6 Aug 2021 16:46:33 +0000 (01:46 +0900)]
Rollup merge of #87775 - Kobzol:single-associated-item-hint, r=oli-obk

Add hint for unresolved associated trait items if the trait has a single item

This PR introduces a special-cased hint for unresolved trait items paths. It is shown if:
- the path was not resolved to any existing trait item
- and no existing trait item's name was reasonably close with regard to edit distance
- and the trait only has a single item in the corresponding namespace

I didn't know where I should put tests, therefore so far I just managed to bless two existing tests. I would be glad for hints where should tests for a hint like this be created, how should they be named (with reference to the original issue?) and what tests should I create (is it enough to test it just for types? or create separate tests also for functions and constants?).

It could also be turned into a machine applicable suggestion I suppose.

This is my first `rustc` PR, so please go easy on me :)

Fixes: https://github.com/rust-lang/rust/issues/87638
2 years agoRollup merge of #87761 - rusticstuff:rustc_error_overflow, r=Mark-Simulacrum
Yuki Okushi [Fri, 6 Aug 2021 16:46:32 +0000 (01:46 +0900)]
Rollup merge of #87761 - rusticstuff:rustc_error_overflow, r=Mark-Simulacrum

Fix overflow in rustc happening if the `err_count()` is reduced in a stage.

This can happen if stashed diagnostics are removed or replaced with fewer errors. The semantics stay the same if built without overflow checks. Fixes #84219.

Background: I came across this independently by running `RUSTFLAGS="-C overflow-checks=on" ./x.py test`. Fixing this will allow us to move on and find further overflow errors with testing or fuzzing.

2 years agoRollup merge of #85807 - glaubitz:powerpc-disable-initial-exec-tls, r=Mark-Simulacrum
Yuki Okushi [Fri, 6 Aug 2021 16:46:31 +0000 (01:46 +0900)]
Rollup merge of #85807 - glaubitz:powerpc-disable-initial-exec-tls, r=Mark-Simulacrum

bootstrap: Disable initial-exec TLS model on powerpc

Fixes #81334.

2 years agoAuto merge of #87784 - rusticstuff:bootstrap_config_overflow_checks, r=Mark-Simulacrum
bors [Fri, 6 Aug 2021 15:35:01 +0000 (15:35 +0000)]
Auto merge of #87784 - rusticstuff:bootstrap_config_overflow_checks, r=Mark-Simulacrum

Add config.toml options for enabling overflow checks in rustc and std

The names are `overflow-checks` and `overflow-checks-std` and they work similar to  `debug-assertions` and `debug-assertions-std`. Once added we can measure how big the performance impact actually is and maybe enable them for CI tests.

Enabling them already makes two ui tests fail:
```
failures:
    [ui] ui/parser/item-free-const-no-body-semantic-fail.rs
    [ui] ui/parser/item-free-static-no-body-semantic-fail.rs
```
(See #84219 and #87761.)

2 years agoRemove special case for statement `NodeId` assignment
Aaron Hill [Thu, 5 Aug 2021 00:41:13 +0000 (19:41 -0500)]
Remove special case for statement `NodeId` assignment

We now let `noop_flat_map_stmt` assign `NodeId`s (via `visit_id`),
just as we do for other AST nodes.