rustc_privacy::DIAGNOSTICS
[−]
[src]
pub const DIAGNOSTICS: [(&'static str, &'static str); 7usize]=
[("E0451", "\nA struct constructor with private fields was invoked. Erroneous code example:\n\n```compile_fail\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"), ("E0450", "\nA tuple constructor was invoked while some of its fields are private. Erroneous\ncode example:\n\n```compile_fail\nmod Bar {\n pub struct Foo(isize);\n}\n\nlet f = Bar::Foo(0); // error: cannot invoke tuple struct constructor with\n // private fields\n```\n\nTo solve this issue, please ensure that all of the fields of the tuple struct\nare public. Alternatively, provide a `new()` method to the tuple struct to\nconstruct it from a given inner value. Example:\n\n```\nmod Bar {\n pub struct Foo(pub isize); // we set its field to public\n}\n\nlet f = Bar::Foo(0); // ok!\n\n// or:\nmod bar {\n pub struct Foo(isize);\n\n impl Foo {\n pub fn new(x: isize) -> Foo {\n Foo(x)\n }\n }\n}\n\nlet f = bar::Foo::new(1);\n```\n"), ("E0449", "\nA visibility qualifier was used when it was unnecessary. Erroneous code\nexamples:\n\n```compile_fail\nstruct Bar;\n\ntrait Foo {\n fn foo();\n}\n\npub impl Bar {} // error: unnecessary visibility qualifier\n\npub impl Foo for Bar { // error: unnecessary visibility qualifier\n pub fn foo() {} // error: unnecessary visibility qualifier\n}\n```\n\nTo fix this error, please remove the visibility qualifier when it is not\nrequired. Example:\n\n```ignore\nstruct Bar;\n\ntrait Foo {\n fn foo();\n}\n\n// Directly implemented methods share the visibility of the type itself,\n// so `pub` is unnecessary here\nimpl Bar {}\n\n// Trait methods share the visibility of the trait, so `pub` is\n// unnecessary in either case\npub impl Foo for Bar {\n pub fn foo() {}\n}\n```\n"), ("E0446", "\nA private type was used in a public type signature. Erroneous code example:\n\n```compile_fail\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\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```compile_fail\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")]
Unstable (
rustc_private
)