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

Bump MSRV to 1.46 #659

Merged
merged 3 commits into from
Jan 30, 2022
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 .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
strategy:
matrix:
include:
- rust: 1.41.0
- rust: 1.46.0
- rust: stable
- rust: beta
- rust: nightly
Expand Down
2 changes: 1 addition & 1 deletion .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pull_request_rules:
- "#approved-reviews-by>=1"
- status-success=continuous-integration/appveyor/pr
- status-success=big-endian-test
- status-success=build (1.41.0)
- status-success=build (1.46.0)
- status-success=build (stable)
- status-success=clippy-rustfmt (stable)
- status-success=code_gen
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/950g0t6i8hfc9dup/branch/master?svg=true)](https://ci.appveyor.com/project/psychon/x11rb)
[![Crate](https://img.shields.io/crates/v/x11rb.svg)](https://crates.io/crates/x11rb)
[![API](https://docs.rs/x11rb/badge.svg)](https://docs.rs/x11rb)
![Minimum rustc version](https://img.shields.io/badge/rustc-1.41+-lightgray.svg)
![Minimum rustc version](https://img.shields.io/badge/rustc-1.46+-lightgray.svg)
[![License](https://img.shields.io/crates/l/x11rb.svg)](https://github.com/psychon/x11rb#license)

Feel free to open issues for any problems or questions you might have.
Expand Down
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
msrv = "1.41.0"
msrv = "1.46.0"
5 changes: 1 addition & 4 deletions generator/src/generator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@ pub(crate) fn generate(module: &xcbgen::defs::Module) -> HashMap<PathBuf, String
}

fn ext_has_feature(name: &str) -> bool {
match name {
"bigreq" | "ge" | "xc_misc" | "xproto" => false,
_ => true,
}
!matches!(name, "bigreq" | "ge" | "xc_misc" | "xproto")
}

/// Add a Rust-header to the output saying that this file is generated.
Expand Down
34 changes: 16 additions & 18 deletions generator/src/generator/namespace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -781,20 +781,18 @@ impl<'ns, 'c> NamespaceGenerator<'ns, 'c> {

// An enum is ok for bitmask if all its values are <bit>
// or have value zero (but not if all values are zero)
let ok_for_bitmask = enum_def
let ok_for_bitmask = enum_def.items.iter().all(|enum_item| {
matches!(
enum_item.value,
xcbdefs::EnumValue::Value(0) | xcbdefs::EnumValue::Bit(_)
)
}) && enum_def
.items
.iter()
.all(|enum_item| match enum_item.value {
xcbdefs::EnumValue::Value(0) | xcbdefs::EnumValue::Bit(_) => true,
_ => false,
})
&& enum_def
.items
.iter()
.any(|enum_item| match enum_item.value {
xcbdefs::EnumValue::Value(_) => false,
xcbdefs::EnumValue::Bit(_) => true,
});
.any(|enum_item| match enum_item.value {
xcbdefs::EnumValue::Value(_) => false,
xcbdefs::EnumValue::Bit(_) => true,
});

outln!(out, "impl std::fmt::Debug for {} {{", rust_name);
out.indented(|out| {
Expand Down Expand Up @@ -971,13 +969,13 @@ impl<'ns, 'c> NamespaceGenerator<'ns, 'c> {
}
type_ => type_.clone(),
};
match original_type {
matches!(
original_type,
xcbdefs::TypeRef::BuiltIn(xcbdefs::BuiltInType::Card8)
| xcbdefs::TypeRef::BuiltIn(xcbdefs::BuiltInType::Byte)
| xcbdefs::TypeRef::BuiltIn(xcbdefs::BuiltInType::Char)
| xcbdefs::TypeRef::BuiltIn(xcbdefs::BuiltInType::Void) => true,
_ => false,
}
| xcbdefs::TypeRef::BuiltIn(xcbdefs::BuiltInType::Byte)
| xcbdefs::TypeRef::BuiltIn(xcbdefs::BuiltInType::Char)
| xcbdefs::TypeRef::BuiltIn(xcbdefs::BuiltInType::Void)
)
}
}

Expand Down
6 changes: 1 addition & 5 deletions generator/src/generator/namespace/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,7 @@ fn emit_value_post_parse(type_: &xcbdefs::FieldValueType, var_name: &str, out: &
}

fn needs_post_parse(type_: &xcbdefs::FieldValueType) -> bool {
if let xcbdefs::FieldValueSet::Enum(_) = type_.value_set {
true
} else {
false
}
matches!(type_.value_set, xcbdefs::FieldValueSet::Enum(_))
}

pub(super) fn can_use_simple_list_parsing(
Expand Down
24 changes: 9 additions & 15 deletions generator/src/generator/namespace/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,13 +449,9 @@ fn emit_request_struct(
out.indented(|out| {
let fields = request_def.fields.borrow();

let has_expr_fields = fields.iter().any(|field| {
if let xcbdefs::FieldDef::Expr(_) = field {
true
} else {
false
}
});
let has_expr_fields = fields
.iter()
.any(|field| matches!(field, xcbdefs::FieldDef::Expr(_)));
// Calculate `VirtualLen` field values because they
// may be used by <exprfield>s.
if has_expr_fields {
Expand Down Expand Up @@ -1356,10 +1352,7 @@ fn gather_request_fields(
.use_enum_type_in_field(&normal_field.type_)
.is_none()
{
match normal_field.type_.value_set {
xcbdefs::FieldValueSet::None => false,
_ => true,
}
!matches!(normal_field.type_.value_set, xcbdefs::FieldValueSet::None)
} else {
false
};
Expand Down Expand Up @@ -1460,10 +1453,11 @@ fn gather_request_fields(
.reply
.as_ref()
.map(|reply_def| {
reply_def.fields.borrow().iter().any(|field| match field {
xcbdefs::FieldDef::Fd(_) => true,
xcbdefs::FieldDef::FdList(_) => true,
_ => false,
reply_def.fields.borrow().iter().any(|field| {
matches!(
field,
xcbdefs::FieldDef::Fd(_) | xcbdefs::FieldDef::FdList(_)
)
})
})
.unwrap_or(false);
Expand Down
5 changes: 1 addition & 4 deletions generator/src/generator/namespace/resource_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,7 @@ fn generate_creator(
.use_enum_type_in_field(&normal_field.type_)
.is_none()
{
match normal_field.type_.value_set {
xcbdefs::FieldValueSet::None => false,
_ => true,
}
!matches!(normal_field.type_.value_set, xcbdefs::FieldValueSet::None)
} else {
false
};
Expand Down
8 changes: 5 additions & 3 deletions generator/src/generator/namespace/struct_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ pub(super) fn emit_struct_type(
}
outln!(out, "}}");

let has_fds = fields.iter().any(|field| match field {
xcbdefs::FieldDef::Fd(_) | xcbdefs::FieldDef::FdList(_) => true,
_ => false,
let has_fds = fields.iter().any(|field| {
matches!(
field,
xcbdefs::FieldDef::Fd(_) | xcbdefs::FieldDef::FdList(_)
)
});

if generate_try_parse {
Expand Down
12 changes: 6 additions & 6 deletions generator/src/generator/namespace/switch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -996,12 +996,12 @@ fn case_has_single_visible_field(
fn needs_match_by_value(field: &xcbdefs::FieldDef) -> bool {
match field {
xcbdefs::FieldDef::Normal(normal_field) => {
match normal_field.type_.type_.get_resolved().get_original_type() {
xcbdefs::TypeRef::BuiltIn(_) => true,
xcbdefs::TypeRef::Xid(_) => true,
xcbdefs::TypeRef::XidUnion(_) => true,
_ => false,
}
matches!(
normal_field.type_.type_.get_resolved().get_original_type(),
xcbdefs::TypeRef::BuiltIn(_)
| xcbdefs::TypeRef::Xid(_)
| xcbdefs::TypeRef::XidUnion(_)
)
}
_ => false,
}
Expand Down
8 changes: 2 additions & 6 deletions src/cursor/find_cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,7 @@ fn parse_inherits_impl(input: &mut impl BufRead) -> Result<Vec<String>, IOError>
to_parse = &to_parse[1..];

fn should_skip(c: u8) -> bool {
match c {
b' ' | b'\t' | b'\n' | b';' | b',' => true,
_ => false,
}
matches!(c, b' ' | b'\t' | b'\n' | b';' | b',')
}

// Iterate over the pieces
Expand Down Expand Up @@ -261,9 +258,8 @@ where
// Calculate the path to the theme's directory
let mut theme_dir = PathBuf::new();
// Does the path begin with '~'?
if path.starts_with('~') {
if let Some(mut path) = path.strip_prefix('~') {
theme_dir.push(&home);
let mut path = &path[1..];
// Skip a path separator if there is one
if path.chars().next().map(std::path::is_separator) == Some(true) {
path = &path[1..];
Expand Down
5 changes: 1 addition & 4 deletions src/resource_manager/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ use super::{Binding, Component, Entry};

/// Check if a character (well, u8) is an octal digit
fn is_octal_digit(c: u8) -> bool {
match c {
b'0' | b'1' | b'2' | b'3' | b'4' | b'5' | b'6' | b'7' => true,
_ => false,
}
matches!(c, b'0' | b'1' | b'2' | b'3' | b'4' | b'5' | b'6' | b'7')
}

/// Find the longest prefix of the given data where the given callback returns true
Expand Down