Skip to content

fix some typos #2104

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

Merged
merged 1 commit into from
Nov 2, 2017
Merged
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
10 changes: 5 additions & 5 deletions Configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ trait Lorem {
dolor: Dolor,
sit: Sit,
amet: Amet,
consectetur: onsectetur,
consectetur: Consectetur,
adipiscing: Adipiscing,
elit: Elit,
);
Expand All @@ -516,7 +516,7 @@ trait Lorem {
dolor: Dolor,
sit: Sit,
amet: Amet,
consectetur: onsectetur,
consectetur: Consectetur,
adipiscing: Adipiscing,
elit: Elit,
) {
Expand Down Expand Up @@ -569,7 +569,7 @@ trait Lorem {
dolor: Dolor,
sit: Sit,
amet: Amet,
consectetur: onsectetur,
consectetur: Consectetur,
adipiscing: Adipiscing,
elit: Elit,
) {
Expand Down Expand Up @@ -598,15 +598,15 @@ trait Lorem {
dolor: Dolor,
sit: Sit,
amet: Amet,
consectetur: onsectetur,
consectetur: Consectetur,
adipiscing: Adipiscing,
elit: Elit);

fn lorem(ipsum: Ipsum,
dolor: Dolor,
sit: Sit,
amet: Amet,
consectetur: onsectetur,
consectetur: Consectetur,
adipiscing: Adipiscing,
elit: Elit) {
// body
Expand Down
2 changes: 1 addition & 1 deletion Design.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ for its configuration.
Our visitor keeps track of the desired current indent due to blocks (
`block_indent`). Each `visit_*` method reformats code according to this indent,
`config.comment_width()` and `config.max_width()`. Most reformatting done in the
`visit_*` methods is a bit hackey and is meant to be temporary until it can be
`visit_*` methods is a bit hacky and is meant to be temporary until it can be
done properly.

There are a bunch of methods called `rewrite_*`. There do the bulk of the
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ are included as out of line modules from `src/lib.rs`.
If `rustfmt` successfully reformatted the code it will exit with `0` exit
status. Exit status `1` signals some unexpected error, like an unknown option or
a failure to read a file. Exit status `2` is returned if there are syntax errors
in the input files. `rustfmt` can't format syntatically invalid code. Finally,
in the input files. `rustfmt` can't format syntactically invalid code. Finally,
exit status `3` is returned if there are some issues which can't be resolved
automatically. For example, if you have a very long comment line `rustfmt`
doesn't split it. Instead it prints a warning and exits with `3`.
Expand Down Expand Up @@ -209,7 +209,7 @@ options covering different styles. File an issue, or even better, submit a PR.
* When you run rustfmt, place a file named `rustfmt.toml` or `.rustfmt.toml` in
target file directory or its parents to override the default settings of
rustfmt. You can generate a file containing the default configuration with
`rustfm --dump-default-config rustfmt.toml` and customize as needed.
`rustfmt --dump-default-config rustfmt.toml` and customize as needed.
* After successful compilation, a `rustfmt` executable can be found in the
target directory.
* If you're having issues compiling Rustfmt (or compile errors when trying to
Expand Down
10 changes: 5 additions & 5 deletions src/chains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -
}).collect::<Option<Vec<_>>>()?;

// Total of all items excluding the last.
let extend_last_subexr = last_line_extendable(&parent_rewrite) && rewrites.is_empty();
let almost_total = if extend_last_subexr {
let extend_last_subexpr = last_line_extendable(&parent_rewrite) && rewrites.is_empty();
let almost_total = if extend_last_subexpr {
last_line_width(&parent_rewrite)
} else {
rewrites.iter().fold(0, |a, b| a + b.len()) + parent_rewrite.len()
Expand Down Expand Up @@ -195,7 +195,7 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -
// In particular, overflowing is effective when the last child is a method with a multi-lined
// block-like argument (e.g. closure):
// ```
// parent.child1.chlid2.last_child(|a, b, c| {
// parent.child1.child2.last_child(|a, b, c| {
// let x = foo(a, b, c);
// let y = bar(a, b, c);
//
Expand All @@ -208,14 +208,14 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -
// `rewrite_last` rewrites the last child on its own line. We use a closure here instead of
// directly calling `rewrite_chain_subexpr()` to avoid exponential blowup.
let rewrite_last = || rewrite_chain_subexpr(last_subexpr, total_span, context, last_shape);
let (last_subexpr_str, fits_single_line) = if all_in_one_line || extend_last_subexr {
let (last_subexpr_str, fits_single_line) = if all_in_one_line || extend_last_subexpr {
// First we try to 'overflow' the last child and see if it looks better than using
// vertical layout.
parent_shape.offset_left(almost_total).map(|shape| {
if let Some(rw) = rewrite_chain_subexpr(last_subexpr, total_span, context, shape) {
// We allow overflowing here only if both of the following conditions match:
// 1. The entire chain fits in a single line expect the last child.
// 2. `last_chlid_str.lines().count() >= 5`.
// 2. `last_child_str.lines().count() >= 5`.
let line_count = rw.lines().count();
let fits_single_line = almost_total + first_line_width(&rw) <= one_line_budget;
if fits_single_line && line_count >= 5 {
Expand Down
2 changes: 1 addition & 1 deletion src/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ pub fn combine_strs_with_missing_comments(
// We have a missing comment between the first expression and the second expression.

// Peek the the original source code and find out whether there is a newline between the first
// expression and the second expression or the missing comment. We will preserve the orginal
// expression and the second expression or the missing comment. We will preserve the original
// layout whenever possible.
let original_snippet = context.snippet(span);
let prefer_same_line = if let Some(pos) = original_snippet.chars().position(|c| c == '/') {
Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ macro_rules! create_config {

// Just like the Config struct but with each property wrapped
// as Option<T>. This is used to parse a rustfmt.toml that doesn't
// specity all properties of `Config`.
// specify all properties of `Config`.
// We first parse into `PartialConfig`, then create a default `Config`
// and overwrite the properties with corresponding values from `PartialConfig`.
#[derive(Deserialize, Serialize, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ pub fn format_expr(
ast::ExprKind::TupField(..) |
ast::ExprKind::MethodCall(..) => rewrite_chain(expr, context, shape),
ast::ExprKind::Mac(ref mac) => {
// Failure to rewrite a marco should not imply failure to
// Failure to rewrite a macro should not imply failure to
// rewrite the expression.
rewrite_macro(mac, None, context, shape, MacroPosition::Expression)
.or_else(|| Some(context.snippet(expr.span)))
Expand Down
2 changes: 1 addition & 1 deletion src/issues.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// Objects for seeking through a char stream for occurences of TODO and FIXME.
// Objects for seeking through a char stream for occurrences of TODO and FIXME.
// Depending on the loaded configuration, may also check that these have an
// associated issue number.

Expand Down
2 changes: 1 addition & 1 deletion src/lists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ where
let comment_end = match self.inner.peek() {
Some(..) => {
let mut block_open_index = post_snippet.find("/*");
// check if it realy is a block comment (and not //*)
// check if it really is a block comment (and not //*)
if let Some(i) = block_open_index {
if i > 0 && &post_snippet[i - 1..i] == "/" {
block_open_index = None;
Expand Down
2 changes: 1 addition & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// foo!( x, y, z ). The token x may represent an identifier in the code, but we
// interpreted as an expression.
// Macro uses which are not-list like, such as bar!(key => val), will not be
// reformated.
// reformatted.
// List-like invocations with parentheses will be formatted as function calls,
// and those with brackets will be formatted as array literals.

Expand Down
16 changes: 8 additions & 8 deletions src/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ impl Rewrite for Pat {
};
Some(result)
}
PatKind::Struct(ref path, ref fields, elipses) => {
rewrite_struct_pat(path, fields, elipses, self.span, context, shape)
PatKind::Struct(ref path, ref fields, ellipsis) => {
rewrite_struct_pat(path, fields, ellipsis, self.span, context, shape)
}
// FIXME(#819) format pattern macros.
PatKind::Mac(..) => Some(context.snippet(self.span)),
Expand All @@ -130,7 +130,7 @@ impl Rewrite for Pat {
fn rewrite_struct_pat(
path: &ast::Path,
fields: &[codemap::Spanned<ast::FieldPat>],
elipses: bool,
ellipsis: bool,
span: Span,
context: &RewriteContext,
shape: Shape,
Expand All @@ -139,15 +139,15 @@ fn rewrite_struct_pat(
let path_shape = shape.sub_width(2)?;
let path_str = rewrite_path(context, PathContext::Expr, None, path, path_shape)?;

if fields.is_empty() && !elipses {
if fields.is_empty() && !ellipsis {
return Some(format!("{} {{}}", path_str));
}

let (elipses_str, terminator) = if elipses { (", ..", "..") } else { ("", "}") };
let (ellipsis_str, terminator) = if ellipsis { (", ..", "..") } else { ("", "}") };

// 3 = ` { `, 2 = ` }`.
let (h_shape, v_shape) =
struct_lit_shape(shape, context, path_str.len() + 3, elipses_str.len() + 2)?;
struct_lit_shape(shape, context, path_str.len() + 3, ellipsis_str.len() + 2)?;

let items = itemize_list(
context.codemap,
Expand All @@ -169,7 +169,7 @@ fn rewrite_struct_pat(
let mut fields_str = write_list(&item_vec, &fmt)?;
let one_line_width = h_shape.map_or(0, |shape| shape.width);

if elipses {
if ellipsis {
if fields_str.contains('\n') || fields_str.len() > one_line_width {
// Add a missing trailing comma.
if fmt.trailing_separator == SeparatorTactic::Never {
Expand All @@ -180,7 +180,7 @@ fn rewrite_struct_pat(
fields_str.push_str("..");
} else {
if !fields_str.is_empty() {
// there are preceeding struct fields being matched on
// there are preceding struct fields being matched on
if fmt.tactic == DefinitiveListTactic::Vertical {
// if the tactic is Vertical, write_list already added a trailing ,
fields_str.push_str(" ");
Expand Down
4 changes: 2 additions & 2 deletions src/vertical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ pub fn rewrite_with_alignment<T: AlignedItem>(
}
}

fn struct_field_preix_max_min_width<T: AlignedItem>(
fn struct_field_prefix_max_min_width<T: AlignedItem>(
context: &RewriteContext,
fields: &[T],
shape: Shape,
Expand Down Expand Up @@ -219,7 +219,7 @@ fn rewrite_aligned_items_inner<T: AlignedItem>(
// 1 = ","
let item_shape = Shape::indented(item_indent, context.config).sub_width(1)?;
let (mut field_prefix_max_width, field_prefix_min_width) =
struct_field_preix_max_min_width(context, fields, item_shape);
struct_field_prefix_max_min_width(context, fields, item_shape);
let max_diff = field_prefix_max_width
.checked_sub(field_prefix_min_width)
.unwrap_or(0);
Expand Down
8 changes: 4 additions & 4 deletions src/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ impl<'a> FmtVisitor<'a> {
// complex in the module case. It is complex because the module could be
// in a separate file and there might be attributes in both files, but
// the AST lumps them all together.
let filterd_attrs;
let filtered_attrs;
let mut attrs = &item.attrs;
match item.node {
ast::ItemKind::Mod(ref m) => {
Expand All @@ -314,7 +314,7 @@ impl<'a> FmtVisitor<'a> {
} else {
// Module is not inline and should not be skipped. We want
// to process only the attributes in the current file.
filterd_attrs = item.attrs
filtered_attrs = item.attrs
.iter()
.filter_map(|a| {
let attr_file = self.codemap.lookup_char_pos(a.span.lo()).file;
Expand All @@ -327,8 +327,8 @@ impl<'a> FmtVisitor<'a> {
.collect::<Vec<_>>();
// Assert because if we should skip it should be caught by
// the above case.
assert!(!self.visit_attrs(&filterd_attrs, ast::AttrStyle::Outer));
attrs = &filterd_attrs;
assert!(!self.visit_attrs(&filtered_attrs, ast::AttrStyle::Outer));
attrs = &filtered_attrs;
}
}
_ => if self.visit_attrs(&item.attrs, ast::AttrStyle::Outer) {
Expand Down
2 changes: 1 addition & 1 deletion tests/source/configs-struct_field_align_threshold-20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ pub struct State<F: FnMut() -> ()> { now: F }

pub struct State<F: FnMut()> { now: F }

struct Palette { /// A map of indizes in the palette to a count of pixels in approximately that color
struct Palette { /// A map of indices in the palette to a count of pixels in approximately that color
foo: i32}

// Splitting a single line comment into a block previously had a misalignment
Expand Down
2 changes: 1 addition & 1 deletion tests/source/fn-simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn op(x: Typ, key : &[u8], upd : Box<Fn(Option<&memcache::Item>) -> (memcache::S
"cool"}


fn weird_comment(/* /*/ double level */ comment */ x: Hello /*/*/* tripple, even */*/*/,
fn weird_comment(/* /*/ double level */ comment */ x: Hello /*/*/* triple, even */*/*/,
// Does this work?
y: World
) {
Expand Down
2 changes: 1 addition & 1 deletion tests/source/fn_args_density-vertical.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// rustfmt-fn_args_density: Vertical

// Empty list shoul stay on one line.
// Empty list should stay on one line.
fn do_bar(

) -> u8 {
Expand Down
2 changes: 1 addition & 1 deletion tests/source/issue-1049.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ impl Handle {
}
}

// Long function without return type that should not be reformated.
// Long function without return type that should not be reformatted.
fn veeeeeeeeeeeeeeeeeeeeery_long_name(a: FirstTypeeeeeeeeee, b: SecondTypeeeeeeeeeeeeeeeeeeeeeee) {}

fn veeeeeeeeeeeeeeeeeeeeeery_long_name(a: FirstTypeeeeeeeeee, b: SecondTypeeeeeeeeeeeeeeeeeeeeeee) {}
Expand Down
2 changes: 1 addition & 1 deletion tests/source/issue-1468.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fn issue1468() {
euc_jp_decoder_functions!({
let trail_minus_offset = byte.wrapping_sub(0xA1);
// Fast-track Hiragana (60% according to Lunde)
// and Katakana (10% acconding to Lunde).
// and Katakana (10% according to Lunde).
if jis0208_lead_minus_offset == 0x03 &&
trail_minus_offset < 0x53 {
// Hiragana
Expand Down
2 changes: 1 addition & 1 deletion tests/source/match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ fn issue355() {
nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn => println!("a", b),
// Rewrite splits macro
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo => vec!(1, 2),
// Macro support fails to recognise this macro as splitable
// Macro support fails to recognise this macro as splittable
// We push the whole expr to a new line, TODO split this macro as well
pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp => vec!(3; 4),
// q, r and s: Rewrite splits match arm
Expand Down
2 changes: 1 addition & 1 deletion tests/source/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pub struct State<F: FnMut() -> ()> { now: F }

pub struct State<F: FnMut()> { now: F }

struct Palette { /// A map of indizes in the palette to a count of pixels in approximately that color
struct Palette { /// A map of indices in the palette to a count of pixels in approximately that color
foo: i32}

// Splitting a single line comment into a block previously had a misalignment
Expand Down
2 changes: 1 addition & 1 deletion tests/source/unions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub union State<F: FnMut() -> ()> { now: F }

pub union State<F: FnMut()> { now: F }

union Palette { /// A map of indizes in the palette to a count of pixels in approximately that color
union Palette { /// A map of indices in the palette to a count of pixels in approximately that color
foo: i32}

// Splitting a single line comment into a block previously had a misalignment
Expand Down
2 changes: 1 addition & 1 deletion tests/target/configs-struct_field_align_threshold-20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ pub struct State<F: FnMut()> {
}

struct Palette {
/// A map of indizes in the palette to a count of pixels in approximately
/// A map of indices in the palette to a count of pixels in approximately
/// that color
foo: i32,
}
Expand Down
2 changes: 1 addition & 1 deletion tests/target/fn-simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn simple(

fn weird_comment(
// /*/ double level */ comment
x: Hello, // /*/* tripple, even */*/
x: Hello, // /*/* triple, even */*/
// Does this work?
y: World,
) {
Expand Down
2 changes: 1 addition & 1 deletion tests/target/fn_args_density-vertical.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// rustfmt-fn_args_density: Vertical

// Empty list shoul stay on one line.
// Empty list should stay on one line.
fn do_bar() -> u8 {
bar()
}
Expand Down
2 changes: 1 addition & 1 deletion tests/target/issue-1049.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl Handle {
}
}

// Long function without return type that should not be reformated.
// Long function without return type that should not be reformatted.
fn veeeeeeeeeeeeeeeeeeeeery_long_name(a: FirstTypeeeeeeeeee, b: SecondTypeeeeeeeeeeeeeeeeeeeeeee) {}

fn veeeeeeeeeeeeeeeeeeeeeery_long_name(a: FirstTypeeeeeeeeee, b: SecondTypeeeeeeeeeeeeeeeeeeeeeee) {
Expand Down
2 changes: 1 addition & 1 deletion tests/target/issue-1468.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fn issue1468() {
euc_jp_decoder_functions!({
let trail_minus_offset = byte.wrapping_sub(0xA1);
// Fast-track Hiragana (60% according to Lunde)
// and Katakana (10% acconding to Lunde).
// and Katakana (10% according to Lunde).
if jis0208_lead_minus_offset == 0x03 && trail_minus_offset < 0x53 {
// Hiragana
handle.write_upper_bmp(0x3041 + trail_minus_offset as u16)
Expand Down
2 changes: 1 addition & 1 deletion tests/target/match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ fn issue355() {
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo => {
vec![1, 2]
}
// Macro support fails to recognise this macro as splitable
// Macro support fails to recognise this macro as splittable
// We push the whole expr to a new line, TODO split this macro as well
pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp => {
vec![3; 4]
Expand Down
2 changes: 1 addition & 1 deletion tests/target/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ pub struct State<F: FnMut()> {
}

struct Palette {
/// A map of indizes in the palette to a count of pixels in approximately
/// A map of indices in the palette to a count of pixels in approximately
/// that color
foo: i32,
}
Expand Down
Loading