-use crate::rustc::hir::{Expr, ExprKind};
-use crate::rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
-use crate::rustc::{declare_tool_lint, lint_array};
-use crate::syntax::ast::LitKind;
-use crate::syntax::source_map::{Span, Spanned};
use crate::utils::{match_type, paths, span_lint, walk_ptrs_ty};
+use rustc::hir::{Expr, ExprKind};
+use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
+use rustc::{declare_tool_lint, lint_array};
+use syntax::ast::LitKind;
+use syntax::source_map::{Span, Spanned};
-/// **What it does:** Checks for duplicate open options as well as combinations
-/// that make no sense.
-///
-/// **Why is this bad?** In the best case, the code will be harder to read than
-/// necessary. I don't know the worst case.
-///
-/// **Known problems:** None.
-///
-/// **Example:**
-/// ```rust
-/// OpenOptions::new().read(true).truncate(true)
-/// ```
declare_clippy_lint! {
+ /// **What it does:** Checks for duplicate open options as well as combinations
+ /// that make no sense.
+ ///
+ /// **Why is this bad?** In the best case, the code will be harder to read than
+ /// necessary. I don't know the worst case.
+ ///
+ /// **Known problems:** None.
+ ///
+ /// **Example:**
+ /// ```rust
+ /// use std::fs::OpenOptions;
+ ///
+ /// OpenOptions::new().read(true).truncate(true);
+ /// ```
pub NONSENSICAL_OPEN_OPTIONS,
correctness,
"nonsensical combination of options for opening a file"
fn get_lints(&self) -> LintArray {
lint_array!(NONSENSICAL_OPEN_OPTIONS)
}
+
+ fn name(&self) -> &'static str {
+ "OpenOptions"
+ }
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSensical {
if let Spanned {
node: LitKind::Bool(lit),
..
- } = **span
+ } = *span
{
if lit {
Argument::True
}
if read && truncate && read_arg && truncate_arg && !(write && write_arg) {
- span_lint(cx, NONSENSICAL_OPEN_OPTIONS, span, "file opened with \"truncate\" and \"read\"");
+ span_lint(
+ cx,
+ NONSENSICAL_OPEN_OPTIONS,
+ span,
+ "file opened with \"truncate\" and \"read\"",
+ );
}
if append && truncate && append_arg && truncate_arg {
span_lint(