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: wrong trait import suggestion for T: #95991

Merged
merged 1 commit into from
Apr 13, 2022

Conversation

PoorlyDefinedBehaviour
Copy link

@PoorlyDefinedBehaviour PoorlyDefinedBehaviour commented Apr 12, 2022

The suggestion to bound T had an extra :.

fn foo<T:>(t: T) {
  t.clone();
}
error[E0599]: no method named `clone` found for type parameter `T` in the current scope
 --> src/lib.rs:2:7
  |
2 |     t.clone();
  |       ^^^^^ method not found in `T`
  |
  = help: items from traits can only be used if the type parameter is bounded by the trait
help: the following trait defines an item `clone`, perhaps you need to restrict type parameter `T` with it:
  |
1 | fn foo<T: Clone:>(t: T) {
  |        ~~~~~~~~

Fixes: #95898

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 12, 2022
@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 @fee1-dead (or someone else) soon.

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 Apr 12, 2022
/// |
/// here
/// ```
pub fn colon_span_for_suggestions(&self, source_map: &SourceMap) -> Option<Span> {
Copy link
Member

Choose a reason for hiding this comment

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

This might possibly merge-conflict with #95970, since it's duplicated from that. Might want to wait on that landing and rebase.

Choose a reason for hiding this comment

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

Done

// Test for #95898: The trait suggestion had an extra `:` after the trait.
// edition:2021

#[rustfmt::skip]
Copy link
Member

Choose a reason for hiding this comment

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

I don't think you need rustfmt::skip here. We configured rustfmt to not run on ui tests for this exact reason.

Copy link
Member

Choose a reason for hiding this comment

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

You might need to turn off auto formatting from your IDE to remove this attribute.

Choose a reason for hiding this comment

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

Removed rustfmt::skip, thanks 👍

@fee1-dead
Copy link
Member

Can you please squash the commits? If you want, I can do it for you by having a bot squash the commits.

@PoorlyDefinedBehaviour
Copy link
Author

Can you please squash the commits? If you want, I can do it for you by having a bot squash the commits.

Done

@fee1-dead
Copy link
Member

Thanks!

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Apr 13, 2022

📌 Commit 9b9f677 has been approved by fee1-dead

@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 Apr 13, 2022
@PoorlyDefinedBehaviour
Copy link
Author

Thanks for your patience @fee1-dead @compiler-errors 👍

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 13, 2022
Rollup of 6 pull requests

Successful merges:

 - rust-lang#93217 (Improve Rustdoc UI for scraped examples with multiline arguments, fix overflow in line numbers)
 - rust-lang#95885 (Improve error message in case of missing checksum)
 - rust-lang#95962 (Document that DirEntry holds the directory open)
 - rust-lang#95991 (fix: wrong trait import suggestion for T:)
 - rust-lang#96005 (Add missing article to fix "few" to "a few".)
 - rust-lang#96006 (Add a missing article)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 648d65a into rust-lang:master Apr 13, 2022
@rustbot rustbot added this to the 1.62.0 milestone Apr 13, 2022
@PoorlyDefinedBehaviour PoorlyDefinedBehaviour deleted the fix/issue_95898 branch April 13, 2022 18:28
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect add bounds suggestion when given type parameter like <T:>
6 participants