summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_error_codes
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:29 +0000
commit631cd5845e8de329d0e227aaa707d7ea228b8f8f (patch)
treea1b87c8f8cad01cf18f7c5f57a08f102771ed303 /compiler/rustc_error_codes
parentAdding debian version 1.69.0+dfsg1-1. (diff)
downloadrustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.tar.xz
rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_error_codes')
-rw-r--r--compiler/rustc_error_codes/src/error_codes.rs1
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0010.md4
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0080.md10
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0206.md8
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0223.md28
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0368.md2
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0416.md2
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0449.md29
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0710.md4
-rw-r--r--compiler/rustc_error_codes/src/error_codes/E0794.md64
10 files changed, 114 insertions, 38 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes.rs b/compiler/rustc_error_codes/src/error_codes.rs
index df857be85..d104ff089 100644
--- a/compiler/rustc_error_codes/src/error_codes.rs
+++ b/compiler/rustc_error_codes/src/error_codes.rs
@@ -513,6 +513,7 @@ E0790: include_str!("./error_codes/E0790.md"),
E0791: include_str!("./error_codes/E0791.md"),
E0792: include_str!("./error_codes/E0792.md"),
E0793: include_str!("./error_codes/E0793.md"),
+E0794: include_str!("./error_codes/E0794.md"),
}
// Undocumented removed error codes. Note that many removed error codes are documented.
diff --git a/compiler/rustc_error_codes/src/error_codes/E0010.md b/compiler/rustc_error_codes/src/error_codes/E0010.md
index 71c790e10..f03f8a660 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0010.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0010.md
@@ -5,7 +5,5 @@ the heap at runtime, and therefore cannot be done at compile time.
Erroneous code example:
```compile_fail,E0010
-#![feature(box_syntax)]
-
-const CON : Box<i32> = box 0;
+const CON : Vec<i32> = vec![1, 2, 3];
```
diff --git a/compiler/rustc_error_codes/src/error_codes/E0080.md b/compiler/rustc_error_codes/src/error_codes/E0080.md
index 7b1bbde61..c05324a5a 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0080.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0080.md
@@ -15,9 +15,9 @@ or causing an integer overflow are two ways to induce this error.
Ensure that the expressions given can be evaluated as the desired integer type.
-See the [Custom Discriminants][custom-discriminants] section of the Reference
-for more information about setting custom integer types on fieldless enums
-using the [`repr` attribute][repr-attribute].
+See the [Discriminants] section of the Reference for more information about
+setting custom integer types on enums using the
+[`repr` attribute][repr-attribute].
-[custom-discriminants]: https://doc.rust-lang.org/reference/items/enumerations.html#custom-discriminant-values-for-field-less-enumerations
-[repr-attribute]: https://doc.rust-lang.org/reference/type-layout.html#reprc-enums
+[discriminants]: https://doc.rust-lang.org/reference/items/enumerations.html#discriminants
+[repr-attribute]: https://doc.rust-lang.org/reference/type-layout.html#representations
diff --git a/compiler/rustc_error_codes/src/error_codes/E0206.md b/compiler/rustc_error_codes/src/error_codes/E0206.md
index 4405a2149..9e85234bd 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0206.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0206.md
@@ -1,5 +1,5 @@
-The `Copy` trait was implemented on a type which is neither a struct nor an
-enum.
+The `Copy` trait was implemented on a type which is neither a struct, an
+enum, nor a union.
Erroneous code example:
@@ -10,6 +10,6 @@ struct Bar;
impl Copy for &'static mut Bar { } // error!
```
-You can only implement `Copy` for a struct or an enum.
+You can only implement `Copy` for a struct, an enum, or a union.
The previous example will fail because `&'static mut Bar`
-is not a struct or enum.
+is not a struct, an enum, or a union.
diff --git a/compiler/rustc_error_codes/src/error_codes/E0223.md b/compiler/rustc_error_codes/src/error_codes/E0223.md
index 0d49f514c..ba5f00528 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0223.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0223.md
@@ -3,31 +3,33 @@ An attempt was made to retrieve an associated type, but the type was ambiguous.
Erroneous code example:
```compile_fail,E0223
-trait MyTrait {type X; }
+trait Trait { type X; }
fn main() {
- let foo: MyTrait::X;
+ let foo: Trait::X;
}
```
-The problem here is that we're attempting to take the type of X from MyTrait.
-Unfortunately, the type of X is not defined, because it's only made concrete in
-implementations of the trait. A working version of this code might look like:
+The problem here is that we're attempting to take the associated type of `X`
+from `Trait`. Unfortunately, the type of `X` is not defined, because it's only
+made concrete in implementations of the trait. A working version of this code
+might look like:
```
-trait MyTrait {type X; }
-struct MyStruct;
+trait Trait { type X; }
-impl MyTrait for MyStruct {
+struct Struct;
+impl Trait for Struct {
type X = u32;
}
fn main() {
- let foo: <MyStruct as MyTrait>::X;
+ let foo: <Struct as Trait>::X;
}
```
-This syntax specifies that we want the X type from MyTrait, as made concrete in
-MyStruct. The reason that we cannot simply use `MyStruct::X` is that MyStruct
-might implement two different traits with identically-named associated types.
-This syntax allows disambiguation between the two.
+This syntax specifies that we want the associated type `X` from `Struct`'s
+implementation of `Trait`.
+
+Due to internal limitations of the current compiler implementation we cannot
+simply use `Struct::X`.
diff --git a/compiler/rustc_error_codes/src/error_codes/E0368.md b/compiler/rustc_error_codes/src/error_codes/E0368.md
index 7b9d93348..b18e8758d 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0368.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0368.md
@@ -41,7 +41,7 @@ impl Add for Foo {
fn main() {
let mut x: Foo = Foo(5);
- x += Foo(7); // error, `+= cannot be applied to the type `Foo`
+ x += Foo(7); // error, `+=` cannot be applied to the type `Foo`
}
```
diff --git a/compiler/rustc_error_codes/src/error_codes/E0416.md b/compiler/rustc_error_codes/src/error_codes/E0416.md
index 7bc316daf..8c0edcee5 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0416.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0416.md
@@ -23,6 +23,6 @@ Or maybe did you mean to unify? Consider using a guard:
# let (A, B, C) = (1, 2, 3);
match (A, B, C) {
(x, x2, see) if x == x2 => { /* A and B are equal, do one thing */ }
- (y, z, see) => { /* A and B unequal; do another thing */ }
+ (y, z, see) => { /* A and B not equal; do another thing */ }
}
```
diff --git a/compiler/rustc_error_codes/src/error_codes/E0449.md b/compiler/rustc_error_codes/src/error_codes/E0449.md
index 9afc67689..a5876e075 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0449.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0449.md
@@ -1,4 +1,6 @@
-A visibility qualifier was used when it was unnecessary.
+A visibility qualifier was used where one is not permitted. Visibility
+qualifiers are not permitted on enum variants, trait items, impl blocks, and
+extern blocks, as they already share the visibility of the parent item.
Erroneous code examples:
@@ -9,15 +11,18 @@ trait Foo {
fn foo();
}
-pub impl Bar {} // error: unnecessary visibility qualifier
+enum Baz {
+ pub Qux, // error: visibility qualifiers are not permitted here
+}
+
+pub impl Bar {} // error: visibility qualifiers are not permitted here
-pub impl Foo for Bar { // error: unnecessary visibility qualifier
- pub fn foo() {} // error: unnecessary visibility qualifier
+pub impl Foo for Bar { // error: visibility qualifiers are not permitted here
+ pub fn foo() {} // error: visibility qualifiers are not permitted here
}
```
-To fix this error, please remove the visibility qualifier when it is not
-required. Example:
+To fix this error, simply remove the visibility qualifier. Example:
```
struct Bar;
@@ -26,12 +31,18 @@ trait Foo {
fn foo();
}
+enum Baz {
+ // Enum variants share the visibility of the enum they are in, so
+ // `pub` is not allowed here
+ Qux,
+}
+
// Directly implemented methods share the visibility of the type itself,
-// so `pub` is unnecessary here
+// so `pub` is not allowed here
impl Bar {}
-// Trait methods share the visibility of the trait, so `pub` is
-// unnecessary in either case
+// Trait methods share the visibility of the trait, so `pub` is not
+// allowed in either case
impl Foo for Bar {
fn foo() {}
}
diff --git a/compiler/rustc_error_codes/src/error_codes/E0710.md b/compiler/rustc_error_codes/src/error_codes/E0710.md
index b7037ea61..84d55d524 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0710.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0710.md
@@ -3,14 +3,14 @@ An unknown tool name was found in a scoped lint.
Erroneous code examples:
```compile_fail,E0710
-#[allow(clipp::filter_map)] // error!`
+#[allow(clipp::filter_map)] // error!
fn main() {
// business logic
}
```
```compile_fail,E0710
-#[warn(clipp::filter_map)] // error!`
+#[warn(clipp::filter_map)] // error!
fn main() {
// business logic
}
diff --git a/compiler/rustc_error_codes/src/error_codes/E0794.md b/compiler/rustc_error_codes/src/error_codes/E0794.md
new file mode 100644
index 000000000..c8f73de95
--- /dev/null
+++ b/compiler/rustc_error_codes/src/error_codes/E0794.md
@@ -0,0 +1,64 @@
+A lifetime parameter of a function definition is called *late-bound* if it both:
+
+1. appears in an argument type
+2. does not appear in a generic type constraint
+
+You cannot specify lifetime arguments for late-bound lifetime parameters.
+
+Erroneous code example:
+
+```compile_fail,E0794
+fn foo<'a>(x: &'a str) -> &'a str { x }
+let _ = foo::<'static>;
+```
+
+The type of a concrete instance of a generic function is universally quantified
+over late-bound lifetime parameters. This is because we want the function to
+work for any lifetime substituted for the late-bound lifetime parameter, no
+matter where the function is called. Consequently, it doesn't make sense to
+specify arguments for late-bound lifetime parameters, since they are not
+resolved until the function's call site(s).
+
+To fix the issue, remove the specified lifetime:
+
+```
+fn foo<'a>(x: &'a str) -> &'a str { x }
+let _ = foo;
+```
+
+### Additional information
+
+Lifetime parameters that are not late-bound are called *early-bound*.
+Confusion may arise from the fact that late-bound and early-bound
+lifetime parameters are declared the same way in function definitions.
+When referring to a function pointer type, universal quantification over
+late-bound lifetime parameters can be made explicit:
+
+```
+trait BarTrait<'a> {}
+
+struct Bar<'a> {
+ s: &'a str
+}
+
+impl<'a> BarTrait<'a> for Bar<'a> {}
+
+fn bar<'a, 'b, T>(x: &'a str, _t: T) -> &'a str
+where T: BarTrait<'b>
+{
+ x
+}
+
+let bar_fn: for<'a> fn(&'a str, Bar<'static>) -> &'a str = bar; // OK
+let bar_fn2 = bar::<'static, Bar>; // Not allowed
+let bar_fn3 = bar::<Bar>; // OK
+```
+
+In the definition of `bar`, the lifetime parameter `'a` is late-bound, while
+`'b` is early-bound. This is reflected in the type annotation for `bar_fn`,
+where `'a` is universally quantified and `'b` is substituted by a specific
+lifetime. It is not allowed to explicitly specify early-bound lifetime
+arguments when late-bound lifetime parameters are present (as for `bar_fn2`,
+see [issue #42868](https://github.com/rust-lang/rust/issues/42868)), although
+the types that are constrained by early-bound parameters can be specified (as
+for `bar_fn3`).