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

[RFC] Clarify (and improve) rules for projections and well-formedness #1214

Merged
merged 10 commits into from
Aug 7, 2015

Conversation

nikomatsakis
Copy link
Contributor

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:

  • Simplify the outlives relation to be syntactically based.
  • Specify improved rules for the outlives relation and projections.
  • Specify more specifically where WF bounds are enforced, covering several cases missing from the implementation.

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:

  1. Initially, warnings will be issued for cases that violate the rules specified in this RFC. These warnings are not lints and cannot be silenced except by correcting the code such that it type-checks under the new rules.
  2. After one release cycle, those warnings will become errors.

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

@nikomatsakis nikomatsakis added the T-lang Relevant to the language team, which will review and decide on the RFC. label Jul 17, 2015
@nikomatsakis nikomatsakis self-assigned this Jul 17, 2015
@nikomatsakis
Copy link
Contributor Author

cc @arielb1

@Ryman
Copy link

Ryman commented Jul 17, 2015

@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).

@nikomatsakis
Copy link
Contributor Author

@Ryman thanks.

R ⊢ scalar: 'a

OutlivesNominalType:
∀i. Pi: 'a
Copy link
Contributor

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?

@arielb1
Copy link
Contributor

arielb1 commented Jul 18, 2015

I think the [[T]] issue is a straight bug in rustc and shouldn't result in just a warning.

R ⊢ T WF
R ⊢ T: Sized
--------------------------------------------------
[T] WF
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@arielb1

There should also be a WfTuple - in fact in the form you use there should be a Wf rule for each type constructor.

Added.

@nikomatsakis
Copy link
Contributor Author

@arielb1

I think the [[T]] issue is a straight bug in rustc and shouldn't result in just a warning.

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.

@arielb1
Copy link
Contributor

arielb1 commented Jul 20, 2015

@nikomatsakis

[[T]] basically causes an ICE every time it is used, so it is relatively hard to abuse.

@arielb1
Copy link
Contributor

arielb1 commented Jul 21, 2015

Could you also clarify which of Box<Foo<'a>+'static>, Box<Foo<'static>+'a> and Box<Foo<'a>+'b> are well-formed (assuming 'a and `'b' are unrelated free regions)? AFAICT the rules say that only the second of these is valid, but an example would always be helpful.

frewsxcv added a commit to frewsxcv/rust-block that referenced this pull request Sep 2, 2015
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
frewsxcv added a commit to frewsxcv/webdriver-rust that referenced this pull request Sep 2, 2015
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
frewsxcv added a commit to frewsxcv/rust-offscreen-rendering-context that referenced this pull request Sep 2, 2015
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
frewsxcv added a commit to frewsxcv/rust-chrono that referenced this pull request Sep 5, 2015
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
@MBons
Copy link

MBons commented Sep 22, 2015

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];
}

@arielb1
Copy link
Contributor

arielb1 commented Sep 22, 2015

@Zalastra

Just add T: 'static. Not a bug.

@bluss
Copy link
Member

bluss commented Sep 22, 2015

It outputs two warnings (playpen)

  • warning: the trait core::marker::Sized is not implemented for the type T
  • warning: the parameter type T may not live long enough

The first one must be a bug.

@eddyb
Copy link
Member

eddyb commented Sep 22, 2015

@bluss it's odd because it seems like it doesn't take actual bounds into account - see fixed version (the Sized bound is unnecessary, but it's there to show the issue).

@nikomatsakis
Copy link
Contributor Author

I agree that the T: Sized message is a bug. Did anyone file an issue?

On Tue, Sep 22, 2015 at 8:14 AM, Eduard-Mihai Burtescu <
notifications@github.com> wrote:

@bluss https://github.com/bluss it's odd because it seems like it
doesn't take actual bounds into account - see fixed version
https://play.rust-lang.org/?gist=343add7244bd4b210961&version=nightly&run=1
(the Sized bound is unnecessary, but it's there to show the issue).


Reply to this email directly or view it on GitHub
#1214 (comment).

@Ericson2314 Ericson2314 mentioned this pull request Dec 4, 2015
2 tasks
@Centril Centril added A-typesystem Type system related proposals & ideas A-lifetimes Lifetime related proposals. A-associated-types Proposals relating to associated types labels Nov 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-types Proposals relating to associated types A-lifetimes Lifetime related proposals. A-typesystem Type system related proposals & ideas final-comment-period Will be merged/postponed/closed in ~10 calendar days unless new substational objections are raised. T-lang Relevant to the language team, which will review and decide on the RFC.
Projects
None yet
Development

Successfully merging this pull request may close these issues.