diff options
| author | Ralf Jung <post@ralfj.de> | 2019-08-17 13:49:27 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2019-08-17 13:50:04 +0200 |
| commit | f19087dd7cdbac5f11ffc606b08c489ea730949a (patch) | |
| tree | 11ac78bd6e9dec6e065cf3f614bb14e32c369355 /src | |
| parent | 689c210b472d4469bec3fb62da7704989d8305fd (diff) | |
| download | rust-f19087dd7cdbac5f11ffc606b08c489ea730949a.tar.gz rust-f19087dd7cdbac5f11ffc606b08c489ea730949a.zip | |
drift leftward
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_lint/builtin.rs | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 3279f243622..94a16e02e20 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -1912,23 +1912,21 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue { if let hir::ExprKind::Call(ref path_expr, ref args) = expr.node { if let hir::ExprKind::Path(ref qpath) = path_expr.node { - if let Some(def_id) = cx.tables.qpath_res(qpath, path_expr.hir_id) - .opt_def_id() - { - if cx.match_def_path(def_id, &ZEROED_PATH) { + let def_id = cx.tables.qpath_res(qpath, path_expr.hir_id).opt_def_id()?; + + if cx.match_def_path(def_id, &ZEROED_PATH) { + return Some(InitKind::Zeroed); + } + if cx.match_def_path(def_id, &UININIT_PATH) { + return Some(InitKind::Uninit); + } + if cx.match_def_path(def_id, &TRANSMUTE_PATH) { + if is_zero(&args[0]) { return Some(InitKind::Zeroed); } - if cx.match_def_path(def_id, &UININIT_PATH) { - return Some(InitKind::Uninit); - } - if cx.match_def_path(def_id, &TRANSMUTE_PATH) { - if is_zero(&args[0]) { - return Some(InitKind::Zeroed); - } - } - // FIXME: Also detect `MaybeUninit::zeroed().assume_init()` and - // `MaybeUninit::uninit().assume_init()`. } + // FIXME: Also detect `MaybeUninit::zeroed().assume_init()` and + // `MaybeUninit::uninit().assume_init()`. } } |
