Skip to content

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

Closed

Description

@liigo

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.

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    on Dec 23, 2014
  2. apasel422 commented on Jul 19, 2015

    @apasel422
    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
    
  3. Gankra commented on Jul 19, 2015

    @Gankra
    Contributor

    Needs test?

  4. added
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    on Jul 19, 2015
  5. added 11 commits that reference this issue on Jul 21, 2015
    87f3c88
    836887b
    3b41959
    886543d
    a7590e3
    477df50
    db0e0ef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions