_ => 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);
}
}
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));
}
) 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));
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));
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,
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,
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,
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,
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()
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,
executables: true,
panic_strategy: PanicStrategy::Abort,
linker: Some("ld".to_string()),
- os_family: Some("unix".to_string()),
+ families: vec!["unix".to_string()],
..Default::default()
}
}
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,
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,
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,
.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| {
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) {
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);
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);
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,
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,
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,
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,
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,
is_like_emscripten: true,
panic_strategy: PanicStrategy::Unwind,
post_link_args,
- os_family: Some("unix".to_string()),
+ families: vec!["unix".to_string()],
..options
};
Target {
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
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,
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,
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();
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
}
}
+#[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]
/// 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 {
ErrorKind::Other => "other os error",
ErrorKind::UnexpectedEof => "unexpected end of file",
ErrorKind::Unsupported => "unsupported",
+ ErrorKind::OutOfMemory => "out of memory",
}
}
}
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
wasi::ERRNO_EXIST => AlreadyExists,
wasi::ERRNO_AGAIN => WouldBlock,
wasi::ERRNO_NOSYS => Unsupported,
+ wasi::ERRNO_NOMEM => OutOfMemory,
_ => Other,
}
}
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;
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
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);
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};
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),
| KeywordItem(_) => [].iter(),
}
}
-
- crate fn is_type_alias(&self) -> bool {
- matches!(self, ItemKind::TypedefItem(..) | ItemKind::AssocTypeItem(..))
- }
}
#[derive(Clone, Debug)]
| clean::EnumItem(..)
| clean::TypedefItem(..)
| clean::TraitItem(..)
+ | clean::TraitAliasItem(..)
| clean::FunctionItem(..)
| clean::ModuleItem(..)
| clean::ForeignFunctionItem(..)
| 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
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,
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;
}
}
}
- 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));
}
}
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);
}
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,
}
};
- 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
})
})
.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,
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,
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,
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,
_ => 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,
}
fn render_default_items(
- w: &mut Buffer,
+ boring: &mut Buffer,
+ interesting: &mut Buffer,
cx: &Context<'_>,
t: &clean::Trait,
i: &clean::Impl,
let assoc_link = AssocItemLink::GotoSource(did, &provided_methods);
doc_impl_item(
- w,
+ boring,
+ interesting,
cx,
trait_item,
parent,
if show_default_items {
if let Some(t) = trait_ {
render_default_items(
+ &mut default_impl_items,
&mut impl_items,
cx,
&t.trait_,
);
}
}
- 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_ {
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 {
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(
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>");
);
}
}
- 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>");
}
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) {
});
}
- 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");
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;
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;
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;
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;
}
.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;
.content ul.crate a.crate {
font-size: 16px/1.6;
- font-family: "Fira Sans", Arial, sans-serif;
}
ol, ul {
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;
}
}
.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;
}
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;
}
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;
}
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
position: absolute;
}
-details.rustdoc-toggle[open] {
+details.rustdoc-toggle, details.undocumented {
position: relative;
}
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";
+}
.collapse-toggle,
details.rustdoc-toggle > summary.hideme > span,
-details.rustdoc-toggle > summary::before {
+details.rustdoc-toggle > summary::before,
+details.undocumented > summary::before {
color: #999;
}
.collapse-toggle,
details.rustdoc-toggle > summary.hideme > span,
-details.rustdoc-toggle > summary::before {
+details.rustdoc-toggle > summary::before,
+details.undocumented > summary::before {
color: #999;
}
.collapse-toggle,
details.rustdoc-toggle > summary.hideme > span,
-details.rustdoc-toggle > summary::before {
+details.rustdoc-toggle > summary::before,
+details.undocumented > summary::before {
color: #999;
}
/// 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."
}
--- /dev/null
+#![feature(trait_alias)]
+
+pub trait SomeAlias = std::fmt::Debug + std::marker::Copy;
--- /dev/null
+pub trait Bar {
+ fn foo();
+}
// @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
// @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;
// @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.
// @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.
}
// @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.
--- /dev/null
+// 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>() {
+}
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'
}
--- /dev/null
+// 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;
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 {}
-// run-pass
+// build-pass
// pretty-expanded FIXME #23616
-// ignore-wasm32-bare no target_family
+// ignore-wasm32-bare no bare family
// ignore-sgx
#[cfg(windows)]
-// run-pass
-// ignore-wasm32-bare no target_family
+// build-pass
// ignore-sgx
// pretty-expanded FIXME #23616
#[cfg(target_family = "unix")]
pub fn main() {
}
+
+#[cfg(target_family="wasm")]
+pub fn main() {
+}
| ^ 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
| ^ 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
| ^ 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
| ^ 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
| ^ 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
| ^ 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
| ^ 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
| ^ 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
--- /dev/null
+#![crate_type="lib"]
+
+struct Example<N>;
+//~^ ERROR parameter
--- /dev/null
+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`.
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
| ^ 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
| ^ 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
| ^ 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
| ^ 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
| ^ 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
| ^ 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
| ^ 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
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
| ^ 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
| ^^^^ 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
| ^ 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
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
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
|
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
--- /dev/null
+// 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() {}
--- /dev/null
+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`.
| ^ 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
| ^ 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
| ^ 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
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 => {},
ErrorKind::Other => {},
ErrorKind::UnexpectedEof => {},
ErrorKind::Unsupported => {},
+ ErrorKind::OutOfMemory => {},
_ => {},
}
}
ErrorKind::Other => {},
ErrorKind::UnexpectedEof => {},
ErrorKind::Unsupported => {},
+ ErrorKind::OutOfMemory => {},
_ => {},
}
}
--> $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