Skip to content

Commit

Permalink
Use tcx.require_lang_item
Browse files Browse the repository at this point in the history
  • Loading branch information
camsteffen committed Oct 29, 2022
1 parent 1c8e658 commit 88d7150
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 18 deletions.
3 changes: 0 additions & 3 deletions compiler/rustc_error_messages/locales/en-US/monomorphize.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,3 @@ monomorphize_large_assignments =
moving {$size} bytes
.label = value moved from here
.note = The current maximum size is {$limit}, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]`
monomorphize_requires_lang_item =
requires `{$lang_item}` lang_item
11 changes: 2 additions & 9 deletions compiler/rustc_monomorphize/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ use std::iter;
use std::ops::Range;
use std::path::PathBuf;

use crate::errors::{LargeAssignmentsLint, RecursionLimit, RequiresLangItem, TypeLengthLimit};
use crate::errors::{LargeAssignmentsLint, RecursionLimit, TypeLengthLimit};

#[derive(PartialEq)]
pub enum MonoItemCollectionMode {
Expand Down Expand Up @@ -1298,14 +1298,7 @@ impl<'v> RootCollector<'_, 'v> {
return;
};

let start_def_id = match self.tcx.lang_items().require(LangItem::Start) {
Ok(s) => s,
Err(lang_item_err) => {
self.tcx
.sess
.emit_fatal(RequiresLangItem { lang_item: lang_item_err.0.name().to_string() });
}
};
let start_def_id = self.tcx.require_lang_item(LangItem::Start, None);
let main_ret_ty = self.tcx.fn_sig(main_def_id).output();

// Given that `main()` has no arguments,
Expand Down
6 changes: 0 additions & 6 deletions compiler/rustc_monomorphize/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ pub struct TypeLengthLimit {
pub type_length: usize,
}

#[derive(Diagnostic)]
#[diag(monomorphize_requires_lang_item)]
pub struct RequiresLangItem {
pub lang_item: String,
}

pub struct UnusedGenericParams {
pub span: Span,
pub param_spans: Vec<Span>,
Expand Down

0 comments on commit 88d7150

Please sign in to comment.