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

Update MSRV check to account for features #260

Merged
merged 2 commits into from
Aug 26, 2024
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
21 changes: 9 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,19 @@ jobs:
msrv:
runs-on: ubuntu-latest
strategy:
matrix:
signing: ["", "--features signing"]
matrix:
features: ["", "--features serde,tokio-1", "--features signing"]
steps:
- uses: actions/checkout@master
- name: Get MSRV from Cargo.toml
run: |
MSRV=$(grep 'rust-version' Cargo.toml | sed 's/.*= *"\(.*\)".*/\1/')
echo "MSRV=$MSRV" >> $GITHUB_ENV
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.65.0
- uses: actions-rs/cargo@v1
with:
command: install
args: cross --locked
- uses: actions-rs/cargo@v1
with:
use-cross: true
command: check
args: --all --all-targets ${{ matrix.signing }}
toolchain: ${{ env.MSRV }}
- uses: taiki-e/install-action@cargo-no-dev-deps
- run: cargo no-dev-deps check --all --all-targets ${{ matrix.features }}

build:
needs: [formatting, linting, internal-tests, mavlink-dump, msrv]
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ byteorder = { version = "1.3.4", default-features = false }

[workspace.package]
edition = "2021"
rust-version = "1.70.0"
1 change: 1 addition & 0 deletions mavlink-bindgen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ license = "MIT/Apache-2.0"
description = "Library used by rust-mavlink."
readme = "README.md"
repository = "https://github.com/mavlink/rust-mavlink"
rust-version.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
37 changes: 17 additions & 20 deletions mavlink-bindgen/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ impl MavEnum {

#[cfg(feature = "emit-description")]
let description = if let Some(description) = self.description.as_ref() {
let desc = format!("{description}");
let desc = description.to_string();
quote!(#[doc = #desc])
} else {
quote!()
Expand Down Expand Up @@ -1001,7 +1001,7 @@ pub enum MavXmlElement {
Extensions,
}

fn identify_element(s: &[u8]) -> Option<MavXmlElement> {
const fn identify_element(s: &[u8]) -> Option<MavXmlElement> {
use self::MavXmlElement::*;
match s {
b"version" => Some(Version),
Expand Down Expand Up @@ -1066,7 +1066,7 @@ pub fn parse_profile(
let mut events: Vec<Result<Event, quick_xml::Error>> = Vec::new();
let file = File::open(&in_path).map_err(|e| BindGenError::CouldNotReadDefinitionFile {
source: e,
path: in_path.to_path_buf(),
path: in_path.clone(),
})?;
let mut reader = Reader::from_reader(BufReader::new(file));
reader.config_mut().trim_text(true);
Expand All @@ -1088,14 +1088,11 @@ pub fn parse_profile(
for e in events {
match e {
Ok(Event::Start(bytes)) => {
let id = match identify_element(bytes.name().into_inner()) {
None => {
panic!(
"unexpected element {:?}",
String::from_utf8_lossy(bytes.name().into_inner())
);
}
Some(kind) => kind,
let Some(id) = identify_element(bytes.name().into_inner()) else {
panic!(
"unexpected element {:?}",
String::from_utf8_lossy(bytes.name().into_inner())
);
};

assert!(
Expand All @@ -1109,20 +1106,20 @@ pub fn parse_profile(
is_in_extension = true;
}
MavXmlElement::Message => {
message = Default::default();
message = MavMessage::default();
}
MavXmlElement::Field => {
field = Default::default();
field = MavField::default();
field.is_extension = is_in_extension;
}
MavXmlElement::Enum => {
mavenum = Default::default();
mavenum = MavEnum::default();
}
MavXmlElement::Entry => {
entry = Default::default();
entry = MavEnumEntry::default();
}
MavXmlElement::Include => {
include = Default::default();
include = PathBuf::default();
}
MavXmlElement::Param => {
paramid = None;
Expand Down Expand Up @@ -1237,7 +1234,7 @@ pub fn parse_profile(
if entry.params.is_none() {
entry.params = Some(vec![]);
}
if let b"index" = attr.key.into_inner() {
if attr.key.into_inner() == b"index" {
let s = std::str::from_utf8(&attr.value).unwrap();
paramid = Some(s.parse::<usize>().unwrap());
}
Expand All @@ -1251,7 +1248,7 @@ pub fn parse_profile(
is_in_extension = true;
}
b"entry" => {
entry = Default::default();
entry = MavEnumEntry::default();
for attr in bytes.attributes() {
let attr = attr.unwrap();
match attr.key.into_inner() {
Expand Down Expand Up @@ -1311,7 +1308,7 @@ pub fn parse_profile(
eprintln!("TODO: deprecated {s:?}");
}
data => {
panic!("unexpected text data {:?} reading {:?}", data, s);
panic!("unexpected text data {data:?} reading {s:?}");
}
}
}
Expand Down Expand Up @@ -1489,7 +1486,7 @@ impl MavXmlFilter {
}
!self.extension_filter.is_in
}
Err(error) => panic!("Failed to filter XML: {}", error),
Err(error) => panic!("Failed to filter XML: {error}"),
}
}
}
2 changes: 1 addition & 1 deletion mavlink-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ readme = "../README.md"
license = "MIT/Apache-2.0"
repository = "https://github.com/mavlink/rust-mavlink"
edition.workspace = true
rust-version = "1.65.0"
rust-version.workspace = true

[dependencies]
crc-any = { workspace = true, default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion mavlink/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ readme = "../README.md"
license = "MIT/Apache-2.0"
repository = "https://github.com/mavlink/rust-mavlink"
edition.workspace = true
rust-version = "1.65.0"
rust-version.workspace = true

[build-dependencies]
mavlink-bindgen = { path = "../mavlink-bindgen", default-features = false }
Expand Down
Loading