--- /dev/null
+use rustc::lint::*;
+use syntax::ast::*;
+use syntax::codemap::Spanned;
+use utils::{span_lint_and_sugg, snippet};
+
+
+/// **What it does:** Checks for
+/// - () being assigned to a variable
+/// - () being passed to a function
+///
+/// **Why is this bad?** It is extremely unlikely that a user intended to assign '()' to valiable. Instead,
+/// Unit is what a block evaluates to when it returns nothing. This is typically caused by a trailing
+/// unintended semicolon.
+///
+/// **Known problems:** None.
+///
+/// **Example:**
+/// * `let x = {"foo" ;}` when the user almost certainly intended `let x ={"foo"}`
+
+declare_lint! {
+ pub UNIT_EXPR,
+ Warn,
+ "unintended assignment or use of a unit typed value"
+}
+
+#[derive(Copy, Clone)]
+pub struct UnitExpr;
+
+impl LintPass for UnitExpr {
+ fn get_lints(&self) -> LintArray {
+ lint_array!(UNIT_EXPR)
+ }
+}
+
+impl EarlyLintPass for UnitExpr {
+ fn check_expr(&mut self, cx: &EarlyContext, expr: &Expr) {
+ if let ExprKind::Assign(ref left, ref right) = expr.node {
+ unimplemented!();
+ }
+ if let ExprKind::MethodCall(ref path, ref args) = expr.node {
+ unimplemented!();
+ }
+ if let ExprKind::Call(ref path, ref args) = expr.node{
+ unimplemented!();
+ }
+ }
+}
pub mod identity_op;
pub mod if_let_redundant_pattern_matching;
pub mod if_not_else;
+pub mod is_unit_expr;
pub mod infinite_iter;
pub mod items_after_statements;
pub mod large_enum_variant;
reg.register_late_lint_pass(box approx_const::Pass);
reg.register_late_lint_pass(box misc::Pass);
reg.register_early_lint_pass(box precedence::Precedence);
+ reg.register_early_lint_pass(box is_unit_expr::UnitExpr);
reg.register_early_lint_pass(box needless_continue::NeedlessContinue);
reg.register_late_lint_pass(box eta_reduction::EtaPass);
reg.register_late_lint_pass(box identity_op::IdentityOp);
panic::PANIC_PARAMS,
partialeq_ne_impl::PARTIALEQ_NE_IMPL,
precedence::PRECEDENCE,
+ is_unit_expr::UnitExpr,
print::PRINT_WITH_NEWLINE,
ptr::CMP_NULL,
ptr::MUT_FROM_REF,