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

Suggest trait bound on type parameter when it is unconstrained #62772

Merged
merged 1 commit into from Jul 24, 2019

Conversation

@estebank
Copy link
Contributor

commented Jul 17, 2019

Given

trait Foo { fn method(&self) {} }

fn call_method<T>(x: &T) {
    x.method()
}

suggest constraining T with Foo.

Fix #21673, fix #41030.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Jul 17, 2019

r? @matthewjasper

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

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

commented Jul 18, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed (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-07-17T23:36:12.3598657Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-07-17T23:36:12.3791362Z ##[command]git config gc.auto 0
2019-07-17T23:36:12.3863584Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-07-17T23:36:12.3911570Z ##[command]git config --get-all http.proxy
2019-07-17T23:36:12.4049729Z ##[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/62772/merge:refs/remotes/pull/62772/merge
---
2019-07-17T23:36:46.6332465Z do so (now or later) by using -b with the checkout command again. Example:
2019-07-17T23:36:46.6332868Z 
2019-07-17T23:36:46.6333215Z   git checkout -b <new-branch-name>
2019-07-17T23:36:46.6333429Z 
2019-07-17T23:36:46.6333619Z HEAD is now at 918f46cb8 Merge dd24ac173c6fc84cd1318dd07c9d75bc911f15b4 into bc2e84ca0939b73fcf1768209044432f6a15c2e5
2019-07-17T23:36:46.6463579Z ##[section]Starting: Collect CPU-usage statistics in the background
2019-07-17T23:36:46.6466895Z ==============================================================================
2019-07-17T23:36:46.6466943Z Task         : Bash
2019-07-17T23:36:46.6466981Z Description  : Run a Bash script on macOS, Linux, or Windows
---
2019-07-18T00:10:41.5710978Z    Compiling syntax_ext v0.0.0 (/checkout/src/libsyntax_ext)
2019-07-18T00:17:27.5756265Z    Compiling rustc_allocator v0.0.0 (/checkout/src/librustc_allocator)
2019-07-18T00:18:36.1156666Z    Compiling rustc_mir v0.0.0 (/checkout/src/librustc_mir)
2019-07-18T00:19:57.0039373Z    Compiling rustc_typeck v0.0.0 (/checkout/src/librustc_typeck)
2019-07-18T00:20:04.6795493Z error: usage of `ty::TyKind::<kind>`
2019-07-18T00:20:04.6796638Z    --> src/librustc_typeck/check/method/suggest.rs:689:17
2019-07-18T00:20:04.6797080Z     |
2019-07-18T00:20:04.6797714Z 689 |                 ty::TyKind::Param(param) => Some(param),
2019-07-18T00:20:04.6798131Z     |                 ^^^^^^^^^^ help: try using ty::<kind> directly: `ty`
2019-07-18T00:20:04.6798490Z     |
2019-07-18T00:20:04.6799333Z     = note: `-D rustc::usage-of-ty-tykind` implied by `-D rustc::internal`
2019-07-18T00:20:04.6799554Z 
2019-07-18T00:20:04.6799866Z error: usage of `ty::TyKind::<kind>`
2019-07-18T00:20:04.6800233Z    --> src/librustc_typeck/check/method/suggest.rs:690:17
2019-07-18T00:20:04.6800552Z     |
2019-07-18T00:20:04.6800909Z 690 |                 ty::TyKind::Ref(_, ty, _) => match ty.sty {
2019-07-18T00:20:04.6801340Z     |                 ^^^^^^^^^^ help: try using ty::<kind> directly: `ty`
2019-07-18T00:20:04.6801565Z 
2019-07-18T00:20:04.6801878Z error: usage of `ty::TyKind::<kind>`
2019-07-18T00:20:04.6802225Z    --> src/librustc_typeck/check/method/suggest.rs:691:21
2019-07-18T00:20:04.6802523Z     |
2019-07-18T00:20:04.6803154Z 691 |                     ty::TyKind::Param(param) => Some(param),
2019-07-18T00:20:04.6803594Z     |                     ^^^^^^^^^^ help: try using ty::<kind> directly: `ty`
2019-07-18T00:20:04.8161629Z error: aborting due to 3 previous errors
2019-07-18T00:20:04.8162394Z 
2019-07-18T00:20:04.8997900Z error: Could not compile `rustc_typeck`.
2019-07-18T00:20:04.8998980Z warning: build failed, waiting for other jobs to finish...
2019-07-18T00:20:04.8998980Z warning: build failed, waiting for other jobs to finish...
2019-07-18T00:23:05.5923250Z error: build failed
2019-07-18T00:23:05.5944924Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "-j" "2" "--release" "--locked" "--color" "always" "--features" "" "--manifest-path" "/checkout/src/rustc/Cargo.toml" "--message-format" "json"
2019-07-18T00:23:05.5945067Z expected success, got: exit code: 101
2019-07-18T00:23:05.5956811Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-07-18T00:23:05.5957005Z Build completed unsuccessfully in 0:40:12
2019-07-18T00:23:07.3077199Z ##[error]Bash exited with code '1'.
2019-07-18T00:23:07.3138603Z ##[section]Starting: Checkout
2019-07-18T00:23:07.3140042Z ==============================================================================
2019-07-18T00:23:07.3140088Z Task         : Get sources
2019-07-18T00:23:07.3140125Z 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)

Suggest trait bound on type parameter when it is unconstrained
Given

```
mented on Jan 26, 2015 •
 trait Foo { fn method(&self) {} }

fn call_method<T>(x: &T) {
    x.method()
}
```

suggest constraining `T` with `Foo`.

@estebank estebank force-pushed the estebank:trait-bound branch from dd24ac1 to f22bc2d Jul 18, 2019

@matthewjasper

This comment has been minimized.

Copy link
Contributor

commented Jul 20, 2019

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

commented Jul 20, 2019

📌 Commit f22bc2d has been approved by matthewjasper

Centril added a commit to Centril/rust that referenced this pull request Jul 21, 2019

Rollup merge of rust-lang#62772 - estebank:trait-bound, r=matthewjasper
Suggest trait bound on type parameter when it is unconstrained

Given

```
trait Foo { fn method(&self) {} }

fn call_method<T>(x: &T) {
    x.method()
}
```

suggest constraining `T` with `Foo`.

Fix rust-lang#21673, fix rust-lang#41030.

bors added a commit that referenced this pull request Jul 21, 2019

Auto merge of #62840 - Centril:rollup-5ettkjy, r=Centril
Rollup of 11 pull requests

Successful merges:

 - #62709 (Test that maplike FromIter satisfies uniqueness)
 - #62746 ( do not use assume_init in std::io)
 - #62772 (Suggest trait bound on type parameter when it is unconstrained)
 - #62787 (Fix typo in src/libstd/net/udp.rs doc comment)
 - #62788 (normalize use of backticks in compiler messages for libcore/ptr)
 - #62791 (Handle more cases of typos misinterpreted as type ascription)
 - #62804 (rustc_typeck: improve diagnostics for _ const/static declarations)
 - #62808 (Revert "Disable stack probing for gnux32.")
 - #62812 (normalize use of backticks in compiler messages for librustc_metadata)
 - #62813 (rustc: Compile the `fmt_macros` crate as an rlib)
 - #62832 (normalize use of backticks in compiler messages for librustc_incremental)

Failed merges:

r? @ghost

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

Rollup merge of rust-lang#62772 - estebank:trait-bound, r=matthewjasper
Suggest trait bound on type parameter when it is unconstrained

Given

```
trait Foo { fn method(&self) {} }

fn call_method<T>(x: &T) {
    x.method()
}
```

suggest constraining `T` with `Foo`.

Fix rust-lang#21673, fix rust-lang#41030.

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

Auto merge of #62920 - Centril:rollup-1tv95ql, r=Centril
Rollup of 13 pull requests

Successful merges:

 - #61890 (Fix some sanity checks)
 - #62261 (Take substs into account in `conservative_is_privately_uninhabited`)
 - #62528 (Add joining slices of slices with a slice separator, not just a single item)
 - #62692 (rustc: precompute the largest Niche and store it in LayoutDetails.)
 - #62738 (Remove uses of mem::uninitialized from std::sys::cloudabi)
 - #62772 (Suggest trait bound on type parameter when it is unconstrained)
 - #62784 (Add riscv32i-unknown-none-elf target)
 - #62813 (rustc: Compile the `fmt_macros` crate as an rlib)
 - #62814 (add support for hexagon-unknown-linux-musl)
 - #62890 (Normalize use of backticks in compiler messages for libsyntax/*)
 - #62901 (cleanup: Remove `extern crate serialize as rustc_serialize`s)
 - #62905 (Normalize use of backticks in compiler messages for doc)
 - #62908 (normalize use of backticks for compiler messages in remaining modules)

Failed merges:

r? @ghost

Centril added a commit to Centril/rust that referenced this pull request Jul 24, 2019

Rollup merge of rust-lang#62772 - estebank:trait-bound, r=matthewjasper
Suggest trait bound on type parameter when it is unconstrained

Given

```
trait Foo { fn method(&self) {} }

fn call_method<T>(x: &T) {
    x.method()
}
```

suggest constraining `T` with `Foo`.

Fix rust-lang#21673, fix rust-lang#41030.

Centril added a commit to Centril/rust that referenced this pull request Jul 24, 2019

Rollup merge of rust-lang#62935 - Centril:rollup-hzj9att, r=Centril
Rollup of 10 pull requests

Successful merges:

 - rust-lang#62641 (Regenerate character tables for Unicode 12.1)
 - rust-lang#62716 (state also in the intro that UnsafeCell has no effect on &mut)
 - rust-lang#62738 (Remove uses of mem::uninitialized from std::sys::cloudabi)
 - rust-lang#62772 (Suggest trait bound on type parameter when it is unconstrained)
 - rust-lang#62890 (Normalize use of backticks in compiler messages for libsyntax/*)
 - rust-lang#62905 (Normalize use of backticks in compiler messages for doc)
 - rust-lang#62916 (Add test `self-in-enum-definition`)
 - rust-lang#62917 (Always emit trailing slash error)
 - rust-lang#62926 (Fix typo in mem::uninitialized doc)
 - rust-lang#62927 (use PanicMessage in MIR, kill InterpError::description)

Failed merges:

r? @ghost

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

Auto merge of #62935 - Centril:rollup-hzj9att, r=Centril
Rollup of 10 pull requests

Successful merges:

 - #62641 (Regenerate character tables for Unicode 12.1)
 - #62716 (state also in the intro that UnsafeCell has no effect on &mut)
 - #62738 (Remove uses of mem::uninitialized from std::sys::cloudabi)
 - #62772 (Suggest trait bound on type parameter when it is unconstrained)
 - #62890 (Normalize use of backticks in compiler messages for libsyntax/*)
 - #62905 (Normalize use of backticks in compiler messages for doc)
 - #62916 (Add test `self-in-enum-definition`)
 - #62917 (Always emit trailing slash error)
 - #62926 (Fix typo in mem::uninitialized doc)
 - #62927 (use PanicMessage in MIR, kill InterpError::description)

Failed merges:

r? @ghost

@bors bors merged commit f22bc2d into rust-lang:master Jul 24, 2019

4 checks passed

pr Build #20190718.29 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-6.0) Linux x86_64-gnu-llvm-6.0 succeeded
Details
pr (LinuxTools) LinuxTools succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.