forked from rust-lang/rust-clippy
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Changes: ```` Normalize custom ICE test Rustup to rust-lang/rust#64736 Use assert_crate_local for a more explicit error Rustup to rust-lang/rust#66789 account for external macro in MISSING_INLINE_IN_PUBLIC_ITEMS lint build(tests/fmt): use shared target dir chore: fix and split some ui tests on 32bit system build: set up build job for i686 targets remove needless my_lint ui test git quiet deploy: cd to out/ before adding files to git Less needless_doctest_main false positives fmt Feed the dog Use rustc_env instead of exec_env for test Make triggering this lint less likely 📎 Use exec_env to set backtrace level and normalize output Update custom ICE function with latest rustc Use Clippy version in ICE message Add custom ICE message that points to Clippy repo Fix master deployment Run update_lints Add projections check to EUV for escape analysis Use infer_ctxt Move use_self to nursery Use `println!` on success instead of `eprintln!` Revert "Disable chalk integration test. Output too large" Remove the old integration-tests.sh script Use rust implementation for integration tests in CI Rust implementation of integration test Don't error on clippy.toml of dependencies Fix categorizations Fix arguments on ExprUseVisitor::new euv moved from middle to typeck cmt_ -> Place build: check if RTIM is not installed make use of Result::map_or trigger string_lit_as_bytes when literal has escapes Remove negative float literal checks. Enable deny-warnings feature everywhere in CI Remove unused debugging feature implemented `as_conversions` lint fixing a typo [comparison_chain] rust-lang#4827 Check `core::cmp::Ord` is implemented add a good example for the approx_const lint Add suggested good cases in docs for lifetimes lint ````
- Loading branch information
1 parent
ee1aa9a
commit ab2dd0d
Showing
71 changed files
with
1,189 additions
and
347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,6 @@ regex = "1" | |
lazy_static = "1.0" | ||
shell-escape = "0.1" | ||
walkdir = "2" | ||
|
||
[features] | ||
deny-warnings = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,4 +35,4 @@ semver = "0.9.0" | |
url = { version = "2.1.0", features = ["serde"] } | ||
|
||
[features] | ||
debugging = [] | ||
deny-warnings = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use rustc::lint::{in_external_macro, EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass}; | ||
use rustc::{declare_lint_pass, declare_tool_lint}; | ||
use syntax::ast::*; | ||
|
||
use crate::utils::span_help_and_lint; | ||
|
||
declare_clippy_lint! { | ||
/// **What it does:** Checks for usage of `as` conversions. | ||
/// | ||
/// **Why is this bad?** `as` conversions will perform many kinds of | ||
/// conversions, including silently lossy conversions and dangerous coercions. | ||
/// There are cases when it makes sense to use `as`, so the lint is | ||
/// Allow by default. | ||
/// | ||
/// **Known problems:** None. | ||
/// | ||
/// **Example:** | ||
/// ```rust,ignore | ||
/// let a: u32; | ||
/// ... | ||
/// f(a as u16); | ||
/// ``` | ||
/// | ||
/// Usually better represents the semantics you expect: | ||
/// ```rust,ignore | ||
/// f(a.try_into()?); | ||
/// ``` | ||
/// or | ||
/// ```rust,ignore | ||
/// f(a.try_into().expect("Unexpected u16 overflow in f")); | ||
/// ``` | ||
/// | ||
pub AS_CONVERSIONS, | ||
restriction, | ||
"using a potentially dangerous silent `as` conversion" | ||
} | ||
|
||
declare_lint_pass!(AsConversions => [AS_CONVERSIONS]); | ||
|
||
impl EarlyLintPass for AsConversions { | ||
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) { | ||
if in_external_macro(cx.sess(), expr.span) { | ||
return; | ||
} | ||
|
||
if let ExprKind::Cast(_, _) = expr.kind { | ||
span_help_and_lint( | ||
cx, | ||
AS_CONVERSIONS, | ||
expr.span, | ||
"using a potentially dangerous silent `as` conversion", | ||
"consider using a safe wrapper for this conversion", | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.