Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compile_fail tests for 1.84 Rust #435

Merged
merged 4 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion impl/src/fmt/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ impl Expansion<'_> {
.shared_attr
.map_or(true, |attr| attr.contains_arg("_variant"));
// If `shared_attr` is a transparent call to `_variant`, then we consider it being absent.
let has_shared_attr = self.shared_attr.map_or(false, |attr| {
let has_shared_attr = self.shared_attr.is_some_and(|attr| {
attr.transparent_call().map_or(true, |(_, called_trait)| {
&called_trait != self.trait_ident || !shared_attr_contains_variant
})
Expand Down
2 changes: 1 addition & 1 deletion impl/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ impl FmtAttribute {
fields.fmt_args_idents().filter_map(move |field_name| {
(used_args.iter().any(|arg| field_name == arg)
&& !self.args.iter().any(|arg| {
arg.alias.as_ref().map_or(false, |(n, _)| n == &field_name)
arg.alias.as_ref().is_some_and(|(n, _)| n == &field_name)
}))
.then(|| quote! { #field_name = *#field_name })
})
Expand Down
19 changes: 5 additions & 14 deletions impl/src/fmt/parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ fn identifier(input: &str) -> Option<(LeftToParse<'_>, Identifier<'_>)> {
),
&mut and_then(char('_'), take_while1(check_char(XID::is_xid_continue))),
]),
|(i, _)| (i, &input[..(input.as_bytes().len() - i.as_bytes().len())]),
|(i, _)| (i, &input[..(input.len() - i.len())]),
)(input)
}

Expand Down Expand Up @@ -614,10 +614,7 @@ fn take_while0(
while let Some(step) = parser(cur) {
cur = step;
}
(
cur,
&input[..(input.as_bytes().len() - cur.as_bytes().len())],
)
(cur, &input[..(input.len() - cur.len())])
}
}

Expand All @@ -631,10 +628,7 @@ fn take_while1(
while let Some(step) = parser(cur) {
cur = step;
}
Some((
cur,
&input[..(input.as_bytes().len() - cur.as_bytes().len())],
))
Some((cur, &input[..(input.len() - cur.len())]))
}
}

Expand Down Expand Up @@ -662,16 +656,13 @@ fn take_until1(
cur = b;
}

Some((
cur,
&input[..(input.as_bytes().len() - cur.as_bytes().len())],
))
Some((cur, &input[..(input.len() - cur.len())]))
}
}

/// Checks whether `input` starts with `s`.
fn str(s: &str) -> impl FnMut(&str) -> Option<LeftToParse<'_>> + '_ {
move |input| input.starts_with(s).then(|| &input[s.as_bytes().len()..])
move |input| input.starts_with(s).then(|| &input[s.len()..])
}

/// Checks whether `input` starts with `c`.
Expand Down
2 changes: 1 addition & 1 deletion impl/src/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ where
.filter(|(top_level, owned, ref_, ref_mut)| {
[top_level, owned, ref_, ref_mut]
.into_iter()
.any(|l| l.as_ref().map_or(false, |l| !l.is_empty()))
.any(|l| l.as_ref().is_some_and(|l| !l.is_empty()))
})
else {
return Ok(());
Expand Down
2 changes: 1 addition & 1 deletion impl/src/parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl Parse for Expr {

impl PartialEq<syn::Ident> for Expr {
fn eq(&self, other: &syn::Ident) -> bool {
self.ident().map_or(false, |i| i == other)
self.ident().is_some_and(|i| i == other)
}
}

Expand Down
4 changes: 2 additions & 2 deletions impl/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2329,7 +2329,7 @@ mod generics_search {

impl<'ast> Visit<'ast> for Visitor<'_> {
fn visit_type_path(&mut self, tp: &'ast syn::TypePath) {
self.found |= tp.path.get_ident().map_or(false, |ident| {
self.found |= tp.path.get_ident().is_some_and(|ident| {
self.search.types.contains(ident) || self.search.consts.contains(ident)
});

Expand All @@ -2346,7 +2346,7 @@ mod generics_search {
self.found |= ep
.path
.get_ident()
.map_or(false, |ident| self.search.consts.contains(ident));
.is_some_and(|ident| self.search.consts.contains(ident));

syn::visit::visit_expr_path(self, ep)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/compile_fail/debug/lifetime_no_debug.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0277]: `NoDebug<'_>` doesn't implement `Debug`
5 | #[derive(derive_more::Debug)]
| ^^^^^^^^^^^^^^^^^^ `NoDebug<'_>` cannot be formatted using `{:?}`
|
= help: the trait `Debug` is not implemented for `NoDebug<'_>`, which is required by `&NoDebug<'_>: Debug`
= help: the trait `Debug` is not implemented for `NoDebug<'_>`
= note: add `#[derive(Debug)]` to `NoDebug<'_>` or manually `impl Debug for NoDebug<'_>`
= note: required for `&NoDebug<'_>` to implement `Debug`
= note: required for the cast from `&&NoDebug<'_>` to `&dyn Debug`
Expand Down
4 changes: 2 additions & 2 deletions tests/compile_fail/debug/unclosed_brace.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: invalid format string: expected `'}'`, found `')'`
error: invalid format string: expected `}`, found `)`
--> tests/compile_fail/debug/unclosed_brace.rs:3:21
|
3 | #[debug("Stuff({)", bar)]
| -^ expected `'}'` in format string
| -^ expected `}` in format string
| |
| because of this opening brace
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: invalid format string: expected `'}'`, found `')'`
error: invalid format string: expected `}`, found `)`
--> tests/compile_fail/display/shared_format_unclosed_brace.rs:2:19
|
2 | #[display("Stuff({)")]
| -^ expected `'}'` in format string
| -^ expected `}` in format string
| |
| because of this opening brace
|
Expand Down
4 changes: 2 additions & 2 deletions tests/compile_fail/display/unclosed_brace.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: invalid format string: expected `'}'`, found `')'`
error: invalid format string: expected `}`, found `)`
--> tests/compile_fail/display/unclosed_brace.rs:2:19
|
2 | #[display("Stuff({)", bar)]
| -^ expected `'}'` in format string
| -^ expected `}` in format string
| |
| because of this opening brace
|
Expand Down
Loading