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:
bors 2021-05-03 00:17:16 +00:00
commit 59f551a2dc
67 changed files with 383 additions and 94 deletions

View file

@ -819,6 +819,19 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
_ => false, _ => 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 mut bad_struct_syntax_suggestion = |def_id: DefId| {
let (followed_by_brace, closing_brace) = self.followed_by_brace(span); 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 => { PathSource::Expr(_) | PathSource::TupleStruct(..) | PathSource::Pat => {
let span = match &source { let span = find_span(&source, err);
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,
};
if let Some(span) = self.def_span(def_id) { if let Some(span) = self.def_span(def_id) {
err.span_label(span, &format!("`{}` defined here", path_str)); err.span_label(span, &format!("`{}` defined here", path_str));
} }
@ -1047,6 +1049,23 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
) if ns == ValueNS => { ) if ns == ValueNS => {
bad_struct_syntax_suggestion(def_id); 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 => { (Res::Def(DefKind::Ctor(_, CtorKind::Fn), def_id), _) if ns == ValueNS => {
if let Some(span) = self.def_span(def_id) { if let Some(span) = self.def_span(def_id) {
err.span_label(span, &format!("`{}` defined here", path_str)); err.span_label(span, &format!("`{}` defined here", path_str));

View file

@ -816,7 +816,7 @@ fn default_configuration(sess: &Session) -> CrateConfig {
ret.reserve(6); // the minimum number of insertions ret.reserve(6); // the minimum number of insertions
// Target bindings. // Target bindings.
ret.insert((sym::target_os, Some(Symbol::intern(os)))); 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)))); ret.insert((sym::target_family, Some(Symbol::intern(fam))));
if fam == "windows" { if fam == "windows" {
ret.insert((sym::windows, None)); ret.insert((sym::windows, None));

View file

@ -23,7 +23,7 @@ pub fn opts(os: &str) -> TargetOptions {
function_sections: false, function_sections: false,
dynamic_linking: true, dynamic_linking: true,
executables: true, executables: true,
os_family: Some("unix".to_string()), families: vec!["unix".to_string()],
is_like_osx: true, is_like_osx: true,
dwarf_version: Some(2), dwarf_version: Some(2),
has_rpath: true, has_rpath: true,

View file

@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
os: "dragonfly".to_string(), os: "dragonfly".to_string(),
dynamic_linking: true, dynamic_linking: true,
executables: true, executables: true,
os_family: Some("unix".to_string()), families: vec!["unix".to_string()],
linker_is_gnu: true, linker_is_gnu: true,
has_rpath: true, has_rpath: true,
position_independent_executables: true, position_independent_executables: true,

View file

@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
os: "freebsd".to_string(), os: "freebsd".to_string(),
dynamic_linking: true, dynamic_linking: true,
executables: true, executables: true,
os_family: Some("unix".to_string()), families: vec!["unix".to_string()],
linker_is_gnu: true, linker_is_gnu: true,
has_rpath: true, has_rpath: true,
position_independent_executables: true, position_independent_executables: true,

View file

@ -25,7 +25,7 @@ pub fn opts() -> TargetOptions {
linker: Some("rust-lld".to_owned()), linker: Some("rust-lld".to_owned()),
dynamic_linking: true, dynamic_linking: true,
executables: true, executables: true,
os_family: Some("unix".to_string()), families: vec!["unix".to_string()],
is_like_fuchsia: true, is_like_fuchsia: true,
linker_is_gnu: true, linker_is_gnu: true,
pre_link_args, pre_link_args,

View file

@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
os: "haiku".to_string(), os: "haiku".to_string(),
dynamic_linking: true, dynamic_linking: true,
executables: true, executables: true,
os_family: Some("unix".to_string()), families: vec!["unix".to_string()],
relro_level: RelroLevel::Full, relro_level: RelroLevel::Full,
linker_is_gnu: true, linker_is_gnu: true,
..Default::default() ..Default::default()

View file

@ -20,7 +20,7 @@ pub fn opts() -> TargetOptions {
dynamic_linking: true, dynamic_linking: true,
executables: true, executables: true,
has_rpath: true, has_rpath: true,
os_family: Some("unix".to_string()), families: vec!["unix".to_string()],
is_like_solaris: true, is_like_solaris: true,
limit_rdylib_exports: false, // Linker doesn't support this limit_rdylib_exports: false, // Linker doesn't support this
eliminate_frame_pointer: false, eliminate_frame_pointer: false,

View file

@ -20,7 +20,7 @@ pub fn opts() -> TargetOptions {
executables: true, executables: true,
panic_strategy: PanicStrategy::Abort, panic_strategy: PanicStrategy::Abort,
linker: Some("ld".to_string()), linker: Some("ld".to_string()),
os_family: Some("unix".to_string()), families: vec!["unix".to_string()],
..Default::default() ..Default::default()
} }
} }

View file

@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
os: "linux".to_string(), os: "linux".to_string(),
dynamic_linking: true, dynamic_linking: true,
executables: true, executables: true,
os_family: Some("unix".to_string()), families: vec!["unix".to_string()],
linker_is_gnu: true, linker_is_gnu: true,
has_rpath: true, has_rpath: true,
position_independent_executables: true, position_independent_executables: true,

View file

@ -1042,8 +1042,12 @@ pub struct TargetOptions {
pub staticlib_prefix: String, pub staticlib_prefix: String,
/// String to append to the name of every static library. Defaults to ".a". /// String to append to the name of every static library. Defaults to ".a".
pub staticlib_suffix: String, pub staticlib_suffix: String,
/// OS family to use for conditional compilation. Valid options: "unix", "windows". /// Values of the `target_family` cfg set for this target.
pub os_family: Option<String>, ///
/// 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. /// Whether the target toolchain's ABI supports returning small structs as an integer.
pub abi_return_struct_as_int: bool, pub abi_return_struct_as_int: bool,
/// Whether the target toolchain is like macOS's. Only useful for compiling against iOS/macOS, /// 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(), exe_suffix: String::new(),
staticlib_prefix: "lib".to_string(), staticlib_prefix: "lib".to_string(),
staticlib_suffix: ".a".to_string(), staticlib_suffix: ".a".to_string(),
os_family: None, families: Vec::new(),
abi_return_struct_as_int: false, abi_return_struct_as_int: false,
is_like_osx: false, is_like_osx: false,
is_like_solaris: false, is_like_solaris: false,
@ -1605,14 +1609,6 @@ impl Target {
.map(|s| s.to_string() ); .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) => ( { ($key_name:ident, LldFlavor) => ( {
let name = (stringify!($key_name)).replace("_", "-"); let name = (stringify!($key_name)).replace("_", "-");
obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| { obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| {
@ -1759,6 +1755,16 @@ impl Target {
Some(Ok(())) Some(Ok(()))
})).unwrap_or(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) { if let Some(s) = obj.find("target-endian").and_then(Json::as_string) {
@ -1802,7 +1808,7 @@ impl Target {
key!(exe_suffix); key!(exe_suffix);
key!(staticlib_prefix); key!(staticlib_prefix);
key!(staticlib_suffix); key!(staticlib_suffix);
key!(os_family = "target-family", optional); key!(families, TargetFamilies);
key!(abi_return_struct_as_int, bool); key!(abi_return_struct_as_int, bool);
key!(is_like_osx, bool); key!(is_like_osx, bool);
key!(is_like_solaris, bool); key!(is_like_solaris, bool);
@ -2042,7 +2048,7 @@ impl ToJson for Target {
target_option_val!(exe_suffix); target_option_val!(exe_suffix);
target_option_val!(staticlib_prefix); target_option_val!(staticlib_prefix);
target_option_val!(staticlib_suffix); 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!(abi_return_struct_as_int);
target_option_val!(is_like_osx); target_option_val!(is_like_osx);
target_option_val!(is_like_solaris); target_option_val!(is_like_solaris);

View file

@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
os: "netbsd".to_string(), os: "netbsd".to_string(),
dynamic_linking: true, dynamic_linking: true,
executables: true, executables: true,
os_family: Some("unix".to_string()), families: vec!["unix".to_string()],
linker_is_gnu: true, linker_is_gnu: true,
no_default_libraries: false, no_default_libraries: false,
has_rpath: true, has_rpath: true,

View file

@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
os: "openbsd".to_string(), os: "openbsd".to_string(),
dynamic_linking: true, dynamic_linking: true,
executables: true, executables: true,
os_family: Some("unix".to_string()), families: vec!["unix".to_string()],
linker_is_gnu: true, linker_is_gnu: true,
has_rpath: true, has_rpath: true,
abi_return_struct_as_int: true, abi_return_struct_as_int: true,

View file

@ -6,7 +6,7 @@ pub fn opts() -> TargetOptions {
env: "relibc".to_string(), env: "relibc".to_string(),
dynamic_linking: true, dynamic_linking: true,
executables: true, executables: true,
os_family: Some("unix".to_string()), families: vec!["unix".to_string()],
linker_is_gnu: true, linker_is_gnu: true,
has_rpath: true, has_rpath: true,
position_independent_executables: true, position_independent_executables: true,

View file

@ -6,7 +6,7 @@ pub fn opts() -> TargetOptions {
dynamic_linking: true, dynamic_linking: true,
executables: true, executables: true,
has_rpath: true, has_rpath: true,
os_family: Some("unix".to_string()), families: vec!["unix".to_string()],
is_like_solaris: true, is_like_solaris: true,
limit_rdylib_exports: false, // Linker doesn't support this limit_rdylib_exports: false, // Linker doesn't support this
eh_frame_header: false, eh_frame_header: false,

View file

@ -9,7 +9,7 @@ pub fn opts() -> TargetOptions {
exe_suffix: ".vxe".to_string(), exe_suffix: ".vxe".to_string(),
dynamic_linking: true, dynamic_linking: true,
executables: true, executables: true,
os_family: Some("unix".to_string()), families: vec!["unix".to_string()],
linker_is_gnu: true, linker_is_gnu: true,
has_rpath: true, has_rpath: true,
has_elf_tls: true, has_elf_tls: true,

View file

@ -38,7 +38,7 @@ pub fn target() -> Target {
is_like_emscripten: true, is_like_emscripten: true,
panic_strategy: PanicStrategy::Unwind, panic_strategy: PanicStrategy::Unwind,
post_link_args, post_link_args,
os_family: Some("unix".to_string()), families: vec!["unix".to_string()],
..options ..options
}; };
Target { Target {

View file

@ -61,6 +61,7 @@ pub fn options() -> TargetOptions {
TargetOptions { TargetOptions {
is_like_wasm: true, is_like_wasm: true,
families: vec!["wasm".to_string()],
// we allow dynamic linking, but only cdylibs. Basically we allow a // we allow dynamic linking, but only cdylibs. Basically we allow a
// final library artifact that exports some symbols (a wasm module) but // final library artifact that exports some symbols (a wasm module) but

View file

@ -71,7 +71,7 @@ pub fn opts() -> TargetOptions {
dll_prefix: String::new(), dll_prefix: String::new(),
dll_suffix: ".dll".to_string(), dll_suffix: ".dll".to_string(),
exe_suffix: ".exe".to_string(), exe_suffix: ".exe".to_string(),
os_family: Some("windows".to_string()), families: vec!["windows".to_string()],
is_like_windows: true, is_like_windows: true,
allows_weak_linkage: false, allows_weak_linkage: false,
pre_link_args, pre_link_args,

View file

@ -13,7 +13,7 @@ pub fn opts() -> TargetOptions {
exe_suffix: ".exe".to_string(), exe_suffix: ".exe".to_string(),
staticlib_prefix: String::new(), staticlib_prefix: String::new(),
staticlib_suffix: ".lib".to_string(), staticlib_suffix: ".lib".to_string(),
os_family: Some("windows".to_string()), families: vec!["windows".to_string()],
crt_static_allows_dylibs: true, crt_static_allows_dylibs: true,
crt_static_respected: true, crt_static_respected: true,
requires_uwtable: true, requires_uwtable: true,

View file

@ -1298,12 +1298,14 @@ fn check_variances_for_type_defn<'tcx>(
match param.name { match param.name {
hir::ParamName::Error => {} 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 mut err = error_392(tcx, span, param_name);
let suggested_marker_id = tcx.lang_items().phantom_data(); 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) format!("consider removing `{}` or referring to it in a field", param_name)
}; };
err.help(&msg); 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 /// Feature gates RFC 2056 -- trivial bounds, checking for global bounds that

View file

@ -186,6 +186,11 @@ pub enum ErrorKind {
/// This means that the operation can never succeed. /// This means that the operation can never succeed.
#[stable(feature = "unsupported_error", since = "1.53.0")] #[stable(feature = "unsupported_error", since = "1.53.0")]
Unsupported, 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 { impl ErrorKind {
@ -210,6 +215,7 @@ impl ErrorKind {
ErrorKind::Other => "other os error", ErrorKind::Other => "other os error",
ErrorKind::UnexpectedEof => "unexpected end of file", ErrorKind::UnexpectedEof => "unexpected end of file",
ErrorKind::Unsupported => "unsupported", ErrorKind::Unsupported => "unsupported",
ErrorKind::OutOfMemory => "out of memory",
} }
} }
} }

View file

@ -149,6 +149,7 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind {
libc::ETIMEDOUT => ErrorKind::TimedOut, libc::ETIMEDOUT => ErrorKind::TimedOut,
libc::EEXIST => ErrorKind::AlreadyExists, libc::EEXIST => ErrorKind::AlreadyExists,
libc::ENOSYS => ErrorKind::Unsupported, libc::ENOSYS => ErrorKind::Unsupported,
libc::ENOMEM => ErrorKind::OutOfMemory,
// These two constants can have the same value on some systems, // These two constants can have the same value on some systems,
// but different values on others, so we can't use a match // but different values on others, so we can't use a match

View file

@ -77,6 +77,7 @@ pub fn decode_error_kind(errno: i32) -> std_io::ErrorKind {
wasi::ERRNO_EXIST => AlreadyExists, wasi::ERRNO_EXIST => AlreadyExists,
wasi::ERRNO_AGAIN => WouldBlock, wasi::ERRNO_AGAIN => WouldBlock,
wasi::ERRNO_NOSYS => Unsupported, wasi::ERRNO_NOSYS => Unsupported,
wasi::ERRNO_NOMEM => OutOfMemory,
_ => Other, _ => Other,
} }
} }

View file

@ -168,6 +168,8 @@ pub const ERROR_FILE_NOT_FOUND: DWORD = 2;
pub const ERROR_PATH_NOT_FOUND: DWORD = 3; pub const ERROR_PATH_NOT_FOUND: DWORD = 3;
pub const ERROR_ACCESS_DENIED: DWORD = 5; pub const ERROR_ACCESS_DENIED: DWORD = 5;
pub const ERROR_INVALID_HANDLE: DWORD = 6; 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_NO_MORE_FILES: DWORD = 18;
pub const ERROR_HANDLE_EOF: DWORD = 38; pub const ERROR_HANDLE_EOF: DWORD = 38;
pub const ERROR_FILE_EXISTS: DWORD = 80; pub const ERROR_FILE_EXISTS: DWORD = 80;

View file

@ -71,6 +71,7 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind {
c::ERROR_PATH_NOT_FOUND => return ErrorKind::NotFound, c::ERROR_PATH_NOT_FOUND => return ErrorKind::NotFound,
c::ERROR_NO_DATA => return ErrorKind::BrokenPipe, c::ERROR_NO_DATA => return ErrorKind::BrokenPipe,
c::ERROR_INVALID_PARAMETER => return ErrorKind::InvalidInput, c::ERROR_INVALID_PARAMETER => return ErrorKind::InvalidInput,
c::ERROR_NOT_ENOUGH_MEMORY | c::ERROR_OUTOFMEMORY => return ErrorKind::OutOfMemory,
c::ERROR_SEM_TIMEOUT c::ERROR_SEM_TIMEOUT
| c::WAIT_TIMEOUT | c::WAIT_TIMEOUT
| c::ERROR_DRIVER_CANCEL_TIMEOUT | c::ERROR_DRIVER_CANCEL_TIMEOUT

View file

@ -19,7 +19,7 @@ use crate::clean::{self, Attributes, AttributesExt, GetDefId, ToSource};
use crate::core::DocContext; use crate::core::DocContext;
use crate::formats::item_type::ItemType; use crate::formats::item_type::ItemType;
use super::Clean; use super::{Clean, Visibility};
type Attrs<'hir> = rustc_middle::ty::Attributes<'hir>; 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() { if did.is_local() {
cx.cache.exact_paths.insert(did, fqn); cx.cache.exact_paths.insert(did, fqn);
} else { } 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 { crate fn build_external_trait(cx: &mut DocContext<'_>, did: DefId) -> clean::Trait {
let trait_items = let trait_items = cx
cx.tcx.associated_items(did).in_definition_order().map(|item| item.clean(cx)).collect(); .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 predicates = cx.tcx.predicates_of(did);
let generics = (cx.tcx.generics_of(did), predicates).clean(cx); let generics = (cx.tcx.generics_of(did), predicates).clean(cx);

View file

@ -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_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
use rustc_index::vec::{Idx, IndexVec}; use rustc_index::vec::{Idx, IndexVec};
use rustc_infer::infer::region_constraints::{Constraint, RegionConstraintData}; use rustc_infer::infer::region_constraints::{Constraint, RegionConstraintData};
use rustc_middle::bug;
use rustc_middle::middle::resolve_lifetime as rl; use rustc_middle::middle::resolve_lifetime as rl;
use rustc_middle::ty::fold::TypeFolder; use rustc_middle::ty::fold::TypeFolder;
use rustc_middle::ty::subst::{InternalSubsts, Subst}; use rustc_middle::ty::subst::{InternalSubsts, Subst};
use rustc_middle::ty::{self, AdtKind, Lift, Ty, TyCtxt}; 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_mir::const_eval::{is_const_fn, is_unstable_const_fn};
use rustc_span::hygiene::{AstPass, MacroKind}; use rustc_span::hygiene::{AstPass, MacroKind};
use rustc_span::symbol::{kw, sym, Ident, Symbol}; 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]) { impl Clean<Type> for (ty::TraitRef<'_>, &[TypeBinding]) {
fn clean(&self, cx: &mut DocContext<'_>) -> Type { fn clean(&self, cx: &mut DocContext<'_>) -> Type {
let (trait_ref, bounds) = *self; 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( let path = external_path(
cx, cx,
cx.tcx.item_name(trait_ref.def_id), cx.tcx.item_name(trait_ref.def_id),

View file

@ -327,6 +327,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
| clean::EnumItem(..) | clean::EnumItem(..)
| clean::TypedefItem(..) | clean::TypedefItem(..)
| clean::TraitItem(..) | clean::TraitItem(..)
| clean::TraitAliasItem(..)
| clean::FunctionItem(..) | clean::FunctionItem(..)
| clean::ModuleItem(..) | clean::ModuleItem(..)
| clean::ForeignFunctionItem(..) | clean::ForeignFunctionItem(..)
@ -337,26 +338,43 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
| clean::ForeignTypeItem | clean::ForeignTypeItem
| clean::MacroItem(..) | clean::MacroItem(..)
| clean::ProcMacroItem(..) | clean::ProcMacroItem(..)
| clean::VariantItem(..) | clean::VariantItem(..) => {
if !self.cache.stripped_mod => if !self.cache.stripped_mod {
{ // Re-exported items mean that the same id can show up twice
// Re-exported items mean that the same id can show up twice // in the rustdoc ast that we're looking at. We know,
// in the rustdoc ast that we're looking at. We know, // however, that a re-exported item doesn't show up in the
// however, that a re-exported item doesn't show up in the // `public_items` map, so we can skip inserting into the
// `public_items` map, so we can skip inserting into the // paths map if there was already an entry present and we're
// paths map if there was already an entry present and we're // not a public item.
// not a public item. if !self.cache.paths.contains_key(&item.def_id)
if !self.cache.paths.contains_key(&item.def_id) || self.cache.access_levels.is_public(item.def_id)
|| self.cache.access_levels.is_public(item.def_id) {
{ self.cache
self.cache.paths.insert(item.def_id, (self.cache.stack.clone(), item.type_())); .paths
.insert(item.def_id, (self.cache.stack.clone(), item.type_()));
}
} }
} }
clean::PrimitiveItem(..) => { clean::PrimitiveItem(..) => {
self.cache.paths.insert(item.def_id, (self.cache.stack.clone(), item.type_())); 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 // Maintain the parent stack

View file

@ -0,0 +1,3 @@
#![feature(trait_alias)]
pub trait SomeAlias = std::fmt::Debug + std::marker::Copy;

View file

@ -0,0 +1,3 @@
pub trait Bar {
fn foo();
}

View 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>() {
}

View 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;

View file

@ -19,3 +19,5 @@ pub trait CopyAlias = Copy;
pub trait Alias2 = Copy + Debug; pub trait Alias2 = Copy + Debug;
// @has foo/traitalias.Foo.html '//section[@id="main"]/pre' 'trait Foo<T> = Into<T> + Debug;' // @has foo/traitalias.Foo.html '//section[@id="main"]/pre' 'trait Foo<T> = Into<T> + Debug;'
pub 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 {}

View file

@ -1,6 +1,6 @@
// run-pass // build-pass
// pretty-expanded FIXME #23616 // pretty-expanded FIXME #23616
// ignore-wasm32-bare no target_family // ignore-wasm32-bare no bare family
// ignore-sgx // ignore-sgx
#[cfg(windows)] #[cfg(windows)]

View file

@ -1,5 +1,4 @@
// run-pass // build-pass
// ignore-wasm32-bare no target_family
// ignore-sgx // ignore-sgx
// pretty-expanded FIXME #23616 // pretty-expanded FIXME #23616
@ -11,3 +10,7 @@ pub fn main() {
#[cfg(target_family = "unix")] #[cfg(target_family = "unix")]
pub fn main() { pub fn main() {
} }
#[cfg(target_family="wasm")]
pub fn main() {
}

View file

@ -11,6 +11,7 @@ LL | pub struct Dependent<T, const X: T>([(); X]);
| ^ unused parameter | ^ unused parameter
| |
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` = 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 error: aborting due to 2 previous errors

View file

@ -11,6 +11,7 @@ LL | pub struct Dependent<T, const X: T>([(); X]);
| ^ unused parameter | ^ unused parameter
| |
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` = 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 error: aborting due to 2 previous errors

View file

@ -15,6 +15,7 @@ LL | struct Bug<T> {
| ^ unused parameter | ^ unused parameter
| |
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` = 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 error: aborting due to previous error; 1 warning emitted

View file

@ -14,6 +14,7 @@ LL | struct Bug<T> {
| ^ unused parameter | ^ unused parameter
| |
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` = 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 error: aborting due to 2 previous errors

View file

@ -19,6 +19,7 @@ LL | struct Bug<S> {
| ^ unused parameter | ^ unused parameter
| |
= help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData` = 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 error: aborting due to 2 previous errors

View file

@ -23,6 +23,7 @@ LL | struct Bug<S> {
| ^ unused parameter | ^ unused parameter
| |
= help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData` = 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 error: aborting due to 3 previous errors

View file

@ -19,6 +19,7 @@ LL | struct Bug<S> {
| ^ unused parameter | ^ unused parameter
| |
= help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData` = 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 error: aborting due to 2 previous errors

View file

@ -23,6 +23,7 @@ LL | struct Bug<S> {
| ^ unused parameter | ^ unused parameter
| |
= help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData` = 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 error: aborting due to 3 previous errors

View file

@ -0,0 +1,4 @@
#![crate_type="lib"]
struct Example<N>;
//~^ ERROR parameter

View file

@ -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`.

View file

@ -1,84 +1,154 @@
error[E0532]: expected tuple struct or tuple variant, found unit struct `Empty2` error[E0532]: expected tuple struct or tuple variant, found unit struct `Empty2`
--> $DIR/empty-struct-unit-pat.rs:21:9 --> $DIR/empty-struct-unit-pat.rs:21:9
| |
LL | struct Empty2;
| -------------- `Empty2` defined here
...
LL | Empty2() => () LL | Empty2() => ()
| ^^^^^^ help: a tuple struct with a similar name exists: `XEmpty6` | ^^^^^^^^
| |
::: $DIR/auxiliary/empty-struct.rs:3:1 ::: $DIR/auxiliary/empty-struct.rs:3:1
| |
LL | pub struct XEmpty6(); LL | pub struct XEmpty6();
| --------------------- similarly named tuple struct `XEmpty6` defined here | --------------------- 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` error[E0532]: expected tuple struct or tuple variant, found unit struct `XEmpty2`
--> $DIR/empty-struct-unit-pat.rs:24:9 --> $DIR/empty-struct-unit-pat.rs:24:9
| |
LL | XEmpty2() => () 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(); LL | pub struct XEmpty6();
| --------------------- similarly named tuple struct `XEmpty6` defined here | --------------------- 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` error[E0532]: expected tuple struct or tuple variant, found unit struct `Empty2`
--> $DIR/empty-struct-unit-pat.rs:28:9 --> $DIR/empty-struct-unit-pat.rs:28:9
| |
LL | struct Empty2;
| -------------- `Empty2` defined here
...
LL | Empty2(..) => () LL | Empty2(..) => ()
| ^^^^^^ help: a tuple struct with a similar name exists: `XEmpty6` | ^^^^^^^^^^
| |
::: $DIR/auxiliary/empty-struct.rs:3:1 ::: $DIR/auxiliary/empty-struct.rs:3:1
| |
LL | pub struct XEmpty6(); LL | pub struct XEmpty6();
| --------------------- similarly named tuple struct `XEmpty6` defined here | --------------------- 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` error[E0532]: expected tuple struct or tuple variant, found unit struct `XEmpty2`
--> $DIR/empty-struct-unit-pat.rs:32:9 --> $DIR/empty-struct-unit-pat.rs:32:9
| |
LL | XEmpty2(..) => () 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(); LL | pub struct XEmpty6();
| --------------------- similarly named tuple struct `XEmpty6` defined here | --------------------- 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` error[E0532]: expected tuple struct or tuple variant, found unit variant `E::Empty4`
--> $DIR/empty-struct-unit-pat.rs:37:9 --> $DIR/empty-struct-unit-pat.rs:37:9
| |
LL | Empty4
| ------ `E::Empty4` defined here
...
LL | E::Empty4() => () 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` error[E0532]: expected tuple struct or tuple variant, found unit variant `XE::XEmpty4`
--> $DIR/empty-struct-unit-pat.rs:41:9 --> $DIR/empty-struct-unit-pat.rs:41:9
| |
LL | XE::XEmpty4() => (), 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(), LL | XEmpty5(),
| --------- similarly named tuple variant `XEmpty5` defined here | --------- 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` error[E0532]: expected tuple struct or tuple variant, found unit variant `E::Empty4`
--> $DIR/empty-struct-unit-pat.rs:46:9 --> $DIR/empty-struct-unit-pat.rs:46:9
| |
LL | Empty4
| ------ `E::Empty4` defined here
...
LL | E::Empty4(..) => () 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` error[E0532]: expected tuple struct or tuple variant, found unit variant `XE::XEmpty4`
--> $DIR/empty-struct-unit-pat.rs:50:9 --> $DIR/empty-struct-unit-pat.rs:50:9
| |
LL | XE::XEmpty4(..) => (), 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(), LL | XEmpty5(),
| --------- similarly named tuple variant `XEmpty5` defined here | --------- 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 error: aborting due to 8 previous errors

View file

@ -14,6 +14,7 @@ LL | enum MyWeirdOption<T> {
| ^ unused parameter | ^ unused parameter
| |
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` = 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 error: aborting due to 2 previous errors

View file

@ -14,6 +14,7 @@ LL | enum Bug<S> {
| ^ unused parameter | ^ unused parameter
| |
= help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData` = 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 error: aborting due to 2 previous errors

View file

@ -14,6 +14,7 @@ LL | enum Bug<S> {
| ^ unused parameter | ^ unused parameter
| |
= help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData` = 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 error: aborting due to 2 previous errors

View file

@ -5,6 +5,7 @@ LL | enum Foo<T> { Bar }
| ^ unused parameter | ^ unused parameter
| |
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` = 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 error: aborting due to previous error

View file

@ -13,6 +13,7 @@ LL | enum Bar<T> { What }
| ^ unused parameter | ^ unused parameter
| |
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` = 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 error: aborting due to 2 previous errors

View file

@ -5,6 +5,7 @@ LL | struct Foo<T> where T: Copy;
| ^ unused parameter | ^ unused parameter
| |
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` = 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 error: aborting due to previous error

View file

@ -5,6 +5,7 @@ LL | struct NoData<T>;
| ^ unused parameter | ^ unused parameter
| |
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` = 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` 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 --> $DIR/issue-20413.rs:8:36

View file

@ -21,8 +21,11 @@ LL | Foo::Baz => {}
error[E0532]: expected tuple struct or tuple variant, found unit struct `S` error[E0532]: expected tuple struct or tuple variant, found unit struct `S`
--> $DIR/issue-32004.rs:16:9 --> $DIR/issue-32004.rs:16:9
| |
LL | struct S;
| --------- `S` defined here
...
LL | S(()) => {} LL | S(()) => {}
| ^ not a tuple struct or tuple variant | ^^^^^ help: use this syntax instead: `S`
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -13,6 +13,7 @@ LL | struct Foo<'a, A> {}
| ^ unused parameter | ^ unused parameter
| |
= help: consider removing `A`, referring to it in a field, or using a marker such as `PhantomData` = 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 error: aborting due to 2 previous errors

View file

@ -17,6 +17,7 @@ LL | struct Foo<Self>(Self);
| ^^^^ unused parameter | ^^^^ unused parameter
| |
= help: consider removing `Self`, referring to it in a field, or using a marker such as `PhantomData` = 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 error: aborting due to 3 previous errors

View file

@ -22,6 +22,7 @@ LL | struct Foo<T: ?Hash> { }
| ^ unused parameter | ^ unused parameter
| |
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` = 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: aborting due to 2 previous errors; 1 warning emitted

View file

@ -1,14 +1,20 @@
error[E0532]: expected tuple struct or tuple variant, found unit variant `E::A` error[E0532]: expected tuple struct or tuple variant, found unit variant `E::A`
--> $DIR/issue-pr29383.rs:9:14 --> $DIR/issue-pr29383.rs:9:14
| |
LL | A,
| - `E::A` defined here
...
LL | Some(E::A(..)) => {} 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` error[E0532]: expected tuple struct or tuple variant, found unit variant `E::B`
--> $DIR/issue-pr29383.rs:11:14 --> $DIR/issue-pr29383.rs:11:14
| |
LL | B,
| - `E::B` defined here
...
LL | Some(E::B(..)) => {} 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: aborting due to 2 previous errors

View file

@ -1,8 +1,11 @@
error[E0532]: expected tuple struct or tuple variant, found unit variant `Color::NoColor` error[E0532]: expected tuple struct or tuple variant, found unit variant `Color::NoColor`
--> $DIR/match-pattern-field-mismatch-2.rs:12:11 --> $DIR/match-pattern-field-mismatch-2.rs:12:11
| |
LL | NoColor,
| ------- `Color::NoColor` defined here
...
LL | Color::NoColor(_) => { } LL | Color::NoColor(_) => { }
| ^^^^^^^^^^^^^^ not a tuple struct or tuple variant | ^^^^^^^^^^^^^^^^^ help: use this syntax instead: `Color::NoColor`
error: aborting due to previous error error: aborting due to previous error

View file

@ -9,11 +9,21 @@ error[E0532]: expected tuple struct or tuple variant, found unit variant `A::D`
| |
LL | B(isize, isize), LL | B(isize, isize),
| --------------- similarly named tuple variant `B` defined here | --------------- similarly named tuple variant `B` defined here
LL | C(isize, isize, isize),
LL | D
| - `A::D` defined here
... ...
LL | A::D(_) => (), 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 error[E0023]: this pattern has 3 fields, but the corresponding tuple variant has 2 fields
--> $DIR/pattern-error-continue.rs:17:9 --> $DIR/pattern-error-continue.rs:17:9

View 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() {}

View 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`.

View file

@ -5,6 +5,7 @@ LL | struct SomeStruct<A> { x: u32 }
| ^ unused parameter | ^ unused parameter
| |
= help: consider removing `A`, referring to it in a field, or using a marker such as `PhantomData` = 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 error[E0392]: parameter `A` is never used
--> $DIR/variance-unused-type-param.rs:9:15 --> $DIR/variance-unused-type-param.rs:9:15
@ -13,6 +14,7 @@ LL | enum SomeEnum<A> { Nothing }
| ^ unused parameter | ^ unused parameter
| |
= help: consider removing `A`, referring to it in a field, or using a marker such as `PhantomData` = 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 error[E0392]: parameter `T` is never used
--> $DIR/variance-unused-type-param.rs:13:15 --> $DIR/variance-unused-type-param.rs:13:15
@ -21,6 +23,7 @@ LL | enum ListCell<T> {
| ^ unused parameter | ^ unused parameter
| |
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` = 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 error: aborting due to 3 previous errors

View file

@ -77,7 +77,7 @@ fn main() {
let error_kind = ErrorKind::NotFound; let error_kind = ErrorKind::NotFound;
match error_kind { match error_kind {
ErrorKind::NotFound => {}, 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 { match error_kind {
ErrorKind::NotFound => {}, ErrorKind::NotFound => {},
@ -99,6 +99,7 @@ fn main() {
ErrorKind::Other => {}, ErrorKind::Other => {},
ErrorKind::UnexpectedEof => {}, ErrorKind::UnexpectedEof => {},
ErrorKind::Unsupported => {}, ErrorKind::Unsupported => {},
ErrorKind::OutOfMemory => {},
_ => {}, _ => {},
} }
} }

View file

@ -99,6 +99,7 @@ fn main() {
ErrorKind::Other => {}, ErrorKind::Other => {},
ErrorKind::UnexpectedEof => {}, ErrorKind::UnexpectedEof => {},
ErrorKind::Unsupported => {}, ErrorKind::Unsupported => {},
ErrorKind::OutOfMemory => {},
_ => {}, _ => {},
} }
} }

View file

@ -32,7 +32,7 @@ error: wildcard matches known variants and will also match future added variants
--> $DIR/wildcard_enum_match_arm.rs:80:9 --> $DIR/wildcard_enum_match_arm.rs:80:9
| |
LL | _ => {}, 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 error: aborting due to 5 previous errors