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

Parse the syntax described in RFC 2632 #67820

Merged
merged 13 commits into from
Jan 10, 2020
Merged

Conversation

ecstatic-morse
Copy link
Contributor

@ecstatic-morse ecstatic-morse commented Jan 3, 2020

This adds support for both impl const Trait for Ty and ?const Trait bound syntax from rust-lang/rfcs#2632 to the parser. For now, both modifiers end up in a newly-added constness field on ast::TraitRef, although this may change once the implementation is fleshed out.

I was planning on using delay_span_bug when this syntax is encountered during lowering, but I can't write should-ice UI tests. I emit a normal error instead, which causes duplicates when the feature gate is not enabled (see the .stderr files for the feature gate tests). Not sure what the desired approach is; Maybe just do nothing when the syntax is encountered with the feature gate is enabled?

@oli-obk I went with const_trait_impl and const_trait_bound_opt_out for the names of these features. Are these to your liking?

cc #67792 #67794

r? @Centril

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 3, 2020
@ecstatic-morse ecstatic-morse changed the title Parse the syntax described in RFC 2362 Parse the syntax described in RFC 2632 Jan 3, 2020
Copy link
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

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

Some nits, r=me with them addressed

src/librustc_parse/parser/ty.rs Show resolved Hide resolved

impl const T for S {}
//~^ ERROR const trait impls are experimental
//~| ERROR const trait impls are experimental
Copy link
Contributor

Choose a reason for hiding this comment

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

That's fine for now. It'll immediately go away when the feature gate has some logic, so...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I switched to "not yet implemented" for the non-feature gated errors anyways. It made it easier to track see when I had forgotten a feature gate in the tests.

trait T {}

// An inherent impl for a trait object of `?const T`.
impl ?const T {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if this should ever be accepted. Probably not without an epoch doing other const things. Please make this a hard error for now

Copy link
Contributor

Choose a reason for hiding this comment

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

But I don't think it should be a hard error under #[cfg(FALSE)]. Make sure to test syntax independently of semantics, and preferably in one file, as a // check-pass test.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd also like to see tests that includes impl Trait in various positions (syntactically vs. semantically -- different tests).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

?const is now forbidden in impl Trait and trait objects.

trait Trait {}
struct Foo<T: Trait>(T);

const fn new_foo<T: ?const Trait>(t: T) -> Foo<T> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the tests with and without the feature gate should have the same content so we are testing all the syntax in both situations

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I reorganized the tests a bit and am using the revisions trick for now to guarantee this.

Copy link
Contributor

@Centril Centril left a comment

Choose a reason for hiding this comment

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

Looks nice overall. Enjoying that this was easy to extend atop #67148. :)

Please make sure the feature gate labels on the PR + tracking issue are there before merging.

@@ -0,0 +1,7 @@
// compile-flags: -Z parse-only
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this flag necessary?

@@ -0,0 +1,9 @@
// parse-fail
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this. There's no such directive.

Copy link
Contributor

Choose a reason for hiding this comment

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

And also this doesn't seem to be true of the test. The errors below are not parser errors.

trait T {}

// An inherent impl for a trait object of `?const T`.
impl ?const T {}
Copy link
Contributor

Choose a reason for hiding this comment

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

But I don't think it should be a hard error under #[cfg(FALSE)]. Make sure to test syntax independently of semantics, and preferably in one file, as a // check-pass test.

trait T {}

// An inherent impl for a trait object of `?const T`.
impl ?const T {}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd also like to see tests that includes impl Trait in various positions (syntactically vs. semantically -- different tests).

src/test/ui/parser/bounds-type.rs Show resolved Hide resolved
src/librustc_parse/parser/ty.rs Show resolved Hide resolved
@ecstatic-morse
Copy link
Contributor Author

@Centril I added checks for impl Trait and trait objects. I also reorganized the tests so I could keep track of what was covered more easily. I think this should address most of your concerns. Lemme know if I missed something.

@ecstatic-morse ecstatic-morse force-pushed the const-trait branch 2 times, most recently from 59a60ed to e38e10f Compare January 4, 2020 00:52
src/librustc_parse/parser/item.rs Show resolved Hide resolved
struct S;
impl T for S {}

fn rpit() -> impl ?const T { S }
Copy link
Contributor

@Centril Centril Jan 4, 2020

Choose a reason for hiding this comment

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

Seems like we came away with different interpretations of what Oliver said.
I think this would be perfectly well defined and semantically sane (same with dyn ?const Trait).

After some more reflection, I think the semantic property one would want is that ?const is legal if and only if we are in a const-by-default context (const fn) or const Trait for { ... }`). However, if you want to get this landed quicker, I'm fine with this for now (but leave the comment visible).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

While these would be fine in the future, having them be a hard error for now and giving them their own feature gates in the future seems the best way forward to me. The RFC specifically talked about a minimal version that does not include impl Trait at all

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After porting these checks to AST validation, I also decided to error when they are found on trait bounds (e.g., trait T: ?const Super {}). While this is not explicitly called out as a future extension by the RFC, it will not be useful until const trait definitions have some meaning.

src/librustc_ast_lowering/lib.rs Outdated Show resolved Hide resolved
struct S;
impl T for S {}

fn rpit() -> impl ?const T { S }
Copy link
Contributor

Choose a reason for hiding this comment

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

While these would be fine in the future, having them be a hard error for now and giving them their own feature gates in the future seems the best way forward to me. The RFC specifically talked about a minimal version that does not include impl Trait at all

@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.
2020-01-05T00:41:02.7982348Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-01-05T00:41:02.8154576Z ##[command]git config gc.auto 0
2020-01-05T00:41:02.8220302Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-01-05T00:41:02.8261722Z ##[command]git config --get-all http.proxy
2020-01-05T00:41:02.8404993Z ##[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/67820/merge:refs/remotes/pull/67820/merge
---
2020-01-05T00:47:53.6071694Z For more information about this error, try `rustc --explain E0432`.
2020-01-05T00:47:53.6136256Z error: could not compile `rustc_parse`.
2020-01-05T00:47:53.6155825Z warning: build failed, waiting for other jobs to finish...
2020-01-05T00:48:35.5244190Z error: build failed
2020-01-05T00:48:35.5247568Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "check" "-Zconfig-profile" "--target" "x86_64-unknown-linux-gnu" "-Zbinary-dep-depinfo" "-j" "2" "--release" "--color" "always" "--features" " llvm" "--manifest-path" "/checkout/src/rustc/Cargo.toml" "--message-format" "json-render-diagnostics"
2020-01-05T00:48:35.5264815Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap check
2020-01-05T00:48:35.5265119Z Build completed unsuccessfully in 0:04:11
2020-01-05T00:48:35.5315126Z == clock drift check ==
2020-01-05T00:48:35.5349913Z   local time: Sun Jan  5 00:48:35 UTC 2020
2020-01-05T00:48:35.5349913Z   local time: Sun Jan  5 00:48:35 UTC 2020
2020-01-05T00:48:35.5665785Z   network time: Sun, 05 Jan 2020 00:48:35 GMT
2020-01-05T00:48:35.5670679Z == end clock drift check ==
2020-01-05T00:48:36.7823664Z 
2020-01-05T00:48:36.7919343Z ##[error]Bash exited with code '1'.
2020-01-05T00:48:36.7949414Z ##[section]Starting: Checkout
2020-01-05T00:48:36.7951062Z ==============================================================================
2020-01-05T00:48:36.7951123Z Task         : Get sources
2020-01-05T00:48:36.7951173Z 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)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-7 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.
2020-01-05T01:11:39.9717466Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-01-05T01:11:39.9946950Z ##[command]git config gc.auto 0
2020-01-05T01:11:40.0010464Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-01-05T01:11:40.0066739Z ##[command]git config --get-all http.proxy
2020-01-05T01:11:40.0227826Z ##[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/67820/merge:refs/remotes/pull/67820/merge
---
2020-01-05T02:08:03.3125833Z .................................................................................................... 1500/9488
2020-01-05T02:08:09.3965771Z .................................................................................................... 1600/9488
2020-01-05T02:08:14.5338683Z .................................................................................................... 1700/9488
2020-01-05T02:08:24.1964652Z .................................................................................................... 1800/9488
2020-01-05T02:08:32.6713553Z i................................................................................................... 1900/9488
2020-01-05T02:08:39.6250766Z ........................................................................................iiiii....... 2000/9488
2020-01-05T02:09:02.2044401Z .................................................................................................... 2200/9488
2020-01-05T02:09:04.6937308Z .................................................................................................... 2300/9488
2020-01-05T02:09:07.2158065Z .................................................................................................... 2400/9488
2020-01-05T02:09:13.3609296Z .................................................................................................... 2500/9488
---
2020-01-05T02:12:19.5691733Z ....................i...............i............................................................... 4900/9488
2020-01-05T02:12:29.8349445Z .................................................................................................... 5000/9488
2020-01-05T02:12:35.9229954Z .................................................................i.................................. 5100/9488
2020-01-05T02:12:44.3449387Z .................................................................................................... 5200/9488
2020-01-05T02:12:52.4343035Z ................................ii.ii...........i................................................... 5300/9488
2020-01-05T02:13:02.4343372Z .................................................................................................... 5500/9488
2020-01-05T02:13:12.7410862Z .................................................................................................... 5600/9488
2020-01-05T02:13:20.1809557Z ................i................................................................................... 5700/9488
2020-01-05T02:13:26.4976124Z ...........................................F........................................................ 5800/9488
2020-01-05T02:13:26.4976124Z ...........................................F........................................................ 5800/9488
2020-01-05T02:13:38.0395845Z .................................................................................................... 5900/9488
2020-01-05T02:13:49.9851275Z .....ii...i..ii...........i......................................................................... 6000/9488
2020-01-05T02:14:07.9245646Z .................................................................................................... 6200/9488
2020-01-05T02:14:15.9052841Z .................................................................................................... 6300/9488
2020-01-05T02:14:15.9052841Z .................................................................................................... 6300/9488
2020-01-05T02:14:32.7203560Z ................................i..ii............................................................... 6400/9488
2020-01-05T02:14:40.0778393Z ............................................FF...................................................... 6500/9488
2020-01-05T02:14:55.9496474Z .......i............................................................................................ 6700/9488
2020-01-05T02:14:58.3146633Z .................................................................................................... 6800/9488
2020-01-05T02:15:00.9615180Z .......i............................................................................................ 6900/9488
2020-01-05T02:15:04.6945267Z .................................................................................................... 7000/9488
---
2020-01-05T02:16:42.4562915Z .................................................................................................... 7500/9488
2020-01-05T02:16:46.7756701Z .................................................................................................... 7600/9488
2020-01-05T02:16:52.2464864Z .................................................................................................... 7700/9488
2020-01-05T02:17:02.0062863Z .................................................................................................... 7800/9488
2020-01-05T02:17:11.5274896Z ........................................................iiii........................................ 7900/9488
2020-01-05T02:17:22.0081963Z ..........................................................................................i......i.. 8000/9488
2020-01-05T02:17:32.4544638Z .................................................................................................... 8200/9488
2020-01-05T02:17:48.6085891Z .................................................................................................... 8300/9488
2020-01-05T02:17:57.0653118Z .................................................................................................... 8400/9488
2020-01-05T02:18:05.4830737Z .................................................................................................... 8500/9488
---
2020-01-05T02:19:58.7123723Z ---- [ui] ui/marker_trait_attr/marker-attribute-with-values.rs stdout ----
2020-01-05T02:19:58.7124032Z 
2020-01-05T02:19:58.7124258Z error: ui test compiled successfully!
2020-01-05T02:19:58.7124459Z status: exit code: 0
2020-01-05T02:19:58.7125542Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/marker_trait_attr/marker-attribute-with-values.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/marker_trait_attr/marker-attribute-with-values" "-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/marker_trait_attr/marker-attribute-with-values/auxiliary" "-A" "unused"
2020-01-05T02:19:58.7126520Z ------------------------------------------
2020-01-05T02:19:58.7126804Z 
2020-01-05T02:19:58.7127259Z ------------------------------------------
2020-01-05T02:19:58.7127513Z stderr:
---
2020-01-05T02:19:58.7133166Z -    | ^^^^^^^^^^^^^^^^^^^^^^^^^
2020-01-05T02:19:58.7133601Z -    |
2020-01-05T02:19:58.7134059Z - help: the following are the possible correct uses
2020-01-05T02:19:58.7134472Z -    |
2020-01-05T02:19:58.7134989Z - LL | #[rustc_on_unimplemented(/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...")]
2020-01-05T02:19:58.7135414Z -    |
2020-01-05T02:19:58.7135865Z - LL | #[rustc_on_unimplemented = "message"]
2020-01-05T02:19:58.7139238Z - 
2020-01-05T02:19:58.7139238Z - 
2020-01-05T02:19:58.7139757Z 14 error[E0230]: there is no parameter `C` on trait `BadAnnotation2`
2020-01-05T02:19:58.7140538Z 16    |
2020-01-05T02:19:58.7140733Z 
2020-01-05T02:19:58.7140975Z 77    |
2020-01-05T02:19:58.7140975Z 77    |
2020-01-05T02:19:58.7141193Z 78    = note: eg `#[rustc_on_unimplemented(message="foo")]`
2020-01-05T02:19:58.7142143Z - error: aborting due to 10 previous errors
2020-01-05T02:19:58.7142437Z + error: aborting due to 9 previous errors
2020-01-05T02:19:58.7143262Z 81 
2020-01-05T02:19:58.7143640Z 82 Some errors have detailed explanations: E0230, E0231, E0232.
2020-01-05T02:19:58.7143640Z 82 Some errors have detailed explanations: E0230, E0231, E0232.
2020-01-05T02:19:58.7144402Z 83 For more information about an error, try `rustc --explain E0230`.
2020-01-05T02:19:58.7144777Z 
2020-01-05T02:19:58.7145012Z 
2020-01-05T02:19:58.7145265Z The actual stderr differed from the expected stderr.
2020-01-05T02:19:58.7145911Z Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/on-unimplemented/bad-annotation/bad-annotation.stderr
2020-01-05T02:19:58.7146587Z To update references, rerun the tests and pass the `--bless` flag
2020-01-05T02:19:58.7147289Z To only update this specific test, also pass `--test-args on-unimplemented/bad-annotation.rs`
2020-01-05T02:19:58.7147925Z error: 1 errors occurred comparing output.
2020-01-05T02:19:58.7148238Z status: exit code: 1
2020-01-05T02:19:58.7148238Z status: exit code: 1
2020-01-05T02:19:58.7149778Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/on-unimplemented/bad-annotation.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/on-unimplemented/bad-annotation" "-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/on-unimplemented/bad-annotation/auxiliary" "-A" "unused"
2020-01-05T02:19:58.7157027Z ------------------------------------------
2020-01-05T02:19:58.7157073Z 
2020-01-05T02:19:58.7157361Z ------------------------------------------
2020-01-05T02:19:58.7157414Z stderr:
2020-01-05T02:19:58.7157414Z stderr:
2020-01-05T02:19:58.7157676Z ------------------------------------------
2020-01-05T02:19:58.7157837Z error[E0230]: there is no parameter `C` on trait `BadAnnotation2`
2020-01-05T02:19:58.7158201Z    |
2020-01-05T02:19:58.7158201Z    |
2020-01-05T02:19:58.7158277Z LL | #[rustc_on_unimplemented = "Unimplemented trait error on `{Self}` with params `<{A},{B},{C}>`"]
2020-01-05T02:19:58.7158383Z 
2020-01-05T02:19:58.7158451Z error[E0231]: only named substitution parameters are allowed
2020-01-05T02:19:58.7158758Z   --> /checkout/src/test/ui/on-unimplemented/bad-annotation.rs:27:1
2020-01-05T02:19:58.7158812Z    |
2020-01-05T02:19:58.7158812Z    |
2020-01-05T02:19:58.7158889Z LL | #[rustc_on_unimplemented = "Unimplemented trait error on `{Self}` with params `<{A},{B},{}>`"]
2020-01-05T02:19:58.7158998Z 
2020-01-05T02:19:58.7159048Z error[E0232]: this attribute must have a valid value
2020-01-05T02:19:58.7159357Z   --> /checkout/src/test/ui/on-unimplemented/bad-annotation.rs:32:26
2020-01-05T02:19:58.7159411Z    |
2020-01-05T02:19:58.7159411Z    |
2020-01-05T02:19:58.7159458Z LL | #[rustc_on_unimplemented(lorem="")]
2020-01-05T02:19:58.7159530Z    |                          ^^^^^^^^ expected value here
2020-01-05T02:19:58.7159877Z    |
2020-01-05T02:19:58.7160009Z    = note: eg `#[rustc_on_unimplemented(message="foo")]`
2020-01-05T02:19:58.7160112Z error[E0232]: this attribute must have a valid value
2020-01-05T02:19:58.7160683Z   --> /checkout/src/test/ui/on-unimplemented/bad-annotation.rs:36:26
2020-01-05T02:19:58.7160739Z    |
2020-01-05T02:19:58.7160739Z    |
2020-01-05T02:19:58.7160810Z LL | #[rustc_on_unimplemented(lorem(ipsum(dolor)))]
2020-01-05T02:19:58.7160866Z    |                          ^^^^^^^^^^^^^^^^^^^ expected value here
2020-01-05T02:19:58.7160914Z    |
2020-01-05T02:19:58.7161085Z    = note: eg `#[rustc_on_unimplemented(message="foo")]`
2020-01-05T02:19:58.7161179Z error[E0232]: this attribute must have a valid value
2020-01-05T02:19:58.7161503Z   --> /checkout/src/test/ui/on-unimplemented/bad-annotation.rs:40:39
2020-01-05T02:19:58.7161579Z    |
2020-01-05T02:19:58.7161579Z    |
2020-01-05T02:19:58.7161628Z LL | #[rustc_on_unimplemented(message="x", message="y")]
2020-01-05T02:19:58.7161685Z    |                                       ^^^^^^^^^^^ expected value here
2020-01-05T02:19:58.7161751Z    |
2020-01-05T02:19:58.7161799Z    = note: eg `#[rustc_on_unimplemented(message="foo")]`
2020-01-05T02:19:58.7161894Z error[E0232]: this attribute must have a valid value
2020-01-05T02:19:58.7162201Z   --> /checkout/src/test/ui/on-unimplemented/bad-annotation.rs:44:39
2020-01-05T02:19:58.7162254Z    |
2020-01-05T02:19:58.7162254Z    |
2020-01-05T02:19:58.7162305Z LL | #[rustc_on_unimplemented(message="x", on(desugared, message="y"))]
2020-01-05T02:19:58.7162392Z    |                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected value here
2020-01-05T02:19:58.7162444Z    |
2020-01-05T02:19:58.7162493Z    = note: eg `#[rustc_on_unimplemented(message="foo")]`
2020-01-05T02:19:58.7162544Z 
2020-01-05T02:19:58.7163304Z error[E0232]: empty `on`-clause in `#[rustc_on_unimplemented]`
2020-01-05T02:19:58.7164057Z    |
2020-01-05T02:19:58.7164057Z    |
2020-01-05T02:19:58.7164106Z LL | #[rustc_on_unimplemented(on(), message="y")]
2020-01-05T02:19:58.7164417Z    |                          ^^^^ empty on-clause here
2020-01-05T02:19:58.7164537Z error[E0232]: this attribute must have a valid value
2020-01-05T02:19:58.7164822Z   --> /checkout/src/test/ui/on-unimplemented/bad-annotation.rs:52:26
2020-01-05T02:19:58.7164874Z    |
2020-01-05T02:19:58.7164874Z    |
2020-01-05T02:19:58.7164942Z LL | #[rustc_on_unimplemented(on="x", message="y")]
2020-01-05T02:19:58.7164994Z    |                          ^^^^^^ expected value here
2020-01-05T02:19:58.7165051Z    |
2020-01-05T02:19:58.7165101Z    = note: eg `#[rustc_on_unimplemented(message="foo")]`
2020-01-05T02:19:58.7165199Z error[E0232]: this attribute must have a valid value
2020-01-05T02:19:58.7165483Z   --> /checkout/src/test/ui/on-unimplemented/bad-annotation.rs:59:40
2020-01-05T02:19:58.7165555Z    |
2020-01-05T02:19:58.7165555Z    |
2020-01-05T02:19:58.7165608Z LL | #[rustc_on_unimplemented(on(desugared, on(desugared, message="x")), message="y")]
2020-01-05T02:19:58.7165669Z    |                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected value here
2020-01-05T02:19:58.7165738Z    |
2020-01-05T02:19:58.7165796Z    = note: eg `#[rustc_on_unimplemented(message="foo")]`
2020-01-05T02:19:58.7165874Z error: aborting due to 9 previous errors
2020-01-05T02:19:58.7165924Z 
2020-01-05T02:19:58.7165974Z Some errors have detailed explanations: E0230, E0231, E0232.
2020-01-05T02:19:58.7167097Z For more information about an error, try `rustc --explain E0230`.
---
2020-01-05T02:19:58.7167775Z ---- [ui] ui/on-unimplemented/expected-comma-found-token.rs stdout ----
2020-01-05T02:19:58.7167831Z 
2020-01-05T02:19:58.7167880Z error: ui test compiled successfully!
2020-01-05T02:19:58.7167929Z status: exit code: 0
2020-01-05T02:19:58.7169105Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/on-unimplemented/expected-comma-found-token.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/on-unimplemented/expected-comma-found-token" "-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/on-unimplemented/expected-comma-found-token/auxiliary" "-A" "unused"
2020-01-05T02:19:58.7169968Z ------------------------------------------
2020-01-05T02:19:58.7170018Z 
2020-01-05T02:19:58.7170281Z ------------------------------------------
2020-01-05T02:19:58.7170355Z stderr:
---
2020-01-05T02:19:58.7172608Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:385:22
2020-01-05T02:19:58.7172692Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2020-01-05T02:19:58.7172728Z 
2020-01-05T02:19:58.7172756Z 
2020-01-05T02:19:58.7174617Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "/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-7/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" "7.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"
2020-01-05T02:19:58.7174892Z 
2020-01-05T02:19:58.7174924Z 
2020-01-05T02:19:58.7176371Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2020-01-05T02:19:58.7183080Z Build completed unsuccessfully in 1:01:42
2020-01-05T02:19:58.7183080Z Build completed unsuccessfully in 1:01:42
2020-01-05T02:19:58.7226006Z == clock drift check ==
2020-01-05T02:19:58.7247220Z   local time: Sun Jan  5 02:19:58 UTC 2020
2020-01-05T02:19:59.2736339Z   network time: Sun, 05 Jan 2020 02:19:59 GMT
2020-01-05T02:19:59.2740406Z == end clock drift check ==
2020-01-05T02:20:00.3240827Z 
2020-01-05T02:20:00.3368924Z ##[error]Bash exited with code '1'.
2020-01-05T02:20:00.3416729Z ##[section]Starting: Checkout
2020-01-05T02:20:00.3418568Z ==============================================================================
2020-01-05T02:20:00.3418619Z Task         : Get sources
2020-01-05T02:20:00.3418852Z 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)

@oli-obk oli-obk added F-const_trait_bound_opt_out F-const_trait_impl `#![feature(const_trait_impl)]` labels Jan 5, 2020
src/librustc_passes/ast_validation.rs Outdated Show resolved Hide resolved
src/librustc_passes/ast_validation.rs Outdated Show resolved Hide resolved
src/librustc_passes/ast_validation.rs Outdated Show resolved Hide resolved
@oli-obk
Copy link
Contributor

oli-obk commented Jan 6, 2020

@bors r+

@bors
Copy link
Contributor

bors commented Jan 6, 2020

📌 Commit 19f74cb has been approved by oli-obk

@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-review Status: Awaiting review from the assignee but also interested parties. labels Jan 6, 2020
Centril added a commit to Centril/rust that referenced this pull request Jan 7, 2020
Parse the syntax described in RFC 2632

This adds support for both `impl const Trait for Ty` and `?const Trait` bound syntax from rust-lang/rfcs#2632 to the parser. For now, both modifiers end up in a newly-added `constness` field on `ast::TraitRef`, although this may change once the implementation is fleshed out.

I was planning on using `delay_span_bug` when this syntax is encountered during lowering, but I can't write `should-ice` UI tests. I emit a normal error instead, which causes duplicates when the feature gate is not enabled (see the `.stderr` files for the feature gate tests). Not sure what the desired approach is; Maybe just do nothing when the syntax is encountered with the feature gate is enabled?

@oli-obk I went with `const_trait_impl` and `const_trait_bound_opt_out` for the names of these features. Are these to your liking?

cc rust-lang#67792 rust-lang#67794

r? @Centril
@bors
Copy link
Contributor

bors commented Jan 8, 2020

☔ The latest upstream changes (presumably #67770) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 8, 2020
bors added a commit that referenced this pull request Jan 8, 2020
Rollup of 10 pull requests

Successful merges:

 - #67774 (Try statx for all linux-gnu target.)
 - #67781 (Move `is_min_const_fn` query to librustc_mir.)
 - #67798 (Remove wrong advice about spin locks from `spin_loop_hint` docs)
 - #67849 (Add a check for swapped words when we can't find an identifier)
 - #67875 (Distinguish between private items and hidden items in rustdoc)
 - #67887 (`Option::{expect,unwrap}` and `Result::{expect, expect_err, unwrap, unwrap_err}` have `#[track_caller]`)
 - #67955 (rustdoc: Remove more `#[doc(cfg(..))]` duplicates)
 - #67977 (Updates for VxWorks)
 - #67985 (Remove insignificant notes from CStr documentation)
 - #68003 (ci: fix wrong shared.sh import for publish_toolstate)

Failed merges:

 - #67820 (Parse the syntax described in RFC 2632)
 - #67979 (Move `intravisit` => `rustc_hir` + misc cleanup)

r? @ghost
bors added a commit that referenced this pull request Jan 8, 2020
Rollup of 10 pull requests

Successful merges:

 - #67774 (Try statx for all linux-gnu target.)
 - #67781 (Move `is_min_const_fn` query to librustc_mir.)
 - #67798 (Remove wrong advice about spin locks from `spin_loop_hint` docs)
 - #67849 (Add a check for swapped words when we can't find an identifier)
 - #67875 (Distinguish between private items and hidden items in rustdoc)
 - #67887 (`Option::{expect,unwrap}` and `Result::{expect, expect_err, unwrap, unwrap_err}` have `#[track_caller]`)
 - #67955 (rustdoc: Remove more `#[doc(cfg(..))]` duplicates)
 - #67977 (Updates for VxWorks)
 - #67985 (Remove insignificant notes from CStr documentation)
 - #68003 (ci: fix wrong shared.sh import for publish_toolstate)

Failed merges:

 - #67820 (Parse the syntax described in RFC 2632)
 - #67979 (Move `intravisit` => `rustc_hir` + misc cleanup)

r? @ghost
This is used for both the `?const` syntax in bounds as well as the `impl
const Trait` syntax. I also considered handling these separately by
adding a variant of `TraitBoundModifier` and a field to
`ItemKind::Impl`, but this approach was less intrusive.
The grammar also handles `?const ?Trait` even though this is
semantically redundant.
This means the new syntax will always fail to compile, even when the
feature gate is enabled. These checks will be removed in a later PR
once the implementation is done.
@ecstatic-morse
Copy link
Contributor Author

@bors r=oli-obk

@bors
Copy link
Contributor

bors commented Jan 10, 2020

📌 Commit fd1c003 has been approved by oli-obk

@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 Jan 10, 2020
Centril added a commit to Centril/rust that referenced this pull request Jan 10, 2020
Parse the syntax described in RFC 2632

This adds support for both `impl const Trait for Ty` and `?const Trait` bound syntax from rust-lang/rfcs#2632 to the parser. For now, both modifiers end up in a newly-added `constness` field on `ast::TraitRef`, although this may change once the implementation is fleshed out.

I was planning on using `delay_span_bug` when this syntax is encountered during lowering, but I can't write `should-ice` UI tests. I emit a normal error instead, which causes duplicates when the feature gate is not enabled (see the `.stderr` files for the feature gate tests). Not sure what the desired approach is; Maybe just do nothing when the syntax is encountered with the feature gate is enabled?

@oli-obk I went with `const_trait_impl` and `const_trait_bound_opt_out` for the names of these features. Are these to your liking?

cc rust-lang#67792 rust-lang#67794

r? @Centril
Centril added a commit to Centril/rust that referenced this pull request Jan 10, 2020
Parse the syntax described in RFC 2632

This adds support for both `impl const Trait for Ty` and `?const Trait` bound syntax from rust-lang/rfcs#2632 to the parser. For now, both modifiers end up in a newly-added `constness` field on `ast::TraitRef`, although this may change once the implementation is fleshed out.

I was planning on using `delay_span_bug` when this syntax is encountered during lowering, but I can't write `should-ice` UI tests. I emit a normal error instead, which causes duplicates when the feature gate is not enabled (see the `.stderr` files for the feature gate tests). Not sure what the desired approach is; Maybe just do nothing when the syntax is encountered with the feature gate is enabled?

@oli-obk I went with `const_trait_impl` and `const_trait_bound_opt_out` for the names of these features. Are these to your liking?

cc rust-lang#67792 rust-lang#67794

r? @Centril
bors added a commit that referenced this pull request Jan 10, 2020
Rollup of 6 pull requests

Successful merges:

 - #66463 (Point at opaque and closure type definitions in type errors)
 - #67501 (Reduce special treatment for zsts)
 - #67820 (Parse the syntax described in RFC 2632)
 - #67922 (rustc_ast_lowering: misc cleanup & rustc dep reductions)
 - #68071 (Extend support of `_` in type parameters)
 - #68073 (expect `fn` after `const unsafe` / `const extern`)

Failed merges:

r? @ghost
@bors bors merged commit fd1c003 into rust-lang:master Jan 10, 2020
@ecstatic-morse ecstatic-morse deleted the const-trait branch October 6, 2020 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-const_trait_impl `#![feature(const_trait_impl)]` 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.

5 participants