Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use #[expect(lint)] where possible #68

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

pub mod ast;
pub mod parse {
#![allow(unused_braces)]
#![allow(unused_comparisons)] // FIXME
#![allow(clippy::collapsible_if)]
#![allow(clippy::if_same_then_else)]
#![allow(clippy::absurd_extreme_comparisons)] // FIXME
#![allow(clippy::needless_return)]
#![allow(clippy::upper_case_acronyms)]
#![allow(clippy::manual_range_patterns)]
#![expect(unused_braces)]
#![expect(clippy::if_same_then_else)]
#![expect(clippy::absurd_extreme_comparisons)] // FIXME
#![expect(clippy::needless_return)]
#![expect(clippy::upper_case_acronyms)]
#![expect(clippy::manual_range_patterns)]

include!(concat!(env!("OUT_DIR"), "/parse.rs"));
}
Expand Down
2 changes: 1 addition & 1 deletion src/parser/parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ use crate::dialect::{from_bytes, from_token, Token, TokenType};
use indexmap::IndexMap;
use log::error;

#[allow(non_camel_case_types)]
#[expect(non_camel_case_types)]
type sqlite3ParserError = crate::parser::ParserError;
} // end %include

Expand Down
28 changes: 13 additions & 15 deletions third_party/lemon/lemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -4197,10 +4197,10 @@ void print_stack_union(
/* Print out the definition of YYTOKENTYPE and YYMINORTYPE */
name = lemp->name ? lemp->name : "Parse";
lineno = *plineno;
fprintf(out,"#[allow(non_camel_case_types)]\n"); lineno++;
fprintf(out,"#[expect(non_camel_case_types)]\n"); lineno++;
fprintf(out,"type %sTOKENTYPE<'i> = %s;\n",name,
lemp->tokentype?lemp->tokentype:"()"); lineno++;
fprintf(out,"#[allow(non_camel_case_types)]\n"); lineno++;
fprintf(out,"#[expect(non_camel_case_types)]\n"); lineno++;
fprintf(out,"enum YYMINORTYPE<'i> {\n"); lineno++;
fprintf(out," yyinit(),\n"); lineno++;
fprintf(out," yy0(%sTOKENTYPE<'i>),\n",name); lineno++;
Expand Down Expand Up @@ -4489,7 +4489,7 @@ void ReportTable(
if( lemp->tokenprefix ) prefix = lemp->tokenprefix;
else prefix = "";
if( mhflag ){
fprintf(out,"#[allow(non_camel_case_types)]\n"); lineno++;
fprintf(out,"#[expect(non_camel_case_types)]\n"); lineno++;
fprintf(out,"#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd)]\n"); lineno++;
fprintf(out,"#[repr(%s)]\n",
minimum_size_type(0, lemp->nsymbol+1, 0)); lineno++;
Expand All @@ -4504,11 +4504,9 @@ void ReportTable(
tplt_xfer(lemp->name,in,out,&lineno);

/* Generate the defines */
fprintf(out,"#[allow(non_camel_case_types)]\n"); lineno++;
fprintf(out,"pub type YYCODETYPE = %s; // unsigned\n",
minimum_size_type(0, lemp->nsymbol+1, &szCodeType)); lineno++;
fprintf(out,"const YYNOCODE: YYCODETYPE = %d;\n",lemp->nsymbol); lineno++;
fprintf(out,"#[allow(non_camel_case_types)]\n"); lineno++;
fprintf(out,"type YYACTIONTYPE = %s; // unsigned\n",
minimum_size_type(0,lemp->maxAction,&szActionType)); lineno++;
if( lemp->wildcard ){
Expand Down Expand Up @@ -4648,7 +4646,7 @@ void ReportTable(
lemp->tablesize += n*szActionType;
fprintf(out,"macro_rules! YY_ACTTAB_COUNT {() => {%d}}\n", n); lineno++;
fprintf(out,"#[rustfmt::skip]\n"); lineno++;
fprintf(out,"#[allow(non_upper_case_globals)]\n"); lineno++;
fprintf(out,"#[expect(non_upper_case_globals)]\n"); lineno++;
fprintf(out,"static yy_action: [YYACTIONTYPE; %d] = [\n", n); lineno++;
for(i=j=0; i<n; i++){
int action = acttab_yyaction(pActtab, i);
Expand All @@ -4668,7 +4666,7 @@ void ReportTable(
lemp->nlookaheadtab = n = acttab_lookahead_size(pActtab);
lemp->tablesize += n*szCodeType;
fprintf(out,"#[rustfmt::skip]\n"); lineno++;
fprintf(out,"#[allow(non_upper_case_globals)]\n"); lineno++;
fprintf(out,"#[expect(non_upper_case_globals)]\n"); lineno++;
nLookAhead = lemp->nterminal + lemp->nactiontab;
fprintf(out,"static yy_lookahead: [YYCODETYPE; %d] = [\n", nLookAhead); lineno++;
for(i=j=0; i<n; i++){
Expand Down Expand Up @@ -4703,14 +4701,14 @@ void ReportTable(
/* Output the yy_shift_ofst[] table */
n = lemp->nxstate;
while( n>0 && lemp->sorted[n-1]->iTknOfst==NO_OFFSET ) n--;
fprintf(out, "#[allow(non_camel_case_types)]\n"); lineno++;
fprintf(out, "#[expect(non_camel_case_types)]\n"); lineno++;
fprintf(out, "type YY_SHIFT_TYPE = %s;\n",
minimum_size_type(mnTknOfst, lemp->nterminal+lemp->nactiontab, &sz)); lineno++;
fprintf(out, "const YY_SHIFT_COUNT: YYACTIONTYPE = %d;\n", n-1); lineno++;
fprintf(out, "//const YY_SHIFT_MIN: YY_SHIFT_TYPE = %d;\n", mnTknOfst); lineno++;
fprintf(out, "//const YY_SHIFT_MAX: YY_SHIFT_TYPE = %d;\n", mxTknOfst); lineno++;
fprintf(out, "#[rustfmt::skip]\n"); lineno++;
fprintf(out, "#[allow(non_upper_case_globals)]\n"); lineno++;
fprintf(out, "#[expect(non_upper_case_globals)]\n"); lineno++;
fprintf(out, "static yy_shift_ofst: [YY_SHIFT_TYPE; %d] = [\n", n); lineno++;
lemp->tablesize += n*sz;
for(i=j=0; i<n; i++){
Expand All @@ -4730,7 +4728,7 @@ void ReportTable(
fprintf(out, "];\n"); lineno++;

/* Output the yy_reduce_ofst[] table */
fprintf(out, "#[allow(non_camel_case_types)]\n"); lineno++;
fprintf(out, "#[expect(non_camel_case_types)]\n"); lineno++;
fprintf(out, "type YY_REDUCE_TYPE = %s;\n",
minimum_size_type(mnNtOfst-1, mxNtOfst, &sz)); lineno++;
n = lemp->nxstate;
Expand All @@ -4739,7 +4737,7 @@ void ReportTable(
fprintf(out, "//const YY_REDUCE_MIN: YY_REDUCE_TYPE = %d;\n", mnNtOfst); lineno++;
fprintf(out, "//const YY_REDUCE_MAX: YY_REDUCE_TYPE = %d;\n", mxNtOfst); lineno++;
fprintf(out, "#[rustfmt::skip]\n"); lineno++;
fprintf(out, "#[allow(non_upper_case_globals)]\n"); lineno++;
fprintf(out, "#[expect(non_upper_case_globals)]\n"); lineno++;
fprintf(out, "static yy_reduce_ofst: [YY_REDUCE_TYPE; %d] = [\n", n); lineno++;
lemp->tablesize += n*sz;
for(i=j=0; i<n; i++){
Expand All @@ -4761,7 +4759,7 @@ void ReportTable(
/* Output the default action table */
n = lemp->nxstate;
fprintf(out, "#[rustfmt::skip]\n"); lineno++;
fprintf(out, "#[allow(non_upper_case_globals)]\n"); lineno++;
fprintf(out, "#[expect(non_upper_case_globals)]\n"); lineno++;
fprintf(out, "static yy_default: [YYACTIONTYPE; %d] = [\n", n); lineno++;
lemp->tablesize += n*szActionType;
for(i=j=0; i<n; i++){
Expand All @@ -4784,7 +4782,7 @@ void ReportTable(

/* Generate the table of fallback tokens.
*/
fprintf(out, "#[allow(non_upper_case_globals)]\n"); lineno++;
fprintf(out, "#[expect(non_upper_case_globals)]\n"); lineno++;
if( lemp->has_fallback ){
int mx = lemp->nterminal - 1;
/* 2019-08-28: Generate fallback entries for every token to avoid
Expand Down Expand Up @@ -4818,7 +4816,7 @@ void ReportTable(
/* Generate a table containing the symbolic name of every symbol
*/
fprintf(out, "#[rustfmt::skip]\n"); lineno++;
fprintf(out, "#[allow(non_upper_case_globals)]\n"); lineno++;
fprintf(out, "#[expect(non_upper_case_globals)]\n"); lineno++;
fprintf(out, "static yyTokenName: [&str; %d] = [\n", lemp->nsymbol); lineno++;
for(i=0; i<lemp->nsymbol; i++){
fprintf(out," /* %4d */ \"%s\",\n",i, lemp->symbols[i]->name); lineno++;
Expand Down Expand Up @@ -4966,7 +4964,7 @@ void ReportHeader(struct lemon *lemp)
out = file_open(lemp,".h","wb");
if( out ){
fprintf(out,"#[non_exhaustive]\n");
fprintf(out,"#[allow(non_camel_case_types)]\n");
fprintf(out,"#[expect(non_camel_case_types)]\n");
fprintf(out,"#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd)]\n");
fprintf(out,"#[repr(%s)]\n",
minimum_size_type(0, lemp->nsymbol+1, 0));
Expand Down
26 changes: 13 additions & 13 deletions third_party/lemon/lempar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
** actually contains the reduce action for the second half of the
** SHIFTREDUCE.
*/
#[allow(non_camel_case_types)]
#[expect(non_camel_case_types)]
#[derive(Default)]
pub struct yyStackEntry<'i> {
stateno: YYACTIONTYPE, /* The state-number, or reduce action in SHIFTREDUCE */
Expand All @@ -176,7 +176,7 @@ pub struct yyStackEntry<'i> {

/* The state of the parser is completely contained in an instance of
** the following structure */
#[allow(non_camel_case_types)]
#[expect(non_camel_case_types)]
pub struct yyParser<'input> {
yyidx: usize, /* Index to top element of the stack */
#[cfg(feature = "YYTRACKMAXSTACKDEPTH")]
Expand Down Expand Up @@ -251,7 +251,7 @@ static TARGET: &str = "Parse";
*/
#[cfg(not(feature = "NDEBUG"))]
#[rustfmt::skip]
#[allow(non_upper_case_globals)]
#[expect(non_upper_case_globals)]
static yyRuleName: [&str; YYNRULE] = [
%%
];
Expand Down Expand Up @@ -318,7 +318,7 @@ impl yyParser<'_> {
** Clear all secondary memory allocations from the parser
*/
impl yyParser<'_> {
#[allow(non_snake_case)]
#[expect(non_snake_case)]
pub fn ParseFinalize(&mut self) {
while self.yyidx > 0 {
self.yy_pop_parser_stack();
Expand All @@ -332,7 +332,7 @@ impl yyParser<'_> {
*/
#[cfg(feature = "YYTRACKMAXSTACKDEPTH")]
impl yyParser<'_> {
#[allow(non_snake_case)]
#[expect(non_snake_case)]
pub fn ParseStackPeak(&self) -> usize {
self.yyhwm
}
Expand Down Expand Up @@ -388,7 +388,7 @@ fn ParseCoverage(/*FILE *out*/) -> i32 {
** Find the appropriate action for a parser given the terminal
** look-ahead token iLookAhead.
*/
#[allow(non_snake_case)]
#[expect(non_snake_case)]
fn yy_find_shift_action(
mut iLookAhead: YYCODETYPE, /* The look-ahead token */
stateno: YYACTIONTYPE, /* Current state number */
Expand Down Expand Up @@ -452,7 +452,7 @@ fn yy_find_shift_action(
** Find the appropriate action for a parser given the non-terminal
** look-ahead token iLookAhead.
*/
#[allow(non_snake_case)]
#[expect(non_snake_case)]
fn yy_find_reduce_action(
stateno: YYACTIONTYPE, /* Current state number */
iLookAhead: YYCODETYPE, /* The look-ahead token */
Expand Down Expand Up @@ -486,11 +486,11 @@ fn yy_find_reduce_action(
** Print tracing information for a SHIFT action
*/
impl yyParser<'_> {
#[allow(non_snake_case)]
#[expect(non_snake_case)]
#[cfg(feature = "NDEBUG")]
fn yyTraceShift(&self, _: YYACTIONTYPE, _: &str) {
}
#[allow(non_snake_case)]
#[expect(non_snake_case)]
#[cfg(not(feature = "NDEBUG"))]
fn yyTraceShift(&self, yyNewState: YYACTIONTYPE, zTag: &str) {
let yytos = &self[0];
Expand All @@ -515,7 +515,7 @@ impl yyParser<'_> {
** Perform a shift action.
*/
impl<'input> yyParser<'input> {
#[allow(non_snake_case)]
#[expect(non_snake_case)]
fn yy_shift(
&mut self,
mut yyNewState: YYACTIONTYPE, /* The new state to shift in */
Expand All @@ -542,14 +542,14 @@ impl<'input> yyParser<'input> {

/* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
** of that rule */
#[allow(non_upper_case_globals)]
#[expect(non_upper_case_globals)]
static yyRuleInfoLhs: [YYCODETYPE; YYNRULE] = [
%%
];

/* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
** of symbols on the right-hand side of that rule. */
#[allow(non_upper_case_globals)]
#[expect(non_upper_case_globals)]
static yyRuleInfoNRhs: [i8; YYNRULE] = [
%%
];
Expand Down Expand Up @@ -689,7 +689,7 @@ impl yyParser<'_> {
** None.
*/
impl<'input> yyParser<'input> {
#[allow(non_snake_case)]
#[expect(non_snake_case)]
pub fn Parse(
&mut self,
yymajor: TokenType, /* The major token code number */
Expand Down
Loading