Skip to content

Commit 4ecef0c

Browse files
committed
Target modifiers: Small fixes & re-work to generated OptionsTargetModifiers enum
1 parent 6741a49 commit 4ecef0c

File tree

11 files changed

+182
-129
lines changed

11 files changed

+182
-129
lines changed

compiler/rustc_driver_impl/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ use rustc_metadata::locator;
5252
use rustc_middle::ty::TyCtxt;
5353
use rustc_parse::{new_parser_from_file, new_parser_from_source_str, unwrap_or_emit_fatal};
5454
use rustc_session::config::{
55-
CG_OPTIONS, ErrorOutputType, Input, OutFileName, OutputType, UnstableOptions, Z_OPTIONS,
56-
nightly_options,
55+
CG_OPTIONS, ErrorOutputType, Input, OptionsTargetModifiers, OutFileName, OutputType,
56+
UnstableOptions, Z_OPTIONS, nightly_options,
5757
};
5858
use rustc_session::getopts::{self, Matches};
5959
use rustc_session::lint::{Lint, LintId};
@@ -1165,7 +1165,7 @@ fn describe_codegen_flags() {
11651165

11661166
fn print_flag_list<T>(
11671167
cmdline_opt: &str,
1168-
flag_list: &[(&'static str, T, &'static str, &'static str, bool)],
1168+
flag_list: &[(&'static str, T, &'static str, &'static str, Option<OptionsTargetModifiers>)],
11691169
) {
11701170
let max_len =
11711171
flag_list.iter().map(|&(name, _, _, _, _)| name.chars().count()).max().unwrap_or(0);

compiler/rustc_metadata/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ metadata_incompatible_rustc =
116116
metadata_incompatible_target_modifiers =
117117
mixing `{$flag_name_prefixed}` will cause an ABI mismatch
118118
.note = `{$flag_name_prefixed}={$flag_local_value}` in this crate is incompatible with `{$flag_name_prefixed}={$flag_extern_value}` in dependency `{$extern_crate}`
119-
.help = `{$flag_name_prefixed}` modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely
119+
.help = this error occurs because the `{$flag_name_prefixed}` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely
120120
121121
metadata_incompatible_target_modifiers_help_allow = alternatively, use `-Cunsafe-allow-abi-mismatch={$flag_name}` to silence this error
122122
metadata_incompatible_target_modifiers_help_fix = set `{$flag_name_prefixed}={$flag_extern_value}` in this crate or `{$flag_name_prefixed}={$flag_local_value}` in `{$extern_crate}`

compiler/rustc_metadata/src/creader.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -301,14 +301,7 @@ impl CStore {
301301
let sess = tcx.sess;
302302
let allowed_flag_mismatches = &sess.opts.cg.unsafe_allow_abi_mismatch;
303303
let span = krate.spans.inner_span.shrink_to_lo();
304-
let tmod_extender = |tmod: &TargetModifier| {
305-
(
306-
sess.opts
307-
.target_modifier_info_by_hash(tmod.name_hash, &tmod.value_name)
308-
.expect("Target modifier not found by name hash"),
309-
tmod.clone(),
310-
)
311-
};
304+
let tmod_extender = |tmod: &TargetModifier| (tmod.extend(), tmod.clone());
312305

313306
let name = tcx.crate_name(LOCAL_CRATE);
314307
let mods = sess.opts.gather_target_modifiers();
@@ -342,7 +335,7 @@ impl CStore {
342335
left_name_val = left_name_val.or_else(|| it1.next());
343336
right_name_val = right_name_val.or_else(|| it2.next());
344337
match (&left_name_val, &right_name_val) {
345-
(Some(l), Some(r)) => match l.1.name_hash.cmp(&r.1.name_hash) {
338+
(Some(l), Some(r)) => match l.1.opt.cmp(&r.1.opt) {
346339
cmp::Ordering::Equal => {
347340
if l.0.tech_value != r.0.tech_value {
348341
report_diff(

compiler/rustc_session/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2334,7 +2334,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
23342334
let crate_types = parse_crate_types_from_list(unparsed_crate_types)
23352335
.unwrap_or_else(|e| early_dcx.early_fatal(e));
23362336

2337-
let mut target_modifiers = BTreeMap::<String, String>::new();
2337+
let mut target_modifiers = BTreeMap::<OptionsTargetModifiers, String>::new();
23382338

23392339
let mut unstable_opts = UnstableOptions::build(early_dcx, matches, &mut target_modifiers);
23402340
let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(early_dcx, matches);

compiler/rustc_session/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![feature(let_chains)]
55
#![feature(map_many_mut)]
66
#![feature(rustc_attrs)]
7+
#![recursion_limit = "256"]
78
#![warn(unreachable_pub)]
89
// tidy-alphabetical-end
910

0 commit comments

Comments
 (0)