diff options
| author | Ralf Jung <post@ralfj.de> | 2019-11-04 10:11:58 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2019-11-04 10:11:58 +0100 |
| commit | bb37d0078750b760f013bfa706fe19d4d823b8df (patch) | |
| tree | 3aac3e1e45518edeb7e628425b13a372928d4a92 /src | |
| parent | 7ff57edb93625857b1ac289160550859e78ef6fb (diff) | |
| download | rust-bb37d0078750b760f013bfa706fe19d4d823b8df.tar.gz rust-bb37d0078750b760f013bfa706fe19d4d823b8df.zip | |
more robust method checking through DefId and diagnostic_item
Diffstat (limited to 'src')
| -rw-r--r-- | src/libcore/mem/maybe_uninit.rs | 1 | ||||
| -rw-r--r-- | src/librustc_lint/builtin.rs | 5 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/libcore/mem/maybe_uninit.rs b/src/libcore/mem/maybe_uninit.rs index 792ce9dfad4..339a94c2180 100644 --- a/src/libcore/mem/maybe_uninit.rs +++ b/src/libcore/mem/maybe_uninit.rs @@ -440,6 +440,7 @@ impl<T> MaybeUninit<T> { /// ``` #[stable(feature = "maybe_uninit", since = "1.36.0")] #[inline(always)] + #[cfg_attr(all(not(bootstrap)), rustc_diagnostic_item = "assume_init")] pub unsafe fn assume_init(self) -> T { intrinsics::panic_if_uninhabited::<T>(); ManuallyDrop::into_inner(self.value) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 7f7db46466f..e38ecd88283 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -1933,9 +1933,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue { } } } - } else if let hir::ExprKind::MethodCall(ref path, _, ref args) = expr.kind { + } else if let hir::ExprKind::MethodCall(_, _, ref args) = expr.kind { // Find problematic calls to `MaybeUninit::assume_init`. - if path.ident.name == sym::assume_init { + let def_id = cx.tables.type_dependent_def_id(expr.hir_id)?; + if cx.tcx.is_diagnostic_item(sym::assume_init, def_id) { // This is a call to *some* method named `assume_init`. // See if the `self` parameter is one of the dangerous constructors. if let hir::ExprKind::Call(ref path_expr, _) = args[0].kind { |
