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

Avoid new lints in 1.81.0 #337

Merged
merged 7 commits into from
Sep 23, 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
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
#
# This is used so that clippy & tests are run on a reliable reference point.
# If clippy has any warnings, this will fail the build (we run with --deny warnings)
- 1.72
- 1.81
# The most recent version of stable rust (automatically updated)
#
# Sometimes, this is exactly the same as the hardcoded right above.
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
* doc: Fix "lazy continuation" in `slog::Logger` doc
* This mistake was caught by a new lint [`#[warn(clippy::doc_lazy_continuation)]`](https://rust-lang.github.io/rust-clippy/rust-1.81.0/index.html#/doc_lazy_continuation)
* Fix some internal warnings
* Example: Avoid the new [`#[warn(unexpected_cfgs)]`](https://blog.rust-lang.org/2024/05/06/check-cfg.html) lint.
* None of these should affect user crates
* nested-values: Fix CI failure caused by `#[deny(unused_extern_crates)]` lint
* Switch `#[deny(rust_2018_idioms)]` to `#[warn(...)]` to avoid unnecessary build failures in the future.
* I don't *think* this should affect user code.

### 2.8.0-beta.2 - 2024-01-05

Expand Down
6 changes: 6 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,10 @@ fn main() {
if !is_emscripten {
println!("cargo:rustc-cfg=integer128");
}

// In Rust 1.80, cfg names are validated at compile time
// See blog: https://blog.rust-lang.org/2024/05/06/check-cfg.html
//
// On prior versions, this directive is ignored.
println!("cargo:rustc-check-cfg=cfg(integer128)");
}
1 change: 1 addition & 0 deletions crates/test_edition2018/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "test_edition2018"
version = "0.0.0"
description = "A crate for testing 2018-style macro imports"
edition = "2018"
authors = ["Yusuke Sasaki <yusuke.sasaki.nuem@gmail.com>"]
publish = false

Expand Down
25 changes: 0 additions & 25 deletions src/key/dynamic.rs
Original file line number Diff line number Diff line change
@@ -1,37 +1,12 @@
#[cfg(not(feature = "std"))]
use alloc::borrow::Cow;
#[cfg(not(feature = "std"))]
use alloc::string::{String, ToString};
#[cfg(not(feature = "std"))]
use core::clone::Clone;
#[cfg(not(feature = "std"))]
use core::cmp::PartialEq;
#[cfg(not(feature = "std"))]
use core::convert::{AsRef, From};
#[cfg(not(feature = "std"))]
use core::fmt;
#[cfg(not(feature = "std"))]
use core::hash::{Hash, Hasher};
#[cfg(not(feature = "std"))]
use core::iter::{FromIterator, IntoIterator};

#[cfg(feature = "std")]
use std::borrow::Cow;
#[cfg(feature = "std")]
use std::cmp::PartialEq;
#[cfg(feature = "std")]
use std::convert::{AsRef, From};
#[cfg(feature = "std")]
use std::fmt;
#[cfg(feature = "std")]
use std::hash::{Hash, Hasher};
#[cfg(feature = "std")]
use std::iter::{FromIterator, IntoIterator};
#[cfg(feature = "std")]
use std::string::String;
#[cfg(feature = "std")]
use std::string::ToString;

/// Opaque Key is a representation of a key.
///
/// It is owned, and largely forms a contract for
Expand Down
45 changes: 13 additions & 32 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,47 +278,28 @@

// {{{ Imports & meta
#![warn(missing_docs)]
#![deny(rust_2018_idioms)]
#![no_std]
#![warn(rust_2018_idioms)]
#![warn(
// Use `core` and `alloc` instead of `std` wherever possible
clippy::alloc_instead_of_core,
clippy::std_instead_of_core,
clippy::std_instead_of_alloc,
)]
#![cfg_attr(not(feature = "std"), no_std)]

#[cfg(not(feature = "std"))]
extern crate alloc;
#[macro_use]
#[cfg(feature = "std")]
extern crate std;

mod key;
pub use self::key::Key;
#[cfg(not(feature = "std"))]

use alloc::borrow::{Cow, ToOwned};
#[cfg(not(feature = "std"))]
use alloc::boxed::Box;
#[cfg(not(feature = "std"))]
use alloc::rc::Rc;
#[cfg(not(feature = "std"))]
use alloc::string::String;
#[cfg(not(feature = "std"))]
use alloc::{sync::Arc, vec::Vec};

#[cfg(feature = "nested-values")]
extern crate erased_serde;
#[cfg(feature = "nested-values")]
extern crate serde;

use core::str::FromStr;
use core::{convert, fmt, result};
#[cfg(feature = "std")]
use std::borrow::{Cow, ToOwned};
#[cfg(feature = "std")]
use std::boxed::Box;
#[cfg(feature = "std")]
use std::rc::Rc;
#[cfg(feature = "std")]
use std::string::String;
#[cfg(feature = "std")]
use std::sync::Arc;
#[cfg(feature = "std")]
use std::vec::Vec;
// }}}

// {{{ Macros
Expand Down Expand Up @@ -1088,7 +1069,7 @@ macro_rules! __slog_builtin {
/// In an essence `Logger` instance holds two pieces of information:
///
/// * drain - destination where to forward logging `Record`s for
/// processing.
/// processing.
/// * context - list of key-value pairs associated with it.
///
/// The root `Logger` is created with a `Drain` that will be cloned to every
Expand Down Expand Up @@ -2439,7 +2420,7 @@ fn filter_level_to_string_and_from_str_are_compatible() {
#[cfg(all(test, feature = "std"))]
fn assert_to_string_from_str<T>(expected: T)
where
T: std::string::ToString + FromStr + PartialEq + fmt::Debug,
T: alloc::string::ToString + FromStr + PartialEq + fmt::Debug,
<T as FromStr>::Err: fmt::Debug,
{
let string = expected.to_string();
Expand Down Expand Up @@ -3931,7 +3912,7 @@ pub enum Error {
/// `io::Error` (not available in ![no_std] mode)
Io(std::io::Error),
/// `fmt::Error`
Fmt(std::fmt::Error),
Fmt(core::fmt::Error),
/// Other error
Other,
}
Expand Down Expand Up @@ -4001,7 +3982,7 @@ impl std::error::Error for Error {

#[cfg(feature = "std")]
impl core::fmt::Display for Error {
fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match *self {
Error::Io(ref e) => e.fmt(fmt),
Error::Fmt(ref e) => e.fmt(fmt),
Expand Down
6 changes: 3 additions & 3 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mod std_only {
&self,
record: &Record<'_>,
values: &OwnedKVList,
) -> std::result::Result<Self::Ok, Self::Err> {
) -> core::result::Result<Self::Ok, Self::Err> {
struct ErrorSerializer(String);

impl Serializer for ErrorSerializer {
Expand Down Expand Up @@ -66,7 +66,7 @@ mod std_only {
}

#[derive(Debug)]
struct TestError<E = std::string::ParseError>(&'static str, Option<E>);
struct TestError<E = alloc::string::ParseError>(&'static str, Option<E>);

impl TestError {
fn new(message: &'static str) -> Self {
Expand Down Expand Up @@ -112,7 +112,7 @@ mod std_only {
&self,
record: &Record<'_>,
values: &OwnedKVList,
) -> std::result::Result<Self::Ok, Self::Err> {
) -> core::result::Result<Self::Ok, Self::Err> {
assert_eq!(
format!("{}", record.msg()),
format!("{:?}", values)
Expand Down
Loading