diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..c624af6f5 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,80 @@ +name: CI +on: [push, pull_request] + +jobs: + test: + name: Test + runs-on: ${{ matrix.os }} + strategy: + matrix: + build: [stable, beta, nightly, macos, win32, win64, mingw] + include: + - build: stable + os: ubuntu-latest + rust: stable + - build: beta + os: ubuntu-latest + rust: beta + - build: nightly + os: ubuntu-latest + rust: nightly + - build: macos + os: macos-latest + rust: stable + - build: win32 + os: windows-latest + rust: stable-i686 + - build: win64 + os: windows-latest + rust: stable-x86_64 + - build: mingw + os: windows-latest + rust: stable-x86_64-gnu + steps: + - uses: actions/checkout@master + - name: Install Rust (rustup) + run: rustup update ${{ matrix.rust }} && rustup default ${{ matrix.rust }} + if: matrix.os != 'macos-latest' + - name: Install Rust (macos) + run: | + curl https://sh.rustup.rs | sh -s -- -y + echo "##[add-path]$HOME/.cargo/bin" + if: matrix.os == 'macos-latest' + - run: cargo test --verbose + - run: cargo test --verbose --features serde + - run: cargo test --verbose --features std + - run: cargo test --verbose --features kv_unstable + - run: cargo test --verbose --features "kv_unstable std" + - run: cargo test --verbose --features "kv_unstable_sval" + - run: cargo run --verbose --manifest-path test_max_level_features/Cargo.toml + - run: cargo run --verbose --manifest-path test_max_level_features/Cargo.toml --release + + rustfmt: + name: Rustfmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Install Rust + run: rustup update stable && rustup default stable && rustup component add rustfmt + - run: cargo fmt -- --check + + msrv: + name: MSRV + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Install Rust + run: rustup update 1.16.0 && rustup default 1.16.0 + - run: cargo build --verbose + - run: cargo build --verbose --features serde + - run: cargo build --verbose --features std + + embedded: + name: Embedded + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Install Rust + run: rustup update stable && rustup default stable + - run: rustup target add thumbv6m-none-eabi + - run: cargo build --verbose --target=thumbv6m-none-eabi diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4fd7e9195..000000000 --- a/.travis.yml +++ /dev/null @@ -1,34 +0,0 @@ -language: rust -sudo: false -rust: - - stable - - beta - - nightly -matrix: - include: - - rust: stable - env: - - LABEL="Embedded" - script: - - rustup target add thumbv6m-none-eabi - - cargo build --verbose --target=thumbv6m-none-eabi - - rust: 1.16.0 - env: - - LABEL="MSRV" - script: - - cargo build --verbose - - cargo build --verbose --features serde - - cargo build --verbose --features std -script: - - cargo test --verbose - - cargo test --verbose --features serde - - cargo test --verbose --features std - - cargo test --verbose --features kv_unstable - - cargo test --verbose --features "kv_unstable std" - - cargo test --verbose --features "kv_unstable_sval" - - cargo run --verbose --manifest-path test_max_level_features/Cargo.toml - - cargo run --verbose --manifest-path test_max_level_features/Cargo.toml --release - -notifications: - email: - on_success: never diff --git a/Cargo.toml b/Cargo.toml index e7e789293..b64111b9f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,10 +44,6 @@ std = [] kv_unstable = [] kv_unstable_sval = ["kv_unstable", "sval/fmt"] -[badges] -travis-ci = { repository = "rust-lang-nursery/log" } -appveyor = { repository = "alexcrichton/log" } - [dependencies] cfg-if = "0.1.2" serde = { version = "1.0", optional = true, default-features = false } diff --git a/README.md b/README.md index 5fbcc9701..e9f2573ea 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,6 @@ log A Rust library providing a lightweight logging *facade*. -[![Build Status](https://travis-ci.com/rust-lang-nursery/log.svg?branch=master)](https://travis-ci.com/rust-lang-nursery/log) -[![Build status](https://ci.appveyor.com/api/projects/status/nopdjmmjt45xcrki?svg=true)](https://ci.appveyor.com/project/alexcrichton/log) [![Latest version](https://img.shields.io/crates/v/log.svg)](https://crates.io/crates/log) [![Documentation](https://docs.rs/log/badge.svg)](https://docs.rs/log) ![License](https://img.shields.io/crates/l/log.svg) diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index eb6786dd1..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,19 +0,0 @@ -environment: - matrix: - - TARGET: x86_64-pc-windows-msvc - - TARGET: i686-pc-windows-msvc - - TARGET: i686-pc-windows-gnu -install: - - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe" - - rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" - - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin - - SET PATH=%PATH%;C:\MinGW\bin - - rustc -V - - cargo -V - -build: false - -test_script: - - cargo test --verbose - - cargo test --verbose --features serde - - cargo test --verbose --features std diff --git a/src/kv/error.rs b/src/kv/error.rs index 0f5652f92..120d74919 100644 --- a/src/kv/error.rs +++ b/src/kv/error.rs @@ -3,7 +3,7 @@ use std::fmt; /// An error encountered while working with structured data. #[derive(Debug)] pub struct Error { - inner: Inner + inner: Inner, } #[derive(Debug)] @@ -37,9 +37,7 @@ impl fmt::Display for Error { impl From for Error { fn from(_: fmt::Error) -> Self { - Error { - inner: Inner::Fmt, - } + Error { inner: Inner::Fmt } } } @@ -63,7 +61,7 @@ mod std_support { E: Into, { Error { - inner: Inner::Boxed(err.into()) + inner: Inner::Boxed(err.into()), } } } diff --git a/src/kv/key.rs b/src/kv/key.rs index 82f1e85e6..86fd0668a 100644 --- a/src/kv/key.rs +++ b/src/kv/key.rs @@ -1,9 +1,9 @@ //! Structured keys. -use std::fmt; +use std::borrow::Borrow; use std::cmp; +use std::fmt; use std::hash; -use std::borrow::Borrow; /// A type that can be converted into a [`Key`](struct.Key.html). pub trait ToKey { @@ -22,9 +22,7 @@ where impl<'k> ToKey for Key<'k> { fn to_key(&self) -> Key { - Key { - key: self.key, - } + Key { key: self.key } } } @@ -43,9 +41,7 @@ pub struct Key<'k> { impl<'k> Key<'k> { /// Get a key from a borrowed string. pub fn from_str(key: &'k str) -> Self { - Key { - key: key, - } + Key { key: key } } /// Get a borrowed string from this key. diff --git a/src/kv/source.rs b/src/kv/source.rs index 0538c14f4..914f3bdac 100644 --- a/src/kv/source.rs +++ b/src/kv/source.rs @@ -1,7 +1,7 @@ //! Sources for key-value pairs. +use kv::{Error, Key, ToKey, ToValue, Value}; use std::fmt; -use kv::{Error, Key, ToKey, Value, ToValue}; /// A source of key-value pairs. /// @@ -22,7 +22,7 @@ pub trait Source { fn visit<'kvs>(&'kvs self, visitor: &mut Visitor<'kvs>) -> Result<(), Error>; /// Get the value for a given key. - /// + /// /// If the key appears multiple times in the source then which key is returned /// is implementation specific. /// @@ -46,10 +46,7 @@ pub trait Source { } } - let mut get = Get { - key, - found: None, - }; + let mut get = Get { key, found: None }; let _ = self.visit(&mut get); get.found diff --git a/src/kv/value/impls.rs b/src/kv/value/impls.rs index ea181466b..59b181e37 100644 --- a/src/kv/value/impls.rs +++ b/src/kv/value/impls.rs @@ -1,6 +1,6 @@ use std::fmt; -use super::{ToValue, Value, Primitive}; +use super::{Primitive, ToValue, Value}; impl ToValue for usize { fn to_value(&self) -> Value { @@ -246,8 +246,14 @@ mod tests { assert_eq!(42.01f64.to_value().to_string(), "42.01"); assert_eq!(true.to_value().to_string(), "true"); assert_eq!('a'.to_value().to_string(), "'a'"); - assert_eq!(format_args!("a {}", "value").to_value().to_string(), "a value"); - assert_eq!("a loong string".to_value().to_string(), "\"a loong string\""); + assert_eq!( + format_args!("a {}", "value").to_value().to_string(), + "a value" + ); + assert_eq!( + "a loong string".to_value().to_string(), + "\"a loong string\"" + ); assert_eq!(Some(true).to_value().to_string(), "true"); assert_eq!(().to_value().to_string(), "None"); assert_eq!(Option::None::.to_value().to_string(), "None"); @@ -260,8 +266,14 @@ mod tests { assert_eq!(42.01f64.to_value().to_token(), Token::F64(42.01)); assert_eq!(true.to_value().to_token(), Token::Bool(true)); assert_eq!('a'.to_value().to_token(), Token::Char('a')); - assert_eq!(format_args!("a {}", "value").to_value().to_token(), Token::Str("a value".into())); - assert_eq!("a loong string".to_value().to_token(), Token::Str("a loong string".into())); + assert_eq!( + format_args!("a {}", "value").to_value().to_token(), + Token::Str("a value".into()) + ); + assert_eq!( + "a loong string".to_value().to_token(), + Token::Str("a loong string".into()) + ); assert_eq!(Some(true).to_value().to_token(), Token::Bool(true)); assert_eq!(().to_value().to_token(), Token::None); assert_eq!(Option::None::.to_value().to_token(), Token::None); diff --git a/src/kv/value/internal.rs b/src/kv/value/internal.rs index 5f01a317b..c437ab73e 100644 --- a/src/kv/value/internal.rs +++ b/src/kv/value/internal.rs @@ -1,6 +1,6 @@ use std::fmt; -use super::{Fill, Slot, Error}; +use super::{Error, Fill, Slot}; use kv; // `Visitor` is an internal API for visiting the structure of a value. @@ -49,7 +49,7 @@ impl<'v> Inner<'v> { pub(super) trait Visitor { fn debug(&mut self, v: &fmt::Debug) -> Result<(), Error>; fn display(&mut self, v: &fmt::Display) -> Result<(), Error> { - self.debug(&format_args!("{}", v)) + self.debug(&format_args!("{}", v)) } fn u64(&mut self, v: u64) -> Result<(), Error>; @@ -115,7 +115,7 @@ mod fmt_support { Ok(()) } } - + struct FmtVisitor<'a, 'b: 'a>(&'a mut fmt::Formatter<'b>); impl<'a, 'b: 'a> Visitor for FmtVisitor<'a, 'b> { @@ -197,7 +197,7 @@ pub(super) mod sval_support { fn from_sval(_: sval::value::Error) -> Self { Error::msg("`sval` serialization failed") } - + fn into_sval(self) -> sval::value::Error { sval::value::Error::msg("`sval` serialization failed") } @@ -207,7 +207,9 @@ pub(super) mod sval_support { impl<'a, 'b: 'a> Visitor for SvalVisitor<'a, 'b> { fn debug(&mut self, v: &fmt::Debug) -> Result<(), Error> { - self.0.fmt(format_args!("{:?}", v)).map_err(Error::from_sval) + self.0 + .fmt(format_args!("{:?}", v)) + .map_err(Error::from_sval) } fn u64(&mut self, v: u64) -> Result<(), Error> { diff --git a/src/kv/value/mod.rs b/src/kv/value/mod.rs index 1695afbd1..5872cc57c 100644 --- a/src/kv/value/mod.rs +++ b/src/kv/value/mod.rs @@ -2,15 +2,15 @@ use std::fmt; -mod internal; mod impls; +mod internal; #[cfg(test)] pub(in kv) mod test; pub use kv::Error; -use self::internal::{Inner, Visitor, Primitive}; +use self::internal::{Inner, Primitive, Visitor}; /// A type that can be converted into a [`Value`](struct.Value.html). pub trait ToValue { @@ -29,14 +29,12 @@ where impl<'v> ToValue for Value<'v> { fn to_value(&self) -> Value { - Value { - inner: self.inner, - } + Value { inner: self.inner } } } /// A type that requires extra work to convert into a [`Value`](struct.Value.html). -/// +/// /// This trait is a more advanced initialization API than [`ToValue`](trait.ToValue.html). /// It's intended for erased values coming from other logging frameworks that may need /// to perform extra work to determine the concrete type to use. @@ -75,11 +73,11 @@ impl<'a> Slot<'a> { } /// Fill the slot with a value. - /// + /// /// The given value doesn't need to satisfy any particular lifetime constraints. - /// + /// /// # Panics - /// + /// /// Calling `fill` more than once will panic. pub fn fill(&mut self, value: Value) -> Result<(), Error> { assert!(!self.filled, "the slot has already been filled"); diff --git a/src/kv/value/test.rs b/src/kv/value/test.rs index c9c03dc42..61f2d3ac8 100644 --- a/src/kv/value/test.rs +++ b/src/kv/value/test.rs @@ -3,8 +3,8 @@ use std::fmt; use std::str; -use super::{Value, Error}; use super::internal; +use super::{Error, Value}; #[derive(Debug, PartialEq)] pub(in kv) enum Token { diff --git a/src/lib.rs b/src/lib.rs index e113e62bf..53fcb3c00 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -846,7 +846,7 @@ impl<'a> Record<'a> { file: self.file, line: self.line, key_values: self.key_values.clone(), - } + }, } } } @@ -1641,24 +1641,17 @@ mod tests { fn visit_pair( &mut self, _: kv::Key<'kvs>, - _: kv::Value<'kvs> + _: kv::Value<'kvs>, ) -> Result<(), kv::Error> { self.seen_pairs += 1; Ok(()) } } - let kvs: &[(&str, i32)] = &[ - ("a", 1), - ("b", 2) - ]; - let record_test = Record::builder() - .key_values(&kvs) - .build(); + let kvs: &[(&str, i32)] = &[("a", 1), ("b", 2)]; + let record_test = Record::builder().key_values(&kvs).build(); - let mut visitor = TestVisitor { - seen_pairs: 0, - }; + let mut visitor = TestVisitor { seen_pairs: 0 }; record_test.key_values().visit(&mut visitor).unwrap();