Skip to content

Commit 94035f9

Browse files
chore: fix compiler warnings
1 parent 9d3c295 commit 94035f9

File tree

5 files changed

+11
-39
lines changed

5 files changed

+11
-39
lines changed

Diff for: src/formatting.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ fn format_project(
100100
None
101101
};
102102

103-
let krate = match Parser::parse_crate(config, input, directory_ownership, &parse_session) {
103+
let krate = match Parser::parse_crate(input, &parse_session) {
104104
Ok(krate) => krate,
105105
Err(e) => {
106106
return Err(OperationError::ParseError {

Diff for: src/formatting/comment.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ impl<'a> Iterator for LineClasses<'a> {
14221422
None => unreachable!(),
14231423
};
14241424

1425-
let mut prev_kind = FullCodeCharKind::Normal;
1425+
let mut prev_kind: FullCodeCharKind;
14261426
while let Some((kind, c)) = self.base.next() {
14271427
prev_kind = self.kind;
14281428
// needed to set the kind of the ending character on the last line
@@ -1723,7 +1723,8 @@ fn remove_comment_header(comment: &str) -> &str {
17231723
} else {
17241724
assert!(
17251725
comment.starts_with("/*"),
1726-
format!("string '{}' is not a comment", comment)
1726+
"string '{}' is not a comment",
1727+
comment,
17271728
);
17281729
&comment[2..comment.len() - 2]
17291730
}

Diff for: src/formatting/syntux/parser.rs

+4-32
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_span::{sym, symbol::kw, Span};
1212

1313
use crate::formatting::attr::first_attr_value_str_by_name;
1414
use crate::formatting::syntux::session::ParseSess;
15-
use crate::{Config, Input};
15+
use crate::Input;
1616

1717
pub(crate) type DirectoryOwnership = rustc_expand::module::DirOwnership;
1818
pub(crate) type ModulePathSuccess = rustc_expand::module::ModulePathSuccess;
@@ -32,10 +32,8 @@ pub(crate) struct Parser<'a> {
3232
/// A builder for the `Parser`.
3333
#[derive(Default)]
3434
pub(crate) struct ParserBuilder<'a> {
35-
config: Option<&'a Config>,
3635
sess: Option<&'a ParseSess>,
3736
input: Option<Input>,
38-
directory_ownership: Option<DirectoryOwnership>,
3937
}
4038

4139
impl<'a> ParserBuilder<'a> {
@@ -49,19 +47,6 @@ impl<'a> ParserBuilder<'a> {
4947
self
5048
}
5149

52-
pub(crate) fn config(mut self, config: &'a Config) -> ParserBuilder<'a> {
53-
self.config = Some(config);
54-
self
55-
}
56-
57-
pub(crate) fn directory_ownership(
58-
mut self,
59-
directory_ownership: Option<DirectoryOwnership>,
60-
) -> ParserBuilder<'a> {
61-
self.directory_ownership = directory_ownership;
62-
self
63-
}
64-
6550
pub(crate) fn build(self) -> Result<Parser<'a>, ParserError> {
6651
let sess = self.sess.ok_or(ParserError::NoParseSess)?;
6752
let input = self.input.ok_or(ParserError::NoInput)?;
@@ -158,12 +143,10 @@ impl<'a> Parser<'a> {
158143
}
159144

160145
pub(crate) fn parse_crate(
161-
config: &'a Config,
162146
input: Input,
163-
directory_ownership: Option<DirectoryOwnership>,
164147
sess: &'a ParseSess,
165148
) -> Result<ast::Crate, ParserError> {
166-
let krate = Parser::parse_crate_inner(config, input, directory_ownership, sess)?;
149+
let krate = Parser::parse_crate_inner(input, sess)?;
167150
if !sess.has_errors() {
168151
return Ok(krate);
169152
}
@@ -176,19 +159,8 @@ impl<'a> Parser<'a> {
176159
Err(ParserError::ParseError)
177160
}
178161

179-
fn parse_crate_inner(
180-
config: &'a Config,
181-
input: Input,
182-
directory_ownership: Option<DirectoryOwnership>,
183-
sess: &'a ParseSess,
184-
) -> Result<ast::Crate, ParserError> {
185-
let mut parser = ParserBuilder::default()
186-
.config(config)
187-
.input(input)
188-
.directory_ownership(directory_ownership)
189-
.sess(sess)
190-
.build()?;
191-
162+
fn parse_crate_inner(input: Input, sess: &'a ParseSess) -> Result<ast::Crate, ParserError> {
163+
let mut parser = ParserBuilder::default().input(input).sess(sess).build()?;
192164
parser.parse_crate_mod()
193165
}
194166

Diff for: src/rustfmt/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ mod test {
662662
me.push("rustfmt");
663663
assert!(
664664
me.is_file() || me.with_extension("exe").is_file(),
665+
"{}",
665666
if cfg!(release) {
666667
"no rustfmt bin, try running `cargo build --release` before testing"
667668
} else {

Diff for: src/test/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,8 @@ fn verify_config_used(path: &Path, config_name: &str) {
136136
.map(Result::unwrap)
137137
.take_while(|l| l.starts_with("//"))
138138
.any(|l| l.starts_with(&format!("// rustfmt-{}", config_name))),
139-
format!(
140-
"config option file {} does not contain expected config name",
141-
path.display()
142-
)
139+
"config option file {} does not contain expected config name",
140+
path.display(),
143141
);
144142
}
145143
}

0 commit comments

Comments
 (0)