Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #115461

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
14dd4e9
rustc_llvm: Link to `zlib` on dragonfly
Aug 1, 2023
6ef7813
rustc_llvm: Link `zlib` on cross Solaris builds
Aug 8, 2023
107cd8e
Add alignment to the NPO guarantee
scottmcm Aug 15, 2023
90f5f94
Use `OnceLock` for `SingleCache`
Zoxc Aug 31, 2023
dc37959
kmc-solid: Directly delegate to `net::is_interrupted` in `std::sys::s…
kawadakk Sep 1, 2023
eb627ea
kmc-solid: Refactor `is_interrupted` to avoid integer overflow
kawadakk Sep 1, 2023
b62eeb2
Fall through when resolving elided assoc const lifetimes
compiler-errors Sep 1, 2023
9aee1de
feat(std): Stabilize 'os_str_bytes' feature
epage Sep 1, 2023
85a1679
Create a SMIR visitor
oli-obk Sep 1, 2023
570c312
Const-stabilize `is_ascii`
scottmcm Sep 1, 2023
8198c59
Add spastorino on vacation
spastorino Sep 1, 2023
30292bb
fix(std): Rename os_str_bytes to encoded_bytes
epage Sep 2, 2023
81aaff2
Rollup merge of #114349 - inferiorhumanorgans:dragonfly-link-libz, r=…
fmease Sep 2, 2023
ad24938
Rollup merge of #114845 - scottmcm:npo-align, r=WaffleLapkin
fmease Sep 2, 2023
15854d1
Rollup merge of #115422 - Zoxc:cache-once-lock, r=cjgillot
fmease Sep 2, 2023
522bf42
Rollup merge of #115427 - solid-rs:patch/kmc-solid/is-interrupted, r=…
fmease Sep 2, 2023
dd501ed
Rollup merge of #115429 - compiler-errors:assoc-ct-lt-fallthrough, r=…
fmease Sep 2, 2023
333684d
Rollup merge of #115443 - epage:os_str, r=cuviper
fmease Sep 2, 2023
8560553
Rollup merge of #115444 - oli-obk:smir_visitor, r=spastorino
fmease Sep 2, 2023
91b2537
Rollup merge of #115449 - scottmcm:stable-const-is-ascii, r=ChrisDenton
fmease Sep 2, 2023
f869e56
Rollup merge of #115456 - spastorino:spastorino-vacation, r=spastorino
fmease Sep 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_data_structures/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ cfg_if! {
pub use std::cell::RefMut as MappedWriteGuard;
pub use std::cell::RefMut as MappedLockGuard;

pub use std::cell::OnceCell;
pub use std::cell::OnceCell as OnceLock;

use std::cell::RefCell as InnerRwLock;

Expand Down Expand Up @@ -327,7 +327,7 @@ cfg_if! {

pub use parking_lot::MappedMutexGuard as MappedLockGuard;

pub use std::sync::OnceLock as OnceCell;
pub use std::sync::OnceLock;

pub use std::sync::atomic::{AtomicBool, AtomicUsize, AtomicU32, AtomicU64};

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_borrowck as mir_borrowck;
use rustc_codegen_ssa::traits::CodegenBackend;
use rustc_data_structures::parallel;
use rustc_data_structures::steal::Steal;
use rustc_data_structures::sync::{Lrc, OnceCell, WorkerLocal};
use rustc_data_structures::sync::{Lrc, OnceLock, WorkerLocal};
use rustc_errors::PResult;
use rustc_expand::base::{ExtCtxt, LintStoreExpand};
use rustc_feature::Features;
Expand Down Expand Up @@ -689,7 +689,7 @@ pub fn create_global_ctxt<'tcx>(
lint_store: Lrc<LintStore>,
dep_graph: DepGraph,
untracked: Untracked,
gcx_cell: &'tcx OnceCell<GlobalCtxt<'tcx>>,
gcx_cell: &'tcx OnceLock<GlobalCtxt<'tcx>>,
arena: &'tcx WorkerLocal<Arena<'tcx>>,
hir_arena: &'tcx WorkerLocal<rustc_hir::Arena<'tcx>>,
) -> &'tcx GlobalCtxt<'tcx> {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_interface/src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rustc_codegen_ssa::traits::CodegenBackend;
use rustc_codegen_ssa::CodegenResults;
use rustc_data_structures::steal::Steal;
use rustc_data_structures::svh::Svh;
use rustc_data_structures::sync::{AppendOnlyIndexVec, Lrc, OnceCell, RwLock, WorkerLocal};
use rustc_data_structures::sync::{AppendOnlyIndexVec, Lrc, OnceLock, RwLock, WorkerLocal};
use rustc_hir::def_id::{StableCrateId, CRATE_DEF_ID, LOCAL_CRATE};
use rustc_hir::definitions::Definitions;
use rustc_incremental::DepGraphFuture;
Expand Down Expand Up @@ -78,7 +78,7 @@ impl<T> Default for Query<T> {

pub struct Queries<'tcx> {
compiler: &'tcx Compiler,
gcx_cell: OnceCell<GlobalCtxt<'tcx>>,
gcx_cell: OnceLock<GlobalCtxt<'tcx>>,

arena: WorkerLocal<Arena<'tcx>>,
hir_arena: WorkerLocal<rustc_hir::Arena<'tcx>>,
Expand All @@ -93,7 +93,7 @@ impl<'tcx> Queries<'tcx> {
pub fn new(compiler: &'tcx Compiler) -> Queries<'tcx> {
Queries {
compiler,
gcx_cell: OnceCell::new(),
gcx_cell: OnceLock::new(),
arena: WorkerLocal::new(|_| Arena::default()),
hir_arena: WorkerLocal::new(|_| rustc_hir::Arena::default()),
parse: Default::default(),
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_llvm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,10 @@ fn main() {
} else if target.contains("windows-gnu") {
println!("cargo:rustc-link-lib=shell32");
println!("cargo:rustc-link-lib=uuid");
} else if target.contains("haiku") || target.contains("darwin") {
} else if target.contains("haiku")
|| target.contains("darwin")
|| (is_crossed && (target.contains("dragonfly") || target.contains("solaris")))
{
println!("cargo:rustc-link-lib=z");
} else if target.contains("netbsd") {
println!("cargo:rustc-link-lib=z");
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_metadata/src/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::owned_slice::OwnedSlice;
use rustc_data_structures::svh::Svh;
use rustc_data_structures::sync::{AppendOnlyVec, AtomicBool, Lock, Lrc, OnceCell};
use rustc_data_structures::sync::{AppendOnlyVec, AtomicBool, Lock, Lrc, OnceLock};
use rustc_data_structures::unhash::UnhashMap;
use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind};
use rustc_expand::proc_macro::{AttrProcMacro, BangProcMacro, DeriveProcMacro};
Expand Down Expand Up @@ -93,7 +93,7 @@ pub(crate) struct CrateMetadata {
/// For every definition in this crate, maps its `DefPathHash` to its `DefIndex`.
def_path_hash_map: DefPathHashMapRef<'static>,
/// Likewise for ExpnHash.
expn_hash_map: OnceCell<UnhashMap<ExpnHash, ExpnIndex>>,
expn_hash_map: OnceLock<UnhashMap<ExpnHash, ExpnIndex>>,
/// Used for decoding interpret::AllocIds in a cached & thread-safe manner.
alloc_decoding_state: AllocDecodingState,
/// Caches decoded `DefKey`s.
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_middle/src/mir/basic_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::graph;
use rustc_data_structures::graph::dominators::{dominators, Dominators};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::OnceCell;
use rustc_data_structures::sync::OnceLock;
use rustc_index::{IndexSlice, IndexVec};
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
use smallvec::SmallVec;
Expand All @@ -23,11 +23,11 @@ pub type SwitchSources = FxHashMap<(BasicBlock, BasicBlock), SmallVec<[Option<u1

#[derive(Clone, Default, Debug)]
struct Cache {
predecessors: OnceCell<Predecessors>,
switch_sources: OnceCell<SwitchSources>,
is_cyclic: OnceCell<bool>,
reverse_postorder: OnceCell<Vec<BasicBlock>>,
dominators: OnceCell<Dominators<BasicBlock>>,
predecessors: OnceLock<Predecessors>,
switch_sources: OnceLock<SwitchSources>,
is_cyclic: OnceLock<bool>,
reverse_postorder: OnceLock<Vec<BasicBlock>>,
dominators: OnceLock<Dominators<BasicBlock>>,
}

impl<'tcx> BasicBlocks<'tcx> {
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_query_system/src/query/caches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::dep_graph::DepNodeIndex;

use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::sharded::{self, Sharded};
use rustc_data_structures::sync::Lock;
use rustc_data_structures::sync::OnceLock;
use rustc_index::{Idx, IndexVec};
use std::fmt::Debug;
use std::hash::Hash;
Expand Down Expand Up @@ -87,12 +87,12 @@ impl<'tcx, V: 'tcx> CacheSelector<'tcx, V> for SingleCacheSelector {
}

pub struct SingleCache<V> {
cache: Lock<Option<(V, DepNodeIndex)>>,
cache: OnceLock<(V, DepNodeIndex)>,
}

impl<V> Default for SingleCache<V> {
fn default() -> Self {
SingleCache { cache: Lock::new(None) }
SingleCache { cache: OnceLock::new() }
}
}

Expand All @@ -105,16 +105,16 @@ where

#[inline(always)]
fn lookup(&self, _key: &()) -> Option<(V, DepNodeIndex)> {
*self.cache.lock()
self.cache.get().copied()
}

#[inline]
fn complete(&self, _key: (), value: V, index: DepNodeIndex) {
*self.cache.lock() = Some((value, index));
self.cache.set((value, index)).ok();
}

fn iter(&self, f: &mut dyn FnMut(&Self::Key, &Self::Value, DepNodeIndex)) {
if let Some(value) = self.cache.lock().as_ref() {
if let Some(value) = self.cache.get() {
f(&(), &value.0, value.1)
}
}
Expand Down
63 changes: 29 additions & 34 deletions compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ enum LifetimeRibKind {

/// Resolves elided lifetimes to `'static`, but gives a warning that this behavior
/// is a bug and will be reverted soon.
AnonymousWarnToStatic(NodeId),
AnonymousWarn(NodeId),

/// Signal we cannot find which should be the anonymous lifetime.
ElisionFailure,
Expand Down Expand Up @@ -1154,7 +1154,7 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
}
LifetimeRibKind::AnonymousCreateParameter { .. }
| LifetimeRibKind::AnonymousReportError
| LifetimeRibKind::AnonymousWarnToStatic(_)
| LifetimeRibKind::AnonymousWarn(_)
| LifetimeRibKind::Elided(_)
| LifetimeRibKind::ElisionFailure
| LifetimeRibKind::ConcreteAnonConst(_)
Expand Down Expand Up @@ -1522,7 +1522,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
// lifetime would be illegal.
LifetimeRibKind::Item
| LifetimeRibKind::AnonymousReportError
| LifetimeRibKind::AnonymousWarnToStatic(_)
| LifetimeRibKind::AnonymousWarn(_)
| LifetimeRibKind::ElisionFailure => Some(LifetimeUseSet::Many),
// An anonymous lifetime is legal here, and bound to the right
// place, go ahead.
Expand Down Expand Up @@ -1585,7 +1585,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
| LifetimeRibKind::Generics { .. }
| LifetimeRibKind::ElisionFailure
| LifetimeRibKind::AnonymousReportError
| LifetimeRibKind::AnonymousWarnToStatic(_) => {}
| LifetimeRibKind::AnonymousWarn(_) => {}
}
}

Expand Down Expand Up @@ -1625,8 +1625,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
self.record_lifetime_res(lifetime.id, res, elision_candidate);
return;
}
LifetimeRibKind::AnonymousWarnToStatic(node_id) => {
self.record_lifetime_res(lifetime.id, LifetimeRes::Static, elision_candidate);
LifetimeRibKind::AnonymousWarn(node_id) => {
let msg = if elided {
"`&` without an explicit lifetime name cannot be used here"
} else {
Expand All @@ -1642,7 +1641,6 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
span: lifetime.ident.span,
},
);
return;
}
LifetimeRibKind::AnonymousReportError => {
let (msg, note) = if elided {
Expand Down Expand Up @@ -1840,7 +1838,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
// impl Foo for std::cell::Ref<u32> // note lack of '_
// async fn foo(_: std::cell::Ref<u32>) { ... }
LifetimeRibKind::AnonymousCreateParameter { report_in_path: true, .. }
| LifetimeRibKind::AnonymousWarnToStatic(_) => {
| LifetimeRibKind::AnonymousWarn(_) => {
let sess = self.r.tcx.sess;
let mut err = rustc_errors::struct_span_err!(
sess,
Expand Down Expand Up @@ -2936,33 +2934,30 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
kind: LifetimeBinderKind::ConstItem,
},
|this| {
this.with_lifetime_rib(
LifetimeRibKind::AnonymousWarnToStatic(item.id),
|this| {
// If this is a trait impl, ensure the const
// exists in trait
this.check_trait_item(
item.id,
item.ident,
&item.kind,
ValueNS,
item.span,
seen_trait_items,
|i, s, c| ConstNotMemberOfTrait(i, s, c),
);
this.with_lifetime_rib(LifetimeRibKind::AnonymousWarn(item.id), |this| {
// If this is a trait impl, ensure the const
// exists in trait
this.check_trait_item(
item.id,
item.ident,
&item.kind,
ValueNS,
item.span,
seen_trait_items,
|i, s, c| ConstNotMemberOfTrait(i, s, c),
);

this.visit_generics(generics);
this.visit_ty(ty);
if let Some(expr) = expr {
// We allow arbitrary const expressions inside of associated consts,
// even if they are potentially not const evaluatable.
//
// Type parameters can already be used and as associated consts are
// not used as part of the type system, this is far less surprising.
this.resolve_const_body(expr, None);
}
},
);
this.visit_generics(generics);
this.visit_ty(ty);
if let Some(expr) = expr {
// We allow arbitrary const expressions inside of associated consts,
// even if they are potentially not const evaluatable.
//
// Type parameters can already be used and as associated consts are
// not used as part of the type system, this is far less surprising.
this.resolve_const_body(expr, None);
}
});
},
);
}
Expand Down
18 changes: 15 additions & 3 deletions compiler/rustc_smir/src/rustc_internal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

use std::fmt::Debug;
use std::ops::Index;
use std::string::ToString;

use crate::rustc_internal;
use crate::{
Expand Down Expand Up @@ -156,10 +155,23 @@ pub fn run(tcx: TyCtxt<'_>, f: impl FnOnce()) {
}

/// A type that provides internal information but that can still be used for debug purpose.
pub type Opaque = impl Debug + ToString + Clone;
#[derive(Clone)]
pub struct Opaque(String);

impl std::fmt::Display for Opaque {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}

impl std::fmt::Debug for Opaque {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self.0)
}
}

pub(crate) fn opaque<T: Debug>(value: &T) -> Opaque {
format!("{value:?}")
Opaque(format!("{value:?}"))
}

pub struct StableMir {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_smir/src/stable_mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use crate::rustc_smir::Tables;

pub mod mir;
pub mod ty;
pub mod visitor;

/// Use String for now but we should replace it.
pub type Symbol = String;
Expand Down
Loading