Constant rustc_privacy::DIAGNOSTICS [] [src]

pub const DIAGNOSTICS: [(&'static str, &'static str); 5] = [("E0451",
  "\nA struct constructor with private fields was invoked. Erroneous code example:\n\n```compile_fail,E0451\nmod Bar {\n    pub struct Foo {\n        pub a: isize,\n        b: isize,\n    }\n}\n\nlet f = Bar::Foo{ a: 0, b: 0 }; // error: field `b` of struct `Bar::Foo`\n                                //        is private\n```\n\nTo fix this error, please ensure that all the fields of the struct are public,\nor implement a function for easy instantiation. Examples:\n\n```\nmod Bar {\n    pub struct Foo {\n        pub a: isize,\n        pub b: isize, // we set `b` field public\n    }\n}\n\nlet f = Bar::Foo{ a: 0, b: 0 }; // ok!\n```\n\nOr:\n\n```\nmod Bar {\n    pub struct Foo {\n        pub a: isize,\n        b: isize, // still private\n    }\n\n    impl Foo {\n        pub fn new() -> Foo { // we create a method to instantiate `Foo`\n            Foo { a: 0, b: 0 }\n        }\n    }\n}\n\nlet f = Bar::Foo::new(); // ok!\n```\n"),
 ("E0446",
  "\nA private type was used in a public type signature. Erroneous code example:\n\n```compile_fail,E0446\n#![deny(private_in_public)]\n\nmod Foo {\n    struct Bar(u32);\n\n    pub fn bar() -> Bar { // error: private type in public interface\n        Bar(0)\n    }\n}\n```\n\nTo solve this error, please ensure that the type is also public. The type\ncan be made inaccessible if necessary by placing it into a private inner\nmodule, but it still has to be marked with `pub`.\nExample:\n\n```\nmod Foo {\n    pub struct Bar(u32); // we set the Bar type public\n\n    pub fn bar() -> Bar { // ok!\n        Bar(0)\n    }\n}\n```\n"),
 ("E0445",
  "\nA private trait was used on a public type parameter bound. Erroneous code\nexamples:\n\n```compile_fail,E0445\n#![deny(private_in_public)]\n\ntrait Foo {\n    fn dummy(&self) { }\n}\n\npub trait Bar : Foo {} // error: private trait in public interface\npub struct Bar2<T: Foo>(pub T); // same error\npub fn foo<T: Foo> (t: T) {} // same error\n```\n\nTo solve this error, please ensure that the trait is also public. The trait\ncan be made inaccessible if necessary by placing it into a private inner\nmodule, but it still has to be marked with `pub`. Example:\n\n```ignore\npub trait Foo { // we set the Foo trait public\n    fn dummy(&self) { }\n}\n\npub trait Bar : Foo {} // ok!\npub struct Bar2<T: Foo>(pub T); // ok!\npub fn foo<T: Foo> (t: T) {} // ok!\n```\n"),
 ("E0447",
  "\nThe `pub` keyword was used inside a function. Erroneous code example:\n\n```ignore\nfn foo() {\n    pub struct Bar; // error: visibility has no effect inside functions\n}\n```\n\nSince we cannot access items defined inside a function, the visibility of its\nitems does not impact outer code. So using the `pub` keyword in this context\nis invalid.\n"),
 ("E0448",
  "\nThe `pub` keyword was used inside a public enum. Erroneous code example:\n\n```compile_fail\npub enum Foo {\n    pub Bar, // error: unnecessary `pub` visibility\n}\n```\n\nSince the enum is already public, adding `pub` on one its elements is\nunnecessary. Example:\n\n```compile_fail,\nenum Foo {\n    pub Bar, // not ok!\n}\n```\n\nThis is the correct syntax:\n\n```ignore\npub enum Foo {\n    Bar, // ok!\n}\n```\n")]
🔬 This is a nightly-only experimental API. (rustc_private)