about summary refs log tree commit diff
path: root/compiler/rustc_error_codes/src
diff options
context:
space:
mode:
authorLaurențiu Nicola <lnicola@dend.ro>2024-10-08 14:25:39 +0300
committerLaurențiu Nicola <lnicola@dend.ro>2024-10-08 14:25:39 +0300
commit4316afffd9390bdac1d3bd5e5398c65d6e9bb150 (patch)
tree9d5b39941405bec4b7c4571606df8b88850325e9 /compiler/rustc_error_codes/src
parent537fb8d1bb2405b118898c663bc076815a1762c7 (diff)
parentcf24c73141a77db730f4b7fda69dcd7e8b113b51 (diff)
downloadrust-4316afffd9390bdac1d3bd5e5398c65d6e9bb150.tar.gz
rust-4316afffd9390bdac1d3bd5e5398c65d6e9bb150.zip
Merge from rust-lang/rust
Diffstat (limited to 'compiler/rustc_error_codes/src')
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0013.md2
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0038.md33
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0607.md10
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0787.md5
-rw-r--r--compiler/rustc_error_codes/src/lib.rs2
5 files changed, 27 insertions, 25 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0013.md b/compiler/rustc_error_codes/src/error_codes/E0013.md
index 9f4848343ff..c4d65225ece 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0013.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0013.md
@@ -5,7 +5,7 @@ variable cannot refer to a static variable.
 
 Erroneous code example:
 
-```compile_fail,E0658
+```
 static X: i32 = 42;
 const Y: i32 = X;
 ```
diff --git a/compiler/rustc_error_codes/src/error_codes/E0038.md b/compiler/rustc_error_codes/src/error_codes/E0038.md
index 8f8eabb1519..014d8c4f761 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0038.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0038.md
@@ -5,9 +5,9 @@ trait, written in type positions) but this was a bit too confusing, so we now
 write `dyn Trait`.
 
 Some traits are not allowed to be used as trait object types. The traits that
-are allowed to be used as trait object types are called "object-safe" traits.
-Attempting to use a trait object type for a trait that is not object-safe will
-trigger error E0038.
+are allowed to be used as trait object types are called "dyn-compatible"[^1]
+traits. Attempting to use a trait object type for a trait that is not
+dyn-compatible will trigger error E0038.
 
 Two general aspects of trait object types give rise to the restrictions:
 
@@ -25,13 +25,16 @@ Two general aspects of trait object types give rise to the restrictions:
      objects with the same trait object type may point to vtables from different
      implementations.
 
-The specific conditions that violate object-safety follow, most of which relate
-to missing size information and vtable polymorphism arising from these aspects.
+The specific conditions that violate dyn-compatibility follow, most of which
+relate to missing size information and vtable polymorphism arising from these
+aspects.
+
+[^1]: Formerly known as "object-safe".
 
 ### The trait requires `Self: Sized`
 
 Traits that are declared as `Trait: Sized` or which otherwise inherit a
-constraint of `Self:Sized` are not object-safe.
+constraint of `Self:Sized` are not dyn-compatible.
 
 The reasoning behind this is somewhat subtle. It derives from the fact that Rust
 requires (and defines) that every trait object type `dyn Trait` automatically
@@ -58,7 +61,7 @@ implement a sized trait like `Trait:Sized`. So, rather than allow an exception
 to the rule that `dyn Trait` always implements `Trait`, Rust chooses to prohibit
 such a `dyn Trait` from existing at all.
 
-Only unsized traits are considered object-safe.
+Only unsized traits are considered dyn-compatible.
 
 Generally, `Self: Sized` is used to indicate that the trait should not be used
 as a trait object. If the trait comes from your own crate, consider removing
@@ -103,8 +106,8 @@ fn call_foo(x: Box<dyn Trait>) {
 }
 ```
 
-If only some methods aren't object-safe, you can add a `where Self: Sized` bound
-on them to mark them as explicitly unavailable to trait objects. The
+If only some methods aren't dyn-compatible, you can add a `where Self: Sized`
+bound on them to mark them as explicitly unavailable to trait objects. The
 functionality will still be available to all other implementers, including
 `Box<dyn Trait>` which is itself sized (assuming you `impl Trait for Box<dyn
 Trait>`).
@@ -117,7 +120,7 @@ trait Trait {
 ```
 
 Now, `foo()` can no longer be called on a trait object, but you will now be
-allowed to make a trait object, and that will be able to call any object-safe
+allowed to make a trait object, and that will be able to call any dyn-compatible
 methods. With such a bound, one can still call `foo()` on types implementing
 that trait that aren't behind trait objects.
 
@@ -306,7 +309,7 @@ Here, the supertrait might have methods as follows:
 
 ```
 trait Super<A: ?Sized> {
-    fn get_a(&self) -> &A; // note that this is object safe!
+    fn get_a(&self) -> &A; // note that this is dyn-compatible!
 }
 ```
 
@@ -314,10 +317,10 @@ If the trait `Trait` was deriving from something like `Super<String>` or
 `Super<T>` (where `Foo` itself is `Foo<T>`), this is okay, because given a type
 `get_a()` will definitely return an object of that type.
 
-However, if it derives from `Super<Self>`, even though `Super` is object safe,
-the method `get_a()` would return an object of unknown type when called on the
-function. `Self` type parameters let us make object safe traits no longer safe,
-so they are forbidden when specifying supertraits.
+However, if it derives from `Super<Self>`, even though `Super` is
+dyn-compatible, the method `get_a()` would return an object of unknown type when
+called on the function. `Self` type parameters let us make dyn-compatible traits
+no longer compatible, so they are forbidden when specifying supertraits.
 
 There's no easy fix for this. Generally, code will need to be refactored so that
 you no longer need to derive from `Super<Self>`.
diff --git a/compiler/rustc_error_codes/src/error_codes/E0607.md b/compiler/rustc_error_codes/src/error_codes/E0607.md
index 0545246929f..8ebc227114d 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0607.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0607.md
@@ -1,4 +1,4 @@
-A cast between a thin and a fat pointer was attempted.
+A cast between a thin and a wide pointer was attempted.
 
 Erroneous code example:
 
@@ -7,18 +7,18 @@ let v = core::ptr::null::<u8>();
 v as *const [u8];
 ```
 
-First: what are thin and fat pointers?
+First: what are thin and wide pointers?
 
 Thin pointers are "simple" pointers: they are purely a reference to a memory
 address.
 
-Fat pointers are pointers referencing Dynamically Sized Types (also called
+Wide pointers are pointers referencing Dynamically Sized Types (also called
 DSTs). DSTs don't have a statically known size, therefore they can only exist
 behind some kind of pointer that contains additional information. For example,
 slices and trait objects are DSTs. In the case of slices, the additional
-information the fat pointer holds is their size.
+information the wide pointer holds is their size.
 
-To fix this error, don't try to cast directly between thin and fat pointers.
+To fix this error, don't try to cast directly between thin and wide pointers.
 
 For more information about type casts, take a look at the section of the
 [The Rust Reference][1] on type cast expressions.
diff --git a/compiler/rustc_error_codes/src/error_codes/E0787.md b/compiler/rustc_error_codes/src/error_codes/E0787.md
index cee50829270..f5c5faa066b 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0787.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0787.md
@@ -11,11 +11,10 @@ pub extern "C" fn f() -> u32 {
 }
 ```
 
-The naked functions must be defined using a single inline assembly
-block.
+The naked function must be defined using a single `naked_asm!` assembly block.
 
 The execution must never fall through past the end of the assembly
-code so the block must use `noreturn` option. The asm block can also
+code, so it must either return or diverge. The asm block can also
 use `att_syntax` and `raw` options, but others options are not allowed.
 
 The asm block must not contain any operands other than `const` and
diff --git a/compiler/rustc_error_codes/src/lib.rs b/compiler/rustc_error_codes/src/lib.rs
index 8631de65ec8..27a34d6003d 100644
--- a/compiler/rustc_error_codes/src/lib.rs
+++ b/compiler/rustc_error_codes/src/lib.rs
@@ -623,7 +623,7 @@ E0800: 0800,
 //  E0314, // closure outlives stack frame
 //  E0315, // cannot invoke closure outside of its lifetime
 //  E0319, // trait impls for defaulted traits allowed just for structs/enums
-//  E0372, // coherence not object safe
+//  E0372, // coherence not dyn-compatible
 //  E0385, // {} in an aliasable location
 //  E0402, // cannot use an outer type parameter in this context
 //  E0406, // merged into 420