Skip to content

Commit f54d47f

Browse files
authored
Merge pull request #88 from rust-embedded-community/feature/ci-fixes
Updating CI
2 parents a0dad18 + dc4a6fd commit f54d47f

File tree

9 files changed

+55
-84
lines changed

9 files changed

+55
-84
lines changed

.github/workflows/ci.yml

+26-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
on:
22
push:
3-
branches: [ staging, trying, master ]
3+
branches: [ master ]
44
pull_request:
5+
branches: [ master ]
56

67
name: Continuous integration
78

@@ -30,19 +31,32 @@ jobs:
3031
TARGET: x86_64-unknown-linux-gnu
3132

3233
steps:
33-
- uses: actions/checkout@v2
34-
- uses: actions-rs/toolchain@v1
34+
- uses: actions/checkout@v4
35+
36+
- uses: dtolnay/rust-toolchain@stable
3537
with:
36-
profile: minimal
3738
toolchain: ${{ matrix.rust }}
3839
target: ${{ matrix.TARGET }}
39-
override: true
40-
- uses: actions-rs/cargo@v1
41-
with:
42-
command: build
43-
args: --target=${{ matrix.TARGET }}
44-
- uses: actions-rs/cargo@v1
40+
41+
- run: cargo build --target=${{ matrix.TARGET }}
42+
43+
- run: cargo test --target=${{ matrix.TARGET }} --all-features
4544
if: ${{ contains(matrix.TARGET, 'x86_64') }}
45+
46+
clippy:
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v4
50+
- uses: dtolnay/rust-toolchain@stable
4651
with:
47-
command: test
48-
args: --target=${{ matrix.TARGET }} --all-features
52+
components: clippy
53+
54+
- run: cargo clippy
55+
56+
fmt:
57+
name: Rustfmt
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: actions/checkout@v4
61+
- uses: dtolnay/rust-toolchain@stable
62+
- run: cargo fmt --all -- --check

.github/workflows/clippy.yml

-20
This file was deleted.

.github/workflows/rustfmt.yml

-23
This file was deleted.

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1212
- Support for optional package `defmt` which allows for easy conversion for
1313
error types when using tools like `probe-rs` for logging over debuggers.
1414
- Implement `Serializer::collect_str`
15+
- Derive `Serialize` for `de::Error` and `ser::Error`
1516

1617
### Changed
1718

rust-toolchain

-1
This file was deleted.

src/ser/map.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ impl<'a, 'b: 'a> ser::SerializeMap for SerializeMap<'a, 'b> {
2222
Ok(())
2323
}
2424

25-
fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<()>
25+
fn serialize_key<T>(&mut self, key: &T) -> Result<()>
2626
where
27-
T: ser::Serialize,
27+
T: ser::Serialize + ?Sized,
2828
{
2929
if !self.first {
3030
self.ser.push(b',')?;
@@ -35,9 +35,9 @@ impl<'a, 'b: 'a> ser::SerializeMap for SerializeMap<'a, 'b> {
3535
Ok(())
3636
}
3737

38-
fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<()>
38+
fn serialize_value<T>(&mut self, value: &T) -> Result<()>
3939
where
40-
T: ser::Serialize,
40+
T: ser::Serialize + ?Sized,
4141
{
4242
value.serialize(&mut *self.ser)?;
4343
Ok(())

src/ser/mod.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use core::mem::MaybeUninit;
44
use core::{fmt, str};
55

66
use serde::ser;
7-
use serde::Serialize;
87
use serde::ser::SerializeStruct as _;
8+
use serde::Serialize;
99

1010
#[cfg(feature = "heapless")]
1111
use heapless::{String, Vec};
@@ -186,8 +186,8 @@ macro_rules! serialize_unsigned {
186186
macro_rules! serialize_signed {
187187
($self:ident, $N:expr, $v:expr, $ixx:ident, $uxx:ident) => {{
188188
let v = $v;
189-
let (signed, mut v) = if v == $ixx::min_value() {
190-
(true, $ixx::max_value() as $uxx + 1)
189+
let (signed, mut v) = if v == $ixx::MIN {
190+
(true, $ixx::MAX as $uxx + 1)
191191
} else if v < 0 {
192192
(true, -v as $uxx)
193193
} else {
@@ -339,9 +339,9 @@ impl<'a, 'b: 'a> ser::Serializer for &'a mut Serializer<'b> {
339339
self.extend_from_slice(b"null")
340340
}
341341

342-
fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Self::Ok>
342+
fn serialize_some<T>(self, value: &T) -> Result<Self::Ok>
343343
where
344-
T: ser::Serialize,
344+
T: ser::Serialize + ?Sized,
345345
{
346346
value.serialize(self)
347347
}
@@ -363,22 +363,22 @@ impl<'a, 'b: 'a> ser::Serializer for &'a mut Serializer<'b> {
363363
self.serialize_str(variant)
364364
}
365365

366-
fn serialize_newtype_struct<T: ?Sized>(self, _name: &'static str, value: &T) -> Result<Self::Ok>
366+
fn serialize_newtype_struct<T>(self, _name: &'static str, value: &T) -> Result<Self::Ok>
367367
where
368-
T: ser::Serialize,
368+
T: ser::Serialize + ?Sized,
369369
{
370370
value.serialize(self)
371371
}
372372

373-
fn serialize_newtype_variant<T: ?Sized>(
373+
fn serialize_newtype_variant<T>(
374374
self,
375375
_name: &'static str,
376376
_variant_index: u32,
377377
variant: &'static str,
378378
value: &T,
379379
) -> Result<Self::Ok>
380380
where
381-
T: ser::Serialize,
381+
T: ser::Serialize + ?Sized,
382382
{
383383
self.push(b'{')?;
384384
let mut s = SerializeStruct::new(self);
@@ -441,9 +441,9 @@ impl<'a, 'b: 'a> ser::Serializer for &'a mut Serializer<'b> {
441441
Ok(SerializeStructVariant::new(self))
442442
}
443443

444-
fn collect_str<T: ?Sized>(self, value: &T) -> Result<Self::Ok>
444+
fn collect_str<T>(self, value: &T) -> Result<Self::Ok>
445445
where
446-
T: fmt::Display,
446+
T: fmt::Display + ?Sized,
447447
{
448448
self.push(b'"')?;
449449

@@ -715,7 +715,7 @@ mod tests {
715715

716716
assert_eq!(
717717
&*crate::to_string::<_, N>(&Temperature {
718-
temperature: -2.3456789012345e-23
718+
temperature: -2.345_678_8e-23
719719
})
720720
.unwrap(),
721721
r#"{"temperature":-2.3456788e-23}"#
@@ -871,7 +871,7 @@ mod tests {
871871
{
872872
let mut aux: String<{ N }> = String::new();
873873
write!(aux, "{:.2}", self.0).unwrap();
874-
serializer.serialize_bytes(&aux.as_bytes())
874+
serializer.serialize_bytes(aux.as_bytes())
875875
}
876876
}
877877

@@ -881,7 +881,7 @@ mod tests {
881881
let sd2 = SimpleDecimal(0.000);
882882
assert_eq!(&*crate::to_string::<_, N>(&sd2).unwrap(), r#"0.00"#);
883883

884-
let sd3 = SimpleDecimal(22222.777777);
884+
let sd3 = SimpleDecimal(22_222.777);
885885
assert_eq!(&*crate::to_string::<_, N>(&sd3).unwrap(), r#"22222.78"#);
886886
}
887887
}

src/ser/seq.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ impl<'a, 'b: 'a> ser::SerializeSeq for SerializeSeq<'a, 'b> {
1717
type Ok = ();
1818
type Error = Error;
1919

20-
fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<()>
20+
fn serialize_element<T>(&mut self, value: &T) -> Result<()>
2121
where
22-
T: ser::Serialize,
22+
T: ser::Serialize + ?Sized,
2323
{
2424
if !self.first {
2525
self.de.push(b',')?;
@@ -40,9 +40,9 @@ impl<'a, 'b: 'a> ser::SerializeTuple for SerializeSeq<'a, 'b> {
4040
type Ok = ();
4141
type Error = Error;
4242

43-
fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<()>
43+
fn serialize_element<T>(&mut self, value: &T) -> Result<()>
4444
where
45-
T: ser::Serialize,
45+
T: ser::Serialize + ?Sized,
4646
{
4747
ser::SerializeSeq::serialize_element(self, value)
4848
}
@@ -56,9 +56,9 @@ impl<'a, 'b: 'a> ser::SerializeTupleStruct for SerializeSeq<'a, 'b> {
5656
type Ok = ();
5757
type Error = Error;
5858

59-
fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<()>
59+
fn serialize_field<T>(&mut self, value: &T) -> Result<()>
6060
where
61-
T: ser::Serialize,
61+
T: ser::Serialize + ?Sized,
6262
{
6363
ser::SerializeSeq::serialize_element(self, value)
6464
}

src/ser/struct_.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ impl<'a, 'b: 'a> ser::SerializeStruct for SerializeStruct<'a, 'b> {
1717
type Ok = ();
1818
type Error = Error;
1919

20-
fn serialize_field<T: ?Sized>(&mut self, key: &'static str, value: &T) -> Result<()>
20+
fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<()>
2121
where
22-
T: ser::Serialize,
22+
T: ser::Serialize + ?Sized,
2323
{
2424
// XXX if `value` is `None` we not produce any output for this field
2525
if !self.first {
@@ -57,9 +57,9 @@ impl<'a, 'b: 'a> ser::SerializeStructVariant for SerializeStructVariant<'a, 'b>
5757
type Ok = ();
5858
type Error = Error;
5959

60-
fn serialize_field<T: ?Sized>(&mut self, key: &'static str, value: &T) -> Result<()>
60+
fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<()>
6161
where
62-
T: ser::Serialize,
62+
T: ser::Serialize + ?Sized,
6363
{
6464
// XXX if `value` is `None` we not produce any output for this field
6565
if !self.first {

0 commit comments

Comments
 (0)