about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-05-17 06:42:07 +0000
committerbors <bors@rust-lang.org>2023-05-17 06:42:07 +0000
commitc2ccc855e74aec03e434405eca3c247ee2432e53 (patch)
tree123b2319d3e649afa4438cc57830d30f5c87db1d /compiler/rustc_middle/src
parent6c64870fa67f0227f40f6adc25a6944e95c2959f (diff)
parent072074383627a6e5eb43c72522ae09010eb218c0 (diff)
downloadrust-c2ccc855e74aec03e434405eca3c247ee2432e53.tar.gz
rust-c2ccc855e74aec03e434405eca3c247ee2432e53.zip
Auto merge of #111671 - Dylan-DPC:rollup-1jy5r16, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #110145 (Share slice of bytes)
 - #111043 (Stabilize feature `cstr_is_empty`)
 - #111648 (Remove `LangItems::require`)
 - #111649 (Add derive for `core::marker::ConstParamTy`)
 - #111654 (Add a conversion from `&mut T` to `&mut UnsafeCell<T>`)
 - #111661 (Erase regions of type in `offset_of!`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_middle/src')
-rw-r--r--compiler/rustc_middle/src/error.rs10
-rw-r--r--compiler/rustc_middle/src/middle/lang_items.rs8
2 files changed, 11 insertions, 7 deletions
diff --git a/compiler/rustc_middle/src/error.rs b/compiler/rustc_middle/src/error.rs
index dc4aa18640f..046186d274c 100644
--- a/compiler/rustc_middle/src/error.rs
+++ b/compiler/rustc_middle/src/error.rs
@@ -1,5 +1,5 @@
 use rustc_macros::Diagnostic;
-use rustc_span::Span;
+use rustc_span::{Span, Symbol};
 
 use crate::ty::Ty;
 
@@ -74,6 +74,14 @@ pub(crate) struct StrictCoherenceNeedsNegativeCoherence {
 }
 
 #[derive(Diagnostic)]
+#[diag(middle_requires_lang_item)]
+pub(crate) struct RequiresLangItem {
+    #[primary_span]
+    pub span: Option<Span>,
+    pub name: Symbol,
+}
+
+#[derive(Diagnostic)]
 #[diag(middle_const_not_used_in_type_alias)]
 pub(super) struct ConstNotUsedTraitAlias {
     pub ct: String,
diff --git a/compiler/rustc_middle/src/middle/lang_items.rs b/compiler/rustc_middle/src/middle/lang_items.rs
index 343ea1f00f5..9a633e04ce7 100644
--- a/compiler/rustc_middle/src/middle/lang_items.rs
+++ b/compiler/rustc_middle/src/middle/lang_items.rs
@@ -18,12 +18,8 @@ impl<'tcx> TyCtxt<'tcx> {
     /// Returns the `DefId` for a given `LangItem`.
     /// If not found, fatally aborts compilation.
     pub fn require_lang_item(self, lang_item: LangItem, span: Option<Span>) -> DefId {
-        self.lang_items().require(lang_item).unwrap_or_else(|err| {
-            if let Some(span) = span {
-                self.sess.span_fatal(span, err.to_string())
-            } else {
-                self.sess.fatal(err.to_string())
-            }
+        self.lang_items().get(lang_item).unwrap_or_else(|| {
+            self.sess.emit_fatal(crate::error::RequiresLangItem { span, name: lang_item.name() });
         })
     }