Use clippy (#276)
* cton-util: fix some clippy unnecessary pass-by-value warnings * clippy: ignore too many arguments / cyclomatic complexity in module since these functions are taking args coming from the command line, i dont think this is actually a valid lint, morally the arguments are all from one structure * cton-util: take care of remaining clippy warnings * cton-reader: fix all non-suspicious clippy warnings * cton-reader: disable clippy at site of suspicious lint * cton-frontend: disable clippy at the site of an invalid lint * cton-frontend: fix clippy warnings, or ignore benign ones * clippy: ignore the camelcase word WebAssembly in docs * cton-wasm: fix clippy complaints or ignore benign ones * cton-wasm tests: fix clippy complaints * cretonne: starting point turns off all clippy warnings * cretonne: clippy fixes, or lower allow() to source of problem * cretonne: more clippy fixes * cretonne: fix or disable needless_lifetimes lint this linter is buggy when the declared lifetime is used for another type constraint. * cretonne: fix clippy complaint about Pass::NoPass * rustfmt * fix prev minor api changes clippy suggested * add clippy to test-all * cton-filetests: clippy fixes * simplify clippy reporting in test-all * cretonne: document clippy allows better * cretonne: fix some more clippy lints * cretonne: fix clippy lints (mostly doc comments) * cretonne: allow all needless_lifetimes clippy warnings remove overrides at the false positives * rustfmt
This commit is contained in:
@@ -53,7 +53,7 @@ pub struct LocatedToken<'a> {
|
||||
}
|
||||
|
||||
/// Wrap up a `Token` with the given location.
|
||||
fn token<'a>(token: Token<'a>, loc: Location) -> Result<LocatedToken<'a>, LocatedError> {
|
||||
fn token(token: Token, loc: Location) -> Result<LocatedToken, LocatedError> {
|
||||
Ok(LocatedToken {
|
||||
token,
|
||||
location: loc,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Cretonne file reader library.
|
||||
//!
|
||||
//! The cton_reader library supports reading .cton files. This functionality is needed for testing
|
||||
//! The `cton_reader` library supports reading .cton files. This functionality is needed for testing
|
||||
//! Cretonne, but is not essential for a JIT compiler.
|
||||
|
||||
#![deny(missing_docs,
|
||||
|
||||
@@ -37,7 +37,7 @@ pub fn parse_functions(text: &str) -> Result<Vec<Function>> {
|
||||
/// Parse the entire `text` as a test case file.
|
||||
///
|
||||
/// The returned `TestFile` contains direct references to substrings of `text`.
|
||||
pub fn parse_test<'a>(text: &'a str) -> Result<TestFile<'a>> {
|
||||
pub fn parse_test(text: &str) -> Result<TestFile> {
|
||||
let _tt = timing::parse_text();
|
||||
let mut parser = Parser::new(text);
|
||||
// Gather the preamble comments.
|
||||
@@ -277,6 +277,10 @@ impl<'a> Parser<'a> {
|
||||
|
||||
// Get the current lookahead token, after making sure there is one.
|
||||
fn token(&mut self) -> Option<Token<'a>> {
|
||||
// clippy says self.lookahead is immutable so this loop is either infinite or never
|
||||
// running. I don't think this is true - self.lookahead is mutated in the loop body - so
|
||||
// maybe this is a clippy bug? Either way, disable clippy for this.
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(while_immutable_condition))]
|
||||
while self.lookahead == None {
|
||||
match self.lex.next() {
|
||||
Some(Ok(lexer::LocatedToken { token, location })) => {
|
||||
@@ -957,7 +961,7 @@ impl<'a> Parser<'a> {
|
||||
isa.register_info()
|
||||
.parse_regunit(name)
|
||||
.map(ArgumentLoc::Reg)
|
||||
.ok_or(self.error("invalid register name"))
|
||||
.ok_or_else(|| self.error("invalid register name"))
|
||||
} else {
|
||||
err!(self.loc, "argument location requires exactly one isa")
|
||||
}
|
||||
@@ -1392,12 +1396,12 @@ impl<'a> Parser<'a> {
|
||||
match self.token() {
|
||||
Some(Token::Arrow) => {
|
||||
self.consume();
|
||||
self.parse_value_alias(results, ctx)?;
|
||||
self.parse_value_alias(&results, ctx)?;
|
||||
}
|
||||
Some(Token::Equal) => {
|
||||
self.consume();
|
||||
self.parse_instruction(
|
||||
results,
|
||||
&results,
|
||||
srcloc,
|
||||
encoding,
|
||||
result_locations,
|
||||
@@ -1408,7 +1412,7 @@ impl<'a> Parser<'a> {
|
||||
_ if !results.is_empty() => return err!(self.loc, "expected -> or ="),
|
||||
_ => {
|
||||
self.parse_instruction(
|
||||
results,
|
||||
&results,
|
||||
srcloc,
|
||||
encoding,
|
||||
result_locations,
|
||||
@@ -1512,7 +1516,7 @@ impl<'a> Parser<'a> {
|
||||
isa.register_info()
|
||||
.parse_regunit(name)
|
||||
.map(ValueLoc::Reg)
|
||||
.ok_or(self.error("invalid register value location"))
|
||||
.ok_or_else(|| self.error("invalid register value location"))
|
||||
} else {
|
||||
err!(self.loc, "value location requires exactly one isa")
|
||||
}
|
||||
@@ -1601,7 +1605,7 @@ impl<'a> Parser<'a> {
|
||||
//
|
||||
// value_alias ::= [inst-results] "->" Value(v)
|
||||
//
|
||||
fn parse_value_alias(&mut self, results: Vec<Value>, ctx: &mut Context) -> Result<()> {
|
||||
fn parse_value_alias(&mut self, results: &[Value], ctx: &mut Context) -> Result<()> {
|
||||
if results.len() != 1 {
|
||||
return err!(self.loc, "wrong number of aliases");
|
||||
}
|
||||
@@ -1621,7 +1625,7 @@ impl<'a> Parser<'a> {
|
||||
//
|
||||
fn parse_instruction(
|
||||
&mut self,
|
||||
results: Vec<Value>,
|
||||
results: &[Value],
|
||||
srcloc: ir::SourceLoc,
|
||||
encoding: Option<Encoding>,
|
||||
result_locations: Option<Vec<ValueLoc>>,
|
||||
@@ -1629,7 +1633,7 @@ impl<'a> Parser<'a> {
|
||||
ebb: Ebb,
|
||||
) -> Result<()> {
|
||||
// Define the result values.
|
||||
for val in &results {
|
||||
for val in results {
|
||||
ctx.map.def_value(*val, &self.loc)?;
|
||||
}
|
||||
|
||||
@@ -1674,7 +1678,7 @@ impl<'a> Parser<'a> {
|
||||
let num_results = ctx.function.dfg.make_inst_results_for_parser(
|
||||
inst,
|
||||
ctrl_typevar,
|
||||
&results,
|
||||
results,
|
||||
);
|
||||
ctx.function.layout.append_inst(inst, ebb);
|
||||
ctx.map.def_entity(inst.into(), &opcode_loc).expect(
|
||||
@@ -1784,11 +1788,9 @@ impl<'a> Parser<'a> {
|
||||
opcode
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// Treat it as a syntax error to speficy a typevar on a non-polymorphic opcode.
|
||||
if ctrl_type != VOID {
|
||||
return err!(self.loc, "{} does not take a typevar", opcode);
|
||||
}
|
||||
// Treat it as a syntax error to speficy a typevar on a non-polymorphic opcode.
|
||||
} else if ctrl_type != VOID {
|
||||
return err!(self.loc, "{} does not take a typevar", opcode);
|
||||
}
|
||||
|
||||
Ok(ctrl_type)
|
||||
|
||||
@@ -13,7 +13,7 @@ use lexer::split_entity_name;
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// Mapping from entity names to source locations.
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct SourceMap {
|
||||
// Store locations for entities, including instructions.
|
||||
locations: HashMap<AnyEntity, Location>,
|
||||
|
||||
Reference in New Issue
Block a user