diff options
| -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 { |
