summaryrefslogtreecommitdiff
path: root/dhall/src/syntax/text
diff options
context:
space:
mode:
authorNadrieril Feneanar2020-03-17 23:36:12 +0000
committerGitHub2020-03-17 23:36:12 +0000
commit6c18f2b698874d125532625e2bedaa6621962074 (patch)
treedc8eec542bdbbb39bc24b8b43e1abf20490e6702 /dhall/src/syntax/text
parent681dad33cf27b2be4f4b3cefd83998af1d7eefb2 (diff)
parent715a941333887c4a29c2c49102bf1455d88a5417 (diff)
Merge pull request #144 from Nadrieril/clippy
Clippy
Diffstat (limited to 'dhall/src/syntax/text')
-rw-r--r--dhall/src/syntax/text/parser.rs35
-rw-r--r--dhall/src/syntax/text/printer.rs2
2 files changed, 25 insertions, 12 deletions
diff --git a/dhall/src/syntax/text/parser.rs b/dhall/src/syntax/text/parser.rs
index b3c2c40..5686300 100644
--- a/dhall/src/syntax/text/parser.rs
+++ b/dhall/src/syntax/text/parser.rs
@@ -267,9 +267,10 @@ impl DhallParser {
};
if s.len() > 8 {
- Err(input.error(format!(
+ return Err(input.error(
"Escape sequences can't have more than 8 chars"
- )))?
+ .to_string(),
+ ));
}
// pad with zeroes
@@ -282,9 +283,12 @@ impl DhallParser {
let bytes: &[u8] = &hex::decode(s).unwrap();
let i = u32::from_be_bytes(bytes.try_into().unwrap());
match i {
- 0xD800..=0xDFFF => Err(input.error(format!(
- "Escape sequences can't contain surrogate pairs"
- )))?,
+ 0xD800..=0xDFFF => {
+ return Err(input.error(
+ "Escape sequences can't contain surrogate pairs"
+ .to_string(),
+ ))
+ }
0x0FFFE..=0x0FFFF
| 0x1FFFE..=0x1FFFF
| 0x2FFFE..=0x2FFFF
@@ -301,9 +305,12 @@ impl DhallParser {
| 0xDFFFE..=0xDFFFF
| 0xEFFFE..=0xEFFFF
| 0xFFFFE..=0xFFFFF
- | 0x10_FFFE..=0x10_FFFF => Err(input.error(format!(
- "Escape sequences can't contain non-characters"
- )))?,
+ | 0x10_FFFE..=0x10_FFFF => {
+ return Err(input.error(
+ "Escape sequences can't contain non-characters"
+ .to_string(),
+ ))
+ }
_ => {}
}
let c: char = i.try_into().unwrap();
@@ -389,7 +396,9 @@ impl DhallParser {
"Kind" => Const(crate::syntax::Const::Kind),
"Sort" => Const(crate::syntax::Const::Sort),
_ => {
- Err(input.error(format!("Unrecognized builtin: '{}'", s)))?
+ return Err(
+ input.error(format!("Unrecognized builtin: '{}'", s))
+ )
}
},
};
@@ -620,7 +629,9 @@ impl DhallParser {
let protocol = &s[..6];
let hash = &s[7..];
if protocol != "sha256" {
- Err(input.error(format!("Unknown hashing protocol '{}'", protocol)))?
+ return Err(
+ input.error(format!("Unknown hashing protocol '{}'", protocol))
+ );
}
Ok(Hash::SHA256(hex::decode(hash).unwrap()))
}
@@ -767,7 +778,9 @@ impl DhallParser {
bool_eq => BoolEQ,
bool_ne => BoolNE,
equivalent => Equivalence,
- r => Err(op.error(format!("Rule {:?} isn't an operator", r)))?,
+ r => {
+ return Err(op.error(format!("Rule {:?} isn't an operator", r)))
+ }
};
Ok(spanned_union(l.span(), r.span(), BinOp(op, l, r)))
diff --git a/dhall/src/syntax/text/printer.rs b/dhall/src/syntax/text/printer.rs
index a8991b0..e9584bb 100644
--- a/dhall/src/syntax/text/printer.rs
+++ b/dhall/src/syntax/text/printer.rs
@@ -29,7 +29,7 @@ impl<'a> PhasedExpr<'a> {
impl UnspannedExpr {
// Annotate subexpressions with the appropriate phase, defaulting to Base
- fn annotate_with_phases<'a>(&'a self) -> ExprKind<PhasedExpr<'a>> {
+ fn annotate_with_phases(&self) -> ExprKind<PhasedExpr<'_>> {
use crate::syntax::ExprKind::*;
use PrintPhase::*;
let with_base = self.map_ref(|e| PhasedExpr(e, Base));