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

Compiler message need improve for OrdSliceExt::sort() #20162

Closed
liigo opened this issue Dec 23, 2014 · 2 comments · Fixed by #27131
Closed

Compiler message need improve for OrdSliceExt::sort() #20162

liigo opened this issue Dec 23, 2014 · 2 comments · Fixed by #27131
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@liigo
Copy link
Contributor

liigo commented Dec 23, 2014

Code:

// #[deriving(Eq, Ord, PartialEq, PartialOrd)]
struct X { x: int }

pub fn main() {
    let mut b: Vec<X> = Vec::new();
    b.sort();
}

Error:

tmp.rs:6:7: 6:13 error: type `collections::vec::Vec<X>` does not implement any method in scope named `sort`
tmp.rs:6     b.sort();

The compiler should tell us, struct X doesn't implements Ord, at least.

@huonw huonw added the A-diagnostics Area: Messages for errors, warnings, and lints label Dec 23, 2014
@apasel422
Copy link
Contributor

This is fixed (after changing the type of X.x to i32):

> rustc --version
rustc 1.3.0-nightly (e4e93196e 2015-07-14)
> rustc foo.rs
foo.rs:6:7: 6:13 error: the trait `core::cmp::Ord` is not implemented for the type `X` [E0277]
foo.rs:6     b.sort();
               ^~~~~~
foo.rs:6:7: 6:13 help: run `rustc --explain E0277` to see a detailed explanation

@Gankra
Copy link
Contributor

Gankra commented Jul 19, 2015

Needs test?

@Gankra Gankra added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jul 19, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Jul 21, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Jul 21, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Jul 21, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Jul 22, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Jul 22, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Jul 22, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Jul 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants