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

suggestion-diagnostics: as_ref improve snippet #57451

Merged
merged 1 commit into from
Feb 14, 2019

Conversation

dlrobertson
Copy link
Contributor

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

Given:

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().`

@rust-highfive
Copy link
Collaborator

r? @eddyb

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

@rust-highfive rust-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
Collaborator

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)

@@ -191,7 +192,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
/// ```
/// opt.map(|arg| { takes_ref(arg) });
/// ```
fn can_use_as_ref(&self, expr: &hir::Expr) -> Option<(Span, &'static str, String)> {
fn can_use_as_ref(&self, expr: &hir::Expr, cm: &SourceMap)
-> Option<(Span, &'static str, String)> {
Copy link
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)> {

src/librustc_typeck/check/demand.rs Show resolved Hide resolved
@TimNN TimNN 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
Contributor

TimNN commented Jan 29, 2019

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

@TimNN
Copy link
Contributor

TimNN commented Jan 29, 2019

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

@estebank
Copy link
Contributor

r? @estebank

@rust-highfive rust-highfive assigned estebank and unassigned eddyb Jan 29, 2019
@dlrobertson
Copy link
Contributor Author

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

@dlrobertson dlrobertson force-pushed the can_use_as_ref_nit branch 2 times, most recently from 8015e91 to 47f16e9 Compare February 3, 2019 21:47
@dlrobertson
Copy link
Contributor Author

@estebank updated

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

@estebank estebank left a comment

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 :)

src/librustc_typeck/check/demand.rs Outdated Show resolved Hide resolved
@dlrobertson
Copy link
Contributor Author

@bors r=estebank

@bors
Copy link
Contributor

bors commented Feb 13, 2019

@dlrobertson: 🔑 Insufficient privileges: Not in reviewers

@dlrobertson
Copy link
Contributor Author

dlrobertson commented Feb 13, 2019

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

@estebank
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Feb 13, 2019

📌 Commit 285d4a7 has been approved by estebank

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels 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().`
```
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().`
```
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:master Feb 14, 2019
@dlrobertson dlrobertson deleted the can_use_as_ref_nit branch February 14, 2019 14:48
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.

6 participants