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

Add error for trailing angle brackets. #57817

Merged
merged 3 commits into from Jan 24, 2019

Conversation

Projects
None yet
4 participants
@davidtwco
Copy link
Member

davidtwco commented Jan 21, 2019

Fixes #54521.

This PR adds a error (and accompanying machine applicable
suggestion) for trailing angle brackets on function calls with a
turbofish.

r? @estebank

@davidtwco

This comment has been minimized.

Copy link
Member Author

davidtwco commented Jan 21, 2019

I think you can change this to use any instead of map().unwrap_or().

I might be missing something, but I don't think I can because this is a Option<P<GenericArgs>>?

@estebank

This comment has been minimized.

Copy link
Contributor

estebank commented Jan 21, 2019

I might be missing something, but I don't think I can because this is a Option<P>?

Ah, you're right. I thought it was something like Vec<P<GenericArg>>. Carry on.

@estebank

This comment was marked as outdated.

Copy link
Contributor

estebank commented Jan 21, 2019

r=me once travis finishes

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented Jan 21, 2019

The job x86_64-gnu-llvm-6.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:17a19948:start=1548102614365033087,finish=1548102692808555072,duration=78443521985
$ 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-6.0
---

[00:03:24] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:03:25] tidy error: /checkout/src/libsyntax/parse/parser.rs:2792: unexplained "```ignore" doctest; try one:
[00:03:25] 
[00:03:25] * make the test actually pass, by adding necessary imports and declarations, or
[00:03:25] * use "```text", if the code is not Rust code, or
[00:03:25] * use "```compile_fail,Ennnn", if the code is expected to fail at compile time, or
[00:03:25] * use "```should_panic", if the code is expected to fail at run time, or
[00:03:25] * use "```no_run", if the code should type-check but not necessary linkable/runnable, or
[00:03:25] * explain it like "```ignore (cannot-test-this-because-xxxx)", if the annotation cannot be avoided.
[00:03:25] 
[00:03:26] some tidy checks failed
[00:03:26] 
[00:03:26] 
[00:03:26] 
[00:03:26] 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:26] 
[00:03:26] 
[00:03:26] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:03:26] Build completed unsuccessfully in 0:00:46
[00:03:26] Build completed unsuccessfully in 0:00:46
[00:03:26] make: *** [tidy] Error 1
[00:03:26] Makefile:69: recipe for target 'tidy' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0011f503
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Mon Jan 21 20:35:08 UTC 2019
---
travis_time:end:0624ec66:start=1548102908829143724,finish=1548102908833488527,duration=4344803
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0b0094cc
$ 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:14eda240
travis_time:start:14eda240
$ 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:0128c4c6
$ 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)

davidtwco added some commits Jan 21, 2019

Add error for trailing angle brackets.
This commit adds a error (and accompanying machine applicable
suggestion) for trailing angle brackets on function calls with a
turbofish.
Pluralize error messages.
This commit pluralizes error messages when more than a single trailing
`>` character is present.
Extend trailing `>` detection for paths.
This commit extends the trailing `>` detection to also work for paths
such as `Foo::<Bar>>:Baz`.

This involves making the existing check take the token that is expected
to follow the path being checked as a parameter.

Care is taken to ensure that this only happens on the construction of a
whole path segment and not a partial path segment (during recursion).

Through this enhancement, it was also observed that the ordering of
right shift token and greater than tokens was overfitted to the examples
being tested.

In practice, given a sequence of `>` characters: `>>>>>>>>>`
..then they will be split into `>>` eagerly: `>> >> >> >> >`.
..but when a `<` is prepended, then the first `>>` is split:
`<T> > >> >> >> >`
..and then when another `<` is prepended, a right shift is first again:
`Vec<<T>> >> >> >> >`

In the previous commits, a example that had two `<<` characters was
always used and therefore it was incorrectly assumed that `>>` would
always be first - but when there is a single `<`, this is not the case.

@davidtwco davidtwco force-pushed the davidtwco:issue-54521 branch from d8dbb3b to 914d142 Jan 21, 2019

@davidtwco
Copy link
Member Author

davidtwco left a comment

@estebank I've added a new commit handling another case, would appreciate if you could re-review.

//
// `PathStyle::Expr` is only provided at the root invocation and never in
// `parse_path_segment` to recurse and therefore can be checked to maintain
// this invariant.

This comment has been minimized.

@davidtwco

davidtwco Jan 21, 2019

Author Member

@estebank do you know if this last sentence is accurate? It works and passes tests but I'm not sure if PathStyle::Expr was intended to make this condition hold.

This comment has been minimized.

@estebank

estebank Jan 22, 2019

Contributor

It should be ok.

@estebank

This comment has been minimized.

Copy link
Contributor

estebank commented Jan 22, 2019

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 22, 2019

📌 Commit 914d142 has been approved by estebank

Centril added a commit to Centril/rust that referenced this pull request Jan 23, 2019

Rollup merge of rust-lang#57817 - davidtwco:issue-54521, r=estebank
Add error for trailing angle brackets.

Fixes rust-lang#54521.

This PR adds a error (and accompanying machine applicable
suggestion) for trailing angle brackets on function calls with a
turbofish.

r? @estebank

bors added a commit that referenced this pull request Jan 23, 2019

Auto merge of #57850 - Centril:rollup, r=Centril
Rollup of 8 pull requests

Successful merges:

 - #55448 (Add 'partition_at_index/_by/_by_key' for slices.)
 - #57179 (Update std/lib.rs docs to reflect Rust 2018 usage)
 - #57730 (Merge visitors in AST validation)
 - #57779 (Recover from parse errors in literal struct fields and incorrect float literals)
 - #57793 (Explain type mismatch cause pointing to return type when it is `impl Trait`)
 - #57795 (Use structured suggestion in stead of notes)
 - #57817 (Add error for trailing angle brackets.)
 - #57834 (Stabilize Any::get_type_id and rename to type_id)

Failed merges:

r? @ghost

bors added a commit that referenced this pull request Jan 23, 2019

Auto merge of #57850 - Centril:rollup, r=Centril
Rollup of 8 pull requests

Successful merges:

 - #55448 (Add 'partition_at_index/_by/_by_key' for slices.)
 - #57179 (Update std/lib.rs docs to reflect Rust 2018 usage)
 - #57730 (Merge visitors in AST validation)
 - #57779 (Recover from parse errors in literal struct fields and incorrect float literals)
 - #57793 (Explain type mismatch cause pointing to return type when it is `impl Trait`)
 - #57795 (Use structured suggestion in stead of notes)
 - #57817 (Add error for trailing angle brackets.)
 - #57834 (Stabilize Any::get_type_id and rename to type_id)

Failed merges:

r? @ghost

bors added a commit that referenced this pull request Jan 23, 2019

Auto merge of #57850 - Centril:rollup, r=Centril
Rollup of 8 pull requests

Successful merges:

 - #55448 (Add 'partition_at_index/_by/_by_key' for slices.)
 - #57179 (Update std/lib.rs docs to reflect Rust 2018 usage)
 - #57730 (Merge visitors in AST validation)
 - #57779 (Recover from parse errors in literal struct fields and incorrect float literals)
 - #57793 (Explain type mismatch cause pointing to return type when it is `impl Trait`)
 - #57795 (Use structured suggestion in stead of notes)
 - #57817 (Add error for trailing angle brackets.)
 - #57834 (Stabilize Any::get_type_id and rename to type_id)

Failed merges:

r? @ghost

bors added a commit that referenced this pull request Jan 23, 2019

Auto merge of #57850 - Centril:rollup, r=Centril
Rollup of 8 pull requests

Successful merges:

 - #55448 (Add 'partition_at_index/_by/_by_key' for slices.)
 - #57179 (Update std/lib.rs docs to reflect Rust 2018 usage)
 - #57730 (Merge visitors in AST validation)
 - #57779 (Recover from parse errors in literal struct fields and incorrect float literals)
 - #57793 (Explain type mismatch cause pointing to return type when it is `impl Trait`)
 - #57795 (Use structured suggestion in stead of notes)
 - #57817 (Add error for trailing angle brackets.)
 - #57834 (Stabilize Any::get_type_id and rename to type_id)

Failed merges:

r? @ghost

Centril added a commit to Centril/rust that referenced this pull request Jan 23, 2019

Rollup merge of rust-lang#57817 - davidtwco:issue-54521, r=estebank
Add error for trailing angle brackets.

Fixes rust-lang#54521.

This PR adds a error (and accompanying machine applicable
suggestion) for trailing angle brackets on function calls with a
turbofish.

r? @estebank

bors added a commit that referenced this pull request Jan 24, 2019

Auto merge of #57869 - Centril:rollup, r=Centril
Rollup of 11 pull requests

Successful merges:

 - #57179 (Update std/lib.rs docs to reflect Rust 2018 usage)
 - #57730 (Merge visitors in AST validation)
 - #57779 (Recover from parse errors in literal struct fields and incorrect float literals)
 - #57793 (Explain type mismatch cause pointing to return type when it is `impl Trait`)
 - #57795 (Use structured suggestion in stead of notes)
 - #57817 (Add error for trailing angle brackets.)
 - #57834 (Stabilize Any::get_type_id and rename to type_id)
 - #57836 (Fix some cross crate existential type ICEs)
 - #57840 (Fix issue 57762)
 - #57844 (use port 80 for retrieving GPG key)
 - #57858 (Ignore line ending on older git versions)

Failed merges:

r? @ghost
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 24, 2019

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

@bors bors merged commit 914d142 into rust-lang:master Jan 24, 2019

@davidtwco davidtwco deleted the davidtwco:issue-54521 branch Jan 24, 2019

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