]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #84842 - blkerby:null_lowercase, r=joshtriplett
authorbors <bors@rust-lang.org>
Mon, 3 May 2021 05:41:23 +0000 (05:41 +0000)
committerbors <bors@rust-lang.org>
Mon, 3 May 2021 05:41:23 +0000 (05:41 +0000)
Replace 'NULL' with 'null'

This replaces occurrences of "NULL" with "null" in docs, comments, and compiler error/lint messages. This is for the sake of consistency, as the lowercase "null" is already the dominant form in Rust. The all-caps NULL looks like the C macro (or SQL keyword), which seems out of place in a Rust context, given that NULL does not exist in the Rust language or standard library (instead having [`ptr::null()`](https://doc.rust-lang.org/stable/std/ptr/fn.null.html)).

80 files changed:
compiler/rustc_resolve/src/late/diagnostics.rs
compiler/rustc_session/src/config.rs
compiler/rustc_target/src/spec/apple_base.rs
compiler/rustc_target/src/spec/dragonfly_base.rs
compiler/rustc_target/src/spec/freebsd_base.rs
compiler/rustc_target/src/spec/fuchsia_base.rs
compiler/rustc_target/src/spec/haiku_base.rs
compiler/rustc_target/src/spec/illumos_base.rs
compiler/rustc_target/src/spec/l4re_base.rs
compiler/rustc_target/src/spec/linux_base.rs
compiler/rustc_target/src/spec/mod.rs
compiler/rustc_target/src/spec/netbsd_base.rs
compiler/rustc_target/src/spec/openbsd_base.rs
compiler/rustc_target/src/spec/redox_base.rs
compiler/rustc_target/src/spec/solaris_base.rs
compiler/rustc_target/src/spec/vxworks_base.rs
compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs
compiler/rustc_target/src/spec/wasm_base.rs
compiler/rustc_target/src/spec/windows_gnu_base.rs
compiler/rustc_target/src/spec/windows_msvc_base.rs
compiler/rustc_typeck/src/check/wfcheck.rs
library/alloc/src/string.rs
library/std/src/io/error.rs
library/std/src/sys/unix/mod.rs
library/std/src/sys/wasi/mod.rs
library/std/src/sys/windows/c.rs
library/std/src/sys/windows/mod.rs
src/librustdoc/clean/inline.rs
src/librustdoc/clean/mod.rs
src/librustdoc/clean/types.rs
src/librustdoc/formats/cache.rs
src/librustdoc/html/render/mod.rs
src/librustdoc/html/static/main.js
src/librustdoc/html/static/rustdoc.css
src/librustdoc/html/static/themes/ayu.css
src/librustdoc/html/static/themes/dark.css
src/librustdoc/html/static/themes/light.css
src/test/rustdoc/assoc-consts.rs
src/test/rustdoc/auxiliary/trait-alias-mention.rs [new file with mode: 0644]
src/test/rustdoc/auxiliary/trait-visibility.rs [new file with mode: 0644]
src/test/rustdoc/inline_cross/assoc-items.rs
src/test/rustdoc/inline_cross/impl-inline-without-trait.rs
src/test/rustdoc/manual_impl.rs
src/test/rustdoc/trait-alias-mention.rs [new file with mode: 0644]
src/test/rustdoc/trait-impl.rs
src/test/rustdoc/trait-visibility.rs [new file with mode: 0644]
src/test/rustdoc/trait_alias.rs
src/test/ui/cfg/cfg-family.rs
src/test/ui/cfg/cfg-target-family.rs
src/test/ui/const-generics/const-param-type-depends-on-type-param.full.stderr
src/test/ui/const-generics/const-param-type-depends-on-type-param.min.stderr
src/test/ui/const-generics/issue-67375.full.stderr
src/test/ui/const-generics/issue-67375.min.stderr
src/test/ui/const-generics/issue-67945-1.full.stderr
src/test/ui/const-generics/issue-67945-1.min.stderr
src/test/ui/const-generics/issue-67945-2.full.stderr
src/test/ui/const-generics/issue-67945-2.min.stderr
src/test/ui/const-generics/unused-type-param-suggestion.rs [new file with mode: 0644]
src/test/ui/const-generics/unused-type-param-suggestion.stderr [new file with mode: 0644]
src/test/ui/empty/empty-struct-unit-pat.stderr
src/test/ui/enum-discriminant/issue-70453-generics-in-discr-ice.stderr
src/test/ui/enum/issue-67945-1.stderr
src/test/ui/enum/issue-67945-2.stderr
src/test/ui/error-codes/E0392.stderr
src/test/ui/inner-static-type-parameter.stderr
src/test/ui/issues/issue-17904-2.stderr
src/test/ui/issues/issue-20413.stderr
src/test/ui/issues/issue-32004.stderr
src/test/ui/issues/issue-36299.stderr
src/test/ui/issues/issue-36638.stderr
src/test/ui/issues/issue-37534.stderr
src/test/ui/issues/issue-pr29383.stderr
src/test/ui/match/match-pattern-field-mismatch-2.stderr
src/test/ui/pattern/pattern-error-continue.stderr
src/test/ui/suggestions/issue-84700.rs [new file with mode: 0644]
src/test/ui/suggestions/issue-84700.stderr [new file with mode: 0644]
src/test/ui/variance/variance-unused-type-param.stderr
src/tools/clippy/tests/ui/wildcard_enum_match_arm.fixed
src/tools/clippy/tests/ui/wildcard_enum_match_arm.rs
src/tools/clippy/tests/ui/wildcard_enum_match_arm.stderr

index e33c374f562e2452d6d68625d3b93810f1bfbd18..7561b3df3af70841d2b436f12115018614048950 100644 (file)
@@ -819,6 +819,19 @@ fn smart_resolve_context_dependent_help(
             _ => false,
         };
 
+        let find_span = |source: &PathSource<'_>, err: &mut DiagnosticBuilder<'_>| {
+            match source {
+                PathSource::Expr(Some(Expr { span, kind: ExprKind::Call(_, _), .. }))
+                | PathSource::TupleStruct(span, _) => {
+                    // We want the main underline to cover the suggested code as well for
+                    // cleaner output.
+                    err.set_span(*span);
+                    *span
+                }
+                _ => span,
+            }
+        };
+
         let mut bad_struct_syntax_suggestion = |def_id: DefId| {
             let (followed_by_brace, closing_brace) = self.followed_by_brace(span);
 
@@ -862,18 +875,7 @@ fn smart_resolve_context_dependent_help(
                     }
                 }
                 PathSource::Expr(_) | PathSource::TupleStruct(..) | PathSource::Pat => {
-                    let span = match &source {
-                        PathSource::Expr(Some(Expr {
-                            span, kind: ExprKind::Call(_, _), ..
-                        }))
-                        | PathSource::TupleStruct(span, _) => {
-                            // We want the main underline to cover the suggested code as well for
-                            // cleaner output.
-                            err.set_span(*span);
-                            *span
-                        }
-                        _ => span,
-                    };
+                    let span = find_span(&source, err);
                     if let Some(span) = self.def_span(def_id) {
                         err.span_label(span, &format!("`{}` defined here", path_str));
                     }
@@ -1047,6 +1049,23 @@ fn smart_resolve_context_dependent_help(
             ) if ns == ValueNS => {
                 bad_struct_syntax_suggestion(def_id);
             }
+            (Res::Def(DefKind::Ctor(_, CtorKind::Const), def_id), _) if ns == ValueNS => {
+                match source {
+                    PathSource::Expr(_) | PathSource::TupleStruct(..) | PathSource::Pat => {
+                        let span = find_span(&source, err);
+                        if let Some(span) = self.def_span(def_id) {
+                            err.span_label(span, &format!("`{}` defined here", path_str));
+                        }
+                        err.span_suggestion(
+                            span,
+                            &format!("use this syntax instead"),
+                            format!("{path_str}"),
+                            Applicability::MaybeIncorrect,
+                        );
+                    }
+                    _ => return false,
+                }
+            }
             (Res::Def(DefKind::Ctor(_, CtorKind::Fn), def_id), _) if ns == ValueNS => {
                 if let Some(span) = self.def_span(def_id) {
                     err.span_label(span, &format!("`{}` defined here", path_str));
index 1f5cb5b8abc8c0c9a39d0552b241a26e53efbb8c..1ddd7d694547d895b4f6034a00fb4eb1ce527edb 100644 (file)
@@ -816,7 +816,7 @@ fn default_configuration(sess: &Session) -> CrateConfig {
     ret.reserve(6); // the minimum number of insertions
     // Target bindings.
     ret.insert((sym::target_os, Some(Symbol::intern(os))));
-    if let Some(ref fam) = sess.target.os_family {
+    for fam in &sess.target.families {
         ret.insert((sym::target_family, Some(Symbol::intern(fam))));
         if fam == "windows" {
             ret.insert((sym::windows, None));
index 6fa0b34545097bc7d6e21afc4aa64a0e18afcab4..bc2ec6709011a6cacb6db75cb30ae0e4cc3bdd60 100644 (file)
@@ -23,7 +23,7 @@ pub fn opts(os: &str) -> TargetOptions {
         function_sections: false,
         dynamic_linking: true,
         executables: true,
-        os_family: Some("unix".to_string()),
+        families: vec!["unix".to_string()],
         is_like_osx: true,
         dwarf_version: Some(2),
         has_rpath: true,
index dd0170987824a70cf61bd8d9dc4f0e158f88c82c..fb94498c131fd38283062d398271ccdf02c0727e 100644 (file)
@@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
         os: "dragonfly".to_string(),
         dynamic_linking: true,
         executables: true,
-        os_family: Some("unix".to_string()),
+        families: vec!["unix".to_string()],
         linker_is_gnu: true,
         has_rpath: true,
         position_independent_executables: true,
index ad3383cc5f26144fffcac082c212407ccab7fec1..5d3c28e5f29c9d80a19675ff9f85d5ff4ce830be 100644 (file)
@@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
         os: "freebsd".to_string(),
         dynamic_linking: true,
         executables: true,
-        os_family: Some("unix".to_string()),
+        families: vec!["unix".to_string()],
         linker_is_gnu: true,
         has_rpath: true,
         position_independent_executables: true,
index 2b925f8b946c4a62908e070617c57dcf47fc6131..13264dffeb4edd955caaf67e80247fc95ff07d3a 100644 (file)
@@ -25,7 +25,7 @@ pub fn opts() -> TargetOptions {
         linker: Some("rust-lld".to_owned()),
         dynamic_linking: true,
         executables: true,
-        os_family: Some("unix".to_string()),
+        families: vec!["unix".to_string()],
         is_like_fuchsia: true,
         linker_is_gnu: true,
         pre_link_args,
index 956e4ed4bf9c838e792928b2d0e8216635c7fb6d..fae56f6a82dc8e7222b736c573166601f06a9045 100644 (file)
@@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
         os: "haiku".to_string(),
         dynamic_linking: true,
         executables: true,
-        os_family: Some("unix".to_string()),
+        families: vec!["unix".to_string()],
         relro_level: RelroLevel::Full,
         linker_is_gnu: true,
         ..Default::default()
index d9b5716c0418528202a5bcda0d48e8b8262370f2..2e365d210f3f62356498e666dd010bf286b75a04 100644 (file)
@@ -20,7 +20,7 @@ pub fn opts() -> TargetOptions {
         dynamic_linking: true,
         executables: true,
         has_rpath: true,
-        os_family: Some("unix".to_string()),
+        families: vec!["unix".to_string()],
         is_like_solaris: true,
         limit_rdylib_exports: false, // Linker doesn't support this
         eliminate_frame_pointer: false,
index db6b74eff6dbd039208b3dd1a883799d93cef670..65c343a5f2169b07e645c79c42935a56642e5c22 100644 (file)
@@ -20,7 +20,7 @@ pub fn opts() -> TargetOptions {
         executables: true,
         panic_strategy: PanicStrategy::Abort,
         linker: Some("ld".to_string()),
-        os_family: Some("unix".to_string()),
+        families: vec!["unix".to_string()],
         ..Default::default()
     }
 }
index eeefd056e4b746818ed731df599920e39afa8edc..184659e22d98693dabc233c64676ab709af615dd 100644 (file)
@@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
         os: "linux".to_string(),
         dynamic_linking: true,
         executables: true,
-        os_family: Some("unix".to_string()),
+        families: vec!["unix".to_string()],
         linker_is_gnu: true,
         has_rpath: true,
         position_independent_executables: true,
index 2af46693449dcfd33a71f751fabdbf2d1b073c2f..dfc97447ce042bb9b11a887725cc7f9b6e305eae 100644 (file)
@@ -1042,8 +1042,12 @@ pub struct TargetOptions {
     pub staticlib_prefix: String,
     /// String to append to the name of every static library. Defaults to ".a".
     pub staticlib_suffix: String,
-    /// OS family to use for conditional compilation. Valid options: "unix", "windows".
-    pub os_family: Option<String>,
+    /// Values of the `target_family` cfg set for this target.
+    ///
+    /// Common options are: "unix", "windows". Defaults to no families.
+    ///
+    /// See <https://doc.rust-lang.org/reference/conditional-compilation.html#target_family>.
+    pub families: Vec<String>,
     /// Whether the target toolchain's ABI supports returning small structs as an integer.
     pub abi_return_struct_as_int: bool,
     /// Whether the target toolchain is like macOS's. Only useful for compiling against iOS/macOS,
@@ -1293,7 +1297,7 @@ fn default() -> TargetOptions {
             exe_suffix: String::new(),
             staticlib_prefix: "lib".to_string(),
             staticlib_suffix: ".a".to_string(),
-            os_family: None,
+            families: Vec::new(),
             abi_return_struct_as_int: false,
             is_like_osx: false,
             is_like_solaris: false,
@@ -1605,14 +1609,6 @@ macro_rules! key {
                         .map(|s| s.to_string() );
                 }
             } );
-            ($key_name:ident = $json_name:expr, optional) => ( {
-                let name = $json_name;
-                if let Some(o) = obj.find(name) {
-                    base.$key_name = o
-                        .as_string()
-                        .map(|s| s.to_string() );
-                }
-            } );
             ($key_name:ident, LldFlavor) => ( {
                 let name = (stringify!($key_name)).replace("_", "-");
                 obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| {
@@ -1759,6 +1755,16 @@ macro_rules! key {
                     Some(Ok(()))
                 })).unwrap_or(Ok(()))
             } );
+            ($key_name:ident, TargetFamilies) => ( {
+                let value = obj.find("target-family");
+                if let Some(v) = value.and_then(Json::as_array) {
+                    base.$key_name = v.iter()
+                        .map(|a| a.as_string().unwrap().to_string())
+                        .collect();
+                } else if let Some(v) = value.and_then(Json::as_string) {
+                    base.$key_name = vec![v.to_string()];
+                }
+            } );
         }
 
         if let Some(s) = obj.find("target-endian").and_then(Json::as_string) {
@@ -1802,7 +1808,7 @@ macro_rules! key {
         key!(exe_suffix);
         key!(staticlib_prefix);
         key!(staticlib_suffix);
-        key!(os_family = "target-family", optional);
+        key!(families, TargetFamilies);
         key!(abi_return_struct_as_int, bool);
         key!(is_like_osx, bool);
         key!(is_like_solaris, bool);
@@ -2042,7 +2048,7 @@ macro_rules! target_option_val {
         target_option_val!(exe_suffix);
         target_option_val!(staticlib_prefix);
         target_option_val!(staticlib_suffix);
-        target_option_val!(os_family, "target-family");
+        target_option_val!(families, "target-family");
         target_option_val!(abi_return_struct_as_int);
         target_option_val!(is_like_osx);
         target_option_val!(is_like_solaris);
index 680cd60788bdea8d158e960e757b2c73c677f2eb..602fb6eb6413b7ac50d82ad5dde01e74351227e1 100644 (file)
@@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
         os: "netbsd".to_string(),
         dynamic_linking: true,
         executables: true,
-        os_family: Some("unix".to_string()),
+        families: vec!["unix".to_string()],
         linker_is_gnu: true,
         no_default_libraries: false,
         has_rpath: true,
index a6fd01ab110df8dbfd134debac2a419db167aad4..8f33bacd9228eb34166cbadd488257d8f728067c 100644 (file)
@@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
         os: "openbsd".to_string(),
         dynamic_linking: true,
         executables: true,
-        os_family: Some("unix".to_string()),
+        families: vec!["unix".to_string()],
         linker_is_gnu: true,
         has_rpath: true,
         abi_return_struct_as_int: true,
index 0afb4a72ac14ffd37bf0c43eab92942d3fc3ce06..72052b9e2e2e3e19f7f328057a057dc71a1f503a 100644 (file)
@@ -6,7 +6,7 @@ pub fn opts() -> TargetOptions {
         env: "relibc".to_string(),
         dynamic_linking: true,
         executables: true,
-        os_family: Some("unix".to_string()),
+        families: vec!["unix".to_string()],
         linker_is_gnu: true,
         has_rpath: true,
         position_independent_executables: true,
index 59731f25821ffb2e28daba18e0554f492ab973a4..4c922eb5cea55081d8c251501b657d412dd8adbf 100644 (file)
@@ -6,7 +6,7 @@ pub fn opts() -> TargetOptions {
         dynamic_linking: true,
         executables: true,
         has_rpath: true,
-        os_family: Some("unix".to_string()),
+        families: vec!["unix".to_string()],
         is_like_solaris: true,
         limit_rdylib_exports: false, // Linker doesn't support this
         eh_frame_header: false,
index 41c4d7625af2a854015faf0efead054148f2e19e..0e8e87f2dff5c9512574cc8c5b192d882c5a6d58 100644 (file)
@@ -9,7 +9,7 @@ pub fn opts() -> TargetOptions {
         exe_suffix: ".vxe".to_string(),
         dynamic_linking: true,
         executables: true,
-        os_family: Some("unix".to_string()),
+        families: vec!["unix".to_string()],
         linker_is_gnu: true,
         has_rpath: true,
         has_elf_tls: true,
index e028dbaa3252018260de58ec15c4ef040f729527..ddf28b423f0d2df4266fe4780399b384eb6edc70 100644 (file)
@@ -38,7 +38,7 @@ pub fn target() -> Target {
         is_like_emscripten: true,
         panic_strategy: PanicStrategy::Unwind,
         post_link_args,
-        os_family: Some("unix".to_string()),
+        families: vec!["unix".to_string()],
         ..options
     };
     Target {
index b208eb92f8ff96eef6d2bf4b09e2c1b8352d514d..87e740de08e9175e0099c03bac8ff93252d65c63 100644 (file)
@@ -61,6 +61,7 @@ pub fn options() -> TargetOptions {
 
     TargetOptions {
         is_like_wasm: true,
+        families: vec!["wasm".to_string()],
 
         // we allow dynamic linking, but only cdylibs. Basically we allow a
         // final library artifact that exports some symbols (a wasm module) but
index 478c567a93b2523ce7ab008ddeba1a081cf75996..35a52896f6fa628e6842da4b68de2029b9a59260 100644 (file)
@@ -71,7 +71,7 @@ pub fn opts() -> TargetOptions {
         dll_prefix: String::new(),
         dll_suffix: ".dll".to_string(),
         exe_suffix: ".exe".to_string(),
-        os_family: Some("windows".to_string()),
+        families: vec!["windows".to_string()],
         is_like_windows: true,
         allows_weak_linkage: false,
         pre_link_args,
index c041245e32862e960751dbad2cb164b73eea4317..0d58618a449a901bcf5955a352885c96b3e0156a 100644 (file)
@@ -13,7 +13,7 @@ pub fn opts() -> TargetOptions {
         exe_suffix: ".exe".to_string(),
         staticlib_prefix: String::new(),
         staticlib_suffix: ".lib".to_string(),
-        os_family: Some("windows".to_string()),
+        families: vec!["windows".to_string()],
         crt_static_allows_dylibs: true,
         crt_static_respected: true,
         requires_uwtable: true,
index d25dd9a6e830222451fad37af2ef27dc90e339ab..4914f196afbb5af1ed34a0c7dd7e5213aa493e1a 100644 (file)
@@ -1298,12 +1298,14 @@ fn check_variances_for_type_defn<'tcx>(
 
         match param.name {
             hir::ParamName::Error => {}
-            _ => report_bivariance(tcx, param.span, param.name.ident().name),
+            _ => report_bivariance(tcx, param),
         }
     }
 }
 
-fn report_bivariance(tcx: TyCtxt<'_>, span: Span, param_name: Symbol) {
+fn report_bivariance(tcx: TyCtxt<'_>, param: &rustc_hir::GenericParam<'_>) {
+    let span = param.span;
+    let param_name = param.name.ident().name;
     let mut err = error_392(tcx, span, param_name);
 
     let suggested_marker_id = tcx.lang_items().phantom_data();
@@ -1318,7 +1320,14 @@ fn report_bivariance(tcx: TyCtxt<'_>, span: Span, param_name: Symbol) {
         format!("consider removing `{}` or referring to it in a field", param_name)
     };
     err.help(&msg);
-    err.emit();
+
+    if matches!(param.kind, rustc_hir::GenericParamKind::Type { .. }) {
+        err.help(&format!(
+            "if you intended `{0}` to be a const parameter, use `const {0}: usize` instead",
+            param_name
+        ));
+    }
+    err.emit()
 }
 
 /// Feature gates RFC 2056 -- trivial bounds, checking for global bounds that
index f4ec4a36ffd2bac8b5e99a12481bbdff21c53a64..509ff9ce4d1308a6e0d6fdfb6d17bc444a226c53 100644 (file)
@@ -2288,6 +2288,47 @@ fn to_string(&self) -> String {
     }
 }
 
+#[stable(feature = "u8_to_string_specialization", since = "1.999.0")]
+impl ToString for u8 {
+    #[inline]
+    fn to_string(&self) -> String {
+        let mut buf = String::with_capacity(3);
+        let mut n = *self;
+        if n >= 10 {
+            if n >= 100 {
+                buf.push((b'0' + n / 100) as char);
+                n %= 100;
+            }
+            buf.push((b'0' + n / 10) as char);
+            n %= 10;
+        }
+        buf.push((b'0' + n) as char);
+        buf
+    }
+}
+
+#[stable(feature = "i8_to_string_specialization", since = "1.999.0")]
+impl ToString for i8 {
+    #[inline]
+    fn to_string(&self) -> String {
+        let mut buf = String::with_capacity(4);
+        if self.is_negative() {
+            buf.push('-');
+        }
+        let mut n = self.unsigned_abs();
+        if n >= 10 {
+            if n >= 100 {
+                buf.push('1');
+                n -= 100;
+            }
+            buf.push((b'0' + n / 10) as char);
+            n %= 10;
+        }
+        buf.push((b'0' + n) as char);
+        buf
+    }
+}
+
 #[stable(feature = "str_to_string_specialization", since = "1.9.0")]
 impl ToString for str {
     #[inline]
index 9bed12bf2ae2b1c47030e111ffb39163a14e04e3..ae896d1240ea536bbfcfbbe9a139c34b6fc48c5a 100644 (file)
@@ -186,6 +186,11 @@ pub enum ErrorKind {
     /// This means that the operation can never succeed.
     #[stable(feature = "unsupported_error", since = "1.53.0")]
     Unsupported,
+
+    /// An operation could not be completed, because it failed
+    /// to allocate enough memory.
+    #[stable(feature = "out_of_memory_error", since = "1.53.0")]
+    OutOfMemory,
 }
 
 impl ErrorKind {
@@ -210,6 +215,7 @@ pub(crate) fn as_str(&self) -> &'static str {
             ErrorKind::Other => "other os error",
             ErrorKind::UnexpectedEof => "unexpected end of file",
             ErrorKind::Unsupported => "unsupported",
+            ErrorKind::OutOfMemory => "out of memory",
         }
     }
 }
index 6c4fbaf27344b8bd3581a6565b782d0e2f91dfd3..562d9d92637a6662fb415d4509e491c702b37df0 100644 (file)
@@ -149,6 +149,7 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind {
         libc::ETIMEDOUT => ErrorKind::TimedOut,
         libc::EEXIST => ErrorKind::AlreadyExists,
         libc::ENOSYS => ErrorKind::Unsupported,
+        libc::ENOMEM => ErrorKind::OutOfMemory,
 
         // These two constants can have the same value on some systems,
         // but different values on others, so we can't use a match
index 37f74fcc052e36b40e2a7f0c5148dfcf083019d4..88b81d455d2416f1c408c1b62e1fdcf4cfb2d165 100644 (file)
@@ -77,6 +77,7 @@ pub fn decode_error_kind(errno: i32) -> std_io::ErrorKind {
         wasi::ERRNO_EXIST => AlreadyExists,
         wasi::ERRNO_AGAIN => WouldBlock,
         wasi::ERRNO_NOSYS => Unsupported,
+        wasi::ERRNO_NOMEM => OutOfMemory,
         _ => Other,
     }
 }
index 3e4176ef7f8fec9b5956c6350a9a8ae04e45201f..7ea6048e94a883e0fea616733edadb3fb73797d4 100644 (file)
@@ -168,6 +168,8 @@ fn clone(&self) -> Self {
 pub const ERROR_PATH_NOT_FOUND: DWORD = 3;
 pub const ERROR_ACCESS_DENIED: DWORD = 5;
 pub const ERROR_INVALID_HANDLE: DWORD = 6;
+pub const ERROR_NOT_ENOUGH_MEMORY: DWORD = 8;
+pub const ERROR_OUTOFMEMORY: DWORD = 14;
 pub const ERROR_NO_MORE_FILES: DWORD = 18;
 pub const ERROR_HANDLE_EOF: DWORD = 38;
 pub const ERROR_FILE_EXISTS: DWORD = 80;
index ddb6ac5f55c0d9684f5bc00a65a07d0072bef437..2208ff025c0f7d77e6a6563a986488207662b0fc 100644 (file)
@@ -71,6 +71,7 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind {
         c::ERROR_PATH_NOT_FOUND => return ErrorKind::NotFound,
         c::ERROR_NO_DATA => return ErrorKind::BrokenPipe,
         c::ERROR_INVALID_PARAMETER => return ErrorKind::InvalidInput,
+        c::ERROR_NOT_ENOUGH_MEMORY | c::ERROR_OUTOFMEMORY => return ErrorKind::OutOfMemory,
         c::ERROR_SEM_TIMEOUT
         | c::WAIT_TIMEOUT
         | c::ERROR_DRIVER_CANCEL_TIMEOUT
index 5dd9f3f1ebd34018434c23befcb32dabd9d96a9d..6ad635012b134bb3f4639bf425d6a4e10051595d 100644 (file)
@@ -19,7 +19,7 @@
 use crate::core::DocContext;
 use crate::formats::item_type::ItemType;
 
-use super::Clean;
+use super::{Clean, Visibility};
 
 type Attrs<'hir> = rustc_middle::ty::Attributes<'hir>;
 
     if did.is_local() {
         cx.cache.exact_paths.insert(did, fqn);
     } else {
-        cx.cache.external_paths.insert(did, (fqn, ItemType::from(kind)));
+        cx.cache.external_paths.insert(did, (fqn, kind));
     }
 }
 
 crate fn build_external_trait(cx: &mut DocContext<'_>, did: DefId) -> clean::Trait {
-    let trait_items =
-        cx.tcx.associated_items(did).in_definition_order().map(|item| item.clean(cx)).collect();
+    let trait_items = cx
+        .tcx
+        .associated_items(did)
+        .in_definition_order()
+        .map(|item| {
+            // When building an external trait, the cleaned trait will have all items public,
+            // which causes methods to have a `pub` prefix, which is invalid since items in traits
+            // can not have a visibility prefix. Thus we override the visibility here manually.
+            // See https://github.com/rust-lang/rust/issues/81274
+            clean::Item { visibility: Visibility::Inherited, ..item.clean(cx) }
+        })
+        .collect();
 
     let predicates = cx.tcx.predicates_of(did);
     let generics = (cx.tcx.generics_of(did), predicates).clean(cx);
index 78b76b05018dc8402e9dcf8efdb33271f12abc47..33df9ea3f3e0cb11cdf819f4d96fbdd03609b027 100644 (file)
 use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
 use rustc_index::vec::{Idx, IndexVec};
 use rustc_infer::infer::region_constraints::{Constraint, RegionConstraintData};
-use rustc_middle::bug;
 use rustc_middle::middle::resolve_lifetime as rl;
 use rustc_middle::ty::fold::TypeFolder;
 use rustc_middle::ty::subst::{InternalSubsts, Subst};
 use rustc_middle::ty::{self, AdtKind, Lift, Ty, TyCtxt};
+use rustc_middle::{bug, span_bug};
 use rustc_mir::const_eval::{is_const_fn, is_unstable_const_fn};
 use rustc_span::hygiene::{AstPass, MacroKind};
 use rustc_span::symbol::{kw, sym, Ident, Symbol};
@@ -158,7 +158,15 @@ fn clean(&self, cx: &mut DocContext<'_>) -> GenericBound {
 impl Clean<Type> for (ty::TraitRef<'_>, &[TypeBinding]) {
     fn clean(&self, cx: &mut DocContext<'_>) -> Type {
         let (trait_ref, bounds) = *self;
-        inline::record_extern_fqn(cx, trait_ref.def_id, ItemType::Trait);
+        let kind = cx.tcx.def_kind(trait_ref.def_id).into();
+        if !matches!(kind, ItemType::Trait | ItemType::TraitAlias) {
+            span_bug!(
+                cx.tcx.def_span(trait_ref.def_id),
+                "`TraitRef` had unexpected kind {:?}",
+                kind
+            );
+        }
+        inline::record_extern_fqn(cx, trait_ref.def_id, kind);
         let path = external_path(
             cx,
             cx.tcx.item_name(trait_ref.def_id),
index 33cb11e539bf2d89f8d8e63633d89b697723bca0..a556fdba2f3f623dcb24cb7dd1c66033c3a5c001 100644 (file)
@@ -678,10 +678,6 @@ impl ItemKind {
             | KeywordItem(_) => [].iter(),
         }
     }
-
-    crate fn is_type_alias(&self) -> bool {
-        matches!(self, ItemKind::TypedefItem(..) | ItemKind::AssocTypeItem(..))
-    }
 }
 
 #[derive(Clone, Debug)]
index 8723e47586ee4600e4ece32f573410dcbf7320c4..b6b76a96e7f9647ec1b36faaed916f7727a2e05b 100644 (file)
@@ -327,6 +327,7 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
             | clean::EnumItem(..)
             | clean::TypedefItem(..)
             | clean::TraitItem(..)
+            | clean::TraitAliasItem(..)
             | clean::FunctionItem(..)
             | clean::ModuleItem(..)
             | clean::ForeignFunctionItem(..)
@@ -337,26 +338,43 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
             | clean::ForeignTypeItem
             | clean::MacroItem(..)
             | clean::ProcMacroItem(..)
-            | clean::VariantItem(..)
-                if !self.cache.stripped_mod =>
-            {
-                // Re-exported items mean that the same id can show up twice
-                // in the rustdoc ast that we're looking at. We know,
-                // however, that a re-exported item doesn't show up in the
-                // `public_items` map, so we can skip inserting into the
-                // paths map if there was already an entry present and we're
-                // not a public item.
-                if !self.cache.paths.contains_key(&item.def_id)
-                    || self.cache.access_levels.is_public(item.def_id)
-                {
-                    self.cache.paths.insert(item.def_id, (self.cache.stack.clone(), item.type_()));
+            | clean::VariantItem(..) => {
+                if !self.cache.stripped_mod {
+                    // Re-exported items mean that the same id can show up twice
+                    // in the rustdoc ast that we're looking at. We know,
+                    // however, that a re-exported item doesn't show up in the
+                    // `public_items` map, so we can skip inserting into the
+                    // paths map if there was already an entry present and we're
+                    // not a public item.
+                    if !self.cache.paths.contains_key(&item.def_id)
+                        || self.cache.access_levels.is_public(item.def_id)
+                    {
+                        self.cache
+                            .paths
+                            .insert(item.def_id, (self.cache.stack.clone(), item.type_()));
+                    }
                 }
             }
             clean::PrimitiveItem(..) => {
                 self.cache.paths.insert(item.def_id, (self.cache.stack.clone(), item.type_()));
             }
 
-            _ => {}
+            clean::ExternCrateItem { .. }
+            | clean::ImportItem(..)
+            | clean::OpaqueTyItem(..)
+            | clean::ImplItem(..)
+            | clean::TyMethodItem(..)
+            | clean::MethodItem(..)
+            | clean::StructFieldItem(..)
+            | clean::AssocConstItem(..)
+            | clean::AssocTypeItem(..)
+            | clean::StrippedItem(..)
+            | clean::KeywordItem(..) => {
+                // FIXME: Do these need handling?
+                // The person writing this comment doesn't know.
+                // So would rather leave them to an expert,
+                // as at least the list is better than `_ => {}`.
+            }
         }
 
         // Maintain the parent stack
index 0a8026ef942b1495f99758fe830d486159e371b6..811c4233386029bdc3ef173eb225f4143ee9c68d 100644 (file)
@@ -508,23 +508,16 @@ fn document(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, parent: Option
     if let Some(ref name) = item.name {
         info!("Documenting {}", name);
     }
-    document_item_info(w, cx, item, false, parent);
-    document_full(w, item, cx, false);
+    document_item_info(w, cx, item, parent);
+    document_full(w, item, cx);
 }
 
 /// Render md_text as markdown.
-fn render_markdown(
-    w: &mut Buffer,
-    cx: &Context<'_>,
-    md_text: &str,
-    links: Vec<RenderedLink>,
-    is_hidden: bool,
-) {
+fn render_markdown(w: &mut Buffer, cx: &Context<'_>, md_text: &str, links: Vec<RenderedLink>) {
     let mut ids = cx.id_map.borrow_mut();
     write!(
         w,
-        "<div class=\"docblock{}\">{}</div>",
-        if is_hidden { " hidden" } else { "" },
+        "<div class=\"docblock\">{}</div>",
         Markdown(
             md_text,
             &links,
@@ -544,11 +537,10 @@ fn document_short(
     item: &clean::Item,
     cx: &Context<'_>,
     link: AssocItemLink<'_>,
-    is_hidden: bool,
     parent: &clean::Item,
     show_def_docs: bool,
 ) {
-    document_item_info(w, cx, item, is_hidden, Some(parent));
+    document_item_info(w, cx, item, Some(parent));
     if !show_def_docs {
         return;
     }
@@ -565,19 +557,14 @@ fn document_short(
             }
         }
 
-        write!(
-            w,
-            "<div class='docblock{}'>{}</div>",
-            if is_hidden { " hidden" } else { "" },
-            summary_html,
-        );
+        write!(w, "<div class='docblock'>{}</div>", summary_html,);
     }
 }
 
-fn document_full(w: &mut Buffer, item: &clean::Item, cx: &Context<'_>, is_hidden: bool) {
+fn document_full(w: &mut Buffer, item: &clean::Item, cx: &Context<'_>) {
     if let Some(s) = cx.shared.maybe_collapsed_doc_value(item) {
         debug!("Doc block: =====\n{}\n=====", s);
-        render_markdown(w, cx, &s, item.links(cx), is_hidden);
+        render_markdown(w, cx, &s, item.links(cx));
     }
 }
 
@@ -590,16 +577,11 @@ fn document_item_info(
     w: &mut Buffer,
     cx: &Context<'_>,
     item: &clean::Item,
-    is_hidden: bool,
     parent: Option<&clean::Item>,
 ) {
     let item_infos = short_item_info(item, cx, parent);
     if !item_infos.is_empty() {
-        if is_hidden {
-            w.write_str("<div class=\"item-info hidden\">");
-        } else {
-            w.write_str("<div class=\"item-info\">");
-        }
+        w.write_str("<div class=\"item-info\">");
         for info in item_infos {
             w.write_str(&info);
         }
@@ -1282,8 +1264,12 @@ fn render_impl(
     let trait_ = i.trait_did_full(cache).map(|did| &traits[&did]);
     let mut close_tags = String::new();
 
+    // For trait implementations, the `interesting` output contains all methods that have doc
+    // comments, and the `boring` output contains all methods that do not. The distinction is
+    // used to allow hiding the boring methods.
     fn doc_impl_item(
-        w: &mut Buffer,
+        boring: &mut Buffer,
+        interesting: &mut Buffer,
         cx: &Context<'_>,
         item: &clean::Item,
         parent: &clean::Item,
@@ -1306,15 +1292,46 @@ fn doc_impl_item(
             }
         };
 
-        let (is_hidden, extra_class) =
-            if (trait_.is_none() || item.doc_value().is_some() || item.kind.is_type_alias())
-                && !is_default_item
-            {
-                (false, "")
-            } else {
-                (true, " hidden")
-            };
         let in_trait_class = if trait_.is_some() { " trait-impl" } else { "" };
+
+        let mut doc_buffer = Buffer::empty_from(boring);
+        let mut info_buffer = Buffer::empty_from(boring);
+        let mut short_documented = true;
+
+        if render_method_item {
+            if !is_default_item {
+                if let Some(t) = trait_ {
+                    // The trait item may have been stripped so we might not
+                    // find any documentation or stability for it.
+                    if let Some(it) = t.items.iter().find(|i| i.name == item.name) {
+                        // We need the stability of the item from the trait
+                        // because impls can't have a stability.
+                        if item.doc_value().is_some() {
+                            document_item_info(&mut info_buffer, cx, it, Some(parent));
+                            document_full(&mut doc_buffer, item, cx);
+                            short_documented = false;
+                        } else {
+                            // In case the item isn't documented,
+                            // provide short documentation from the trait.
+                            document_short(&mut doc_buffer, it, cx, link, parent, show_def_docs);
+                        }
+                    }
+                } else {
+                    document_item_info(&mut info_buffer, cx, item, Some(parent));
+                    if show_def_docs {
+                        document_full(&mut doc_buffer, item, cx);
+                        short_documented = false;
+                    }
+                }
+            } else {
+                document_short(&mut doc_buffer, item, cx, link, parent, show_def_docs);
+            }
+        }
+        let w = if short_documented && trait_.is_some() { interesting } else { boring };
+
+        if !doc_buffer.is_empty() {
+            w.write_str("<details class=\"rustdoc-toggle\" open><summary>");
+        }
         match *item.kind {
             clean::MethodItem(..) | clean::TyMethodItem(_) => {
                 // Only render when the method is not static or we allow static methods
@@ -1327,11 +1344,7 @@ fn doc_impl_item(
                             })
                         })
                         .map(|item| format!("{}.{}", item.type_(), name));
-                    write!(
-                        w,
-                        "<h4 id=\"{}\" class=\"{}{}{}\">",
-                        id, item_type, extra_class, in_trait_class,
-                    );
+                    write!(w, "<h4 id=\"{}\" class=\"{}{}\">", id, item_type, in_trait_class,);
                     w.write_str("<code>");
                     render_assoc_item(
                         w,
@@ -1356,11 +1369,7 @@ fn doc_impl_item(
             clean::TypedefItem(ref tydef, _) => {
                 let source_id = format!("{}.{}", ItemType::AssocType, name);
                 let id = cx.derive_id(source_id.clone());
-                write!(
-                    w,
-                    "<h4 id=\"{}\" class=\"{}{}{}\"><code>",
-                    id, item_type, extra_class, in_trait_class
-                );
+                write!(w, "<h4 id=\"{}\" class=\"{}{}\"><code>", id, item_type, in_trait_class);
                 assoc_type(
                     w,
                     item,
@@ -1377,11 +1386,7 @@ fn doc_impl_item(
             clean::AssocConstItem(ref ty, ref default) => {
                 let source_id = format!("{}.{}", item_type, name);
                 let id = cx.derive_id(source_id.clone());
-                write!(
-                    w,
-                    "<h4 id=\"{}\" class=\"{}{}{}\"><code>",
-                    id, item_type, extra_class, in_trait_class
-                );
+                write!(w, "<h4 id=\"{}\" class=\"{}{}\"><code>", id, item_type, in_trait_class);
                 assoc_const(
                     w,
                     item,
@@ -1406,11 +1411,7 @@ fn doc_impl_item(
             clean::AssocTypeItem(ref bounds, ref default) => {
                 let source_id = format!("{}.{}", item_type, name);
                 let id = cx.derive_id(source_id.clone());
-                write!(
-                    w,
-                    "<h4 id=\"{}\" class=\"{}{}{}\"><code>",
-                    id, item_type, extra_class, in_trait_class
-                );
+                write!(w, "<h4 id=\"{}\" class=\"{}{}\"><code>", id, item_type, in_trait_class);
                 assoc_type(
                     w,
                     item,
@@ -1428,38 +1429,20 @@ fn doc_impl_item(
             _ => panic!("can't make docs for trait item with name {:?}", item.name),
         }
 
-        if render_method_item {
-            if !is_default_item {
-                if let Some(t) = trait_ {
-                    // The trait item may have been stripped so we might not
-                    // find any documentation or stability for it.
-                    if let Some(it) = t.items.iter().find(|i| i.name == item.name) {
-                        // We need the stability of the item from the trait
-                        // because impls can't have a stability.
-                        if item.doc_value().is_some() {
-                            document_item_info(w, cx, it, is_hidden, Some(parent));
-                            document_full(w, item, cx, is_hidden);
-                        } else {
-                            // In case the item isn't documented,
-                            // provide short documentation from the trait.
-                            document_short(w, it, cx, link, is_hidden, parent, show_def_docs);
-                        }
-                    }
-                } else {
-                    document_item_info(w, cx, item, is_hidden, Some(parent));
-                    if show_def_docs {
-                        document_full(w, item, cx, is_hidden);
-                    }
-                }
-            } else {
-                document_short(w, item, cx, link, is_hidden, parent, show_def_docs);
-            }
+        w.push_buffer(info_buffer);
+        if !doc_buffer.is_empty() {
+            w.write_str("</summary>");
+            w.push_buffer(doc_buffer);
+            w.push_str("</details>");
         }
     }
 
     let mut impl_items = Buffer::empty_from(w);
+    let mut default_impl_items = Buffer::empty_from(w);
+
     for trait_item in &i.inner_impl().items {
         doc_impl_item(
+            &mut default_impl_items,
             &mut impl_items,
             cx,
             trait_item,
@@ -1475,7 +1458,8 @@ fn doc_impl_item(
     }
 
     fn render_default_items(
-        w: &mut Buffer,
+        boring: &mut Buffer,
+        interesting: &mut Buffer,
         cx: &Context<'_>,
         t: &clean::Trait,
         i: &clean::Impl,
@@ -1495,7 +1479,8 @@ fn render_default_items(
             let assoc_link = AssocItemLink::GotoSource(did, &provided_methods);
 
             doc_impl_item(
-                w,
+                boring,
+                interesting,
                 cx,
                 trait_item,
                 parent,
@@ -1517,6 +1502,7 @@ fn render_default_items(
     if show_default_items {
         if let Some(t) = trait_ {
             render_default_items(
+                &mut default_impl_items,
                 &mut impl_items,
                 cx,
                 &t.trait_,
@@ -1529,10 +1515,14 @@ fn render_default_items(
             );
         }
     }
-    let details_str = if impl_items.is_empty() {
-        ""
-    } else {
-        "<details class=\"rustdoc-toggle implementors-toggle\" open><summary>"
+    let toggled = !impl_items.is_empty() || !default_impl_items.is_empty();
+    let open_details = |close_tags: &mut String| {
+        if toggled {
+            close_tags.insert_str(0, "</details>");
+            "<details class=\"rustdoc-toggle implementors-toggle\" open><summary>"
+        } else {
+            ""
+        }
     };
     if render_mode == RenderMode::Normal {
         let id = cx.derive_id(match i.inner_impl().trait_ {
@@ -1554,11 +1544,10 @@ fn render_default_items(
             write!(
                 w,
                 "{}<h3 id=\"{}\" class=\"impl\"{}><code class=\"in-band\">",
-                details_str, id, aliases
+                open_details(&mut close_tags),
+                id,
+                aliases
             );
-            if !impl_items.is_empty() {
-                close_tags.insert_str(0, "</details>");
-            }
             write!(w, "{}", i.inner_impl().print(use_absolute, cx));
             if show_def_docs {
                 for it in &i.inner_impl().items {
@@ -1582,14 +1571,11 @@ fn render_default_items(
             write!(
                 w,
                 "{}<h3 id=\"{}\" class=\"impl\"{}><code class=\"in-band\">{}</code>",
-                details_str,
+                open_details(&mut close_tags),
                 id,
                 aliases,
                 i.inner_impl().print(false, cx)
             );
-            if !impl_items.is_empty() {
-                close_tags.insert_str(0, "</details>");
-            }
         }
         write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
         render_stability_since_raw(
@@ -1600,7 +1586,7 @@ fn render_default_items(
             outer_const_version,
         );
         write_srclink(cx, &i.impl_item, w);
-        if impl_items.is_empty() {
+        if !toggled {
             w.write_str("</h3>");
         } else {
             w.write_str("</h3></summary>");
@@ -1629,8 +1615,13 @@ fn render_default_items(
             );
         }
     }
-    if !impl_items.is_empty() {
+    if toggled {
         w.write_str("<div class=\"impl-items\">");
+        w.push_buffer(default_impl_items);
+        if trait_.is_some() && !impl_items.is_empty() {
+            w.write_str("<details class=\"undocumented\"><summary></summary>");
+            close_tags.insert_str(0, "</details>");
+        }
         w.push_buffer(impl_items);
         close_tags.insert_str(0, "</div>");
     }
index e81eaca8f0e40ae4027c882b0eda19e45bfc918c..1bc5362592494d7b70048af27823ff5232535e4f 100644 (file)
@@ -1156,8 +1156,6 @@ function hideThemeButtonState() {
         var hideMethodDocs = getSettingValue("auto-hide-method-docs") === "true";
         var hideImplementors = getSettingValue("auto-collapse-implementors") !== "false";
         var hideLargeItemContents = getSettingValue("auto-hide-large-items") !== "false";
-        var hideTraitImplementations =
-            getSettingValue("auto-hide-trait-implementations") !== "false";
 
         var impl_list = document.getElementById("trait-implementations-list");
         if (impl_list !== null) {
@@ -1173,39 +1171,18 @@ function hideThemeButtonState() {
             });
         }
 
-        var func = function(e) {
-            var next = e.nextElementSibling;
-            if (next && hasClass(next, "item-info")) {
-              next = next.nextElementSibling;
-            }
-            if (!next) {
-                return;
-            }
-            if (hasClass(next, "docblock")) {
-                var newToggle = toggle.cloneNode(true);
-                insertAfter(newToggle, e.childNodes[e.childNodes.length - 1]);
-                if (hideMethodDocs === true && hasClass(e, "method") === true) {
-                    collapseDocs(newToggle, "hide");
+        if (hideMethodDocs === true) {
+            onEachLazy(document.getElementsByClassName("method"), function(e) {
+                var toggle = e.parentNode;
+                if (toggle) {
+                    toggle = toggle.parentNode;
                 }
-            }
-        };
-
-        var funcImpl = function(e) {
-            var next = e.nextElementSibling;
-            if (next && hasClass(next, "item-info")) {
-                next = next.nextElementSibling;
-            }
-            if (next && hasClass(next, "docblock")) {
-                next = next.nextElementSibling;
-            }
-            if (!next) {
-                return;
-            }
-        };
+                if (toggle && toggle.tagName === "DETAILS") {
+                    toggle.open = false;
+                }
+            });
+        }
 
-        onEachLazy(document.getElementsByClassName("method"), func);
-        onEachLazy(document.getElementsByClassName("associatedconstant"), func);
-        var impl_call = function() {};
         onEachLazy(document.getElementsByTagName("details"), function (e) {
             var showLargeItem = !hideLargeItemContents && hasClass(e, "type-contents-toggle");
             var showImplementor = !hideImplementors && hasClass(e, "implementors-toggle");
@@ -1213,60 +1190,6 @@ function hideThemeButtonState() {
                 e.open = true;
             }
         });
-        if (hideMethodDocs === true) {
-            impl_call = function(e, newToggle) {
-                if (e.id.match(/^impl(?:-\d+)?$/) === null) {
-                    // Automatically minimize all non-inherent impls
-                    if (hasClass(e, "impl") === true) {
-                        collapseDocs(newToggle, "hide");
-                    }
-                }
-            };
-        }
-        var newToggle = document.createElement("a");
-        newToggle.href = "javascript:void(0)";
-        newToggle.className = "collapse-toggle hidden-default collapsed";
-        newToggle.innerHTML = "[<span class=\"inner\">" + labelForToggleButton(true) +
-                              "</span>] Show hidden undocumented items";
-        function toggleClicked() {
-            if (hasClass(this, "collapsed")) {
-                removeClass(this, "collapsed");
-                onEachLazy(this.parentNode.getElementsByClassName("hidden"), function(x) {
-                    if (hasClass(x, "content") === false) {
-                        removeClass(x, "hidden");
-                        addClass(x, "x");
-                    }
-                }, true);
-                this.innerHTML = "[<span class=\"inner\">" + labelForToggleButton(false) +
-                                 "</span>] Hide undocumented items";
-            } else {
-                addClass(this, "collapsed");
-                onEachLazy(this.parentNode.getElementsByClassName("x"), function(x) {
-                    if (hasClass(x, "content") === false) {
-                        addClass(x, "hidden");
-                        removeClass(x, "x");
-                    }
-                }, true);
-                this.innerHTML = "[<span class=\"inner\">" + labelForToggleButton(true) +
-                                 "</span>] Show hidden undocumented items";
-            }
-        }
-        onEachLazy(document.getElementsByClassName("impl-items"), function(e) {
-            onEachLazy(e.getElementsByClassName("associatedconstant"), func);
-            // We transform the DOM iterator into a vec of DOM elements to prevent performance
-            // issues on webkit browsers.
-            var hiddenElems = Array.prototype.slice.call(e.getElementsByClassName("hidden"));
-            var needToggle = hiddenElems.some(function(hiddenElem) {
-                return hasClass(hiddenElem, "content") === false &&
-                    hasClass(hiddenElem, "docblock") === false;
-            });
-            if (needToggle === true) {
-                var inner_toggle = newToggle.cloneNode(true);
-                inner_toggle.onclick = toggleClicked;
-                e.insertBefore(inner_toggle, e.firstChild);
-                impl_call(e.previousSibling, inner_toggle);
-            }
-        });
 
         var currentType = document.getElementsByClassName("type-decl")[0];
         var className = null;
index a95c90e999f98ca5c715cee40286dfa840f3e732..d3fe59e8d0b01d7b97d3073aacec4a9f3196da5d 100644 (file)
@@ -110,7 +110,7 @@ h3 {
        font-size: 1.3em;
 }
 h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod):not(.notable),
-h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant) {
+h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant):not(.associatedtype) {
        font-weight: 500;
        margin: 20px 0 15px 0;
        padding-bottom: 6px;
@@ -128,10 +128,10 @@ h1.fqn > .in-band > a:hover {
        text-decoration: underline;
 }
 h2, h3:not(.impl):not(.method):not(.type):not(.tymethod),
-h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant) {
+h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant):not(.associatedtype) {
        border-bottom: 1px solid;
 }
-h3.impl, h3.method, h4.method, h3.type, h4.type, h4.associatedconstant {
+h3.impl, h3.method, h4.method, h3.type, h4.type, h4.associatedconstant, h4.associatedtype {
        flex-basis: 100%;
        font-weight: 600;
        margin-top: 16px;
@@ -139,7 +139,7 @@ h3.impl, h3.method, h4.method, h3.type, h4.type, h4.associatedconstant {
        position: relative;
 }
 h3.impl, h3.method, h4.method.trait-impl, h3.type,
-h4.type.trait-impl, h4.associatedconstant.trait-impl {
+h4.type.trait-impl, h4.associatedconstant.trait-impl, h4.associatedtype.trait-impl {
        padding-left: 15px;
 }
 
@@ -147,6 +147,9 @@ h1, h2, h3, h4,
 .sidebar, a.source, .search-input, .content table td:first-child > a,
 .collapse-toggle, div.item-list .out-of-band,
 #source-sidebar, #sidebar-toggle,
+details.rustdoc-toggle > summary::before,
+details.undocumented > summary::before,
+.content ul.crate a.crate,
 /* This selector is for the items listed in the "all items" page. */
 #main > ul.docblock > li > a {
        font-family: "Fira Sans", Arial, sans-serif;
@@ -154,7 +157,6 @@ h1, h2, h3, h4,
 
 .content ul.crate a.crate {
        font-size: 16px/1.6;
-       font-family: "Fira Sans", Arial, sans-serif;
 }
 
 ol, ul {
@@ -596,7 +598,10 @@ h4 > code, h3 > code, .invisible > code {
        left: -19px;
 }
 
-.content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant {
+.content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant,
+.impl-items > .associatedtype, .content .impl-items details > summary > .type,
+.impl-items details > summary > .associatedconstant,
+.impl-items details > summary > .associatedtype {
        margin-left: 20px;
 }
 
@@ -656,7 +661,8 @@ a {
 }
 
 .in-band:hover > .anchor, .impl:hover > .anchor, .method.trait-impl:hover > .anchor,
-.type.trait-impl:hover > .anchor, .associatedconstant.trait-impl:hover > .anchor {
+.type.trait-impl:hover > .anchor, .associatedconstant.trait-impl:hover > .anchor,
+.associatedtype.trait-impl:hover > .anchor {
        display: inline-block;
        position: absolute;
 }
@@ -1466,7 +1472,8 @@ h4 > .notable-traits {
                margin-left: 0;
        }
 
-       .content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant {
+       .content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant,
+       .impl-items > .associatedtype {
                display: flex;
        }
 
@@ -1764,7 +1771,10 @@ details.rustdoc-toggle > summary.hideme {
        cursor: pointer;
 }
 
-details.rustdoc-toggle > summary::-webkit-details-marker {
+details.rustdoc-toggle > summary::-webkit-details-marker,
+details.rustdoc-toggle > summary::marker,
+details.undocumented > summary::-webkit-details-marker,
+details.undocumented > summary::marker {
        display: none;
 }
 
@@ -1787,6 +1797,14 @@ details.rustdoc-toggle > summary.hideme::before {
 details.rustdoc-toggle > summary:not(.hideme)::before {
        position: absolute;
        left: -23px;
+       top: initial;
+}
+
+.impl-items > details.rustdoc-toggle > summary:not(.hideme)::before,
+.undocumented > details.rustdoc-toggle > summary:not(.hideme)::before {
+       position: absolute;
+       top: 3px;
+       left: -2px;
 }
 
 /* When a "hideme" summary is open and the "Expand description" or "Show
@@ -1798,7 +1816,7 @@ details.rustdoc-toggle[open] > summary.hideme {
        position: absolute;
 }
 
-details.rustdoc-toggle[open] {
+details.rustdoc-toggle, details.undocumented {
        position: relative;
 }
 
@@ -1810,3 +1828,14 @@ details.rustdoc-toggle[open] > summary::before {
        content: "[−]";
        display: inline;
 }
+
+details.undocumented > summary::before {
+       content: "[+] Show hidden undocumented items";
+       cursor: pointer;
+       font-size: 16px;
+       font-weight: 300;
+}
+
+details.undocumented[open] > summary::before {
+       content: "[-] Hide undocumented items";
+}
index 72396ec6b76bd936d7647b916b92ee8287165e5f..aace0b3c037caf6be61d86ed5f3b9485ef0d0dec 100644 (file)
@@ -226,7 +226,8 @@ a {
 
 .collapse-toggle,
 details.rustdoc-toggle > summary.hideme > span,
-details.rustdoc-toggle > summary::before {
+details.rustdoc-toggle > summary::before,
+details.undocumented > summary::before {
        color: #999;
 }
 
index b2003b5274120c6237c1fd05de865a2ecb3e42cc..c23e95ce107a9431410efedb309d947a72225d65 100644 (file)
@@ -188,7 +188,8 @@ a.test-arrow {
 
 .collapse-toggle,
 details.rustdoc-toggle > summary.hideme > span,
-details.rustdoc-toggle > summary::before {
+details.rustdoc-toggle > summary::before,
+details.undocumented > summary::before {
        color: #999;
 }
 
index 04187773b64db85b6feb8b4af1e705bad406f4fa..9330972121073b31b29705c793f806748b94af38 100644 (file)
@@ -186,7 +186,8 @@ a.test-arrow {
 
 .collapse-toggle,
 details.rustdoc-toggle > summary.hideme > span,
-details.rustdoc-toggle > summary::before {
+details.rustdoc-toggle > summary::before,
+details.undocumented > summary::before {
        color: #999;
 }
 
index bb6af7995a0ad15445befc2c4d13c552421c239d..7bfa922185b77cfd436cade0dc3db9e718723ece 100644 (file)
@@ -88,12 +88,14 @@ impl Qux for Bar {
     /// Docs for QUX1 in impl.
     const QUX1: i8 = 5;
     // @has - '//*[@id="associatedconstant.QUX_DEFAULT0"]' 'const QUX_DEFAULT0: u16'
-    // @has - '//*[@class="docblock hidden"]' "Docs for QUX_DEFAULT12 in trait."
+    // @!has - '//div[@class="impl-items"]/details[@open=""]//*[@class="docblock"]' "Docs for QUX_DEFAULT12 in trait."
+    // @has - '//div[@class="impl-items"]/details//*[@class="docblock"]' "Docs for QUX_DEFAULT12 in trait."
     const QUX_DEFAULT0: u16 = 6;
     // @has - '//*[@id="associatedconstant.QUX_DEFAULT1"]' 'const QUX_DEFAULT1: i16'
     // @has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT1 in impl."
     /// Docs for QUX_DEFAULT1 in impl.
     const QUX_DEFAULT1: i16 = 7;
     // @has - '//*[@id="associatedconstant.QUX_DEFAULT2"]' 'const QUX_DEFAULT2: u32'
-    // @has - '//*[@class="docblock hidden"]' "Docs for QUX_DEFAULT2 in trait."
+    // @!has - '//div[@class="impl-items"]/details[@open=""]//*[@class="docblock"]' "Docs for QUX_DEFAULT2 in trait."
+    // @has - '//div[@class="impl-items"]/details//*[@class="docblock"]' "Docs for QUX_DEFAULT2 in trait."
 }
diff --git a/src/test/rustdoc/auxiliary/trait-alias-mention.rs b/src/test/rustdoc/auxiliary/trait-alias-mention.rs
new file mode 100644 (file)
index 0000000..6df06c8
--- /dev/null
@@ -0,0 +1,3 @@
+#![feature(trait_alias)]
+
+pub trait SomeAlias = std::fmt::Debug + std::marker::Copy;
diff --git a/src/test/rustdoc/auxiliary/trait-visibility.rs b/src/test/rustdoc/auxiliary/trait-visibility.rs
new file mode 100644 (file)
index 0000000..1e8d0b8
--- /dev/null
@@ -0,0 +1,3 @@
+pub trait Bar {
+    fn foo();
+}
index 7eb3e43cb114e0b0779d55d904efe9b64ad3206d..8fc01c3f04cda4be143634107d39ec87481d566c 100644 (file)
 // @has - '//*[@id="associatedconstant.ConstNoDefault"]' 'const ConstNoDefault: i16'
 // @has - '//*[@class="docblock"]' 'dox for ConstNoDefault'
 // @has - '//*[@id="associatedconstant.ConstWithDefault"]' 'const ConstWithDefault: u16'
-// @has - '//*[@class="docblock hidden"]' 'docs for ConstWithDefault'
+// @!has - '//details[@open=""]/details/div[@class="docblock"]' 'docs for ConstWithDefault'
+// @has - '//details/details/div[@class="docblock"]' 'docs for ConstWithDefault'
 // @has - '//*[@id="associatedtype.TypeNoDefault"]' 'type TypeNoDefault = i32'
 // @has - '//*[@class="docblock"]' 'dox for TypeNoDefault'
 // @has - '//*[@id="associatedtype.TypeWithDefault"]' 'type TypeWithDefault = u32'
-// @has - '//*[@class="docblock hidden"]' 'docs for TypeWithDefault'
+// @!has - '//details[@open=""]/details/div[@class="docblock"]' 'docs for TypeWithDefault'
+// @has - '//details/details/div[@class="docblock"]' 'docs for TypeWithDefault'
 // @has - '//*[@id="method.method_no_default"]' 'fn method_no_default()'
 // @has - '//*[@class="docblock"]' 'dox for method_no_default'
 // @has - '//*[@id="method.method_with_default"]' 'fn method_with_default()'
-// @has - '//*[@class="docblock hidden"]' 'docs for method_with_default'
+// @!has - '//details[@open=""]/details/div[@class="docblock"]' 'docs for method_with_default'
+// @has - '//details/details/div[@class="docblock"]' 'docs for method_with_default'
 pub use assoc_items::MyStruct;
 
 // @has foo/trait.MyTrait.html
index 4591bb526ae77424d4e229049f3bb5b20255ce7b..cc0596c70ced736fafb76bf0a67535ec436c1a00 100644 (file)
@@ -8,5 +8,6 @@
 
 // @has 'foo/struct.MyStruct.html'
 // @has - '//*[@id="method.my_trait_method"]' 'fn my_trait_method()'
-// @has - '//*[@class="docblock hidden"]' 'docs for my_trait_method'
+// @!has - '//details[@open=""]/details/div[@class="docblock"]' 'docs for my_trait_method'
+// @has - '//details/details/div[@class="docblock"]' 'docs for my_trait_method'
 pub use impl_inline_without_trait::MyStruct;
index 11ddab5f7ff26a3f65131ff0bd2ca690a575369f..776a191ceefb35308268ed23c6379b35883feefe 100644 (file)
@@ -24,10 +24,13 @@ fn c_method(&self) -> usize {
 // @has  - '//*[@class="docblock"]' 'Docs associated with the S1 trait implementation.'
 // @has  - '//*[@class="docblock"]' 'Docs associated with the S1 trait a_method implementation.'
 // @!has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.'
-// @has - '//*[@class="docblock hidden"]' 'Docs associated with the trait b_method definition.'
-// @has - '//*[@class="docblock hidden"]' 'Docs associated with the trait c_method definition.'
+// @!has - '//div[@class="impl-items"]/details[@open=""]//div[@class="docblock"]' 'Docs associated with the trait b_method definition.'
+// @has - '//div[@class="impl-items"]/details//div[@class="docblock"]' 'Docs associated with the trait b_method definition.'
+// @!has - '//div[@class="impl-items"]/details[@open=""]//div[@class="docblock"]' 'Docs associated with the trait c_method definition.'
+// @has - '//div[@class="impl-items"]/details//div[@class="docblock"]' 'Docs associated with the trait c_method definition.'
 // @!has - '//*[@class="docblock"]' 'There is another line'
-// @has - '//*[@class="docblock hidden"]' 'Read more'
+// @!has - '//div[@class="impl-items"]/details[@open=""]//div[@class="docblock"]' 'Read more'
+// @has - '//div[@class="impl-items"]/details//div[@class="docblock"]' 'Read more'
 pub struct S1(usize);
 
 /// Docs associated with the S1 trait implementation.
@@ -42,9 +45,10 @@ fn a_method(&self) -> usize {
 // @has  - '//*[@class="docblock"]' 'Docs associated with the S2 trait implementation.'
 // @has  - '//*[@class="docblock"]' 'Docs associated with the S2 trait a_method implementation.'
 // @has  - '//*[@class="docblock"]' 'Docs associated with the S2 trait c_method implementation.'
-// @!has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.'
-// @!has - '//*[@class="docblock"]' 'Docs associated with the trait c_method definition.'
-// @has - '//*[@class="docblock hidden"]' 'Docs associated with the trait b_method definition.'
+// @!has - '//details[open=""]/div[@class="docblock"]' 'Docs associated with the trait a_method definition.'
+// @!has - '//details[open=""]/div[@class="docblock"]' 'Docs associated with the trait c_method definition.'
+// @!has - '//div[@class="impl-items"]/details[@open=""]//div[@class="docblock"]' 'Docs associated with the trait b_method definition.'
+// @has - '//div[@class="impl-items"]/details//div[@class="docblock"]' 'Docs associated with the trait b_method definition.'
 pub struct S2(usize);
 
 /// Docs associated with the S2 trait implementation.
@@ -61,9 +65,10 @@ fn c_method(&self) -> usize {
 }
 
 // @has manual_impl/struct.S3.html '//*[@class="trait"]' 'T'
-// @has  - '//*[@class="docblock"]' 'Docs associated with the S3 trait implementation.'
-// @has  - '//*[@class="docblock"]' 'Docs associated with the S3 trait b_method implementation.'
-// @has - '//*[@class="docblock hidden"]' 'Docs associated with the trait a_method definition.'
+// @has  - '//details[@open=""]/div[@class="docblock"]' 'Docs associated with the S3 trait implementation.'
+// @has  - '//details[@open=""]/div[@class="docblock"]' 'Docs associated with the S3 trait b_method implementation.'
+// @!has - '//div[@class="impl-items"]/details[@open=""]//div[@class="docblock"]' 'Docs associated with the trait a_method definition.'
+// @has - '//div[@class="impl-items"]/details//div[@class="docblock"]' 'Docs associated with the trait a_method definition.'
 pub struct S3(usize);
 
 /// Docs associated with the S3 trait implementation.
diff --git a/src/test/rustdoc/trait-alias-mention.rs b/src/test/rustdoc/trait-alias-mention.rs
new file mode 100644 (file)
index 0000000..6da0dc6
--- /dev/null
@@ -0,0 +1,10 @@
+// aux-build:trait-alias-mention.rs
+// build-aux-docs
+
+#![crate_name = "foo"]
+
+extern crate trait_alias_mention;
+
+// @has foo/fn.mention_alias_in_bounds.html '//a[@href="../trait_alias_mention/traitalias.SomeAlias.html"]' 'SomeAlias'
+pub fn mention_alias_in_bounds<T: trait_alias_mention::SomeAlias>() {
+}
index 3bcaa3bb673139956d3681eaa6c7aaf7ea06e781..931691db3e6d9a3d7fa5e4c379a82f8f2da6d1c4 100644 (file)
@@ -21,26 +21,27 @@ pub trait Trait {
 pub struct Struct;
 
 impl Trait for Struct {
-    // @has trait_impl/struct.Struct.html '//*[@id="method.a"]/../div/p' 'Some long docs'
-    // @!has - '//*[@id="method.a"]/../div/p' 'link will be added'
-    // @has - '//*[@id="method.a"]/../div/p/a' 'Read more'
-    // @has - '//*[@id="method.a"]/../div/p/a/@href' 'trait.Trait.html'
+    // @has trait_impl/struct.Struct.html '//*[@id="method.a"]/../../div[@class="docblock"]/p' 'Some long docs'
+    // @!has - '//*[@id="method.a"]/../../div[@class="docblock"]/p' 'link will be added'
+    // @has - '//*[@id="method.a"]/../../div[@class="docblock"]/p/a' 'Read more'
+    // @has - '//*[@id="method.a"]/../../div[@class="docblock"]/p/a/@href' 'trait.Trait.html#tymethod.a'
     fn a() {}
 
-    // @has trait_impl/struct.Struct.html '//*[@id="method.b"]/../div/p' 'These docs contain'
-    // @has - '//*[@id="method.b"]/../div/p/a' 'reference link'
-    // @has - '//*[@id="method.b"]/../div/p/a/@href' 'https://example.com'
-    // @has - '//*[@id="method.b"]/../div/p/a' 'Read more'
-    // @has - '//*[@id="method.b"]/../div/p/a/@href' 'trait.Trait.html'
+    // @has - '//*[@id="method.b"]/../../div[@class="docblock"]/p' 'These docs contain'
+    // @has - '//*[@id="method.b"]/../../div[@class="docblock"]/p/a' 'reference link'
+    // @has - '//*[@id="method.b"]/../../div[@class="docblock"]/p/a/@href' 'https://example.com'
+    // @has - '//*[@id="method.b"]/../../div[@class="docblock"]/p/a' 'Read more'
+    // @has - '//*[@id="method.b"]/../../div[@class="docblock"]/p/a/@href' 'trait.Trait.html#tymethod.b'
     fn b() {}
 
-    // @!has trait_impl/struct.Struct.html '//*[@id="method.c"]/../div/p' 'code block'
-    // @has - '//*[@id="method.c"]/../div/p/a' 'Read more'
-    // @has - '//*[@id="method.c"]/../div/p/a/@href' 'trait.Trait.html'
+    // @!has - '//*[@id="method.c"]/../../div[@class="docblock"]/p' 'code block'
+    // @has - '//*[@id="method.c"]/../../div[@class="docblock"]/a' 'Read more'
+    // @has - '//*[@id="method.c"]/../../div[@class="docblock"]/a/@href' 'trait.Trait.html#tymethod.c'
     fn c() {}
 
-    // @has trait_impl/struct.Struct.html '//*[@id="method.d"]/../div/p' \
-    //   'Escaped formatting a*b*c* works'
-    // @!has trait_impl/struct.Struct.html '//*[@id="method.d"]/../div/p/em'
+    // @has - '//*[@id="method.d"]/../../div[@class="docblock"]/p' 'Escaped formatting a*b*c* works'
+    // @!has - '//*[@id="method.d"]/../../div[@class="docblock"]/p/em'
     fn d() {}
+
+    // @has - '//*[@id="impl-Trait"]/code/a/@href' 'trait.Trait.html'
 }
diff --git a/src/test/rustdoc/trait-visibility.rs b/src/test/rustdoc/trait-visibility.rs
new file mode 100644 (file)
index 0000000..8ba3ee0
--- /dev/null
@@ -0,0 +1,8 @@
+// aux-build:trait-visibility.rs
+
+#![crate_name = "foo"]
+
+extern crate trait_visibility;
+
+// @has foo/trait.Bar.html '//a[@href="#tymethod.foo"]/..' "fn foo()"
+pub use trait_visibility::Bar;
index 98b8d879ac078da3f39cfe50ff59acc8a0ee529f..6cd4a1a0afa085e89f210d1c46138fda15f1194a 100644 (file)
@@ -19,3 +19,5 @@
 pub trait Alias2 = Copy + Debug;
 // @has foo/traitalias.Foo.html '//section[@id="main"]/pre' 'trait Foo<T> = Into<T> + Debug;'
 pub trait Foo<T> = Into<T> + Debug;
+// @has foo/fn.bar.html '//a[@href="traitalias.Alias2.html"]' 'Alias2'
+pub fn bar<T>() where T: Alias2 {}
index 912bda4b5e5000af10f9072de419b363f2781a8c..c7d196a2aa6eba992610f4ea1319b68450f37a99 100644 (file)
@@ -1,6 +1,6 @@
-// run-pass
+// build-pass
 // pretty-expanded FIXME #23616
-// ignore-wasm32-bare no target_family
+// ignore-wasm32-bare no bare family
 // ignore-sgx
 
 #[cfg(windows)]
index b4dc1b738638c0b2657989bdec5f58a29f460b72..90a59fab8e250b7c2808e21492146600abf425b5 100644 (file)
@@ -1,5 +1,4 @@
-// run-pass
-// ignore-wasm32-bare no target_family
+// build-pass
 // ignore-sgx
 
 // pretty-expanded FIXME #23616
@@ -11,3 +10,7 @@ pub fn main() {
 #[cfg(target_family = "unix")]
 pub fn main() {
 }
+
+#[cfg(target_family="wasm")]
+pub fn main() {
+}
index a83ee627187b52e5577ee95e0e21f0ede4d84747..32f7dea82639b70d41221a97d7c30205a7677ebe 100644 (file)
@@ -11,6 +11,7 @@ LL | pub struct Dependent<T, const X: T>([(); X]);
    |                      ^ unused parameter
    |
    = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
+   = help: if you intended `T` to be a const parameter, use `const T: usize` instead
 
 error: aborting due to 2 previous errors
 
index a83ee627187b52e5577ee95e0e21f0ede4d84747..32f7dea82639b70d41221a97d7c30205a7677ebe 100644 (file)
@@ -11,6 +11,7 @@ LL | pub struct Dependent<T, const X: T>([(); X]);
    |                      ^ unused parameter
    |
    = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
+   = help: if you intended `T` to be a const parameter, use `const T: usize` instead
 
 error: aborting due to 2 previous errors
 
index 2f004f75de56c67974c5096cf6c0af559a3c4433..0fe65272f1b78d0bea6437c2da47606da92fc59d 100644 (file)
@@ -15,6 +15,7 @@ LL | struct Bug<T> {
    |            ^ unused parameter
    |
    = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
+   = help: if you intended `T` to be a const parameter, use `const T: usize` instead
 
 error: aborting due to previous error; 1 warning emitted
 
index 337e7bc14099d5bcaf4c912168da65da9e0cd9e6..be81fa921297b2a67ffa0ed00d89a2c4ed011318 100644 (file)
@@ -14,6 +14,7 @@ LL | struct Bug<T> {
    |            ^ unused parameter
    |
    = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
+   = help: if you intended `T` to be a const parameter, use `const T: usize` instead
 
 error: aborting due to 2 previous errors
 
index 5cdcefe35015f542d169231d05be2bda5501490b..63c50b5ca542387bc5058f9b94c222a2314e313c 100644 (file)
@@ -19,6 +19,7 @@ LL | struct Bug<S> {
    |            ^ unused parameter
    |
    = help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData`
+   = help: if you intended `S` to be a const parameter, use `const S: usize` instead
 
 error: aborting due to 2 previous errors
 
index a3e086ea95486709445809cce14c07949227285e..074d36c8ef3ed2d41a3894f4115f7636fac0c387 100644 (file)
@@ -23,6 +23,7 @@ LL | struct Bug<S> {
    |            ^ unused parameter
    |
    = help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData`
+   = help: if you intended `S` to be a const parameter, use `const S: usize` instead
 
 error: aborting due to 3 previous errors
 
index 4d96058b395b2188317ca1594320b3fa9187b485..b900406023117111434003fc8c6cf261bd131300 100644 (file)
@@ -19,6 +19,7 @@ LL | struct Bug<S> {
    |            ^ unused parameter
    |
    = help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData`
+   = help: if you intended `S` to be a const parameter, use `const S: usize` instead
 
 error: aborting due to 2 previous errors
 
index 860be4a9b6ac91efe8aa07b4b053b51763789945..c06df79f8428c51a3b3da3e8ea9cafd31b319bb6 100644 (file)
@@ -23,6 +23,7 @@ LL | struct Bug<S> {
    |            ^ unused parameter
    |
    = help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData`
+   = help: if you intended `S` to be a const parameter, use `const S: usize` instead
 
 error: aborting due to 3 previous errors
 
diff --git a/src/test/ui/const-generics/unused-type-param-suggestion.rs b/src/test/ui/const-generics/unused-type-param-suggestion.rs
new file mode 100644 (file)
index 0000000..2251512
--- /dev/null
@@ -0,0 +1,4 @@
+#![crate_type="lib"]
+
+struct Example<N>;
+//~^ ERROR parameter
diff --git a/src/test/ui/const-generics/unused-type-param-suggestion.stderr b/src/test/ui/const-generics/unused-type-param-suggestion.stderr
new file mode 100644 (file)
index 0000000..807065c
--- /dev/null
@@ -0,0 +1,12 @@
+error[E0392]: parameter `N` is never used
+  --> $DIR/unused-type-param-suggestion.rs:3:16
+   |
+LL | struct Example<N>;
+   |                ^ unused parameter
+   |
+   = help: consider removing `N`, referring to it in a field, or using a marker such as `PhantomData`
+   = help: if you intended `N` to be a const parameter, use `const N: usize` instead
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0392`.
index 8ee14a3d01d899ccde72f5d933f0d85b55f5c15b..a704e1fae497cb0065dc867d0a29d43214806921 100644 (file)
 error[E0532]: expected tuple struct or tuple variant, found unit struct `Empty2`
   --> $DIR/empty-struct-unit-pat.rs:21:9
    |
+LL | struct Empty2;
+   | -------------- `Empty2` defined here
+...
 LL |         Empty2() => ()
-   |         ^^^^^^ help: a tuple struct with a similar name exists: `XEmpty6`
+   |         ^^^^^^^^
    | 
   ::: $DIR/auxiliary/empty-struct.rs:3:1
    |
 LL | pub struct XEmpty6();
    | --------------------- similarly named tuple struct `XEmpty6` defined here
+   |
+help: use this syntax instead
+   |
+LL |         Empty2 => ()
+   |         ^^^^^^
+help: a tuple struct with a similar name exists
+   |
+LL |         XEmpty6() => ()
+   |         ^^^^^^^
 
 error[E0532]: expected tuple struct or tuple variant, found unit struct `XEmpty2`
   --> $DIR/empty-struct-unit-pat.rs:24:9
    |
 LL |         XEmpty2() => ()
-   |         ^^^^^^^ help: a tuple struct with a similar name exists: `XEmpty6`
+   |         ^^^^^^^^^
    | 
-  ::: $DIR/auxiliary/empty-struct.rs:3:1
+  ::: $DIR/auxiliary/empty-struct.rs:2:1
    |
+LL | pub struct XEmpty2;
+   | ------------------- `XEmpty2` defined here
 LL | pub struct XEmpty6();
    | --------------------- similarly named tuple struct `XEmpty6` defined here
+   |
+help: use this syntax instead
+   |
+LL |         XEmpty2 => ()
+   |         ^^^^^^^
+help: a tuple struct with a similar name exists
+   |
+LL |         XEmpty6() => ()
+   |         ^^^^^^^
 
 error[E0532]: expected tuple struct or tuple variant, found unit struct `Empty2`
   --> $DIR/empty-struct-unit-pat.rs:28:9
    |
+LL | struct Empty2;
+   | -------------- `Empty2` defined here
+...
 LL |         Empty2(..) => ()
-   |         ^^^^^^ help: a tuple struct with a similar name exists: `XEmpty6`
+   |         ^^^^^^^^^^
    | 
   ::: $DIR/auxiliary/empty-struct.rs:3:1
    |
 LL | pub struct XEmpty6();
    | --------------------- similarly named tuple struct `XEmpty6` defined here
+   |
+help: use this syntax instead
+   |
+LL |         Empty2 => ()
+   |         ^^^^^^
+help: a tuple struct with a similar name exists
+   |
+LL |         XEmpty6(..) => ()
+   |         ^^^^^^^
 
 error[E0532]: expected tuple struct or tuple variant, found unit struct `XEmpty2`
   --> $DIR/empty-struct-unit-pat.rs:32:9
    |
 LL |         XEmpty2(..) => ()
-   |         ^^^^^^^ help: a tuple struct with a similar name exists: `XEmpty6`
+   |         ^^^^^^^^^^^
    | 
-  ::: $DIR/auxiliary/empty-struct.rs:3:1
+  ::: $DIR/auxiliary/empty-struct.rs:2:1
    |
+LL | pub struct XEmpty2;
+   | ------------------- `XEmpty2` defined here
 LL | pub struct XEmpty6();
    | --------------------- similarly named tuple struct `XEmpty6` defined here
+   |
+help: use this syntax instead
+   |
+LL |         XEmpty2 => ()
+   |         ^^^^^^^
+help: a tuple struct with a similar name exists
+   |
+LL |         XEmpty6(..) => ()
+   |         ^^^^^^^
 
 error[E0532]: expected tuple struct or tuple variant, found unit variant `E::Empty4`
   --> $DIR/empty-struct-unit-pat.rs:37:9
    |
+LL |     Empty4
+   |     ------ `E::Empty4` defined here
+...
 LL |         E::Empty4() => ()
-   |         ^^^^^^^^^ not a tuple struct or tuple variant
+   |         ^^^^^^^^^^^ help: use this syntax instead: `E::Empty4`
 
 error[E0532]: expected tuple struct or tuple variant, found unit variant `XE::XEmpty4`
   --> $DIR/empty-struct-unit-pat.rs:41:9
    |
 LL |         XE::XEmpty4() => (),
-   |         ^^^^-------
-   |             |
-   |             help: a tuple variant with a similar name exists: `XEmpty5`
+   |         ^^^^^^^^^^^^^
    | 
-  ::: $DIR/auxiliary/empty-struct.rs:8:5
+  ::: $DIR/auxiliary/empty-struct.rs:7:5
    |
+LL |     XEmpty4,
+   |     ------- `XE::XEmpty4` defined here
 LL |     XEmpty5(),
    |     --------- similarly named tuple variant `XEmpty5` defined here
+   |
+help: use this syntax instead
+   |
+LL |         XE::XEmpty4 => (),
+   |         ^^^^^^^^^^^
+help: a tuple variant with a similar name exists
+   |
+LL |         XE::XEmpty5() => (),
+   |             ^^^^^^^
 
 error[E0532]: expected tuple struct or tuple variant, found unit variant `E::Empty4`
   --> $DIR/empty-struct-unit-pat.rs:46:9
    |
+LL |     Empty4
+   |     ------ `E::Empty4` defined here
+...
 LL |         E::Empty4(..) => ()
-   |         ^^^^^^^^^ not a tuple struct or tuple variant
+   |         ^^^^^^^^^^^^^ help: use this syntax instead: `E::Empty4`
 
 error[E0532]: expected tuple struct or tuple variant, found unit variant `XE::XEmpty4`
   --> $DIR/empty-struct-unit-pat.rs:50:9
    |
 LL |         XE::XEmpty4(..) => (),
-   |         ^^^^-------
-   |             |
-   |             help: a tuple variant with a similar name exists: `XEmpty5`
+   |         ^^^^^^^^^^^^^^^
    | 
-  ::: $DIR/auxiliary/empty-struct.rs:8:5
+  ::: $DIR/auxiliary/empty-struct.rs:7:5
    |
+LL |     XEmpty4,
+   |     ------- `XE::XEmpty4` defined here
 LL |     XEmpty5(),
    |     --------- similarly named tuple variant `XEmpty5` defined here
+   |
+help: use this syntax instead
+   |
+LL |         XE::XEmpty4 => (),
+   |         ^^^^^^^^^^^
+help: a tuple variant with a similar name exists
+   |
+LL |         XE::XEmpty5(..) => (),
+   |             ^^^^^^^
 
 error: aborting due to 8 previous errors
 
index 1d43903928bef7394c2e5156289d5afd549c1935..f89be630eeb30c7746fbedbecfb2a6f28e8a8407 100644 (file)
@@ -14,6 +14,7 @@ LL | enum MyWeirdOption<T> {
    |                    ^ unused parameter
    |
    = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
+   = help: if you intended `T` to be a const parameter, use `const T: usize` instead
 
 error: aborting due to 2 previous errors
 
index 32ca94203e630ce935a36927a0384ee4f56616ac..227899e75350f3ed155d2640315c2b61b02764df 100644 (file)
@@ -14,6 +14,7 @@ LL | enum Bug<S> {
    |          ^ unused parameter
    |
    = help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData`
+   = help: if you intended `S` to be a const parameter, use `const S: usize` instead
 
 error: aborting due to 2 previous errors
 
index a738d3b15a5574d803e706b4d2b451b9b18d6d2f..5a90f00c346d0de0f44b8d131f96592318e836a1 100644 (file)
@@ -14,6 +14,7 @@ LL | enum Bug<S> {
    |          ^ unused parameter
    |
    = help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData`
+   = help: if you intended `S` to be a const parameter, use `const S: usize` instead
 
 error: aborting due to 2 previous errors
 
index 860bf68f0189b5f7de115258c790317f607f4dc7..622402999c348b11d5167b4d55681a81127ce7c0 100644 (file)
@@ -5,6 +5,7 @@ LL | enum Foo<T> { Bar }
    |          ^ unused parameter
    |
    = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
+   = help: if you intended `T` to be a const parameter, use `const T: usize` instead
 
 error: aborting due to previous error
 
index 990e4649a5817321cd28830cd00e4215bc898a96..e4e449e4159b6b8067e5be8ad38ba817fe904455 100644 (file)
@@ -13,6 +13,7 @@ LL | enum Bar<T> { What }
    |          ^ unused parameter
    |
    = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
+   = help: if you intended `T` to be a const parameter, use `const T: usize` instead
 
 error: aborting due to 2 previous errors
 
index 62b7b79538c612c9ff3a8767acf1bcc8172bf652..259e029113d5097cf0a14e0ad6ab74de17c66c50 100644 (file)
@@ -5,6 +5,7 @@ LL | struct Foo<T> where T: Copy;
    |            ^ unused parameter
    |
    = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
+   = help: if you intended `T` to be a const parameter, use `const T: usize` instead
 
 error: aborting due to previous error
 
index 7fb1e3f2bba4f9db7f63cad177db4e371c1bc598..6bcff7aff2dc4fa59982c14a7299c509ce1dfb0d 100644 (file)
@@ -5,6 +5,7 @@ LL | struct NoData<T>;
    |               ^ unused parameter
    |
    = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
+   = help: if you intended `T` to be a const parameter, use `const T: usize` instead
 
 error[E0275]: overflow evaluating the requirement `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Foo`
   --> $DIR/issue-20413.rs:8:36
index f95afb9c1fdc76cbea779302c4d934920896de5f..bf125a8942edf904636de5c92da05a30865db05a 100644 (file)
@@ -21,8 +21,11 @@ LL |         Foo::Baz => {}
 error[E0532]: expected tuple struct or tuple variant, found unit struct `S`
   --> $DIR/issue-32004.rs:16:9
    |
+LL | struct S;
+   | --------- `S` defined here
+...
 LL |         S(()) => {}
-   |         ^ not a tuple struct or tuple variant
+   |         ^^^^^ help: use this syntax instead: `S`
 
 error: aborting due to 2 previous errors
 
index 8e29a925d8044dad8c74de52f1ae538a9200d247..dc24fb353f408069dfe673c7bc3d98f97c62b2ac 100644 (file)
@@ -13,6 +13,7 @@ LL | struct Foo<'a, A> {}
    |                ^ unused parameter
    |
    = help: consider removing `A`, referring to it in a field, or using a marker such as `PhantomData`
+   = help: if you intended `A` to be a const parameter, use `const A: usize` instead
 
 error: aborting due to 2 previous errors
 
index e5d6f8ec7adebec3a961e7c2f6a9c3f4411786a1..733fc4af534f76477e57ed97521527cc8a823be0 100644 (file)
@@ -17,6 +17,7 @@ LL | struct Foo<Self>(Self);
    |            ^^^^ unused parameter
    |
    = help: consider removing `Self`, referring to it in a field, or using a marker such as `PhantomData`
+   = help: if you intended `Self` to be a const parameter, use `const Self: usize` instead
 
 error: aborting due to 3 previous errors
 
index 895479986f1d1a0323d5ee3cd305ed33f2ce2f74..82bb51028c9774d84dd478fc43268fe6cf2cbcaf 100644 (file)
@@ -22,6 +22,7 @@ LL | struct Foo<T: ?Hash> { }
    |            ^ unused parameter
    |
    = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
+   = help: if you intended `T` to be a const parameter, use `const T: usize` instead
 
 error: aborting due to 2 previous errors; 1 warning emitted
 
index e92fd6c2fdc5ac97e799fe83f0723447e5507fa7..57783d75ba182e1c81448782ffc2a8231e4cb150 100644 (file)
@@ -1,14 +1,20 @@
 error[E0532]: expected tuple struct or tuple variant, found unit variant `E::A`
   --> $DIR/issue-pr29383.rs:9:14
    |
+LL |     A,
+   |     - `E::A` defined here
+...
 LL |         Some(E::A(..)) => {}
-   |              ^^^^ not a tuple struct or tuple variant
+   |              ^^^^^^^^ help: use this syntax instead: `E::A`
 
 error[E0532]: expected tuple struct or tuple variant, found unit variant `E::B`
   --> $DIR/issue-pr29383.rs:11:14
    |
+LL |     B,
+   |     - `E::B` defined here
+...
 LL |         Some(E::B(..)) => {}
-   |              ^^^^ not a tuple struct or tuple variant
+   |              ^^^^^^^^ help: use this syntax instead: `E::B`
 
 error: aborting due to 2 previous errors
 
index cfffcd13851b8fcb355deadb217561d878b484a2..ba32d0e99a47165c06007adb4f55a926c22976f0 100644 (file)
@@ -1,8 +1,11 @@
 error[E0532]: expected tuple struct or tuple variant, found unit variant `Color::NoColor`
   --> $DIR/match-pattern-field-mismatch-2.rs:12:11
    |
+LL |         NoColor,
+   |         ------- `Color::NoColor` defined here
+...
 LL |           Color::NoColor(_) => { }
-   |           ^^^^^^^^^^^^^^ not a tuple struct or tuple variant
+   |           ^^^^^^^^^^^^^^^^^ help: use this syntax instead: `Color::NoColor`
 
 error: aborting due to previous error
 
index 497c93b29497cc6079d7cb70143b138844f727dc..44d6a854b3db6d90ddc35f48484c2f66566660e6 100644 (file)
@@ -9,11 +9,21 @@ error[E0532]: expected tuple struct or tuple variant, found unit variant `A::D`
    |
 LL |     B(isize, isize),
    |     --------------- similarly named tuple variant `B` defined here
+LL |     C(isize, isize, isize),
+LL |     D
+   |     - `A::D` defined here
 ...
 LL |         A::D(_) => (),
-   |         ^^^-
-   |            |
-   |            help: a tuple variant with a similar name exists: `B`
+   |         ^^^^^^^
+   |
+help: use this syntax instead
+   |
+LL |         A::D => (),
+   |         ^^^^
+help: a tuple variant with a similar name exists
+   |
+LL |         A::B(_) => (),
+   |            ^
 
 error[E0023]: this pattern has 3 fields, but the corresponding tuple variant has 2 fields
   --> $DIR/pattern-error-continue.rs:17:9
diff --git a/src/test/ui/suggestions/issue-84700.rs b/src/test/ui/suggestions/issue-84700.rs
new file mode 100644 (file)
index 0000000..a27169f
--- /dev/null
@@ -0,0 +1,26 @@
+// test for suggestion on fieldless enum variant
+
+#[derive(PartialEq, Debug)]
+enum FarmAnimal {
+    Worm,
+    Cow,
+    Bull,
+    Chicken { num_eggs: usize },
+    Dog (String),
+}
+
+fn what_does_the_animal_say(animal: &FarmAnimal) {
+
+    let noise = match animal {
+        FarmAnimal::Cow(_) => "moo".to_string(),
+        //~^ ERROR expected tuple struct or tuple variant, found unit variant `FarmAnimal::Cow`
+        FarmAnimal::Chicken(_) => "cluck, cluck!".to_string(),
+        //~^ ERROR expected tuple struct or tuple variant, found struct variant `FarmAnimal::Chicken`
+        FarmAnimal::Dog{..} => "woof!".to_string(),
+        _ => todo!()
+    };
+
+    println!("{:?} says: {:?}", animal, noise);
+}
+
+fn main() {}
diff --git a/src/test/ui/suggestions/issue-84700.stderr b/src/test/ui/suggestions/issue-84700.stderr
new file mode 100644 (file)
index 0000000..b36d8ab
--- /dev/null
@@ -0,0 +1,21 @@
+error[E0532]: expected tuple struct or tuple variant, found unit variant `FarmAnimal::Cow`
+  --> $DIR/issue-84700.rs:15:9
+   |
+LL |     Cow,
+   |     --- `FarmAnimal::Cow` defined here
+...
+LL |         FarmAnimal::Cow(_) => "moo".to_string(),
+   |         ^^^^^^^^^^^^^^^^^^ help: use this syntax instead: `FarmAnimal::Cow`
+
+error[E0532]: expected tuple struct or tuple variant, found struct variant `FarmAnimal::Chicken`
+  --> $DIR/issue-84700.rs:17:9
+   |
+LL |     Chicken { num_eggs: usize },
+   |     --------------------------- `FarmAnimal::Chicken` defined here
+...
+LL |         FarmAnimal::Chicken(_) => "cluck, cluck!".to_string(),
+   |         ^^^^^^^^^^^^^^^^^^^^^^ help: use struct pattern syntax instead: `FarmAnimal::Chicken { num_eggs }`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0532`.
index a4d636bc03c76145c99485a2f51ecbac97f55986..270233c0c97723acc8b785e842141c1596a86b4a 100644 (file)
@@ -5,6 +5,7 @@ LL | struct SomeStruct<A> { x: u32 }
    |                   ^ unused parameter
    |
    = help: consider removing `A`, referring to it in a field, or using a marker such as `PhantomData`
+   = help: if you intended `A` to be a const parameter, use `const A: usize` instead
 
 error[E0392]: parameter `A` is never used
   --> $DIR/variance-unused-type-param.rs:9:15
@@ -13,6 +14,7 @@ LL | enum SomeEnum<A> { Nothing }
    |               ^ unused parameter
    |
    = help: consider removing `A`, referring to it in a field, or using a marker such as `PhantomData`
+   = help: if you intended `A` to be a const parameter, use `const A: usize` instead
 
 error[E0392]: parameter `T` is never used
   --> $DIR/variance-unused-type-param.rs:13:15
@@ -21,6 +23,7 @@ LL | enum ListCell<T> {
    |               ^ unused parameter
    |
    = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
+   = help: if you intended `T` to be a const parameter, use `const T: usize` instead
 
 error: aborting due to 3 previous errors
 
index 129d82652d75915f55dc7907e52fddfbd08a0b9d..5ad27bb14501feb8988331dfaefd1dee909e6431 100644 (file)
@@ -77,7 +77,7 @@ fn main() {
     let error_kind = ErrorKind::NotFound;
     match error_kind {
         ErrorKind::NotFound => {},
-        ErrorKind::PermissionDenied | ErrorKind::ConnectionRefused | ErrorKind::ConnectionReset | ErrorKind::ConnectionAborted | ErrorKind::NotConnected | ErrorKind::AddrInUse | ErrorKind::AddrNotAvailable | ErrorKind::BrokenPipe | ErrorKind::AlreadyExists | ErrorKind::WouldBlock | ErrorKind::InvalidInput | ErrorKind::InvalidData | ErrorKind::TimedOut | ErrorKind::WriteZero | ErrorKind::Interrupted | ErrorKind::Other | ErrorKind::UnexpectedEof | ErrorKind::Unsupported | _ => {},
+        ErrorKind::PermissionDenied | ErrorKind::ConnectionRefused | ErrorKind::ConnectionReset | ErrorKind::ConnectionAborted | ErrorKind::NotConnected | ErrorKind::AddrInUse | ErrorKind::AddrNotAvailable | ErrorKind::BrokenPipe | ErrorKind::AlreadyExists | ErrorKind::WouldBlock | ErrorKind::InvalidInput | ErrorKind::InvalidData | ErrorKind::TimedOut | ErrorKind::WriteZero | ErrorKind::Interrupted | ErrorKind::Other | ErrorKind::UnexpectedEof | ErrorKind::Unsupported | ErrorKind::OutOfMemory | _ => {},
     }
     match error_kind {
         ErrorKind::NotFound => {},
@@ -99,6 +99,7 @@ fn main() {
         ErrorKind::Other => {},
         ErrorKind::UnexpectedEof => {},
         ErrorKind::Unsupported => {},
+        ErrorKind::OutOfMemory => {},
         _ => {},
     }
 }
index 028ecb63e7e6dcc7dddf75c0b170ef944d65e054..adca0738bba5b3cdee4e8255d79916ed98a3912c 100644 (file)
@@ -99,6 +99,7 @@ fn main() {
         ErrorKind::Other => {},
         ErrorKind::UnexpectedEof => {},
         ErrorKind::Unsupported => {},
+        ErrorKind::OutOfMemory => {},
         _ => {},
     }
 }
index fd45cad00d6b51bd6c5cc980957b46439899f9d8..73f6a4a80c960d36c8611b63fca88f59d1103c5d 100644 (file)
@@ -32,7 +32,7 @@ error: wildcard matches known variants and will also match future added variants
   --> $DIR/wildcard_enum_match_arm.rs:80:9
    |
 LL |         _ => {},
-   |         ^ help: try this: `ErrorKind::PermissionDenied | ErrorKind::ConnectionRefused | ErrorKind::ConnectionReset | ErrorKind::ConnectionAborted | ErrorKind::NotConnected | ErrorKind::AddrInUse | ErrorKind::AddrNotAvailable | ErrorKind::BrokenPipe | ErrorKind::AlreadyExists | ErrorKind::WouldBlock | ErrorKind::InvalidInput | ErrorKind::InvalidData | ErrorKind::TimedOut | ErrorKind::WriteZero | ErrorKind::Interrupted | ErrorKind::Other | ErrorKind::UnexpectedEof | ErrorKind::Unsupported | _`
+   |         ^ help: try this: `ErrorKind::PermissionDenied | ErrorKind::ConnectionRefused | ErrorKind::ConnectionReset | ErrorKind::ConnectionAborted | ErrorKind::NotConnected | ErrorKind::AddrInUse | ErrorKind::AddrNotAvailable | ErrorKind::BrokenPipe | ErrorKind::AlreadyExists | ErrorKind::WouldBlock | ErrorKind::InvalidInput | ErrorKind::InvalidData | ErrorKind::TimedOut | ErrorKind::WriteZero | ErrorKind::Interrupted | ErrorKind::Other | ErrorKind::UnexpectedEof | ErrorKind::Unsupported | ErrorKind::OutOfMemory | _`
 
 error: aborting due to 5 previous errors