Skip to content

Commit

Permalink
Update to rustfmt 1.6.0-nightly (839e9a6 2023-07-02)
Browse files Browse the repository at this point in the history
Summary:
Update to rustfmt 1.6.0-nightly (839e9a6 2023-07-02)

The big ticket item here is that let-else is now supported! In fact, the
suppport just landed two days ago (see [rust-lang/rustfmt#4914])

The unfortunate thing here though is that rustfmt is not statically
linked anymore (see discussion in [rust-lang/rust#107297]). So we need
all of librustc_driver and libstd - which makes our use case pretty big
(~4-5MB to 50MB-100MB). We should explore building from source and
statically linking, or using rustfmt from the toolchain. Both things
that I don't want to deal with right now.

[rust-lang/rustfmt#4914]: rust-lang/rustfmt#4914
[rust-lang/rust#107297]: rust-lang/rust#107297

Note to future updaters: To find out more-or-less what libs you need,
you can use `objdump -p bin/rustfmt | grep NEEDED` on Linux for ELF
bins, and `otool -L bin/rustfmt` on macOS for Mach-O bins. No idea what
you do for Windows.

Ran `tools/arcanist/lint/codemods/rustfmt-fbsource` to format the repo.

Reviewed By: shayne-fletcher

Differential Revision: D47203254

fbshipit-source-id: 6ffd3ce66c7f2b006d09505b93fed515ebc76902
  • Loading branch information
zertosh authored and facebook-github-bot committed Jul 5, 2023
1 parent bd8f86a commit 00c4309
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 28 deletions.
6 changes: 3 additions & 3 deletions app/buck2_client_ctx/src/events_ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ impl From<tonic::Status> for BuckdCommunicationError {
#[async_trait]
pub trait PartialResultHandler {
type PartialResult: TryFrom<
buck2_cli_proto::partial_result::PartialResult,
Error = buck2_cli_proto::partial_result::PartialResult,
>;
buck2_cli_proto::partial_result::PartialResult,
Error = buck2_cli_proto::partial_result::PartialResult,
>;

async fn handle_partial_result(
&mut self,
Expand Down
10 changes: 6 additions & 4 deletions app/buck2_core/src/cells/nested.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,19 @@ impl NestedCells {
all_cells: &[(CellName, &CellRootPath)],
this_cell: &CellRootPath,
) -> NestedCells {
Self::from_cell_paths_relative_to_this_cell(all_cells.iter()
.filter_map(|(cell_name, cell_root_path)| {
let Some(path_relative_to_this_cell) = cell_root_path.strip_prefix_opt(this_cell) else {
Self::from_cell_paths_relative_to_this_cell(all_cells.iter().filter_map(
|(cell_name, cell_root_path)| {
let Some(path_relative_to_this_cell) = cell_root_path.strip_prefix_opt(this_cell)
else {
return None;
};

Some((
CellRelativePath::new(path_relative_to_this_cell),
*cell_name,
))
}))
},
))
}

pub fn matches<'a, 'b>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,9 @@ pub(crate) fn parse_visibility_with_view(
for item in list {
let Some(item) = item.unpack_str() else {
if StarlarkSelector::from_value(*item).is_some() {
return Err(VisibilityAttrTypeCoerceError::NotConfigurable(
attr.to_repr(),
)
.into());
return Err(VisibilityAttrTypeCoerceError::NotConfigurable(attr.to_repr()).into());
}
return Err(VisibilityAttrTypeCoerceError::WrongType(
attr.to_repr(),
).into());
return Err(VisibilityAttrTypeCoerceError::WrongType(attr.to_repr()).into());
};

if item == VisibilityPattern::PUBLIC {
Expand Down
12 changes: 8 additions & 4 deletions starlark-rust/starlark/src/eval/compiler/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,14 @@ impl<'v> Compiler<'v, '_, '_> {
let Some(type_value) = expr.payload else {
// This is unreachable. But unfortunately we do not return error here.
// Still make an error in panic to produce nice panic message.
panic!("{:?}", EvalException::new(
TypesError::TypePayloadNotSet.into(),
expr.span,
&self.codemap));
panic!(
"{:?}",
EvalException::new(
TypesError::TypePayloadNotSet.into(),
expr.span,
&self.codemap
)
);
};
if type_value.type_is_wildcard() {
return None;
Expand Down
2 changes: 1 addition & 1 deletion starlark-rust/starlark/src/values/types/int_or_big.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ impl<'v> StarlarkIntRef<'v> {
Ok(StarlarkInt::Small(InlineInt::MINUS_ONE))
} else {
Ok(StarlarkInt::Small(InlineInt::ZERO))
}
};
};

match self {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ impl<'a> Iterator for PercentFormatParser<'a> {
_ => {
// Note we need to find the second character, not the second byte.
let Some(c) = rem.chars().nth(1) else {
return Some(Err(StringInterpolationError::ExpectingFormatCharacter.into()));
return Some(Err(
StringInterpolationError::ExpectingFormatCharacter.into(),
));
};
return Some(Err(
StringInterpolationError::UnsupportedFormatCharacter(c).into(),
Expand Down
10 changes: 2 additions & 8 deletions starlark-rust/starlark_derive/src/starlark_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,10 @@ fn is_impl_starlark_value(
) -> syn::Result<ImplStarlarkValue> {
let err = "expected `impl StarlarkValue for ...`";
let Some((_, path, _)) = &input.trait_ else {
return Err(syn::Error::new_spanned(
input,
err,
));
return Err(syn::Error::new_spanned(input, err));
};
let Some(last) = path.segments.last() else {
return Err(syn::Error::new_spanned(
path,
err,
));
return Err(syn::Error::new_spanned(path, err));
};
if last.ident != "StarlarkValue" {
return Err(syn::Error::new_spanned(&last.ident, err));
Expand Down

0 comments on commit 00c4309

Please sign in to comment.