mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-09 21:42:44 +00:00
Fix up lines exceeding max width
This commit is contained in:
parent
5f05987211
commit
51c07f4335
@ -50,7 +50,8 @@ create_config! {
|
||||
comment_width: usize, 80, false,
|
||||
"Maximum length of comments. No effect unless wrap_comments = true";
|
||||
normalize_comments: bool, false, true, "Convert /* */ comments to // comments where possible";
|
||||
license_template_path: String, String::default(), false, "Beginning of file must match license template";
|
||||
license_template_path: String, String::default(), false,
|
||||
"Beginning of file must match license template";
|
||||
format_strings: bool, false, false, "Format string literals where necessary";
|
||||
|
||||
// Single line expressions and items
|
||||
@ -239,16 +240,21 @@ mod test {
|
||||
create_config! {
|
||||
// Options that are used by the generated functions
|
||||
max_width: usize, 100, true, "Maximum width of each line";
|
||||
use_small_heuristics: bool, true, false, "Whether to use different formatting for items and \
|
||||
expressions if they satisfy a heuristic notion of 'small'.";
|
||||
license_template_path: String, String::default(), false, "Beginning of file must match license template";
|
||||
required_version: String, env!("CARGO_PKG_VERSION").to_owned(), false, "Require a specific version of rustfmt.";
|
||||
ignore: IgnoreList, IgnoreList::default(), false, "Skip formatting the specified files and directories.";
|
||||
use_small_heuristics: bool, true, false,
|
||||
"Whether to use different formatting for items and \
|
||||
expressions if they satisfy a heuristic notion of 'small'.";
|
||||
license_template_path: String, String::default(), false,
|
||||
"Beginning of file must match license template";
|
||||
required_version: String, env!("CARGO_PKG_VERSION").to_owned(), false,
|
||||
"Require a specific version of rustfmt.";
|
||||
ignore: IgnoreList, IgnoreList::default(), false,
|
||||
"Skip formatting the specified files and directories.";
|
||||
verbose: bool, false, false, "Use verbose output";
|
||||
file_lines: FileLines, FileLines::all(), false,
|
||||
"Lines to format; this is not supported in rustfmt.toml, and can only be specified \
|
||||
via the --file-lines option";
|
||||
width_heuristics: WidthHeuristics, WidthHeuristics::scaled(100), false, "'small' heuristic values";
|
||||
width_heuristics: WidthHeuristics, WidthHeuristics::scaled(100), false,
|
||||
"'small' heuristic values";
|
||||
|
||||
// Options that are used by the tests
|
||||
stable_option: bool, false, true, "A stable option";
|
||||
|
@ -191,7 +191,8 @@ configuration_option_enum! { WriteMode:
|
||||
// Output the changed lines (for internal value only)
|
||||
Modified,
|
||||
// Checks if a diff can be generated. If so, rustfmt outputs a diff and quits with exit code 1.
|
||||
// This option is designed to be run in CI where a non-zero exit signifies non-standard code formatting.
|
||||
// This option is designed to be run in CI where a non-zero exit signifies non-standard code
|
||||
// formatting.
|
||||
Check,
|
||||
// Rustfmt shouldn't output anything formatting-like (e.g., emit a help message).
|
||||
None,
|
||||
|
@ -116,7 +116,8 @@ pub(crate) type FileRecord = (FileName, String);
|
||||
pub enum ErrorKind {
|
||||
// Line has exceeded character limit (found, maximum)
|
||||
#[fail(
|
||||
display = "line formatted, but exceeded maximum width (maximum: {} (see `max_width` option), found: {})",
|
||||
display = "line formatted, but exceeded maximum width \
|
||||
(maximum: {} (see `max_width` option), found: {})",
|
||||
_0,
|
||||
_1
|
||||
)]
|
||||
|
@ -1296,7 +1296,9 @@ impl MacroBranch {
|
||||
fn format_lazy_static(context: &RewriteContext, shape: Shape, ts: &TokenStream) -> Option<String> {
|
||||
let mut result = String::with_capacity(1024);
|
||||
let mut parser = new_parser_from_tts(context.parse_session, ts.trees().collect());
|
||||
let nested_shape = shape.block_indent(context.config.tab_spaces());
|
||||
let nested_shape = shape
|
||||
.block_indent(context.config.tab_spaces())
|
||||
.with_max_width(context.config);
|
||||
|
||||
result.push_str("lazy_static! {");
|
||||
result.push_str(&nested_shape.indent.to_string_with_newline(context.config));
|
||||
|
@ -618,8 +618,9 @@ impl ConfigurationSection {
|
||||
lazy_static! {
|
||||
static ref CONFIG_NAME_REGEX: regex::Regex =
|
||||
regex::Regex::new(r"^## `([^`]+)`").expect("Failed creating configuration pattern");
|
||||
static ref CONFIG_VALUE_REGEX: regex::Regex = regex::Regex::new(r#"^#### `"?([^`"]+)"?`"#)
|
||||
.expect("Failed creating configuration value pattern");
|
||||
static ref CONFIG_VALUE_REGEX: regex::Regex =
|
||||
regex::Regex::new(r#"^#### `"?([^`"]+)"?`"#)
|
||||
.expect("Failed creating configuration value pattern");
|
||||
}
|
||||
|
||||
loop {
|
||||
|
Loading…
Reference in New Issue
Block a user