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 1214 warning in librustc_mir/repr.rs #28999

Closed
apasel422 opened this issue Oct 12, 2015 · 3 comments
Closed

RFC 1214 warning in librustc_mir/repr.rs #28999

apasel422 opened this issue Oct 12, 2015 · 3 comments

Comments

@apasel422
Copy link
Contributor

Building nightly yields

../rust/src/librustc_mir/repr.rs:404:5: 404:38 warning: the parameter type `V` may not live long enough [E0309]
../rust/src/librustc_mir/repr.rs:404     pub elem: ProjectionElem<'tcx, V>,
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../rust/src/librustc_mir/repr.rs:401:24: 401:33 note: in this expansion of #[derive_PartialEq] (defined in ../rust/src/librustc_mir/repr.rs)
../rust/src/librustc_mir/repr.rs:404:5: 404:38 help: run `rustc --explain E0309` to see a detailed explanation
../rust/src/librustc_mir/repr.rs:404:5: 404:38 help: consider adding an explicit lifetime bound `V: 'tcx`...
../rust/src/librustc_mir/repr.rs:404:5: 404:38 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.
../rust/src/librustc_mir/repr.rs:404     pub elem: ProjectionElem<'tcx, V>,
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../rust/src/librustc_mir/repr.rs:401:24: 401:33 note: in this expansion of #[derive_PartialEq] (defined in ../rust/src/librustc_mir/repr.rs)
../rust/src/librustc_mir/repr.rs:404:5: 404:38 note: ...so that the reference type `&repr::ProjectionElem<'_, V>` does not outlive the data it points at
../rust/src/librustc_mir/repr.rs:404     pub elem: ProjectionElem<'tcx, V>,
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../rust/src/librustc_mir/repr.rs:401:24: 401:33 note: in this expansion of #[derive_PartialEq] (defined in ../rust/src/librustc_mir/repr.rs)
../rust/src/librustc_mir/repr.rs:404:5: 404:38 warning: the parameter type `V` may not live long enough [E0309]
../rust/src/librustc_mir/repr.rs:404     pub elem: ProjectionElem<'tcx, V>,
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../rust/src/librustc_mir/repr.rs:401:24: 401:33 note: in this expansion of #[derive_PartialEq] (defined in ../rust/src/librustc_mir/repr.rs)
../rust/src/librustc_mir/repr.rs:404:5: 404:38 help: run `rustc --explain E0309` to see a detailed explanation
../rust/src/librustc_mir/repr.rs:404:5: 404:38 help: consider adding an explicit lifetime bound `V: 'tcx`...
../rust/src/librustc_mir/repr.rs:404:5: 404:38 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.
../rust/src/librustc_mir/repr.rs:404     pub elem: ProjectionElem<'tcx, V>,
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../rust/src/librustc_mir/repr.rs:401:24: 401:33 note: in this expansion of #[derive_PartialEq] (defined in ../rust/src/librustc_mir/repr.rs)
../rust/src/librustc_mir/repr.rs:404:5: 404:38 note: ...so that the reference type `&repr::ProjectionElem<'_, V>` does not outlive the data it points at
../rust/src/librustc_mir/repr.rs:404     pub elem: ProjectionElem<'tcx, V>,
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../rust/src/librustc_mir/repr.rs:401:24: 401:33 note: in this expansion of #[derive_PartialEq] (defined in ../rust/src/librustc_mir/repr.rs)
@apasel422
Copy link
Contributor Author

A reduction of the code in question is available here: https://play.rust-lang.org/?gist=9893feaa919468e9f534&version=nightly

CC @nikomatsakis @arielb1.

@arielb1
Copy link
Contributor

arielb1 commented Oct 12, 2015

Further reduced:

pub struct Xyz<'a, V> {
    v: (V, &'a u32),
}

fn eq<'a, 's, 't, V>(this: &'s Xyz<'a, V>, other: &'t Xyz<'a, V>) -> bool
        where V: PartialEq {
    this.v == other.v
}

fn main() {}

@arielb1
Copy link
Contributor

arielb1 commented Oct 12, 2015

It looks like the borrow of this.v is not constrained and is therefore inferred to 'a.

arielb1 added a commit to arielb1/rust that referenced this issue Oct 12, 2015
This rather crucial requirement was not checked. In most cases, that
didn't cause any trouble because the argument types are required to
outlive the call and are subtypes of a subformula of the callee type.

However, binary ops are taken by ref only indirectly, without it being
marked in the argument types, which led to the argument types not being
constrained anywhere causing spurious errors (as these are basically
unconstrainable, I don't think this change can break code). Of course,
the old way was also incorrent with contravariance, but that is still
unsound for other reasons.

This also improves rustc::front to get RUST_LOG to *somewhat* work.

Fixes rust-lang#28999
Manishearth added a commit to Manishearth/rust that referenced this issue Oct 14, 2015
…felix

This rather crucial requirement was not checked. In most cases, that
didn't cause any trouble because the argument types are required to
outlive the call and are subtypes of a subformula of the callee type.

However, binary ops are taken by ref only indirectly, without it being
marked in the argument types, which led to the argument types not being
constrained anywhere causing spurious errors (as these are basically
unconstrainable, I don't think this change can break code). Of course,
the old way was also incorrent with contravariance, but that is still
unsound for other reasons.

This also improves rustc::front to get RUST_LOG to *somewhat* work.

Fixes rust-lang#28999. That issue is one of the several regression introduced by rust-lang#28669.

r? @pnkfelix
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

No branches or pull requests

2 participants