Skip to content

Commit af078ec

Browse files
authored
Deny warnings on CI to keep codebase warning-free (#394)
* 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
1 parent e7cbd9b commit af078ec

File tree

13 files changed

+41
-32
lines changed

13 files changed

+41
-32
lines changed

.github/workflows/main.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ jobs:
5252
- name: Install Rust (rustup)
5353
run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }}
5454
shell: bash
55+
- run: echo RUSTFLAGS=-Dwarnings >> $GITHUB_ENV
56+
shell: bash
5557
# full fidelity of backtraces on 32-bit msvc requires frame pointers, so
5658
# enable that for our tests
5759
- name: Force frame pointers
58-
run: echo RUSTFLAGS=-Cforce-frame-pointers >> $GITHUB_ENV
60+
run: echo RUSTFLAGS="-Cforce-frame-pointers $RUSTFLAGS" >> $GITHUB_ENV
5961
shell: bash
6062
if: matrix.thing == 'windows-msvc32'
6163
- run: cargo build --manifest-path crates/backtrace-sys/Cargo.toml
@@ -99,6 +101,8 @@ jobs:
99101
- name: Install Rust
100102
run: rustup update stable --no-self-update && rustup default stable
101103
shell: bash
104+
- run: echo RUSTFLAGS=-Dwarnings >> $GITHUB_ENV
105+
shell: bash
102106
- run: rustup target add aarch64-pc-windows-msvc
103107
- run: cargo test --no-run --target aarch64-pc-windows-msvc
104108
- run: cargo test --no-run --target aarch64-pc-windows-msvc --features verify-winapi
@@ -122,6 +126,7 @@ jobs:
122126
submodules: true
123127
- run: rustup target add ${{ matrix.target }}
124128
- run: |
129+
export RUSTFLAGS=-Dwarnings
125130
export SDK_PATH=`xcrun --show-sdk-path --sdk ${{ matrix.sdk }}`
126131
export RUSTFLAGS="-C link-arg=-isysroot -C link-arg=$SDK_PATH"
127132
cargo test --no-run --target ${{ matrix.target }}
@@ -156,6 +161,8 @@ jobs:
156161
run: rustup update stable && rustup default stable
157162
- run: rustup target add ${{ matrix.target }}
158163
- run: cargo generate-lockfile
164+
- run: echo RUSTFLAGS=-Dwarnings >> $GITHUB_ENV
165+
shell: bash
159166
- run: ./ci/run-docker.sh ${{ matrix.target }}
160167

161168
rustfmt:
@@ -182,6 +189,8 @@ jobs:
182189
- name: Install Rust
183190
run: rustup update nightly && rustup default nightly
184191
- run: rustup target add ${{ matrix.target }}
192+
- run: echo RUSTFLAGS=-Dwarnings >> $GITHUB_ENV
193+
shell: bash
185194
- run: cargo build --target ${{ matrix.target }}
186195

187196
msrv:

ci/run-docker.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ run() {
1818
--volume `pwd`/target:/checkout/target \
1919
--workdir /checkout \
2020
--privileged \
21+
--env RUSTFLAGS \
2122
backtrace \
2223
bash \
2324
-c 'PATH=$PATH:/rust/bin exec ci/run.sh'

crates/cpp_smoke_test/tests/smoke.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ extern "C" {
99

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

crates/dylib-dep/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(improper_ctypes_definitions)]
2+
13
type Pos = (&'static str, u32);
24

35
macro_rules! pos {

src/backtrace/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ cfg_if::cfg_if! {
152152
mod dbghelp;
153153
use self::dbghelp::trace as trace_imp;
154154
pub(crate) use self::dbghelp::Frame as FrameImp;
155+
#[cfg(target_env = "msvc")] // only used in dbghelp symbolize
155156
pub(crate) use self::dbghelp::StackFrame;
156157
} else {
157158
mod noop;

src/capture.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -472,12 +472,10 @@ mod rustc_serialize_impls {
472472

473473
#[cfg(feature = "serde")]
474474
mod serde_impls {
475-
extern crate serde;
476-
477-
use self::serde::de::Deserializer;
478-
use self::serde::ser::Serializer;
479-
use self::serde::{Deserialize, Serialize};
480475
use super::*;
476+
use serde::de::Deserializer;
477+
use serde::ser::Serializer;
478+
use serde::{Deserialize, Serialize};
481479

482480
#[derive(Serialize, Deserialize)]
483481
struct SerializedFrame {

src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,15 @@
5252
// When we're building as part of libstd, silence all warnings since they're
5353
// irrelevant as this crate is developed out-of-tree.
5454
#![cfg_attr(backtrace_in_libstd, allow(warnings))]
55+
#![cfg_attr(not(feature = "std"), allow(dead_code))]
5556

5657
#[cfg(feature = "std")]
5758
#[macro_use]
5859
extern crate std;
5960

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

6466
pub use self::backtrace::{trace_unsynchronized, Frame};

src/symbolize/dbghelp.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,5 @@ unsafe fn cache(filename: Option<*const [u16]>) -> Option<::std::ffi::OsString>
214214

215215
#[cfg(not(feature = "std"))]
216216
unsafe fn cache(_filename: Option<*const [u16]>) {}
217+
218+
pub unsafe fn clear_symbol_cache() {}

src/symbolize/gimli/coff.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl<'a> Object<'a> {
101101
self.symbols[i].1.name(self.strings).ok()
102102
}
103103

104-
pub(super) fn search_object_map(&self, _addr: u64) -> Option<(&Context, u64)> {
104+
pub(super) fn search_object_map(&self, _addr: u64) -> Option<(&Context<'_>, u64)> {
105105
None
106106
}
107107
}

src/symbolize/libbacktrace.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,3 +456,5 @@ pub unsafe fn resolve(what: ResolveWhat<'_>, cb: &mut dyn FnMut(&super::Symbol))
456456
&mut syminfo_state as *mut _ as *mut _,
457457
);
458458
}
459+
460+
pub unsafe fn clear_symbol_cache() {}

src/symbolize/miri.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,5 @@ impl<'a> Symbol<'a> {
5252
))
5353
}
5454
}
55+
56+
pub unsafe fn clear_symbol_cache() {}

src/symbolize/mod.rs

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ pub unsafe fn resolve_unsynchronized<F>(addr: *mut c_void, mut cb: F)
159159
where
160160
F: FnMut(&Symbol),
161161
{
162-
resolve_imp(ResolveWhat::Address(addr), &mut cb)
162+
imp::resolve(ResolveWhat::Address(addr), &mut cb)
163163
}
164164

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

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

197197
impl Symbol {
@@ -383,7 +383,7 @@ fn format_symbol_name(
383383
cfg_if::cfg_if! {
384384
if #[cfg(feature = "cpp_demangle")] {
385385
impl<'a> fmt::Display for SymbolName<'a> {
386-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
386+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
387387
if let Some(ref s) = self.demangled {
388388
s.fmt(f)
389389
} else if let Some(ref cpp) = self.cpp_demangled.0 {
@@ -409,7 +409,7 @@ cfg_if::cfg_if! {
409409
cfg_if::cfg_if! {
410410
if #[cfg(all(feature = "std", feature = "cpp_demangle"))] {
411411
impl<'a> fmt::Debug for SymbolName<'a> {
412-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
412+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
413413
use std::fmt::Write;
414414

415415
if let Some(ref s) = self.demangled {
@@ -459,21 +459,17 @@ cfg_if::cfg_if! {
459459
pub fn clear_symbol_cache() {
460460
let _guard = crate::lock::lock();
461461
unsafe {
462-
clear_symbol_cache_imp();
462+
imp::clear_symbol_cache();
463463
}
464464
}
465465

466466
cfg_if::cfg_if! {
467467
if #[cfg(miri)] {
468468
mod miri;
469-
use self::miri::resolve as resolve_imp;
470-
use self::miri::Symbol as SymbolImp;
471-
unsafe fn clear_symbol_cache_imp() {}
469+
use miri as imp;
472470
} else if #[cfg(all(windows, target_env = "msvc", not(target_vendor = "uwp")))] {
473471
mod dbghelp;
474-
use self::dbghelp::resolve as resolve_imp;
475-
use self::dbghelp::Symbol as SymbolImp;
476-
unsafe fn clear_symbol_cache_imp() {}
472+
use dbghelp as imp;
477473
} else if #[cfg(all(
478474
feature = "libbacktrace",
479475
any(unix, all(windows, not(target_vendor = "uwp"), target_env = "gnu")),
@@ -483,24 +479,17 @@ cfg_if::cfg_if! {
483479
not(target_env = "libnx"),
484480
))] {
485481
mod libbacktrace;
486-
use self::libbacktrace::resolve as resolve_imp;
487-
use self::libbacktrace::Symbol as SymbolImp;
488-
unsafe fn clear_symbol_cache_imp() {}
482+
use libbacktrace as imp;
489483
} else if #[cfg(all(
490484
feature = "gimli-symbolize",
491485
any(unix, windows),
492486
not(target_vendor = "uwp"),
493487
not(target_os = "emscripten"),
494488
))] {
495489
mod gimli;
496-
use self::gimli::resolve as resolve_imp;
497-
use self::gimli::Symbol as SymbolImp;
498-
use self::gimli::clear_symbol_cache as clear_symbol_cache_imp;
490+
use gimli as imp;
499491
} else {
500492
mod noop;
501-
use self::noop::resolve as resolve_imp;
502-
use self::noop::Symbol as SymbolImp;
503-
#[allow(unused)]
504-
unsafe fn clear_symbol_cache_imp() {}
493+
use noop as imp;
505494
}
506495
}

src/symbolize/noop.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,5 @@ impl Symbol<'_> {
3737
None
3838
}
3939
}
40+
41+
pub unsafe fn clear_symbol_cache() {}

0 commit comments

Comments
 (0)