Skip to content

Ice lang item #26910

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

Merged
merged 1 commit into from
Jul 13, 2015
Merged

Ice lang item #26910

merged 1 commit into from
Jul 13, 2015

Conversation

nrc
Copy link
Member

@nrc nrc commented Jul 9, 2015

No description provided.

@rust-highfive
Copy link
Contributor

r? @huonw

(rust_highfive has picked a reviewer for you, use r? to override)

// option. This file may not be copied, modified, or distributed
// except according to those terms.

// Test that we don't ICE when we are missing the owned_box lang item.
Copy link
Contributor

Choose a reason for hiding this comment

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

doesn't this file need an error pattern?

Copy link
Member Author

Choose a reason for hiding this comment

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

it has one (admittedly it was missing on my first push :-) )

@nrc nrc force-pushed the ice-lang-item branch from 4c4771d to 0c574bb Compare July 9, 2015 06:34
@huonw
Copy link
Member

huonw commented Jul 9, 2015

Hm, I'm not totally on board with returning Result: not having a lang item isn't always an error (i.e. most of the checks are like "if this is lang item X", and those are fine to be false if the lang item doesn't exist at all). I feel like it may have non-trivial overhead with all the String allocation?

@nrc nrc force-pushed the ice-lang-item branch from 0c574bb to c7e2039 Compare July 12, 2015 23:52
@nrc nrc force-pushed the ice-lang-item branch from c7e2039 to 7fb8208 Compare July 12, 2015 23:53
@nrc
Copy link
Member Author

nrc commented Jul 12, 2015

@huonw I'm not 100% sure I agree, seems like if the compiler wants a lang item to be there and it isn't then that ought to be an error, the fact that we work around it sometimes means its still an error. However, I guess the change is only worthwhile if we use the error message from lang items in the errors, which we don't and I don't want to do. So, here is a version without the Result change. The treatment of owned_box becomes a little ad hoc, but then our treatment of owned box seems pretty ad hoc already.

@huonw
Copy link
Member

huonw commented Jul 13, 2015

if the compiler wants a lang item to be there and it isn't then that ought to be an error, the fact that we work around it sometimes means its still an error

Many of the lang-item queries are essentially checking whether some type has a certain behaviour, where that behaviour is represented by some lang-item. Hence it's fine if the lang item doesn't exist, it means the type definitely doesn't have that behaviour.

@@ -90,6 +90,10 @@ impl LanguageItems {
}
}

pub fn require_owned_box(&self) -> Result<ast::DefId, String> {
Copy link
Member

Choose a reason for hiding this comment

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

Other places that do this sort of thing just write the self.require(...) call inline, maybe it's ok to do that here too instead of introducing a special method?

Copy link
Member Author

Choose a reason for hiding this comment

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

My reasoning was:

  • owned_box is already somewhat special - it doesn't follow the idioms of the others
  • we could have done that but didn't, which indicates that we need to do something differently
  • the 'right' thing should be at least as ergonomic as the 'wrong' thing (.owned_box())

Copy link
Member

Choose a reason for hiding this comment

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

the 'right' thing should be at least as ergonomic as the 'wrong' thing (.owned_box())

Hm, actually, I'm not totally clear why owned_box is wrong? Doesn't it return an Option, and the ICE caused by the unwrap call?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's right, but there's not a great way to handle the error unless you get the error message which comes with the require version. I guess you could make up your own message. That's why I use "'right'" rather than "right" - it's not too important. But it is an error if its not there, so Result feels right.

@huonw
Copy link
Member

huonw commented Jul 13, 2015

(r=me with or without require_owned_box, as you see fit.)

@nrc
Copy link
Member Author

nrc commented Jul 13, 2015

@bors: r=@huonw

@bors
Copy link
Collaborator

bors commented Jul 13, 2015

📌 Commit 7fb8208 has been approved by @huonw

@bors
Copy link
Collaborator

bors commented Jul 13, 2015

⌛ Testing commit 7fb8208 with merge b5939ae...

@bors
Copy link
Collaborator

bors commented Jul 13, 2015

💔 Test failed - auto-linux-64-x-android-t

@nrc
Copy link
Member Author

nrc commented Jul 13, 2015

@bors: retry

bors added a commit that referenced this pull request Jul 13, 2015
@bors
Copy link
Collaborator

bors commented Jul 13, 2015

⌛ Testing commit 7fb8208 with merge c044791...

@bors bors merged commit 7fb8208 into rust-lang:master Jul 13, 2015
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 this pull request may close these issues.

5 participants