Skip to content

Commit

Permalink
Auto merge of #14273 - gmorenz:rustflags_arc_to_rc, r=weihanglo
Browse files Browse the repository at this point in the history
Use `Rc` instead of `Arc` for storing rustflags

# What does this PR try to resolve?

There's no reason that these reference counted pointers (which I introduced in #13900) need to be atomic, so let's use non-atomic pointers.

# Additional information

First noticed by `@weihanglo` [here](#14205 (comment)).

r? `@weihanglo`
  • Loading branch information
bors committed Jul 20, 2024
2 parents 5f6b9a9 + 22c6a7d commit 631b877
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/cargo/core/compiler/build_context/target_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ use serde::{Deserialize, Serialize};
use std::cell::RefCell;
use std::collections::hash_map::{Entry, HashMap};
use std::path::{Path, PathBuf};
use std::rc::Rc;
use std::str::{self, FromStr};
use std::sync::Arc;

/// Information about the platform target gleaned from querying rustc.
///
Expand Down Expand Up @@ -51,9 +51,9 @@ pub struct TargetInfo {
/// target libraries.
pub sysroot_target_libdir: PathBuf,
/// Extra flags to pass to `rustc`, see [`extra_args`].
pub rustflags: Arc<[String]>,
pub rustflags: Rc<[String]>,
/// Extra flags to pass to `rustdoc`, see [`extra_args`].
pub rustdocflags: Arc<[String]>,
pub rustdocflags: Rc<[String]>,
/// Whether or not rustc (stably) supports the `--check-cfg` flag.
///
/// Can be removed once the minimum supported rustc version of Cargo is
Expand Down
9 changes: 4 additions & 5 deletions src/cargo/core/compiler/unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use std::fmt;
use std::hash::{Hash, Hasher};
use std::ops::Deref;
use std::rc::Rc;
use std::sync::Arc;

use super::BuildOutput;

Expand Down Expand Up @@ -72,7 +71,7 @@ pub struct UnitInner {
///
/// [`BuildContext::extra_args_for`]: crate::core::compiler::build_context::BuildContext::extra_args_for
/// [`TargetInfo.rustflags`]: crate::core::compiler::build_context::TargetInfo::rustflags
pub rustflags: Arc<[String]>,
pub rustflags: Rc<[String]>,
/// Extra compiler flags to pass to `rustdoc` for a given unit.
///
/// Although it depends on the caller, in the current Cargo implementation,
Expand All @@ -83,7 +82,7 @@ pub struct UnitInner {
///
/// [`BuildContext::extra_args_for`]: crate::core::compiler::build_context::BuildContext::extra_args_for
/// [`TargetInfo.rustdocflags`]: crate::core::compiler::build_context::TargetInfo::rustdocflags
pub rustdocflags: Arc<[String]>,
pub rustdocflags: Rc<[String]>,
/// Build script override for the given library name.
///
/// Any package with a `links` value for the given library name will skip
Expand Down Expand Up @@ -232,8 +231,8 @@ impl UnitInterner {
kind: CompileKind,
mode: CompileMode,
features: Vec<InternedString>,
rustflags: Arc<[String]>,
rustdocflags: Arc<[String]>,
rustflags: Rc<[String]>,
rustdocflags: Rc<[String]>,
links_overrides: Rc<BTreeMap<String, BuildOutput>>,
is_std: bool,
dep_hash: u64,
Expand Down

0 comments on commit 631b877

Please sign in to comment.