Skip to content

Non-Deterministic Lifetime Error Message #17872

@maxsnew

Description

@maxsnew

I'm getting this on Fedora 20 with rustc 0.12.0-nightly (b5ba2f5 2014-10-06 20:27:14 +0000).

The following program:

extern crate graphviz;

use graphviz as dot;
use std::str;

type Nd = uint;
type Ed = (uint, uint);
struct Graph<'a> {
  nodes: Vec<&'a str>,
  edges: Vec<Ed>,
}

impl<'a> dot::Labeller<'a, Nd, Ed> for Graph<'a> {
  fn graph_id(&self) -> dot::Id<'a> {
    dot::Id::new("example3")
  }
  fn node_id(&self, n: &Nd) -> dot::Id {
    dot::Id::new(format!("N{:u}", *n))
  }
  fn node_label<'a>(&self, i: &Nd) -> dot::LabelText<'a> {
    dot::LabelStr(str::Slice(self.nodes[*i].as_slice()))
  }
}

When compiled with rustc --crate-type=lib non-deterministically gives one of 2 error messages.
A useful one:

lifetime-error.rs:21:5: 23:6 note: consider using an explicit lifetime parameter as shown: fn node_label<'a>(&'a self, i: &Nd) -> dot::LabelText<'a>

and a buggy one, thats suggested fix is what's already written in the program:

lifetime-error.rs:21:5: 23:6 note: consider using an explicit lifetime parameter as shown: fn node_label<'a>(&self, i: &Nd) -> dot::LabelText<'a>

On my Mac, I always get the worse error message.

I think this is the same issue described here: #13057

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions