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

Two test cases for incorrect region inference #4036

Closed
brson opened this issue Nov 25, 2012 · 3 comments
Closed

Two test cases for incorrect region inference #4036

brson opened this issue Nov 25, 2012 · 3 comments
Labels
A-lifetimes Area: Lifetimes / regions I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@brson
Copy link
Contributor

brson commented Nov 25, 2012

I came up with these two similar test cases for region-related ICEs. They both have to do with JsonDeserializer's interior pointer.

pub trait Deserializable<D> {
    static fn deserialize(&self, d: &D) -> self;
}

pub impl<D> int: Deserializable<D> {
    static fn deserialize(&self, _d: &D) -> int { fail }
}

struct JsonDeserializer {
    stack: &int,
}

impl JsonDeserializer {
}

trait Unflattenator<T> {
    fn unflatten(&self) -> T;
}

struct DeserializingUnflattenator<D, T: Deserializable<D>> {
    bogus: ()
}

fn from_reader<D>() -> D { fail }

fn unflatten<D, T: Deserializable<D>>(_s: &DeserializingUnflattenator<D, T>) -> T {
    let deser: &D = &from_reader();
    deserialize(deser)
}

fn m(_t: &r/int) {
    let unflat: DeserializingUnflattenator<JsonDeserializer, int> = DeserializingUnflattenator { bogus: () };
    unflatten(&unflat);
}

fn main() {
}
note: cannot encode region variables lifetime re_infer(ReVar(RegionVid(0)))
error: internal compiler error: Cannot encode region variables
pub trait Deserializable<D> {
    static fn deserialize(&self, d: &D) -> self;
}

pub impl<D> int: Deserializable<D> {
    static fn deserialize(&self, d: &D) -> int { fail }
}

struct JsonDeserializer {
    stack: &int,
}

impl JsonDeserializer {
}

trait Unflattenator<T> {
    fn unflatten(&self) -> T;
}

struct DeserializingUnflattenator<D, T: Deserializable<D>> {
    bogus: ()
}

fn from_reader<D>() -> D { fail }

fn unflatten<D, T: Deserializable<D>>() -> T {
    let deser: &D = &from_reader();
    deserialize(deser)
}

fn m(foo: &r/int) {
    unflatten::<JsonDeserializer, int>();
}

fn main() {
}
/home/brian/dev/rust2/src/test/run-pass/flatpipe-encode2.rs:32:16: 32:32 error: Unconstrained region variable #0
/home/brian/dev/rust2/src/test/run-pass/flatpipe-encode2.rs:32     unflatten::<JsonDeserializer, int>();
@erickt
Copy link
Contributor

erickt commented Mar 10, 2013

@nikomatsakis: I bisected my Cannot encode region variables bug and it seems to match up with issue. I thought this bug was recent, but I just did a big bisection and found it's been present since 2012-10-23, in ab89b5c, where I made the serialization traits take type parameters. So the JSON decoder has been busted for a couple months now because we didn't have a proper test case. I'm guessing this bug is from region inference not properly working with trait type parameters.

@erickt
Copy link
Contributor

erickt commented Mar 10, 2013

Oh and here's the test case I used to reduce the bug down to that commit:

extern mod std;
use std::json;
use std::serialization::{Deserializable, deserialize};

fn main() {
    do io::with_str_reader("[1]") |rdr| {
        let deser = result::unwrap(json::Deserializer(rdr));
        let x: ~[int] = deserialize(&deser);
        io::println(fmt!("%?", x));
    }
}

@erickt
Copy link
Contributor

erickt commented Mar 11, 2013

Here's the modern version of the test case:

extern mod std;
use std::json;
use std::serialize;

fn main() {
    let json = json::from_str("[1]").unwrap();
    let _x: ~[int] = serialize::Decodable::decode(&json::Decoder(json));
}

nikomatsakis added a commit that referenced this issue Mar 21, 2013
…rboten.

Add assertions that no inference by-products are added to this table.

cc #4036
nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 25, 2013
… astconv

and from typeck, which is verboten.  We are supposed to write inference results
into the FnCtxt and then these get copied over in writeback.  Add assertions
that no inference by-products are added to this table.

Fixes rust-lang#3888
Fixes rust-lang#4036
Fixes rust-lang#4492
bors added a commit that referenced this issue Mar 26, 2013
…encode-region-variables, r=nikomatsakis

The basic problem was that vtables were not being resolved.  The fix uncovered another issue, which was that the syntax extensions were not creating method calls properly and were relying on outdated code in typeck, so I fixed that too.  

Resolves issues #3888, #4036, #4492.

r? @catamorphism
bors added a commit to rust-lang-ci/rust that referenced this issue May 2, 2020
…1995

Add `skip_while_next` lint

Fixes rust-lang#4036

changelog: Add `skip_while_next` lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: Lifetimes / regions I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

2 participants