Skip to content

Commit d683e3a

Browse files
committed
Remove rustc_session::config::Config
The wrapper type led to tons of target.target across the compiler. Its ptr_width field isn't required any more, as target_pointer_width is already present in parsed form.
1 parent 4fa5578 commit d683e3a

File tree

5 files changed

+12
-24
lines changed

5 files changed

+12
-24
lines changed

compiler/rustc_codegen_llvm/src/attributes.rs

-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ pub fn llvm_target_features(sess: &Session) -> impl Iterator<Item = &str> {
174174
.split(',')
175175
.filter(|f| !RUSTC_SPECIFIC_FEATURES.iter().any(|s| f.contains(s)));
176176
sess.target
177-
.target
178177
.options
179178
.features
180179
.split(',')

compiler/rustc_codegen_ssa/src/back/link.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_session::{filesearch, Session};
1515
use rustc_span::symbol::Symbol;
1616
use rustc_target::spec::crt_objects::{CrtObjects, CrtObjectsFallback};
1717
use rustc_target::spec::{LinkOutputKind, LinkerFlavor, LldFlavor};
18-
use rustc_target::spec::{PanicStrategy, RelocModel, RelroLevel};
18+
use rustc_target::spec::{PanicStrategy, RelocModel, RelroLevel, Target};
1919

2020
use super::archive::ArchiveBuilder;
2121
use super::command::Command;
@@ -1842,12 +1842,8 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
18421842
}
18431843

18441844
// Converts a library file-stem into a cc -l argument
1845-
fn unlib<'a>(config: &config::Config, stem: &'a str) -> &'a str {
1846-
if stem.starts_with("lib") && !config.target.options.is_like_windows {
1847-
&stem[3..]
1848-
} else {
1849-
stem
1850-
}
1845+
fn unlib<'a>(target: &Target, stem: &'a str) -> &'a str {
1846+
if stem.starts_with("lib") && !target.options.is_like_windows { &stem[3..] } else { stem }
18511847
}
18521848

18531849
// Adds the static "rlib" versions of all crates to the command line.

compiler/rustc_session/src/config.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ use std::iter::{self, FromIterator};
3434
use std::path::{Path, PathBuf};
3535
use std::str::{self, FromStr};
3636

37-
pub struct Config {
38-
pub target: Target,
39-
pub ptr_width: u32,
40-
}
41-
4237
bitflags! {
4338
#[derive(Default, Encodable, Decodable)]
4439
pub struct SanitizerSet: u8 {
@@ -831,7 +826,7 @@ pub fn build_configuration(sess: &Session, mut user_cfg: CrateConfig) -> CrateCo
831826
user_cfg
832827
}
833828

834-
pub fn build_target_config(opts: &Options, target_override: Option<Target>) -> Config {
829+
pub fn build_target_config(opts: &Options, target_override: Option<Target>) -> Target {
835830
let target_result = target_override.map_or_else(|| Target::search(&opts.target_triple), Ok);
836831
let target = target_result.unwrap_or_else(|e| {
837832
early_error(
@@ -855,9 +850,7 @@ pub fn build_target_config(opts: &Options, target_override: Option<Target>) -> C
855850
)
856851
}
857852

858-
let ptr_width = target.pointer_width;
859-
860-
Config { target, ptr_width }
853+
target
861854
}
862855

863856
#[derive(Copy, Clone, PartialEq, Eq, Debug)]

compiler/rustc_session/src/session.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl Mul<usize> for Limit {
102102
/// Represents the data associated with a compilation
103103
/// session for a single crate.
104104
pub struct Session {
105-
pub target: config::Config,
105+
pub target: Target,
106106
pub host: Target,
107107
pub opts: config::Options,
108108
pub host_tlib_path: SearchPath,
@@ -1258,7 +1258,7 @@ pub fn build_session(
12581258

12591259
let loader = file_loader.unwrap_or(Box::new(RealFileLoader));
12601260
let hash_kind = sopts.debugging_opts.src_hash_algorithm.unwrap_or_else(|| {
1261-
if target_cfg.target.options.is_like_msvc {
1261+
if target_cfg.options.is_like_msvc {
12621262
SourceFileHashAlgorithm::Sha1
12631263
} else {
12641264
SourceFileHashAlgorithm::Md5
@@ -1368,8 +1368,8 @@ pub fn build_session(
13681368
if candidate.join("library/std/src/lib.rs").is_file() { Some(candidate) } else { None }
13691369
};
13701370

1371-
let asm_arch = if target_cfg.target.options.allow_asm {
1372-
InlineAsmArch::from_str(&target_cfg.target.arch).ok()
1371+
let asm_arch = if target_cfg.options.allow_asm {
1372+
InlineAsmArch::from_str(&target_cfg.arch).ok()
13731373
} else {
13741374
None
13751375
};

src/tools/clippy/clippy_lints/src/trivially_copy_pass_by_ref.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ use rustc_hir::intravisit::FnKind;
99
use rustc_hir::{Body, FnDecl, HirId, ItemKind, MutTy, Mutability, Node};
1010
use rustc_lint::{LateContext, LateLintPass};
1111
use rustc_middle::ty;
12-
use rustc_session::config::Config as SessionConfig;
1312
use rustc_session::{declare_tool_lint, impl_lint_pass};
1413
use rustc_span::Span;
1514
use rustc_target::abi::LayoutOf;
15+
use rustc_target::spec::Target;
1616
use rustc_target::spec::abi::Abi;
1717

1818
declare_clippy_lint! {
@@ -60,9 +60,9 @@ pub struct TriviallyCopyPassByRef {
6060
}
6161

6262
impl<'tcx> TriviallyCopyPassByRef {
63-
pub fn new(limit: Option<u64>, target: &SessionConfig) -> Self {
63+
pub fn new(limit: Option<u64>, target: &Target) -> Self {
6464
let limit = limit.unwrap_or_else(|| {
65-
let bit_width = u64::from(target.ptr_width);
65+
let bit_width = u64::from(target.pointer_width);
6666
// Cap the calculated bit width at 32-bits to reduce
6767
// portability problems between 32 and 64-bit targets
6868
let bit_width = cmp::min(bit_width, 32);

0 commit comments

Comments
 (0)