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

Fix issue #64732 #64783

Merged
merged 2 commits into from
Sep 27, 2019
Merged

Fix issue #64732 #64783

merged 2 commits into from
Sep 27, 2019

Conversation

onehr
Copy link
Contributor

@onehr onehr commented Sep 25, 2019

Based on issue #64732, when creating a byte literal with single quotes,
the suggestion message would indicate that you meant to write a str literal,
but we actually meant to write a byte string literal.

So I changed the unescape_error_reporting.rs to decide whether to print out
"if you meant to write a str literal, use double quotes",
or "if you meant to write a byte string literal, use double quotes".

Fixes #64732.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @petrochenkov (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 25, 2019
@varkor varkor assigned varkor and unassigned petrochenkov Sep 25, 2019
@varkor
Copy link
Member

varkor commented Sep 25, 2019

@onehr: thanks, this looks good! Could you add a test somewhere in src/test/ui to make sure it's working correctly? After you add the test, you can run x.py test src/test/ui/<TEST> --bless to generate the output file and make sure it's passing. The rustc guide has more detailed help.

@onehr
Copy link
Contributor Author

onehr commented Sep 25, 2019

@varkor Thanks for your help! So do I need to put the test into any specific file or it's ok to create a new one and name it?

@varkor
Copy link
Member

varkor commented Sep 25, 2019

You can create a new one. If you can come up with a relevant name, you can put it under src/test/ui directly, or if not, you can just create a new test at src/test/ui/issues/issue-64732.rs.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-09-26T00:22:33.8989149Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-09-26T00:22:33.9179110Z ##[command]git config gc.auto 0
2019-09-26T00:22:33.9303725Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-09-26T00:22:33.9340285Z ##[command]git config --get-all http.proxy
2019-09-26T00:22:33.9513131Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/64783/merge:refs/remotes/pull/64783/merge
---
2019-09-26T00:29:28.7752104Z    Compiling serde_json v1.0.40
2019-09-26T00:29:30.6474224Z    Compiling tidy v0.1.0 (/checkout/src/tools/tidy)
2019-09-26T00:29:41.7428418Z     Finished release [optimized] target(s) in 1m 28s
2019-09-26T00:29:41.7496461Z tidy check
2019-09-26T00:29:41.9917086Z tidy error: /checkout/src/test/ui/issues/issue-64732.rs:5: trailing whitespace
2019-09-26T00:29:41.9917464Z tidy error: /checkout/src/test/ui/issues/issue-64732.rs:6: trailing whitespace
2019-09-26T00:29:43.8034432Z some tidy checks failed
2019-09-26T00:29:43.8034591Z 
2019-09-26T00:29:43.8034591Z 
2019-09-26T00:29:43.8036282Z 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"
2019-09-26T00:29:43.8036428Z 
2019-09-26T00:29:43.8036495Z 
2019-09-26T00:29:43.8055971Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
2019-09-26T00:29:43.8056068Z Build completed unsuccessfully in 0:01:31
2019-09-26T00:29:43.8056068Z Build completed unsuccessfully in 0:01:31
2019-09-26T00:29:43.8109049Z == clock drift check ==
2019-09-26T00:29:43.8123399Z   local time: Thu Sep 26 00:29:43 UTC 2019
2019-09-26T00:29:43.9646918Z   network time: Thu, 26 Sep 2019 00:29:43 GMT
2019-09-26T00:29:43.9650475Z == end clock drift check ==
2019-09-26T00:29:45.5624882Z ##[error]Bash exited with code '1'.
2019-09-26T00:29:45.5666858Z ##[section]Starting: Checkout
2019-09-26T00:29:45.5669874Z ==============================================================================
2019-09-26T00:29:45.5669941Z Task         : Get sources
2019-09-26T00:29:45.5669990Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

Based on issue #64732, when creating a byte literal with single quotes,
the suggestion message would indicate that you meant to write a `str` literal,
but we actually meant to write a byte string literal.

So I changed the unescape_error_reporting.rs to decide whether to print out
"if you meant to write a `str` literal, use double quotes",
or "if you meant to write a byte string literal, use double quotes".
@onehr
Copy link
Contributor Author

onehr commented Sep 26, 2019

Hi @varkor, I have changed the code based on your review and added the test case for it, can you give it a check?

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-09-26T00:49:31.6386958Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-09-26T00:49:31.6600046Z ##[command]git config gc.auto 0
2019-09-26T00:49:31.6696122Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-09-26T00:49:31.6750524Z ##[command]git config --get-all http.proxy
2019-09-26T00:49:31.6917684Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/64783/merge:refs/remotes/pull/64783/merge
---
2019-09-26T00:56:43.5665815Z    Compiling serde_json v1.0.40
2019-09-26T00:56:45.5053779Z    Compiling tidy v0.1.0 (/checkout/src/tools/tidy)
2019-09-26T00:56:57.2447643Z     Finished release [optimized] target(s) in 1m 34s
2019-09-26T00:56:57.2555653Z tidy check
2019-09-26T00:56:57.5010705Z tidy error: /checkout/src/test/ui/issues/issue-64732.rs:5: trailing whitespace
2019-09-26T00:56:57.5011104Z tidy error: /checkout/src/test/ui/issues/issue-64732.rs:6: trailing whitespace
2019-09-26T00:56:59.3624785Z some tidy checks failed
2019-09-26T00:56:59.3632067Z 
2019-09-26T00:56:59.3632067Z 
2019-09-26T00:56:59.3633212Z 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"
2019-09-26T00:56:59.3633748Z 
2019-09-26T00:56:59.3633952Z 
2019-09-26T00:56:59.3638577Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
2019-09-26T00:56:59.3638857Z Build completed unsuccessfully in 0:01:37
2019-09-26T00:56:59.3638857Z Build completed unsuccessfully in 0:01:37
2019-09-26T00:56:59.3690747Z == clock drift check ==
2019-09-26T00:56:59.3703246Z   local time: Thu Sep 26 00:56:59 UTC 2019
2019-09-26T00:56:59.5207204Z   network time: Thu, 26 Sep 2019 00:56:59 GMT
2019-09-26T00:56:59.5209669Z == end clock drift check ==
2019-09-26T00:57:00.9631833Z ##[error]Bash exited with code '1'.
2019-09-26T00:57:00.9670991Z ##[section]Starting: Checkout
2019-09-26T00:57:00.9672886Z ==============================================================================
2019-09-26T00:57:00.9672942Z Task         : Get sources
2019-09-26T00:57:00.9673004Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-09-26T01:22:01.2323584Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-09-26T01:22:01.2562191Z ##[command]git config gc.auto 0
2019-09-26T01:22:01.9724239Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-09-26T01:22:01.9732628Z ##[command]git config --get-all http.proxy
2019-09-26T01:22:01.9736083Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/64783/merge:refs/remotes/pull/64783/merge
---
2019-09-26T02:26:39.2323568Z .................................................................................................... 1500/9045
2019-09-26T02:26:45.3853183Z .................................................................................................... 1600/9045
2019-09-26T02:26:58.1543555Z ..........................................................................i...............i......... 1700/9045
2019-09-26T02:27:05.1269093Z .................................................................................................... 1800/9045
2019-09-26T02:27:14.0280454Z .................................................................iiiii.............................. 1900/9045
2019-09-26T02:27:34.1044563Z .................................................................................................... 2100/9045
2019-09-26T02:27:36.7558208Z .................................................................................................... 2200/9045
2019-09-26T02:27:40.0185355Z .................................................................................................... 2300/9045
2019-09-26T02:27:48.6618926Z .................................................................................................... 2400/9045
---
2019-09-26T02:30:53.2771122Z ........................................................i...............i........................... 4700/9045
2019-09-26T02:31:02.7252063Z .................................................................................................... 4800/9045
2019-09-26T02:31:11.4539404Z .................................................................................................... 4900/9045
2019-09-26T02:31:19.0161911Z .......................................F............................................................ 5000/9045
2019-09-26T02:31:29.0391901Z ............................................ii.ii................................................... 5100/9045
2019-09-26T02:31:39.3005992Z .................................................................................................... 5300/9045
2019-09-26T02:31:49.7871346Z .................................................................................................... 5400/9045
2019-09-26T02:31:57.7497309Z .........i.......................................................................................... 5500/9045
2019-09-26T02:32:03.3157764Z .................................................................................................... 5600/9045
2019-09-26T02:32:03.3157764Z .................................................................................................... 5600/9045
2019-09-26T02:32:15.5075182Z .................................................................................................... 5700/9045
2019-09-26T02:32:28.4614499Z ....ii...i..ii...........i.......................................................................... 5800/9045
2019-09-26T02:32:50.7005212Z .................................................................................................... 6000/9045
2019-09-26T02:33:00.2668591Z .................................................................................................... 6100/9045
2019-09-26T02:33:00.2668591Z .................................................................................................... 6100/9045
2019-09-26T02:33:15.0561601Z ......i..ii......................................................................................... 6200/9045
2019-09-26T02:33:34.7282667Z ..................................................................i................................. 6400/9045
2019-09-26T02:33:37.0020855Z .................................................................................................... 6500/9045
2019-09-26T02:33:39.6043136Z ......................................i............................................................. 6600/9045
2019-09-26T02:33:43.7259111Z .................................................................................................... 6700/9045
---
2019-09-26T02:34:40.1641067Z .................................................................................................... 7200/9045
2019-09-26T02:34:45.7278998Z .................................................................................................... 7300/9045
2019-09-26T02:34:53.5303541Z .................................................................................................... 7400/9045
2019-09-26T02:35:04.0915021Z .................................................................................................... 7500/9045
2019-09-26T02:35:14.3112607Z ..........................................................................................ii......i. 7600/9045
2019-09-26T02:35:25.7504124Z .................................................................................................... 7800/9045
2019-09-26T02:35:42.8536943Z .................................................................................................... 7900/9045
2019-09-26T02:35:51.7794125Z .................................................................................................... 8000/9045
2019-09-26T02:36:01.9563747Z .................................................................................................... 8100/9045
---
2019-09-26T02:37:56.4012146Z 
2019-09-26T02:37:56.4012951Z ---- [ui] ui/issues/issue-64732.rs stdout ----
2019-09-26T02:37:56.4013225Z diff of stderr:
2019-09-26T02:37:56.4013411Z 
2019-09-26T02:37:56.4013625Z 11 error: character literal may only contain one codepoint
2019-09-26T02:37:56.4014080Z 12   --> $DIR/issue-64732.rs:6:16
2019-09-26T02:37:56.4014349Z 13    |
2019-09-26T02:37:56.4014777Z - LL |     let _bar = 'hello';    
2019-09-26T02:37:56.4015230Z + LL |     let _bar = 'hello';
2019-09-26T02:37:56.4015474Z 15    |                ^^^^^^^
2019-09-26T02:37:56.4015660Z 16 help: if you meant to write a `str` literal, use double quotes
2019-09-26T02:37:56.4016021Z 
2019-09-26T02:37:56.4016021Z 
2019-09-26T02:37:56.4016439Z - LL |     let _bar = "hello";    
2019-09-26T02:37:56.4016659Z + LL |     let _bar = "hello";
2019-09-26T02:37:56.4017026Z 20 
2019-09-26T02:37:56.4017224Z 21 error: aborting due to 2 previous errors
2019-09-26T02:37:56.4017637Z 
2019-09-26T02:37:56.4017856Z 
2019-09-26T02:37:56.4017856Z 
2019-09-26T02:37:56.4018037Z The actual stderr differed from the expected stderr.
2019-09-26T02:37:56.4018610Z Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-64732/issue-64732.stderr
2019-09-26T02:37:56.4019149Z To update references, rerun the tests and pass the `--bless` flag
2019-09-26T02:37:56.4020259Z To only update this specific test, also pass `--test-args issues/issue-64732.rs`
2019-09-26T02:37:56.4020769Z error: 1 errors occurred comparing output.
2019-09-26T02:37:56.4020942Z status: exit code: 1
2019-09-26T02:37:56.4020942Z status: exit code: 1
2019-09-26T02:37:56.4021987Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/issues/issue-64732.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-64732" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-64732/auxiliary" "-A" "unused"
2019-09-26T02:37:56.4023020Z ------------------------------------------
2019-09-26T02:37:56.4023231Z 
2019-09-26T02:37:56.4023656Z ------------------------------------------
2019-09-26T02:37:56.4024030Z stderr:
2019-09-26T02:37:56.4024030Z stderr:
2019-09-26T02:37:56.4024547Z ------------------------------------------
2019-09-26T02:37:56.4025581Z error: character literal may only contain one codepoint
2019-09-26T02:37:56.4025957Z   --> /checkout/src/test/ui/issues/issue-64732.rs:3:17
2019-09-26T02:37:56.4026017Z    |
2019-09-26T02:37:56.4026273Z LL |     let _foo = b'hello\0';
2019-09-26T02:37:56.4026327Z    |                 ^^^^^^^^^
2019-09-26T02:37:56.4026381Z help: if you meant to write a byte string literal, use double quotes
2019-09-26T02:37:56.4026432Z    |
2019-09-26T02:37:56.4026496Z LL |     let _foo = b"hello\0";
2019-09-26T02:37:56.4026597Z 
2019-09-26T02:37:56.4026597Z 
2019-09-26T02:37:56.4026664Z error: character literal may only contain one codepoint
2019-09-26T02:37:56.4026940Z   --> /checkout/src/test/ui/issues/issue-64732.rs:6:16
2019-09-26T02:37:56.4026993Z    |
2019-09-26T02:37:56.4027217Z LL |     let _bar = 'hello';
2019-09-26T02:37:56.4027285Z    |                ^^^^^^^
2019-09-26T02:37:56.4027340Z help: if you meant to write a `str` literal, use double quotes
2019-09-26T02:37:56.4027389Z    |
2019-09-26T02:37:56.4027454Z LL |     let _bar = "hello";
2019-09-26T02:37:56.4027533Z 
2019-09-26T02:37:56.4027581Z error: aborting due to 2 previous errors
2019-09-26T02:37:56.4027629Z 
2019-09-26T02:37:56.4027657Z 
---
2019-09-26T02:37:56.4053801Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:537:22
2019-09-26T02:37:56.4053920Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-09-26T02:37:56.4067523Z 
2019-09-26T02:37:56.4067631Z 
2019-09-26T02:37:56.4071457Z 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/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.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"
2019-09-26T02:37:56.4072063Z 
2019-09-26T02:37:56.4072118Z 
2019-09-26T02:37:56.4083592Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-09-26T02:37:56.4083835Z Build completed unsuccessfully in 1:08:35
2019-09-26T02:37:56.4083835Z Build completed unsuccessfully in 1:08:35
2019-09-26T02:37:56.4138934Z == clock drift check ==
2019-09-26T02:37:56.4170743Z   local time: Thu Sep 26 02:37:56 UTC 2019
2019-09-26T02:37:56.5677216Z   network time: Thu, 26 Sep 2019 02:37:56 GMT
2019-09-26T02:37:56.5681473Z == end clock drift check ==
2019-09-26T02:37:57.9875011Z ##[error]Bash exited with code '1'.
2019-09-26T02:37:57.9933123Z ##[section]Starting: Checkout
2019-09-26T02:37:57.9935474Z ==============================================================================
2019-09-26T02:37:57.9935525Z Task         : Get sources
2019-09-26T02:37:57.9935566Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@varkor
Copy link
Member

varkor commented Sep 26, 2019

@onehr: that's perfect, thanks for fixing this issue!

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Sep 26, 2019

📌 Commit a048447 has been approved by varkor

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 26, 2019
Centril added a commit to Centril/rust that referenced this pull request Sep 26, 2019
Fix issue rust-lang#64732

Based on issue rust-lang#64732, when creating a byte literal with single quotes,
the suggestion message would indicate that you meant to write a `str` literal,
but we actually meant to write a byte string literal.

So I changed the unescape_error_reporting.rs to decide whether to print out
"if you meant to write a `str` literal, use double quotes",
or "if you meant to write a byte string literal, use double quotes".

Fixes rust-lang#64732.
bors added a commit that referenced this pull request Sep 26, 2019
Rollup of 5 pull requests

Successful merges:

 - #64221 ( Rust 2015: No longer downgrade NLL errors)
 - #64772 (Remove tx_to_llvm_workers from TyCtxt)
 - #64783 (Fix issue #64732)
 - #64787 (Fix ExitStatus on Fuchsia)
 - #64812 (Add test for E0543)

Failed merges:

r? @ghost
bors added a commit that referenced this pull request Sep 26, 2019
Rollup of 5 pull requests

Successful merges:

 - #64221 ( Rust 2015: No longer downgrade NLL errors)
 - #64772 (Remove tx_to_llvm_workers from TyCtxt)
 - #64783 (Fix issue #64732)
 - #64787 (Fix ExitStatus on Fuchsia)
 - #64812 (Add test for E0543)

Failed merges:

r? @ghost
@bors bors merged commit a048447 into rust-lang:master Sep 27, 2019
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.

Incorrect error message for byte literal with single quotes
5 participants