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

Expand Attributes on Statements and Expressions #49124

Merged
merged 1 commit into from
Apr 2, 2018

Conversation

abonander
Copy link
Contributor

@abonander abonander commented Mar 18, 2018

This enables attribute-macro expansion on statements and expressions while retaining the stmt_expr_attributes feature requirement for attributes on expressions.

closes #41475
cc #38356 @petrochenkov @jseyfried
r? @nrc

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 18, 2018
@abonander
Copy link
Contributor Author

This is the error that doesn't make any sense (others are breakages that I haven't fixed cause I've only been running the one test): https://travis-ci.org/rust-lang/rust/builds/354876674#L2899

The only attribute being expanded is #[expect_let] which should be returning the statement verbatim.

@abonander
Copy link
Contributor Author

abonander commented Mar 18, 2018

I understand the problem now. Parser::parse_full_stmt() expects a trailing semicolon as a separate token but the NtStmt is the only token and is returned wholesale from parse_stmt_without_recovery

@nrc
Copy link
Member

nrc commented Mar 19, 2018

Looks fine to me, but I'm somewhat out of touch with the compiler nowadays.

r? @petrochenkov

@rust-highfive rust-highfive assigned petrochenkov and unassigned nrc Mar 19, 2018
@abonander
Copy link
Contributor Author

Turns out #43988 isn't related to this bit of the code.

@abonander abonander changed the title [WIP] Expand Attributes on Statements and Expressions Expand Attributes on Statements and Expressions Mar 19, 2018
@abonander
Copy link
Contributor Author

@petrochenkov Squashed and ready for review.

@petrochenkov
Copy link
Contributor

I'll likely leave this until weekend.

@petrochenkov
Copy link
Contributor

Also, Travis fails

[00:45:12] failures:
[00:45:12] [ui] ui/feature-gate-stmt_expr_attributes.rs

@abonander
Copy link
Contributor Author

Oh yeah that's because I changed the error message since attributes on statements are stable.

@abonander
Copy link
Contributor Author

@petrochenkov build is green

@pietroalbini
Copy link
Member

Ping from triage @petrochenkov! This PR still needs your review.

@petrochenkov
Copy link
Contributor

I'd like to see a couple more compile fail tests:

  • Expression attribute expanding into 0 or >1 expressions in a position where such expansion is not supported.
  • Attribute expanding into 0 or >1 things applied to a trailing expression/statement in a block.

r=me after adding those tests

@petrochenkov petrochenkov 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 Mar 27, 2018
@TimNN
Copy link
Contributor

TimNN commented Apr 1, 2018

Your PR failed on Travis. 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.
[00:00:42] configure: rust.quiet-tests     := True
---
[00:35:42] .........................................................................i..........................
[00:35:48] ................i...................................................................................
---
[00:36:21] ............................................................................................i.......
[00:36:27] ................................................................i...................................
---
[00:37:17] .............................................i......................................................
---
[00:40:47] .............................i......................................................................
[00:41:00] ..............................................................i.....................................
[00:41:15] ...............................................i....................................................
[00:41:33] ....................................................................................................
[00:41:53] ....................................................................................................
[00:42:12] ....................................................................................................
[00:42:35] .i................................................................................................i.
[00:43:05] ..............................................................................................test [run-pass] run-pass/mir_heavy_promoted.rs has been running for over 60 seconds
[00:43:08] ......
[00:43:35] ....................................................................................................
[00:44:07] ...............................................................ii...................................
[00:44:52] ..........................i....................................................i.ii.................
[00:45:28] .......................................................................................iiiiiii......
---
[00:47:20] ....................................i...............................................................
[00:47:27] ....................................................................................................
[00:47:34] ..................i............................................................ii.iii...............
[00:47:41] ....................................................................................................
[00:47:48] ........i..............................i............................................................
[00:47:55] ....................................................................................................
[00:48:02] .....................i..............................................................................
[00:48:09] ....................................................................................................
[00:48:19] ....................................................................................................
[00:48:28] ....................................................................................................
[00:48:38] ....................................................................................................
[00:48:50] ....................................................................................................
[00:48:58] ..............i.....................................................................................
[00:49:07] .................i..ii..............................................................................
[00:49:16] ....................................................................................................
[00:49:25] ....................................................................................................
[00:49:34] ....................................................................................i...............
[00:49:44] ..............................i.....................................................................
---
[00:50:18] ............................i.......................................................................
[00:50:20] ....................................................................i...............................
[00:50:21] .................i......................................................
---
[00:50:34] ...........i........................
---
[00:51:03] i...i..ii....i.............ii........iii......i..i...i...ii..i..i..ii.....
---
[00:51:06] i.......i......................i......
---
[00:51:40] iiii.......i..i........i..i.i.............i..........iiii...........i...i..........ii.i.i.......ii..
[00:51:41] ....ii...
---
[00:56:01] ..................F....F...........................
[00:56:01] failures:
[00:56:01] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:478:22
[00:56:01]
[00:56:01] ---- [compile-fail] compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs stdout ----
[00:56:01]
[00:56:01] error: /checkout/src/test/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs:22: unexpected error: '22:13: 22:25: attributes on expressions are experimental. (see issue #15701) [E0658]'
[00:56:01]
[00:56:01] error: /checkout/src/test/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs:25: unexpected error: '25:5: 25:17: attributes on expressions are experimental. (see issue #15701) [E0658]'
[00:56:01]
[00:56:01] error: /checkout/src/test/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs:25: unexpected error: '25:5: 25:17: macro expansion ignores token `,` and any following'
[00:56:01]
[00:56:01] error: /checkout/src/test/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs:22: expected error not found: asdf
[00:56:01]
[00:56:01] error: /(
[00:56:01]             Error
[00:56:01]         ),
[00:56:01]         msg: "34:5: 34:17: attributes on expressions are experimental. (see issue #15701) [E0658]"
---
[00:56:01]         msg: "34:5: 34:17: add #![feature(stmt_expr_attributes)] to the crate attributes to enable"
---
[00:56:01]         msg: "attributes on expressions are experimental"
---
[00:56:01]         msg: "add #![feature(stmt_expr_attributes)] to the crate attributes to enable"
[00:56:01]     }
[00:56:01] ]
[00:56:01]
[00:56:01] thread '[compile-fail] compile-fail-fulldeps/proc-macro/attr-stmt-expr.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:1253:13
---
$ cat obj/tmp/sccache.log

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.

@abonander
Copy link
Contributor Author

@TimNN suggestion: only send a message if the user doesn't push another commit within X hours. I'm watching these builds and I know how to interpret them so the bot's not really adding anything.

@TimNN
Copy link
Contributor

TimNN commented Apr 1, 2018

@abonander: Thanks for the feedback, I'll look into implementing something like that.

@TimNN
Copy link
Contributor

TimNN commented Apr 1, 2018

Your PR failed on Travis. 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.
[00:00:46] configure: rust.quiet-tests     := True
---
[00:39:48] .........................................................................i..........................
[00:39:54] ................i...................................................................................
---
[00:40:29] ............................................................................................i.......
[00:40:36] ................................................................i...................................
---
[00:41:30] .............................................i......................................................
---
[00:45:19] .............................i......................................................................
[00:45:34] ..............................................................i.....................................
[00:45:49] ...............................................i....................................................
[00:46:09] ....................................................................................................
[00:46:30] ....................................................................................................
[00:46:52] ....................................................................................................
[00:47:16] .i................................................................................................i.
[00:47:44] ....................................................................................test [run-pass] run-pass/mir_heavy_promoted.rs has been running for over 60 seconds
[00:47:52] ................
[00:48:22] ....................................................................................................
[00:48:57] ...............................................................ii...................................
[00:49:43] ..........................i....................................................i.ii......test [run-pass] run-pass/saturating-float-casts.rs has been running for over 60 seconds
[00:49:46] ...........
[00:50:26] .......................................................................................iiiiiii......
---
[00:52:23] ....................................i...............................................................
[00:52:30] ....................................................................................................
[00:52:38] ..................i............................................................ii.iii...............
[00:52:45] ....................................................................................................
[00:52:53] ........i..............................i............................................................
[00:53:00] ....................................................................................................
[00:53:07] .....................i..............................................................................
[00:53:15] ....................................................................................................
[00:53:25] ....................................................................................................
[00:53:35] ....................................................................................................
[00:53:46] ....................................................................................................
[00:54:00] ....................................................................................................
[00:54:09] ..............i.....................................................................................
[00:54:18] .................i..ii..............................................................................
[00:54:28] ....................................................................................................
[00:54:39] ....................................................................................................
[00:54:48] ....................................................................................i...............
[00:54:59] ..............................i.....................................................................
---
[00:55:36] ...........................i........................................................................
[00:55:37] ....................................................................i...............................
[00:55:38] ................i.......................................................
---
[00:55:53] ...........i........................
---
[00:56:23] i...i..ii....i.............ii........iii......i..i...i...ii..i..i..ii.....
---
[00:56:26] i.......i......................i......
---
[00:57:02] iiii.......i..i........i..i.i.............i..........iiii...........i...i..........ii.i.i.......ii..
[00:57:03] ....ii...
---
json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Zmiri" "-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/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.stage2-x86_64-unknown-linux-gnu.aux" "-A" "unused"
[01:02:18] unexpected errors (from JSON output): [
[01:02:18]     Error {
[01:02:18]         line_num: 25,
[01:02:18]         kind: Some(
[01:02:18]             Error
[01:02:18]         ),
[01:02:18]         msg: "25:13: 25:25: macro expansion ignores token `,` and any following"
---
[01:02:18]         msg: "asdf"
---
[01:02:18]         msg: "asdf"
[01:02:18]     }
[01:02:18] ]
[01:02:18]
[01:02:18] thread '[compile-fail] compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:1253:13

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.

let _ = #[no_output] "Hello, world!";
//~^ ERROR asdf

let _ = #[duplicate] "Hello, world!";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@petrochenkov
https://travis-ci.org/rust-lang/rust/builds/360794617#L1905

25:13: 25:25: macro expansion ignores token , and any following

So it seems that the parser currently doesn't support directly expanding into >1 expressions.

use attr_stmt_expr::duplicate;

fn main() {
let _ = #[no_output] "Hello, world!";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This didn't produce an error, which is concerning.

Copy link
Contributor Author

@abonander abonander Apr 1, 2018

Choose a reason for hiding this comment

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

Nevermind, it hits later than the other one so it didn't occur until I commented it out. However, the UX is pretty bad:

1:1: 1:1: expected expression, found `<eof>`

I reckon I should do the same checks that #[cfg] does in this context and emit the same error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Either that, or just re-span the parse error. That'd probably be easier.

@petrochenkov
Copy link
Contributor

Still needs a test for

Attribute expanding into 0 or >1 things applied to a trailing expression/statement in a block.

+ squashing + green Travis.
Possibly suboptimal diagnostics for tests from #49124 (comment) are okay.

@bors delegate+

@bors
Copy link
Contributor

bors commented Apr 1, 2018

✌️ @abonander can now approve this pull request

@abonander
Copy link
Contributor Author

I'm at least gonna try to get it to point to the problematic invocation. The current error message has a dummy span.

@TimNN
Copy link
Contributor

TimNN commented Apr 1, 2018

Your PR failed on Travis. 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.
Resolving deltas: 100% (613643/613643), completed with 4863 local objects.
---
[00:00:29] configure: rust.quiet-tests     := True
---
[00:38:45] .........................................................................i..........................
[00:38:51] ................i...................................................................................
---
[00:39:26] ............................................................................................i.......
[00:39:33] ................................................................i...................................
---
[00:40:26] .............................................i......................................................
---
[00:44:13] .............................i......................................................................
[00:44:27] ..............................................................i.....................................
[00:44:42] ...............................................i....................................................
[00:45:02] ....................................................................................................
[00:45:23] ....................................................................................................
[00:45:44] ....................................................................................................
[00:46:08] .i................................................................................................i.
[00:46:36] .....................................................................................test [run-pass] run-pass/mir_heavy_promoted.rs has been running for over 60 seconds
[00:46:44] ...............
[00:47:14] ....................................................................................................
[00:47:49] ...............................................................ii...................................
[00:48:34] ..........................i....................................................i.ii......test [run-pass] run-pass/saturating-float-casts.rs has been running for over 60 seconds
[00:48:38] ...........
[00:49:17] .......................................................................................iiiiiii......
---
[00:51:17] ....................................i...............................................................
[00:51:24] ....................................................................................................
[00:51:32] ..................i............................................................ii.iii...............
[00:51:39] ....................................................................................................
[00:51:47] ........i..............................i............................................................
[00:51:54] ....................................................................................................
[00:52:01] .....................i..............................................................................
[00:52:09] ....................................................................................................
[00:52:18] ....................................................................................................
[00:52:28] ....................................................................................................
[00:52:39] ....................................................................................................
[00:52:53] ....................................................................................................
[00:53:01] ..............i.....................................................................................
[00:53:11] .................i..ii..............................................................................
[00:53:20] ....................................................................................................
[00:53:31] ....................................................................................................
[00:53:40] ....................................................................................i...............
[00:53:50] ..............................i.....................................................................
---
[00:54:27] ...........................i........................................................................
[00:54:28] ....................................................................i...............................
[00:54:30] ................i.......................................................
---
[00:54:44] ...........i........................
---
[00:55:14] i...i..ii....i.............ii........iii......i..i...i...ii..i..i..ii.....
---
[00:55:17] i.......i......................i......
---
[00:55:54] iiii.......i..i........i..i.i.............i..........iiii...........i...i..........ii.i.i.......ii..
[00:55:55] ....ii...
---
[01:01:05] ...................F...............................
[01:01:05] failures:
[01:01:05]
[01:01:05] ---- [compile-fail] compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs stdout ----
[01:01:05]
[01:01:05] error: /checkout/src/test/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs:25: unexpected error: '25:13: 25:25: macro expansion ignores token `,` and any following'
[01:01:05]
[01:01:05] error: 1 unexpected errors found, 0 expected errors not found
[01:01:05] status: exit code: 101
[01:01:05] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/compile-fail-fulldeps" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Zmiri" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnle-fail-fulldeps" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "compile-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 -Zmiri -Zunstable-options " "--target-rustcflags" "-Crpath -O -Zmiri -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"
[01:01:05] expected success, got: exit code: 101
[01:01:05]
[01:01:05]
[01:01:05] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:01:05] Build completed unsuccessfully in 0:23:10
[01:01:05] make: *** [check] Error 1
[01:01:05] Makefile:58: recipe for target 'check' failed
---
$ cat obj/tmp/sccache.log

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.

@TimNN
Copy link
Contributor

TimNN commented Apr 2, 2018

Your PR failed on Travis. 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.
Resolving deltas: 100% (613649/613649), completed with 4863 local objects.
---
[00:00:45] configure: rust.quiet-tests     := True
---
[00:43:18] .........................................................................i..........................
[00:43:24] ................i...................................................................................
---
[00:44:01] ............................................................................................i.......
[00:44:08] ................................................................i...................................
---
[00:45:05] .............................................i......................................................
---
[00:49:07] .............................i......................................................................
[00:49:22] ..............................................................i.....................................
[00:49:38] ...............................................i....................................................
[00:49:59] ....................................................................................................
[00:50:22] ....................................................................................................
[00:50:44] ....................................................................................................
[00:51:10] .i................................................................................................i.
[00:51:35] ............................................................................test [run-pass] run-pass/mir_heavy_promoted.rs has been running for over 60 seconds
[00:51:48] ........................
[00:52:20] ....................................................................................................
[00:52:57] ...............................................................ii...................................
[00:53:42] ..........................i....................................................i.iitest [run-pass] run-pass/saturating-float-casts.rs has been running for over 60 seconds
[00:53:48] .................
[00:54:30] .......................................................................................iiiiiii......
---
[00:56:32] ....................................i...............................................................
[00:56:40] ....................................................................................................
[00:56:48] ..................i............................................................ii.iii...............
[00:56:55] ....................................................................................................
[00:57:03] ........i..............................i............................................................
[00:57:11] ....................................................................................................
[00:57:18] .....................i..............................................................................
[00:57:26] ....................................................................................................
[00:57:37] ....................................................................................................
[00:57:47] ....................................................................................................
[00:57:58] ....................................................................................................
[00:58:12] ....................................................................................................
[00:58:22] ..............i.....................................................................................
[00:58:32] .................i..ii..............................................................................
[00:58:42] ....................................................................................................
[00:58:53] ....................................................................................................
[00:59:02] ....................................................................................i...............
[00:59:13] ..............................i.....................................................................
---
[00:59:51] ............................i.......................................................................
[00:59:53] ....................................................................i...............................
[00:59:54] ................i.......................................................
---
[01:00:09] ...........i........................
---
[01:00:41] i...i..ii....i.............ii........iii......i..i...i...ii..i..i..ii.....
---
[01:00:44] i.......i......................i......
---
[01:01:23] iiii.......i..i........i..i.i.............i..........iiii...........i...i..........ii.i.i.......ii..
[01:01:24] ....ii...
---
est/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Zmiri" "-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/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.stage2-x86_64-unknown-linux-gnu.aux" "-A" "unused"
[01:07:07] unexpected errors (from JSON output): [
[01:07:07]     Error {
[01:07:07]         line_num: 34,
[01:07:07]         kind: Some(
[01:07:07]             Error
[01:07:07]         ),
[01:07:07]         msg: "34:9: 34:21: macro expansion ignores token `,` and any following"
---
[01:07:07]         msg: "macro expansion ignores token `,` and any following"
[01:07:07]     }
[01:07:07] ]
[01:07:07]
[01:07:07] thread '[compile-fail] compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:1253:13
---
[01:07:07] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:478:22
[01:07:07] 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/compile-fail-fulldeps" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/compile-fail-fulldeps" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "compile-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 -Zmiri -Zunstable-options " "--target-rustcflags" "-Crpath -O -Zmiri -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"
[01:07:07] expected success, got: exit code: 101
[01:07:07]
[01:07:07]
[01:07:07] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:07:07] Build completed unsuccessfully in 0:24:48
[01:07:07] Makefile:58: recipe for target 'check' failed
[01:07:07] make: *** [check] Error 1
/incremental/bootstrap-1xj36c8o119z7
113580 ./obj/build/bootstrap/debug/incremental/bootstrap-1xj36c8o119z7/s-ezq7nnjkjd-1qawgcj-1qldka3x57wek
112704 ./obj/build/x86_64-unknown-linux-gnu/test/mir-opt
108032 ./obj/build/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends
102612 ./obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/incremental/core-1sv8kuz0m8z0z
102608 ./obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/incremental/core-1sv8kuz0m8z0z/s-ezq8pbn7od-17kdcob-mx3hb8bwcwpv
---
$ cat obj/tmp/sccache.log
---
$ ls -lat $HOME/Library/Logs/DiagnosticReports/
ls: cannot access /home/travis/Library/Logs/DiagnosticReports/: No such file or directory
travis_time:end:0d961061:start=1522636287567666826,finish=1522636287574938720,duration=7271894
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:1450e71c
$ find $HOME/Library/Logs/DiagnosticReports -type f -name '*.crash' -not -name '*.stage2-*.crash' -not -name 'com.apple.CoreSimulator.CoreSimulatorService-*.crash' -exec printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" {} \; -exec head -750 {} \; -exec echo travis_fold":"end:crashlog \; || true
find: `/home/travis/Library/Logs/DiagnosticReports': No such file or directory
travis_time:end:1450e71c:start=1522636287581513151,finish=1522636287588508769,duration=6995618
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:01a41bcb
$ dmesg | grep -i kill
[   10.954591] init: failsafe main process (1094) killed by TERM signal

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.

Retains the `stmt_expr_attributes` feature requirement for attributes on expressions.

closes rust-lang#41475
cc rust-lang#38356
@abonander
Copy link
Contributor Author

@bors r+

@bors
Copy link
Contributor

bors commented Apr 2, 2018

📌 Commit 7c0124d has been approved by abonander

@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 Apr 2, 2018
@bors
Copy link
Contributor

bors commented Apr 2, 2018

⌛ Testing commit 7c0124d with merge 097efa9...

bors added a commit that referenced this pull request Apr 2, 2018
Expand Attributes on Statements and Expressions

This enables attribute-macro expansion on statements and expressions while retaining the `stmt_expr_attributes` feature requirement for attributes on expressions.

closes #41475
cc #38356  @petrochenkov @jseyfried
r? @nrc

let _ = {
#[no_output]
"Hello, world!"
Copy link
Contributor

Choose a reason for hiding this comment

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

So, you can cfg-out a trailing expression and implicit () will be used instead? Fun.
At least this is consistent with existing behavior of #[cfg].

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 think that's just the behavior of an empty block, no?

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.

It's behavior of an empty block, yes, but it's not obvious that { #[cfg_like] trailing } should expand into an empty block - it depends on interpretation.
If the attribute is applied to the statement, then 1 statement -> 0 statements transformation is okay, but if the attribute is applied to the expression inside of that statement, then it supposedly should be an error, because you can't shrink an expression in that position into nothing (it's not a part of expression list).

As I understand the code in expand.rs, attributes on expression statements are treated as expression attributes and not statement attributes, but the behavior follows the statement attribute interpretation.
Ok, now I'm actually not sure whether #[no_output] is applied at all here.
We need to add a test making sure that this doesn't expand into let _ = { "Hello, world!" }; ignoring the attribute.

@bors
Copy link
Contributor

bors commented Apr 2, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: abonander
Pushing 097efa9 to master...

@bors bors merged commit 7c0124d into rust-lang:master Apr 2, 2018
kennytm added a commit to kennytm/rust that referenced this pull request Apr 3, 2018
…etrochenkov

run-pass/attr-stmt-expr: expand test cases

Follow-up to rust-lang#49124 (comment)

r? @petrochenkov
kennytm added a commit to kennytm/rust that referenced this pull request Apr 3, 2018
…etrochenkov

run-pass/attr-stmt-expr: expand test cases

Follow-up to rust-lang#49124 (comment)

r? @petrochenkov
kennytm added a commit to kennytm/rust that referenced this pull request Apr 4, 2018
…etrochenkov

run-pass/attr-stmt-expr: expand test cases

Follow-up to rust-lang#49124 (comment)

r? @petrochenkov
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.

Attribute macros can't be applied to statements
7 participants