about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2024-01-30 16:57:51 +0100
committerGitHub <noreply@github.com>2024-01-30 16:57:51 +0100
commitf3f14726787b492cfc511fe76725613a963fa516 (patch)
treecb9ceb49700870e95900cc8f9166effcf41d6810
parent399b81faac6d157c64940c618234b72d94554014 (diff)
parentb4efe07006773c3049fb78586fd00acff690e544 (diff)
downloadrust-f3f14726787b492cfc511fe76725613a963fa516.tar.gz
rust-f3f14726787b492cfc511fe76725613a963fa516.zip
Rollup merge of #120476 - compiler-errors:lang-items-yeet, r=Nilstrieb
Remove some unnecessary check logic for lang items in HIR typeck

Obvious bugs with `#[no_core]` do not deserve customized recovery logic, since they are bugs we do not expect users to ever encounter, and if users are experimenting with `#[no_core]`, they should really be familiar with the compiler implementation.

These error recoveries are implemented now only where issues have been reported in the past, rather than systematically validating lang items.

See https://github.com/rust-lang/compiler-team/issues/620
> In particular, one-off fixes for particular assumptions about lang items or intrinsics that introduce additional complexity into the compiler are not accepted.

r? Nilstrieb
-rw-r--r--compiler/rustc_hir_typeck/messages.ftl5
-rw-r--r--compiler/rustc_hir_typeck/src/callee.rs25
-rw-r--r--compiler/rustc_hir_typeck/src/check.rs16
-rw-r--r--compiler/rustc_hir_typeck/src/errors.rs16
-rw-r--r--compiler/rustc_hir_typeck/src/lib.rs9
-rw-r--r--compiler/rustc_hir_typeck/src/method/mod.rs21
-rw-r--r--compiler/rustc_hir_typeck/src/op.rs21
-rw-r--r--compiler/rustc_hir_typeck/src/place_op.rs30
-rw-r--r--tests/ui/lang-items/bad-add-impl.rs18
-rw-r--r--tests/ui/lang-items/bad-add-impl.stderr11
-rw-r--r--tests/ui/lang-items/fn-fn_mut-call-ill-formed.bad_item.stderr18
-rw-r--r--tests/ui/lang-items/fn-fn_mut-call-ill-formed.bad_sig.stderr18
-rw-r--r--tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_bad_item.stderr18
-rw-r--r--tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_bad_sig.stderr18
-rw-r--r--tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_mut_bad_item.stderr18
-rw-r--r--tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_mut_bad_sig.stderr18
-rw-r--r--tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_once_bad_item.stderr18
-rw-r--r--tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_once_bad_sig.stderr18
-rw-r--r--tests/ui/lang-items/fn-fn_mut-call-ill-formed.rs49
-rw-r--r--tests/ui/lang-items/issue-31076.rs17
-rw-r--r--tests/ui/lang-items/issue-31076.stderr19
-rw-r--r--tests/ui/lang-items/issue-86238.rs16
-rw-r--r--tests/ui/lang-items/issue-86238.stderr10
-rw-r--r--tests/ui/panic-handler/panic-handler-requires-panic-info.rs2
-rw-r--r--tests/ui/panic-handler/panic-handler-requires-panic-info.stderr6
-rw-r--r--tests/ui/traits/invalid_operator_trait.rs23
-rw-r--r--tests/ui/traits/invalid_operator_trait.stderr8
27 files changed, 21 insertions, 445 deletions
diff --git a/compiler/rustc_hir_typeck/messages.ftl b/compiler/rustc_hir_typeck/messages.ftl
index 4fd9391acc3..220da19a29d 100644
--- a/compiler/rustc_hir_typeck/messages.ftl
+++ b/compiler/rustc_hir_typeck/messages.ftl
@@ -96,9 +96,6 @@ hir_typeck_lossy_provenance_ptr2int =
 hir_typeck_method_call_on_unknown_raw_pointee =
     cannot call a method on a raw pointer with an unknown pointee type
 
-hir_typeck_missing_fn_lang_items = failed to find an overloaded call trait for closure call
-    .help = make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
-
 hir_typeck_missing_parentheses_in_range = can't call method `{$method_name}` on type `{$ty_str}`
 
 hir_typeck_no_associated_item = no {$item_kind} named `{$item_name}` found for {$ty_prefix} `{$ty_str}`{$trait_missing_method ->
@@ -108,8 +105,6 @@ hir_typeck_no_associated_item = no {$item_kind} named `{$item_name}` found for {
 
 hir_typeck_note_edition_guide = for more on editions, read https://doc.rust-lang.org/edition-guide
 
-hir_typeck_op_trait_generic_params = `{$method_name}` must not have any generic parameters
-
 hir_typeck_option_result_asref = use `{$def_path}::as_ref` to convert `{$expected_ty}` to `{$expr_ty}`
 hir_typeck_option_result_cloned = use `{$def_path}::cloned` to clone the value inside the `{$def_path}`
 hir_typeck_option_result_copied = use `{$def_path}::copied` to copy the value inside the `{$def_path}`
diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs
index 2d22af98375..b263c985534 100644
--- a/compiler/rustc_hir_typeck/src/callee.rs
+++ b/compiler/rustc_hir_typeck/src/callee.rs
@@ -254,28 +254,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                 adjusted_ty,
                 opt_input_type.as_ref().map(slice::from_ref),
             ) {
-                // Check for `self` receiver on the method, otherwise we can't use this as a `Fn*` trait.
-                if !self.tcx.associated_item(ok.value.def_id).fn_has_self_parameter {
-                    self.dcx().span_delayed_bug(
-                        call_expr.span,
-                        "input to overloaded call fn is not a self receiver",
-                    );
-                    return None;
-                }
-
                 let method = self.register_infer_ok_obligations(ok);
                 let mut autoref = None;
                 if borrow {
                     // Check for &self vs &mut self in the method signature. Since this is either
                     // the Fn or FnMut trait, it should be one of those.
                     let ty::Ref(region, _, mutbl) = method.sig.inputs()[0].kind() else {
-                        // The `fn`/`fn_mut` lang item is ill-formed, which should have
-                        // caused an error elsewhere.
-                        self.dcx().span_delayed_bug(
-                            call_expr.span,
-                            "input to call/call_mut is not a ref",
-                        );
-                        return None;
+                        bug!("Expected `FnMut`/`Fn` to take receiver by-ref/by-mut")
                     };
 
                     // For initial two-phase borrow
@@ -949,9 +934,11 @@ impl<'a, 'tcx> DeferredCallResolution<'tcx> {
                 );
             }
             None => {
-                // This can happen if `#![no_core]` is used and the `fn/fn_mut/fn_once`
-                // lang items are not defined (issue #86238).
-                fcx.dcx().emit_err(errors::MissingFnLangItems { span: self.call_expr.span });
+                span_bug!(
+                    self.call_expr.span,
+                    "Expected to find a suitable `Fn`/`FnMut`/`FnOnce` implementation for `{}`",
+                    self.adjusted_ty
+                )
             }
         }
     }
diff --git a/compiler/rustc_hir_typeck/src/check.rs b/compiler/rustc_hir_typeck/src/check.rs
index ec63954df34..aab78465f8c 100644
--- a/compiler/rustc_hir_typeck/src/check.rs
+++ b/compiler/rustc_hir_typeck/src/check.rs
@@ -152,26 +152,22 @@ pub(super) fn check_fn<'a, 'tcx>(
 }
 
 fn check_panic_info_fn(tcx: TyCtxt<'_>, fn_id: LocalDefId, fn_sig: ty::FnSig<'_>) {
+    let span = tcx.def_span(fn_id);
+
     let DefKind::Fn = tcx.def_kind(fn_id) else {
-        let span = tcx.def_span(fn_id);
         tcx.dcx().span_err(span, "should be a function");
         return;
     };
 
     let generic_counts = tcx.generics_of(fn_id).own_counts();
     if generic_counts.types != 0 {
-        let span = tcx.def_span(fn_id);
         tcx.dcx().span_err(span, "should have no type parameters");
     }
     if generic_counts.consts != 0 {
-        let span = tcx.def_span(fn_id);
         tcx.dcx().span_err(span, "should have no const parameters");
     }
 
-    let Some(panic_info_did) = tcx.lang_items().panic_info() else {
-        tcx.dcx().err("language item required, but not found: `panic_info`");
-        return;
-    };
+    let panic_info_did = tcx.require_lang_item(hir::LangItem::PanicInfo, Some(span));
 
     // build type `for<'a, 'b> fn(&'a PanicInfo<'b>) -> !`
     let panic_info_ty = tcx.type_of(panic_info_did).instantiate(
@@ -203,11 +199,7 @@ fn check_panic_info_fn(tcx: TyCtxt<'_>, fn_id: LocalDefId, fn_sig: ty::FnSig<'_>
 
     let _ = check_function_signature(
         tcx,
-        ObligationCause::new(
-            tcx.def_span(fn_id),
-            fn_id,
-            ObligationCauseCode::LangFunctionType(sym::panic_impl),
-        ),
+        ObligationCause::new(span, fn_id, ObligationCauseCode::LangFunctionType(sym::panic_impl)),
         fn_id.into(),
         expected_sig,
     );
diff --git a/compiler/rustc_hir_typeck/src/errors.rs b/compiler/rustc_hir_typeck/src/errors.rs
index 0695af15b16..70afb042441 100644
--- a/compiler/rustc_hir_typeck/src/errors.rs
+++ b/compiler/rustc_hir_typeck/src/errors.rs
@@ -84,14 +84,6 @@ pub struct MethodCallOnUnknownRawPointee {
 }
 
 #[derive(Diagnostic)]
-#[diag(hir_typeck_missing_fn_lang_items)]
-#[help]
-pub struct MissingFnLangItems {
-    #[primary_span]
-    pub span: Span,
-}
-
-#[derive(Diagnostic)]
 #[diag(hir_typeck_functional_record_update_on_non_struct, code = E0436)]
 pub struct FunctionalRecordUpdateOnNonStruct {
     #[primary_span]
@@ -193,14 +185,6 @@ pub struct AddMissingParenthesesInRange {
     pub right: Span,
 }
 
-#[derive(Diagnostic)]
-#[diag(hir_typeck_op_trait_generic_params)]
-pub struct OpMethodGenericParams {
-    #[primary_span]
-    pub span: Span,
-    pub method_name: String,
-}
-
 pub struct TypeMismatchFruTypo {
     /// Span of the LHS of the range
     pub expr_span: Span,
diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs
index 36aa949668f..deb3ad2edc7 100644
--- a/compiler/rustc_hir_typeck/src/lib.rs
+++ b/compiler/rustc_hir_typeck/src/lib.rs
@@ -444,15 +444,6 @@ fn fatally_break_rust(tcx: TyCtxt<'_>, span: Span) -> ! {
     diag.emit()
 }
 
-/// `expected` here is the expected number of explicit generic arguments on the trait.
-fn has_expected_num_generic_args(tcx: TyCtxt<'_>, trait_did: DefId, expected: usize) -> bool {
-    let generics = tcx.generics_of(trait_did);
-    generics.count()
-        == expected
-            + if generics.has_self { 1 } else { 0 }
-            + if generics.host_effect_index.is_some() { 1 } else { 0 }
-}
-
 pub fn provide(providers: &mut Providers) {
     method::provide(providers);
     *providers = Providers {
diff --git a/compiler/rustc_hir_typeck/src/method/mod.rs b/compiler/rustc_hir_typeck/src/method/mod.rs
index af172b59a14..804d6ff2cb5 100644
--- a/compiler/rustc_hir_typeck/src/method/mod.rs
+++ b/compiler/rustc_hir_typeck/src/method/mod.rs
@@ -10,7 +10,6 @@ mod suggest;
 pub use self::suggest::SelfSource;
 pub use self::MethodError::*;
 
-use crate::errors::OpMethodGenericParams;
 use crate::FnCtxt;
 use rustc_errors::{Applicability, Diagnostic, SubdiagnosticMessage};
 use rustc_hir as hir;
@@ -385,26 +384,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         // type parameters or early-bound regions.
         let tcx = self.tcx;
         let Some(method_item) = self.associated_value(trait_def_id, m_name) else {
-            tcx.dcx().span_delayed_bug(
-                obligation.cause.span,
-                "operator trait does not have corresponding operator method",
-            );
-            return None;
+            bug!("expected associated item for operator trait")
         };
 
-        if method_item.kind != ty::AssocKind::Fn {
-            self.dcx().span_delayed_bug(tcx.def_span(method_item.def_id), "not a method");
-            return None;
-        }
-
         let def_id = method_item.def_id;
-        let generics = tcx.generics_of(def_id);
-
-        if generics.params.len() != 0 {
-            tcx.dcx().emit_fatal(OpMethodGenericParams {
-                span: tcx.def_span(method_item.def_id),
-                method_name: m_name.to_string(),
-            });
+        if method_item.kind != ty::AssocKind::Fn {
+            span_bug!(tcx.def_span(def_id), "expected `{m_name}` to be an associated function");
         }
 
         debug!("lookup_in_trait_adjusted: method_item={:?}", method_item);
diff --git a/compiler/rustc_hir_typeck/src/op.rs b/compiler/rustc_hir_typeck/src/op.rs
index bbe6d9e9670..9ce61898561 100644
--- a/compiler/rustc_hir_typeck/src/op.rs
+++ b/compiler/rustc_hir_typeck/src/op.rs
@@ -1,7 +1,7 @@
 //! Code related to processing overloaded binary and unary operators.
 
 use super::method::MethodCallee;
-use super::{has_expected_num_generic_args, FnCtxt};
+use super::FnCtxt;
 use crate::Expectation;
 use rustc_ast as ast;
 use rustc_data_structures::packed::Pu128;
@@ -887,25 +887,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
             lhs_ty, op, opname, trait_did
         );
 
-        // Catches cases like #83893, where a lang item is declared with the
-        // wrong number of generic arguments. Should have yielded an error
-        // elsewhere by now, but we have to catch it here so that we do not
-        // index `other_tys` out of bounds (if the lang item has too many
-        // generic arguments, `other_tys` is too short).
-        if !has_expected_num_generic_args(
-            self.tcx,
-            trait_did,
-            match op {
-                // Binary ops have a generic right-hand side, unary ops don't
-                Op::Binary(..) => 1,
-                Op::Unary(..) => 0,
-            },
-        ) {
-            self.dcx()
-                .span_delayed_bug(span, "operator didn't have the right number of generic args");
-            return Err(vec![]);
-        }
-
         let opname = Ident::with_dummy_span(opname);
         let (opt_rhs_expr, opt_rhs_ty) = opt_rhs.unzip();
         let input_types = opt_rhs_ty.as_slice();
diff --git a/compiler/rustc_hir_typeck/src/place_op.rs b/compiler/rustc_hir_typeck/src/place_op.rs
index d6261763772..1eaaf30043b 100644
--- a/compiler/rustc_hir_typeck/src/place_op.rs
+++ b/compiler/rustc_hir_typeck/src/place_op.rs
@@ -1,5 +1,5 @@
 use crate::method::MethodCallee;
-use crate::{has_expected_num_generic_args, FnCtxt, PlaceOp};
+use crate::{FnCtxt, PlaceOp};
 use rustc_ast as ast;
 use rustc_errors::Applicability;
 use rustc_hir as hir;
@@ -209,20 +209,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
             return None;
         };
 
-        // If the lang item was declared incorrectly, stop here so that we don't
-        // run into an ICE (#83893). The error is reported where the lang item is
-        // declared.
-        if !has_expected_num_generic_args(
-            self.tcx,
-            imm_tr,
-            match op {
-                PlaceOp::Deref => 0,
-                PlaceOp::Index => 1,
-            },
-        ) {
-            return None;
-        }
-
         self.lookup_method_in_trait(
             self.misc(span),
             Ident::with_dummy_span(imm_op),
@@ -249,20 +235,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
             return None;
         };
 
-        // If the lang item was declared incorrectly, stop here so that we don't
-        // run into an ICE (#83893). The error is reported where the lang item is
-        // declared.
-        if !has_expected_num_generic_args(
-            self.tcx,
-            mut_tr,
-            match op {
-                PlaceOp::Deref => 0,
-                PlaceOp::Index => 1,
-            },
-        ) {
-            return None;
-        }
-
         self.lookup_method_in_trait(
             self.misc(span),
             Ident::with_dummy_span(mut_op),
diff --git a/tests/ui/lang-items/bad-add-impl.rs b/tests/ui/lang-items/bad-add-impl.rs
deleted file mode 100644
index 0c44edbe51a..00000000000
--- a/tests/ui/lang-items/bad-add-impl.rs
+++ /dev/null
@@ -1,18 +0,0 @@
-#![feature(no_core)]
-#![feature(lang_items)]
-#![no_core]
-
-#[lang = "sized"]
-trait Sized {}
-
-#[lang = "add"]
-trait Add<T> {
-    const add: u32 = 1u32;
-}
-
-impl Add<u32> for u32 {}
-
-fn main() {
-    1u32 + 1u32;
-    //~^ ERROR cannot add `u32` to `u32`
-}
diff --git a/tests/ui/lang-items/bad-add-impl.stderr b/tests/ui/lang-items/bad-add-impl.stderr
deleted file mode 100644
index c5ad9ff2a08..00000000000
--- a/tests/ui/lang-items/bad-add-impl.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0369]: cannot add `u32` to `u32`
-  --> $DIR/bad-add-impl.rs:16:10
-   |
-LL |     1u32 + 1u32;
-   |     ---- ^ ---- u32
-   |     |
-   |     u32
-
-error: aborting due to 1 previous error
-
-For more information about this error, try `rustc --explain E0369`.
diff --git a/tests/ui/lang-items/fn-fn_mut-call-ill-formed.bad_item.stderr b/tests/ui/lang-items/fn-fn_mut-call-ill-formed.bad_item.stderr
deleted file mode 100644
index ff603111e94..00000000000
--- a/tests/ui/lang-items/fn-fn_mut-call-ill-formed.bad_item.stderr
+++ /dev/null
@@ -1,18 +0,0 @@
-error: failed to find an overloaded call trait for closure call
-  --> $DIR/fn-fn_mut-call-ill-formed.rs:39:5
-   |
-LL |     a();
-   |     ^^^
-   |
-   = help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
-
-error: failed to find an overloaded call trait for closure call
-  --> $DIR/fn-fn_mut-call-ill-formed.rs:43:5
-   |
-LL |     b();
-   |     ^^^
-   |
-   = help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
-
-error: aborting due to 2 previous errors
-
diff --git a/tests/ui/lang-items/fn-fn_mut-call-ill-formed.bad_sig.stderr b/tests/ui/lang-items/fn-fn_mut-call-ill-formed.bad_sig.stderr
deleted file mode 100644
index ff603111e94..00000000000
--- a/tests/ui/lang-items/fn-fn_mut-call-ill-formed.bad_sig.stderr
+++ /dev/null
@@ -1,18 +0,0 @@
-error: failed to find an overloaded call trait for closure call
-  --> $DIR/fn-fn_mut-call-ill-formed.rs:39:5
-   |
-LL |     a();
-   |     ^^^
-   |
-   = help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
-
-error: failed to find an overloaded call trait for closure call
-  --> $DIR/fn-fn_mut-call-ill-formed.rs:43:5
-   |
-LL |     b();
-   |     ^^^
-   |
-   = help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
-
-error: aborting due to 2 previous errors
-
diff --git a/tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_bad_item.stderr b/tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_bad_item.stderr
deleted file mode 100644
index 02e33c597fe..00000000000
--- a/tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_bad_item.stderr
+++ /dev/null
@@ -1,18 +0,0 @@
-error: failed to find an overloaded call trait for closure call
-  --> $DIR/fn-fn_mut-call-ill-formed.rs:42:5
-   |
-LL |     a();
-   |     ^^^
-   |
-   = help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
-
-error: failed to find an overloaded call trait for closure call
-  --> $DIR/fn-fn_mut-call-ill-formed.rs:47:5
-   |
-LL |     b();
-   |     ^^^
-   |
-   = help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
-
-error: aborting due to 2 previous errors
-
diff --git a/tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_bad_sig.stderr b/tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_bad_sig.stderr
deleted file mode 100644
index 02e33c597fe..00000000000
--- a/tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_bad_sig.stderr
+++ /dev/null
@@ -1,18 +0,0 @@
-error: failed to find an overloaded call trait for closure call
-  --> $DIR/fn-fn_mut-call-ill-formed.rs:42:5
-   |
-LL |     a();
-   |     ^^^
-   |
-   = help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
-
-error: failed to find an overloaded call trait for closure call
-  --> $DIR/fn-fn_mut-call-ill-formed.rs:47:5
-   |
-LL |     b();
-   |     ^^^
-   |
-   = help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
-
-error: aborting due to 2 previous errors
-
diff --git a/tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_mut_bad_item.stderr b/tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_mut_bad_item.stderr
deleted file mode 100644
index 02e33c597fe..00000000000
--- a/tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_mut_bad_item.stderr
+++ /dev/null
@@ -1,18 +0,0 @@
-error: failed to find an overloaded call trait for closure call
-  --> $DIR/fn-fn_mut-call-ill-formed.rs:42:5
-   |
-LL |     a();
-   |     ^^^
-   |
-   = help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
-
-error: failed to find an overloaded call trait for closure call
-  --> $DIR/fn-fn_mut-call-ill-formed.rs:47:5
-   |
-LL |     b();
-   |     ^^^
-   |
-   = help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
-
-error: aborting due to 2 previous errors
-
diff --git a/tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_mut_bad_sig.stderr b/tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_mut_bad_sig.stderr
deleted file mode 100644
index 02e33c597fe..00000000000
--- a/tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_mut_bad_sig.stderr
+++ /dev/null
@@ -1,18 +0,0 @@
-error: failed to find an overloaded call trait for closure call
-  --> $DIR/fn-fn_mut-call-ill-formed.rs:42:5
-   |
-LL |     a();
-   |     ^^^
-   |
-   = help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
-
-error: failed to find an overloaded call trait for closure call
-  --> $DIR/fn-fn_mut-call-ill-formed.rs:47:5
-   |
-LL |     b();
-   |     ^^^
-   |
-   = help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
-
-error: aborting due to 2 previous errors
-
diff --git a/tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_once_bad_item.stderr b/tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_once_bad_item.stderr
deleted file mode 100644
index 02e33c597fe..00000000000
--- a/tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_once_bad_item.stderr
+++ /dev/null
@@ -1,18 +0,0 @@
-error: failed to find an overloaded call trait for closure call
-  --> $DIR/fn-fn_mut-call-ill-formed.rs:42:5
-   |
-LL |     a();
-   |     ^^^
-   |
-   = help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
-
-error: failed to find an overloaded call trait for closure call
-  --> $DIR/fn-fn_mut-call-ill-formed.rs:47:5
-   |
-LL |     b();
-   |     ^^^
-   |
-   = help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
-
-error: aborting due to 2 previous errors
-
diff --git a/tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_once_bad_sig.stderr b/tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_once_bad_sig.stderr
deleted file mode 100644
index 02e33c597fe..00000000000
--- a/tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_once_bad_sig.stderr
+++ /dev/null
@@ -1,18 +0,0 @@
-error: failed to find an overloaded call trait for closure call
-  --> $DIR/fn-fn_mut-call-ill-formed.rs:42:5
-   |
-LL |     a();
-   |     ^^^
-   |
-   = help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
-
-error: failed to find an overloaded call trait for closure call
-  --> $DIR/fn-fn_mut-call-ill-formed.rs:47:5
-   |
-LL |     b();
-   |     ^^^
-   |
-   = help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
-
-error: aborting due to 2 previous errors
-
diff --git a/tests/ui/lang-items/fn-fn_mut-call-ill-formed.rs b/tests/ui/lang-items/fn-fn_mut-call-ill-formed.rs
deleted file mode 100644
index 757c6538d05..00000000000
--- a/tests/ui/lang-items/fn-fn_mut-call-ill-formed.rs
+++ /dev/null
@@ -1,49 +0,0 @@
-// revisions: fn_once_bad_item fn_once_bad_sig fn_mut_bad_item fn_mut_bad_sig fn_bad_item fn_bad_sig
-
-#![feature(lang_items)]
-#![feature(no_core)]
-#![no_core]
-
-#[lang = "sized"]
-trait Sized {}
-
-#[cfg(any(fn_bad_item, fn_bad_sig))]
-#[lang = "fn"]
-trait MyFn<T> {
-    #[cfg(fn_bad_sig)]
-    fn call(i: i32) -> i32 { 0 }
-
-    #[cfg(fn_bad_item)]
-    const call: i32 = 42;
-}
-
-#[cfg(any(fn_mut_bad_item, fn_mut_bad_sig))]
-#[lang = "fn_mut"]
-trait MyFnMut<T> {
-    #[cfg(fn_mut_bad_sig)]
-    fn call_mut(i: i32) -> i32 { 0 }
-
-    #[cfg(fn_mut_bad_item)]
-    const call_mut: i32 = 42;
-}
-
-#[cfg(any(fn_once_bad_item, fn_once_bad_sig))]
-#[lang = "fn_once"]
-trait MyFnOnce<T> {
-    #[cfg(fn_once_bad_sig)]
-    fn call_once(i: i32) -> i32 { 0 }
-
-    #[cfg(fn_once_bad_item)]
-    const call_once: i32 = 42;
-}
-
-fn main() {
-    let a = || 42;
-    a();
-    //~^ ERROR failed to find an overloaded call trait for closure call
-
-    let mut i = 0;
-    let mut b = || { };
-    b();
-    //~^ ERROR failed to find an overloaded call trait for closure call
-}
diff --git a/tests/ui/lang-items/issue-31076.rs b/tests/ui/lang-items/issue-31076.rs
deleted file mode 100644
index cdb196d4ff2..00000000000
--- a/tests/ui/lang-items/issue-31076.rs
+++ /dev/null
@@ -1,17 +0,0 @@
-#![feature(no_core, lang_items)]
-#![no_core]
-
-#[lang="sized"]
-trait Sized {}
-
-#[lang="add"]
-trait Add<T> {}
-
-impl Add<i32> for i32 {}
-
-fn main() {
-    let x = 5 + 6;
-    //~^ ERROR cannot add `i32` to `{integer}`
-    let y = 5i32 + 6i32;
-    //~^ ERROR cannot add `i32` to `i32`
-}
diff --git a/tests/ui/lang-items/issue-31076.stderr b/tests/ui/lang-items/issue-31076.stderr
deleted file mode 100644
index ac0d9dc7528..00000000000
--- a/tests/ui/lang-items/issue-31076.stderr
+++ /dev/null
@@ -1,19 +0,0 @@
-error[E0369]: cannot add `i32` to `{integer}`
-  --> $DIR/issue-31076.rs:13:15
-   |
-LL |     let x = 5 + 6;
-   |             - ^ - i32
-   |             |
-   |             {integer}
-
-error[E0369]: cannot add `i32` to `i32`
-  --> $DIR/issue-31076.rs:15:18
-   |
-LL |     let y = 5i32 + 6i32;
-   |             ---- ^ ---- i32
-   |             |
-   |             i32
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0369`.
diff --git a/tests/ui/lang-items/issue-86238.rs b/tests/ui/lang-items/issue-86238.rs
deleted file mode 100644
index 509f94f3834..00000000000
--- a/tests/ui/lang-items/issue-86238.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-// Regression test for the ICE described in issue #86238.
-
-#![feature(lang_items)]
-#![feature(no_core)]
-
-#![no_core]
-fn main() {
-    let one = || {};
-    one()
-    //~^ ERROR: failed to find an overloaded call trait for closure call
-    //~| HELP: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined
-}
-#[lang = "sized"]
-trait Sized {}
-#[lang = "copy"]
-trait Copy {}
diff --git a/tests/ui/lang-items/issue-86238.stderr b/tests/ui/lang-items/issue-86238.stderr
deleted file mode 100644
index b492904bcc7..00000000000
--- a/tests/ui/lang-items/issue-86238.stderr
+++ /dev/null
@@ -1,10 +0,0 @@
-error: failed to find an overloaded call trait for closure call
-  --> $DIR/issue-86238.rs:9:5
-   |
-LL |     one()
-   |     ^^^^^
-   |
-   = help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
-
-error: aborting due to 1 previous error
-
diff --git a/tests/ui/panic-handler/panic-handler-requires-panic-info.rs b/tests/ui/panic-handler/panic-handler-requires-panic-info.rs
index f13c12fc52e..b59023b50e1 100644
--- a/tests/ui/panic-handler/panic-handler-requires-panic-info.rs
+++ b/tests/ui/panic-handler/panic-handler-requires-panic-info.rs
@@ -1,5 +1,4 @@
 // compile-flags:-C panic=abort
-// error-pattern: language item required, but not found: `panic_info`
 
 #![feature(lang_items)]
 #![feature(no_core)]
@@ -8,6 +7,7 @@
 
 #[panic_handler]
 fn panic() -> ! {
+    //~^ ERROR requires `panic_info` lang_item
     loop {}
 }
 
diff --git a/tests/ui/panic-handler/panic-handler-requires-panic-info.stderr b/tests/ui/panic-handler/panic-handler-requires-panic-info.stderr
index 06ff8e3098a..873f61a5163 100644
--- a/tests/ui/panic-handler/panic-handler-requires-panic-info.stderr
+++ b/tests/ui/panic-handler/panic-handler-requires-panic-info.stderr
@@ -1,4 +1,8 @@
-error: language item required, but not found: `panic_info`
+error: requires `panic_info` lang_item
+  --> $DIR/panic-handler-requires-panic-info.rs:9:1
+   |
+LL | fn panic() -> ! {
+   | ^^^^^^^^^^^^^^^
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/traits/invalid_operator_trait.rs b/tests/ui/traits/invalid_operator_trait.rs
deleted file mode 100644
index 7ea3b0d5bac..00000000000
--- a/tests/ui/traits/invalid_operator_trait.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-#![crate_type = "lib"]
-#![feature(lang_items)]
-#![feature(no_core)]
-#![no_core]
-
-#[lang="sized"]
-pub trait Sized {
-    // Empty.
-}
-
-#[lang = "add"]
-trait Add<RHS=Self> {
-    type Output;
-
-    fn add<Y>(self, _: RHS) -> Self::Output;
-    //~^ ERROR `add` must not have any generic parameters
-}
-
-#[allow(unreachable_code)]
-fn ice(a: usize) {
-    let r = loop {};
-    r = r + a;
-}
diff --git a/tests/ui/traits/invalid_operator_trait.stderr b/tests/ui/traits/invalid_operator_trait.stderr
deleted file mode 100644
index f2e5e9080b1..00000000000
--- a/tests/ui/traits/invalid_operator_trait.stderr
+++ /dev/null
@@ -1,8 +0,0 @@
-error: `add` must not have any generic parameters
-  --> $DIR/invalid_operator_trait.rs:15:5
-   |
-LL |     fn add<Y>(self, _: RHS) -> Self::Output;
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: aborting due to 1 previous error
-