Suggest associated type when the specified one cannot be found#67406
Merged
bors merged 1 commit intorust-lang:masterfrom Dec 19, 2019
Merged
Suggest associated type when the specified one cannot be found#67406bors merged 1 commit intorust-lang:masterfrom
bors merged 1 commit intorust-lang:masterfrom
Conversation
e9d418f to
ce57747
Compare
estebank
approved these changes
Dec 18, 2019
Contributor
estebank
left a comment
There was a problem hiding this comment.
It looks good and love the new output.
Left some nitpicks inline.
src/librustc_typeck/astconv.rs
Outdated
Contributor
There was a problem hiding this comment.
Could you clean this up to be a bit terser?
self.one_bound_for_assoc_type(
|| traits::transitive_bounds(tcx, predicates.iter()
.filter_map(|(p, _)| p.to_opt_poly_trait_ref())),
¶m_name.as_str(),
assoc_name,
span,
)
src/librustc_typeck/astconv.rs
Outdated
Comment on lines
1561
to
1596
Contributor
There was a problem hiding this comment.
Could we move all this to a separate method called complain_about_assoc_type_not_found?
ce57747 to
a4a2fc0
Compare
Contributor
|
@bors r+ |
Collaborator
|
📌 Commit a4a2fc0 has been approved by |
Collaborator
|
🌲 The tree is currently closed for pull requests below priority 100, this pull request will be tested once the tree is reopened |
Centril
added a commit
to Centril/rust
that referenced
this pull request
Dec 19, 2019
…ebank Suggest associated type when the specified one cannot be found Fixes rust-lang#67386, so code like this: ``` use std::ops::Deref; fn homura<T: Deref<Trget = i32>>(_: T) {} fn main() {} ``` results in: ``` error[E0220]: associated type `Trget` not found for `std::ops::Deref` --> type-binding.rs:6:20 | 6 | fn homura<T: Deref<Trget = i32>>(_: T) {} | ^^^^^^^^^^^ help: there is an associated type with a similar name: `Target` error: aborting due to previous error ``` (The `help` is new) I used an `all_candidates: impl Fn() -> Iterator<...>` instead of `collect`ing to avoid the cost of allocating the Vec when no errors are found, at the expense of a little added complexity. r? @estebank
bors
added a commit
that referenced
this pull request
Dec 19, 2019
Rollup of 8 pull requests Successful merges: - #67189 (Unify binop wording) - #67270 (std: Implement `LineWriter::write_vectored`) - #67286 (Fix the configure.py TOML field for a couple LLVM options) - #67321 (make htons const fn) - #67382 (Remove some unnecessary `ATTR_*` constants.) - #67389 (Remove `SO_NOSIGPIPE` dummy variable on platforms that don't use it.) - #67394 (Remove outdated references to @t from comments) - #67406 (Suggest associated type when the specified one cannot be found) Failed merges: r? @ghost
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #67386, so code like this:
results in:
(The
helpis new)I used an
all_candidates: impl Fn() -> Iterator<...>instead ofcollecting to avoid the cost of allocating the Vec when no errors are found, at the expense of a little added complexity.r? @estebank