]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/diagnostics.rs
Fix stability
[rust.git] / src / librustc / diagnostics.rs
index 9616b596c063827512e49afeabb8ff57239df46e..7cb2de78e2c7dbdf1248b05ed9270c458ff90e13 100644 (file)
@@ -298,10 +298,18 @@ fn index<'a>(&'a self, idx: u8) -> &'a u8 { &self.a }
 ```
 "##,
 
+// FIXME(#24111) Change the language here when const fn stabilizes
 E0015: r##"
 The only functions that can be called in static or constant expressions are
-`const` functions. Rust currently does not support more general compile-time
-function execution.
+`const` functions, and struct/enum constructors. `const` functions are only
+available on a nightly compiler. Rust currently does not support more general
+compile-time function execution.
+
+```
+const FOO: Option<u8> = Some(1); // enum constructor
+struct Bar {x: u8}
+const BAR: Bar = Bar {x: 1}; // struct constructor
+```
 
 See [RFC 911] for more details on the design of `const fn`s.
 
@@ -1886,7 +1894,150 @@ fn foo<'a>(arg: &Box<SomeTrait+'a>) { ... }
 contain references (with a maximum lifetime of `'a`).
 
 [1]: https://github.com/rust-lang/rfcs/pull/1156
-"##
+"##,
+
+E0454: r##"
+A link name was given with an empty name. Erroneous code example:
+
+```
+#[link(name = "")] extern {} // error: #[link(name = "")] given with empty name
+```
+
+The rust compiler cannot link to an external library if you don't give it its
+name. Example:
+
+```
+#[link(name = "some_lib")] extern {} // ok!
+```
+"##,
+
+E0458: r##"
+An unknown "kind" was specified for a link attribute. Erroneous code example:
+
+```
+#[link(kind = "wonderful_unicorn")] extern {}
+// error: unknown kind: `wonderful_unicorn`
+```
+
+Please specify a valid "kind" value, from one of the following:
+ * static
+ * dylib
+ * framework
+"##,
+
+E0459: r##"
+A link was used without a name parameter. Erroneous code example:
+
+```
+#[link(kind = "dylib")] extern {}
+// error: #[link(...)] specified without `name = "foo"`
+```
+
+Please add the name parameter to allow the rust compiler to find the library
+you want. Example:
+
+```
+#[link(kind = "dylib", name = "some_lib")] extern {} // ok!
+```
+"##,
+
+E0493: r##"
+A type with a destructor was assigned to an invalid type of variable. Erroneous
+code example:
+
+```
+struct Foo {
+    a: u32
+}
+
+impl Drop for Foo {
+    fn drop(&mut self) {}
+}
+
+const F : Foo = Foo { a : 0 };
+// error: constants are not allowed to have destructors
+static S : Foo = Foo { a : 0 };
+// error: statics are not allowed to have destructors
+```
+
+To solve this issue, please use a type which does allow the usage of type with
+destructors.
+"##,
+
+E0494: r##"
+A reference of an interior static was assigned to another const/static.
+Erroneous code example:
+
+```
+struct Foo {
+    a: u32
+}
+
+static S : Foo = Foo { a : 0 };
+static A : &'static u32 = &S.a;
+// error: cannot refer to the interior of another static, use a
+//        constant instead
+```
+
+The "base" variable has to be a const if you want another static/const variable
+to refer to one of its fields. Example:
+
+```
+struct Foo {
+    a: u32
+}
+
+const S : Foo = Foo { a : 0 };
+static A : &'static u32 = &S.a; // ok!
+```
+"##,
+
+E0496: r##"
+A lifetime name is shadowing another lifetime name. Erroneous code example:
+
+```
+struct Foo<'a> {
+    a: &'a i32,
+}
+
+impl<'a> Foo<'a> {
+    fn f<'a>(x: &'a i32) { // error: lifetime name `'a` shadows a lifetime
+                           //        name that is already in scope
+    }
+}
+```
+
+Please change the name of one of the lifetimes to remove this error. Example:
+
+
+```
+struct Foo<'a> {
+    a: &'a i32,
+}
+
+impl<'a> Foo<'a> {
+    fn f<'b>(x: &'b i32) { // ok!
+    }
+}
+
+fn main() {
+}
+```
+"##,
+
+E0497: r##"
+A stability attribute was used outside of the standard library. Erroneous code
+example:
+
+```
+#[stable] // error: stability attributes may not be used outside of the
+          //        standard library
+fn foo() {}
+```
+
+It is not possible to use stability attributes outside of the standard library.
+Also, for now, it is not possible to write deprecation messages either.
+"##,
 
 }
 
@@ -1914,5 +2065,46 @@ fn foo<'a>(arg: &Box<SomeTrait+'a>) { ... }
     E0314, // closure outlives stack frame
     E0315, // cannot invoke closure outside of its lifetime
     E0316, // nested quantification of lifetimes
-    E0400  // overloaded derefs are not allowed in constants
+    E0400, // overloaded derefs are not allowed in constants
+    E0452, // malformed lint attribute
+    E0453, // overruled by outer forbid
+    E0455, // native frameworks are only available on OSX targets
+    E0456, // plugin `..` is not available for triple `..`
+    E0457, // plugin `..` only found in rlib format, but must be available...
+    E0460, // found possibly newer version of crate `..`
+    E0461, // couldn't find crate `..` with expected target triple ..
+    E0462, // found staticlib `..` instead of rlib or dylib
+    E0463, // can't find crate for `..`
+    E0464, // multiple matching crates for `..`
+    E0465, // multiple .. candidates for `..` found
+    E0466, // bad macro import
+    E0467, // bad macro reexport
+    E0468, // an `extern crate` loading macros must be at the crate root
+    E0469, // imported macro not found
+    E0470, // reexported macro not found
+    E0471, // constant evaluation error: ..
+    E0472, // asm! is unsupported on this target
+    E0473, // dereference of reference outside its lifetime
+    E0474, // captured variable `..` does not outlive the enclosing closure
+    E0475, // index of slice outside its lifetime
+    E0476, // lifetime of the source pointer does not outlive lifetime bound...
+    E0477, // the type `..` does not fulfill the required lifetime...
+    E0478, // lifetime bound not satisfied
+    E0479, // the type `..` (provided as the value of a type parameter) is...
+    E0480, // lifetime of method receiver does not outlive the method call
+    E0481, // lifetime of function argument does not outlive the function call
+    E0482, // lifetime of return value does not outlive the function call
+    E0483, // lifetime of operand does not outlive the operation
+    E0484, // reference is not valid at the time of borrow
+    E0485, // automatically reference is not valid at the time of borrow
+    E0486, // type of expression contains references that are not valid during...
+    E0487, // unsafe use of destructor: destructor might be called while...
+    E0488, // lifetime of variable does not enclose its declaration
+    E0489, // type/lifetime parameter not in scope here
+    E0490, // a value of type `..` is borrowed for too long
+    E0491, // in type `..`, reference has a longer lifetime than the data it...
+    E0492, // cannot borrow a constant which contains interior mutability
+    E0495, // cannot infer an appropriate lifetime due to conflicting requirements
+    E0498, // malformed plugin attribute
+    E0514, // metadata version mismatch
 }