try! -> ?
Automated conversion using the untry tool [1] and the following command: ``` $ find -name '*.rs' -type f | xargs untry ``` at the root of the Rust repo. [1]: https://github.com/japaric/untry
This commit is contained in:
@@ -77,8 +77,8 @@ impl ConstnessSpace {
|
||||
impl<'a, T: fmt::Display> fmt::Display for CommaSep<'a, T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
for (i, item) in self.0.iter().enumerate() {
|
||||
if i != 0 { try!(write!(f, ", ")); }
|
||||
try!(write!(f, "{}", item));
|
||||
if i != 0 { write!(f, ", ")?; }
|
||||
write!(f, "{}", item)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -89,9 +89,9 @@ impl<'a> fmt::Display for TyParamBounds<'a> {
|
||||
let &TyParamBounds(bounds) = self;
|
||||
for (i, bound) in bounds.iter().enumerate() {
|
||||
if i > 0 {
|
||||
try!(f.write_str(" + "));
|
||||
f.write_str(" + ")?;
|
||||
}
|
||||
try!(write!(f, "{}", *bound));
|
||||
write!(f, "{}", *bound)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -100,36 +100,36 @@ impl<'a> fmt::Display for TyParamBounds<'a> {
|
||||
impl fmt::Display for clean::Generics {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
if self.lifetimes.is_empty() && self.type_params.is_empty() { return Ok(()) }
|
||||
try!(f.write_str("<"));
|
||||
f.write_str("<")?;
|
||||
|
||||
for (i, life) in self.lifetimes.iter().enumerate() {
|
||||
if i > 0 {
|
||||
try!(f.write_str(", "));
|
||||
f.write_str(", ")?;
|
||||
}
|
||||
try!(write!(f, "{}", *life));
|
||||
write!(f, "{}", *life)?;
|
||||
}
|
||||
|
||||
if !self.type_params.is_empty() {
|
||||
if !self.lifetimes.is_empty() {
|
||||
try!(f.write_str(", "));
|
||||
f.write_str(", ")?;
|
||||
}
|
||||
for (i, tp) in self.type_params.iter().enumerate() {
|
||||
if i > 0 {
|
||||
try!(f.write_str(", "))
|
||||
f.write_str(", ")?
|
||||
}
|
||||
try!(f.write_str(&tp.name));
|
||||
f.write_str(&tp.name)?;
|
||||
|
||||
if !tp.bounds.is_empty() {
|
||||
try!(write!(f, ": {}", TyParamBounds(&tp.bounds)));
|
||||
write!(f, ": {}", TyParamBounds(&tp.bounds))?;
|
||||
}
|
||||
|
||||
match tp.default {
|
||||
Some(ref ty) => { try!(write!(f, " = {}", ty)); },
|
||||
Some(ref ty) => { write!(f, " = {}", ty)?; },
|
||||
None => {}
|
||||
};
|
||||
}
|
||||
}
|
||||
try!(f.write_str(">"));
|
||||
f.write_str(">")?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -140,40 +140,40 @@ impl<'a> fmt::Display for WhereClause<'a> {
|
||||
if gens.where_predicates.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
try!(f.write_str(" <span class='where'>where "));
|
||||
f.write_str(" <span class='where'>where ")?;
|
||||
for (i, pred) in gens.where_predicates.iter().enumerate() {
|
||||
if i > 0 {
|
||||
try!(f.write_str(", "));
|
||||
f.write_str(", ")?;
|
||||
}
|
||||
match pred {
|
||||
&clean::WherePredicate::BoundPredicate { ref ty, ref bounds } => {
|
||||
let bounds = bounds;
|
||||
try!(write!(f, "{}: {}", ty, TyParamBounds(bounds)));
|
||||
write!(f, "{}: {}", ty, TyParamBounds(bounds))?;
|
||||
}
|
||||
&clean::WherePredicate::RegionPredicate { ref lifetime,
|
||||
ref bounds } => {
|
||||
try!(write!(f, "{}: ", lifetime));
|
||||
write!(f, "{}: ", lifetime)?;
|
||||
for (i, lifetime) in bounds.iter().enumerate() {
|
||||
if i > 0 {
|
||||
try!(f.write_str(" + "));
|
||||
f.write_str(" + ")?;
|
||||
}
|
||||
|
||||
try!(write!(f, "{}", lifetime));
|
||||
write!(f, "{}", lifetime)?;
|
||||
}
|
||||
}
|
||||
&clean::WherePredicate::EqPredicate { ref lhs, ref rhs } => {
|
||||
try!(write!(f, "{} == {}", lhs, rhs));
|
||||
write!(f, "{} == {}", lhs, rhs)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
try!(f.write_str("</span>"));
|
||||
f.write_str("</span>")?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for clean::Lifetime {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
try!(f.write_str(self.get_ref()));
|
||||
f.write_str(self.get_ref())?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -181,14 +181,14 @@ impl fmt::Display for clean::Lifetime {
|
||||
impl fmt::Display for clean::PolyTrait {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
if !self.lifetimes.is_empty() {
|
||||
try!(f.write_str("for<"));
|
||||
f.write_str("for<")?;
|
||||
for (i, lt) in self.lifetimes.iter().enumerate() {
|
||||
if i > 0 {
|
||||
try!(f.write_str(", "));
|
||||
f.write_str(", ")?;
|
||||
}
|
||||
try!(write!(f, "{}", lt));
|
||||
write!(f, "{}", lt)?;
|
||||
}
|
||||
try!(f.write_str("> "));
|
||||
f.write_str("> ")?;
|
||||
}
|
||||
write!(f, "{}", self.trait_)
|
||||
}
|
||||
@@ -218,46 +218,46 @@ impl fmt::Display for clean::PathParameters {
|
||||
ref lifetimes, ref types, ref bindings
|
||||
} => {
|
||||
if !lifetimes.is_empty() || !types.is_empty() || !bindings.is_empty() {
|
||||
try!(f.write_str("<"));
|
||||
f.write_str("<")?;
|
||||
let mut comma = false;
|
||||
for lifetime in lifetimes {
|
||||
if comma {
|
||||
try!(f.write_str(", "));
|
||||
f.write_str(", ")?;
|
||||
}
|
||||
comma = true;
|
||||
try!(write!(f, "{}", *lifetime));
|
||||
write!(f, "{}", *lifetime)?;
|
||||
}
|
||||
for ty in types {
|
||||
if comma {
|
||||
try!(f.write_str(", "));
|
||||
f.write_str(", ")?;
|
||||
}
|
||||
comma = true;
|
||||
try!(write!(f, "{}", *ty));
|
||||
write!(f, "{}", *ty)?;
|
||||
}
|
||||
for binding in bindings {
|
||||
if comma {
|
||||
try!(f.write_str(", "));
|
||||
f.write_str(", ")?;
|
||||
}
|
||||
comma = true;
|
||||
try!(write!(f, "{}", *binding));
|
||||
write!(f, "{}", *binding)?;
|
||||
}
|
||||
try!(f.write_str(">"));
|
||||
f.write_str(">")?;
|
||||
}
|
||||
}
|
||||
clean::PathParameters::Parenthesized { ref inputs, ref output } => {
|
||||
try!(f.write_str("("));
|
||||
f.write_str("(")?;
|
||||
let mut comma = false;
|
||||
for ty in inputs {
|
||||
if comma {
|
||||
try!(f.write_str(", "));
|
||||
f.write_str(", ")?;
|
||||
}
|
||||
comma = true;
|
||||
try!(write!(f, "{}", *ty));
|
||||
write!(f, "{}", *ty)?;
|
||||
}
|
||||
try!(f.write_str(")"));
|
||||
f.write_str(")")?;
|
||||
if let Some(ref ty) = *output {
|
||||
try!(f.write_str(" -> "));
|
||||
try!(write!(f, "{}", ty));
|
||||
f.write_str(" -> ")?;
|
||||
write!(f, "{}", ty)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -267,7 +267,7 @@ impl fmt::Display for clean::PathParameters {
|
||||
|
||||
impl fmt::Display for clean::PathSegment {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
try!(f.write_str(&self.name));
|
||||
f.write_str(&self.name)?;
|
||||
write!(f, "{}", self.params)
|
||||
}
|
||||
}
|
||||
@@ -275,14 +275,14 @@ impl fmt::Display for clean::PathSegment {
|
||||
impl fmt::Display for clean::Path {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
if self.global {
|
||||
try!(f.write_str("::"))
|
||||
f.write_str("::")?
|
||||
}
|
||||
|
||||
for (i, seg) in self.segments.iter().enumerate() {
|
||||
if i > 0 {
|
||||
try!(f.write_str("::"))
|
||||
f.write_str("::")?
|
||||
}
|
||||
try!(write!(f, "{}", seg));
|
||||
write!(f, "{}", seg)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -339,20 +339,20 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
|
||||
Some(mut root) => {
|
||||
for seg in &path.segments[..amt] {
|
||||
if "super" == seg.name || "self" == seg.name {
|
||||
try!(write!(w, "{}::", seg.name));
|
||||
write!(w, "{}::", seg.name)?;
|
||||
} else {
|
||||
root.push_str(&seg.name);
|
||||
root.push_str("/");
|
||||
try!(write!(w, "<a class='mod'
|
||||
write!(w, "<a class='mod'
|
||||
href='{}index.html'>{}</a>::",
|
||||
root,
|
||||
seg.name));
|
||||
seg.name)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
None => {
|
||||
for seg in &path.segments[..amt] {
|
||||
try!(write!(w, "{}::", seg.name));
|
||||
write!(w, "{}::", seg.name)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -360,12 +360,12 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
|
||||
|
||||
match href(did) {
|
||||
Some((url, shortty, fqp)) => {
|
||||
try!(write!(w, "<a class='{}' href='{}' title='{}'>{}</a>",
|
||||
shortty, url, fqp.join("::"), last.name));
|
||||
write!(w, "<a class='{}' href='{}' title='{}'>{}</a>",
|
||||
shortty, url, fqp.join("::"), last.name)?;
|
||||
}
|
||||
_ => try!(write!(w, "{}", last.name)),
|
||||
_ => write!(w, "{}", last.name)?,
|
||||
}
|
||||
try!(write!(w, "{}", last.params));
|
||||
write!(w, "{}", last.params)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -378,9 +378,9 @@ fn primitive_link(f: &mut fmt::Formatter,
|
||||
Some(&LOCAL_CRATE) => {
|
||||
let len = CURRENT_LOCATION_KEY.with(|s| s.borrow().len());
|
||||
let len = if len == 0 {0} else {len - 1};
|
||||
try!(write!(f, "<a class='primitive' href='{}primitive.{}.html'>",
|
||||
write!(f, "<a class='primitive' href='{}primitive.{}.html'>",
|
||||
repeat("../").take(len).collect::<String>(),
|
||||
prim.to_url_str()));
|
||||
prim.to_url_str())?;
|
||||
needs_termination = true;
|
||||
}
|
||||
Some(&cnum) => {
|
||||
@@ -398,10 +398,10 @@ fn primitive_link(f: &mut fmt::Formatter,
|
||||
};
|
||||
match loc {
|
||||
Some(root) => {
|
||||
try!(write!(f, "<a class='primitive' href='{}{}/primitive.{}.html'>",
|
||||
write!(f, "<a class='primitive' href='{}{}/primitive.{}.html'>",
|
||||
root,
|
||||
path.0.first().unwrap(),
|
||||
prim.to_url_str()));
|
||||
prim.to_url_str())?;
|
||||
needs_termination = true;
|
||||
}
|
||||
None => {}
|
||||
@@ -409,9 +409,9 @@ fn primitive_link(f: &mut fmt::Formatter,
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
try!(write!(f, "{}", name));
|
||||
write!(f, "{}", name)?;
|
||||
if needs_termination {
|
||||
try!(write!(f, "</a>"));
|
||||
write!(f, "</a>")?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -422,8 +422,8 @@ fn tybounds(w: &mut fmt::Formatter,
|
||||
match *typarams {
|
||||
Some(ref params) => {
|
||||
for param in params {
|
||||
try!(write!(w, " + "));
|
||||
try!(write!(w, "{}", *param));
|
||||
write!(w, " + ")?;
|
||||
write!(w, "{}", *param)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -439,7 +439,7 @@ impl fmt::Display for clean::Type {
|
||||
}
|
||||
clean::ResolvedPath{ did, ref typarams, ref path, is_generic } => {
|
||||
// Paths like T::Output and Self::Output should be rendered with all segments
|
||||
try!(resolved_path(f, did, path, is_generic));
|
||||
resolved_path(f, did, path, is_generic)?;
|
||||
tybounds(f, typarams)
|
||||
}
|
||||
clean::Infer => write!(f, "_"),
|
||||
@@ -459,25 +459,25 @@ impl fmt::Display for clean::Type {
|
||||
match &**typs {
|
||||
[] => primitive_link(f, clean::PrimitiveTuple, "()"),
|
||||
[ref one] => {
|
||||
try!(primitive_link(f, clean::PrimitiveTuple, "("));
|
||||
try!(write!(f, "{},", one));
|
||||
primitive_link(f, clean::PrimitiveTuple, "(")?;
|
||||
write!(f, "{},", one)?;
|
||||
primitive_link(f, clean::PrimitiveTuple, ")")
|
||||
}
|
||||
many => {
|
||||
try!(primitive_link(f, clean::PrimitiveTuple, "("));
|
||||
try!(write!(f, "{}", CommaSep(&many)));
|
||||
primitive_link(f, clean::PrimitiveTuple, "(")?;
|
||||
write!(f, "{}", CommaSep(&many))?;
|
||||
primitive_link(f, clean::PrimitiveTuple, ")")
|
||||
}
|
||||
}
|
||||
}
|
||||
clean::Vector(ref t) => {
|
||||
try!(primitive_link(f, clean::Slice, &format!("[")));
|
||||
try!(write!(f, "{}", t));
|
||||
primitive_link(f, clean::Slice, &format!("["))?;
|
||||
write!(f, "{}", t)?;
|
||||
primitive_link(f, clean::Slice, &format!("]"))
|
||||
}
|
||||
clean::FixedVector(ref t, ref s) => {
|
||||
try!(primitive_link(f, clean::PrimitiveType::Array, "["));
|
||||
try!(write!(f, "{}", t));
|
||||
primitive_link(f, clean::PrimitiveType::Array, "[")?;
|
||||
write!(f, "{}", t)?;
|
||||
primitive_link(f, clean::PrimitiveType::Array,
|
||||
&format!("; {}]", *s))
|
||||
}
|
||||
@@ -489,8 +489,8 @@ impl fmt::Display for clean::Type {
|
||||
&format!("*{}{}", RawMutableSpace(m), t))
|
||||
}
|
||||
_ => {
|
||||
try!(primitive_link(f, clean::PrimitiveType::PrimitiveRawPointer,
|
||||
&format!("*{}", RawMutableSpace(m))));
|
||||
primitive_link(f, clean::PrimitiveType::PrimitiveRawPointer,
|
||||
&format!("*{}", RawMutableSpace(m)))?;
|
||||
write!(f, "{}", t)
|
||||
}
|
||||
}
|
||||
@@ -508,9 +508,9 @@ impl fmt::Display for clean::Type {
|
||||
primitive_link(f, clean::Slice,
|
||||
&format!("&{}{}[{}]", lt, m, **bt)),
|
||||
_ => {
|
||||
try!(primitive_link(f, clean::Slice,
|
||||
&format!("&{}{}[", lt, m)));
|
||||
try!(write!(f, "{}", **bt));
|
||||
primitive_link(f, clean::Slice,
|
||||
&format!("&{}{}[", lt, m))?;
|
||||
write!(f, "{}", **bt)?;
|
||||
primitive_link(f, clean::Slice, "]")
|
||||
}
|
||||
}
|
||||
@@ -523,9 +523,9 @@ impl fmt::Display for clean::Type {
|
||||
clean::PolyTraitRef(ref bounds) => {
|
||||
for (i, bound) in bounds.iter().enumerate() {
|
||||
if i != 0 {
|
||||
try!(write!(f, " + "));
|
||||
write!(f, " + ")?;
|
||||
}
|
||||
try!(write!(f, "{}", *bound));
|
||||
write!(f, "{}", *bound)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -544,9 +544,9 @@ impl fmt::Display for clean::Type {
|
||||
ref self_type,
|
||||
trait_: box clean::ResolvedPath { did, ref typarams, .. },
|
||||
} => {
|
||||
try!(write!(f, "{}::", self_type));
|
||||
write!(f, "{}::", self_type)?;
|
||||
let path = clean::Path::singleton(name.clone());
|
||||
try!(resolved_path(f, did, &path, false));
|
||||
resolved_path(f, did, &path, false)?;
|
||||
|
||||
// FIXME: `typarams` are not rendered, and this seems bad?
|
||||
drop(typarams);
|
||||
@@ -564,13 +564,13 @@ impl fmt::Display for clean::Type {
|
||||
|
||||
impl fmt::Display for clean::Impl {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
try!(write!(f, "impl{} ", self.generics));
|
||||
write!(f, "impl{} ", self.generics)?;
|
||||
if let Some(ref ty) = self.trait_ {
|
||||
try!(write!(f, "{}{} for ",
|
||||
write!(f, "{}{} for ",
|
||||
if self.polarity == Some(clean::ImplPolarity::Negative) { "!" } else { "" },
|
||||
*ty));
|
||||
*ty)?;
|
||||
}
|
||||
try!(write!(f, "{}{}", self.for_, WhereClause(&self.generics)));
|
||||
write!(f, "{}{}", self.for_, WhereClause(&self.generics))?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -578,11 +578,11 @@ impl fmt::Display for clean::Impl {
|
||||
impl fmt::Display for clean::Arguments {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
for (i, input) in self.values.iter().enumerate() {
|
||||
if i > 0 { try!(write!(f, ", ")); }
|
||||
if i > 0 { write!(f, ", ")?; }
|
||||
if !input.name.is_empty() {
|
||||
try!(write!(f, "{}: ", input.name));
|
||||
write!(f, "{}: ", input.name)?;
|
||||
}
|
||||
try!(write!(f, "{}", input.type_));
|
||||
write!(f, "{}", input.type_)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -678,12 +678,12 @@ impl fmt::Display for clean::Import {
|
||||
write!(f, "use {}::*;", *src)
|
||||
}
|
||||
clean::ImportList(ref src, ref names) => {
|
||||
try!(write!(f, "use {}::{{", *src));
|
||||
write!(f, "use {}::{{", *src)?;
|
||||
for (i, n) in names.iter().enumerate() {
|
||||
if i > 0 {
|
||||
try!(write!(f, ", "));
|
||||
write!(f, ", ")?;
|
||||
}
|
||||
try!(write!(f, "{}", *n));
|
||||
write!(f, "{}", *n)?;
|
||||
}
|
||||
write!(f, "}};")
|
||||
}
|
||||
@@ -698,9 +698,9 @@ impl fmt::Display for clean::ImportSource {
|
||||
_ => {
|
||||
for (i, seg) in self.path.segments.iter().enumerate() {
|
||||
if i > 0 {
|
||||
try!(write!(f, "::"))
|
||||
write!(f, "::")?
|
||||
}
|
||||
try!(write!(f, "{}", seg.name));
|
||||
write!(f, "{}", seg.name)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -713,13 +713,13 @@ impl fmt::Display for clean::ViewListIdent {
|
||||
match self.source {
|
||||
Some(did) => {
|
||||
let path = clean::Path::singleton(self.name.clone());
|
||||
try!(resolved_path(f, did, &path, false));
|
||||
resolved_path(f, did, &path, false)?;
|
||||
}
|
||||
_ => try!(write!(f, "{}", self.name)),
|
||||
_ => write!(f, "{}", self.name)?,
|
||||
}
|
||||
|
||||
if let Some(ref name) = self.rename {
|
||||
try!(write!(f, " as {}", name));
|
||||
write!(f, " as {}", name)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user