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

Lint on incorrect unseparated repetition #55373

Open
wants to merge 7 commits into
base: master
from

Conversation

Projects
None yet
@estebank
Contributor

estebank commented Oct 26, 2018

Macro pattern ($a:expr $b:expr) is invalid, for good reason.
Correctly reject pattern ($($a:expr)*), as it is functionally the
same.

This PR adds a warn by default lint that checks for any repeatable
pattern that would be rejected by the parser if it had been written
as independent arguments:

  • expr and stmt variables may only be followed by one of:
    => , ;
  • ty and path variables may only be followed by one of:
    => , = | ; : > [ { as where
  • pat variables may only be followed by one of:
    => , = | if in
  • Other variables may be followed by any token.

Fix #44975, fix #48220.

@rust-highfive

This comment has been minimized.

Collaborator

rust-highfive commented Oct 26, 2018

r? @sfackler

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

@estebank

This comment has been minimized.

Contributor

estebank commented Oct 26, 2018

@bors try

@bors

This comment has been minimized.

Contributor

bors commented Oct 26, 2018

⌛️ Trying commit 5c5fca0 with merge a7b077c...

bors added a commit that referenced this pull request Oct 26, 2018

Auto merge of #55373 - estebank:macro-rep, r=<try>
Disallow incorrect unseparated repetition

Macro pattern `($a:expr, $b:expr)` is invalid, for good reason.
Correctly reject pattern `($($a:expr)*)`, as it is functionally the
same.

Fix #44975, fix #48220.
@rust-highfive

This comment was marked as resolved.

Collaborator

rust-highfive commented Oct 26, 2018

The job x86_64-gnu-llvm-5.0 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:end:1bf04d88:start=1540529482999991297,finish=1540529540356568187,duration=57356576890
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
---

[00:04:00] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:04:00] tidy error: /checkout/src/test/ui/macros/incorrrect-repetition-2.rs:3: line longer than 100 chars
[00:04:00] tidy error: /checkout/src/test/ui/macros/incorrrect-repetition.rs:3: line longer than 100 chars
[00:04:01] some tidy checks failed
[00:04:01] 
[00:04:01] 
[00:04:01] 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:04:01] 
[00:04:01] 
[00:04:01] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:01] Build completed unsuccessfully in 0:00:48
[00:04:01] Build completed unsuccessfully in 0:00:48
[00:04:01] Makefile:79: recipe for target 'tidy' failed
[00:04:01] make: *** [tidy] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0d69dcbd
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:026ad418:start=1540529792912585710,finish=1540529792917744501,duration=5158791
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:001adc66
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:1d0c762a
travis_time:start:1d0c762a
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:01971354
$ 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)

@estebank

This comment has been minimized.

Contributor

estebank commented Oct 26, 2018

cc @nikomatsakis @durka @joshtriplett


I'm afraid fixing this is going to be problematic, because even we are using this "feature" in rustc. I'll post a PR with the fix (including changing our mis-uses), but will expect there to be breakage. If that is the case after a crater run, should we still include the fix as a warning?

This will need a crater run to see how much this would break.

@estebank estebank force-pushed the estebank:macro-rep branch from 5c5fca0 to 11b8746 Oct 26, 2018

@estebank

This comment was marked as outdated.

Contributor

estebank commented Oct 26, 2018

@bors try

@bors

This comment was marked as outdated.

Contributor

bors commented Oct 26, 2018

⌛️ Trying commit 11b8746 with merge 7ae3681...

bors added a commit that referenced this pull request Oct 26, 2018

Auto merge of #55373 - estebank:macro-rep, r=<try>
Disallow incorrect unseparated repetition

Macro pattern `($a:expr, $b:expr)` is invalid, for good reason.
Correctly reject pattern `($($a:expr)*)`, as it is functionally the
same.

Fix #44975, fix #48220.
@rust-highfive

This comment was marked as resolved.

Collaborator

rust-highfive commented Oct 26, 2018

The job x86_64-gnu-llvm-5.0 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:end:17d33900:start=1540530678669451371,finish=1540530732059178857,duration=53389727486
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
---
[00:23:02]    Compiling syntax_pos v0.0.0 (/checkout/src/libsyntax_pos)
[00:23:07]    Compiling rustc_errors v0.0.0 (/checkout/src/librustc_errors)
[00:24:35]    Compiling proc_macro v0.0.0 (/checkout/src/libproc_macro)
[00:24:44]    Compiling syntax_ext v0.0.0 (/checkout/src/libsyntax_ext)
[00:24:45] error: `$warn_text:expr` is followed (through repetition) by `$warn_val:expr`, which is not allowed for `expr` fragments
[00:24:45]    --> librustc/session/config.rs:314:74
[00:24:45]     |
[00:24:45] 314 |         $opt:ident : $t:ty [$dep_tracking_marker:ident $($warn_val:expr, $warn_text:expr)*],
[00:24:45]     |                                                          --------------  ^^^^^^^^^^^^^^^ this fragment is followed by the first fragment in this repetition without a valid separator
[00:24:45]     |                                                          |
[00:24:45]     |                                                          this is the first fragment in the evaluated repetition
[00:24:47] error[E0432]: unresolved import `session::config::Options`
[00:24:47]   --> librustc/util/profiling.rs:11:5
[00:24:47]    |
[00:24:47] 11 | use session::config::Options;
---
[00:24:49] 
[00:24:49] error[E0412]: cannot find type `Options` in this scope
[00:24:49]     --> librustc/session/config.rs:1471:35
[00:24:49]      |
[00:24:49] 1471 | pub fn build_target_config(opts: &Options, sp: &Handler) -> Config {
[00:24:49]      |                                   ^^^^^^^ did you mean `Option`?
[00:24:49]      |
[00:24:49] 14   | use getopts::Options;
[00:24:49]      |
[00:24:49] 14   | use test::Options;
---
[00:24:49] 
[00:24:49] error[E0412]: cannot find type `Options` in module `config`
[00:24:49]   --> librustc/session/mod.rs:66:23
[00:24:49]    |
[00:24:49] 66 |     pub opts: config::Options,
[00:24:49] help: possible candidates are found in other modules, you can import them into scope
[00:24:49]    |
[00:24:49] 11 | use getopts::Options;
[00:24:49]    |
---
[00:24:49] 
[00:24:49] error[E0412]: cannot find type `Options` in module `config`
[00:24:49]    --> librustc/session/mod.rs:889:51
[00:24:49]     |
[00:24:49] 889 |     pub fn query_threads_from_opts(opts: &config::Options) -> usize {
[00:24:49] help: possible candidates are found in other modules, you can import them into scope
[00:24:49]     |
[00:24:49] 11  | use getopts::Options;
[00:24:49]     |
---
[00:24:49] 
[00:25:13] error[E0277]: the size for values of type `str` cannot be known at compilation time
[00:25:13]   --> librustc/lint/levels.rs:65:40
[00:25:13]    |
[00:25:13] 65 |         for &(ref lint_name, level) in &sess.opts.lint_opts {
[00:25:13]    |
[00:25:13]    = help: the trait `std::marker::Sized` is not implemented for `str`
[00:25:13]    = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
[00:25:13]    = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
[00:25:13]    = note: only the last element of a tuple may have a dynamically sized type
[00:25:15] error[E0277]: the size for values of type `str` cannot be known at compilation time
[00:25:15]     --> librustc/mir/mod.rs:2351:33
[00:25:15]      |
[00:25:15]      |
[00:25:15] 2351 |                             let name = if tcx.sess.opts.debugging_opts.span_free_formats {
[00:25:15]      |
[00:25:15]      = help: the trait `std::marker::Sized` is not implemented for `str`
[00:25:15]      = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
[00:25:15]      = note: all local variables must have a statically known size
[00:25:15]      = note: all local variables must have a statically known size
[00:25:15]      = help: unsized locals are gated as an unstable feature
[00:25:15] 
[00:25:17] error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
[00:25:17]    --> librustc/session/mod.rs:700:13
[00:25:17] 700 |             Some(ref sysroot) => sysroot,
[00:25:17] 700 |             Some(ref sysroot) => sysroot,
[00:25:17]     |             ^^^^^^^^^^^^^^^^^ borrow the `Path` instead
[00:25:17]     |
[00:25:17]     = help: within `std::path::Path`, the trait `std::marker::Sized` is not implemented for `[u8]`
[00:25:17]     = note: required because it appears within the type `std::path::Path`
[00:25:17]     = note: required because it appears within the type `std::path::Path`
[00:25:17]     = note: required by `std::prelude::v1::Some`

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

This comment was marked as resolved.

Collaborator

rust-highfive commented Oct 26, 2018

The job dist-x86_64-linux 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_fold:end:services

travis_fold:start:git.checkout
travis_time:start:142c7d42
$ git clone --depth=2 --branch=try https://github.com/rust-lang/rust.git rust-lang/rust
---
[00:52:16]    Compiling syntax_pos v0.0.0 (/checkout/src/libsyntax_pos)
[00:52:21]    Compiling rustc_errors v0.0.0 (/checkout/src/librustc_errors)
[00:53:55]    Compiling proc_macro v0.0.0 (/checkout/src/libproc_macro)
[00:54:06]    Compiling syntax_ext v0.0.0 (/checkout/src/libsyntax_ext)
[00:54:08] error: `$warn_text:expr` is followed (through repetition) by `$warn_val:expr`, which is not allowed for `expr` fragments
[00:54:08]    --> librustc/session/config.rs:314:74
[00:54:08]     |
[00:54:08] 314 |         $opt:ident : $t:ty [$dep_tracking_marker:ident $($warn_val:expr, $warn_text:expr)*],
[00:54:08]     |                                                          --------------  ^^^^^^^^^^^^^^^ this fragment is followed by the first fragment in this repetition without a valid separator
[00:54:08]     |                                                          |
[00:54:08]     |                                                          this is the first fragment in the evaluated repetition
[00:54:11] error[E0432]: unresolved import `session::config::Options`
[00:54:11]   --> librustc/util/profiling.rs:11:5
[00:54:11]    |
[00:54:11] 11 | use session::config::Options;
---
[00:54:14] 
[00:54:14] error[E0412]: cannot find type `Options` in this scope
[00:54:14]     --> librustc/session/config.rs:1471:35
[00:54:14]      |
[00:54:14] 1471 | pub fn build_target_config(opts: &Options, sp: &Handler) -> Config {
[00:54:14]      |                                   ^^^^^^^ did you mean `Option`?
[00:54:14]      |
[00:54:14] 14   | use getopts::Options;
[00:54:14]      |
[00:54:14] 14   | use test::Options;
---
[00:54:14] 
[00:54:14] error[E0412]: cannot find type `Options` in module `config`
[00:54:14]   --> librustc/session/mod.rs:66:23
[00:54:14]    |
[00:54:14] 66 |     pub opts: config::Options,
[00:54:14] help: possible candidates are found in other modules, you can import them into scope
[00:54:14]    |
[00:54:14] 11 | use getopts::Options;
[00:54:14]    |
---
[00:54:14] 
[00:54:14] error[E0412]: cannot find type `Options` in module `config`
[00:54:14]    --> librustc/session/mod.rs:889:51
[00:54:14]     |
[00:54:14] 889 |     pub fn query_threads_from_opts(opts: &config::Options) -> usize {
[00:54:14] help: possible candidates are found in other modules, you can import them into scope
[00:54:14]     |
[00:54:14] 11  | use getopts::Options;
[00:54:14]     |
---
[00:54:14] 
[00:54:33] error[E0277]: the size for values of type `str` cannot be known at compilation time
[00:54:33]   --> librustc/lint/levels.rs:65:40
[00:54:33]    |
[00:54:33] 65 |         for &(ref lint_name, level) in &sess.opts.lint_opts {
[00:54:33]    |
[00:54:33]    = help: the trait `std::marker::Sized` is not implemented for `str`
[00:54:33]    = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
[00:54:33]    = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
[00:54:33]    = note: only the last element of a tuple may have a dynamically sized type
[00:54:36] error[E0277]: the size for values of type `str` cannot be known at compilation time
[00:54:36]     --> librustc/mir/mod.rs:2351:33
[00:54:36]      |
[00:54:36]      |
[00:54:36] 2351 |                             let name = if tcx.sess.opts.debugging_opts.span_free_formats {
[00:54:36]      |
[00:54:36]      = help: the trait `std::marker::Sized` is not implemented for `str`
[00:54:36]      = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
[00:54:36]      = note: all local variables must have a statically known size
[00:54:36]      = note: all local variables must have a statically known size
[00:54:36]      = help: unsized locals are gated as an unstable feature
[00:54:36] 
[00:54:37] error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
[00:54:37]    --> librustc/session/mod.rs:700:13
[00:54:37] 700 |             Some(ref sysroot) => sysroot,
[00:54:37] 700 |             Some(ref sysroot) => sysroot,
[00:54:37]     |             ^^^^^^^^^^^^^^^^^ borrow the `Path` instead
[00:54:37]     |
[00:54:37]     = help: within `std::path::Path`, the trait `std::marker::Sized` is not implemented for `[u8]`
[00:54:37]     = note: required because it appears within the type `std::path::Path`
[00:54:37]     = note: required because it appears within the type `std::path::Path`
[00:54:37]     = note: required by `std::prelude::v1::Some`
[00:54:45] error: aborting due to 17 previous errors
[00:54:45] 
[00:54:45] Some errors occurred: E0277, E0412, E0422, E0432.
[00:54:45] For more information about an error, try `rustc --explain E0277`.
[00:54:45] For more information about an error, try `rustc --explain E0277`.
[00:54:45] error: Could not compile `rustc`.
[00:54:45] 
[00:54:45] To learn more, run the command again with --verbose.
[00:54:45] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" " jemalloc" "--manifest-path" "/checkout/src/rustc/Cargo.toml" "--message-format" "json"
[00:54:45] expected success, got: exit code: 101
[00:54:45] thread 'main' panicked at 'cargo must succeed', bootstrap/compile.rs:1115:9
[00:54:45] travis_fold:end:stage1-rustc

[00:54:45] travis_time:end:stage1-rustc:start=1540532763905769226,finish=1540532966058997712,duration=202153228486

---
travis_time:end:01e95038:start=1540532967460490633,finish=1540532967474365114,duration=13874481
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:01a20f20
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:0eeb22d4
travis_time:start:0eeb22d4
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:2c95bedc
$ 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)

@bors

This comment was marked as outdated.

Contributor

bors commented Oct 26, 2018

💔 Test failed - status-travis

@rust-highfive

This comment was marked as resolved.

Collaborator

rust-highfive commented Oct 26, 2018

The job dist-x86_64-linux 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_fold:end:services

travis_fold:start:git.checkout
travis_time:start:051bda1c
$ git clone --depth=2 --branch=try https://github.com/rust-lang/rust.git rust-lang/rust
---
[00:54:23]    Compiling syntax_pos v0.0.0 (/checkout/src/libsyntax_pos)
[00:54:27]    Compiling rustc_errors v0.0.0 (/checkout/src/librustc_errors)
[00:56:02]    Compiling proc_macro v0.0.0 (/checkout/src/libproc_macro)
[00:56:13]    Compiling syntax_ext v0.0.0 (/checkout/src/libsyntax_ext)
[00:56:13] error: `$warn_text:expr` is followed (through repetition) by `$warn_val:expr`, which is not allowed for `expr` fragments
[00:56:13]    --> librustc/session/config.rs:314:74
[00:56:13]     |
[00:56:13] 314 |         $opt:ident : $t:ty [$dep_tracking_marker:ident $($warn_val:expr, $warn_text:expr)*],
[00:56:13]     |                                                          --------------  ^^^^^^^^^^^^^^^ this fragment is followed by the first fragment in this repetition without a valid separator
[00:56:13]     |                                                          |
[00:56:13]     |                                                          this is the first fragment in the evaluated repetition
[00:56:16] error[E0432]: unresolved import `session::config::Options`
[00:56:16]   --> librustc/util/profiling.rs:11:5
[00:56:16]    |
[00:56:16] 11 | use session::config::Options;
---
[00:56:18] 
[00:56:18] error[E0412]: cannot find type `Options` in this scope
[00:56:18]     --> librustc/session/config.rs:1471:35
[00:56:18]      |
[00:56:18] 1471 | pub fn build_target_config(opts: &Options, sp: &Handler) -> Config {
[00:56:18]      |                                   ^^^^^^^ did you mean `Option`?
[00:56:18]      |
[00:56:18] 14   | use getopts::Options;
[00:56:18]      |
[00:56:18] 14   | use test::Options;
---
[00:56:18] 
[00:56:18] error[E0412]: cannot find type `Options` in module `config`
[00:56:18]   --> librustc/session/mod.rs:66:23
[00:56:18]    |
[00:56:18] 66 |     pub opts: config::Options,
[00:56:18] help: possible candidates are found in other modules, you can import them into scope
[00:56:18]    |
[00:56:18] 11 | use getopts::Options;
[00:56:18]    |
---
[00:56:18] 
[00:56:18] error[E0412]: cannot find type `Options` in module `config`
[00:56:18]    --> librustc/session/mod.rs:889:51
[00:56:18]     |
[00:56:18] 889 |     pub fn query_threads_from_opts(opts: &config::Options) -> usize {
[00:56:18] help: possible candidates are found in other modules, you can import them into scope
[00:56:18]     |
[00:56:18] 11  | use getopts::Options;
[00:56:18]     |
---
[00:56:18] 
[00:56:40] error[E0277]: the size for values of type `str` cannot be known at compilation time
[00:56:40]   --> librustc/lint/levels.rs:65:40
[00:56:40]    |
[00:56:40] 65 |         for &(ref lint_name, level) in &sess.opts.lint_opts {
[00:56:40]    |
[00:56:40]    = help: the trait `std::marker::Sized` is not implemented for `str`
[00:56:40]    = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
[00:56:40]    = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
[00:56:40]    = note: only the last element of a tuple may have a dynamically sized type
[00:56:42] error[E0277]: the size for values of type `str` cannot be known at compilation time
[00:56:42]     --> librustc/mir/mod.rs:2351:33
[00:56:42]      |
[00:56:42]      |
[00:56:42] 2351 |                             let name = if tcx.sess.opts.debugging_opts.span_free_formats {
[00:56:42]      |
[00:56:42]      = help: the trait `std::marker::Sized` is not implemented for `str`
[00:56:42]      = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
[00:56:42]      = note: all local variables must have a statically known size
[00:56:42]      = note: all local variables must have a statically known size
[00:56:42]      = help: unsized locals are gated as an unstable feature
[00:56:42] 
[00:56:43] error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
[00:56:43]    --> librustc/session/mod.rs:700:13
[00:56:43] 700 |             Some(ref sysroot) => sysroot,
[00:56:43] 700 |             Some(ref sysroot) => sysroot,
[00:56:43]     |             ^^^^^^^^^^^^^^^^^ borrow the `Path` instead
[00:56:43]     |
[00:56:43]     = help: within `std::path::Path`, the trait `std::marker::Sized` is not implemented for `[u8]`
[00:56:43]     = note: required because it appears within the type `std::path::Path`
[00:56:43]     = note: required because it appears within the type `std::path::Path`
[00:56:43]     = note: required by `std::prelude::v1::Some`

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)

@estebank estebank force-pushed the estebank:macro-rep branch 2 times, most recently from 7139c6b to 2915cc7 Oct 26, 2018

@rust-highfive

This comment was marked as resolved.

Collaborator

rust-highfive commented Oct 26, 2018

The job x86_64-gnu-llvm-5.0 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:end:00f6bea5:start=1540566445621560380,finish=1540566504709247763,duration=59087687383
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
---
[00:23:37]    Compiling syntax_ext v0.0.0 (/checkout/src/libsyntax_ext)
[00:30:17]    Compiling rustc_metadata_utils v0.0.0 (/checkout/src/librustc_metadata_utils)
[00:30:17]    Compiling rustc_mir v0.0.0 (/checkout/src/librustc_mir)
[00:30:17]    Compiling rustc_typeck v0.0.0 (/checkout/src/librustc_typeck)
[00:30:17] error: `$delegate:expr` is followed (through repetition) by `->`, which is not allowed for `expr` fragments
[00:30:17]    --> librustc_mir/interpret/snapshot.rs:107:52
[00:30:17]     |
[00:30:17] 107 |         $( $variant:ident $( ( $($field:ident $(-> $delegate:expr)*),* ) )* ),* $(,)*
[00:30:17]     |                                                 -- ^^^^^^^^^^^^^^ this fragment is followed by the first fragment in this repetition without a valid separator
[00:30:17]     |                                                 |
[00:30:17]     |                                                 this is the first fragment in the evaluated repetition
[00:30:17] 
[00:30:17] error: `$delegate:expr` is followed (through repetition) by `->`, which is not allowed for `expr` fragments
[00:30:17]    --> librustc_mir/interpret/snapshot.rs:130:54
[00:30:17]     |
[00:30:17] 130 |     (struct $struct_name:ident { $($field:ident $(-> $delegate:expr)*),*  $(,)* }) => {
[00:30:17]     |                                                   -- ^^^^^^^^^^^^^^ this fragment is followed by the first fragment in this repetition without a valid separator
[00:30:17]     |                                                   |
[00:30:17]     |                                                   this is the first fragment in the evaluated repetition
[00:30:17]    Compiling rustc_allocator v0.0.0 (/checkout/src/librustc_allocator)
[00:30:20] error: unused import: `Pointer`
[00:30:20] error: unused import: `Pointer`
[00:30:20]   --> librustc_mir/interpret/snapshot.rs:14:14
[00:30:20] 14 |     AllocId, Pointer, Scalar,
[00:30:20]    |              ^^^^^^^
[00:30:20]    |
[00:30:20]    = note: `-D unused-imports` implied by `-D warnings`
[00:30:20]    = note: `-D unused-imports` implied by `-D warnings`
[00:30:20] 
[00:30:20] error: unused imports: `MemPlace`, `Operand`, `ScalarMaybeUndef`, `Value`
[00:30:20]   --> librustc_mir/interpret/snapshot.rs:28:28
[00:30:20]    |
[00:30:20] 28 | use super::{Frame, Memory, Operand, MemPlace, Place, Value, ScalarMaybeUndef};
[00:30:20] 
[00:30:20] error: unused macro definition
[00:30:20] error: unused macro definition
[00:30:20]    --> librustc_mir/interpret/snapshot.rs:97:1
[00:30:20]     |
[00:30:20] 97  | / macro_rules! __impl_snapshot_field {
[00:30:20] 98  | |     ($field:ident, $ctx:expr) => ($field.snapshot($ctx));
[00:30:20] 99  | |     ($field:ident, $ctx:expr, $delegate:expr) => ($delegate);
[00:30:20]     | |_^
[00:30:20]     |
[00:30:20]     = note: `-D unused-macros` implied by `-D warnings`
[00:30:20] 
[00:30:20] 
[00:30:34] error[E0599]: no method named `snapshot` found for type `&rustc::mir::interpret::Pointer` in the current scope
[00:30:34]    --> librustc_mir/interpret/snapshot.rs:190:45
[00:30:34]     |
[00:30:34] 190 |             Scalar::Ptr(p) => Scalar::Ptr(p.snapshot(ctx)),
[00:30:34]     |
[00:30:34]     = help: items from traits can only be used if the trait is implemented and in scope
[00:30:34]     = help: items from traits can only be used if the trait is implemented and in scope
[00:30:34]     = note: the following trait defines an item `snapshot`, perhaps you need to implement it:
[00:30:34]             candidate #1: `interpret::snapshot::Snapshot`
[00:30:34] 
[00:30:34] error[E0599]: no method named `snapshot` found for type `&interpret::place::MemPlace` in the current scope
[00:30:34]    --> librustc_mir/interpret/snapshot.rs:244:43
[00:30:34]     |
[00:30:34] 244 |             Place::Ptr(p) => Place::Ptr(p.snapshot(ctx)),
[00:30:34]     |
[00:30:34]     = help: items from traits can only be used if the trait is implemented and in scope
[00:30:34]     = help: items from traits can only be used if the trait is implemented and in scope
[00:30:34]     = note: the following trait defines an item `snapshot`, perhaps you need to implement it:
[00:30:34]             candidate #1: `interpret::snapshot::Snapshot`
[00:30:34] 
[00:30:34] error[E0599]: no method named `snapshot` found for type `&interpret::eval_context::LocalValue` in the current scope
[00:30:34]    --> librustc_mir/interpret/snapshot.rs:392:53
[00:30:34]     |
[00:30:34] 392 |             locals: locals.iter().map(|local| local.snapshot(ctx)).collect(),
[00:30:34]     |
[00:30:34]     = help: items from traits can only be used if the trait is implemented and in scope
[00:30:34]     = help: items from traits can only be used if the trait is implemented and in scope
[00:30:34]     = note: the following trait defines an item `snapshot`, perhaps you need to implement it:
[00:30:34]             candidate #1: `interpret::snapshot::Snapshot`
[00:30:36] error: aborting due to 8 previous errors
[00:30:36] 
[00:30:36] For more information about this error, try `rustc --explain E0599`.
[00:30:36] error: Could not compile `rustc_mir`.
---
travis_time:end:0262f2c0:start=1540568424284202950,finish=1540568424290020583,duration=5817633
travis_fold:end:after_failure.2
travis_fold:start:after_failure.3
travis_time:start:0cc2f506
$ find $HOME/Library/Logs/DiagnosticReports -type f -name '*.crash' -not -name '*.stage2-*.crash' -not -name 'com.apple.CoreSimulator.CoreSimulatorServitravis_time:start:0b141949
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:058bb33e
travis_time:start:058bb33e
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:0bbe273f
$ 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)

@estebank estebank force-pushed the estebank:macro-rep branch from 2915cc7 to 8e288c4 Oct 26, 2018

@rust-highfive

This comment was marked as resolved.

Collaborator

rust-highfive commented Oct 26, 2018

The job x86_64-gnu-llvm-5.0 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:end:2accea05:start=1540571271866295998,finish=1540571331713735577,duration=59847439579
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
---
[00:48:59] .................................................................................................... 2200/4955
[00:49:03] .................................................................................................... 2300/4955
[00:49:07] .................................................................................................... 2400/4955
[00:49:10] .................................................................................................... 2500/4955
[00:49:14] .......................................................iiiiiiiii.................................... 2600/4955
[00:49:20] .....ii............................................................................................. 2800/4955
[00:49:23] .................................................................................................... 2900/4955
[00:49:27] ..................................................................................................i. 3000/4955
[00:49:29] .................................................................................................... 3100/4955
---
[00:52:12] .................................................................................................... 1000/2869
[00:52:24] .................................................................................................... 1100/2869
[00:52:33] .................................................................................................... 1200/2869
[00:52:43] .................................................................................................... 1300/2869
[00:52:55] ........................................................................i...........F............... 1400/2869
[00:53:20] .........................................i.......................................................... 1600/2869
[00:53:34] .................................................................................................... 1700/2869
[00:53:34] .................................................................................................... 1700/2869
[00:53:46] ................................................F................................................... 1800/2869
[00:54:09] .....................................i.............................................................. 2000/2869
[00:54:32] .................................................................................................... 2100/2869
[00:54:39] ...................................................................................................i 2200/2869
[00:54:56] i.....................................................................i....i........................ 2300/2869
---
[00:56:18] failures:
[00:56:18] 
[00:56:18] ---- [run-pass] run-pass/issues/issue-33185.rs stdout ----
[00:56:18] 
[00:56:18] error: test compilation failed although it shouldn't!
[00:56:18] status: exit code: 1
[00:56:18] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/run-pass/issues/issue-33185.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/run-pass/issues/issue-33185/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/run-pass/issues/issue-33185/auxiliary"
[00:56:18] stdout:
[00:56:18] ------------------------------ment in the evaluated repetition\n\n"}
[00:56:18] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:56:18] ------------------------------------------
[00:56:18] 
[00:56:18] thread '[run-pass] run-pass/issues/issue-33185.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3284:9
[00:56:18] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[00:56:18] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[00:56:18] 
[00:56:18] ---- [run-pass] run-pass/macros/macro-first-set.rs stdout ----
[00:56:18] 
[00:56:18] error: test compilation failed although it shouldn't!
[00:56:18] status: exit code: 1
[00:56:18] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/run-pass/macros/macro-first-set.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/run-pass/macros/macro-first-set/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/run-pass/macros/macro-first-set/auxiliary"
[00:56:18] ------------------------------------------
[00:56:18] 
[00:56:18] ------------------------------------------
[00:56:18] stderr:
[00:56:18] stderr:
[00:56:18] ------------------------------------------
[00:56:18] {"message":"`$arg:pat` is followed (through repetition) by itself, which is not allowed for `pat` fragments","code":null,"level":"error","spans":[{"file_name":"/checkout/src/test/run-pass/macros/macro-first-set.rs","byte_start":1194,"byte_end":1202,"line_start":43,"line_end":43,"column_start":21,"column_end":29,"is_primary":true,"text":[{"text":"    ($fname:ident $($arg:pat)* =) => {}","highlight_start":21,"highlight_end":29}],"label":"this fragment is followed by itself without a valid separator","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error: `$arg:pat` is followed (through repetition) by itself, which is not allowed for `pat` fragments\n  --> /checkout/src/test/run-pass/macros/macro-first-set.rs:43:21\n   |\nLL |     ($fname:ident $($arg:pat)* =) => {}\n   |                     ^^^^^^^^ this fragment is followed by itself without a valid separator\n\n"}
[00:56:18] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:56:18] ------------------------------------------
[00:56:18] 
[00:56:18] thread '[run-pass] run-pass/macros/macro-first-set.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3284:9
[00:56:18] 
---
[00:56:18] 
[00:56:18] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:503:22
[00:56:18] 
[00:56:18] 
[00:56:18] 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/run-pass" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "run-pass" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-5.0/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" "5.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"
[00:56:18] 
[00:56:18] 
[00:56:18] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[00:56:18] Build completed unsuccessfully in 0:11:58
[00:56:18] Build completed unsuccessfully in 0:11:58
[00:56:18] Makefile:58: recipe for target 'check' failed
[00:56:18] make: *** [check] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:062efba2
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:022ea39f:start=1540574724432479919,finish=1540574724437323808,duration=4843889
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:05e8d7f4
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:084f9e07
travis_time:start:084f9e07
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:06849b58
$ 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)

@estebank estebank force-pushed the estebank:macro-rep branch from 8e288c4 to e57e5eb Oct 26, 2018

@estebank

This comment has been minimized.

Contributor

estebank commented Oct 26, 2018

@nikomatsakis I fully expect this change to wreak havoc. I wouldn't want to make it a lint because the logic to accomplish that would be much more involved than this change. Is it ok for us to start generating an unsilenceable warning all of a sudden?

@rust-highfive

This comment was marked as resolved.

Collaborator

rust-highfive commented Oct 26, 2018

The job x86_64-gnu-llvm-5.0 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:end:29b35abc:start=1540575235567081098,finish=1540575290297513653,duration=54730432555
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
---
[00:49:20] .................................................................................................... 2200/4955
[00:49:24] .................................................................................................... 2300/4955
[00:49:27] .................................................................................................... 2400/4955
[00:49:31] .................................................................................................... 2500/4955
[00:49:34] .......................................................iiiiiiiii.................................... 2600/4955
[00:49:41] .....ii............................................................................................. 2800/4955
[00:49:44] .................................................................................................... 2900/4955
[00:49:47] ..................................................................................................i. 3000/4955
[00:49:50] .................................................................................................... 3100/4955
---
[00:53:05] ........................................................................i........................... 1400/2869
[00:53:16] .................................................................................................... 1500/2869
[00:53:27] .........................................i.......................................................... 1600/2869
[00:53:41] .................................................................................................... 1700/2869
[00:53:52] ................................................F................................................... 1800/2869
[00:54:13] .....................................i.............................................................. 2000/2869
[00:54:34] .................................................................................................... 2100/2869
[00:54:40] ...................................................................................................i 2200/2869
[00:54:56] i.....................................................................i....i........................ 2300/2869
---
[00:56:15] failures:
[00:56:15] 
[00:56:15] ---- [run-pass] run-pass/macros/macro-first-set.rs stdout ----
[00:56:15] 
[00:56:15] error: test compilation failed although it shouldn't!
[00:56:15] status: exit code: 1
[00:56:15] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/run-pass/macros/macro-first-set.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/run-pass/macros/macro-first-set/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/run-pass/macros/macro-first-set/auxiliary"
[00:56:15] ------------------------------------------
[00:56:15] 
[00:56:15] ------------------------------------------
[00:56:15] stderr:
[00:56:15] stderr:
[00:56:15] ------------------------------------------
[00:56:15] {"message":"`$arg:pat` is followed (through repetition) by itself, which is not allowed for `pat` fragments","code":null,"level":"error","spans":[{"file_name":"/checkout/src/test/run-pass/macros/macro-first-set.rs","byte_start":1194,"byte_end":1202,"line_start":43,"line_end":43,"column_start":21,"column_end":29,"is_primary":true,"text":[{"text":"    ($fname:ident $($arg:pat)* =) => {}","highlight_start":21,"highlight_end":29}],"label":"this fragment is followed by itself without a valid separator","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error: `$arg:pat` is followed (through repetition) by itself, which is not allowed for `pat` fragments\n  --> /checkout/src/test/run-pass/macros/macro-first-set.rs:43:21\n   |\nLL |     ($fname:ident $($arg:pat)* =) => {}\n   |                     ^^^^^^^^ this fragment is followed by itself without a valid separator\n\n"}
[00:56:15] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[00:56:15] ------------------------------------------
[00:56:15] 
[00:56:15] thread '[run-pass] run-pass/macros/macro-first-set.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3284:9
[00:56:15] note: Run with `RUST_BACKTRACE=1` for a backtrace.
---
[00:56:15] 
[00:56:15] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:503:22
[00:56:15] 
[00:56:15] 
[00:56:15] 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/run-pass" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "run-pass" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-5.0/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" "5.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"
[00:56:15] 
[00:56:15] 
[00:56:15] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
travis_time:end:0f103400:start=1540575300221661696,finish=1540578676073297741,duration=3375851636045

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)

@estebank estebank force-pushed the estebank:macro-rep branch from e57e5eb to aff95c7 Oct 26, 2018

@estebank

This comment has been minimized.

Contributor

estebank commented Oct 26, 2018

@Centril Centril added the T-lang label Dec 6, 2018

@dtolnay

@estebank thanks for the ping. Please update the top of thread with a clarification of what "correctly reject" means. Is this now an error? Warning? Unsilenceable warning? EDIT: missed the title :D. I assume the warning is silenceable.

Which fragment types does it apply to? Is $:stmt affected?

macro_rules! m {
    ($($s:stmt)*) => {}
}

m! {
    let a = b
    c!{}
}
@Centril

This comment has been minimized.

Contributor

Centril commented Dec 6, 2018

For the purposes of T-lang review I agree with @dtolnay that it would be good to specify what is linted against in a way that is quickly understandable. For example, it would be good to know what fragment specifiers followed by what other fragment specifiers this applies to.

@estebank estebank changed the title from Warn on incorrect unseparated repetition to Lint on incorrect unseparated repetition Dec 6, 2018

@estebank

This comment has been minimized.

Contributor

estebank commented Dec 6, 2018

Is this now an error? Warning? Unsilenceable warning?

@dtolnay it is a lint. Right now it is warn by default, but I feel it makes sense to merge as allow by default and start working with the community at large to fix existing crates that exploit this loophole. This way we get the code into rustc and we can start warning a couple of releases down the road (while still giving people an escape hatch to continue doing what they're doing now).

Which fragment types does it apply to? Is $:stmt affected?

It affects any repeatable pattern that would be rejected by the parser if it had been written as independent arguments, including the example you wrote.

it would be good to know what fragment specifiers followed by what other fragment specifiers this applies to.

@Centril It follows the same ruleset as the individual non-repeated patterns:

  • expr and stmt variables may only be followed by one of: => , ;
  • ty and path variables may only be followed by one of: => , = | ; : > [ { as where
  • pat variables may only be followed by one of: => , = | if in
  • Other variables may be followed by any token.

Updated the PR description and title to be more descriptive :)

@dtolnay

This comment has been minimized.

Member

dtolnay commented Dec 6, 2018

Sounds good! This is pretty clearly the right behavior. I am on board with a warn-by-default lint or allow-by-default for now depending on the fallout. Do we want to add the usual phased out note? "this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release"

estebank added some commits Oct 26, 2018

@estebank estebank referenced this pull request Dec 6, 2018

Open

tracking issue for incorrect macro fragment repetition #56575

1 of 4 tasks complete

@estebank estebank force-pushed the estebank:macro-rep branch from 74a5f26 to 619ef8c Dec 6, 2018

@estebank

This comment has been minimized.

Contributor

estebank commented Dec 6, 2018

@dtolnay added deprecation message, changed to allow by default and rebased.

@estebank estebank force-pushed the estebank:macro-rep branch from 619ef8c to 096fbb7 Dec 6, 2018

@rust-highfive

This comment was marked as resolved.

Collaborator

rust-highfive commented Dec 6, 2018

The job x86_64-gnu-llvm-5.0 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:end:0094a862:start=1544138237332547585,finish=1544138239674179103,duration=2341631518
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-5.0
---
/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
/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/ff/94/838f88e12e6d3aadb427955e657f3fe3c763ee1ad9290d4601a287fed7d1/awscli-1.16.71-py2.py3-none-any.whl (1.4MB)
    0% |▎                               | 10kB 34.0MB/s eta 0:00:01
    1% |▌                               | 20kB 2.2MB/s eta 0:00:01
    2% |▊                               | 30kB 3.2MB/s eta 0:00:01
    2% |█                               | 40kB 2.1MB/s eta 0:00:01
---

[00:03:13] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:03:13] tidy error: /checkout/src/test/ui/macros/incorrrect-repetition-2.rs: missing trailing newline
[00:03:15] some tidy checks failed
[00:03:15] 
[00:03:15] 
[00:03: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:03:15] 
[00:03:15] 
[00:03:15] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:03:15] Build completed unsuccessfully in 0:00:58
[00:03:15] Build completed unsuccessfully in 0:00:58
[00:03:15] Makefile:79: recipe for target 'tidy' failed
[00:03:15] make: *** [tidy] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0f07c83a
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Thu Dec  6 23:20:44 UTC 2018
---
travis_time:end:13e777ba:start=1544138444920003209,finish=1544138444924962482,duration=4959273
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:1797f135
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:279ddfb9
travis_time:start:279ddfb9
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:303b7a30
$ 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)

@estebank estebank force-pushed the estebank:macro-rep branch from 096fbb7 to f2c74fc Dec 6, 2018

@estebank estebank force-pushed the estebank:macro-rep branch from f2c74fc to fa976ba Dec 7, 2018

@petrochenkov

This comment has been minimized.

Contributor

petrochenkov commented Dec 8, 2018

Sigh, the following token restrictions exist to prevent breakage from extending Rust syntax, but this change alone breaks more code than syntax extensions ever did.

@petrochenkov

This comment has been minimized.

Contributor

petrochenkov commented Dec 8, 2018

It looks like the warning may be reported both at definition crate (when the macro is defined) and at use crate when the macro is loaded?
Could you make sure this doesn't happen and add a test?
(The warning needs to be reported only when macro_rules::compile is called from define_macro.)

@petrochenkov

This comment has been minimized.

Contributor

petrochenkov commented Dec 8, 2018

Also a test making sure that #[allow(incorrect_macro_fragment_repetition)] on the macro item silences the warning for both local crate and clients.

@petrochenkov

This comment has been minimized.

Contributor

petrochenkov commented Dec 8, 2018

Otherwise LGTM.

@withoutboats

This comment has been minimized.

Contributor

withoutboats commented Dec 13, 2018

We discussed this in the lang team meeting today. Overall, we're uncertain that this is worth the churn it will cause. The point of these restrictions is to avoid a lot of breakage when we do extend the expression syntax: are we just frontloading that breakage by adopting this change, defeating the point of the restriction in the first place?

Contrarily, one could argue that if we do ever extend expressions in the future, after Rust's adoption has continued to grow, we might end up breaking a lot more people than this lint will cause problems for.

But overall we were uncertain, so we're throwing it back to the people invested in the PR: this change is definitely correct, but is it worth the breakage to become more correct? Why or why not?

@estebank

This comment has been minimized.

Contributor

estebank commented Dec 13, 2018

Contrarily, one could argue that if we do ever extend expressions in the future, after Rust's adoption has continued to grow, we might end up breaking a lot more people than this lint will cause problems for.

This is exactly the camp where I would fall on. Getting a lint in at the earliest possible moment, even if it is disabled by default for several releases and warn only until the next edition makes it much more likely that breaking this in 2021 will be possible.

this change is definitely correct, but is it worth the breakage to become more correct? Why or why not?

I feel that merging as an allow by default lint is the clear right choice. That way projects that care about it can enable it selectively or opt out of it completely (indefinitely). After that we can work with crates to move away from exploiting this loophole. I don't think this lint should be deny-by-default unless it is part of a new edition.

Alternatively, we could explicitly allow some particular use cases, like repeated bare types and literals in expr arguments (enabling the common use in rustc), while disallowing/warning of plainly incorrect usage on use, not definition like we do here...

@bors

This comment has been minimized.

Contributor

bors commented Dec 15, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment