Skip to content

Commit f4e017d

Browse files
lnicolatopecongiro
authored andcommitted
chore: drop derive-new dependency (#3917)
1 parent 20bb447 commit f4e017d

File tree

7 files changed

+42
-22
lines changed

7 files changed

+42
-22
lines changed

Cargo.lock

Lines changed: 0 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ diff = "0.1"
4545
log = "0.4"
4646
env_logger = "0.6"
4747
getopts = "0.2"
48-
derive-new = "0.5"
4948
cargo_metadata = "0.8"
5049
failure = "0.1.3"
5150
bytecount = "0.6"

src/attr/doc_comment.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@ use crate::comment::CommentStyle;
22
use std::fmt::{self, Display};
33

44
/// Formats a string as a doc comment using the given [`CommentStyle`].
5-
#[derive(new)]
65
pub(super) struct DocCommentFormatter<'a> {
76
literal: &'a str,
87
style: CommentStyle<'a>,
98
}
109

10+
impl<'a> DocCommentFormatter<'a> {
11+
/// Constructs a new `DocCommentFormatter`.
12+
pub(super) fn new(literal: &'a str, style: CommentStyle<'a>) -> Self {
13+
Self { literal, style }
14+
}
15+
}
16+
1117
impl Display for DocCommentFormatter<'_> {
1218
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
1319
let opener = self.style.opener().trim_end();

src/formatting.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ fn format_project<T: FormatHandler>(
118118
Ok(context.report)
119119
}
120120

121-
// Used for formatting files.
122-
#[derive(new)]
121+
/// Used for formatting files.
123122
struct FormatContext<'a, T: FormatHandler> {
124123
krate: &'a ast::Crate,
125124
report: FormatReport,
@@ -129,6 +128,23 @@ struct FormatContext<'a, T: FormatHandler> {
129128
}
130129

131130
impl<'a, T: FormatHandler + 'a> FormatContext<'a, T> {
131+
/// Constructs a new FormatContext.
132+
fn new(
133+
krate: &'a ast::Crate,
134+
report: FormatReport,
135+
parse_session: ParseSess,
136+
config: &'a Config,
137+
handler: &'a mut T,
138+
) -> Self {
139+
Self {
140+
krate,
141+
report,
142+
parse_session,
143+
config,
144+
handler,
145+
}
146+
}
147+
132148
fn ignore_file(&self, path: &FileName) -> bool {
133149
self.parse_session.ignore_file(path)
134150
}

src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#![deny(rust_2018_idioms)]
22
#![warn(unreachable_pub)]
33

4-
#[macro_use]
5-
extern crate derive_new;
64
#[macro_use]
75
extern crate lazy_static;
86
#[macro_use]

src/macros.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,14 +1220,18 @@ fn macro_style(mac: &ast::Mac, context: &RewriteContext<'_>) -> DelimToken {
12201220
}
12211221
}
12221222

1223-
// A very simple parser that just parses a macros 2.0 definition into its branches.
1224-
// Currently we do not attempt to parse any further than that.
1225-
#[derive(new)]
1223+
/// A very simple parser that just parses a macros 2.0 definition into its branches.
1224+
/// Currently we do not attempt to parse any further than that.
12261225
struct MacroParser {
12271226
toks: Cursor,
12281227
}
12291228

12301229
impl MacroParser {
1230+
/// Constructs a new `MacroParser`.
1231+
fn new(toks: Cursor) -> Self {
1232+
Self { toks }
1233+
}
1234+
12311235
// (`(` ... `)` `=>` `{` ... `}`)*
12321236
fn parse(&mut self) -> Option<Macro> {
12331237
let mut branches = vec![];

src/pairs.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,23 @@ use crate::utils::{
99
};
1010

1111
/// Sigils that decorate a binop pair.
12-
#[derive(new, Clone, Copy)]
12+
#[derive(Clone, Copy)]
1313
pub(crate) struct PairParts<'a> {
1414
prefix: &'a str,
1515
infix: &'a str,
1616
suffix: &'a str,
1717
}
1818

1919
impl<'a> PairParts<'a> {
20+
/// Constructs a new `PairParts`.
21+
pub(crate) fn new(prefix: &'a str, infix: &'a str, suffix: &'a str) -> Self {
22+
Self {
23+
prefix,
24+
infix,
25+
suffix,
26+
}
27+
}
28+
2029
pub(crate) fn infix(infix: &'a str) -> PairParts<'a> {
2130
PairParts {
2231
prefix: "",

0 commit comments

Comments
 (0)