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

async/await #51580

Merged
merged 19 commits into from Jun 23, 2018
Merged

async/await #51580

merged 19 commits into from Jun 23, 2018

Conversation

cramertj
Copy link
Member

This PR implements async/await syntax for async fn in Rust 2015 and async closures and async blocks in Rust 2018 (tracking issue: #50547). Limitations: non-move async closures with arguments are currently not supported, nor are async fn with multiple different input lifetimes. These limitations are not fundamental and will be removed in the future, however I'd like to go ahead and get this PR merged so we can start experimenting with this in combination with futures 0.3.

Based on #51414.
cc @petrochenkov for parsing changes.
r? @eddyb

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 15, 2018
@withoutboats
Copy link
Contributor

Why are async_await and await_macro separate features?

My inclination would be to try to make the feature gating as pleasant as possible for users; I'd prefer merging both compiler features into async_await and renaming futures_api to just futures, so an end user hopefully just has to add:

#![feature(async_await, futures)]

(assuming they're using a library that handles pinning for them as a part of its execution API).

@petrochenkov petrochenkov self-assigned this Jun 17, 2018
| |
| first lifetime here
|
= help: `async fn` can only accept borrowed values identical lifetimes
Copy link
Contributor

Choose a reason for hiding this comment

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

async fn can only accept borrowed values with identical lifetimes (<-- added "with")

@@ -6755,6 +6807,28 @@ impl<'a> Parser<'a> {
maybe_append(attrs, extra_attrs));
return Ok(Some(item));
}
if self.check_keyword(keywords::Async) &&
(self.look_ahead(1, |t| t.is_keyword(keywords::Fn)) ||
self.look_ahead(1, |t| t.is_keyword(keywords::Unsafe)))
Copy link
Contributor

Choose a reason for hiding this comment

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

The order a lot of people seemed to agree on in the RFC discussion was different. rust-lang/rfcs#2394 (comment)

"const unsafe async move": unsafe was in front of async back then (of course move doesn't apply here) To me unsafe in front of async seems more "natural" because unsafety should be featured more prominently.

@Nemo157
Copy link
Member

Nemo157 commented Jun 18, 2018

I notice this is still using TLS for passing the context in to the generated futures. Has resurrecting generator arguments for this been considered? (big reason I want this is to easily support no_std)

@withoutboats
Copy link
Contributor

@Nemo157 as far as I know, we definitely want to stop using TLS in the long run (before we stabilize anything), and the current use in this PR is a hack to get the next iteration of async/await up and running.

@cramertj
Copy link
Member Author

@Nemo157 @withoutboats is absolutely correct-- we definitely want to support no-TLS and no-std async/await, but doing that requires more invasive changes to generators. I'd like to first land this version so that we can begin experimenting with 0.3 ASAP.

@cramertj
Copy link
Member Author

One thing that occurred to me: async move isn't a legal pair of sequential identifiers in edition 2015. We could use this to support async move blocks and closures in 2015, but not their non-move counterparts. This seems potentially useful for experimenting with async/await in 2015 edition code. WDYT? Is this too weird of an edge case?

@withoutboats
Copy link
Contributor

@cramertj why would we want to experiment on the 2015 edition over the 2018 edition (since both are available on nightly)?

In the final stable version I think I'd like to make things consistent by not support any async and await features on 2015 (so that the story is very simple, instead of having to remember which half of the features are available on 2015). But if its expedient to support some things on 2015 in this iteration, that seems fine.

@cramertj
Copy link
Member Author

@withoutboats

why would we want to experiment on the 2015 edition over the 2018 edition (since both are available on nightly)?

Because it would allow for specifically testing out async/await without having to change the rest of the project over to the 2018 edition.

@cramertj
Copy link
Member Author

cramertj commented Jun 18, 2018

@withoutboats

Why are async_await and await_macro separate features?

Currently standard library features must be gated separately from language features. This is also why generator_trait and generators are separate. Attempting to join them causes the library feature to be shadowed by the language feature.

@withoutboats
Copy link
Contributor

@cramertj I didn't see it was literally implemented as a macro. We don't intend to stabilize it with the current syntax anyway, do you object to using the futures_api feature to avoid users having to enumerate so many features to use this?

@cramertj
Copy link
Member Author

cramertj commented Jun 19, 2018

@withoutboats

We don't intend to stabilize it with the current syntax anyway, do you object to using the futures_api feature to avoid users having to enumerate so many features to use this?

Hm... it seems sort of surprising to me that futures_api would be tied to async/await and I could see that potentially causing confusion or problems when it comes time to stabilize, but I agree that it's an unfortunately large number of features. I think my preference would be to leave as-is, but if you strongly disagree I'm happy to change it.

@rust-lang rust-lang deleted a comment from rust-highfive Jun 19, 2018
@rust-highfive

This comment has been minimized.

@@ -213,6 +213,26 @@ macro_rules! eprintln {
($fmt:expr, $($arg:tt)*) => (eprint!(concat!($fmt, "\n"), $($arg)*));
}

#[macro_export]
#[unstable(feature = "await_macro", issue = "50547")]
#[allow_internal_unstable]
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably use #[allow_internal_unsafe] as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@@ -95,6 +95,16 @@ impl<T: 'static> P<T> {
}
}

impl<T: 'static> P<[T]> {
pub fn map_slice<F>(self, f: F) -> P<[T]> where
F: FnOnce(Vec<T>) -> Vec<T>
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks similar to existing move_map/move_flat_map.

Copy link
Member Author

Choose a reason for hiding this comment

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

It is similar, but move_map and move_flat_map expect to receive one element at a time, whereas this takes the whole list at once, allowing it to do things like modifying the last element.

Copy link
Member

Choose a reason for hiding this comment

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

Should be able to remove this now.

@@ -2246,6 +2258,15 @@ impl<'a> Parser<'a> {
hi = path.span;
return Ok(self.mk_expr(lo.to(hi), ExprKind::Path(Some(qself), path), attrs));
}
if syntax_pos::hygiene::default_edition() >= Edition::Edition2018 &&
Copy link
Contributor

Choose a reason for hiding this comment

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

You probably want self.token.span.edition() >= Edition::Edition2018 here instead of default edition in case async comes from a macro defined with other edition.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you mean self.span.edition()? Token doesn't have a span field.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, sorry (self.span is the span of self.token).

@@ -3240,6 +3261,13 @@ impl<'a> Parser<'a> {
} else {
Movability::Movable
};
let asyncness = if syntax_pos::hygiene::default_edition() >= Edition::Edition2018
Copy link
Contributor

Choose a reason for hiding this comment

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

IsAsync::Async(ast::DUMMY_NODE_ID)
} else {
IsAsync::NotAsync
};
Copy link
Contributor

Choose a reason for hiding this comment

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

So it's fixed-order static async move |args...| body now.
The number of modifiers becomes closer to the point where nobody can remember the correct order :)

@@ -4274,6 +4320,18 @@ impl<'a> Parser<'a> {
})
}

fn is_async_block(&mut self) -> bool {
self.token.is_keyword(keywords::Async) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: This is kind of fragile due to assumption that edition check was already performed and the function is used only once, so it may be better to just inline it.

// `unsafe async fn` or `async fn`
if (
self.check_keyword(keywords::Unsafe) &&
self.look_ahead(1, |t| t.is_keyword(keywords::Async))
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like edition checks are missing here and below.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's intentional-- async fn is supposed to work on edition 2015. It's just closures and blocks that don't.

let is_const_fn = self.eat_keyword(keywords::Const);
let const_span = self.prev_span;
let unsafety = self.parse_unsafety();
let asyncness = self.parse_asyncness();
Copy link
Contributor

Choose a reason for hiding this comment

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

So the syntax is fixed-order default const unsafe async extern "C" fn foo() {} now.

Fascinating.

There are two groups of things here - stuff inherent to the fn type (unsafe, extern "ABI" and fn itself) and possibly context-dependent "modifiers" (default, const, async).
So far the logic was that modifiers were grouped together on the left, and type-things were grouped together with fn on the right - default const | unsafe extern "C" fn so the modifiers can't get "inside the fn type" type F = unsafe extern "C" fn();.

I think we should turn the syntax into (default const async in arbitrary order) | (unsafe extern "C" in arbitrary order) fn eventually, but for now let's keep it fixed-order while keeping the grouping rule - default const async | unsafe extern "C" fn.

@petrochenkov
Copy link
Contributor

Reviewed.
(I skipped the the main desugaring part though.)

@cramertj
Copy link
Member Author

Thanks @petrochenkov!

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-3.9 of your PR failed on Travis (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.
travis_time:start:test_parse-fail
Check compiletest suite=parse-fail mode=parse-fail (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[00:56:34] 
[00:56:34] running 271 tests
[00:56:36] ...........................i.....................................................FF.................
[00:56:37] ....................................................................i...............................
[00:56:38] ...............i...............F.................F....F.FF.............
[00:56:38] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:498:22
[00:56:38] 
[00:56:38] ---- [parse-fail] parse-fail/issue-20711-2.rs stdout ----
[00:56:38] 
[00:56:38] 
[00:56:38] error: /checkout/src/test/parse-fail/issue-20711-2.rs:19: unexpected error: '19:1: 19:2: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, or `unsafe`, found `}`'
[00:56:38] 
[00:56:38] error: /checkout/src/test/parse-fail/issue-20711-2.rs:19: expected error not found: expected one of `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, or `unsafe`
[00:56:38] 
[00:56:38] error: 1 unexpected errors found, 1 expected errors not found
[00:56:38] status: exit code: 101
[00:56:38] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/parse-fail/issue-20711-2.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/parse-fail/issue-20711-2/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Z" "parse-only" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/parse-fail/issue-20711-2/auxiliary"
[00:56:38] unexpected errors (from JSON output): [
[00:56:38]     Error {
[00:56:38]         line_num: 19,
[00:56:38]         kind: Some(
[00:56:38]         ),
[00:56:38]         ),
[00:56:38]         msg: "19:1: 19:2: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, or `unsafe`, found `}`"
[00:56:38] ]
[00:56:38] 
[00:56:38] not found errors (from test file): [
[00:56:38]     Error {
[00:56:38]     Error {
[00:56:38]         line_num: 19,
[00:56:38]         kind: Some(
[00:56:38]             Error
[00:56:38]         ),
[00:56:38]         msg: "expected one of `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, or `unsafe`"
[00:56:38] ]
[00:56:38] 
[00:56:38] thread '[parse-fail] parse-fail/issue-20711-2.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:1284:13
[00:56:38] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[00:56:38] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[00:56:38] 
[00:56:38] ---- [parse-fail] parse-fail/issue-20711.rs stdout ----
[00:56:38] 
[00:56:38] error: /checkout/src/test/parse-fail/issue-20711.rs:17: unexpected error: '17:1: 17:2: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, or `unsafe`, found `}`'
[00:56:38] 
[00:56:38] error: /checkout/src/test/parse-fail/issue-20711.rs:17: expected error not found: expected one of `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, or `unsafe`
[00:56:38] 
[00:56:38] error: 1 unexpected errors found, 1 expected errors not found
[00:56:38] status: exit code: 101
[00:56:38] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/parse-fail/issue-20711.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/parse-fail/issue-20711/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Z" "parse-only" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/parse-fail/issue-20711/auxiliary"
[00:56:38] unexpected errors (from JSON output): [
[00:56:38]     Error {
[00:56:38]         line_num: 17,
[00:56:38]         kind: Some(
[00:56:38]         ),
[00:56:38]         ),
[00:56:38]         msg: "17:1: 17:2: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, or `unsafe`, found `}`"
[00:56:38] ]
[00:56:38] 
[00:56:38] not found errors (from test file): [
[00:56:38]     Error {
[00:56:38]     Error {
[00:56:38]         line_num: 17,
[00:56:38]         kind: Some(
[00:56:38]             Error
[00:56:38]         ),
[00:56:38]         msg: "expected one of `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, or `unsafe`"
[00:56:38] ]
[00:56:38] 
[00:56:38] thread '[parse-fail] parse-fail/issue-20711.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:1284:13
[00:56:38] 
[00:56:38] 
[00:56:38] ---- [parse-fail] parse-fail/removed-syntax-static-fn.rs stdout ----
[00:56:38] 
[00:56:38] error: /checkout/src/test/parse-fail/removed-syntax-static-fn.rs:16: unexpected error: '16:5: 16:11: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `static`'
[00:56:38] 
[00:56:38] error: /checkout/src/test/parse-fail/removed-syntax-static-fn.rs:16: expected error not found: expected one of `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, `unsafe`
[00:56:38] 
[00:56:38] error: 1 unexpected errors found, 1 expected errors not found
[00:56:38] status: exit code: 101
[00:56:38] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/parse-fail/removed-syntax-static-fn.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/parse-fail/removed-syntax-static-fn/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Z" "parse-only" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/parse-fail/removed-syntax-static-fn/auxiliary"
[00:56:38] unexpected errors (from JSON output): [
[00:56:38]     Error {
[00:56:38]         line_num: 16,
[00:56:38]         kind: Some(
[00:56:38]         ),
[00:56:38]         ),
[00:56:38]         msg: "16:5: 16:11: expected one of `async`, `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `static`"
[00:56:38] ]
[00:56:38] 
[00:56:38] not found errors (from test file): [
[00:56:38]     Error {
[00:56:38]     Error {
[00:56:38]         line_num: 16,
[00:56:38]         kind: Some(
[00:56:38]             Error
[00:56:38]         ),
[00:56:38]         msg: "expected one of `const`, `crate`, `default`, `extern`, `fn`, `pub`, `type`, `unsafe`"
[00:56:38] ]
[00:56:38] 
[00:56:38] thread '[parse-fail] parse-fail/removed-syntax-static-fn.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:1284:13
[00:56:38] 
[00:56:38] 
[00:56:38] ---- [parse-fail] parse-fail/trait-non-item-macros.rs stdout ----
[00:56:38] 
[00:56:38] error: /checkout/src/test/parse-fail/trait-non-item-macros.rs:12: unexpected error: '12:19: 12:21: expected one of `async`, `const`, `extern`, `fn`, `type`, or `unsafe`, found `2`'
[00:56:38] 
[00:56:38] error: /checkout/src/test/parse-fail/trait-non-item-macros.rs:12: expected error not found: expected one of `const`, `extern`, `fn`, `type`, or `unsafe`, found `2`
[00:56:38] 
[00:56:38] error: 1 unexpected errors found, 1 expected errors not found
[00:56:38] status: exit code: 101
[00:56:38] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/parse-fail/trait-non-item-macros.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/parse-fail/trait-non-item-macros/a" "-Crpath" "-O" "-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/parse-fail/trait-non-item-macros/auxiliary"
[00:56:38] unexpected errors (from JSON output): [
[00:56:38]     Error {
[00:56:38]         line_num: 12,
[00:56:38]         kind: Some(
[00:56:38]         ),
[00:56:38]         ),
[00:56:38]         msg: "12:19: 12:21: expected one of `async`, `const`, `extern`, `fn`, `type`, or `unsafe`, found `2`"
[00:56:38] ]
[00:56:38] 
[00:56:38] not found errors (from test file): [
[00:56:38]     Error {
[00:56:38]     Error {
[00:56:38]         line_num: 12,
[00:56:38]         kind: Some(
[00:56:38]             Error
[00:56:38]         ),
[00:56:38]         msg: "expected one of `const`, `extern`, `fn`, `type`, or `unsafe`, found `2`"
[00:56:38] ]
[00:56:38] 
[00:56:38] thread '[parse-fail] parse-fail/trait-non-item-macros.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:1284:13
[00:56:38] 
[00:56:38] 
[00:56:38] ---- [parse-fail] parse-fail/trait-pub-assoc-const.rs stdout ----
[00:56:38] 
[00:56:38] error: /checkout/src/test/parse-fail/trait-pub-assoc-const.rs:12: unexpected error: '12:5: 12:8: expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found `pub`'
[00:56:38] 
[00:56:38] error: /checkout/src/test/parse-fail/trait-pub-assoc-const.rs:12: expected error not found: expected one of `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found `pub`
[00:56:38] 
[00:56:38] error: 1 unexpected errors found, 1 expected errors not found
[00:56:38] status: exit code: 101
[00:56:38] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/parse-fail/trait-pub-assoc-const.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/parse-fail/trait-pub-assoc-const/a" "-Crpath" "-O" "-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/parse-fail/trait-pub-assoc-const/auxiliary"
[00:56:38] unexpected errors (from JSON output): [
[00:56:38]     Error {
[00:56:38]         line_num: 12,
[00:56:38]         kind: Some(
[00:56:38]         ),
[00:56:38]         ),
[00:56:38]         msg: "12:5: 12:8: expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found `pub`"
[00:56:38] ]
[00:56:38] 
[00:56:38] not found errors (from test file): [
[00:56:38]     Error {
[00:56:38]     Error {
[00:56:38]         line_num: 12,
[00:56:38]         kind: Some(
[00:56:38]             Error
[00:56:38]         ),
[00:56:38]         msg: "expected one of `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found `pub`"
[00:56:38] ]
[00:56:38] 
[00:56:38] thread '[parse-fail] parse-fail/trait-pub-assoc-const.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:1284:13
[00:56:38] 
[00:56:38] 
[00:56:38] ---- [parse-fail] parse-fail/trait-pub-assoc-ty.rs stdout ----
[00:56:38] 
[00:56:38] error: /checkout/src/test/parse-fail/trait-pub-assoc-ty.rs:12: unexpected error: '12:5: 12:8: expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found `pub`'
[00:56:38] 
[00:56:38] error: /checkout/src/test/parse-fail/trait-pub-assoc-ty.rs:12: expected error not found: expected one of `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found `pub`
[00:56:38] 
[00:56:38] error: 1 unexpected errors found, 1 expected errors not found
[00:56:38] status: exit code: 101
[00:56:38] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/parse-fail/trait-pub-assoc-ty.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/parse-fail/trait-pub-assoc-ty/a" "-Crpath" "-O" "-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/parse-fail/trait-pub-assoc-ty/auxiliary"
[00:56:38] unexpected errors (from JSON output): [
[00:56:38]     Error {
[00:56:38]         line_num: 12,
[00:56:38]         kind: Some(
[00:56:38]         ),
[00:56:38]         ),
[00:56:38]         msg: "12:5: 12:8: expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found `pub`"
[00:56:38] ]
[00:56:38] 
[00:56:38] not found errors (from test file): [
[00:56:38]     Error {
[00:56:38]     Error {
[00:56:38]         line_num: 12,
[00:56:38]         kind: Some(
[00:56:38]             Error
[00:56:38]         ),
[00:56:38]         msg: "expected one of `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found `pub`"
[00:56:38] ]
[00:56:38] 
[00:56:38] thread '[parse-fail] parse-fail/trait-pub-assoc-ty.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:1284:13
[00:56:38] 
[00:56:38] 
[00:56:38] ---- [parse-fail] parse-fail/trait-pub-method.rs stdout ----
[00:56:38] 
[00:56:38] error: /checkout/src/test/parse-fail/trait-pub-method.rs:12: unexpected error: '12:5: 12:8: expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found `pub`'
[00:56:38] 
[00:56:38] error: /checkout/src/test/parse-fail/trait-pub-method.rs:12: expected error not found: expected one of `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found `pub`
[00:56:38] 
[00:56:38] error: 1 unexpected errors found, 1 expected errors not found
[00:56:38] status: exit code: 101
[00:56:38] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/parse-fail/trait-pub-method.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/parse-fail/trait-pub-method/a" "-Crpath" "-O" "-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/parse-fail/trait-pub-method/auxiliary"
[00:56:38] unexpected errors (from JSON output): [
[00:56:38]     Error {
[00:56:38]         line_num: 12,
[00:56:38]         kind: Some(
[00:56:38]         ),
[00:56:38]         ),
[00:56:38]         msg: "12:5: 12:8: expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found `pub`"
[00:56:38] ]
[00:56:38] 
[00:56:38] not found errors (from test file): [
[00:56:38]     Error {
[00:56:38]     Error {
[00:56:38]         line_num: 12,
[00:56:38]         kind: Some(
[00:56:38]             Error
[00:56:38]         ),
[00:56:38]         msg: "expected one of `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found `pub`"
[00:56:38] ]
[00:56:38] 
[00:56:38] thread '[parse-fail] parse-fail/trait-pub-method.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:1284:13
[00:56:38] 
---
[00:56:38] test result: FAILED. 261 passed; 7 failed; 3 ignored; 0 measured; 0 filtered out
[00:56:38] 
[00:56:38] 
[00:56:38] 
[00:56:38] 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/parse-fail" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/parse-fail" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "parse-fail" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-3.9/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options " "--target-rustcflags" "-Crpath -O -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" "3.9.1\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[00:56:38] 
[00:56:38] 
[00:56:38] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[00:56:38] Build completed unsuccessfully in 0:14:27
[00:56:38] Build completed unsuccessfully in 0:14:27
[00:56:38] make: *** [check] Error 1
[00:56:38] Makefile:58: recipe for target 'check' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:330a7612
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

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)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-3.9 of your PR failed on Travis (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.
    100% |████████████████████████████████| 61kB 6.3MB/s 
Collecting botocore==1.10.41 (from awscli)
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading https://files.pythonhosted.org/packages/38/37/80162be9e5a50c293ab1646d35d0a4886752df96dbc5a14843733bcaecd0/botocore-1.10.41-py2.py3-none-any.whl (4.3MB)
    0% |                                | 10kB 33.0MB/s eta 0:00:01
    0% |▏                               | 20kB 16.4MB/s eta 0:00:01
    0% |▎                               | 30kB 19.8MB/s eta 0:00:01
    0% |▎                               | 40kB 9.5MB/s eta 0:00:01
---

[00:05:13] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:05:13] tidy error: /checkout/src/test/parse-fail/issue-20711-2.rs:19: line longer than 100 chars
[00:05:13] tidy error: /checkout/src/test/parse-fail/issue-20711.rs:17: line longer than 100 chars
[00:05:13] tidy error: /checkout/src/test/parse-fail/trait-pub-assoc-ty.rs:13: line longer than 100 chars
[00:05:13] tidy error: /checkout/src/test/parse-fail/trait-pub-assoc-const.rs:13: line longer than 100 chars
[00:05:13] tidy error: /checkout/src/test/parse-fail/trait-pub-method.rs:13: line longer than 100 chars
[00:05:13] tidy error: /checkout/src/test/parse-fail/removed-syntax-static-fn.rs:18: line longer than 100 chars
[00:05:15] some tidy checks failed
[00:05:15] 
[00:05:15] 
[00:05:15] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:05:15] 
[00:05:15] 
[00:05:15] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:05:15] Build completed unsuccessfully in 0:01:55
[00:05:15] Build completed unsuccessfully in 0:01:55
[00:05:15] make: *** [tidy] Error 1
[00:05:15] Makefile:79: recipe for target 'tidy' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0ae32a9c
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:33a0db14:start=1529446569192764490,finish=1529446569199525400,duration=6760910
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0070dc41
$ head -30 ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
head: cannot open ‘./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers’ for reading: No such file or directory
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:0650a45f
$ dmesg | grep -i kill

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)

@GuillaumeGomez
Copy link
Member

Is there a reason that the error codes number order got broken once again?

@cramertj
Copy link
Member Author

@petrochenkov sorry, I misunderstood what you were requesting when I bought read that comment the first time. When I opened the PR it was "async unsafe" but then @MajorBreakfast pointed out that the opposite decision was made on the rfc: #51580 (comment)

I don't have a strong preference here-- I'm happy to change it around again if you think it makes more sense.

@cramertj
Copy link
Member Author

@GuillaumeGomez I'm not sure what you're asking-- is there a specific policy over the order in which error codes are added now?

@GuillaumeGomez
Copy link
Member

GuillaumeGomez commented Jun 23, 2018

There always has been one: you take the current biggest and you add one. Otherwise it's nearly impossible to keep track of what's going on. Anyway, I'll open a PR to fix it...

@cramertj
Copy link
Member Author

@guillaumegomes I've never done that because it means you have to constantly edit your PR when someone else merges something using the same error codes.

@GuillaumeGomez
Copy link
Member

It doesn't happen very often, and in addition to that, it's a very small change. Going from 700 to 900+ is kind of a big step.

@petrochenkov
Copy link
Contributor

I've never done that because it means you have to constantly edit your PR when someone else merges something using the same error codes.

+1, that's the reason I don't add errors with codes at all and leave that for separate error-code-assigning PRs

@GuillaumeGomez
Copy link
Member

GuillaumeGomez commented Jun 23, 2018

@petrochenkov: That's pretty bad but whatever. If no one cares I'll just stop doing it at some point...

@eddyb
Copy link
Member

eddyb commented Jun 24, 2018

@GuillaumeGomez Error codes are a complete disaster IMO and I'd argue we should just remove them and figure out another indexing mechanism. Every single time someone mentions an error by code, I have to ask them to replace the code with something readable.

@blaenk
Copy link
Contributor

blaenk commented Jun 24, 2018

Sorry for being off-topic (on the digression into error codes), and I admit that I have no idea about any of this, but has anyone suggested or brought up using some kind of short, descriptive error identifiers (I'll call them "shortcodes") instead of opaque numeric error codes? Something like eslint rules.

Yes, an error code isn't meant to be a self-contained exhaustive explanation of an error, but I find "shortcodes" to be qualitatively better than basic numeric codes. Whenever I see them emitted by eslint, they're much more helpful to me than numeric error codes (emitted by TypeScript for example), they're usually enough for me to remember what the error/mistake pertains to so that I can quickly fix it without having to spend time (even if mere seconds) deciphering the compiler/linter output, but in the unlikely event that that's not the case, then of course I could still look it up since the shortcode is uniquely identifying (for example no-dupe-args).

For example, the error codes from this PR:

E0906, // closures cannot be static
E0725, // multiple different lifetimes used in arguments of `async fn`
E0726, // multiple elided lifetimes used in arguments of `async fn`
E0727, // `async` non-`move` closures with arguments are not currently supported

Might become (first draft, see below):

static-closures,             // closures cannot be static 
async-multi-args,            // multiple different lifetimes used in arguments of `async fn`
async-multi-lifetime-elides, // multiple elided lifetimes used in arguments of `async fn`
async-move-arg-closures,     // `async` non-`move` closures with arguments are not currently supported

Some others might be straightforward:

- E0300,            // unexpanded macro
+ unexpanded-macro, // unexpanded macro

Others maybe trickier:

- E0315,                       // cannot invoke closure outside of its lifetime
+ outlived-closure-invocation, // cannot invoke closure outside of its lifetime

Obviously as a first draft that may not look great. I admit that I don't have a deep enough understanding of the errors in order to name them both precisely and concisely, and I'm sure people can pile on with bikeshedding those particular codes, but the idea is that some convention/standard would evolve around how to abbreviate/shorten certain words, what prefixes/suffixes to use, what words to use to connote/convey different types of errors/mistakes, and so on, such that each code would be somewhat uniform/consistent

There would preferably be no hard limit on the length as that may eventually lead to overly terse error codes due to unforeseen future Rust terminology or overly niche/specific error situations, defeating the point of them in the first place, but obviously there would be a very strong preference toward short and concise while balancing for descriptive, and definitely unique.

Yes, it's unlikely that any one scheme would be perfect, but "shortcodes" may serve more useful and readable than clearly opaque (to end users) numeric error codes, and would at least as one consequence remedy this PR contribution/conflict situation.

I'm not sure how error codes relate to backwards compatibility, or whether this can ever be done going forward, even at the edition level. Maybe the ship has long since sailed on this and it's not feasible to introduce something like this at this point.

@GuillaumeGomez
Copy link
Member

@eddyb: I agree on your points but as long as a new (better?) system is put in place, let's just keep to stop destroying the current one, as bad as it might seems. It'll make the migration simpler.

@SimonSapin
Copy link
Contributor

This appears to have uncovered a miscompilation bug on old macOS: servo/servo#21089 (comment). I haven’t managed to run lldb so far, but both affected build scripts use Command::new("rustc").

bors added a commit that referenced this pull request Jun 24, 2018
@SimonSapin
Copy link
Contributor

I suspect this PR broke println! on macOS 10.10: #51758

@eddyb
Copy link
Member

eddyb commented Jun 24, 2018

Something like eslint rules.

FWIW, the direct equivalent is our lint names. I'm not sure we need identifiers at all, although ones that could be name types would be better, since we could use them for structural errors.

flip1995 added a commit to flip1995/rust-clippy that referenced this pull request Jun 25, 2018
Addresses the errors produced by (re)moving, merging or renaming
structs, fields and methods by rust-lang/rust#48149 and rust-lang/rust#51580
@chris-morgan
Copy link
Member

@blaenk That is indeed very off-topic for this. You should create a new issue if you want further discussion of it. One remark I will make: some tooling is designed around using numbers. Vim’s 'errorformat' looks for error numbers and treats them specially. Very mild damage would be done there if that were changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet