Skip to content

Deny common lints by default for lib{std,extra} #7031

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

Closed
wants to merge 2 commits into from
Closed
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
26 changes: 18 additions & 8 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ ifndef DEBUG_BORROWS
RUSTFLAGS_STAGE2 += -Z no-debug-borrows
endif

# The standard libraries should be held up to a higher standard than any old
# code, make sure that these common warnings are denied by default. These can
# be overridden during development temporarily.
RUSTDENYFLAGS := -D dead-assignment -D unnecessary-allocation \
-D unreachable-code -D unused-imports -D unused-mut \
-D unused-unsafe -D unused-variable -D missing-doc \
-D non-camel-case-types
DENYFLAGS_STAGE1 := $(RUSTDENYFLAGS)
DENYFLAGS_STAGE2 := $(RUSTDENYFLAGS)

# platform-specific auto-configuration
include $(CFG_SRC_DIR)mk/platform.mk

Expand Down Expand Up @@ -242,29 +252,29 @@ $(foreach target,$(CFG_TARGET_TRIPLES),\
# Standard library variables
######################################################################

STDLIB_CRATE := $(S)src/libstd/core.rc
STDLIB_CRATE := $(S)src/libstd/std.rs
STDLIB_INPUTS := $(wildcard $(addprefix $(S)src/libstd/, \
core.rc *.rs */*.rs */*/*rs */*/*/*rs))
*.rs */*.rs */*/*rs */*/*/*rs))

######################################################################
# Extra library variables
######################################################################

EXTRALIB_CRATE := $(S)src/libextra/std.rc
EXTRALIB_CRATE := $(S)src/libextra/extra.rs
EXTRALIB_INPUTS := $(wildcard $(addprefix $(S)src/libextra/, \
std.rc *.rs */*.rs))
*.rs */*.rs))

######################################################################
# rustc crate variables
######################################################################

COMPILER_CRATE := $(S)src/librustc/rustc.rc
COMPILER_CRATE := $(S)src/librustc/rustc.rs
COMPILER_INPUTS := $(wildcard $(addprefix $(S)src/librustc/, \
rustc.rc *.rs */*.rs */*/*.rs */*/*/*.rs))
*.rs */*.rs */*/*.rs */*/*/*.rs))

LIBSYNTAX_CRATE := $(S)src/libsyntax/syntax.rc
LIBSYNTAX_CRATE := $(S)src/libsyntax/syntax.rs
LIBSYNTAX_INPUTS := $(wildcard $(addprefix $(S)src/libsyntax/, \
syntax.rc *.rs */*.rs */*/*.rs))
*.rs */*.rs */*/*.rs))

DRIVER_CRATE := $(S)src/driver/driver.rs

Expand Down
4 changes: 2 additions & 2 deletions mk/target.mk
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)): \
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
| $$(TLIB$(1)_T_$(2)_H_$(3))/
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< && touch $$@
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(DENYFLAGS_STAGE$(1)) -o $$@ $$< && touch $$@

$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_EXTRALIB_$(2)): \
$$(EXTRALIB_CRATE) $$(EXTRALIB_INPUTS) \
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)) \
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
| $$(TLIB$(1)_T_$(2)_H_$(3))/
@$$(call E, compile_and_link: $$@)
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< && touch $$@
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(DENYFLAGS_STAGE$(1)) -o $$@ $$< && touch $$@

$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(3)): \
$$(LIBSYNTAX_CRATE) $$(LIBSYNTAX_INPUTS) \
Expand Down
16 changes: 8 additions & 8 deletions mk/tools.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@
# Rules for non-core tools built with the compiler, both for target
# and host architectures

FUZZER_LIB := $(S)src/libfuzzer/fuzzer.rc
FUZZER_LIB := $(S)src/libfuzzer/fuzzer.rs
FUZZER_INPUTS := $(wildcard $(addprefix $(S)src/libfuzzer/, *.rs))

# The test runner that runs the cfail/rfail/rpass and bxench tests
COMPILETEST_CRATE := $(S)src/compiletest/compiletest.rc
COMPILETEST_INPUTS := $(wildcard $(S)src/compiletest/*rs)
COMPILETEST_CRATE := $(S)src/compiletest/compiletest.rs
COMPILETEST_INPUTS := $(wildcard $(S)src/compiletest/*.rs)

# Rustpkg, the package manager and build system
RUSTPKG_LIB := $(S)src/librustpkg/rustpkg.rc
RUSTPKG_INPUTS := $(wildcard $(S)src/librustpkg/*rs)
RUSTPKG_LIB := $(S)src/librustpkg/rustpkg.rs
RUSTPKG_INPUTS := $(wildcard $(S)src/librustpkg/*.rs)

# Rustdoc, the documentation tool
RUSTDOC_LIB := $(S)src/librustdoc/rustdoc.rc
RUSTDOC_LIB := $(S)src/librustdoc/rustdoc.rs
RUSTDOC_INPUTS := $(wildcard $(S)src/librustdoc/*.rs)

# Rusti, the JIT REPL
RUSTI_LIB := $(S)src/librusti/rusti.rc
RUSTI_LIB := $(S)src/librusti/rusti.rs
RUSTI_INPUTS := $(wildcard $(S)src/librusti/*.rs)

# Rust, the convenience tool
RUST_LIB := $(S)src/librust/rust.rc
RUST_LIB := $(S)src/librust/rust.rs
RUST_INPUTS := $(wildcard $(S)src/librust/*.rs)

# FIXME: These are only built for the host arch. Eventually we'll
Expand Down
File renamed without changes.
16 changes: 7 additions & 9 deletions src/libextra/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,13 @@ impl<T:Owned> MutexARC<T> {
*/
#[inline(always)]
pub unsafe fn access<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
unsafe {
let state = self.x.get();
// Borrowck would complain about this if the function were
// not already unsafe. See borrow_rwlock, far below.
do (&(*state).lock).lock {
check_poison(true, (*state).failed);
let _z = PoisonOnFail(&mut (*state).failed);
blk(&mut (*state).data)
}
let state = self.x.get();
// Borrowck would complain about this if the function were
// not already unsafe. See borrow_rwlock, far below.
do (&(*state).lock).lock {
check_poison(true, (*state).failed);
let _z = PoisonOnFail(&mut (*state).failed);
blk(&mut (*state).data)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libextra/c_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ mod tests {
assert!(mem as int != 0);

return c_vec_with_dtor(mem as *mut u8, n as uint,
|| unsafe { free(mem) });
|| { free(mem) });
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/libextra/std.rc → src/libextra/extra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ not required in or otherwise suitable for the core library.
#[license = "MIT/ASL2"];
#[crate_type = "lib"];

#[deny(non_camel_case_types)];
#[deny(missing_doc)];

// NOTE: remove these two attributes after the next snapshot
#[no_core]; // for stage0
#[allow(unrecognized_lint)]; // otherwise stage0 is seriously ugly
Expand All @@ -37,6 +34,7 @@ not required in or otherwise suitable for the core library.

extern mod core(name = "std", vers = "0.7-pre");

#[cfg(stage0)]
use core::{str, unstable};
use core::str::{StrSlice, OwnedStr};

Expand Down
Loading