Don't format tests/run-make/*/rmake.rs
.
It's reasonable to want to, but in the current implementation this causes multiple problems. - All the `rmake.rs` files are formatted every time even when they haven't changed. This is because they get whitelisted unconditionally in the `OverrideBuilder`, before the changed files get added. - The way `OverrideBuilder` works, if any files gets whitelisted then no unmentioned files will get traversed. This is surprising, and means that the `rmake.rs` entries broke the use of explicit paths to `x fmt`, and also broke `GITHUB_ACTIONS=true git check --fmt`. The commit removes the `rmake.rs` entries, fixes the formatting of a couple of files that were misformatted (not previously caught due to the `GITHUB_ACTIONS` breakage), and bans `!`-prefixed entries in `rustfmt.toml` because they cause all these problems.
This commit is contained in:
parent
4702a1c345
commit
f1b0ca08a4
@ -219,10 +219,8 @@ fn simplify_cast(&self, rvalue: &mut Rvalue<'tcx>) {
|
|||||||
for (i, field) in variant.fields.iter_enumerated() {
|
for (i, field) in variant.fields.iter_enumerated() {
|
||||||
let field_ty = field.ty(self.tcx, args);
|
let field_ty = field.ty(self.tcx, args);
|
||||||
if field_ty == *cast_ty {
|
if field_ty == *cast_ty {
|
||||||
let place = place.project_deeper(
|
let place = place
|
||||||
&[ProjectionElem::Field(i, *cast_ty)],
|
.project_deeper(&[ProjectionElem::Field(i, *cast_ty)], self.tcx);
|
||||||
self.tcx,
|
|
||||||
);
|
|
||||||
let operand = if operand.is_move() {
|
let operand = if operand.is_move() {
|
||||||
Operand::Move(place)
|
Operand::Move(place)
|
||||||
} else {
|
} else {
|
||||||
|
@ -691,7 +691,7 @@ fn visit_projection_elem(
|
|||||||
location,
|
location,
|
||||||
format!(
|
format!(
|
||||||
"You can't project to field {f:?} of `DynMetadata` because \
|
"You can't project to field {f:?} of `DynMetadata` because \
|
||||||
layout is weird and thinks it doesn't have fields."
|
layout is weird and thinks it doesn't have fields."
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -209,18 +209,14 @@ pub fn size_of(self) -> usize {
|
|||||||
// Consider a reference like `&(i32, dyn Send)`: the vtable will only store the size of the
|
// Consider a reference like `&(i32, dyn Send)`: the vtable will only store the size of the
|
||||||
// `Send` part!
|
// `Send` part!
|
||||||
// SAFETY: DynMetadata always contains a valid vtable pointer
|
// SAFETY: DynMetadata always contains a valid vtable pointer
|
||||||
return unsafe {
|
return unsafe { crate::intrinsics::vtable_size(self.vtable_ptr() as *const ()) };
|
||||||
crate::intrinsics::vtable_size(self.vtable_ptr() as *const ())
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the alignment of the type associated with this vtable.
|
/// Returns the alignment of the type associated with this vtable.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn align_of(self) -> usize {
|
pub fn align_of(self) -> usize {
|
||||||
// SAFETY: DynMetadata always contains a valid vtable pointer
|
// SAFETY: DynMetadata always contains a valid vtable pointer
|
||||||
return unsafe {
|
return unsafe { crate::intrinsics::vtable_align(self.vtable_ptr() as *const ()) };
|
||||||
crate::intrinsics::vtable_align(self.vtable_ptr() as *const ())
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the size and alignment together as a `Layout`
|
/// Returns the size and alignment together as a `Layout`
|
||||||
|
10
rustfmt.toml
10
rustfmt.toml
@ -3,7 +3,7 @@ version = "Two"
|
|||||||
use_small_heuristics = "Max"
|
use_small_heuristics = "Max"
|
||||||
merge_derives = false
|
merge_derives = false
|
||||||
|
|
||||||
# Files to ignore. Each entry uses gitignore syntax.
|
# Files to ignore. Each entry uses gitignore syntax, but `!` prefixes aren't allowed.
|
||||||
ignore = [
|
ignore = [
|
||||||
"/build/",
|
"/build/",
|
||||||
"/*-build/",
|
"/*-build/",
|
||||||
@ -12,13 +12,7 @@ ignore = [
|
|||||||
|
|
||||||
# Tests for now are not formatted, as they are sometimes pretty-printing constrained
|
# Tests for now are not formatted, as they are sometimes pretty-printing constrained
|
||||||
# (and generally rustfmt can move around comments in UI-testing incompatible ways).
|
# (and generally rustfmt can move around comments in UI-testing incompatible ways).
|
||||||
"/tests/*",
|
"/tests/",
|
||||||
|
|
||||||
# But we still want to format rmake.rs files in tests/run-make/ so we need to do this
|
|
||||||
# dance to avoid the parent directory from being excluded.
|
|
||||||
"!/tests/run-make/",
|
|
||||||
"/tests/run-make/*/*.rs",
|
|
||||||
"!/tests/run-make/*/rmake.rs",
|
|
||||||
|
|
||||||
# Do not format submodules.
|
# Do not format submodules.
|
||||||
# FIXME: sync submodule list with tidy/bootstrap/etc
|
# FIXME: sync submodule list with tidy/bootstrap/etc
|
||||||
|
@ -115,8 +115,15 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
|
|||||||
let rustfmt_config: RustfmtConfig = t!(toml::from_str(&rustfmt_config));
|
let rustfmt_config: RustfmtConfig = t!(toml::from_str(&rustfmt_config));
|
||||||
let mut fmt_override = ignore::overrides::OverrideBuilder::new(&build.src);
|
let mut fmt_override = ignore::overrides::OverrideBuilder::new(&build.src);
|
||||||
for ignore in rustfmt_config.ignore {
|
for ignore in rustfmt_config.ignore {
|
||||||
if let Some(ignore) = ignore.strip_prefix('!') {
|
if ignore.starts_with('!') {
|
||||||
fmt_override.add(ignore).expect(ignore);
|
// A `!`-prefixed entry could be added as a whitelisted entry in `fmt_override`, i.e.
|
||||||
|
// strip the `!` prefix. But as soon as whitelisted entries are added, an
|
||||||
|
// `OverrideBuilder` will only traverse those whitelisted entries, and won't traverse
|
||||||
|
// any files that aren't explicitly mentioned. No bueno! Maybe there's a way to combine
|
||||||
|
// explicit whitelisted entries and traversal of unmentioned files, but for now just
|
||||||
|
// forbid such entries.
|
||||||
|
eprintln!("`!`-prefixed entries are not supported in rustfmt.toml, sorry");
|
||||||
|
crate::exit!(1);
|
||||||
} else {
|
} else {
|
||||||
fmt_override.add(&format!("!{ignore}")).expect(&ignore);
|
fmt_override.add(&format!("!{ignore}")).expect(&ignore);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user