Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e7772f2
use posix_memalign on most Unix targets
RalfJung May 19, 2024
3c2d9c2
fix typo
RalfJung May 19, 2024
1eda580
Bump bootstrap compiler to the latest beta compiler
Urgau May 24, 2024
02eada8
Remove now outdated comment since we bumped stage0
Urgau May 24, 2024
9dc7620
Fail relating constants of different types
oli-obk May 23, 2024
d5eb7a7
Use regular type equating instead of a custom query
oli-obk May 23, 2024
3fe3157
Stop using the avx512er and avx512pf x86 target features
zmodem May 24, 2024
ebd9f35
remove proof tree formatter, make em shallow
lcnr May 24, 2024
1af490d
Better ICE message for unresolved upvars
compiler-errors May 24, 2024
61aac55
Structurally resolve before builtin_index in EUV
compiler-errors May 24, 2024
f4b9ac6
Add manual Sync impl for ReentrantLockGuard
programmerjake May 24, 2024
045f448
Don't eagerly monomorphize drop for types that are impossible to inst…
compiler-errors May 24, 2024
f28d368
Rollup merge of #125271 - RalfJung:posix_memalign, r=workingjubilee
matthiaskrgr May 25, 2024
7ea507e
Rollup merge of #125451 - oli-obk:const_type_mismatch, r=compiler-errors
matthiaskrgr May 25, 2024
e58a0a8
Rollup merge of #125478 - Urgau:check-cfg-config-bump-stage0, r=Mark-…
matthiaskrgr May 25, 2024
4d13c96
Rollup merge of #125498 - zmodem:avx512er, r=workingjubilee
matthiaskrgr May 25, 2024
00c51bd
Rollup merge of #125510 - lcnr:change-proof-trees-to-be-shallow, r=co…
matthiaskrgr May 25, 2024
3fc8fe0
Rollup merge of #125513 - compiler-errors:impossible-drop, r=jackh726
matthiaskrgr May 25, 2024
d747148
Rollup merge of #125514 - compiler-errors:builtin-index, r=lcnr
matthiaskrgr May 25, 2024
1d54ba8
Rollup merge of #125527 - programmerjake:patch-2, r=workingjubilee
matthiaskrgr May 25, 2024
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
Prev Previous commit
Next Next commit
Add manual Sync impl for ReentrantLockGuard
Fixes: #125526
  • Loading branch information
programmerjake committed May 25, 2024
commit f4b9ac68f306f630b5167959d5ee90626a9d7d84
3 changes: 3 additions & 0 deletions library/std/src/sync/reentrant_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ pub struct ReentrantLockGuard<'a, T: ?Sized + 'a> {
#[unstable(feature = "reentrant_lock", issue = "121440")]
impl<T: ?Sized> !Send for ReentrantLockGuard<'_, T> {}

#[unstable(feature = "reentrant_lock", issue = "121440")]
unsafe impl<T: ?Sized + Sync> Sync for ReentrantLockGuard<'_, T> {}

#[unstable(feature = "reentrant_lock", issue = "121440")]
impl<T> ReentrantLock<T> {
/// Creates a new re-entrant lock in an unlocked state ready for use.
Expand Down
15 changes: 15 additions & 0 deletions tests/ui/sync/reentrantlockguard-sync.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#![feature(reentrant_lock)]
use std::sync::ReentrantLock;
use std::cell::Cell;

// ReentrantLockGuard<Cell<i32>> must not be Sync, that would be unsound.

fn test_sync<T: Sync>(_t: T) {}

fn main()
{
let m = ReentrantLock::new(Cell::new(0i32));
let guard = m.lock();
test_sync(guard);
//~^ ERROR `Cell<i32>` cannot be shared between threads safely [E0277]
}
20 changes: 20 additions & 0 deletions tests/ui/sync/reentrantlockguard-sync.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
error[E0277]: `Cell<i32>` cannot be shared between threads safely
--> $DIR/reentrantlockguard-sync.rs:13:15
|
LL | test_sync(guard);
| --------- ^^^^^ `Cell<i32>` cannot be shared between threads safely
| |
| required by a bound introduced by this call
|
= help: the trait `Sync` is not implemented for `Cell<i32>`, which is required by `ReentrantLockGuard<'_, Cell<i32>>: Sync`
= note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` or `std::sync::atomic::AtomicI32` instead
= note: required for `ReentrantLockGuard<'_, Cell<i32>>` to implement `Sync`
note: required by a bound in `test_sync`
--> $DIR/reentrantlockguard-sync.rs:7:17
|
LL | fn test_sync<T: Sync>(_t: T) {}
| ^^^^ required by this bound in `test_sync`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0277`.