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 5 pull requests #130483

Merged
merged 79 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
13e36cf
add new_cyclic_in for rc
Aug 28, 2024
21cb847
fix fmt
Aug 29, 2024
4abb8e2
fix new_cyclic_in for rc
Aug 29, 2024
2383cc9
improve comments
Aug 29, 2024
68169d3
add new_cyclic_in for Arc
Aug 29, 2024
97df334
remove the Clone requirement
Sep 6, 2024
550e55f
Remove duplicate impl
Sep 6, 2024
4db9c01
Renamed variable and fixed comments referring to renamed FileDescriptor
DeSevilla Sep 7, 2024
ff28977
detect when pthread_rwlock_t is moved
Mandragorian Sep 9, 2024
1185eb0
ci: bump actions/checkout to v4
trivikr Sep 9, 2024
d4eeb31
use fd_num for file descriptors, so we can use fd for file description
RalfJung Sep 9, 2024
e6604ea
Auto merge of #3867 - DeSevilla:rename-fd, r=RalfJung
bors Sep 9, 2024
797ddd2
Auto merge of #3872 - trivikr:actions-checkout-v4, r=RalfJung
bors Sep 9, 2024
0aa3fd4
Auto merge of #3871 - Mandragorian:detect_rwlock_move, r=RalfJung
bors Sep 9, 2024
51dbed2
sync methods: pass around places, not pointer-typed operands
RalfJung Sep 9, 2024
218057c
sync: store extra sync primitive data in a Box<dyn Any> so the type c…
RalfJung Sep 9, 2024
0225309
Auto merge of #3874 - RalfJung:sync, r=RalfJung
bors Sep 9, 2024
0d12c58
Preparing for merge from rustc
RalfJung Sep 10, 2024
c78cd65
Merge from rustc
RalfJung Sep 10, 2024
6e70bd4
fmt
RalfJung Sep 10, 2024
79d4cc9
Auto merge of #3876 - RalfJung:rustup, r=RalfJung
bors Sep 10, 2024
4712e57
Preparing for merge from rustc
Sep 11, 2024
19fa141
Merge from rustc
Sep 11, 2024
7e6ce60
also allow illumos to use mmap for its stack guard
RalfJung Sep 11, 2024
59835ae
Auto merge of #3878 - rust-lang:rustup-2024-09-11, r=RalfJung
bors Sep 11, 2024
2f09cac
Preparing for merge from rustc
Sep 12, 2024
93ef7cd
Merge from rustc
Sep 12, 2024
5fc0865
Auto merge of #3879 - rust-lang:rustup-2024-09-12, r=RalfJung
bors Sep 12, 2024
157dd83
Remove an unused piece of logic
oli-obk Sep 8, 2024
e4d0ae9
add non-portable linux pthread initializers to layout sanity check
RalfJung Sep 12, 2024
b7c7a45
enable all pthread tests on Solarish
RalfJung Sep 12, 2024
9621058
Auto merge of #3880 - RalfJung:sync, r=RalfJung
bors Sep 12, 2024
dd01ee7
smoke-test './miri run --dep'
RalfJung Sep 13, 2024
d5ad772
Auto merge of #3883 - RalfJung:miri-run-dep, r=RalfJung
bors Sep 13, 2024
03f14f0
./miri run: directly run binary instead of using 'cargo run'
RalfJung Sep 13, 2024
20862e4
Auto merge of #3881 - RalfJung:miri-run, r=RalfJung
bors Sep 13, 2024
9bab91f
Preparing for merge from rustc
Sep 14, 2024
94d4991
Merge from rustc
Sep 14, 2024
583f358
Auto merge of #3885 - rust-lang:rustup-2024-09-14, r=RalfJung
bors Sep 14, 2024
b6dea9e
detect when pthread_cond_t is moved
Mandragorian Sep 13, 2024
8c4f055
Auto merge of #3884 - Mandragorian:detect_cond_move, r=RalfJung
bors Sep 14, 2024
efdc01b
unix/sync: cleanup
RalfJung Sep 15, 2024
4000027
pthread: add FreeBSD, remove PTHREAD_MUTEX_NORMAL_FLAG hack
RalfJung Sep 15, 2024
2cdf5f7
move two tests to a better location
RalfJung Sep 15, 2024
2ed9188
enable std::sync tests on Solarish
RalfJung Sep 15, 2024
75921d2
Auto merge of #3886 - RalfJung:freebsd-pthread, r=RalfJung
bors Sep 15, 2024
cb445d0
make pthread-threadname nicer with cfg-if
RalfJung Sep 15, 2024
8ee38bf
add Android pthread support
RalfJung Sep 15, 2024
f394c6c
test std::time APIs on FreeBSD and Solarish
RalfJung Sep 15, 2024
5f3bec4
we can test more things on Solarish, and update its status in the README
RalfJung Sep 15, 2024
7d8ee71
Auto merge of #3889 - RalfJung:android-pthread, r=RalfJung
bors Sep 15, 2024
ffcaa7f
Preparing for merge from rustc
Sep 16, 2024
4d824fd
Merge from rustc
Sep 16, 2024
1692d12
fmt
Sep 16, 2024
5b8a18f
fix clippy lints
RalfJung Sep 16, 2024
a0f57d8
Auto merge of #3892 - rust-lang:rustup-2024-09-16, r=RalfJung
bors Sep 16, 2024
9f9f198
Bump ui test
oli-obk Sep 7, 2024
987702f
Refator DependencyBuilder construction
oli-obk Sep 16, 2024
4dabcc3
Fix run --dep
oli-obk Sep 16, 2024
e04dc62
Automatically add/remove labesl when github review (requests) are used
oli-obk Sep 16, 2024
1b25298
Update Trusty target maintainers
randomPoison Sep 16, 2024
472fef6
Revert "Rollup merge of #129749 - krasimirgg:llvm-20-lto, r=nikic"
tmandry Sep 17, 2024
6750f04
Update library/alloc/src/sync.rs
matthewpipie Sep 17, 2024
540b4da
Preparing for merge from rustc
Sep 17, 2024
48440b1
Merge from rustc
Sep 17, 2024
c5f5cfc
fmt
Sep 17, 2024
f6ae3cb
Auto merge of #3866 - rust-lang:ui_test_26_1, r=oli-obk
bors Sep 17, 2024
9c3a392
Auto merge of #3893 - rust-lang:autolabel, r=RalfJung
bors Sep 17, 2024
d0f4a52
Auto merge of #3894 - rust-lang:rustup-2024-09-17, r=RalfJung
bors Sep 17, 2024
143710f
Tokio ICE fix: Changed the type of EpollEventInterest::epfd from i32 …
tiif Sep 17, 2024
b880024
Auto merge of #3891 - tiif:tokiotest, r=RalfJung
bors Sep 17, 2024
ba86cf8
update lockfile
RalfJung Sep 17, 2024
0a25324
Add test for fluent diagnostics
Xiretza Aug 23, 2024
5b3bde9
fluent_macro: fix diagnostics for fluent parse failures
Xiretza Aug 19, 2024
8b36ecb
Rollup merge of #129477 - Xiretza:fix-fluent-diagnostics, r=compiler-…
matthiaskrgr Sep 17, 2024
f6fd305
Rollup merge of #129674 - matthewpipie:rc-arc-new-cyclic-in, r=dtolnay
matthiaskrgr Sep 17, 2024
084e93a
Rollup merge of #130452 - randomPoison:trusty-update-maintainers, r=e…
matthiaskrgr Sep 17, 2024
9087312
Rollup merge of #130467 - RalfJung:miri-sync, r=RalfJung
matthiaskrgr Sep 17, 2024
f8090dd
Rollup merge of #130477 - tmandry:revert-llvm-20-lto, r=tmandry
matthiaskrgr Sep 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
58 changes: 13 additions & 45 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,6 @@ dependencies = [
"unicode-width",
]

[[package]]
name = "ansi_term"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi",
]

[[package]]
name = "anstream"
version = "0.6.15"
Expand Down Expand Up @@ -714,7 +705,7 @@ dependencies = [
"miow",
"miropt-test-tools",
"regex",
"rustfix 0.8.1",
"rustfix",
"serde",
"serde_json",
"tracing",
Expand Down Expand Up @@ -2278,7 +2269,7 @@ dependencies = [
"rustc_version",
"smallvec",
"tempfile",
"ui_test 0.21.2",
"ui_test 0.26.5",
"windows-sys 0.52.0",
]

Expand Down Expand Up @@ -2807,16 +2798,6 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"

[[package]]
name = "prettydiff"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ff1fec61082821f8236cf6c0c14e8172b62ce8a72a0eedc30d3b247bb68dc11"
dependencies = [
"ansi_term",
"pad",
]

[[package]]
name = "prettydiff"
version = "0.7.0"
Expand Down Expand Up @@ -4625,18 +4606,6 @@ dependencies = [
"rustdoc",
]

[[package]]
name = "rustfix"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecd2853d9e26988467753bd9912c3a126f642d05d229a4b53f5752ee36c56481"
dependencies = [
"anyhow",
"log",
"serde",
"serde_json",
]

[[package]]
name = "rustfix"
version = "0.8.1"
Expand Down Expand Up @@ -5518,36 +5487,36 @@ checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9"

[[package]]
name = "ui_test"
version = "0.21.2"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aaf4bf7c184b8dfc7a4d3b90df789b1eb992ee42811cd115f32a7a1eb781058d"
checksum = "f7e4f339f62edc873975c47115f9e71c5454ddaa37c1142b42fc0b2672c8dacb"
dependencies = [
"annotate-snippets 0.9.2",
"annotate-snippets 0.11.4",
"anyhow",
"bstr",
"cargo-platform",
"cargo_metadata 0.15.4",
"cargo_metadata 0.18.1",
"color-eyre",
"colored",
"comma",
"crossbeam-channel",
"indicatif",
"lazy_static",
"levenshtein",
"prettydiff 0.6.4",
"prettydiff",
"regex",
"rustc_version",
"rustfix 0.6.1",
"rustfix",
"serde",
"serde_json",
"tempfile",
"spanned",
]

[[package]]
name = "ui_test"
version = "0.25.0"
version = "0.26.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7e4f339f62edc873975c47115f9e71c5454ddaa37c1142b42fc0b2672c8dacb"
checksum = "32ee4c40e5a5f9fa6864ff976473e5d6a6e9884b6ce68b40690d9f87e1994c83"
dependencies = [
"annotate-snippets 0.11.4",
"anyhow",
Expand All @@ -5559,12 +5528,11 @@ dependencies = [
"comma",
"crossbeam-channel",
"indicatif",
"lazy_static",
"levenshtein",
"prettydiff 0.7.0",
"prettydiff",
"regex",
"rustc_version",
"rustfix 0.8.1",
"rustfix",
"serde",
"serde_json",
"spanned",
Expand Down
17 changes: 0 additions & 17 deletions compiler/rustc_fluent_macro/src/fluent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,25 +138,8 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok
// with a lowercase as rustc errors do.
err.replace_range(0..1, &err.chars().next().unwrap().to_lowercase().to_string());

let line_starts: Vec<usize> = std::iter::once(0)
.chain(
this.source()
.char_indices()
.filter_map(|(i, c)| Some(i + 1).filter(|_| c == '\n')),
)
.collect();
let line_start = line_starts
.iter()
.enumerate()
.map(|(line, idx)| (line + 1, idx))
.filter(|(_, idx)| **idx <= pos.start)
.last()
.unwrap()
.0;

let message = annotate_snippets::Level::Error.title(&err).snippet(
Snippet::source(this.source())
.line_start(line_start)
.origin(&relative_ftl_path)
.fold(true)
.annotation(annotate_snippets::Level::Error.span(pos.start..pos.end - 1)),
Expand Down
10 changes: 3 additions & 7 deletions compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1211,11 +1211,7 @@ struct LLVMRustThinLTOData {
// Not 100% sure what these are, but they impact what's internalized and
// what's inlined across modules, I believe.
#if LLVM_VERSION_GE(18, 0)
#if LLVM_VERSION_GE(20, 0)
FunctionImporter::ImportListsTy ImportLists;
#else
DenseMap<StringRef, FunctionImporter::ImportMapTy> ImportLists;
#endif
DenseMap<StringRef, FunctionImporter::ExportSetTy> ExportLists;
DenseMap<StringRef, GVSummaryMapTy> ModuleToDefinedGVSummaries;
#else
Expand Down Expand Up @@ -1424,13 +1420,13 @@ LLVMRustPrepareThinLTOInternalize(const LLVMRustThinLTOData *Data,
return true;
}

extern "C" bool LLVMRustPrepareThinLTOImport(LLVMRustThinLTOData *Data,
extern "C" bool LLVMRustPrepareThinLTOImport(const LLVMRustThinLTOData *Data,
LLVMModuleRef M,
LLVMTargetMachineRef TM) {
Module &Mod = *unwrap(M);
TargetMachine &Target = *unwrap(TM);

const auto &ImportList = Data->ImportLists[Mod.getModuleIdentifier()];
const auto &ImportList = Data->ImportLists.lookup(Mod.getModuleIdentifier());
auto Loader = [&](StringRef Identifier) {
const auto &Memory = Data->ModuleMap.lookup(Identifier);
auto &Context = Mod.getContext();
Expand Down Expand Up @@ -1613,7 +1609,7 @@ extern "C" void LLVMRustComputeLTOCacheKey(RustStringRef KeyOut,
LLVMRustThinLTOData *Data) {
SmallString<40> Key;
llvm::lto::Config conf;
const auto &ImportList = Data->ImportLists[ModId];
const auto &ImportList = Data->ImportLists.lookup(ModId);
const auto &ExportList = Data->ExportLists.lookup(ModId);
const auto &ResolvedODR = Data->ResolvedODR.lookup(ModId);
const auto &DefinedGlobals = Data->ModuleToDefinedGVSummaries.lookup(ModId);
Expand Down
115 changes: 79 additions & 36 deletions library/alloc/src/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,42 +460,7 @@ impl<T> Rc<T> {
where
F: FnOnce(&Weak<T>) -> T,
{
// Construct the inner in the "uninitialized" state with a single
// weak reference.
let uninit_ptr: NonNull<_> = Box::leak(Box::new(RcBox {
strong: Cell::new(0),
weak: Cell::new(1),
value: mem::MaybeUninit::<T>::uninit(),
}))
.into();

let init_ptr: NonNull<RcBox<T>> = uninit_ptr.cast();

let weak = Weak { ptr: init_ptr, alloc: Global };

// It's important we don't give up ownership of the weak pointer, or
// else the memory might be freed by the time `data_fn` returns. If
// we really wanted to pass ownership, we could create an additional
// weak pointer for ourselves, but this would result in additional
// updates to the weak reference count which might not be necessary
// otherwise.
let data = data_fn(&weak);

let strong = unsafe {
let inner = init_ptr.as_ptr();
ptr::write(ptr::addr_of_mut!((*inner).value), data);

let prev_value = (*inner).strong.get();
debug_assert_eq!(prev_value, 0, "No prior strong references should exist");
(*inner).strong.set(1);

Rc::from_inner(init_ptr)
};

// Strong references should collectively own a shared weak reference,
// so don't run the destructor for our old weak reference.
mem::forget(weak);
strong
Self::new_cyclic_in(data_fn, Global)
}

/// Constructs a new `Rc` with uninitialized contents.
Expand Down Expand Up @@ -762,6 +727,84 @@ impl<T, A: Allocator> Rc<T, A> {
}
}

/// Constructs a new `Rc<T, A>` in the given allocator while giving you a `Weak<T, A>` to the allocation,
/// to allow you to construct a `T` which holds a weak pointer to itself.
///
/// Generally, a structure circularly referencing itself, either directly or
/// indirectly, should not hold a strong reference to itself to prevent a memory leak.
/// Using this function, you get access to the weak pointer during the
/// initialization of `T`, before the `Rc<T, A>` is created, such that you can
/// clone and store it inside the `T`.
///
/// `new_cyclic_in` first allocates the managed allocation for the `Rc<T, A>`,
/// then calls your closure, giving it a `Weak<T, A>` to this allocation,
/// and only afterwards completes the construction of the `Rc<T, A>` by placing
/// the `T` returned from your closure into the allocation.
///
/// Since the new `Rc<T, A>` is not fully-constructed until `Rc<T, A>::new_cyclic_in`
/// returns, calling [`upgrade`] on the weak reference inside your closure will
/// fail and result in a `None` value.
///
/// # Panics
///
/// If `data_fn` panics, the panic is propagated to the caller, and the
/// temporary [`Weak<T, A>`] is dropped normally.
///
/// # Examples
///
/// See [`new_cyclic`].
///
/// [`new_cyclic`]: Rc::new_cyclic
/// [`upgrade`]: Weak::upgrade
#[cfg(not(no_global_oom_handling))]
#[unstable(feature = "allocator_api", issue = "32838")]
pub fn new_cyclic_in<F>(data_fn: F, alloc: A) -> Rc<T, A>
where
F: FnOnce(&Weak<T, A>) -> T,
{
// Construct the inner in the "uninitialized" state with a single
// weak reference.
let (uninit_raw_ptr, alloc) = Box::into_raw_with_allocator(Box::new_in(
RcBox {
strong: Cell::new(0),
weak: Cell::new(1),
value: mem::MaybeUninit::<T>::uninit(),
},
alloc,
));
let uninit_ptr: NonNull<_> = (unsafe { &mut *uninit_raw_ptr }).into();
let init_ptr: NonNull<RcBox<T>> = uninit_ptr.cast();

let weak = Weak { ptr: init_ptr, alloc: alloc };

// It's important we don't give up ownership of the weak pointer, or
// else the memory might be freed by the time `data_fn` returns. If
// we really wanted to pass ownership, we could create an additional
// weak pointer for ourselves, but this would result in additional
// updates to the weak reference count which might not be necessary
// otherwise.
let data = data_fn(&weak);

let strong = unsafe {
let inner = init_ptr.as_ptr();
ptr::write(ptr::addr_of_mut!((*inner).value), data);

let prev_value = (*inner).strong.get();
debug_assert_eq!(prev_value, 0, "No prior strong references should exist");
(*inner).strong.set(1);

// Strong references should collectively own a shared weak reference,
// so don't run the destructor for our old weak reference.
// Calling into_raw_with_allocator has the double effect of giving us back the allocator,
// and forgetting the weak reference.
let alloc = weak.into_raw_with_allocator().1;

Rc::from_inner_in(init_ptr, alloc)
};

strong
}

/// Constructs a new `Rc<T>` in the provided allocator, returning an error if the allocation
/// fails
///
Expand Down
Loading
Loading