Last active
August 29, 2015 14:07
-
-
Save maxsnew/9d3d30b469e7e39909d0 to your computer and use it in GitHub Desktop.
Non-deterministic Lifetime Error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>(&'a self, i: &Nd) -> dot::LabelText<'a> { | |
dot::LabelStr(str::Slice(self.nodes[*i].as_slice())) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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())) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sometimes I get this bad error message: | |
lifetime-error.rs:21:34: 21:48 error: cannot infer an appropriate lifetime for autoref due to conflicting requirements | |
lifetime-error.rs:21 dot::LabelStr(str::Slice(self.nodes[*i].as_slice())) | |
^~~~~~~~~~~~~~ | |
lifetime-error.rs:20:5: 22:6 note: consider using an explicit lifetime parameter as shown: fn node_label<'a>(&self, i: &Nd) -> dot::LabelText<'a> | |
lifetime-error.rs:20 fn node_label<'a>(&self, i: &Nd) -> dot::LabelText<'a> { | |
lifetime-error.rs:21 dot::LabelStr(str::Slice(self.nodes[*i].as_slice())) | |
lifetime-error.rs:22 } | |
error: aborting due to previous error | |
Other times I get this good error message: | |
lifetime-error.rs:21:34: 21:48 error: cannot infer an appropriate lifetime for autoref due to conflicting requirements | |
lifetime-error.rs:21 dot::LabelStr(str::Slice(self.nodes[*i].as_slice())) | |
^~~~~~~~~~~~~~ | |
lifetime-error.rs:20:5: 22:6 note: consider using an explicit lifetime parameter as shown: fn node_label<'a>(&'a self, i: &Nd) -> dot::LabelText<'a> | |
lifetime-error.rs:20 fn node_label<'a>(&self, i: &Nd) -> dot::LabelText<'a> { | |
lifetime-error.rs:21 dot::LabelStr(str::Slice(self.nodes[*i].as_slice())) | |
lifetime-error.rs:22 } | |
error: aborting due to previous error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I honestly do not see the difference between the good and the bad error message, and my local
diff
tool can't see it either. Are you maybe looking at different places?