mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
fix some typos
This commit is contained in:
parent
0af8825eb1
commit
f930a16b8d
@ -506,7 +506,7 @@ trait Lorem {
|
||||
dolor: Dolor,
|
||||
sit: Sit,
|
||||
amet: Amet,
|
||||
consectetur: onsectetur,
|
||||
consectetur: Consectetur,
|
||||
adipiscing: Adipiscing,
|
||||
elit: Elit,
|
||||
);
|
||||
@ -516,7 +516,7 @@ trait Lorem {
|
||||
dolor: Dolor,
|
||||
sit: Sit,
|
||||
amet: Amet,
|
||||
consectetur: onsectetur,
|
||||
consectetur: Consectetur,
|
||||
adipiscing: Adipiscing,
|
||||
elit: Elit,
|
||||
) {
|
||||
@ -569,7 +569,7 @@ trait Lorem {
|
||||
dolor: Dolor,
|
||||
sit: Sit,
|
||||
amet: Amet,
|
||||
consectetur: onsectetur,
|
||||
consectetur: Consectetur,
|
||||
adipiscing: Adipiscing,
|
||||
elit: Elit,
|
||||
) {
|
||||
@ -598,7 +598,7 @@ trait Lorem {
|
||||
dolor: Dolor,
|
||||
sit: Sit,
|
||||
amet: Amet,
|
||||
consectetur: onsectetur,
|
||||
consectetur: Consectetur,
|
||||
adipiscing: Adipiscing,
|
||||
elit: Elit);
|
||||
|
||||
@ -606,7 +606,7 @@ trait Lorem {
|
||||
dolor: Dolor,
|
||||
sit: Sit,
|
||||
amet: Amet,
|
||||
consectetur: onsectetur,
|
||||
consectetur: Consectetur,
|
||||
adipiscing: Adipiscing,
|
||||
elit: Elit) {
|
||||
// body
|
||||
|
@ -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
|
||||
|
@ -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`.
|
||||
@ -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
|
||||
|
@ -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()
|
||||
@ -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);
|
||||
//
|
||||
@ -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 {
|
||||
|
@ -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 == '/') {
|
||||
|
@ -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)]
|
||||
|
@ -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)))
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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)),
|
||||
@ -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,
|
||||
@ -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,
|
||||
@ -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 {
|
||||
@ -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(" ");
|
||||
|
@ -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,
|
||||
@ -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);
|
||||
|
@ -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) => {
|
||||
@ -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;
|
||||
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
) {
|
||||
|
@ -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 {
|
||||
|
@ -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) {}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
}
|
||||
|
@ -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,
|
||||
) {
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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)
|
||||
|
@ -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]
|
||||
|
@ -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,
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ pub union State<F: FnMut()> {
|
||||
}
|
||||
|
||||
union 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,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user