@@ -7559,7 +7559,6 @@ msgid "\"yikes, something went wrong\""
7559
7559
msgstr ""
7560
7560
7561
7561
#: src/closures/exercise.md src/closures/solution.md
7562
- #: src/unsafe-rust/dereferencing.md
7563
7562
msgid "\"uhoh\""
7564
7563
msgstr ""
7565
7564
@@ -11271,35 +11270,34 @@ msgstr ""
11271
11270
msgid "Creating pointers is safe, but dereferencing them requires `unsafe`:"
11272
11271
msgstr ""
11273
11272
11274
- #: src/unsafe-rust/dereferencing.md
11275
- msgid "\"careful!\""
11276
- msgstr ""
11277
-
11278
11273
#: src/unsafe-rust/dereferencing.md
11279
11274
msgid ""
11280
- "// SAFETY: r1 and r2 were obtained from references and so are guaranteed to\n"
11281
- " // be non-null and properly aligned, the objects underlying the "
11282
- "references\n"
11283
- " // from which they were obtained are live throughout the whole unsafe\n"
11284
- " // block, and they are not accessed either through the references or\n"
11285
- " // concurrently through any other pointers.\n"
11286
- msgstr ""
11287
-
11288
- #: src/unsafe-rust/dereferencing.md
11289
- msgid "\"r1 is: {}\""
11275
+ "// SAFETY: p1 and p2 were created by taking raw pointers to a local, so "
11276
+ "they\n"
11277
+ " // are guaranteed to be non-null, aligned, and point into a single "
11278
+ "(stack-)\n"
11279
+ " // allocated object.\n"
11280
+ " //\n"
11281
+ " // The object underlying the raw pointers lives for the entire function, "
11282
+ "so\n"
11283
+ " // it is not deallocated while the raw pointers still exist. It is not\n"
11284
+ " // accessed through references while the raw pointers exist, nor is it\n"
11285
+ " // accessed from other threads concurrently.\n"
11290
11286
msgstr ""
11291
11287
11292
11288
#: src/unsafe-rust/dereferencing.md
11293
- msgid "\"r2 is: {}\" "
11289
+ msgid "// Mutation may soundly be observed through a raw pointer, like in C.\n "
11294
11290
msgstr ""
11295
11291
11296
11292
#: src/unsafe-rust/dereferencing.md
11297
11293
msgid ""
11298
- "// NOT SAFE . DO NOT DO THIS.\n"
11294
+ "// UNSOUND . DO NOT DO THIS.\n"
11299
11295
" /*\n"
11300
- " let r3: &String = unsafe { &*r1 };\n"
11301
- " drop(s);\n"
11302
- " println!(\"r3 is: {}\", *r3);\n"
11296
+ " let r: &i32 = unsafe { &*p1 };\n"
11297
+ " dbg!(r);\n"
11298
+ " x = 50;\n"
11299
+ " dbg!(r); // Object underlying the reference has been mutated. This is "
11300
+ "UB.\n"
11303
11301
" */"
11304
11302
msgstr ""
11305
11303
@@ -11346,9 +11344,12 @@ msgstr ""
11346
11344
11347
11345
#: src/unsafe-rust/dereferencing.md
11348
11346
msgid ""
11349
- "The \"NOT SAFE\" section gives an example of a common kind of UB bug: `*r1` "
11350
- "has the `'static` lifetime, so `r3` has type `&'static String`, and thus "
11351
- "outlives `s`. Creating a reference from a pointer requires _great care_."
11347
+ "The \"UNSOUND\" section gives an example of a common kind of UB bug: naïvely "
11348
+ "taking a reference to the dereference of a raw pointer sidesteps the "
11349
+ "compiler's knowledge of what object the reference is actually pointing to. "
11350
+ "As such, the borrow checker does not freeze `x` and so we are able to modify "
11351
+ "it despite the existence of a reference to it. Creating a reference from a "
11352
+ "pointer requires _great care_."
11352
11353
msgstr ""
11353
11354
11354
11355
#: src/unsafe-rust/mutable-static.md
@@ -11365,8 +11366,15 @@ msgstr ""
11365
11366
11366
11367
#: src/unsafe-rust/mutable-static.md
11367
11368
msgid ""
11368
- "However, since data races can occur, it is unsafe to read and write mutable "
11369
- "static variables:"
11369
+ "However, mutable static variables are unsafe to read and write because "
11370
+ "multiple threads could do so concurrently without synchronization, "
11371
+ "constituting a data race."
11372
+ msgstr ""
11373
+
11374
+ #: src/unsafe-rust/mutable-static.md
11375
+ msgid ""
11376
+ "Using mutable statics soundly requires reasoning about concurrency without "
11377
+ "the compiler's help:"
11370
11378
msgstr ""
11371
11379
11372
11380
#: src/unsafe-rust/mutable-static.md
@@ -11376,17 +11384,16 @@ msgstr ""
11376
11384
11377
11385
#: src/unsafe-rust/mutable-static.md
11378
11386
msgid ""
11379
- "The program here is safe because it is single-threaded. However, the Rust "
11387
+ "The program here is sound because it is single-threaded. However, the Rust "
11380
11388
"compiler reasons about functions individually so can't assume that. Try "
11381
11389
"removing the `unsafe` and see how the compiler explains that it is undefined "
11382
11390
"behavior to access a mutable static from multiple threads."
11383
11391
msgstr ""
11384
11392
11385
11393
#: src/unsafe-rust/mutable-static.md
11386
11394
msgid ""
11387
- "Rust 2024 edition goes further and makes accessing a mutable static by "
11388
- "reference an error by default. We work around this in the example with "
11389
- "`#[allow(static_mut_refs)]`. Don't do this."
11395
+ "The 2024 Rust edition goes further and makes accessing a mutable static by "
11396
+ "reference an error by default."
11390
11397
msgstr ""
11391
11398
11392
11399
#: src/unsafe-rust/mutable-static.md
@@ -11439,15 +11446,16 @@ msgid ""
11439
11446
msgstr ""
11440
11447
11441
11448
#: src/unsafe-rust/unsafe-functions.md
11442
- msgid "There are two main categories :"
11449
+ msgid "Unsafe functions may come from two places :"
11443
11450
msgstr ""
11444
11451
11445
11452
#: src/unsafe-rust/unsafe-functions.md
11446
- msgid "Rust functions declared unsafe with `unsafe fn`."
11453
+ #, fuzzy
11454
+ msgid "Rust functions declared unsafe."
11447
11455
msgstr "Rust fonksiyonları `unsafe fn` ile emniyetli olmadığı bildirildi."
11448
11456
11449
11457
#: src/unsafe-rust/unsafe-functions.md
11450
- msgid "Foreign functions in `extern \"C\"` blocks."
11458
+ msgid "Unsafe foreign functions in `extern \"C\"` blocks."
11451
11459
msgstr ""
11452
11460
11453
11461
#: src/unsafe-rust/unsafe-functions.md
@@ -11503,7 +11511,11 @@ msgid ""
11503
11511
msgstr ""
11504
11512
11505
11513
#: src/unsafe-rust/unsafe-functions/extern-c.md
11506
- msgid "Functions in a foreign language may also be unsafe:"
11514
+ msgid ""
11515
+ "You can declare foreign functions for access from Rust with `unsafe extern`. "
11516
+ "This is unsafe because the compiler has to way to reason about their "
11517
+ "behavior. Functions declared in an `extern` block must be marked as `safe` "
11518
+ "or `unsafe`, depending on whether they have preconditions for safe use:"
11507
11519
msgstr ""
11508
11520
11509
11521
#: src/unsafe-rust/unsafe-functions/extern-c.md src/unsafe-rust/exercise.md
0 commit comments