Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix coherence checking for impl trait in type aliases #63934

Merged
merged 2 commits into from
Sep 25, 2019

Conversation

Aaron1011
Copy link
Member

@Aaron1011 Aaron1011 commented Aug 27, 2019

UPDATE: This PR now treats all opaque types as remote. The original description appears below, but is no longer accurate.

Fixes #63677

RFC 2071 (impl-trait-existential-types) does not explicitly state how type_alias_impl_trait should interact with coherence. However, there's only one choice which makes sense - coherence should look at the underlying type (i.e. the "defining" type of the impl Trait) of the type alias, just like we do for non-impl Trait type aliases.

Specifically, impl Trait type aliases that resolve to a local type should be treated like a local type with respect to coherence (e.g. impl Trait type aliases which resolve to a foreign type should be treated as a foreign type, and those that resolve to a local type should be treated as a local type).

Since neither inherent impls nor direct trait impl (i.e. impl MyType or impl MyTrait for MyType) are allowed for type aliases, this usually does not come up. Before we ever attempt to do coherence checking, we will have errored out if an impl Trait type alias was used directly in an impl clause.

However, during trait selection, we sometimes need to prove bounds like T: Sized for some type T. If T is an impl trait type alias, this requires to know the coherence behavior for impl Trait type aliases when we perform coherence checking.

Note: Since determining the underlying type of an impl Trait type alias requires us to perform body type checking, this commit causes us to type check some bodies easier than we otherwise would have. However, since this is done through a query, this shouldn't cause any problems

For completeness, I've added an additional test of the coherence-related behavior of impl Trait type aliases.

cc #63063

@rust-highfive
Copy link
Collaborator

r? @petrochenkov

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 27, 2019
@Centril Centril added the F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` label Aug 27, 2019
@Centril
Copy link
Contributor

Centril commented Aug 27, 2019

r? @nikomatsakis cc @cramertj @varkor

@nikomatsakis
Copy link
Contributor

This is another PR that requires some thought. I'm scheduling a slot on this coming Friday (Sep 6) to do that.

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spent some time thinking about this PR. I'm not sure yet if I think it's the right direction, but here are some interim notes.

src/librustc/traits/coherence.rs Show resolved Hide resolved
@JohnCSimon
Copy link
Member

Ping from triage

@Aaron1011 What is the status of this pr?

Thanks

@nikomatsakis
Copy link
Contributor

@Aaron1011

I think it makes sense to say that opaque types are always non-local with respect to coherence.

I'm inclined to agree. Re-reading my comment, I'm not entirely sure what I was concerned about when talking about a "smarter negative" test. If we consider opaque types as foreign, I think that will have the effect I wanted of not assuming either way whether they implement other traits.

Can you update the PR to make opaque types be considered foreign?

@Centril Centril added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 18, 2019
@rust-highfive
Copy link
Collaborator

The job mingw-check of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-09-18T21:36:06.6551335Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-09-18T21:36:06.6807985Z ##[command]git config gc.auto 0
2019-09-18T21:36:06.6882928Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-09-18T21:36:06.6934603Z ##[command]git config --get-all http.proxy
2019-09-18T21:36:06.7074384Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/63934/merge:refs/remotes/pull/63934/merge
---
2019-09-18T21:44:34.5299432Z     Checking syntax_ext v0.0.0 (/checkout/src/libsyntax_ext)
2019-09-18T21:45:01.2731008Z error: unreachable pattern
2019-09-18T21:45:01.2731601Z    --> src/librustc/traits/coherence.rs:548:9
2019-09-18T21:45:01.2731882Z     |
2019-09-18T21:45:01.2732194Z 548 |         ty::Opaque(..) => {
2019-09-18T21:45:01.2732789Z     |
2019-09-18T21:45:01.2733104Z     = note: `-D unreachable-patterns` implied by `-D warnings`
2019-09-18T21:45:01.2733179Z 
2019-09-18T21:45:22.0082068Z error: aborting due to previous error
---
2019-09-18T21:45:22.3674739Z == clock drift check ==
2019-09-18T21:45:22.3690945Z   local time: Wed Sep 18 21:45:22 UTC 2019
2019-09-18T21:45:22.6357875Z   network time: Wed, 18 Sep 2019 21:45:22 GMT
2019-09-18T21:45:22.6362025Z == end clock drift check ==
2019-09-18T21:45:23.2806325Z ##[error]Bash exited with code '1'.
2019-09-18T21:45:23.2852154Z ##[section]Starting: Checkout
2019-09-18T21:45:23.2853932Z ==============================================================================
2019-09-18T21:45:23.2853986Z Task         : Get sources
2019-09-18T21:45:23.2854034Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@Aaron1011
Copy link
Member Author

@nikomatsakis Updated

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we also need a test focused on negative reasoning. Something like this:

trait OpaqueTrait { }
impl<T> OpaqueTrait for { }
type OpaqueType = impl OpaqueTrait;
fn mk_opaque() -> OpaqueType { () }

#[derive(Debug)]
struct D<T>(T);

trait AnotherTrait { }
impl<T: Debug> AnotherTrait for T { }

// This is in error, because we cannot assume that `OpaqueType: !Debug`.
impl AnotherTrait for D<OpaqueType> { 
    //^~ ERROR foo
}

Another good test would be to check for auto trait interaction:

trait OpaqueTrait { }
impl<T> OpaqueTrait for { }
type OpaqueType = impl OpaqueTrait;
fn mk_opaque() -> OpaqueType { () }

#[derive(Debug)]
struct D<T>(T);

trait AnotherTrait { }
impl<T: Send> AnotherTrait for T { }

// This is in error, because we cannot assume that `OpaqueType: !Send`.
// (We treat opaque types as "foreign types" that could grow more impls
// in the future.)
impl AnotherTrait for D<OpaqueType> { 
    //^~ ERROR foo
}

It would be good to create cross-crate vesions of these tests, as well.

@nikomatsakis
Copy link
Contributor

@Aaron1011 these changes look great, and the comment explaining the reasoning is good; I left a review with a few more tests to add, but otherwise I think good to go.

@Aaron1011
Copy link
Member Author

@nikomatsakis: I've added the tests you requested

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-09-24T14:03:42.4926302Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-09-24T14:03:43.1079919Z ##[command]git config gc.auto 0
2019-09-24T14:03:43.1084505Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-09-24T14:03:43.1086547Z ##[command]git config --get-all http.proxy
2019-09-24T14:03:43.1090656Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/63934/merge:refs/remotes/pull/63934/merge
---
2019-09-24T15:02:25.9164519Z .................................................................................................... 1500/9042
2019-09-24T15:02:31.6069683Z .................................................................................................... 1600/9042
2019-09-24T15:02:43.2794851Z .........................................................................i...............i.......... 1700/9042
2019-09-24T15:02:49.9586619Z .................................................................................................... 1800/9042
2019-09-24T15:02:58.1114322Z ................................................................iiiii............................... 1900/9042
2019-09-24T15:03:16.2324507Z .................................................................................................... 2100/9042
2019-09-24T15:03:18.6085164Z .................................................................................................... 2200/9042
2019-09-24T15:03:21.6532979Z .................................................................................................... 2300/9042
2019-09-24T15:03:29.4550045Z .................................................................................................... 2400/9042
---
2019-09-24T15:06:18.7704826Z .......................................................i...............i............................ 4700/9042
2019-09-24T15:06:27.5079612Z .................................................................................................... 4800/9042
2019-09-24T15:06:35.5998390Z .................................................................................................... 4900/9042
2019-09-24T15:06:42.5630647Z .................................................................................................... 5000/9042
2019-09-24T15:06:51.7482190Z ..........................................ii.ii..................................................... 5100/9042
2019-09-24T15:07:01.2351606Z .................................................................................................... 5300/9042
2019-09-24T15:07:11.0478725Z .................................................................................................... 5400/9042
2019-09-24T15:07:17.9689348Z .......i............................................................................................ 5500/9042
2019-09-24T15:07:23.0960995Z .................................................................................................... 5600/9042
2019-09-24T15:07:23.0960995Z .................................................................................................... 5600/9042
2019-09-24T15:07:33.9594429Z .................................................................................................... 5700/9042
2019-09-24T15:07:45.9434672Z ..ii...i...ii..........i............................................................................ 5800/9042
2019-09-24T15:08:06.1848269Z .................................................................................................... 6000/9042
2019-09-24T15:08:14.5031020Z .................................................................................................... 6100/9042
2019-09-24T15:08:14.5031020Z .................................................................................................... 6100/9042
2019-09-24T15:08:27.3835054Z ....i..ii........................................................................................... 6200/9042
2019-09-24T15:08:45.7014536Z ................................................................i................................... 6400/9042
2019-09-24T15:08:47.0410623Z .................................................................................................... 6500/9042
2019-09-24T15:08:49.3289660Z ....................................i............................................................... 6600/9042
2019-09-24T15:08:53.1951269Z .................................................................................................... 6700/9042
---
2019-09-24T15:12:39.6802226Z 
2019-09-24T15:12:39.6803165Z ---- [ui] ui/impl-trait/negative-reasoning.rs stdout ----
2019-09-24T15:12:39.6804117Z diff of stderr:
2019-09-24T15:12:39.6804431Z 
2019-09-24T15:12:39.6804683Z 7 LL | impl AnotherTrait for D<OpaqueType> {
2019-09-24T15:12:39.6804942Z 8    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<OpaqueType>`
2019-09-24T15:12:39.6805212Z 9    |
2019-09-24T15:12:39.6805834Z -    = note: upstream crates may add new impl of trait `std::fmt::Debug` for type `OpaqueType` in future versions
2019-09-24T15:12:39.6806183Z +    = note: upstream crates may add a new impl of trait `std::fmt::Debug` for type `OpaqueType` in future versions
2019-09-24T15:12:39.6806719Z 12 error: aborting due to previous error
2019-09-24T15:12:39.6806986Z 13 
2019-09-24T15:12:39.6807200Z 
2019-09-24T15:12:39.6807564Z 
2019-09-24T15:12:39.6807564Z 
2019-09-24T15:12:39.6807762Z The actual stderr differed from the expected stderr.
2019-09-24T15:12:39.6808298Z Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/impl-trait/negative-reasoning/negative-reasoning.stderr
2019-09-24T15:12:39.6808763Z To update references, rerun the tests and pass the `--bless` flag
2019-09-24T15:12:39.6809302Z To only update this specific test, also pass `--test-args impl-trait/negative-reasoning.rs`
2019-09-24T15:12:39.6809758Z error: 1 errors occurred comparing output.
2019-09-24T15:12:39.6809988Z status: exit code: 1
2019-09-24T15:12:39.6809988Z status: exit code: 1
2019-09-24T15:12:39.6810838Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/impl-trait/negative-reasoning.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/impl-trait/negative-reasoning" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/impl-trait/negative-reasoning/auxiliary" "-A" "unused"
2019-09-24T15:12:39.6811873Z ------------------------------------------
2019-09-24T15:12:39.6812116Z 
2019-09-24T15:12:39.6812571Z ------------------------------------------
2019-09-24T15:12:39.6812822Z stderr:
2019-09-24T15:12:39.6812822Z stderr:
2019-09-24T15:12:39.6813247Z ------------------------------------------
2019-09-24T15:12:39.6814000Z error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>`:
2019-09-24T15:12:39.6814584Z   --> /checkout/src/test/ui/impl-trait/negative-reasoning.rs:18:1
2019-09-24T15:12:39.6814918Z    |
2019-09-24T15:12:39.6815186Z LL | impl<T: std::fmt::Debug> AnotherTrait for T { }
2019-09-24T15:12:39.6815711Z    | ------------------------------------------- first implementation here
2019-09-24T15:12:39.6816032Z ...
2019-09-24T15:12:39.6816273Z LL | impl AnotherTrait for D<OpaqueType> {
2019-09-24T15:12:39.6816536Z    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<OpaqueType>`
2019-09-24T15:12:39.6816808Z    |
2019-09-24T15:12:39.6817186Z    = note: upstream crates may add a new impl of trait `std::fmt::Debug` for type `OpaqueType` in future versions
2019-09-24T15:12:39.6817580Z error: aborting due to previous error
2019-09-24T15:12:39.6817758Z 
2019-09-24T15:12:39.6818201Z For more information about this error, try `rustc --explain E0119`.
2019-09-24T15:12:39.6818458Z 
---
2019-09-24T15:12:39.6838199Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:537:22
2019-09-24T15:12:39.6838564Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-09-24T15:12:39.6854159Z 
2019-09-24T15:12:39.6857623Z 
2019-09-24T15:12:39.6859586Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
2019-09-24T15:12:39.6859862Z 
2019-09-24T15:12:39.6859929Z 
2019-09-24T15:12:39.6867743Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-09-24T15:12:39.6868247Z Build completed unsuccessfully in 1:02:02
2019-09-24T15:12:39.6868247Z Build completed unsuccessfully in 1:02:02
2019-09-24T15:12:39.6925862Z == clock drift check ==
2019-09-24T15:12:39.6944166Z   local time: Tue Sep 24 15:12:39 UTC 2019
2019-09-24T15:12:39.7806512Z   network time: Tue, 24 Sep 2019 15:12:39 GMT
2019-09-24T15:12:39.7811038Z == end clock drift check ==
2019-09-24T15:12:40.5225621Z ##[error]Bash exited with code '1'.
2019-09-24T15:12:40.5260154Z ##[section]Starting: Checkout
2019-09-24T15:12:40.5261841Z ==============================================================================
2019-09-24T15:12:40.5261884Z Task         : Get sources
2019-09-24T15:12:40.5261943Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@nikomatsakis
Copy link
Contributor

nikomatsakis commented Sep 24, 2019

@Aaron1011 looks like you need to "bless" -- though you may also need to rebase

Fixes rust-lang#63677

RFC rust-lang#2071 (impl-trait-existential-types) does not explicitly state how
impl trait type alises should interact with coherence. However, there's
only one choice which makes sense - coherence should look at the
underlying type (i.e. the 'defining' type of the impl trait) of the type
alias, just like we do for non-impl-trait type aliases.

Specifically, impl trait type alises which resolve to a local type
should be treated like a local type with respect to coherence (e.g.
impl trait type aliases which resolve to a forieign type should be
treated as a foreign type, and those that resolve to a local type should
be treated as a local type).

Since neither inherent impls nor direct trait impl (i.e. `impl MyType`
or `impl MyTrait for MyType`) are allowd for type aliases, this
usually does not come up. Before we ever attempt to do coherence
checking, we will have errored out if an impl trait type alias was used
directly in an 'impl' clause.

However, during trait selection, we sometimes need to prove bounds like
'T: Sized' for some type 'T'. If 'T' is an impl trait type alias, this
requires to know the coherence behavior for impl trait type aliases when
we perform coherence checking.

Note: Since determining the underlying type of an impl trait type alias
requires us to perform body type checking, this commit causes us to type
check some bodies easlier than we otherwise would have. However, since
this is done through a query, this shouldn't cause any problems

For completeness, I've added an additional test of the coherence-related
behavior of impl trait type aliases.
@Aaron1011
Copy link
Member Author

@nikomatsakis Fixed

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Sep 24, 2019

📌 Commit 61cfe92 has been approved by nikomatsakis

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 24, 2019
@bors
Copy link
Contributor

bors commented Sep 24, 2019

⌛ Testing commit 61cfe92 with merge a0323f8a4d1baa7815356cf42f26b2fceb4e3b20...

Centril added a commit to Centril/rust that referenced this pull request Sep 24, 2019
… r=nikomatsakis

Fix coherence checking for impl trait in type aliases

**UPDATE**: This PR now treats all opaque types as remote. The original description appears below, but is no longer accurate.

Fixes rust-lang#63677

[RFC 2071](rust-lang/rfcs#2071) (impl-trait-existential-types) does not explicitly state how `type_alias_impl_trait` should interact with coherence. However, there's only one choice which makes sense - coherence should look at the underlying type (i.e. the *"defining"* type of the `impl Trait`) of the type alias, just like we do for non-`impl Trait` type aliases.

Specifically, `impl Trait` type aliases that resolve to a local type should be treated like a local type with respect to coherence (e.g. `impl Trait` type aliases which resolve to a foreign type should be treated as a foreign type, and those that resolve to a local type should be treated as a local type).

Since neither inherent impls nor direct trait impl (i.e. `impl MyType` or `impl MyTrait for MyType`) are allowed for type aliases, this usually does not come up. Before we ever attempt to do coherence checking, we will have errored out if an `impl Trait` type alias was used directly in an `impl` clause.

However, during trait selection, we sometimes need to prove bounds like `T: Sized` for some type `T`. If `T` is an impl trait type alias, this requires to know the coherence behavior for `impl Trait` type aliases when we perform coherence checking.

Note: Since determining the underlying type of an `impl Trait` type alias requires us to perform body type checking, this commit causes us to type check some bodies easier than we otherwise would have. However, since this is done through a query, this shouldn't cause any problems

For completeness, I've added an additional test of the coherence-related behavior of `impl Trait` type aliases.

cc rust-lang#63063
@Centril
Copy link
Contributor

Centril commented Sep 24, 2019

@bors retry rolled up.

bors added a commit that referenced this pull request Sep 24, 2019
Rollup of 16 pull requests

Successful merges:

 - #63356 (Issue#63183: Add fs::read_dir() and ReadDir warning about iterator order + example)
 - #63934 (Fix coherence checking for impl trait in type aliases)
 - #64016 (Streamline `Compiler`)
 - #64296 (Document the unstable iter_order_by library feature)
 - #64443 (rustdoc: general cleanup)
 - #64622 (Add a cycle detector for generic `Graph`s and `mir::Body`s)
 - #64689 (Refactor macro by example)
 - #64698 (Recover on `const X = 42;` and infer type + Error Stash API)
 - #64702 (Remove unused dependencies)
 - #64717 (update mem::discriminant test to use assert_eq and assert_ne over comparison operators)
 - #64720 ( remove rtp.rs, and move rtpSpawn and RTP_ID_ERROR to libc)
 - #64721 (Fixed issue from #64447)
 - #64725 (fix one typo)
 - #64737 (fix several issues in String docs)
 - #64742 (relnotes: make compatibility section more sterile and fix rustc version)
 - #64748 (Fix #64744. Account for the Zero sub-pattern case.)

Failed merges:

r? @ghost
@bors
Copy link
Contributor

bors commented Sep 25, 2019

⌛ Testing commit 61cfe92 with merge dcd473d...

@bors bors merged commit 61cfe92 into rust-lang:master Sep 25, 2019
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Nov 11, 2019
Pkgsrc changes:
 * Remove patch which no longer applies (but what about RPATH?)
 * Adapt a few patches to changed files upstream.

Upstream changes:

Version 1.39.0 (2019-11-07)
===========================

Language
--------
- [You can now create `async` functions and blocks with `async fn`,
  `async move {}`, and `async {}` respectively, and you can now call
  `.await` on async expressions.][63209]
- [You can now use certain attributes on function, closure, and function
  pointer parameters.][64010] These attributes include `cfg`, `cfg_attr`,
  `allow`, `warn`, `deny`, `forbid` as well as inert helper attributes used
  by procedural macro attributes applied to items. e.g.
  ```rust
  fn len(
      #[cfg(windows)] slice: &[u16],
      #[cfg(not(windows))] slice: &[u8],
  ) -> usize {
      slice.len()
  }
  ```
- [You can now take shared references to bind-by-move patterns in the
  `if` guards of `match` arms.][63118] e.g.
  ```rust
  fn main() {
      let array: Box<[u8; 4]> = Box::new([1, 2, 3, 4]);

      match array {
          nums
  //      ---- `nums` is bound by move.
              if nums.iter().sum::<u8>() == 10
  //                 ^------ `.iter()` implicitly takes a reference to `nums`.
          => {
              drop(nums);
  //          ----------- Legal as `nums` was bound by move and so we have ownership.
          }
          _ => unreachable!(),
      }
  }
  ```

Compiler
--------
- [Added tier 3\* support for the `i686-unknown-uefi` target.][64334]
- [Added tier 3 support for the `sparc64-unknown-openbsd` target.][63595]
- [rustc will now trim code snippets in diagnostics to fit in your terminal.]
  [63402] **Note** Cargo currently doesn't use this feature. Refer to
  [cargo#7315][cargo/7315] to track this feature's progress.
- [You can now pass `--show-output` argument to test binaries to print the
  output of successful tests.][62600]

\* Refer to Rust's [platform support page][forge-platform-support] for more
information on Rust's tiered platform support.

Libraries
---------
- [`Vec::new` and `String::new` are now `const` functions.][64028]
- [`LinkedList::new` is now a `const` function.][63684]
- [`str::len`, `[T]::len` and `str::as_bytes` are now `const` functions.][63770]
- [The `abs`, `wrapping_abs`, and `overflowing_abs` numeric functions are
  now `const`.][63786]

Stabilized APIs
---------------
- [`Pin::into_inner`]
- [`Instant::checked_duration_since`]
- [`Instant::saturating_duration_since`]

Cargo
-----
- [You can now publish git dependencies if supplied with a `version`.]
  [cargo/7237]
- [The `--all` flag has been renamed to `--workspace`.][cargo/7241] Using
  `--all` is now deprecated.

Misc
----
- [You can now pass `-Clinker` to rustdoc to control the linker used
  for compiling doctests.][63834]

Compatibility Notes
-------------------
- [Code that was previously accepted by the old borrow checker, but rejected by
  the NLL borrow checker is now a hard error in Rust 2018.][63565] This was
  previously a warning, and will also become a hard error in the Rust 2015
  edition in the 1.40.0 release.
- [`rustdoc` now requires `rustc` to be installed and in the same directory to
  run tests.][63827] This should improve performance when running a large
  amount of doctests.
- [The `try!` macro will now issue a deprecation warning.][62672] It is
  recommended to use the `?` operator instead.
- [`asinh(-0.0)` now correctly returns `-0.0`.][63698] Previously this
  returned `0.0`.

[62600]: rust-lang/rust#62600
[62672]: rust-lang/rust#62672
[63118]: rust-lang/rust#63118
[63209]: rust-lang/rust#63209
[63402]: rust-lang/rust#63402
[63565]: rust-lang/rust#63565
[63595]: rust-lang/rust#63595
[63684]: rust-lang/rust#63684
[63698]: rust-lang/rust#63698
[63770]: rust-lang/rust#63770
[63786]: rust-lang/rust#63786
[63827]: rust-lang/rust#63827
[63834]: rust-lang/rust#63834
[63927]: rust-lang/rust#63927
[63933]: rust-lang/rust#63933
[63934]: rust-lang/rust#63934
[63938]: rust-lang/rust#63938
[63940]: rust-lang/rust#63940
[63941]: rust-lang/rust#63941
[63945]: rust-lang/rust#63945
[64010]: rust-lang/rust#64010
[64028]: rust-lang/rust#64028
[64334]: rust-lang/rust#64334
[cargo/7237]: rust-lang/cargo#7237
[cargo/7241]: rust-lang/cargo#7241
[cargo/7315]: rust-lang/cargo#7315
[`Pin::into_inner`]: https://doc.rust-lang.org/std/pin/struct.Pin.html#method.into_inner
[`Instant::checked_duration_since`]: https://doc.rust-lang.org/std/time/struct.Instant.html#method.checked_duration_since
[`Instant::saturating_duration_since`]: https://doc.rust-lang.org/std/time/struct.Instant.html#method.saturating_duration_since
Aaron1011 added a commit to Aaron1011/rust that referenced this pull request Nov 28, 2019
While working on PR rust-lang#63934, I accidentally reverted to an older version
of the PR while working on a rebase. The PR was then merged, not with
the later, approved changes, but with earlier, unapproved changes.

This PR applies the changes that were *suppoesd* to be mereged in
PR rust-lang#63934. All of the proper tests appear to have been merged
in PR rust-lang#63934, so this PR adds no new tests

Fixes rust-lang#66580
bors added a commit that referenced this pull request Nov 29, 2019
Apply proper commit from PR #63934

While working on PR #63934, I accidentally reverted to an older version
of the PR while working on a rebase. The PR was then merged, not with
the later, approved changes, but with earlier, unapproved changes.

This PR applies the changes that were *suppoesd* to be mereged in
PR #63934. All of the proper tests appear to have been merged
in PR #63934, so this PR adds no new tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Development

Successfully merging this pull request may close these issues.

rustc crash with type alias of impl trait
7 participants