Auto merge of #84840 - Dylan-DPC:rollup-uzk7w0h, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - #84072 (Allow setting `target_family` to multiple values, and implement `target_family="wasm"`) - #84744 (Add ErrorKind::OutOfMemory) - #84784 (Add help message to suggest const for unused type param) - #84811 (RustDoc: Fix bounds linking trait.Foo instead of traitalias.Foo) - #84818 (suggestion for unit enum variant when matched with a patern) - #84832 (Do not print visibility in external traits) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
59f551a2dc
67 changed files with 383 additions and 94 deletions
|
@ -819,6 +819,19 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
_ => 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 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
}
|
||||
}
|
||||
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 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
) 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));
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 @@ impl Default for 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 @@ impl Target {
|
|||
.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 @@ impl Target {
|
|||
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 @@ impl Target {
|
|||
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 @@ impl ToJson for Target {
|
|||
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);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 @@ impl ErrorKind {
|
|||
ErrorKind::Other => "other os error",
|
||||
ErrorKind::UnexpectedEof => "unexpected end of file",
|
||||
ErrorKind::Unsupported => "unsupported",
|
||||
ErrorKind::OutOfMemory => "out of memory",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -168,6 +168,8 @@ pub const ERROR_FILE_NOT_FOUND: DWORD = 2;
|
|||
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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -19,7 +19,7 @@ use crate::clean::{self, Attributes, AttributesExt, GetDefId, ToSource};
|
|||
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>;
|
||||
|
||||
|
@ -188,13 +188,23 @@ crate fn record_extern_fqn(cx: &mut DocContext<'_>, did: DefId, kind: ItemType)
|
|||
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);
|
||||
|
|
|
@ -17,11 +17,11 @@ use rustc_hir::def::{CtorKind, DefKind, Res};
|
|||
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 @@ impl Clean<GenericBound> for hir::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),
|
||||
|
|
|
@ -327,6 +327,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
|
|||
| clean::EnumItem(..)
|
||||
| clean::TypedefItem(..)
|
||||
| clean::TraitItem(..)
|
||||
| clean::TraitAliasItem(..)
|
||||
| clean::FunctionItem(..)
|
||||
| clean::ModuleItem(..)
|
||||
| clean::ForeignFunctionItem(..)
|
||||
|
@ -337,26 +338,43 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
|
|||
| 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
|
||||
|
|
3
src/test/rustdoc/auxiliary/trait-alias-mention.rs
Normal file
3
src/test/rustdoc/auxiliary/trait-alias-mention.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
#![feature(trait_alias)]
|
||||
|
||||
pub trait SomeAlias = std::fmt::Debug + std::marker::Copy;
|
3
src/test/rustdoc/auxiliary/trait-visibility.rs
Normal file
3
src/test/rustdoc/auxiliary/trait-visibility.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
pub trait Bar {
|
||||
fn foo();
|
||||
}
|
10
src/test/rustdoc/trait-alias-mention.rs
Normal file
10
src/test/rustdoc/trait-alias-mention.rs
Normal file
|
@ -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>() {
|
||||
}
|
8
src/test/rustdoc/trait-visibility.rs
Normal file
8
src/test/rustdoc/trait-visibility.rs
Normal file
|
@ -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;
|
|
@ -19,3 +19,5 @@ pub trait CopyAlias = Copy;
|
|||
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 {}
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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() {
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
#![crate_type="lib"]
|
||||
|
||||
struct Example<N>;
|
||||
//~^ ERROR parameter
|
|
@ -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`.
|
|
@ -1,84 +1,154 @@
|
|||
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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
26
src/test/ui/suggestions/issue-84700.rs
Normal file
26
src/test/ui/suggestions/issue-84700.rs
Normal file
|
@ -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() {}
|
21
src/test/ui/suggestions/issue-84700.stderr
Normal file
21
src/test/ui/suggestions/issue-84700.stderr
Normal file
|
@ -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`.
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 => {},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,6 +99,7 @@ fn main() {
|
|||
ErrorKind::Other => {},
|
||||
ErrorKind::UnexpectedEof => {},
|
||||
ErrorKind::Unsupported => {},
|
||||
ErrorKind::OutOfMemory => {},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue