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

Projects
None yet
@nikomatsakis
Contributor

nikomatsakis commented Jul 17, 2015

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 label Jul 17, 2015

@nikomatsakis nikomatsakis self-assigned this Jul 17, 2015

@nikomatsakis

This comment has been minimized.

Show comment
Hide comment
@nikomatsakis
Contributor

nikomatsakis commented Jul 17, 2015

@Ryman

This comment has been minimized.

Show comment
Hide comment
@Ryman

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

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

This comment has been minimized.

Show comment
Hide comment
@nikomatsakis

nikomatsakis Jul 17, 2015

Contributor

@Ryman thanks.

Contributor

nikomatsakis commented Jul 17, 2015

@Ryman thanks.

R ⊢ 'x: 'a
R ⊢ T: 'a
--------------------------------------------------
R ⊢ &'x T: 'a

This comment has been minimized.

@Gankro

Gankro Jul 18, 2015

Contributor

It seems like T: 'a is redundant, since &'x T is WF only if T: 'x, no?

So T: 'x and 'x: 'a -> T: 'a by transitivity?

Maybe I'm missing a corner case.

@Gankro

Gankro Jul 18, 2015

Contributor

It seems like T: 'a is redundant, since &'x T is WF only if T: 'x, no?

So T: 'x and 'x: 'a -> T: 'a by transitivity?

Maybe I'm missing a corner case.

This comment has been minimized.

@nikomatsakis

nikomatsakis Aug 7, 2015

Contributor

@Gankro

Sorry, I'm not sure if I ever answered this.

It seems like T: 'a is redundant, since &'x T is WF only if T: 'x, no?

This seems true, if harmless.

@nikomatsakis

nikomatsakis Aug 7, 2015

Contributor

@Gankro

Sorry, I'm not sure if I ever answered this.

It seems like T: 'a is redundant, since &'x T is WF only if T: 'x, no?

This seems true, if harmless.

∀i. R ⊢ Oi: 'a
R ⊢ 'x: 'a
--------------------------------------------------
R ⊢ O0..On+'x: 'a

This comment has been minimized.

@Gankro

Gankro Jul 18, 2015

Contributor

Similar as above

@Gankro

Gankro Jul 18, 2015

Contributor

Similar as above

This comment has been minimized.

@arielb1

arielb1 Jul 18, 2015

Contributor

Shouldn't this be ∀i R, i: 'a ⊢ Oi: 'a (otherwise for<'α> Fn(&'α ()) : 'a would be false).

@arielb1

arielb1 Jul 18, 2015

Contributor

Shouldn't this be ∀i R, i: 'a ⊢ Oi: 'a (otherwise for<'α> Fn(&'α ()) : 'a would be false).

This comment has been minimized.

@nikomatsakis

nikomatsakis Aug 7, 2015

Contributor

@arielb1

Shouldn't this be ∀i R, i: 'a ⊢ Oi: 'a (otherwise for<'α> Fn(&'α ()) : 'a would be false).

No, because the binder is within the Oi.

@nikomatsakis

nikomatsakis Aug 7, 2015

Contributor

@arielb1

Shouldn't this be ∀i R, i: 'a ⊢ Oi: 'a (otherwise for<'α> Fn(&'α ()) : 'a would be false).

No, because the binder is within the Oi.

OutlivesScalar:
--------------------------------------------------
R ⊢ scalar: 'a

This comment has been minimized.

@Gankro

Gankro Jul 18, 2015

Contributor

Note for those of us without a very strong type theory background:

⊢ == "proves"

So this is just saying that any set of bounds proves that a scalar outlives 'a, for any given 'a (Plain Old Data has no external lifetime constraints, so it lives for any lifetime).

(I think)

@Gankro

Gankro Jul 18, 2015

Contributor

Note for those of us without a very strong type theory background:

⊢ == "proves"

So this is just saying that any set of bounds proves that a scalar outlives 'a, for any given 'a (Plain Old Data has no external lifetime constraints, so it lives for any lifetime).

(I think)

This comment has been minimized.

@arielb1

arielb1 Jul 18, 2015

Contributor

Not exactly "proves". this is a sequent-style deduction rule, read "(implicitly) for every environment R, scalar s and lifetime 'a, s outlives 'a given R"

@arielb1

arielb1 Jul 18, 2015

Contributor

Not exactly "proves". this is a sequent-style deduction rule, read "(implicitly) for every environment R, scalar s and lifetime 'a, s outlives 'a given R"

reduce `<PROJ>: 'x` to `&'a T: 'x`, which in turn holds if `'a: 'x`
and `T: 'x` (from the rule `OutlivesReference`).
But often we are in a situation where we can't normalize the

This comment has been minimized.

@Gankro

Gankro Jul 18, 2015

Contributor

An example would be great. Is it simply any time you're working with a generic I: Iterator?

@Gankro

Gankro Jul 18, 2015

Contributor

An example would be great. Is it simply any time you're working with a generic I: Iterator?

This comment has been minimized.

@nikomatsakis

nikomatsakis Aug 7, 2015

Contributor

@Gankro

An example would be great. Is it simply any time you're working with a generic I: Iterator?

I added an example, but yes that's roughly right (and other analogous cases, of course).

@nikomatsakis

nikomatsakis Aug 7, 2015

Contributor

@Gankro

An example would be great. Is it simply any time you're working with a generic I: Iterator?

I added an example, but yes that's roughly right (and other analogous cases, of course).

This complication is unfortunate, but to a large extent already exists
with where-clauses and trait matching (see e.g. [#21974]). (Moreover,
it seems to be inherent to the concept of assocated types, since they
take several inputs (the parameters to the trait) which may or may not

This comment has been minimized.

@Gankro

Gankro Jul 18, 2015

Contributor

yesss nested asides

@Gankro

Gankro Jul 18, 2015

Contributor

yesss nested asides

@arielb1

This comment has been minimized.

Show comment
Hide comment
@arielb1

arielb1 Jul 18, 2015

Contributor

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

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

This comment has been minimized.

@arielb1

arielb1 Jul 18, 2015

Contributor

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

@arielb1

arielb1 Jul 18, 2015

Contributor

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

This comment has been minimized.

@nikomatsakis

nikomatsakis Aug 7, 2015

Contributor

@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

nikomatsakis Aug 7, 2015

Contributor

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

and a trait object like `Foo+'x`, when we require that `'static: 'x`
(which is true, clearly, but in some cases the implicit bounds from
traits are not `'static` but rather some named lifetime).

This comment has been minimized.

@arielb1

arielb1 Jul 18, 2015

Contributor

Is there a case where this is relevant? What's an object type vs. object fragment?

@arielb1

arielb1 Jul 18, 2015

Contributor

Is there a case where this is relevant? What's an object type vs. object fragment?

@nikomatsakis

This comment has been minimized.

Show comment
Hide comment
@nikomatsakis

nikomatsakis Jul 20, 2015

Contributor

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

Contributor

nikomatsakis commented Jul 20, 2015

@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

This comment has been minimized.

Show comment
Hide comment
@arielb1

arielb1 Jul 20, 2015

Contributor

@nikomatsakis

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

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

This comment has been minimized.

Show comment
Hide comment
@arielb1

arielb1 Jul 21, 2015

Contributor

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.

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.

@nikomatsakis

This comment has been minimized.

Show comment
Hide comment
@nikomatsakis

nikomatsakis Aug 17, 2015

Contributor

@bluss re: the question of root vs non-root, good point! I've wondered about that from time to time; seems like we should improve crater in this respect.

Contributor

nikomatsakis commented Aug 17, 2015

@bluss re: the question of root vs non-root, good point! I've wondered about that from time to time; seems like we should improve crater in this respect.

@bluss

This comment has been minimized.

Show comment
Hide comment
@bluss

bluss Aug 17, 2015

@nikomatsakis Ok thanks for chiming in on the Fix struct! This kind of type kind of ties my brain into a knot..

I'm not sure much can be done with crater, just that we basically don't know if leaf regressions are to be counted as regressions on their own or not, because the root regression makes it impossible to test. We just have to judge the numbers a bit differently, at least when so many crates as this are affected.

bluss commented Aug 17, 2015

@nikomatsakis Ok thanks for chiming in on the Fix struct! This kind of type kind of ties my brain into a knot..

I'm not sure much can be done with crater, just that we basically don't know if leaf regressions are to be counted as regressions on their own or not, because the root regression makes it impossible to test. We just have to judge the numbers a bit differently, at least when so many crates as this are affected.

Gustorn added a commit to Gustorn/num that referenced this pull request Aug 19, 2015

crumblingstatue added a commit to crumblingstatue/rust-sdl2_image that referenced this pull request Aug 24, 2015

Put Sized bound on LoadSurface trait
This fixes a warning on nightly Rust (which will later become a hard error).

See rust-lang/rfcs#1214.

frewsxcv added a commit to frewsxcv/rust-block that referenced this pull request Sep 2, 2015

Fix nightly warnings related to lifetimes
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

Fix nightly warnings related to lifetimes
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

Fix nightly warnings related to lifetimes
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

Fix nightly warnings related to lifetimes
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
@Zalastra

This comment has been minimized.

Show comment
Hide comment
@Zalastra

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

Zalastra 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

This comment has been minimized.

Show comment
Hide comment
@arielb1

arielb1 Sep 22, 2015

Contributor

@Zalastra

Just add T: 'static. Not a bug.

Contributor

arielb1 commented Sep 22, 2015

@Zalastra

Just add T: 'static. Not a bug.

@bluss

This comment has been minimized.

Show comment
Hide comment
@bluss

bluss 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.

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

This comment has been minimized.

Show comment
Hide comment
@eddyb

eddyb Sep 22, 2015

Member

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

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

This comment has been minimized.

Show comment
Hide comment
@nikomatsakis

nikomatsakis Sep 30, 2015

Contributor

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

Contributor

nikomatsakis commented Sep 30, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment