Skip to content

Commit a2b570a

Browse files
author
Ray Redondo
committed
chore: misc code cleanup
1 parent fd4283e commit a2b570a

File tree

15 files changed

+83
-55
lines changed

15 files changed

+83
-55
lines changed

rust/src/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ impl core::fmt::Display for SimplePath {
719719
let mut sep = if self.from_root { "::" } else { "" };
720720

721721
for seg in &self.segments {
722-
f.write_str(sep);
722+
f.write_str(sep)?;
723723
sep = "::";
724724
seg.body.fmt(f)?;
725725
}

rust/src/feature.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::interning::Symbol;
22
use core::num::NonZeroU32;
33

4+
#[allow(dead_code)]
45
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
56
pub enum FeatureState {
67
Stable(Since),
@@ -20,11 +21,13 @@ pub struct TrackingIssue {
2021
pub issue_number: NonZeroU32,
2122
}
2223

24+
#[allow(dead_code)]
2325
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
2426
pub enum Repo {
2527
Lccc,
2628
Rust,
2729
Custom(Symbol),
2830
}
2931

32+
#[allow(dead_code)]
3033
pub struct Features {}

rust/src/lang.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pub enum LangItemTarget {
33
Type,
44
Variant,
55
Function,
6+
#[allow(dead_code)]
67
AssociatedType,
78
AssociatedFunction,
89
Trait,

rust/src/lex.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ macro_rules! punctuation {
221221
}
222222
}
223223

224+
#[allow(dead_code)]
224225
pub const fn symbol(&self) -> &'static str {
225226
match self {
226227
$(Self::$name => ::core::stringify!($tok)),*

rust/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use xlang::abi::result::Result;
2525
use xlang::abi::string::StringView;
2626
use xlang::ir;
2727
use xlang::plugin::{Error, XLangFrontend, XLangPlugin};
28-
use xlang::targets::properties::{get_properties, TargetProperties};
28+
use xlang::targets::properties::TargetProperties;
2929

3030
use crate::{
3131
irgen::irgen,

rust/src/macro_parse.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ impl core::fmt::Display for MacroDefId {
1313
}
1414
}
1515

16+
#[allow(dead_code)]
1617
pub struct Macros {
1718
nextdefid: u64,
1819
}

rust/src/parse.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ pub fn do_token_classes(
223223
if let Some(err) = error.as_mut() {
224224
*err |= e;
225225
} else {
226-
error.insert(e);
226+
error = Some(e);
227227
}
228228
}
229229
}
@@ -258,7 +258,7 @@ pub fn do_alternation<R, I: Iterator<Item = Lexeme>>(
258258
if let Some(err) = err.as_mut() {
259259
*err |= e;
260260
} else {
261-
err.insert(e);
261+
err = Some(e);
262262
}
263263
}
264264
}
@@ -705,7 +705,7 @@ pub fn do_user_type_struct(
705705
_ => ctor,
706706
},
707707
Err(e) => match do_lexeme_class(&mut tree, LexemeClass::Punctuation(Punctuation::Semi)) {
708-
Ok(lex) => Spanned {
708+
Ok(_) => Spanned {
709709
body: Constructor::Unit,
710710
span: end_span.after(),
711711
},
@@ -765,7 +765,7 @@ pub fn do_if_block(
765765
let mut elseifs = Vec::new();
766766
let mut elseblock = None;
767767
while let Ok(Lexeme {
768-
span: else_span, ..
768+
..
769769
}) = do_lexeme_class(&mut tree, LexemeClass::Keyword(Keyword::Else))
770770
{
771771
match do_lexeme_class(&mut tree, LexemeClass::Keyword(Keyword::If)) {
@@ -1283,7 +1283,7 @@ pub fn do_control_flow_expr<const ALLOW_CONSTRUCTOR: bool>(
12831283
span: tspan,
12841284
})
12851285
}
1286-
Err(e_) => None,
1286+
Err(_) => None,
12871287
};
12881288

12891289
let expr = match do_expression_maybe_constructor::<ALLOW_CONSTRUCTOR>(&mut tree) {
@@ -1326,7 +1326,7 @@ pub fn do_control_flow_expr<const ALLOW_CONSTRUCTOR: bool>(
13261326
span: tspan,
13271327
})
13281328
}
1329-
Err(e_) => None,
1329+
Err(_) => None,
13301330
};
13311331

13321332
Ok(Spanned {
@@ -1770,7 +1770,7 @@ pub fn do_raw_ref(
17701770
Err(e) => Err(e),
17711771
}
17721772
}
1773-
Ok((span, tok)) => Err(Error {
1773+
Ok((span, _)) => Err(Error {
17741774
expected: vec![keyword!(raw)],
17751775
got: LexemeClass::Identifier,
17761776
span,
@@ -1888,7 +1888,6 @@ pub fn do_unary_expression<const ALLOW_CONSTRUCTOR: bool>(
18881888
);
18891889
Ok(Spanned { body: expr, span })
18901890
}
1891-
_ => unreachable!(),
18921891
},
18931892
Ok(_) => unreachable!(),
18941893
Err(e) => match do_suffix_expression::<ALLOW_CONSTRUCTOR>(&mut tree) {
@@ -2543,7 +2542,8 @@ pub fn do_item_fn(
25432542
})
25442543
}
25452544

2546-
pub fn do_reciever(
2545+
#[allow(dead_code)]
2546+
pub fn do_receiver(
25472547
tree: &mut PeekMoreIterator<impl Iterator<Item = Lexeme>>,
25482548
) -> Result<Spanned<SelfParam>> {
25492549
let mut tree = tree.into_rewinder();
@@ -2563,7 +2563,7 @@ pub fn do_reciever(
25632563
tree.accept();
25642564
Ok(Spanned { span, body })
25652565
}
2566-
Err(e) => {
2566+
Err(_) => {
25672567
let mt = do_lexeme_token(&mut tree, keyword!(mut))
25682568
.map(|(span, _)| Spanned {
25692569
span,
@@ -2588,6 +2588,7 @@ pub fn do_reciever(
25882588
}
25892589
}
25902590

2591+
#[allow(dead_code)]
25912592
pub fn do_item_fn_in_trait(
25922593
tree: &mut PeekMoreIterator<impl Iterator<Item = Lexeme>>,
25932594
) -> Result<Spanned<ItemBody>> {
@@ -2607,7 +2608,7 @@ pub fn do_item_fn_in_trait(
26072608
// TODO: receiver
26082609
let mut params_tree = params_group.body.into_iter().peekmore();
26092610

2610-
let reciever = match do_reciever(&mut params_tree) {
2611+
let _receiver = match do_receiver(&mut params_tree) {
26112612
Ok(x) => {
26122613
do_lexeme_classes(&mut params_tree, &[punct!(,), LexemeClass::Eof])?;
26132614
Some(x)
@@ -2871,12 +2872,12 @@ pub fn do_item_trait(
28712872
loop {
28722873
match do_type_bound(&mut tree) {
28732874
Ok(bound) => bounds_list.push(bound),
2874-
Err(e) => break,
2875+
Err(_) => break,
28752876
}
28762877

28772878
match do_lexeme_classes(&mut tree, &[punct!(+)]) {
28782879
Ok(_) => continue,
2879-
Err(e) => break,
2880+
Err(_) => break,
28802881
}
28812882
}
28822883
Some(bounds_list)

0 commit comments

Comments
 (0)