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

PartialOrd derving broken for slices #18738

Closed
emberian opened this issue Nov 7, 2014 · 5 comments
Closed

PartialOrd derving broken for slices #18738

emberian opened this issue Nov 7, 2014 · 5 comments

Comments

@emberian
Copy link
Member

emberian commented Nov 7, 2014

#[deriving(PartialEq, PartialOrd)]
pub struct Version {
    pub vender_info: &'static str
}

fn main(){}
> rustc foo.rs
foo.rs:3:9: 3:34 error: mismatched types: expected `&str`, found `&&'static str` (expected str, found &-ptr)
foo.rs:3     pub vender_info: &'static str
                 ^~~~~~~~~~~~~~~~~~~~~~~~~
note: in expansion of #[deriving]
foo.rs:1:1: 1:35 note: expansion site
error: aborting due to previous error

Removing the PartialOrd deriving fixes it.

@emberian
Copy link
Member Author

emberian commented Nov 7, 2014

Offending code:

 #[inline]
 fn partial_cmp(&self, __arg_0: &Version) ->
  ::std::option::Option<::std::cmp::Ordering> {
     match *__arg_0 {
         Version { vender_info: ref __self_1_0 } =>
         match *self {
             Version { vender_info: ref __self_0_0 } => {
                 let __test = (*__self_0_0).partial_cmp(&(*__self_1_0));
                 if __test == ::std::option::Some(::std::cmp::Equal) {
                     ::std::option::Some(::std::cmp::Equal)
                 } else { __test }
             }
         },
     }
 }
bar.rs:21:60: 21:74 error: mismatched types: expected `&str`, found `&&'static str` (expected str, found &-ptr)
bar.rs:21                     let __test = (*__self_0_0).partial_cmp(&(*__self_1_0));
                                                                     ^~~~~~~~~~~~~~
error: aborting due to previous error

@japaric
Copy link
Member

japaric commented Nov 7, 2014

@cmr See #15689 (comment) I'll probably send a fix later today.

@brendanzab
Copy link
Member

This still seems broken:

#[deriving(Eq, PartialEq, Ord, PartialOrd)]
struct Foo(&'static str);
<anon>:2:12: 2:25 error: mismatched types: expected `&str`, found `&&'static str` (expected str, found &-ptr)
<anon>:2 struct Foo(&'static str);
                    ^~~~~~~~~~~~~
note: in expansion of #[deriving]
<anon>:1:1: 1:44 note: expansion site

http://is.gd/4GFt9D

brendanzab added a commit to brendanzab/gfx-rs that referenced this issue Dec 6, 2014
rust-lang/rust#18738 still seems broken, but this makes the impls a tad less ugly...
@japaric
Copy link
Member

japaric commented Dec 6, 2014

@bjz Hmm, deriving(Ord) is the one that's still broken now. This issue was about PartialOrd which is still working (it has a run-pass test). Anyways, I'll send a patch later.

@brendanzab
Copy link
Member

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants