]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoCorrect calling convention
Chris Denton [Mon, 4 Apr 2022 18:37:11 +0000 (19:37 +0100)]
Correct calling convention

2 years agoUpdate library/std/src/sys/windows/pipe.rs
Chris Denton [Mon, 4 Apr 2022 04:59:51 +0000 (05:59 +0100)]
Update library/std/src/sys/windows/pipe.rs

2 years agoSynchronize asynchronous pipe reads and writes
Chris Denton [Wed, 30 Mar 2022 07:02:21 +0000 (08:02 +0100)]
Synchronize asynchronous pipe reads and writes

2 years agoAuto merge of #95466 - Dylan-DPC:rollup-g7ddr8y, r=Dylan-DPC
bors [Wed, 30 Mar 2022 07:45:42 +0000 (07:45 +0000)]
Auto merge of #95466 - Dylan-DPC:rollup-g7ddr8y, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #95294 (Document Linux kernel handoff in std::io::copy and std::fs::copy)
 - #95443 (Clarify how `src/tools/x` searches for python)
 - #95452 (fix since field version for termination stabilization)
 - #95460 (Spellchecking compiler code)
 - #95461 (Spellchecking some comments)

Failed merges:

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

2 years agoRollup merge of #95461 - nyurik:spelling, r=lcnr
Dylan DPC [Wed, 30 Mar 2022 07:10:07 +0000 (09:10 +0200)]
Rollup merge of #95461 - nyurik:spelling, r=lcnr

Spellchecking some comments

This PR attempts to clean up some minor spelling mistakes in comments

2 years agoRollup merge of #95460 - nyurik:spelling-str, r=lcnr
Dylan DPC [Wed, 30 Mar 2022 07:10:06 +0000 (09:10 +0200)]
Rollup merge of #95460 - nyurik:spelling-str, r=lcnr

Spellchecking compiler code

Address some spelling mistakes in strings, private function names, and function params.

2 years agoRollup merge of #95452 - yaahc:termination-version-correction, r=ehuss
Dylan DPC [Wed, 30 Mar 2022 07:10:05 +0000 (09:10 +0200)]
Rollup merge of #95452 - yaahc:termination-version-correction, r=ehuss

fix since field version for termination stabilization

fixes incorrect version fields in stabilization of https://github.com/rust-lang/rust/pull/93840

r? `@ehuss`

2 years agoRollup merge of #95443 - jyn514:clarify-python-search-logic, r=Dylan-DPC
Dylan DPC [Wed, 30 Mar 2022 07:10:04 +0000 (09:10 +0200)]
Rollup merge of #95443 - jyn514:clarify-python-search-logic, r=Dylan-DPC

Clarify how `src/tools/x` searches for python

Before, it confusingly looked like `python` was chosen last instead of first.

2 years agoRollup merge of #95294 - sourcefrog:doc-copy, r=dtolnay
Dylan DPC [Wed, 30 Mar 2022 07:10:04 +0000 (09:10 +0200)]
Rollup merge of #95294 - sourcefrog:doc-copy, r=dtolnay

Document Linux kernel handoff in std::io::copy and std::fs::copy

2 years agoSpellchecking compiler code
Yuri Astrakhan [Wed, 30 Mar 2022 05:42:10 +0000 (01:42 -0400)]
Spellchecking compiler code

Address some spelling mistakes in strings, private function names, and function params.

2 years agoSpellchecking some comments
Yuri Astrakhan [Wed, 30 Mar 2022 05:39:38 +0000 (01:39 -0400)]
Spellchecking some comments

This PR attempts to clean up some minor spelling mistakes in comments

2 years agoAuto merge of #94081 - oli-obk:lazy_tait_take_two, r=nikomatsakis
bors [Wed, 30 Mar 2022 05:04:45 +0000 (05:04 +0000)]
Auto merge of #94081 - oli-obk:lazy_tait_take_two, r=nikomatsakis

Lazy type-alias-impl-trait take two

### user visible change 1: RPIT inference from recursive call sites

Lazy TAIT has an insta-stable change. The following snippet now compiles, because opaque types can now have their hidden type set from wherever the opaque type is mentioned.

```rust
fn bar(b: bool) -> impl std::fmt::Debug {
    if b {
        return 42
    }
    let x: u32 = bar(false); // this errors on stable
    99
}
```

The return type of `bar` stays opaque, you can't do `bar(false) + 42`, you need to actually mention the hidden type.

### user visible change 2: divergence between RPIT and TAIT in return statements

Note that `return` statements and the trailing return expression are special with RPIT (but not TAIT). So

```rust
#![feature(type_alias_impl_trait)]
type Foo = impl std::fmt::Debug;

fn foo(b: bool) -> Foo {
    if b {
        return vec![42];
    }
    std::iter::empty().collect() //~ ERROR `Foo` cannot be built from an iterator
}

fn bar(b: bool) -> impl std::fmt::Debug {
    if b {
        return vec![42]
    }
    std::iter::empty().collect() // Works, magic (accidentally stabilized, not intended)
}
```

But when we are working with the return value of a recursive call, the behavior of RPIT and TAIT is the same:

```rust
type Foo = impl std::fmt::Debug;

fn foo(b: bool) -> Foo {
    if b {
        return vec![];
    }
    let mut x = foo(false);
    x = std::iter::empty().collect(); //~ ERROR `Foo` cannot be built from an iterator
    vec![]
}

fn bar(b: bool) -> impl std::fmt::Debug {
    if b {
        return vec![];
    }
    let mut x = bar(false);
    x = std::iter::empty().collect(); //~ ERROR `impl Debug` cannot be built from an iterator
    vec![]
}
```

### user visible change 3: TAIT does not merge types across branches

In contrast to RPIT, TAIT does not merge types across branches, so the following does not compile.

```rust
type Foo = impl std::fmt::Debug;

fn foo(b: bool) -> Foo {
    if b {
        vec![42_i32]
    } else {
        std::iter::empty().collect()
        //~^ ERROR `Foo` cannot be built from an iterator over elements of type `_`
    }
}
```

It is easy to support, but we should make an explicit decision to include the additional complexity in the implementation (it's not much, see a721052457cf513487fb4266e3ade65c29b272d2 which needs to be reverted to enable this).

### PR formalities

previous attempt: #92007

This PR also includes #92306 and #93783, as they were reverted along with #92007 in #93893

fixes #93411
fixes #88236
fixes #89312
fixes #87340
fixes #86800
fixes #86719
fixes #84073
fixes #83919
fixes #82139
fixes #77987
fixes #74282
fixes #67830
fixes #62742
fixes #54895

2 years agoWarn that platform-specific behavior may change
Martin Pool [Wed, 30 Mar 2022 02:43:40 +0000 (19:43 -0700)]
Warn that platform-specific behavior may change

2 years agoAuto merge of #95455 - RalfJung:miri, r=RalfJung
bors [Wed, 30 Mar 2022 02:41:44 +0000 (02:41 +0000)]
Auto merge of #95455 - RalfJung:miri, r=RalfJung

update miri

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

2 years agoupdate miri
Ralf Jung [Wed, 30 Mar 2022 02:13:33 +0000 (22:13 -0400)]
update miri

2 years agofix since field version for termination stabilization
Jane Lusby [Wed, 30 Mar 2022 00:10:49 +0000 (17:10 -0700)]
fix since field version for termination stabilization

2 years agoAuto merge of #95448 - Dylan-DPC:rollup-wpj5yto, r=Dylan-DPC
bors [Tue, 29 Mar 2022 21:01:45 +0000 (21:01 +0000)]
Auto merge of #95448 - Dylan-DPC:rollup-wpj5yto, r=Dylan-DPC

Rollup of 4 pull requests

Successful merges:

 - #93840 (Stabilize Termination and ExitCode)
 - #95256 (Ensure io::Error's bitpacked repr doesn't accidentally impl UnwindSafe)
 - #95386 (Suggest wrapping patterns in enum variants)
 - #95437 (diagnostics: regression test for derive bounds)

Failed merges:

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

2 years agoRollup merge of #95437 - notriddle:notriddle/issue-79076, r=compiler-errors
Dylan DPC [Tue, 29 Mar 2022 20:46:36 +0000 (22:46 +0200)]
Rollup merge of #95437 - notriddle:notriddle/issue-79076, r=compiler-errors

diagnostics: regression test for derive bounds

Closes #79076

2 years agoRollup merge of #95386 - compiler-errors:try-wrapping, r=oli-obk
Dylan DPC [Tue, 29 Mar 2022 20:46:34 +0000 (22:46 +0200)]
Rollup merge of #95386 - compiler-errors:try-wrapping, r=oli-obk

Suggest wrapping patterns in enum variants

Structured suggestion to wrap a pattern in a single-field enum or struct:

```diff
 struct A;

 enum B {
   A(A),
 }

 fn main(b: B) {
   match b {
-    A => {}
+    B::A(A) => {}
   }
 }
```

Half of #94942, the other half I'm not exactly sure how to fix.

Also includes two drive-by changes (that I am open to splitting out into another PR, but thought they could be rolled up into this one):
07776c111f07b887cd46b752870cd3fd76b2ba7c: Makes sure not to suggest wrapping if it doesn't have tuple field constructor (i.e. has named fields)
8f2bbb18fd53e5008bb488302dbd354577698ede: Also suggest wrapping expressions in a tuple struct (not just enum variants)

2 years agoRollup merge of #95256 - thomcc:fix-unwind-safe, r=m-ou-se
Dylan DPC [Tue, 29 Mar 2022 20:46:33 +0000 (22:46 +0200)]
Rollup merge of #95256 - thomcc:fix-unwind-safe, r=m-ou-se

Ensure io::Error's bitpacked repr doesn't accidentally impl UnwindSafe

Sadly, I'm not sure how to easily test that we don't impl a trait, though (or can libstd use `where io::Error: !UnwindSafe` or something).

Fixes #95203

2 years agoRollup merge of #93840 - yaahc:termination-stabilization-celebration-station, r=josht...
Dylan DPC [Tue, 29 Mar 2022 20:46:31 +0000 (22:46 +0200)]
Rollup merge of #93840 - yaahc:termination-stabilization-celebration-station, r=joshtriplett

Stabilize Termination and ExitCode

From https://github.com/rust-lang/rust/issues/43301

This PR stabilizes the Termination trait and associated ExitCode type. It also adjusts the ExitCode feature flag to replace the placeholder flag with a more permanent name, as well as splitting off the `to_i32` method behind its own permanently unstable feature flag.

This PR stabilizes the termination trait with the following signature:

```rust
pub trait Termination {
    fn report(self) -> ExitCode;
}
```

The existing impls of `Termination` are effectively already stable due to the prior stabilization of `?` in main.

This PR also stabilizes the following APIs on exit code

```rust
#[derive(Clone, Copy, Debug)]
pub struct ExitCode(_);

impl ExitCode {
    pub const SUCCESS: ExitCode;
    pub const FAILURE: ExitCode;
}

impl From<u8> for ExitCode { /* ... */ }
```

---

All of the previous blockers have been resolved. The main ones that were resolved recently are:

* The trait's name: We decided against changing this since none of the alternatives seemed particularly compelling. Instead we decided to end the bikeshedding and stick with the current name. ([link to the discussion](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Termination.2FExit.20Status.20Stabilization/near/269793887))
* Issues around platform specific representations: We resolved this issue by changing the return type of `report` from `i32` to the opaque type `ExitCode`. That way we can change the underlying representation without affecting the API, letting us offer full support for platform specific exit code APIs in the future.
* Custom exit codes: We resolved this by adding `From<u8> for ExitCode`. We choose to only support u8 initially because it is the least common denominator between the sets of exit codes supported by our current platforms. In the future we anticipate adding platform specific extension traits to ExitCode for constructors from larger or negative numbers, as needed.

2 years agoClarify how `src/tools/x` searches for python
Joshua Nelson [Tue, 29 Mar 2022 18:50:17 +0000 (13:50 -0500)]
Clarify how `src/tools/x` searches for python

2 years agoIndicate the correct error code in the `compile_fail` block.
Thom Chiovoloni [Tue, 29 Mar 2022 18:45:49 +0000 (11:45 -0700)]
Indicate the correct error code in the `compile_fail` block.

Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2 years agoAuto merge of #95433 - Dylan-DPC:rollup-xdfit9h, r=Dylan-DPC
bors [Tue, 29 Mar 2022 17:48:40 +0000 (17:48 +0000)]
Auto merge of #95433 - Dylan-DPC:rollup-xdfit9h, r=Dylan-DPC

Rollup of 4 pull requests

Successful merges:

 - #94566 (Show ignore message in console and json output)
 - #95415 (diagnostics: regression test for HashMap iter_mut suggestion)
 - #95422 (Refactor: Use `format-args-capture` and remove an unnecessary nested block)
 - #95424 (:arrow_up: rust-analyzer)

Failed merges:

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

2 years agodiagnostics: regression test for derive bounds
Michael Howell [Tue, 29 Mar 2022 17:17:27 +0000 (10:17 -0700)]
diagnostics: regression test for derive bounds

Closes #79076

2 years agoAuto merge of #94566 - yanganto:show-ignore-message, r=m-ou-se
bors [Tue, 29 Mar 2022 15:18:57 +0000 (15:18 +0000)]
Auto merge of #94566 - yanganto:show-ignore-message, r=m-ou-se

Show ignore message in console and json output

- Provide ignore the message in console and JSON output
- Modify the ignore message style in the log file

related: #92714

2 years agoRollup merge of #95424 - lnicola:rust-analyzer-2022-03-29, r=lnicola
Dylan DPC [Tue, 29 Mar 2022 15:11:55 +0000 (17:11 +0200)]
Rollup merge of #95424 - lnicola:rust-analyzer-2022-03-29, r=lnicola

:arrow_up: rust-analyzer

r? `@ghost`

2 years agoRollup merge of #95422 - TaKO8Ki:use-format-args-capture-and-remove-unnecessary-nesti...
Dylan DPC [Tue, 29 Mar 2022 15:11:54 +0000 (17:11 +0200)]
Rollup merge of #95422 - TaKO8Ki:use-format-args-capture-and-remove-unnecessary-nesting-in-rustc-typeck, r=petrochenkov

Refactor: Use `format-args-capture` and remove an unnecessary nested block

2 years agoRollup merge of #95415 - notriddle:notriddle/issue-82081, r=Dylan-DPC
Dylan DPC [Tue, 29 Mar 2022 15:11:52 +0000 (17:11 +0200)]
Rollup merge of #95415 - notriddle:notriddle/issue-82081, r=Dylan-DPC

diagnostics: regression test for HashMap iter_mut suggestion

Closes #82081

2 years agoRollup merge of #94566 - yanganto:show-ignore-message, r=m-ou-se
Dylan DPC [Tue, 29 Mar 2022 15:11:51 +0000 (17:11 +0200)]
Rollup merge of #94566 - yanganto:show-ignore-message, r=m-ou-se

Show ignore message in console and json output

- Provide ignore the message in console and JSON output
- Modify the ignore message style in the log file

related: #92714

2 years agoRemove unnecessary .as_ref().
Mara Bos [Tue, 29 Mar 2022 13:53:09 +0000 (15:53 +0200)]
Remove unnecessary .as_ref().

2 years agoAuto merge of #95096 - GuillaumeGomez:rm-header-fn-field, r=camelid
bors [Tue, 29 Mar 2022 12:49:03 +0000 (12:49 +0000)]
Auto merge of #95096 - GuillaumeGomez:rm-header-fn-field, r=camelid

Remove header field from clean::Function

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

This is another take on https://github.com/rust-lang/rust/issues/89673 (compared to https://github.com/rust-lang/rust/pull/91217) but very different on the approach: I moved the header call in one place but still require to have the `clean::Item` so I can use the `DefId` to get what is missing.

cc `@jyn514` (you reviewed the original so maybe you want to take a look?)
r? `@camelid`

2 years agoRefactor after review
Antonio Yang [Tue, 29 Mar 2022 11:41:16 +0000 (19:41 +0800)]
Refactor after review

Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2 years agoMerge ItemKind::TyMethodItem branch with ItemKind::FunctionItem and ItemKind::MethodI...
Guillaume Gomez [Tue, 29 Mar 2022 10:09:42 +0000 (12:09 +0200)]
Merge ItemKind::TyMethodItem branch with ItemKind::FunctionItem and ItemKind::MethodItem in fn_header function

2 years agoAuto merge of #95375 - MarcusCalhoun-Lopez:i686_apple_darwin, r=m-ou-se
bors [Tue, 29 Mar 2022 10:08:03 +0000 (10:08 +0000)]
Auto merge of #95375 - MarcusCalhoun-Lopez:i686_apple_darwin, r=m-ou-se

Fix build on i686-apple-darwin systems

Replace `target_arch = "x86_64"` with `not(target_arch = "aarch64")` so that i686-apple-darwin systems dynamically choose implementation.

2 years agoAdd test to ensure foreign functions from dependencies are correctly handled
Guillaume Gomez [Sat, 19 Mar 2022 16:08:20 +0000 (17:08 +0100)]
Add test to ensure foreign functions from dependencies are correctly handled

2 years agoRemove header field from clean::Function
Guillaume Gomez [Fri, 18 Mar 2022 17:48:32 +0000 (18:48 +0100)]
Remove header field from clean::Function

2 years agoAuto merge of #95257 - compiler-errors:fn-borrow, r=lcnr
bors [Tue, 29 Mar 2022 07:27:14 +0000 (07:27 +0000)]
Auto merge of #95257 - compiler-errors:fn-borrow, r=lcnr

Add suggestion to borrow `Fn` and `FnMut` params/opaque/closures instead of move

I think that Closure/ParamTy/Opaque are all "opaque" enough that it's meaningful to suggest borrowing them instead of moving them at their usage sites when we see a move error. See the attached issue for example.

Is this suggestion too general? I could perhaps use the move site information to limit this to places like fn calls, but I don't know enough about mir borrowck to know if that's an easy change.

Fixes #90828

2 years ago:arrow_up: rust-analyzer
Laurențiu Nicola [Tue, 29 Mar 2022 05:31:05 +0000 (08:31 +0300)]
:arrow_up: rust-analyzer

2 years agoSuggest function borrow ignoring needs_note
Michael Goulet [Tue, 29 Mar 2022 02:30:39 +0000 (19:30 -0700)]
Suggest function borrow ignoring needs_note

`needs_note` is false if we've already suggested why the type is Copy...
but that has nothing to do with the diagnostic.

2 years agodrive-by: move Copy bound suggestion to its own function
Michael Goulet [Tue, 29 Mar 2022 01:35:23 +0000 (18:35 -0700)]
drive-by: move Copy bound suggestion to its own function

2 years agoAdd suggestion to borrow opaque Fn and FnMut instead of move
Michael Goulet [Wed, 23 Mar 2022 23:15:43 +0000 (16:15 -0700)]
Add suggestion to borrow opaque Fn and FnMut instead of move

2 years agoAuto merge of #95423 - ehuss:update-books, r=ehuss
bors [Tue, 29 Mar 2022 05:15:58 +0000 (05:15 +0000)]
Auto merge of #95423 - ehuss:update-books, r=ehuss

Update books

## nomicon

3 commits in f6d6126fc96ecf4a7f7d22da330df9506293b0d0..11f1165e8a2f5840467e748c8108dc53c948ee9a
2022-02-26 02:21:21 +0900 to 2022-03-19 16:02:00 -0400
- Make the Vec impl be slightly more careful with ZSTs and alignment.
- implement `IntoIterator` for `Vec` (rust-lang/nomicon#337)
- Add an explanation shared to exclusive transmute (rust-lang/nomicon#344)

## reference

2 commits in 0a2fe6651fbccc6416c5110fdf5b93fb3cb29247..c97d14fa6fed0baa9255432b8a93cb70614f80e3
2022-03-15 09:32:25 -0700 to 2022-03-19 18:18:10 -0700
- Fixed inconsistency in the usage of semicolon at end of scopes (rust-lang/reference#1182)
- Document ADX `target_feature` (rust-lang/reference#1172)

## book

23 commits in 036e88a4f135365de85358febe5324976a56030a..ea90bbaf53ba64ef4e2da9ac2352b298aec6bec8
2022-03-04 21:53:33 -0500 to 2022-03-28 21:59:34 -0400
- Fix nostarch snapshot
- Snapshot of chapter 7 for nostarch
- Add a forward reference to chapter 14, another example of pub use
- Clarify pub use example. Fixes rust-lang/book#2716.
- Fancy quotes
- Fix incorrectly worded sentence. Fixes rust-lang/book#3086.
- Reword description of how a listing came to be
- Call out binary+library crate practices
- Define binary and library crates more explicitly
- Clarify when a path is a crate name and when it should be literal crate
- Make it clearer the outer `mod` doesn't move to the file
- Don't wrap this example in main when copying. Fixes rust-lang/book#2930.
- Try to make clearer that `mod` is not an `import`
- Mention mod.rs file naming scheme
- Explain why submodule subdirectories are needed more
- Rename a separate example of serve_order to deliver_order
- Show an example that `use` only applies in its own scope
- quick modules guide
- Tweak a snippet of ch18-03
- Propagating edits to chapter 10 back
- Responses to nostarch questions of chapter 10
- Update src/ch04-01-what-is-ownership.md
- Add Danish translation link. Connects to rust-lang/book#3079.

## rust-by-example

2 commits in d504324f1e7dc7edb918ac39baae69f1f1513b8e..ec954f35eedf592cd173b21c05a7f80a65b61d8a
2022-03-07 09:26:32 -0300 to 2022-03-22 11:09:06 -0300
- PathBuf details and example (rust-lang/rust-by-example#1519)
- Move allow dead code attribute and add comment (rust-lang/rust-by-example#1518)

## rustc-dev-guide

1 commits in 0e4b961a9c708647bca231430ce1b199993e0196..155126b1d2e2cb01ddb1d7ba9489b90d7cd173ad
2022-03-14 08:40:37 -0700 to 2022-03-22 14:34:21 +0100
- update section for type system constants (rust-lang/rustc-dev-guide#1329)

## embedded-book

1 commits in d5fc1bce3f8eb398f9c25f1b15e0257d7537cd41..a6de8b6e3ea5d4f0de8b7b9a7e5c1405dc2c2ddb
2022-01-24 07:13:31 +0000 to 2022-03-17 21:21:39 +0000
- Update OpenOCD install instruction for rust-embedded/book#313  (rust-embedded/book#314)

2 years agoUpdate books
Eric Huss [Tue, 29 Mar 2022 05:16:31 +0000 (22:16 -0700)]
Update books

2 years agouse format-args-capture and remove an unnecessary nested block
Takayuki Maeda [Tue, 29 Mar 2022 03:15:09 +0000 (12:15 +0900)]
use format-args-capture and remove an unnecessary nested block

2 years agoAuto merge of #95417 - ehuss:doc-no_std-error, r=Dylan-DPC
bors [Tue, 29 Mar 2022 01:09:22 +0000 (01:09 +0000)]
Auto merge of #95417 - ehuss:doc-no_std-error, r=Dylan-DPC

bootstrap: better error message for no_std docs

Currently if one tries to build std documentation for a no_std target, you get a confusing error message:

`error: The argument '--package [<SPEC>...]' was provided more than once, but cannot be used multiple times`

This is because [`std_cargo`](https://github.com/rust-lang/rust/blob/600ec284838c52d1f6657c2cf0097b58970b133b/src/bootstrap/compile.rs#L299-L305) has a built-in `-p alloc` argument that conflicts with the `cargo rustdoc` command used in the Std doc step.

This just adds a better error message in this scenario. It may be possible to fix this correctly, but that would likely be a bit more of an invasive change that I don't have time for right now.

2 years agoAuto merge of #95249 - HeroicKatora:set-ptr-value, r=dtolnay
bors [Mon, 28 Mar 2022 22:47:31 +0000 (22:47 +0000)]
Auto merge of #95249 - HeroicKatora:set-ptr-value, r=dtolnay

Refactor set_ptr_value as with_metadata_of

Replaces `set_ptr_value` (#75091) with methods of reversed argument order:

```rust
impl<T: ?Sized> *mut T {
    pub fn with_metadata_of<U: ?Sized>(self, val: *mut U) -> *mut U;
}

impl<T: ?Sized> *const T {
    pub fn with_metadata_of<U: ?Sized>(self, val: *const U) -> *const U;
}
```

By reversing the arguments we achieve several clarifications:

- The function closely resembles `cast` with an argument to
  initialize the metadata. This is easier to teach and answers a long
  outstanding question that had restricted cast to `Sized` pointee
  targets. See multiples reviews of
  <https://github.com/rust-lang/rust/pull/47631>
- The 'object identity', in the form of provenance, is now preserved
  from the receiver argument to the result. This helps explain the method as
  a builder-style, instead of some kind of setter that would modify
  something in-place. Ensuring that the result has the identity of the
  `self` argument is also beneficial for an intuition of effects.
- An outstanding concern, 'Correct argument type', is avoided by not
  committing to any specific argument type. This is consistent with cast
  which does not require its receiver to be a 'raw address'.

Hopefully the usage examples in `sync/rc.rs` serve as sufficient examples of the style to convince the reader of the readability improvements of this style, when compared to the previous order of arguments.

I want to take the opportunity to motivate inclusion of this method _separate_ from metadata API, separate from `feature(ptr_metadata)`. It does _not_ involve the `Pointee` trait in any form. This may be regarded as a very, very light form that does not commit to any details of the pointee trait, or its associated metadata. There are several use cases for which this is already sufficient and no further inspection of metadata is necessary.

- Storing the coercion of `*mut T` into `*mut dyn Trait` as a way to dynamically cast some an arbitrary instance of the same type to a dyn trait instance. In particular, one can have a field of type `Option<*mut dyn io::Seek>` to memorize if a particular writer is seekable. Then a method `fn(self: &T) -> Option<&dyn Seek>` can be provided, which does _not_ involve the static trait bound `T: Seek`. This makes it possible to create an API that is capable of utilizing seekable streams and non-seekable streams (instead of a possible less efficient manner such as more buffering) through the same entry-point.

- Enabling more generic forms of unsizing for no-`std` smart pointers. Using the stable APIs only few concrete cases are available. One can unsize arrays to `[T]` by `ptr::slice_from_raw_parts` but unsizing a custom smart pointer to, e.g., `dyn Iterator`, `dyn Future`, `dyn Debug`, can't easily be done generically. Exposing `with_metadata_of` would allow smart pointers to offer their own `unsafe` escape hatch with similar parameters where the caller provides the unsized metadata. This is particularly interesting for embedded where `dyn`-trait usage can drastically reduce code size.

2 years agoFix build on i686-apple-darwin systems
Marcus Calhoun-Lopez [Mon, 28 Mar 2022 19:44:19 +0000 (12:44 -0700)]
Fix build on i686-apple-darwin systems

On 32-bit systems, fdopendir is called `_fdopendir$INODE64$UNIX2003`.
On 64-bit systems, fdopendir is called `_fdopendir$INODE64`.

2 years agoFix build on i686-apple-darwin systems
Marcus Calhoun-Lopez [Sun, 27 Mar 2022 18:18:01 +0000 (11:18 -0700)]
Fix build on i686-apple-darwin systems

Replace `target_arch = "x86_64"` with `not(target_arch = "aarch64")` so that i686-apple-darwin systems dynamically choose implementation.

2 years agobootstrap: better error message for no_std docs
Eric Huss [Mon, 28 Mar 2022 19:13:18 +0000 (12:13 -0700)]
bootstrap: better error message for no_std docs

2 years agodiagnostics: add regression test for #82081
Michael Howell [Mon, 28 Mar 2022 18:47:19 +0000 (11:47 -0700)]
diagnostics: add regression test for #82081

2 years agodiagnostics: do not suggest `map.iter_mut()()`
Michael Howell [Mon, 28 Mar 2022 18:47:01 +0000 (11:47 -0700)]
diagnostics: do not suggest `map.iter_mut()()`

2 years agoAuto merge of #95414 - Dylan-DPC:rollup-9hbshd0, r=Dylan-DPC
bors [Mon, 28 Mar 2022 18:42:59 +0000 (18:42 +0000)]
Auto merge of #95414 - Dylan-DPC:rollup-9hbshd0, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #93787 (parallel_compiler: hide dependencies behind feature)
 - #95318 (diagnostics: correct generic bounds with doubled colon)
 - #95328 (Fix yet another Box<T, A> ICE)
 - #95397 (Link to std::io's platform-specific behavior disclaimer)
 - #95407 (Inline u8::is_utf8_char_boundary)

Failed merges:

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

2 years agoRollup merge of #95407 - xfix:inline-u8-is_utf8_char_boundary, r=scottmcm
Dylan DPC [Mon, 28 Mar 2022 18:41:53 +0000 (20:41 +0200)]
Rollup merge of #95407 - xfix:inline-u8-is_utf8_char_boundary, r=scottmcm

Inline u8::is_utf8_char_boundary

Since Rust beta, Rust is incapable of inlining this function in the following example function.

```rust
pub fn safe_substr_to(s: &str, mut length: usize) -> &str {
    loop {
        if let Some(s) = s.get(..length) {
            return s;
        }
        length -= 1;
    }
}
```

When compiled with beta or nightly compiler on Godbolt with `-C opt-level=3` flag it prints the following assembly.

```asm
example::safe_substr_to:
        push    r15
        push    r14
        push    r12
        push    rbx
        push    rax
        mov     r14, rdi
        test    rdx, rdx
        je      .LBB0_8
        mov     rbx, rdx
        mov     r15, rsi
        mov     r12, qword ptr [rip + core::num::<impl u8>::is_utf8_char_boundary@GOTPCREL]
        jmp     .LBB0_4
.LBB0_2:
        je      .LBB0_9
.LBB0_3:
        add     rbx, -1
        je      .LBB0_8
.LBB0_4:
        cmp     rbx, r15
        jae     .LBB0_2
        movzx   edi, byte ptr [r14 + rbx]
        call    r12
        test    al, al
        je      .LBB0_3
        mov     r15, rbx
        jmp     .LBB0_9
.LBB0_8:
        xor     r15d, r15d
.LBB0_9:
        mov     rax, r14
        mov     rdx, r15
        add     rsp, 8
        pop     rbx
        pop     r12
        pop     r14
        pop     r15
        ret
```

`qword ptr [rip + core::num::<impl u8>::is_utf8_char_boundary@GOTPCREL]` is not inlined. `-C remark=all` outputs the following message:

```
note: /rustc/7bccde19767082c7865a12902fa614ed4f8fed73/library/core/src/str/mod.rs:214:25: inline: _ZN4core3num20_$LT$impl$u20$u8$GT$21is_utf8_char_boundary17hace9f12f5ba07a7fE will not be inlined into _ZN4core3str21_$LT$impl$u20$str$GT$16is_char_boundary17hf2587e9a6b8c5e43E because its definition is unavailable
```

Stable compiler outputs more reasonable code:

```asm
example::safe_substr_to:
        mov     rcx, rdx
        mov     rax, rdi
        test    rdx, rdx
        je      .LBB0_9
        mov     rdx, rsi
        jmp     .LBB0_4
.LBB0_2:
        cmp     rdx, rcx
        je      .LBB0_7
.LBB0_3:
        add     rcx, -1
        je      .LBB0_9
.LBB0_4:
        cmp     rcx, rdx
        jae     .LBB0_2
        cmp     byte ptr [rax + rcx], -64
        jl      .LBB0_3
        mov     rdx, rcx
.LBB0_7:
        ret
.LBB0_9:
        xor     edx, edx
        ret
```

2 years agoRollup merge of #95397 - dtolnay:disclaimer, r=m-ou-se
Dylan DPC [Mon, 28 Mar 2022 18:41:52 +0000 (20:41 +0200)]
Rollup merge of #95397 - dtolnay:disclaimer, r=m-ou-se

Link to std::io's platform-specific behavior disclaimer

This PR adds some links in standard library documentation to point to https://doc.rust-lang.org/std/io/index.html#platform-specific-behavior.

> ### Platform-specific behavior
>
> Many I/O functions throughout the standard library are documented to indicate what various library or syscalls they are delegated to. This is done to help applications both understand what’s happening under the hood as well as investigate any possibly unclear semantics. Note, however, that this is informative, not a binding contract. The implementation of many of these functions are subject to change over time and may call fewer or more syscalls/library functions.

Many of the `std::fs` APIs already link to this disclaimer when discussing system calls.

2 years agoRollup merge of #95328 - DrMeepster:box_gep_err, r=oli-obk
Dylan DPC [Mon, 28 Mar 2022 18:41:51 +0000 (20:41 +0200)]
Rollup merge of #95328 - DrMeepster:box_gep_err, r=oli-obk

Fix yet another Box<T, A> ICE

Fixes #95036.

This widens the special case from #94414 to make sure that boxes with a custom allocator are never directly dereferenced.

2 years agoRollup merge of #95318 - rust-lang:notriddle/issue-95208, r=wesleywiser
Dylan DPC [Mon, 28 Mar 2022 18:41:50 +0000 (20:41 +0200)]
Rollup merge of #95318 - rust-lang:notriddle/issue-95208, r=wesleywiser

diagnostics: correct generic bounds with doubled colon

Fixes #95208

2 years agoRollup merge of #93787 - klensy:really-not-a-features, r=wesleywiser
Dylan DPC [Mon, 28 Mar 2022 18:41:49 +0000 (20:41 +0200)]
Rollup merge of #93787 - klensy:really-not-a-features, r=wesleywiser

parallel_compiler: hide dependencies behind feature

Separate dependencies for `parallel_compiler` feature, so they will not be compiled if feature not selected, reducing number of compiled crates from 238 to 224.

2 years agorebase fallout
Oli Scherer [Mon, 28 Mar 2022 17:22:42 +0000 (17:22 +0000)]
rebase fallout

2 years agoAdd test for revealing auto traits in the defining scope
Oli Scherer [Thu, 17 Mar 2022 14:27:21 +0000 (14:27 +0000)]
Add test for revealing auto traits in the defining scope

2 years agoAdd some tests showcasing further differences between TAIT and RPIT
Oli Scherer [Thu, 17 Mar 2022 13:28:12 +0000 (13:28 +0000)]
Add some tests showcasing further differences between TAIT and RPIT

2 years agoBless ui tests
Oli Scherer [Tue, 1 Mar 2022 16:03:27 +0000 (16:03 +0000)]
Bless ui tests

2 years agoAlso use the RPIT back compat hack in trait projection
Oli Scherer [Wed, 23 Feb 2022 13:34:39 +0000 (13:34 +0000)]
Also use the RPIT back compat hack in trait projection

2 years agoShow that the behaviour is the same for RPIT and TAIT
Oli Scherer [Wed, 23 Feb 2022 13:14:59 +0000 (13:14 +0000)]
Show that the behaviour is the same for RPIT and TAIT

2 years agoAdd a test showing that a similar example compiles
Oli Scherer [Tue, 22 Feb 2022 17:20:58 +0000 (17:20 +0000)]
Add a test showing that a similar example compiles

2 years agoAdded another folder to the `ui` dir
Oli Scherer [Tue, 22 Feb 2022 17:10:38 +0000 (17:10 +0000)]
Added another folder to the `ui` dir

2 years agoFix mixing lazy TAIT and RPIT in their defining scopes
Oli Scherer [Tue, 22 Feb 2022 17:09:25 +0000 (17:09 +0000)]
Fix mixing lazy TAIT and RPIT in their defining scopes

2 years agoAdd regression test
Oli Scherer [Tue, 22 Feb 2022 15:38:58 +0000 (15:38 +0000)]
Add regression test

2 years agoAdd another regression test
Oli Scherer [Thu, 17 Feb 2022 15:59:04 +0000 (15:59 +0000)]
Add another regression test

2 years agoTest that TAIT and RPIT are in sync
Oli Scherer [Thu, 17 Feb 2022 15:54:28 +0000 (15:54 +0000)]
Test that TAIT and RPIT are in sync

2 years agoAdd some tests around recursion and "revealing"
Oli Scherer [Thu, 17 Feb 2022 15:42:53 +0000 (15:42 +0000)]
Add some tests around recursion and "revealing"

2 years agoRemove some special code handling TAIT being passed through if and match
Oli Scherer [Thu, 17 Feb 2022 15:23:28 +0000 (15:23 +0000)]
Remove some special code handling TAIT being passed through if and match

This is not necessary for RPIT anymore, since we reverted that to using inference vars.

2 years agoThe hack isn't necessary for back compat anymore
Oli Scherer [Thu, 17 Feb 2022 15:02:17 +0000 (15:02 +0000)]
The hack isn't necessary for back compat anymore

2 years agoMerge two duplicates of the same logic into a common function
Oli Scherer [Thu, 17 Feb 2022 14:49:45 +0000 (14:49 +0000)]
Merge two duplicates of the same logic into a common function

2 years agoAdd regression tests
Oli Scherer [Thu, 17 Feb 2022 13:55:58 +0000 (13:55 +0000)]
Add regression tests

2 years agoRemove opaque type obligation and just register opaque types as they are encountered.
Oli Scherer [Thu, 17 Feb 2022 13:28:06 +0000 (13:28 +0000)]
Remove opaque type obligation and just register opaque types as they are encountered.

This also registers obligations for the hidden type immediately.

2 years agoTouch up ExitCode docs
Noa [Sun, 27 Mar 2022 23:38:01 +0000 (18:38 -0500)]
Touch up ExitCode docs

2 years agoRevert to inference variable based hidden type computation for RPIT
Oli Scherer [Wed, 16 Feb 2022 15:48:46 +0000 (15:48 +0000)]
Revert to inference variable based hidden type computation for RPIT

2 years agoInline u8::is_utf8_char_boundary
Konrad Borowski [Mon, 28 Mar 2022 16:37:11 +0000 (18:37 +0200)]
Inline u8::is_utf8_char_boundary

2 years agoSpecial case the situation where the previous span is the same as the new one
Oli Scherer [Wed, 9 Feb 2022 17:39:28 +0000 (17:39 +0000)]
Special case the situation where the previous span is the same as the new one

2 years agoHave the spans of TAIT type conflict errors point to the actual site instead of the...
Oli Scherer [Wed, 9 Feb 2022 16:44:17 +0000 (16:44 +0000)]
Have the spans of TAIT type conflict errors point to the actual site instead of the owning function

2 years agoRemove some dead code
Oli Scherer [Thu, 10 Feb 2022 14:14:39 +0000 (14:14 +0000)]
Remove some dead code

2 years agoNormalize all projections in mir validation again
Oli Scherer [Thu, 10 Feb 2022 17:53:35 +0000 (17:53 +0000)]
Normalize all projections in mir validation again

2 years agoDon't bind hidden types when searching for matching impls
Oli Scherer [Thu, 10 Feb 2022 14:53:50 +0000 (14:53 +0000)]
Don't bind hidden types when searching for matching impls

2 years agoFail more aggressively
Oli Scherer [Thu, 10 Feb 2022 14:15:20 +0000 (14:15 +0000)]
Fail more aggressively

2 years agoRevert "Auto merge of #93893 - oli-obk:sad_revert, r=oli-obk"
Oli Scherer [Mon, 14 Feb 2022 16:10:22 +0000 (16:10 +0000)]
Revert "Auto merge of #93893 - oli-obk:sad_revert, r=oli-obk"

This reverts commit 6499c5e7fc173a3f55b7a3bd1e6a50e9edef782d, reversing
changes made to 78450d2d602b06d9b94349aaf8cece1a4acaf3a8.

2 years agoAuto merge of #95403 - Dylan-DPC:rollup-9on30mg, r=Dylan-DPC
bors [Mon, 28 Mar 2022 16:15:17 +0000 (16:15 +0000)]
Auto merge of #95403 - Dylan-DPC:rollup-9on30mg, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #95301 (Remove `Nonterminal::NtTT`.)
 - #95314 (Tell users that `||` operators are not currently supported in let chain expressions)
 - #95350 (resolve: Simplify some diagnostic code to avoid an ICE)
 - #95370 ([bootstrap] Don't print `Suite not skipped` unless `--verbose` is set)
 - #95390 (Ignore doc comments in a declarative macro matcher.)
 - #95401 (Remove duplicated and unused test files)

Failed merges:

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

2 years agoRollup merge of #95401 - c410-f3r:moar-tests, r=petrochenkov
Dylan DPC [Mon, 28 Mar 2022 14:08:12 +0000 (16:08 +0200)]
Rollup merge of #95401 - c410-f3r:moar-tests, r=petrochenkov

Remove duplicated and unused test files

cc https://github.com/rust-lang/rust/issues/73494
r? `@petrochenkov`

2 years agoRollup merge of #95390 - nnethercote:allow-doc-comments-in-macros, r=petrochenkov
Dylan DPC [Mon, 28 Mar 2022 14:08:11 +0000 (16:08 +0200)]
Rollup merge of #95390 - nnethercote:allow-doc-comments-in-macros, r=petrochenkov

Ignore doc comments in a declarative macro matcher.

Fixes #95267. Reverts to the old behaviour before #95159 introduced a
regression.

r? `@petrochenkov`

2 years agoRollup merge of #95370 - jyn514:less-verbose-skips, r=Dylan-DPC
Dylan DPC [Mon, 28 Mar 2022 14:08:10 +0000 (16:08 +0200)]
Rollup merge of #95370 - jyn514:less-verbose-skips, r=Dylan-DPC

[bootstrap] Don't print `Suite not skipped` unless `--verbose` is set

This was so verbose before that it made it hard to see what effect the flag actually had.

Before:
```
Set({test::src/tools/tidy}) not skipped for "bootstrap::test::Tidy" -- not in [src/test/ui, src/test/mir-opt/, src/test/debuginfo, src/test/ui-fulldeps]
Skipping Suite(test::src/test/ui) because it is excluded
Suite(test::src/test/run-pass-valgrind) not skipped for "bootstrap::test::RunPassValgrind" -- not in [src/test/ui, src/test/mir-opt/, src/test/debuginfo, src/test/ui-fulldeps]
Skipping Suite(test::src/test/mir-opt) because it is excluded
Suite(test::src/test/codegen) not skipped for "bootstrap::test::Codegen" -- not in [src/test/ui, src/test/mir-opt/, src/test/debuginfo, src/test/ui-fulldeps]
Suite(test::src/test/codegen-units) not skipped for "bootstrap::test::CodegenUnits" -- not in [src/test/ui, src/test/mir-opt/, src/test/debuginfo, src/test/ui-fulldeps]
Suite(test::src/test/assembly) not skipped for "bootstrap::test::Assembly" -- not in [src/test/ui, src/test/mir-opt/, src/test/debuginfo, src/test/ui-fulldeps]
Suite(test::src/test/incremental) not skipped for "bootstrap::test::Incremental" -- not in [src/test/ui, src/test/mir-opt/, src/test/debuginfo, src/test/ui-fulldeps]
Skipping Suite(test::src/test/debuginfo) because it is excluded
Skipping Suite(test::src/test/ui-fulldeps) because it is excluded
... about 100 more lines ...
```

After:
```
Skipping Suite(test::src/test/ui) because it is excluded
Skipping Suite(test::src/test/mir-opt) because it is excluded
Skipping Suite(test::src/test/debuginfo) because it is excluded
Skipping Suite(test::src/test/ui-fulldeps) because it is excluded
```

2 years agoRollup merge of #95350 - petrochenkov:qpathregr, r=cjgillot
Dylan DPC [Mon, 28 Mar 2022 14:08:09 +0000 (16:08 +0200)]
Rollup merge of #95350 - petrochenkov:qpathregr, r=cjgillot

resolve: Simplify some diagnostic code to avoid an ICE

No need to resolve those paths, they are already resolved, we just need to take the results from `partial_res_map`.

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

2 years agoRollup merge of #95314 - c410-f3r:aqui-vamos-nos, r=lcnr
Dylan DPC [Mon, 28 Mar 2022 14:08:08 +0000 (16:08 +0200)]
Rollup merge of #95314 - c410-f3r:aqui-vamos-nos, r=lcnr

Tell users that `||` operators are not currently supported in let chain expressions

Tells that `||` operators are not currently supported instead of not allowed. See https://github.com/rust-lang/rust/issues/53667#issuecomment-1066075876

In other words, this PR is pretty much trivial.

2 years agoRollup merge of #95301 - nnethercote:rm-NtTT, r=petrochenkov
Dylan DPC [Mon, 28 Mar 2022 14:08:07 +0000 (16:08 +0200)]
Rollup merge of #95301 - nnethercote:rm-NtTT, r=petrochenkov

Remove `Nonterminal::NtTT`.

It's only needed for macro expansion, not as a general element in the
AST. This commit removes it, adds `NtOrTt` for the parser and macro
expansion cases, and renames the variants in `NamedMatch` to better
match the new type.

r? `@petrochenkov`

2 years agoAuto merge of #95024 - koehlma:rustdoc-private-items, r=GuillaumeGomez,camelid,jsha
bors [Mon, 28 Mar 2022 13:49:22 +0000 (13:49 +0000)]
Auto merge of #95024 - koehlma:rustdoc-private-items, r=GuillaumeGomez,camelid,jsha

rustdoc: add 🔒 to items with restricted visibility

This change marks items with restricted visibility with 🔒 when building with `--document-private-items`:

<img width="278" alt="Screen Shot 2022-03-20 at 23 50 24" src="https://user-images.githubusercontent.com/509209/159189513-9e4b09bb-6785-41a5-bfe2-df02f83f8641.png">

There also appears a “Restricted Visibility” tooltip when hovering over the emoji.

---

The original PR for reference:

This change makes private items slightly transparent (similar to `unstable` items in rustc):

<img width="272" alt="Screen Shot 2022-03-16 at 22 17 43" src="https://user-images.githubusercontent.com/509209/158692627-a1f6f5ec-e043-4aa2-9352-8d2b15c31c08.png">

I found myself using `--document-private-items` a lot recently because I find the documentation of private internals quite helpful when working on a larger project. However, not being able to distinguish private from public items (see #87785) when looking at the documentation makes this somewhat cumbersome.

This PR addresses the third suggestion of issue #87785 by marking private items typographically. It seems to me that the other suggestions are more involved but this is at least a first step.

A private item is also made slightly transparent in the path displayed in the header of a page:

<img width="467" alt="Screen Shot 2022-03-16 at 22 19 51" src="https://user-images.githubusercontent.com/509209/158692885-0bbd3417-3c0b-486f-b8ab-99c05c6fa7ca.png">

I am looking forward to feedback and suggestions.

2 years agoRemove duplicated and unused test files
Caio [Mon, 28 Mar 2022 13:16:32 +0000 (10:16 -0300)]
Remove duplicated and unused test files

2 years agoAuto merge of #94789 - compiler-errors:fatal-never, r=eddyb
bors [Mon, 28 Mar 2022 11:08:23 +0000 (11:08 +0000)]
Auto merge of #94789 - compiler-errors:fatal-never, r=eddyb

Make fatal DiagnosticBuilder yield `!`

Fatal errors should really be fatal, so emitting them should cause us to exit at the same time.

Fine with just throwing away these changes if they're not worthwhile. Also, maybe we want to use an uninhabited enum instead of `!`.

r? `@eddyb` who has been working on `DiagnosticBuilder` stuff, feel free to reassign.

2 years agoAuto merge of #95396 - TaKO8Ki:suggest-replacing-field-when-using-the-same-type,...
bors [Mon, 28 Mar 2022 08:40:25 +0000 (08:40 +0000)]
Auto merge of #95396 - TaKO8Ki:suggest-replacing-field-when-using-the-same-type, r=compiler-errors

Suggest replacing a field when using the same type

closes #89166

2 years agoAuto merge of #95300 - workingjubilee:less-bitsets, r=eddyb
bors [Mon, 28 Mar 2022 05:48:25 +0000 (05:48 +0000)]
Auto merge of #95300 - workingjubilee:less-bitsets, r=eddyb

Skip needless bitset for debuginfo

Found this while digging around looking at the inlining logic.
Seemed obvious enough so I decided to try to take care of it.
Is this what you had in mind, `@eddyb?`

2 years agoPropagate `parallel_compiler` feature through rustc crates. Turned off feature gives...
klensy [Fri, 11 Feb 2022 20:25:14 +0000 (23:25 +0300)]
Propagate `parallel_compiler` feature through rustc crates. Turned off feature gives change of builded crates: 238 -> 224.

2 years agouse cfg attribute instead of macro
klensy [Tue, 8 Feb 2022 19:21:16 +0000 (22:21 +0300)]
use cfg attribute instead of macro