Skip to content

Commit 6170948

Browse files
jyn514calebcartwright
authored andcommitted
Fix warnings
- Fix nightly warning about `format!` - Remove unused functions and fields
1 parent 6b64e30 commit 6170948

File tree

5 files changed

+12
-39
lines changed

5 files changed

+12
-39
lines changed

src/comment.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1674,7 +1674,8 @@ fn remove_comment_header(comment: &str) -> &str {
16741674
} else {
16751675
assert!(
16761676
comment.starts_with("/*"),
1677-
format!("string '{}' is not a comment", comment)
1677+
"string '{}' is not a comment",
1678+
comment
16781679
);
16791680
&comment[2..comment.len() - 2]
16801681
}

src/formatting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ fn format_project<T: FormatHandler>(
7676
// Parse the crate.
7777
let mut report = FormatReport::new();
7878
let directory_ownership = input.to_directory_ownership();
79-
let krate = match Parser::parse_crate(config, input, directory_ownership, &parse_session) {
79+
let krate = match Parser::parse_crate(input, &parse_session) {
8080
Ok(krate) => krate,
8181
// Surface parse error via Session (errors are merged there from report)
8282
Err(e) => {

src/git-rustfmt/main.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ fn make_opts() -> Options {
127127
struct Config {
128128
commits: String,
129129
uncommitted: bool,
130-
check: bool,
131130
}
132131

133132
impl Config {
@@ -146,11 +145,9 @@ impl Config {
146145
let mut config = Config {
147146
commits: "1".to_owned(),
148147
uncommitted: false,
149-
check: false,
150148
};
151149

152150
if matches.opt_present("c") {
153-
config.check = true;
154151
unimplemented!();
155152
}
156153

src/syntux/parser.rs

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_span::{sym, symbol::kw, Span};
1212

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

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

4038
impl<'a> ParserBuilder<'a> {
@@ -48,19 +46,6 @@ impl<'a> ParserBuilder<'a> {
4846
self
4947
}
5048

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

159144
pub(crate) fn parse_crate(
160-
config: &'a Config,
161145
input: Input,
162-
directory_ownership: Option<DirectoryOwnership>,
163146
sess: &'a ParseSess,
164147
) -> Result<ast::Crate, ParserError> {
165-
let krate = Parser::parse_crate_inner(config, input, directory_ownership, sess)?;
148+
let krate = Parser::parse_crate_inner(input, sess)?;
166149
if !sess.has_errors() {
167150
return Ok(krate);
168151
}
@@ -175,19 +158,12 @@ impl<'a> Parser<'a> {
175158
Err(ParserError::ParseError)
176159
}
177160

178-
fn parse_crate_inner(
179-
config: &'a Config,
180-
input: Input,
181-
directory_ownership: Option<DirectoryOwnership>,
182-
sess: &'a ParseSess,
183-
) -> Result<ast::Crate, ParserError> {
184-
let mut parser = ParserBuilder::default()
185-
.config(config)
161+
fn parse_crate_inner(input: Input, sess: &'a ParseSess) -> Result<ast::Crate, ParserError> {
162+
ParserBuilder::default()
186163
.input(input)
187-
.directory_ownership(directory_ownership)
188164
.sess(sess)
189-
.build()?;
190-
parser.parse_crate_mod()
165+
.build()?
166+
.parse_crate_mod()
191167
}
192168

193169
fn parse_crate_mod(&mut self) -> Result<ast::Crate, ParserError> {

src/test/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,8 @@ fn verify_config_used(path: &Path, config_name: &str) {
133133
.map(Result::unwrap)
134134
.take_while(|l| l.starts_with("//"))
135135
.any(|l| l.starts_with(&format!("// rustfmt-{}", config_name))),
136-
format!(
137-
"config option file {} does not contain expected config name",
138-
path.display()
139-
)
136+
"config option file {} does not contain expected config name",
137+
path.display()
140138
);
141139
}
142140
}
@@ -884,6 +882,7 @@ fn rustfmt() -> PathBuf {
884882
me.push("rustfmt");
885883
assert!(
886884
me.is_file() || me.with_extension("exe").is_file(),
885+
"{}",
887886
if cfg!(release) {
888887
"no rustfmt bin, try running `cargo build --release` before testing"
889888
} else {

0 commit comments

Comments
 (0)