mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 00:34:06 +00:00
Merge pull request #2920 from topecongiro/issue-2919
Use correct max width when formatting macro body
This commit is contained in:
commit
a275a059e7
@ -1277,20 +1277,22 @@ impl MacroBranch {
|
||||
let body_indent = if has_block_body {
|
||||
shape.indent
|
||||
} else {
|
||||
// We'll hack the indent below, take this into account when formatting,
|
||||
let body_indent = shape.indent.block_indent(&config);
|
||||
let new_width = config.max_width() - body_indent.width();
|
||||
config.set().max_width(new_width);
|
||||
body_indent
|
||||
shape.indent.block_indent(&config)
|
||||
};
|
||||
let new_width = config.max_width() - body_indent.width();
|
||||
config.set().max_width(new_width);
|
||||
|
||||
// First try to format as items, then as statements.
|
||||
let new_body = match ::format_snippet(&body_str, &config) {
|
||||
Some(new_body) => new_body,
|
||||
None => match ::format_code_block(&body_str, &config) {
|
||||
Some(new_body) => new_body,
|
||||
None => return None,
|
||||
},
|
||||
None => {
|
||||
let new_width = new_width + config.tab_spaces();
|
||||
config.set().max_width(new_width);
|
||||
match ::format_code_block(&body_str, &config) {
|
||||
Some(new_body) => new_body,
|
||||
None => return None,
|
||||
}
|
||||
}
|
||||
};
|
||||
let new_body = wrap_str(new_body, config.max_width(), shape)?;
|
||||
|
||||
|
@ -263,3 +263,19 @@ macro_rules! impl_as_byte_slice_arrays {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// #2919
|
||||
fn foo() {
|
||||
{
|
||||
macro_rules! touch_value {
|
||||
($func:ident, $value:expr) => {{
|
||||
let result = API::get_cached().$func(self, key.as_ptr(), $value, ffi::VSPropAppendMode::paTouch);
|
||||
let result = API::get_cached().$func(self, key.as_ptr(), $value, ffi::VSPropAppend);
|
||||
let result = API::get_cached().$func(self, key.as_ptr(), $value, ffi::VSPropAppendM);
|
||||
let result = APIIIIIIIII::get_cached().$func(self, key.as_ptr(), $value, ffi::VSPropAppendM);
|
||||
let result = API::get_cached().$func(self, key.as_ptr(), $value, ffi::VSPropAppendMMMMMMMMMM);
|
||||
debug_assert!(result == 0);
|
||||
}};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -305,3 +305,31 @@ macro_rules! impl_as_byte_slice_arrays {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// #2919
|
||||
fn foo() {
|
||||
{
|
||||
macro_rules! touch_value {
|
||||
($func:ident, $value:expr) => {{
|
||||
let result = API::get_cached().$func(
|
||||
self,
|
||||
key.as_ptr(),
|
||||
$value,
|
||||
ffi::VSPropAppendMode::paTouch,
|
||||
);
|
||||
let result = API::get_cached().$func(self, key.as_ptr(), $value, ffi::VSPropAppend);
|
||||
let result =
|
||||
API::get_cached().$func(self, key.as_ptr(), $value, ffi::VSPropAppendM);
|
||||
let result =
|
||||
APIIIIIIIII::get_cached().$func(self, key.as_ptr(), $value, ffi::VSPropAppendM);
|
||||
let result = API::get_cached().$func(
|
||||
self,
|
||||
key.as_ptr(),
|
||||
$value,
|
||||
ffi::VSPropAppendMMMMMMMMMM,
|
||||
);
|
||||
debug_assert!(result == 0);
|
||||
}};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user