Skip to content

suggestion-diagnostics: as_ref improve snippet - #57451

Merged
bors merged 1 commit into
rust-lang:masterfrom
dlrobertson:can_use_as_ref_nit
Feb 14, 2019
Merged

suggestion-diagnostics: as_ref improve snippet#57451
bors merged 1 commit into
rust-lang:masterfrom
dlrobertson:can_use_as_ref_nit

Conversation

@dlrobertson

Copy link
Copy Markdown
Contributor

Improve the code snippet suggested in suggestion-diagnostics when
suggesting the use of as_ref.

Given:

fntest(x:&usize){}fnmain(){Some(42).map(|x| test(x));}

Suggest

 help: consider using `as_ref` instead: `as_ref().map`

Instead of

 help: consider using `as_ref` instead: `as_ref().`

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @eddyb

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

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 8, 2019
@rust-highfive

Copy link
Copy Markdown
Contributor

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:04ee9a5e:start=1546978089151273248,finish=1546978090321928223,duration=1170654975
$ 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:05:08] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:05:08] tidy error: /checkout/src/librustc_typeck/check/demand.rs:195: line longer than 100 chars
[00:05:10] some tidy checks failed
[00:05:10] [00:05:10] [00:05:10] 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:05:10] [00:05:10] [00:05:10] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:05:10] Build completed unsuccessfully in 0:00:45
[00:05:10] Build completed unsuccessfully in 0:00:45
[00:05:10] Makefile:69: recipe for target 'tidy' failed
[00:05:10] make: *** [tidy] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:094e3067
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Tue Jan 8 20:13:40 UTC 2019
---
travis_time:end:0148d452:start=1546978421677496844,finish=1546978421682105515,duration=4608671
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:03c82578
$ 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:2f41bc7b
travis_time:start:2f41bc7b
$ 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:0247d91f
$ 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)

Comment threadsrc/librustc_typeck/check/demand.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Formatting:

 fn can_use_as_ref(
&self,
expr: &hir::Expr,
cm: &SourceMap,
) -> Option<(Span, &'static str, String)> {

Comment threadsrc/librustc_typeck/check/demand.rs Outdated
@TimNNTimNN added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 29, 2019
@TimNN

Copy link
Copy Markdown
Contributor

Ping from triage @dlrobertson: Some changes have been requested to your PR.

@TimNN

Copy link
Copy Markdown
Contributor

Also, @estebank: Can you review this PR? It seems like @eddyb is unavailable at the moment.

@estebank

Copy link
Copy Markdown
Contributor

r? @estebank

@rust-highfiverust-highfive assigned estebank and unassigned eddybJan 29, 2019
@dlrobertson

Copy link
Copy Markdown
ContributorAuthor

👍 thanks for the ping. I'll look at this tonight.

@dlrobertson
dlrobertsonforce-pushed the can_use_as_ref_nit branch 2 times, most recently from 8015e91 to 47f16e9CompareFebruary 3, 2019 21:47
@dlrobertson

Copy link
Copy Markdown
ContributorAuthor

@estebank updated

Improve the code snippet suggested in suggestion-diagnostics when
suggesting the use of as_ref.

@estebankestebank left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

r=me once the nitpick is addressed :)

Comment threadsrc/librustc_typeck/check/demand.rs Outdated
@dlrobertson

Copy link
Copy Markdown
ContributorAuthor

@bors r=estebank

@bors

bors commented Feb 13, 2019

Copy link
Copy Markdown
Collaborator

@dlrobertson: 🔑 Insufficient privileges: Not in reviewers

@dlrobertson

dlrobertson commented Feb 13, 2019

Copy link
Copy Markdown
ContributorAuthor

@estebank looks like you'll need to r or delegate the PR... Unless I missed something.

@estebank

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Feb 13, 2019

Copy link
Copy Markdown
Collaborator

📌 Commit 285d4a7 has been approved by estebank

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 13, 2019
Centril added a commit to Centril/rust that referenced this pull request Feb 14, 2019
…stebank
suggestion-diagnostics: as_ref improve snippet
Improve the code snippet suggested in suggestion-diagnostics when
suggesting the use of as_ref.
Given:
```rust
fn test(x: &usize) {}
fn main() {
Some(42).map(|x| test(x));
}
```
Suggest
```
help: consider using `as_ref` instead: `as_ref().map`
```
Instead of
```
help: consider using `as_ref` instead: `as_ref().`
```
@CentrilCentril mentioned this pull request Feb 14, 2019
Centril added a commit to Centril/rust that referenced this pull request Feb 14, 2019
…stebank
suggestion-diagnostics: as_ref improve snippet
Improve the code snippet suggested in suggestion-diagnostics when
suggesting the use of as_ref.
Given:
```rust
fn test(x: &usize) {}
fn main() {
Some(42).map(|x| test(x));
}
```
Suggest
```
help: consider using `as_ref` instead: `as_ref().map`
```
Instead of
```
help: consider using `as_ref` instead: `as_ref().`
```
@CentrilCentril mentioned this pull request Feb 14, 2019
bors added a commit that referenced this pull request Feb 14, 2019
Rollup of 8 pull requests
Successful merges:
- #57451 (suggestion-diagnostics: as_ref improve snippet)
- #57856 (Convert old first edition links to current edition one)
- #57992 (Update the future/task API)
- #58258 (Reduce the size of `hir::Expr`.)
- #58267 (Tweak "incompatible match arms" error)
- #58296 (Hidden suggestion support)
- #58301 (Enable comparing fat pointers)
- #58308 (Extract block to insert an intrinsic into its own function)
Failed merges:
r? @ghost
@bors
bors merged commit 285d4a7 into rust-lang:masterFeb 14, 2019
@dlrobertson
dlrobertson deleted the can_use_as_ref_nit branch February 14, 2019 14:48
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: 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.

6 participants

@dlrobertson@rust-highfive@TimNN@estebank@bors@eddyb