Skip to content

Commit

Permalink
Deny warnings on CI to keep codebase warning-free (rust-lang#394)
Browse files Browse the repository at this point in the history
* Deny warnings on CI to keep codebase warning-free

There's a ton of platforms here that we compile for and so it's only
really all covered on CI. To help keep warnings out for everyone let's
deny warnings on CI.

* Fix a warning in dylib-dep

No need to care much about FFI representation here since we control both
sides.

* Squash an elided lifetime warning

* Try to fix an extern crate warning

* Squash a windows warning

* Really squash unused crate

* Fix a serde warning

* Fix cpp-demangle formatter warnings

* Try to handle dead code a bit better

* Fix a warning found in tests
  • Loading branch information
alexcrichton authored Nov 20, 2020
1 parent e7cbd9b commit af078ec
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 32 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ jobs:
- name: Install Rust (rustup)
run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }}
shell: bash
- run: echo RUSTFLAGS=-Dwarnings >> $GITHUB_ENV
shell: bash
# full fidelity of backtraces on 32-bit msvc requires frame pointers, so
# enable that for our tests
- name: Force frame pointers
run: echo RUSTFLAGS=-Cforce-frame-pointers >> $GITHUB_ENV
run: echo RUSTFLAGS="-Cforce-frame-pointers $RUSTFLAGS" >> $GITHUB_ENV
shell: bash
if: matrix.thing == 'windows-msvc32'
- run: cargo build --manifest-path crates/backtrace-sys/Cargo.toml
Expand Down Expand Up @@ -99,6 +101,8 @@ jobs:
- name: Install Rust
run: rustup update stable --no-self-update && rustup default stable
shell: bash
- run: echo RUSTFLAGS=-Dwarnings >> $GITHUB_ENV
shell: bash
- run: rustup target add aarch64-pc-windows-msvc
- run: cargo test --no-run --target aarch64-pc-windows-msvc
- run: cargo test --no-run --target aarch64-pc-windows-msvc --features verify-winapi
Expand All @@ -122,6 +126,7 @@ jobs:
submodules: true
- run: rustup target add ${{ matrix.target }}
- run: |
export RUSTFLAGS=-Dwarnings
export SDK_PATH=`xcrun --show-sdk-path --sdk ${{ matrix.sdk }}`
export RUSTFLAGS="-C link-arg=-isysroot -C link-arg=$SDK_PATH"
cargo test --no-run --target ${{ matrix.target }}
Expand Down Expand Up @@ -156,6 +161,8 @@ jobs:
run: rustup update stable && rustup default stable
- run: rustup target add ${{ matrix.target }}
- run: cargo generate-lockfile
- run: echo RUSTFLAGS=-Dwarnings >> $GITHUB_ENV
shell: bash
- run: ./ci/run-docker.sh ${{ matrix.target }}

rustfmt:
Expand All @@ -182,6 +189,8 @@ jobs:
- name: Install Rust
run: rustup update nightly && rustup default nightly
- run: rustup target add ${{ matrix.target }}
- run: echo RUSTFLAGS=-Dwarnings >> $GITHUB_ENV
shell: bash
- run: cargo build --target ${{ matrix.target }}

msrv:
Expand Down
1 change: 1 addition & 0 deletions ci/run-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ run() {
--volume `pwd`/target:/checkout/target \
--workdir /checkout \
--privileged \
--env RUSTFLAGS \
backtrace \
bash \
-c 'PATH=$PATH:/rust/bin exec ci/run.sh'
Expand Down
1 change: 0 additions & 1 deletion crates/cpp_smoke_test/tests/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ extern "C" {

#[test]
#[ignore] // fixme(fitzgen/cpp_demangle#73)
#[cfg(not(target_os = "windows"))]
fn smoke_test_cpp() {
static RAN_ASSERTS: AtomicBool = AtomicBool::new(false);

Expand Down
2 changes: 2 additions & 0 deletions crates/dylib-dep/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(improper_ctypes_definitions)]

type Pos = (&'static str, u32);

macro_rules! pos {
Expand Down
1 change: 1 addition & 0 deletions src/backtrace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ cfg_if::cfg_if! {
mod dbghelp;
use self::dbghelp::trace as trace_imp;
pub(crate) use self::dbghelp::Frame as FrameImp;
#[cfg(target_env = "msvc")] // only used in dbghelp symbolize
pub(crate) use self::dbghelp::StackFrame;
} else {
mod noop;
Expand Down
8 changes: 3 additions & 5 deletions src/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,12 +472,10 @@ mod rustc_serialize_impls {

#[cfg(feature = "serde")]
mod serde_impls {
extern crate serde;

use self::serde::de::Deserializer;
use self::serde::ser::Serializer;
use self::serde::{Deserialize, Serialize};
use super::*;
use serde::de::Deserializer;
use serde::ser::Serializer;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize)]
struct SerializedFrame {
Expand Down
6 changes: 4 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@
// When we're building as part of libstd, silence all warnings since they're
// irrelevant as this crate is developed out-of-tree.
#![cfg_attr(backtrace_in_libstd, allow(warnings))]
#![cfg_attr(not(feature = "std"), allow(dead_code))]

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

// This is only used for gimli right now, so silence warnings elsewhere.
#[cfg_attr(not(target_os = "linux"), allow(unused_extern_crates))]
// This is only used for gimli right now, which is only used on some platforms,
// so don't worry if it's unused in other configurations.
#[allow(unused_extern_crates)]
extern crate alloc;

pub use self::backtrace::{trace_unsynchronized, Frame};
Expand Down
2 changes: 2 additions & 0 deletions src/symbolize/dbghelp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,5 @@ unsafe fn cache(filename: Option<*const [u16]>) -> Option<::std::ffi::OsString>

#[cfg(not(feature = "std"))]
unsafe fn cache(_filename: Option<*const [u16]>) {}

pub unsafe fn clear_symbol_cache() {}
2 changes: 1 addition & 1 deletion src/symbolize/gimli/coff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl<'a> Object<'a> {
self.symbols[i].1.name(self.strings).ok()
}

pub(super) fn search_object_map(&self, _addr: u64) -> Option<(&Context, u64)> {
pub(super) fn search_object_map(&self, _addr: u64) -> Option<(&Context<'_>, u64)> {
None
}
}
2 changes: 2 additions & 0 deletions src/symbolize/libbacktrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,3 +456,5 @@ pub unsafe fn resolve(what: ResolveWhat<'_>, cb: &mut dyn FnMut(&super::Symbol))
&mut syminfo_state as *mut _ as *mut _,
);
}

pub unsafe fn clear_symbol_cache() {}
2 changes: 2 additions & 0 deletions src/symbolize/miri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ impl<'a> Symbol<'a> {
))
}
}

pub unsafe fn clear_symbol_cache() {}
33 changes: 11 additions & 22 deletions src/symbolize/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ pub unsafe fn resolve_unsynchronized<F>(addr: *mut c_void, mut cb: F)
where
F: FnMut(&Symbol),
{
resolve_imp(ResolveWhat::Address(addr), &mut cb)
imp::resolve(ResolveWhat::Address(addr), &mut cb)
}

/// Same as `resolve_frame`, only unsafe as it's unsynchronized.
Expand All @@ -175,7 +175,7 @@ pub unsafe fn resolve_frame_unsynchronized<F>(frame: &Frame, mut cb: F)
where
F: FnMut(&Symbol),
{
resolve_imp(ResolveWhat::Frame(frame), &mut cb)
imp::resolve(ResolveWhat::Frame(frame), &mut cb)
}

/// A trait representing the resolution of a symbol in a file.
Expand All @@ -191,7 +191,7 @@ pub struct Symbol {
// TODO: this lifetime bound needs to be persisted eventually to `Symbol`,
// but that's currently a breaking change. For now this is safe since
// `Symbol` is only ever handed out by reference and can't be cloned.
inner: SymbolImp<'static>,
inner: imp::Symbol<'static>,
}

impl Symbol {
Expand Down Expand Up @@ -383,7 +383,7 @@ fn format_symbol_name(
cfg_if::cfg_if! {
if #[cfg(feature = "cpp_demangle")] {
impl<'a> fmt::Display for SymbolName<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Some(ref s) = self.demangled {
s.fmt(f)
} else if let Some(ref cpp) = self.cpp_demangled.0 {
Expand All @@ -409,7 +409,7 @@ cfg_if::cfg_if! {
cfg_if::cfg_if! {
if #[cfg(all(feature = "std", feature = "cpp_demangle"))] {
impl<'a> fmt::Debug for SymbolName<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use std::fmt::Write;

if let Some(ref s) = self.demangled {
Expand Down Expand Up @@ -459,21 +459,17 @@ cfg_if::cfg_if! {
pub fn clear_symbol_cache() {
let _guard = crate::lock::lock();
unsafe {
clear_symbol_cache_imp();
imp::clear_symbol_cache();
}
}

cfg_if::cfg_if! {
if #[cfg(miri)] {
mod miri;
use self::miri::resolve as resolve_imp;
use self::miri::Symbol as SymbolImp;
unsafe fn clear_symbol_cache_imp() {}
use miri as imp;
} else if #[cfg(all(windows, target_env = "msvc", not(target_vendor = "uwp")))] {
mod dbghelp;
use self::dbghelp::resolve as resolve_imp;
use self::dbghelp::Symbol as SymbolImp;
unsafe fn clear_symbol_cache_imp() {}
use dbghelp as imp;
} else if #[cfg(all(
feature = "libbacktrace",
any(unix, all(windows, not(target_vendor = "uwp"), target_env = "gnu")),
Expand All @@ -483,24 +479,17 @@ cfg_if::cfg_if! {
not(target_env = "libnx"),
))] {
mod libbacktrace;
use self::libbacktrace::resolve as resolve_imp;
use self::libbacktrace::Symbol as SymbolImp;
unsafe fn clear_symbol_cache_imp() {}
use libbacktrace as imp;
} else if #[cfg(all(
feature = "gimli-symbolize",
any(unix, windows),
not(target_vendor = "uwp"),
not(target_os = "emscripten"),
))] {
mod gimli;
use self::gimli::resolve as resolve_imp;
use self::gimli::Symbol as SymbolImp;
use self::gimli::clear_symbol_cache as clear_symbol_cache_imp;
use gimli as imp;
} else {
mod noop;
use self::noop::resolve as resolve_imp;
use self::noop::Symbol as SymbolImp;
#[allow(unused)]
unsafe fn clear_symbol_cache_imp() {}
use noop as imp;
}
}
2 changes: 2 additions & 0 deletions src/symbolize/noop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ impl Symbol<'_> {
None
}
}

pub unsafe fn clear_symbol_cache() {}

0 comments on commit af078ec

Please sign in to comment.