-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[RFC] Clarify (and improve) rules for projections and well-formedness #1214
[RFC] Clarify (and improve) rules for projections and well-formedness #1214
Conversation
cc @arielb1 |
@nikomatsakis I think the issue referenced for 'unsound' in your description should be rust-lang/rust#24622 which is mentioned in the RFC (also labelled wrong). |
@Ryman thanks. |
R ⊢ scalar: 'a | ||
|
||
OutlivesNominalType: | ||
∀i. Pi: 'a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be ∀i. R ⊢ Pi: 'a
?
I think the |
R ⊢ T WF | ||
R ⊢ T: Sized | ||
-------------------------------------------------- | ||
[T] WF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should also be a WfTuple
- in fact in the form you use there should be a Wf
rule for each type constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should also be a WfTuple - in fact in the form you use there should be a Wf rule for each type constructor.
Added.
Perhaps, but the issue is really not whether it's a bug or not, the question is about whether code is affected by the change. That said, I haven't observed any. |
|
Could you also clarify which of |
The following warnings appear: ``` src/lib.rs:73:5: 73:68 warning: the trait `core::marker::Sized` is not implemented for the type `Self` [E0277] src/lib.rs:73 unsafe fn call_block<R>(self, block: *mut Block<Self, R>) -> R; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:73:5: 73:68 help: run `rustc --explain E0277` to see a detailed explanation src/lib.rs:73:5: 73:68 note: `Self` does not have a constant size known at compile-time src/lib.rs:73 unsafe fn call_block<R>(self, block: *mut Block<Self, R>) -> R; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:73:5: 73:68 note: this warning results from recent bug fixes and clarifications; it will become a HARD ERROR in the next release. See RFC 1214 for details. src/lib.rs:73 unsafe fn call_block<R>(self, block: *mut Block<Self, R>) -> R; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:73:5: 73:68 note: required by `Block` src/lib.rs:73 unsafe fn call_block<R>(self, block: *mut Block<Self, R>) -> R; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:187:5: 187:71 warning: the trait `core::marker::Sized` is not implemented for the type `Self` [E0277] src/lib.rs:187 fn into_concrete_block(self) -> ConcreteBlock<A, Self::Ret, Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:187:5: 187:71 help: run `rustc --explain E0277` to see a detailed explanation src/lib.rs:187:5: 187:71 note: `Self` does not have a constant size known at compile-time src/lib.rs:187 fn into_concrete_block(self) -> ConcreteBlock<A, Self::Ret, Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:187:5: 187:71 note: this warning results from recent bug fixes and clarifications; it will become a HARD ERROR in the next release. See RFC 1214 for details. src/lib.rs:187 fn into_concrete_block(self) -> ConcreteBlock<A, Self::Ret, Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:187:5: 187:71 note: required by `ConcreteBlock` src/lib.rs:187 fn into_concrete_block(self) -> ConcreteBlock<A, Self::Ret, Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` ...because of: rust-lang/rfcs#1214
The following warnings appear: ``` src/command.rs:344:5: 344:56 warning: the trait `core::marker::Sized` is not implemented for the type `Self` [E0277] src/command.rs:344 fn from_json(body: &Json) -> WebDriverResult<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/command.rs:344:5: 344:56 help: run `rustc --explain E0277` to see a detailed explanation src/command.rs:344:5: 344:56 note: `Self` does not have a constant size known at compile-time src/command.rs:344 fn from_json(body: &Json) -> WebDriverResult<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/command.rs:344:5: 344:56 note: this warning results from recent bug fixes and clarifications; it will become a HARD ERROR in the next release. See RFC 1214 for details. src/command.rs:344 fn from_json(body: &Json) -> WebDriverResult<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/command.rs:344:5: 344:56 note: required by `core::result::Result` src/command.rs:344 fn from_json(body: &Json) -> WebDriverResult<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` ...because of: rust-lang/rfcs#1214
The following warnings appear: ``` src/platform/mod.rs:7:5: 7:56 warning: the trait `core::marker::Sized` is not implemented for the type `Self` [E0277] src/platform/mod.rs:7 fn create_headless() -> Result<Self, &'static str>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/platform/mod.rs:7:5: 7:56 help: run `rustc --explain E0277` to see a detailed explanation src/platform/mod.rs:7:5: 7:56 note: `Self` does not have a constant size known at compile-time src/platform/mod.rs:7 fn create_headless() -> Result<Self, &'static str>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/platform/mod.rs:7:5: 7:56 note: this warning results from recent bug fixes and clarifications; it will become a HARD ERROR in the next release. See RFC 1214 for details. src/platform/mod.rs:7 fn create_headless() -> Result<Self, &'static str>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/platform/mod.rs:7:5: 7:56 note: required by `core::result::Result` src/platform/mod.rs:7 fn create_headless() -> Result<Self, &'static str>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` ...because of: rust-lang/rfcs#1214
The following warnings appear: ``` Compiling chrono v0.2.15 (file:///Users/coreyf/Development/rust/rust-chrono) src/lib.rs:504:5: 504:52 warning: the trait `core::marker::Sized` is not implemented for the type `Self` [E0277] src/lib.rs:504 fn with_year(&self, year: i32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:504:5: 504:52 help: run `rustc --explain E0277` to see a detailed explanation src/lib.rs:504:5: 504:52 note: `Self` does not have a constant size known at compile-time src/lib.rs:504 fn with_year(&self, year: i32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:504:5: 504:52 note: this warning results from recent bug fixes and clarifications; it will become a HARD ERROR in the next release. See RFC 1214 for details. src/lib.rs:504 fn with_year(&self, year: i32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:504:5: 504:52 note: required by `core::option::Option` src/lib.rs:504 fn with_year(&self, year: i32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:509:5: 509:54 warning: the trait `core::marker::Sized` is not implemented for the type `Self` [E0277] src/lib.rs:509 fn with_month(&self, month: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:509:5: 509:54 help: run `rustc --explain E0277` to see a detailed explanation src/lib.rs:509:5: 509:54 note: `Self` does not have a constant size known at compile-time src/lib.rs:509 fn with_month(&self, month: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:509:5: 509:54 note: this warning results from recent bug fixes and clarifications; it will become a HARD ERROR in the next release. See RFC 1214 for details. src/lib.rs:509 fn with_month(&self, month: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:509:5: 509:54 note: required by `core::option::Option` src/lib.rs:509 fn with_month(&self, month: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:514:5: 514:56 warning: the trait `core::marker::Sized` is not implemented for the type `Self` [E0277] src/lib.rs:514 fn with_month0(&self, month0: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:514:5: 514:56 help: run `rustc --explain E0277` to see a detailed explanation src/lib.rs:514:5: 514:56 note: `Self` does not have a constant size known at compile-time src/lib.rs:514 fn with_month0(&self, month0: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:514:5: 514:56 note: this warning results from recent bug fixes and clarifications; it will become a HARD ERROR in the next release. See RFC 1214 for details. src/lib.rs:514 fn with_month0(&self, month0: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:514:5: 514:56 note: required by `core::option::Option` src/lib.rs:514 fn with_month0(&self, month0: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:519:5: 519:50 warning: the trait `core::marker::Sized` is not implemented for the type `Self` [E0277] src/lib.rs:519 fn with_day(&self, day: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:519:5: 519:50 help: run `rustc --explain E0277` to see a detailed explanation src/lib.rs:519:5: 519:50 note: `Self` does not have a constant size known at compile-time src/lib.rs:519 fn with_day(&self, day: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:519:5: 519:50 note: this warning results from recent bug fixes and clarifications; it will become a HARD ERROR in the next release. See RFC 1214 for details. src/lib.rs:519 fn with_day(&self, day: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:519:5: 519:50 note: required by `core::option::Option` src/lib.rs:519 fn with_day(&self, day: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:524:5: 524:52 warning: the trait `core::marker::Sized` is not implemented for the type `Self` [E0277] src/lib.rs:524 fn with_day0(&self, day0: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:524:5: 524:52 help: run `rustc --explain E0277` to see a detailed explanation src/lib.rs:524:5: 524:52 note: `Self` does not have a constant size known at compile-time src/lib.rs:524 fn with_day0(&self, day0: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:524:5: 524:52 note: this warning results from recent bug fixes and clarifications; it will become a HARD ERROR in the next release. See RFC 1214 for details. src/lib.rs:524 fn with_day0(&self, day0: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:524:5: 524:52 note: required by `core::option::Option` src/lib.rs:524 fn with_day0(&self, day0: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:529:5: 529:58 warning: the trait `core::marker::Sized` is not implemented for the type `Self` [E0277] src/lib.rs:529 fn with_ordinal(&self, ordinal: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:529:5: 529:58 help: run `rustc --explain E0277` to see a detailed explanation src/lib.rs:529:5: 529:58 note: `Self` does not have a constant size known at compile-time src/lib.rs:529 fn with_ordinal(&self, ordinal: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:529:5: 529:58 note: this warning results from recent bug fixes and clarifications; it will become a HARD ERROR in the next release. See RFC 1214 for details. src/lib.rs:529 fn with_ordinal(&self, ordinal: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:529:5: 529:58 note: required by `core::option::Option` src/lib.rs:529 fn with_ordinal(&self, ordinal: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:534:5: 534:60 warning: the trait `core::marker::Sized` is not implemented for the type `Self` [E0277] src/lib.rs:534 fn with_ordinal0(&self, ordinal0: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:534:5: 534:60 help: run `rustc --explain E0277` to see a detailed explanation src/lib.rs:534:5: 534:60 note: `Self` does not have a constant size known at compile-time src/lib.rs:534 fn with_ordinal0(&self, ordinal0: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:534:5: 534:60 note: this warning results from recent bug fixes and clarifications; it will become a HARD ERROR in the next release. See RFC 1214 for details. src/lib.rs:534 fn with_ordinal0(&self, ordinal0: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:534:5: 534:60 note: required by `core::option::Option` src/lib.rs:534 fn with_ordinal0(&self, ordinal0: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:580:5: 580:52 warning: the trait `core::marker::Sized` is not implemented for the type `Self` [E0277] src/lib.rs:580 fn with_hour(&self, hour: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:580:5: 580:52 help: run `rustc --explain E0277` to see a detailed explanation src/lib.rs:580:5: 580:52 note: `Self` does not have a constant size known at compile-time src/lib.rs:580 fn with_hour(&self, hour: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:580:5: 580:52 note: this warning results from recent bug fixes and clarifications; it will become a HARD ERROR in the next release. See RFC 1214 for details. src/lib.rs:580 fn with_hour(&self, hour: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:580:5: 580:52 note: required by `core::option::Option` src/lib.rs:580 fn with_hour(&self, hour: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:585:5: 585:53 warning: the trait `core::marker::Sized` is not implemented for the type `Self` [E0277] src/lib.rs:585 fn with_minute(&self, min: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:585:5: 585:53 help: run `rustc --explain E0277` to see a detailed explanation src/lib.rs:585:5: 585:53 note: `Self` does not have a constant size known at compile-time src/lib.rs:585 fn with_minute(&self, min: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:585:5: 585:53 note: this warning results from recent bug fixes and clarifications; it will become a HARD ERROR in the next release. See RFC 1214 for details. src/lib.rs:585 fn with_minute(&self, min: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:585:5: 585:53 note: required by `core::option::Option` src/lib.rs:585 fn with_minute(&self, min: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:590:5: 590:53 warning: the trait `core::marker::Sized` is not implemented for the type `Self` [E0277] src/lib.rs:590 fn with_second(&self, sec: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:590:5: 590:53 help: run `rustc --explain E0277` to see a detailed explanation src/lib.rs:590:5: 590:53 note: `Self` does not have a constant size known at compile-time src/lib.rs:590 fn with_second(&self, sec: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:590:5: 590:53 note: this warning results from recent bug fixes and clarifications; it will become a HARD ERROR in the next release. See RFC 1214 for details. src/lib.rs:590 fn with_second(&self, sec: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:590:5: 590:53 note: required by `core::option::Option` src/lib.rs:590 fn with_second(&self, sec: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:595:5: 595:58 warning: the trait `core::marker::Sized` is not implemented for the type `Self` [E0277] src/lib.rs:595 fn with_nanosecond(&self, nano: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:595:5: 595:58 help: run `rustc --explain E0277` to see a detailed explanation src/lib.rs:595:5: 595:58 note: `Self` does not have a constant size known at compile-time src/lib.rs:595 fn with_nanosecond(&self, nano: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:595:5: 595:58 note: this warning results from recent bug fixes and clarifications; it will become a HARD ERROR in the next release. See RFC 1214 for details. src/lib.rs:595 fn with_nanosecond(&self, nano: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/lib.rs:595:5: 595:58 note: required by `core::option::Option` src/lib.rs:595 fn with_nanosecond(&self, nano: u32) -> Option<Self>; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` ...because of: rust-lang/rfcs#1214
Ran into this error using an associated const on a trait. On IRC it was suggested that this is likely a compiler bug. pub trait IterableEnum<T> {
const ENUM_VARIANTS: &'static [T];
} |
@Zalastra Just add |
It outputs two warnings (playpen)
The first one must be a bug. |
@bluss it's odd because it seems like it doesn't take actual bounds into account - see fixed version (the |
I agree that the On Tue, Sep 22, 2015 at 8:14 AM, Eduard-Mihai Burtescu <
|
RFC has been accepted and merged.
Current text: https://github.com/rust-lang/rfcs/blob/master/text/1214-projections-lifetimes-and-wf.md
Tracking issue: rust-lang/rust#27579
Type system changes to address the outlives relation with respect to projections, and to better enforce that all types are well-formed (meaning that they respect their declared bounds). The current implementation can be both unsound (rust-lang/rust#24622), inconvenient (rust-lang/rust#23442), and surprising (rust-lang/rust#21748, rust-lang/rust#25692). The changes are as follows:
The proposed changes here have been tested and found to cause only a modest number of regressions (about two dozen root regressions were previously found on crates.io; however, that run did not yet include all the provisions from this RFC; updated numbers coming soon). In order to minimize the impact on users, the plan is to first introduce the changes in two stages:
Note that although the changes do cause regressions, they also cause some code (like that in rust-lang/rust#23442) which currently gets errors to compile successfully.
cc @rust-lang/lang
Rendered