[[package]]
name = "cargo"
-version = "0.57.0"
+version = "0.58.0"
dependencies = [
"anyhow",
"atty",
[[package]]
name = "curl-sys"
-version = "0.4.45+curl-7.78.0"
+version = "0.4.47+curl-7.79.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "de9e5a72b1c744eb5dd20b2be4d7eb84625070bb5c4ab9b347b70464ab1e62eb"
+checksum = "1ab94a47d9b61f2d905beb7a3d46aba7704c9f1dfcf84e7d178998d9e95f7989"
dependencies = [
"cc",
"libc",
Never,
/// A tuple (`(A, B, C, D,...)`).
Tup(Vec<P<Ty>>),
- /// An anonymous struct type i.e. `struct { foo: Type }`
- AnonymousStruct(Vec<FieldDef>, bool),
- /// An anonymous union type i.e. `union { bar: Type }`
- AnonymousUnion(Vec<FieldDef>, bool),
/// A path (`module::module::...::Type`), optionally
/// "qualified", e.g., `<Vec<T> as SomeTrait>::SomeType`.
///
visit_vec(bounds, |bound| vis.visit_param_bound(bound));
}
TyKind::MacCall(mac) => vis.visit_mac_call(mac),
- TyKind::AnonymousStruct(fields, ..) | TyKind::AnonymousUnion(fields, ..) => {
- fields.flat_map_in_place(|field| vis.flat_map_field_def(field));
- }
}
vis.visit_span(span);
visit_lazy_tts(tokens, vis);
TyKind::Typeof(ref expression) => visitor.visit_anon_const(expression),
TyKind::Infer | TyKind::ImplicitSelf | TyKind::Err => {}
TyKind::MacCall(ref mac) => visitor.visit_mac_call(mac),
- TyKind::AnonymousStruct(ref fields, ..) | TyKind::AnonymousUnion(ref fields, ..) => {
- walk_list!(visitor, visit_field_def, fields)
- }
TyKind::Never | TyKind::CVarArgs => {}
}
}
}
}
- pub(super) fn lower_field_def(
- &mut self,
- (index, f): (usize, &FieldDef),
- ) -> hir::FieldDef<'hir> {
+ fn lower_field_def(&mut self, (index, f): (usize, &FieldDef)) -> hir::FieldDef<'hir> {
let ty = if let TyKind::Path(ref qself, ref path) = f.ty.kind {
let t = self.lower_path_ty(
&f.ty,
let kind = match t.kind {
TyKind::Infer => hir::TyKind::Infer,
TyKind::Err => hir::TyKind::Err,
- // FIXME(unnamed_fields): IMPLEMENTATION IN PROGRESS
- TyKind::AnonymousStruct(ref _fields, _recovered) => {
- self.sess.struct_span_err(t.span, "anonymous structs are unimplemented").emit();
- hir::TyKind::Err
- }
- TyKind::AnonymousUnion(ref _fields, _recovered) => {
- self.sess.struct_span_err(t.span, "anonymous unions are unimplemented").emit();
- hir::TyKind::Err
- }
TyKind::Slice(ref ty) => hir::TyKind::Slice(self.lower_ty(ty, itctx)),
TyKind::Ptr(ref mt) => hir::TyKind::Ptr(self.lower_mt(mt, itctx)),
TyKind::Rptr(ref region, ref mt) => {
}
}
}
- TyKind::AnonymousStruct(ref fields, ..) | TyKind::AnonymousUnion(ref fields, ..) => {
- self.with_banned_assoc_ty_bound(|this| {
- walk_list!(this, visit_struct_field_def, fields)
- });
- }
_ => visit::walk_ty(self, t),
}
}
fn visit_struct_field_def(&mut self, field: &'a FieldDef) {
if let Some(ident) = field.ident {
if ident.name == kw::Underscore {
- self.check_anonymous_field(field);
self.visit_vis(&field.vis);
self.visit_ident(ident);
self.visit_ty_common(&field.ty);
err.emit();
}
- fn check_anonymous_field(&self, field: &FieldDef) {
- let FieldDef { ty, .. } = field;
- match &ty.kind {
- TyKind::AnonymousStruct(..) | TyKind::AnonymousUnion(..) => {
- // We already checked for `kw::Underscore` before calling this function,
- // so skip the check
- }
- TyKind::Path(..) => {
- // If the anonymous field contains a Path as type, we can't determine
- // if the path is a valid struct or union, so skip the check
- }
- _ => {
- let msg = "unnamed fields can only have struct or union types";
- let label = "not a struct or union";
- self.err_handler()
- .struct_span_err(field.span, msg)
- .span_label(ty.span, label)
- .emit();
- }
- }
- }
-
- fn deny_anonymous_struct(&self, ty: &Ty) {
- match &ty.kind {
- TyKind::AnonymousStruct(..) => {
- self.err_handler()
- .struct_span_err(
- ty.span,
- "anonymous structs are not allowed outside of unnamed struct or union fields",
- )
- .span_label(ty.span, "anonymous struct declared here")
- .emit();
- }
- TyKind::AnonymousUnion(..) => {
- self.err_handler()
- .struct_span_err(
- ty.span,
- "anonymous unions are not allowed outside of unnamed struct or union fields",
- )
- .span_label(ty.span, "anonymous union declared here")
- .emit();
- }
- _ => {}
- }
- }
-
- fn deny_anonymous_field(&self, field: &FieldDef) {
- if let Some(ident) = field.ident {
- if ident.name == kw::Underscore {
- self.err_handler()
- .struct_span_err(
- field.span,
- "anonymous fields are not allowed outside of structs or unions",
- )
- .span_label(ident.span, "anonymous field declared here")
- .emit()
- }
- }
- }
-
fn check_decl_no_pat(decl: &FnDecl, mut report_err: impl FnMut(Span, Option<Ident>, bool)) {
for Param { pat, .. } in &decl.inputs {
match pat.kind {
fn visit_ty(&mut self, ty: &'a Ty) {
self.visit_ty_common(ty);
- self.deny_anonymous_struct(ty);
self.walk_ty(ty)
}
}
fn visit_field_def(&mut self, s: &'a FieldDef) {
- self.deny_anonymous_field(s);
visit::walk_field_def(self, s)
}
// involved, so we only emit errors where there are no other parsing errors.
gate_all!(destructuring_assignment, "destructuring assignments are unstable");
}
- gate_all!(unnamed_fields, "unnamed fields are not yet fully implemented");
// All uses of `gate_all!` below this point were added in #65742,
// and subsequently disabled (with the non-early gating readded).
}
fn maybe_stage_features(sess: &Session, krate: &ast::Crate) {
+ // checks if `#![feature]` has been used to enable any lang feature
+ // does not check the same for lib features unless there's at least one
+ // declared lang feature
use rustc_errors::Applicability;
if !sess.opts.unstable_features.is_nightly_build() {
let lang_features = &sess.features_untracked().declared_lang_features;
+ if lang_features.len() == 0 {
+ return;
+ }
for attr in krate.attrs.iter().filter(|attr| attr.has_name(sym::feature)) {
let mut err = struct_span_err!(
sess.parse_sess.span_diagnostic,
}
self.pclose();
}
- ast::TyKind::AnonymousStruct(ref fields, ..) => {
- self.head("struct");
- self.print_record_struct_body(&fields, ty.span);
- }
- ast::TyKind::AnonymousUnion(ref fields, ..) => {
- self.head("union");
- self.print_record_struct_body(&fields, ty.span);
- }
ast::TyKind::Paren(ref typ) => {
self.popen();
self.print_type(typ);
}
}
- crate fn print_record_struct_body(&mut self, fields: &[ast::FieldDef], span: rustc_span::Span) {
+ crate fn print_record_struct_body(
+ &mut self,
+ fields: &Vec<ast::FieldDef>,
+ span: rustc_span::Span,
+ ) {
+ self.nbsp();
self.bopen();
self.hardbreak_if_not_bol();
}
ast::VariantData::Struct(ref fields, ..) => {
self.print_where_clause(&generics.where_clause);
- self.nbsp();
self.print_record_struct_body(fields, span);
}
}
};
/// This function computes Polonius facts for the given body. It makes a copy of
-/// the body because it needs to regenerate the region identifiers.
+/// the body because it needs to regenerate the region identifiers. This function
+/// should never be invoked during a typical compilation session due to performance
+/// issues with Polonius.
///
/// Note:
/// * This function will panic if the required body was already stolen. This
/// because they are evaluated during typechecking. The panic can be avoided
/// by overriding the `mir_borrowck` query. You can find a complete example
/// that shows how to do this at `src/test/run-make/obtain-borrowck/`.
-/// * This function will also panic if computation of Polonius facts
-/// (`-Zpolonius` flag) is not enabled.
///
/// * Polonius is highly unstable, so expect regular changes in its signature or other details.
pub fn get_body_with_borrowck_facts<'tcx>(
if def_id.as_local() == Some(self.mir_def_id()) && upvar_field.is_some() =>
{
let closure_kind_ty = closure_substs.as_closure().kind_ty();
- let closure_kind = closure_kind_ty.to_opt_closure_kind();
- let capture_description = match closure_kind {
- Some(ty::ClosureKind::Fn) => "captured variable in an `Fn` closure",
- Some(ty::ClosureKind::FnMut) => "captured variable in an `FnMut` closure",
+ let closure_kind = match closure_kind_ty.to_opt_closure_kind() {
+ Some(kind @ (ty::ClosureKind::Fn | ty::ClosureKind::FnMut)) => kind,
Some(ty::ClosureKind::FnOnce) => {
bug!("closure kind does not match first argument type")
}
None => bug!("closure kind not inferred by borrowck"),
};
+ let capture_description =
+ format!("captured variable in an `{}` closure", closure_kind);
let upvar = &self.upvars[upvar_field.unwrap().index()];
let upvar_hir_id = upvar.place.get_root_variable();
let mut diag = self.cannot_move_out_of(span, &place_description);
diag.span_label(upvar_span, "captured outer variable");
+ diag.span_label(
+ self.body.span,
+ format!("captured by this `{}` closure", closure_kind),
+ );
diag
}
debug!("do_mir_borrowck(def = {:?})", def);
- assert!(
- !return_body_with_facts || infcx.tcx.sess.opts.debugging_opts.polonius,
- "borrowck facts can be requested only when Polonius is enabled"
- );
-
let tcx = infcx.tcx;
let param_env = tcx.param_env(def.did);
let id = tcx.hir().local_def_id_to_hir_id(def.did);
let borrow_set =
Rc::new(BorrowSet::build(tcx, body, locals_are_invalidated_at_exit, &mdpe.move_data));
+ let use_polonius = return_body_with_facts || infcx.tcx.sess.opts.debugging_opts.polonius;
+
// Compute non-lexical lifetimes.
let nll::NllOutput {
regioncx,
&mdpe.move_data,
&borrow_set,
&upvars,
+ use_polonius,
);
// Dump MIR results into a file, if that is enabled. This let us
move_data: &MoveData<'tcx>,
borrow_set: &BorrowSet<'tcx>,
upvars: &[Upvar<'tcx>],
+ use_polonius: bool,
) -> NllOutput<'tcx> {
- let mut all_facts = AllFacts::enabled(infcx.tcx).then_some(AllFacts::default());
+ let mut all_facts =
+ (use_polonius || AllFacts::enabled(infcx.tcx)).then_some(AllFacts::default());
let universal_regions = Rc::new(universal_regions);
all_facts.write_to_dir(dir_path, location_table).unwrap();
}
- if infcx.tcx.sess.opts.debugging_opts.polonius {
+ if use_polonius {
let algorithm =
env::var("POLONIUS_ALGORITHM").unwrap_or_else(|_| String::from("Hybrid"));
let algorithm = Algorithm::from_str(&algorithm).unwrap();
/// Calling `universal_upper_bound` for such a region gives `fr_fn_body`,
/// which has no `external_name` in which case we use `'empty` as the
/// region to pass to `infer_opaque_definition_from_instantiation`.
- #[instrument(skip(self, infcx))]
+ #[instrument(level = "debug", skip(self, infcx))]
pub(crate) fn infer_opaque_types(
&self,
infcx: &InferCtxt<'_, 'tcx>,
&obligation,
&traits::SelectionError::Unimplemented,
false,
- false,
);
}
}
// We want to make sure we have the ctxt set so that we can use unstable methods
let span = cx.with_def_site_ctxt(span);
let name = cx.expr_lit(span, ast::LitKind::Str(ident.name, ast::StrStyle::Cooked));
+ let fmt = substr.nonself_args[0].clone();
+
+ // Special fast path for unit variants. In the common case of an enum that is entirely unit
+ // variants (i.e. a C-like enum), this fast path allows LLVM to eliminate the entire switch in
+ // favor of a lookup table.
+ if let ast::VariantData::Unit(..) = vdata {
+ let fn_path_write_str = cx.std_path(&[sym::fmt, sym::Formatter, sym::write_str]);
+ let expr = cx.expr_call_global(span, fn_path_write_str, vec![fmt, name]);
+ let stmts = vec![cx.stmt_expr(expr)];
+ let block = cx.block(span, stmts);
+ return cx.expr_block(block);
+ }
+
let builder = Ident::new(sym::debug_trait_builder, span);
let builder_expr = cx.expr_ident(span, builder);
- let fmt = substr.nonself_args[0].clone();
-
let mut stmts = Vec::with_capacity(fields.len() + 2);
let fn_path_finish;
match vdata {
- ast::VariantData::Tuple(..) | ast::VariantData::Unit(..) => {
+ ast::VariantData::Unit(..) => {
+ cx.span_bug(span, "unit variants should have been handled above");
+ }
+ ast::VariantData::Tuple(..) => {
// tuple struct/"normal" variant
let fn_path_debug_tuple = cx.std_path(&[sym::fmt, sym::Formatter, sym::debug_tuple]);
let expr = cx.expr_call_global(span, fn_path_debug_tuple, vec![fmt, name]);
cmd.arg("-o");
cmd.arg(&dwp_out_filename);
- let mut new_path = sess.host_filesearch(PathKind::All).get_tools_search_paths(false);
+ let mut new_path = sess.get_tools_search_paths(false);
if let Some(path) = env::var_os("PATH") {
new_path.extend(env::split_paths(&path));
}
match ld_impl {
LdImpl::Lld => {
if sess.target.lld_flavor == LldFlavor::Ld64 {
- let tools_path =
- sess.host_filesearch(PathKind::All).get_tools_search_paths(false);
+ let tools_path = sess.get_tools_search_paths(false);
let ld64_exe = tools_path
.into_iter()
.map(|p| p.join("gcc-ld"))
arg
});
} else {
- let tools_path =
- sess.host_filesearch(PathKind::All).get_tools_search_paths(false);
+ let tools_path = sess.get_tools_search_paths(false);
let lld_path = tools_path
.into_iter()
.map(|p| p.join("gcc-ld"))
use rustc_middle::ty::TyCtxt;
use rustc_serialize::{json, Encoder};
use rustc_session::config::{self, CrateType, DebugInfo, LinkerPluginLto, Lto, OptLevel, Strip};
-use rustc_session::search_paths::PathKind;
use rustc_session::Session;
use rustc_span::symbol::Symbol;
use rustc_target::spec::{LinkOutputKind, LinkerFlavor, LldFlavor};
// The compiler's sysroot often has some bundled tools, so add it to the
// PATH for the child.
- let mut new_path = sess.host_filesearch(PathKind::All).get_tools_search_paths(self_contained);
+ let mut new_path = sess.get_tools_search_paths(self_contained);
let mut msvc_changed_path = false;
if sess.target.is_like_msvc {
if let Some(ref tool) = msvc_tool {
assert!(!layout.is_unsized());
let ret = ecx.allocate(layout, MemoryKind::Stack)?;
- let name =
- with_no_trimmed_paths(|| ty::tls::with(|tcx| tcx.def_path_str(cid.instance.def_id())));
- let prom = cid.promoted.map_or_else(String::new, |p| format!("::promoted[{:?}]", p));
- trace!("eval_body_using_ecx: pushing stack frame for global: {}{}", name, prom);
+ trace!(
+ "eval_body_using_ecx: pushing stack frame for global: {}{}",
+ with_no_trimmed_paths(|| ty::tls::with(|tcx| tcx.def_path_str(cid.instance.def_id()))),
+ cid.promoted.map_or_else(String::new, |p| format!("::promoted[{:?}]", p))
+ );
ecx.push_stack_frame(
cid.instance,
let def_id = instance.def_id();
if Some(def_id) == self.tcx.lang_items().panic_fn()
|| Some(def_id) == self.tcx.lang_items().panic_str()
+ || Some(def_id) == self.tcx.lang_items().panic_display()
|| Some(def_id) == self.tcx.lang_items().begin_panic_fn()
{
- // &str
+ // &str or &&str
assert!(args.len() == 1);
- let msg_place = self.deref_operand(&args[0])?;
+ let mut msg_place = self.deref_operand(&args[0])?;
+ while msg_place.layout.ty.is_ref() {
+ msg_place = self.deref_operand(&msg_place.into())?;
+ }
+
let msg = Symbol::intern(self.read_str(&msg_place)?);
let span = self.find_closest_untracked_caller_location();
let (file, line, col) = self.location_triple_for_span(span);
ensure_monomorphic_enough(tcx, tp_ty)?;
ConstValue::from_bool(tp_ty.needs_drop(tcx, param_env))
}
- sym::min_align_of | sym::pref_align_of => {
+ sym::pref_align_of => {
// Correctly handles non-monomorphic calls, so there is no need for ensure_monomorphic_enough.
let layout = tcx.layout_of(param_env.and(tp_ty)).map_err(|e| err_inval!(Layout(e)))?;
- let n = match name {
- sym::pref_align_of => layout.align.pref.bytes(),
- sym::min_align_of => layout.align.abi.bytes(),
- _ => bug!(),
- };
- ConstValue::from_machine_usize(n, &tcx)
+ ConstValue::from_machine_usize(layout.align.pref.bytes(), &tcx)
}
sym::type_id => {
ensure_monomorphic_enough(tcx, tp_ty)?;
if is_lang_panic_fn(tcx, callee) {
self.check_op(ops::Panic);
+ // `begin_panic` and `panic_display` are generic functions that accept
+ // types other than str. Check to enforce that only str can be used in
+ // const-eval.
+
// const-eval of the `begin_panic` fn assumes the argument is `&str`
if Some(callee) == tcx.lang_items().begin_panic_fn() {
match args[0].ty(&self.ccx.body.local_decls, tcx).kind() {
}
}
+ // const-eval of the `panic_display` fn assumes the argument is `&&str`
+ if Some(callee) == tcx.lang_items().panic_display() {
+ match args[0].ty(&self.ccx.body.local_decls, tcx).kind() {
+ ty::Ref(_, ty, _) if matches!(ty.kind(), ty::Ref(_, ty, _) if ty.is_str()) =>
+ {}
+ _ => self.check_op(ops::PanicNonStr),
+ }
+ }
+
return;
}
// Keep in sync with what that function handles!
Some(def_id) == tcx.lang_items().panic_fn()
|| Some(def_id) == tcx.lang_items().panic_str()
+ || Some(def_id) == tcx.lang_items().panic_display()
|| Some(def_id) == tcx.lang_items().begin_panic_fn()
|| Some(def_id) == tcx.lang_items().panic_fmt()
|| Some(def_id) == tcx.lang_items().begin_panic_fmt()
}
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
- feature_err(
+ let mut builder = feature_err(
&ccx.tcx.sess.parse_sess,
sym::const_fn_trait_bound,
span,
"trait bounds other than `Sized` on const fn parameters are unstable",
- )
+ );
+
+ match ccx.fn_sig() {
+ Some(fn_sig) if !fn_sig.span.contains(span) => {
+ builder.span_label(fn_sig.span, "function declared as const here");
+ }
+ _ => {}
+ }
+
+ builder
}
}
qualifs.needs_drop
}
- fn in_any_value_of_ty(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool {
+ fn in_any_value_of_ty(cx: &ConstCx<'_, 'tcx>, mut ty: Ty<'tcx>) -> bool {
+ // Avoid selecting for simple cases.
+ match ty::util::needs_drop_components(ty, &cx.tcx.data_layout).as_deref() {
+ Ok([]) => return false,
+ Err(ty::util::AlwaysRequiresDrop) => return true,
+ // If we've got a single component, select with that
+ // to increase the chance that we hit the selection cache.
+ Ok([t]) => ty = t,
+ Ok([..]) => {}
+ }
+
let drop_trait = if let Some(did) = cx.tcx.lang_items().drop_trait() {
did
} else {
println!("{}", targets.join("\n"));
}
Sysroot => println!("{}", sess.sysroot.display()),
- TargetLibdir => println!(
- "{}",
- sess.target_tlib_path.as_ref().unwrap_or(&sess.host_tlib_path).dir.display()
- ),
+ TargetLibdir => println!("{}", sess.target_tlib_path.dir.display()),
TargetSpec => println!("{}", sess.target.to_json().pretty()),
FileNames | CrateName => {
let input = input.unwrap_or_else(|| {
For example, the code above can be fixed to:
```
-enum Foo {
- FirstValue(i32)
-}
+type U32 = u32;
+let t: U32 = 4;
+```
-fn main() {
- let u = Foo::FirstValue(0i32);
+or:
- let t = 4;
-}
+```
+struct U32 { value: u32 }
+let t = U32 { value: 4 };
```
pub fn highlighted<S: Into<String>>(t: S) -> DiagnosticStyledString {
DiagnosticStyledString(vec![StringPart::Highlighted(t.into())])
}
+
+ pub fn content(&self) -> String {
+ self.0.iter().map(|x| x.content()).collect::<String>()
+ }
}
#[derive(Debug, PartialEq, Eq)]
Highlighted(String),
}
+impl StringPart {
+ pub fn content(&self) -> &str {
+ match self {
+ &StringPart::Normal(ref s) | &StringPart::Highlighted(ref s) => s,
+ }
+ }
+}
+
impl Diagnostic {
pub fn new(level: Level, message: &str) -> Self {
Diagnostic::new_with_code(level, None, message)
// this with just `span.edition()`. A
// `SyntaxContext::root()` from the current crate will
// have the edition of the current crate, and a
- // `SyntaxxContext::root()` from a foreign crate will
+ // `SyntaxContext::root()` from a foreign crate will
// have the edition of that crate (which we manually
// retrieve via the `edition` parameter).
if span.ctxt() == SyntaxContext::root() {
/// Allows specifying the as-needed link modifier
(active, native_link_modifiers_as_needed, "1.53.0", Some(81490), None),
- /// Allows unnamed fields of struct and union type
- (incomplete, unnamed_fields, "1.53.0", Some(49804), None),
-
/// Allows qualified paths in struct expressions, struct patterns and tuple struct patterns.
(active, more_qualified_paths, "1.54.0", Some(86935), None),
// a weak lang item, but do not have it defined.
Panic, sym::panic, panic_fn, Target::Fn, GenericRequirement::None;
PanicFmt, sym::panic_fmt, panic_fmt, Target::Fn, GenericRequirement::None;
+ PanicDisplay, sym::panic_display, panic_display, Target::Fn, GenericRequirement::None;
PanicStr, sym::panic_str, panic_str, Target::Fn, GenericRequirement::None;
ConstPanicFmt, sym::const_panic_fmt, const_panic_fmt, Target::Fn, GenericRequirement::None;
PanicBoundsCheck, sym::panic_bounds_check, panic_bounds_check_fn, Target::Fn, GenericRequirement::None;
trace: TypeTrace<'tcx>,
terr: &TypeError<'tcx>,
) -> DiagnosticBuilder<'tcx> {
+ use crate::traits::ObligationCauseCode::MatchExpressionArm;
+
debug!("report_and_explain_type_error(trace={:?}, terr={:?})", trace, terr);
let span = trace.cause.span(self.tcx);
_ => {}
}
}
+ if let MatchExpressionArm(box MatchExpressionArmCause { source, .. }) =
+ trace.cause.code
+ {
+ if let hir::MatchSource::TryDesugar = source {
+ if let Some((expected_ty, found_ty)) = self.values_str(trace.values) {
+ err.note(&format!(
+ "`?` operator cannot convert from `{}` to `{}`",
+ found_ty.content(),
+ expected_ty.content(),
+ ));
+ }
+ }
+ }
err
}
FailureCode::Error0644(failure_str) => {
CompareImplTypeObligation { .. } => Error0308("type not compatible with trait"),
MatchExpressionArm(box MatchExpressionArmCause { source, .. }) => {
Error0308(match source {
- hir::MatchSource::TryDesugar => {
- "try expression alternatives have incompatible types"
- }
+ hir::MatchSource::TryDesugar => "`?` operator has incompatible types",
_ => "`match` arms have incompatible types",
})
}
SubregionOrigin::Subtype(box TypeTrace { ref cause, .. }) => cause,
_ => return None,
};
- let (parent, impl_def_id) = match &cause.code {
+ // If we added a "points at argument expression" obligation, we remove it here, we care
+ // about the original obligation only.
+ let code = match &cause.code {
+ ObligationCauseCode::FunctionArgumentObligation { parent_code, .. } => &*parent_code,
+ _ => &cause.code,
+ };
+ let (parent, impl_def_id) = match code {
ObligationCauseCode::MatchImpl(parent, impl_def_id) => (parent, impl_def_id),
_ => return None,
};
messages.push(msg.clone());
}
}
- if trait_span.is_some() {
- // Only provide the help if its a local trait, otherwise it's not actionable.
- violation.solution(&mut err);
- }
}
}
let has_multi_span = !multi_span.is_empty();
to be resolvable dynamically; for more information visit \
<https://doc.rust-lang.org/reference/items/traits.html#object-safety>",
);
+ if trait_span.is_some() {
+ let mut reported_violations: Vec<_> = reported_violations.into_iter().collect();
+ reported_violations.sort();
+ for violation in reported_violations {
+ // Only provide the help if its a local trait, otherwise it's not actionable.
+ violation.solution(&mut err);
+ }
+ }
err
}
pub struct FulfillmentError<'tcx> {
pub obligation: PredicateObligation<'tcx>,
pub code: FulfillmentErrorCode<'tcx>,
- /// Diagnostics only: we opportunistically change the `code.span` when we encounter an
- /// obligation error caused by a call argument. When this is the case, we also signal that in
- /// this field to ensure accuracy of suggestions.
- pub points_at_arg_span: bool,
/// Diagnostics only: the 'root' obligation which resulted in
/// the failure to process `obligation`. This is the obligation
/// that was initially passed to `register_predicate_obligation`
code: FulfillmentErrorCode<'tcx>,
root_obligation: PredicateObligation<'tcx>,
) -> FulfillmentError<'tcx> {
- FulfillmentError { obligation, code, points_at_arg_span: false, root_obligation }
+ FulfillmentError { obligation, code, root_obligation }
}
}
assert!(!fresh_key, "never started projecting `{:?}`", key);
}
- /// Mark the relevant projection cache key as having its derived obligations
- /// complete, so they won't have to be re-computed (this is OK to do in a
- /// snapshot - if the snapshot is rolled back, the obligations will be
- /// marked as incomplete again).
- pub fn complete(&mut self, key: ProjectionCacheKey<'tcx>) {
- let mut map = self.map();
- let ty = match map.get(&key) {
- Some(&ProjectionCacheEntry::NormalizedTy(ref ty)) => {
- debug!("ProjectionCacheEntry::complete({:?}) - completing {:?}", key, ty);
- ty.value
- }
- ref value => {
- // Type inference could "strand behind" old cache entries. Leave
- // them alone for now.
- debug!("ProjectionCacheEntry::complete({:?}) - ignoring {:?}", key, value);
- return;
- }
- };
-
- map.insert(
- key,
- ProjectionCacheEntry::NormalizedTy(Normalized { value: ty, obligations: vec![] }),
- );
- }
-
- /// A specialized version of `complete` for when the key's value is known
- /// to be a NormalizedTy.
- pub fn complete_normalized(&mut self, key: ProjectionCacheKey<'tcx>, ty: &NormalizedTy<'tcx>) {
- // We want to insert `ty` with no obligations. If the existing value
- // already has no obligations (as is common) we don't insert anything.
- if !ty.obligations.is_empty() {
- self.map().insert(
- key,
- ProjectionCacheEntry::NormalizedTy(Normalized {
- value: ty.value,
- obligations: vec![],
- }),
- );
- }
- }
-
/// Indicates that trying to normalize `key` resulted in
/// ambiguity. No point in trying it again then until we gain more
/// type information (in which case, the "fully resolved" key will
tracked!(profiler_runtime, "abc".to_string());
tracked!(relax_elf_relocations, Some(true));
tracked!(relro_level, Some(RelroLevel::Full));
+ tracked!(remap_cwd_prefix, Some(PathBuf::from("abc")));
tracked!(simulate_remapped_rust_src_base, Some(PathBuf::from("/rustc/abc")));
tracked!(report_delayed_bugs, true);
tracked!(sanitizer, SanitizerSet::ADDRESS);
use FfiResult::*;
if def.repr.transparent() {
- // Can assume that only one field is not a ZST, so only check
+ // Can assume that at most one field is not a ZST, so only check
// that field's type for FFI-safety.
if let Some(field) = transparent_newtype_field(self.cx.tcx, variant) {
self.check_field_type_for_ffi(cache, field, substs)
} else {
- bug!("malformed transparent type");
+ // All fields are ZSTs; this means that the type should behave
+ // like (), which is FFI-unsafe
+ FfiUnsafe {
+ ty,
+ reason: "this struct contains only zero-sized fields".into(),
+ help: None,
+ }
}
} else {
// We can't completely trust repr(C) markings; make sure the fields are
UNSUPPORTED_CALLING_CONVENTIONS,
BREAK_WITH_LABEL_AND_LOOP,
UNUSED_ATTRIBUTES,
+ NON_EXHAUSTIVE_OMITTED_PATTERNS,
]
}
Warn,
"`break` expression with label and unlabeled loop as value expression"
}
+
+declare_lint! {
+ /// The `non_exhaustive_omitted_patterns` lint detects when a wildcard (`_` or `..`) in a
+ /// pattern for a `#[non_exhaustive]` struct or enum is reachable.
+ ///
+ /// ### Example
+ ///
+ /// ```rust,ignore (needs separate crate)
+ /// // crate A
+ /// #[non_exhaustive]
+ /// pub enum Bar {
+ /// A,
+ /// B, // added variant in non breaking change
+ /// }
+ ///
+ /// // in crate B
+ /// match Bar::A {
+ /// Bar::A => {},
+ /// #[warn(non_exhaustive_omitted_patterns)]
+ /// _ => {},
+ /// }
+ /// ```
+ ///
+ /// This will produce:
+ ///
+ /// ```text
+ /// warning: reachable patterns not covered of non exhaustive enum
+ /// --> $DIR/reachable-patterns.rs:70:9
+ /// |
+ /// LL | _ => {}
+ /// | ^ pattern `B` not covered
+ /// |
+ /// note: the lint level is defined here
+ /// --> $DIR/reachable-patterns.rs:69:16
+ /// |
+ /// LL | #[warn(non_exhaustive_omitted_patterns)]
+ /// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ /// = help: ensure that all possible cases are being handled by adding the suggested match arms
+ /// = note: the matched value is of type `Bar` and the `non_exhaustive_omitted_patterns` attribute was found
+ /// ```
+ ///
+ /// ### Explanation
+ ///
+ /// Structs and enums tagged with `#[non_exhaustive]` force the user to add a
+ /// (potentially redundant) wildcard when pattern-matching, to allow for future
+ /// addition of fields or variants. The `non_exhaustive_omitted_patterns` lint
+ /// detects when such a wildcard happens to actually catch some fields/variants.
+ /// In other words, when the match without the wildcard would not be exhaustive.
+ /// This lets the user be informed if new fields/variants were added.
+ pub NON_EXHAUSTIVE_OMITTED_PATTERNS,
+ Allow,
+ "detect when patterns of types marked `non_exhaustive` are missed",
+}
#if LLVM_VERSION_GE(11, 0)
OptimizerLastEPCallbacks.push_back(
[Options](ModulePassManager &MPM, OptimizationLevel Level) {
+#if LLVM_VERSION_GE(14, 0)
+ MPM.addPass(ModuleMemorySanitizerPass(Options));
+#else
MPM.addPass(MemorySanitizerPass(Options));
+#endif
MPM.addPass(createModuleToFunctionPassAdaptor(MemorySanitizerPass(Options)));
}
);
#if LLVM_VERSION_GE(11, 0)
OptimizerLastEPCallbacks.push_back(
[](ModulePassManager &MPM, OptimizationLevel Level) {
+#if LLVM_VERSION_GE(14, 0)
+ MPM.addPass(ModuleThreadSanitizerPass());
+#else
MPM.addPass(ThreadSanitizerPass());
+#endif
MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
}
);
DerivedObligation(DerivedObligationCause<'tcx>),
+ FunctionArgumentObligation {
+ /// The node of the relevant argument in the function call.
+ arg_hir_id: hir::HirId,
+ /// The node of the function call.
+ call_hir_id: hir::HirId,
+ /// The obligation introduced by this argument.
+ parent_code: Lrc<ObligationCauseCode<'tcx>>,
+ },
+
/// Error derived when matching traits/impls; see ObligationCause for more details
CompareImplConstObligation,
// Return the base obligation, ignoring derived obligations.
pub fn peel_derives(&self) -> &Self {
let mut base_cause = self;
- while let BuiltinDerivedObligation(cause)
- | ImplDerivedObligation(cause)
- | DerivedObligation(cause) = base_cause
+ while let BuiltinDerivedObligation(DerivedObligationCause { parent_code, .. })
+ | ImplDerivedObligation(DerivedObligationCause { parent_code, .. })
+ | DerivedObligation(DerivedObligationCause { parent_code, .. })
+ | FunctionArgumentObligation { parent_code, .. } = base_cause
{
- base_cause = &cause.parent_code;
+ base_cause = &parent_code;
}
base_cause
}
pub nested: Vec<N>,
}
-#[derive(Clone, Debug, PartialEq, Eq, Hash, HashStable)]
+#[derive(Clone, Debug, PartialEq, Eq, Hash, HashStable, PartialOrd, Ord)]
pub enum ObjectSafetyViolation {
/// `Self: Sized` declared on the trait.
SizedSelf(SmallVec<[Span; 1]>),
}
/// Reasons a method might not be object-safe.
-#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, HashStable)]
+#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, HashStable, PartialOrd, Ord)]
pub enum MethodViolationCode {
/// e.g., `fn foo()`
StaticMethod(Option<(&'static str, Span)>, Span, bool /* has args */),
use rustc_hir::{HirId, Pat};
use rustc_middle::thir::PatKind;
use rustc_middle::ty::{self, Ty, TyCtxt};
-use rustc_session::lint::builtin::BINDINGS_WITH_VARIANT_NAME;
-use rustc_session::lint::builtin::{IRREFUTABLE_LET_PATTERNS, UNREACHABLE_PATTERNS};
+use rustc_session::lint::builtin::{
+ BINDINGS_WITH_VARIANT_NAME, IRREFUTABLE_LET_PATTERNS, UNREACHABLE_PATTERNS,
+};
use rustc_session::Session;
use rustc_span::{DesugaringKind, ExpnKind, Span};
use std::slice;
err.emit();
}
-fn joined_uncovered_patterns(witnesses: &[super::Pat<'_>]) -> String {
+crate fn joined_uncovered_patterns(witnesses: &[super::Pat<'_>]) -> String {
const LIMIT: usize = 3;
match witnesses {
[] => bug!(),
}
}
-fn pattern_not_covered_label(witnesses: &[super::Pat<'_>], joined_patterns: &str) -> String {
+crate fn pattern_not_covered_label(witnesses: &[super::Pat<'_>], joined_patterns: &str) -> String {
format!("pattern{} {} not covered", rustc_errors::pluralize!(witnesses.len()), joined_patterns)
}
/// for those types for which we cannot list constructors explicitly, like `f64` and `str`.
NonExhaustive,
/// Stands for constructors that are not seen in the matrix, as explained in the documentation
- /// for [`SplitWildcard`].
- Missing,
+ /// for [`SplitWildcard`]. The carried `bool` is used for the `non_exhaustive_omitted_patterns`
+ /// lint.
+ Missing { nonexhaustive_enum_missing_real_variants: bool },
/// Wildcard pattern.
Wildcard,
}
matches!(self, Wildcard)
}
+ pub(super) fn is_non_exhaustive(&self) -> bool {
+ matches!(self, NonExhaustive)
+ }
+
fn as_int_range(&self) -> Option<&IntRange> {
match self {
IntRange(range) => Some(range),
// Wildcards cover anything
(_, Wildcard) => true,
// The missing ctors are not covered by anything in the matrix except wildcards.
- (Missing | Wildcard, _) => false,
+ (Missing { .. } | Wildcard, _) => false,
(Single, Single) => true,
(Variant(self_id), Variant(other_id)) => self_id == other_id,
.any(|other| slice.is_covered_by(other)),
// This constructor is never covered by anything else
NonExhaustive => false,
- Str(..) | FloatRange(..) | Opaque | Missing | Wildcard => {
+ Str(..) | FloatRange(..) | Opaque | Missing { .. } | Wildcard => {
span_bug!(pcx.span, "found unexpected ctor in all_ctors: {:?}", self)
}
}
&& !cx.tcx.features().exhaustive_patterns
&& !pcx.is_top_level;
- if is_secretly_empty || is_declared_nonexhaustive {
+ if is_secretly_empty {
smallvec![NonExhaustive]
+ } else if is_declared_nonexhaustive {
+ def.variants
+ .indices()
+ .map(|idx| Variant(idx))
+ .chain(Some(NonExhaustive))
+ .collect()
} else if cx.tcx.features().exhaustive_patterns {
// If `exhaustive_patterns` is enabled, we exclude variants known to be
// uninhabited.
// This type is one for which we cannot list constructors, like `str` or `f64`.
_ => smallvec![NonExhaustive],
};
+
SplitWildcard { matrix_ctors: Vec::new(), all_ctors }
}
// sometimes prefer reporting the list of constructors instead of just `_`.
let report_when_all_missing = pcx.is_top_level && !IntRange::is_integral(pcx.ty);
let ctor = if !self.matrix_ctors.is_empty() || report_when_all_missing {
- Missing
+ if pcx.is_non_exhaustive {
+ Missing {
+ nonexhaustive_enum_missing_real_variants: self
+ .iter_missing(pcx)
+ .filter(|c| !c.is_non_exhaustive())
+ .next()
+ .is_some(),
+ }
+ } else {
+ Missing { nonexhaustive_enum_missing_real_variants: false }
+ }
} else {
Wildcard
};
}
_ => bug!("bad slice pattern {:?} {:?}", constructor, ty),
},
- Str(..) | FloatRange(..) | IntRange(..) | NonExhaustive | Opaque | Missing
+ Str(..)
+ | FloatRange(..)
+ | IntRange(..)
+ | NonExhaustive
+ | Opaque
+ | Missing { .. }
| Wildcard => Fields::Slice(&[]),
};
debug!("Fields::wildcards({:?}, {:?}) = {:#?}", constructor, ty, ret);
/// This is roughly the inverse of `specialize_constructor`.
///
/// Examples:
- /// `ctor`: `Constructor::Single`
- /// `ty`: `Foo(u32, u32, u32)`
- /// `self`: `[10, 20, _]`
+ ///
+ /// ```text
+ /// ctor: `Constructor::Single`
+ /// ty: `Foo(u32, u32, u32)`
+ /// self: `[10, 20, _]`
/// returns `Foo(10, 20, _)`
///
- /// `ctor`: `Constructor::Variant(Option::Some)`
- /// `ty`: `Option<bool>`
- /// `self`: `[false]`
+ /// ctor: `Constructor::Variant(Option::Some)`
+ /// ty: `Option<bool>`
+ /// self: `[false]`
/// returns `Some(false)`
+ /// ```
pub(super) fn apply(self, pcx: PatCtxt<'_, 'p, 'tcx>, ctor: &Constructor<'tcx>) -> Pat<'tcx> {
let subpatterns_and_indices = self.patterns_and_indices();
let mut subpatterns = subpatterns_and_indices.iter().map(|&(_, p)| p).cloned();
NonExhaustive => PatKind::Wild,
Wildcard => return Pat::wildcard_from_ty(pcx.ty),
Opaque => bug!("we should not try to apply an opaque constructor"),
- Missing => bug!(
+ Missing { .. } => bug!(
"trying to apply the `Missing` constructor; this should have been done in `apply_constructors`"
),
};
//! The details are not necessary to understand this file, so we explain them in
//! [`super::deconstruct_pat`]. Splitting is done by the [`Constructor::split`] function.
+use self::ArmType::*;
use self::Usefulness::*;
-use self::WitnessPreference::*;
+use super::check_match::{joined_uncovered_patterns, pattern_not_covered_label};
use super::deconstruct_pat::{Constructor, Fields, SplitWildcard};
use super::{PatternFoldable, PatternFolder};
use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::FxHashMap;
+use hir::def_id::DefId;
+use hir::HirId;
use rustc_arena::TypedArena;
-use rustc_hir::def_id::DefId;
-use rustc_hir::HirId;
+use rustc_hir as hir;
use rustc_middle::thir::{Pat, PatKind};
use rustc_middle::ty::{self, Ty, TyCtxt};
+use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS;
use rustc_span::Span;
use smallvec::{smallvec, SmallVec};
/// Whether the current pattern is the whole pattern as found in a match arm, or if it's a
/// subpattern.
pub(super) is_top_level: bool,
+ /// Wether the current pattern is from a `non_exhaustive` enum.
+ pub(super) is_non_exhaustive: bool,
}
impl<'a, 'p, 'tcx> fmt::Debug for PatCtxt<'a, 'p, 'tcx> {
/// of potential unreachable sub-patterns (in the presence of or-patterns). When checking
/// exhaustiveness of a whole match, we use the `WithWitnesses` variant, which carries a list of
/// witnesses of non-exhaustiveness when there are any.
-/// Which variant to use is dictated by `WitnessPreference`.
+/// Which variant to use is dictated by `ArmType`.
#[derive(Clone, Debug)]
enum Usefulness<'p, 'tcx> {
/// Carries a set of subpatterns that have been found to be reachable. If empty, this indicates
}
impl<'p, 'tcx> Usefulness<'p, 'tcx> {
- fn new_useful(preference: WitnessPreference) -> Self {
+ fn new_useful(preference: ArmType) -> Self {
match preference {
- ConstructWitness => WithWitnesses(vec![Witness(vec![])]),
- LeaveOutWitness => NoWitnesses(SubPatSet::full()),
+ FakeExtraWildcard => WithWitnesses(vec![Witness(vec![])]),
+ RealArm => NoWitnesses(SubPatSet::full()),
}
}
- fn new_not_useful(preference: WitnessPreference) -> Self {
+
+ fn new_not_useful(preference: ArmType) -> Self {
match preference {
- ConstructWitness => WithWitnesses(vec![]),
- LeaveOutWitness => NoWitnesses(SubPatSet::empty()),
+ FakeExtraWildcard => WithWitnesses(vec![]),
+ RealArm => NoWitnesses(SubPatSet::empty()),
+ }
+ }
+
+ fn is_useful(&self) -> bool {
+ match self {
+ Usefulness::NoWitnesses(set) => !set.is_empty(),
+ Usefulness::WithWitnesses(witnesses) => !witnesses.is_empty(),
}
}
/// When trying several branches and each returns a `Usefulness`, we need to combine the
/// results together.
- fn merge(pref: WitnessPreference, usefulnesses: impl Iterator<Item = Self>) -> Self {
+ fn merge(pref: ArmType, usefulnesses: impl Iterator<Item = Self>) -> Self {
let mut ret = Self::new_not_useful(pref);
for u in usefulnesses {
ret.extend(u);
}
}
- /// After calculating usefulness after a specialization, call this to recontruct a usefulness
+ /// After calculating usefulness after a specialization, call this to reconstruct a usefulness
/// that makes sense for the matrix pre-specialization. This new usefulness can then be merged
/// with the results of specializing with the other constructors.
fn apply_constructor(
match self {
WithWitnesses(witnesses) if witnesses.is_empty() => WithWitnesses(witnesses),
WithWitnesses(witnesses) => {
- let new_witnesses = if matches!(ctor, Constructor::Missing) {
- let mut split_wildcard = SplitWildcard::new(pcx);
- split_wildcard.split(pcx, matrix.head_ctors(pcx.cx));
- // Construct for each missing constructor a "wild" version of this
- // constructor, that matches everything that can be built with
- // it. For example, if `ctor` is a `Constructor::Variant` for
- // `Option::Some`, we get the pattern `Some(_)`.
- let new_patterns: Vec<_> = split_wildcard
- .iter_missing(pcx)
- .map(|missing_ctor| {
- Fields::wildcards(pcx, missing_ctor).apply(pcx, missing_ctor)
- })
- .collect();
+ let new_witnesses = if let Constructor::Missing { .. } = ctor {
+ // We got the special `Missing` constructor, so each of the missing constructors
+ // gives a new pattern that is not caught by the match. We list those patterns.
+ let new_patterns = if pcx.is_non_exhaustive {
+ // Here we don't want the user to try to list all variants, we want them to add
+ // a wildcard, so we only suggest that.
+ vec![
+ Fields::wildcards(pcx, &Constructor::NonExhaustive)
+ .apply(pcx, &Constructor::NonExhaustive),
+ ]
+ } else {
+ let mut split_wildcard = SplitWildcard::new(pcx);
+ split_wildcard.split(pcx, matrix.head_ctors(pcx.cx));
+ // Construct for each missing constructor a "wild" version of this
+ // constructor, that matches everything that can be built with
+ // it. For example, if `ctor` is a `Constructor::Variant` for
+ // `Option::Some`, we get the pattern `Some(_)`.
+ split_wildcard
+ .iter_missing(pcx)
+ .map(|missing_ctor| {
+ Fields::wildcards(pcx, missing_ctor).apply(pcx, missing_ctor)
+ })
+ .collect()
+ };
+
witnesses
.into_iter()
.flat_map(|witness| {
}
#[derive(Copy, Clone, Debug)]
-enum WitnessPreference {
- ConstructWitness,
- LeaveOutWitness,
+enum ArmType {
+ FakeExtraWildcard,
+ RealArm,
}
/// A witness of non-exhaustiveness for error reporting, represented
}
}
+/// Report that a match of a `non_exhaustive` enum marked with `non_exhaustive_omitted_patterns`
+/// is not exhaustive enough.
+///
+/// NB: The partner lint for structs lives in `compiler/rustc_typeck/src/check/pat.rs`.
+fn lint_non_exhaustive_omitted_patterns<'p, 'tcx>(
+ cx: &MatchCheckCtxt<'p, 'tcx>,
+ scrut_ty: Ty<'tcx>,
+ sp: Span,
+ hir_id: HirId,
+ witnesses: Vec<Pat<'tcx>>,
+) {
+ let joined_patterns = joined_uncovered_patterns(&witnesses);
+ cx.tcx.struct_span_lint_hir(NON_EXHAUSTIVE_OMITTED_PATTERNS, hir_id, sp, |build| {
+ let mut lint = build.build("some variants are not matched explicitly");
+ lint.span_label(sp, pattern_not_covered_label(&witnesses, &joined_patterns));
+ lint.help(
+ "ensure that all variants are matched explicitly by adding the suggested match arms",
+ );
+ lint.note(&format!(
+ "the matched value is of type `{}` and the `non_exhaustive_omitted_patterns` attribute was found",
+ scrut_ty,
+ ));
+ lint.emit();
+ });
+}
+
/// Algorithm from <http://moscova.inria.fr/~maranget/papers/warn/index.html>.
/// The algorithm from the paper has been modified to correctly handle empty
/// types. The changes are:
cx: &MatchCheckCtxt<'p, 'tcx>,
matrix: &Matrix<'p, 'tcx>,
v: &PatStack<'p, 'tcx>,
- witness_preference: WitnessPreference,
+ witness_preference: ArmType,
hir_id: HirId,
is_under_guard: bool,
is_top_level: bool,
// FIXME(Nadrieril): Hack to work around type normalization issues (see #72476).
let ty = matrix.heads().next().map_or(v.head().ty, |r| r.ty);
- let pcx = PatCtxt { cx, ty, span: v.head().span, is_top_level };
+ let is_non_exhaustive = cx.is_foreign_non_exhaustive_enum(ty);
+ let pcx = PatCtxt { cx, ty, span: v.head().span, is_top_level, is_non_exhaustive };
// If the first pattern is an or-pattern, expand it.
let ret = if is_or_pat(v.head()) {
}
// We split the head constructor of `v`.
let split_ctors = v_ctor.split(pcx, matrix.head_ctors(cx));
+ let is_non_exhaustive_and_wild = is_non_exhaustive && v_ctor.is_wildcard();
// For each constructor, we compute whether there's a value that starts with it that would
// witness the usefulness of `v`.
let start_matrix = &matrix;
let v = v.pop_head_constructor(&ctor_wild_subpatterns);
let usefulness =
is_useful(cx, &spec_matrix, &v, witness_preference, hir_id, is_under_guard, false);
+
+ // When all the conditions are met we have a match with a `non_exhaustive` enum
+ // that has the potential to trigger the `non_exhaustive_omitted_patterns` lint.
+ // To understand the workings checkout `Constructor::split` and `SplitWildcard::new/into_ctors`
+ if is_non_exhaustive_and_wild
+ // We check that the match has a wildcard pattern and that that wildcard is useful,
+ // meaning there are variants that are covered by the wildcard. Without the check
+ // for `witness_preference` the lint would trigger on `if let NonExhaustiveEnum::A = foo {}`
+ && usefulness.is_useful() && matches!(witness_preference, RealArm)
+ && matches!(
+ &ctor,
+ Constructor::Missing { nonexhaustive_enum_missing_real_variants: true }
+ )
+ {
+ let patterns = {
+ let mut split_wildcard = SplitWildcard::new(pcx);
+ split_wildcard.split(pcx, matrix.head_ctors(pcx.cx));
+ // Construct for each missing constructor a "wild" version of this
+ // constructor, that matches everything that can be built with
+ // it. For example, if `ctor` is a `Constructor::Variant` for
+ // `Option::Some`, we get the pattern `Some(_)`.
+ split_wildcard
+ .iter_missing(pcx)
+ // Filter out the `Constructor::NonExhaustive` variant it's meaningless
+ // to our lint
+ .filter(|c| !c.is_non_exhaustive())
+ .map(|missing_ctor| {
+ Fields::wildcards(pcx, missing_ctor).apply(pcx, missing_ctor)
+ })
+ .collect::<Vec<_>>()
+ };
+
+ lint_non_exhaustive_omitted_patterns(pcx.cx, pcx.ty, pcx.span, hir_id, patterns);
+ }
+
usefulness.apply_constructor(pcx, start_matrix, &ctor, &ctor_wild_subpatterns)
});
Usefulness::merge(witness_preference, usefulnesses)
};
+
debug!(?ret);
ret
}
.copied()
.map(|arm| {
let v = PatStack::from_pattern(arm.pat);
- let usefulness =
- is_useful(cx, &matrix, &v, LeaveOutWitness, arm.hir_id, arm.has_guard, true);
+ let usefulness = is_useful(cx, &matrix, &v, RealArm, arm.hir_id, arm.has_guard, true);
if !arm.has_guard {
matrix.push(v);
}
let wild_pattern = cx.pattern_arena.alloc(Pat::wildcard_from_ty(scrut_ty));
let v = PatStack::from_pattern(wild_pattern);
- let usefulness = is_useful(cx, &matrix, &v, ConstructWitness, scrut_hir_id, false, true);
+ let usefulness = is_useful(cx, &matrix, &v, FakeExtraWildcard, scrut_hir_id, false, true);
let non_exhaustiveness_witnesses = match usefulness {
WithWitnesses(pats) => pats.into_iter().map(|w| w.single_pattern()).collect(),
NoWitnesses(_) => bug!(),
on_lookup_result_bits,
};
pub use self::framework::{
- fmt, lattice, visit_results, Analysis, AnalysisDomain, Backward, Direction, Engine, Forward,
- GenKill, GenKillAnalysis, JoinSemiLattice, Results, ResultsCursor, ResultsRefCursor,
+ fmt, graphviz, lattice, visit_results, Analysis, AnalysisDomain, Backward, Direction, Engine,
+ Forward, GenKill, GenKillAnalysis, JoinSemiLattice, Results, ResultsCursor, ResultsRefCursor,
ResultsVisitable, ResultsVisitor,
};
use rustc_const_eval::transform::check_consts;
use rustc_const_eval::transform::promote_consts;
use rustc_const_eval::transform::validate;
-use rustc_const_eval::transform::MirPass;
+pub use rustc_const_eval::transform::MirPass;
use rustc_mir_dataflow::rustc_peek;
pub fn provide(providers: &mut Providers) {
impl<'tcx> MirPass<'tcx> for RemoveZsts {
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
+ // Avoid query cycles (generators require optimized MIR for layout).
+ if tcx.type_of(body.source.def_id()).is_generator() {
+ return;
+ }
let param_env = tcx.param_env(body.source.def_id());
let (basic_blocks, local_decls) = body.basic_blocks_and_local_decls_mut();
for block in basic_blocks.iter_mut() {
/// Determine which generic parameters are used by the function/method/closure represented by
/// `def_id`. Returns a bitset where bits representing unused parameters are set (`is_empty`
/// indicates all parameters are used).
-#[instrument(skip(tcx))]
+#[instrument(level = "debug", skip(tcx))]
fn unused_generic_params(tcx: TyCtxt<'_>, def_id: DefId) -> FiniteBitSet<u32> {
if !tcx.sess.opts.debugging_opts.polymorphize {
// If polymorphization disabled, then all parameters are used.
/// Some parameters are considered used-by-default, such as non-generic parameters and the dummy
/// generic parameters from closures, this function marks them as used. `leaf_is_closure` should
/// be `true` if the item that `unused_generic_params` was invoked on is a closure.
-#[instrument(skip(tcx, def_id, generics, unused_parameters))]
+#[instrument(level = "debug", skip(tcx, def_id, generics, unused_parameters))]
fn mark_used_by_default_parameters<'tcx>(
tcx: TyCtxt<'tcx>,
def_id: DefId,
/// Search the predicates on used generic parameters for any unused generic parameters, and mark
/// those as used.
-#[instrument(skip(tcx, def_id))]
+#[instrument(level = "debug", skip(tcx, def_id))]
fn mark_used_by_predicates<'tcx>(
tcx: TyCtxt<'tcx>,
def_id: DefId,
/// Emit errors for the function annotated by `#[rustc_polymorphize_error]`, labelling each generic
/// parameter which was unused.
-#[instrument(skip(tcx, generics))]
+#[instrument(level = "debug", skip(tcx, generics))]
fn emit_unused_generic_params_error<'tcx>(
tcx: TyCtxt<'tcx>,
def_id: DefId,
impl<'a, 'tcx> MarkUsedGenericParams<'a, 'tcx> {
/// Invoke `unused_generic_params` on a body contained within the current item (e.g.
/// a closure, generator or constant).
- #[instrument(skip(self, def_id, substs))]
+ #[instrument(level = "debug", skip(self, def_id, substs))]
fn visit_child_body(&mut self, def_id: DefId, substs: SubstsRef<'tcx>) {
let unused = self.tcx.unused_generic_params(def_id);
debug!(?self.unused_parameters, ?unused);
}
impl<'a, 'tcx> Visitor<'tcx> for MarkUsedGenericParams<'a, 'tcx> {
- #[instrument(skip(self, local))]
+ #[instrument(level = "debug", skip(self, local))]
fn visit_local_decl(&mut self, local: Local, local_decl: &LocalDecl<'tcx>) {
if local == Local::from_usize(1) {
let def_kind = self.tcx.def_kind(self.def_id);
fn tcx_for_anon_const_substs(&self) -> Option<TyCtxt<'tcx>> {
Some(self.tcx)
}
- #[instrument(skip(self))]
+ #[instrument(level = "debug", skip(self))]
fn visit_const(&mut self, c: &'tcx Const<'tcx>) -> ControlFlow<Self::BreakTy> {
if !c.potentially_has_param_types_or_consts() {
return ControlFlow::CONTINUE;
}
}
- #[instrument(skip(self))]
+ #[instrument(level = "debug", skip(self))]
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
if !ty.potentially_has_param_types_or_consts() {
return ControlFlow::CONTINUE;
Some(self.tcx)
}
- #[instrument(skip(self))]
+ #[instrument(level = "debug", skip(self))]
fn visit_const(&mut self, c: &'tcx Const<'tcx>) -> ControlFlow<Self::BreakTy> {
if !c.potentially_has_param_types_or_consts() {
return ControlFlow::CONTINUE;
}
}
- #[instrument(skip(self))]
+ #[instrument(level = "debug", skip(self))]
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
if !ty.potentially_has_param_types_or_consts() {
return ControlFlow::CONTINUE;
pub(super) fn recover_parens_around_for_head(
&mut self,
pat: P<Pat>,
- expr: &Expr,
begin_paren: Option<Span>,
) -> P<Pat> {
match (&self.token.kind, begin_paren) {
(token::CloseDelim(token::Paren), Some(begin_par_sp)) => {
self.bump();
- let pat_str = self
- // Remove the `(` from the span of the pattern:
- .span_to_snippet(pat.span.trim_start(begin_par_sp).unwrap())
- .unwrap_or_else(|_| pprust::pat_to_string(&pat));
-
- self.struct_span_err(self.prev_token.span, "unexpected closing `)`")
- .span_label(begin_par_sp, "opening `(`")
- .span_suggestion(
- begin_par_sp.to(self.prev_token.span),
- "remove parenthesis in `for` loop",
- format!("{} in {}", pat_str, pprust::expr_to_string(&expr)),
- // With e.g. `for (x) in y)` this would replace `(x) in y)`
- // with `x) in y)` which is syntactically invalid.
- // However, this is prevented before we get here.
- Applicability::MachineApplicable,
- )
- .emit();
+ self.struct_span_err(
+ MultiSpan::from_spans(vec![begin_par_sp, self.prev_token.span]),
+ "unexpected parenthesis surrounding `for` loop head",
+ )
+ .multipart_suggestion(
+ "remove parenthesis in `for` loop",
+ vec![(begin_par_sp, String::new()), (self.prev_token.span, String::new())],
+ // With e.g. `for (x) in y)` this would replace `(x) in y)`
+ // with `x) in y)` which is syntactically invalid.
+ // However, this is prevented before we get here.
+ Applicability::MachineApplicable,
+ )
+ .emit();
// Unwrap `(pat)` into `pat` to avoid the `unused_parens` lint.
pat.and_then(|pat| match pat.kind {
}
match self.parse_expr_res(Restrictions::CONST_EXPR, None) {
Ok(expr) => {
- if token::Comma == self.token.kind || self.token.kind.should_end_const_arg() {
+ // Find a mistake like `MyTrait<Assoc == S::Assoc>`.
+ if token::EqEq == snapshot.token.kind {
+ err.span_suggestion(
+ snapshot.token.span,
+ "if you meant to use an associated type binding, replace `==` with `=`",
+ "=".to_string(),
+ Applicability::MaybeIncorrect,
+ );
+ let value = self.mk_expr_err(start.to(expr.span));
+ err.emit();
+ return Ok(GenericArg::Const(AnonConst { id: ast::DUMMY_NODE_ID, value }));
+ } else if token::Comma == self.token.kind || self.token.kind.should_end_const_arg()
+ {
// Avoid the following output by checking that we consumed a full const arg:
// help: expressions must be enclosed in braces to be used as const generic
// arguments
}
}
+ fn look_ahead_type_ascription_as_field(&mut self) -> bool {
+ self.look_ahead(1, |t| t.is_ident())
+ && self.look_ahead(2, |t| t == &token::Colon)
+ && self.look_ahead(3, |t| t.can_begin_expr())
+ }
+
fn parse_dot_suffix_expr(&mut self, lo: Span, base: P<Expr>) -> PResult<'a, P<Expr>> {
match self.token.uninterpolate().kind {
token::Ident(..) => self.parse_dot_suffix(base, lo),
/// Parse a function call expression, `expr(...)`.
fn parse_fn_call_expr(&mut self, lo: Span, fun: P<Expr>) -> P<Expr> {
- let seq = self.parse_paren_expr_seq().map(|args| {
+ let snapshot = if self.token.kind == token::OpenDelim(token::Paren)
+ && self.look_ahead_type_ascription_as_field()
+ {
+ Some((self.clone(), fun.kind.clone()))
+ } else {
+ None
+ };
+ let open_paren = self.token.span;
+
+ let mut seq = self.parse_paren_expr_seq().map(|args| {
self.mk_expr(lo.to(self.prev_token.span), self.mk_call(fun, args), AttrVec::new())
});
+ if let Some(expr) =
+ self.maybe_recover_struct_lit_bad_delims(lo, open_paren, &mut seq, snapshot)
+ {
+ return expr;
+ }
self.recover_seq_parse_error(token::Paren, lo, seq)
}
+ /// If we encounter a parser state that looks like the user has written a `struct` literal with
+ /// parentheses instead of braces, recover the parser state and provide suggestions.
+ fn maybe_recover_struct_lit_bad_delims(
+ &mut self,
+ lo: Span,
+ open_paren: Span,
+ seq: &mut PResult<'a, P<Expr>>,
+ snapshot: Option<(Self, ExprKind)>,
+ ) -> Option<P<Expr>> {
+ match (seq.as_mut(), snapshot) {
+ (Err(ref mut err), Some((mut snapshot, ExprKind::Path(None, path)))) => {
+ let name = pprust::path_to_string(&path);
+ snapshot.bump(); // `(`
+ match snapshot.parse_struct_fields(path.clone(), false, token::Paren) {
+ Ok((fields, ..)) if snapshot.eat(&token::CloseDelim(token::Paren)) => {
+ // We have are certain we have `Enum::Foo(a: 3, b: 4)`, suggest
+ // `Enum::Foo { a: 3, b: 4 }` or `Enum::Foo(3, 4)`.
+ *self = snapshot;
+ let close_paren = self.prev_token.span;
+ let span = lo.to(self.prev_token.span);
+ err.cancel();
+ self.struct_span_err(
+ span,
+ "invalid `struct` delimiters or `fn` call arguments",
+ )
+ .multipart_suggestion(
+ &format!("if `{}` is a struct, use braces as delimiters", name),
+ vec![(open_paren, " { ".to_string()), (close_paren, " }".to_string())],
+ Applicability::MaybeIncorrect,
+ )
+ .multipart_suggestion(
+ &format!("if `{}` is a function, use the arguments directly", name),
+ fields
+ .into_iter()
+ .map(|field| (field.span.until(field.expr.span), String::new()))
+ .collect(),
+ Applicability::MaybeIncorrect,
+ )
+ .emit();
+ return Some(self.mk_expr_err(span));
+ }
+ Ok(_) => {}
+ Err(mut err) => err.emit(),
+ }
+ }
+ _ => {}
+ }
+ None
+ }
+
/// Parse an indexing expression `expr[...]`.
fn parse_index_expr(&mut self, lo: Span, base: P<Expr>) -> PResult<'a, P<Expr>> {
self.bump(); // `[`
self.check_for_for_in_in_typo(self.prev_token.span);
let expr = self.parse_expr_res(Restrictions::NO_STRUCT_LITERAL, None)?;
- let pat = self.recover_parens_around_for_head(pat, &expr, begin_paren);
+ let pat = self.recover_parens_around_for_head(pat, begin_paren);
let (iattrs, loop_block) = self.parse_inner_attrs_and_block()?;
attrs.extend(iattrs);
.emit();
}
- /// Precondition: already parsed the '{'.
- pub(super) fn parse_struct_expr(
+ pub(super) fn parse_struct_fields(
&mut self,
- qself: Option<ast::QSelf>,
pth: ast::Path,
- attrs: AttrVec,
recover: bool,
- ) -> PResult<'a, P<Expr>> {
+ close_delim: token::DelimToken,
+ ) -> PResult<'a, (Vec<ExprField>, ast::StructRest, bool)> {
let mut fields = Vec::new();
let mut base = ast::StructRest::None;
let mut recover_async = false;
e.note("for more on editions, read https://doc.rust-lang.org/edition-guide");
};
- while self.token != token::CloseDelim(token::Brace) {
+ while self.token != token::CloseDelim(close_delim) {
if self.eat(&token::DotDot) {
let exp_span = self.prev_token.span;
// We permit `.. }` on the left-hand side of a destructuring assignment.
- if self.check(&token::CloseDelim(token::Brace)) {
+ if self.check(&token::CloseDelim(close_delim)) {
self.sess.gated_spans.gate(sym::destructuring_assignment, self.prev_token.span);
base = ast::StructRest::Rest(self.prev_token.span.shrink_to_hi());
break;
}
};
- match self.expect_one_of(&[token::Comma], &[token::CloseDelim(token::Brace)]) {
+ match self.expect_one_of(&[token::Comma], &[token::CloseDelim(close_delim)]) {
Ok(_) => {
if let Some(f) = parsed_field.or(recovery_field) {
// Only include the field if there's no parse error for the field name.
}
}
}
+ Ok((fields, base, recover_async))
+ }
- let span = pth.span.to(self.token.span);
+ /// Precondition: already parsed the '{'.
+ pub(super) fn parse_struct_expr(
+ &mut self,
+ qself: Option<ast::QSelf>,
+ pth: ast::Path,
+ attrs: AttrVec,
+ recover: bool,
+ ) -> PResult<'a, P<Expr>> {
+ let lo = pth.span;
+ let (fields, base, recover_async) =
+ self.parse_struct_fields(pth.clone(), recover, token::Brace)?;
+ let span = lo.to(self.token.span);
self.expect(&token::CloseDelim(token::Brace))?;
let expr = if recover_async {
ExprKind::Err
Ok((class_name, ItemKind::Union(vdata, generics)))
}
- pub(super) fn parse_record_struct_body(
+ fn parse_record_struct_body(
&mut self,
adt_ty: &str,
) -> PResult<'a, (Vec<FieldDef>, /* recovered */ bool)> {
fn parse_field_ident(&mut self, adt_ty: &str, lo: Span) -> PResult<'a, Ident> {
let (ident, is_raw) = self.ident_or_err()?;
if !is_raw && ident.is_reserved() {
- if ident.name == kw::Underscore {
- self.sess.gated_spans.gate(sym::unnamed_fields, lo);
+ let err = if self.check_fn_front_matter(false) {
+ // We use `parse_fn` to get a span for the function
+ if let Err(mut db) = self.parse_fn(&mut Vec::new(), |_| true, lo) {
+ db.delay_as_bug();
+ }
+ let mut err = self.struct_span_err(
+ lo.to(self.prev_token.span),
+ &format!("functions are not allowed in {} definitions", adt_ty),
+ );
+ err.help("unlike in C++, Java, and C#, functions are declared in `impl` blocks");
+ err.help("see https://doc.rust-lang.org/book/ch05-03-method-syntax.html for more information");
+ err
} else {
- let err = if self.check_fn_front_matter(false) {
- // We use `parse_fn` to get a span for the function
- if let Err(mut db) = self.parse_fn(&mut Vec::new(), |_| true, lo) {
- db.delay_as_bug();
- }
- let mut err = self.struct_span_err(
- lo.to(self.prev_token.span),
- &format!("functions are not allowed in {} definitions", adt_ty),
- );
- err.help(
- "unlike in C++, Java, and C#, functions are declared in `impl` blocks",
- );
- err.help("see https://doc.rust-lang.org/book/ch05-03-method-syntax.html for more information");
- err
- } else {
- self.expected_ident_found()
- };
- return Err(err);
- }
+ self.expected_ident_found()
+ };
+ return Err(err);
}
self.bump();
Ok(ident)
let mac = MacCall { path, args, prior_type_ascription: self.last_type_ascription };
- let kind = if delim == token::Brace || self.token == token::Semi || self.token == token::Eof
- {
- StmtKind::MacCall(P(MacCallStmt { mac, style, attrs, tokens: None }))
- } else {
- // Since none of the above applied, this is an expression statement macro.
- let e = self.mk_expr(lo.to(hi), ExprKind::MacCall(mac), AttrVec::new());
- let e = self.maybe_recover_from_bad_qpath(e, true)?;
- let e = self.parse_dot_or_call_expr_with(e, lo, attrs.into())?;
- let e = self.parse_assoc_expr_with(0, LhsExpr::AlreadyParsed(e))?;
- StmtKind::Expr(e)
- };
+ let kind =
+ if (delim == token::Brace && self.token != token::Dot && self.token != token::Question)
+ || self.token == token::Semi
+ || self.token == token::Eof
+ {
+ StmtKind::MacCall(P(MacCallStmt { mac, style, attrs, tokens: None }))
+ } else {
+ // Since none of the above applied, this is an expression statement macro.
+ let e = self.mk_expr(lo.to(hi), ExprKind::MacCall(mac), AttrVec::new());
+ let e = self.maybe_recover_from_bad_qpath(e, true)?;
+ let e = self.parse_dot_or_call_expr_with(e, lo, attrs.into())?;
+ let e = self.parse_assoc_expr_with(0, LhsExpr::AlreadyParsed(e))?;
+ StmtKind::Expr(e)
+ };
Ok(self.mk_stmt(lo.to(hi), kind))
}
}
} else if self.eat_keyword(kw::Impl) {
self.parse_impl_ty(&mut impl_dyn_multi)?
- } else if self.token.is_keyword(kw::Union)
- && self.look_ahead(1, |t| t == &token::OpenDelim(token::Brace))
- {
- self.bump();
- let (fields, recovered) = self.parse_record_struct_body("union")?;
- let span = lo.to(self.prev_token.span);
- self.sess.gated_spans.gate(sym::unnamed_fields, span);
- TyKind::AnonymousUnion(fields, recovered)
- } else if self.eat_keyword(kw::Struct) {
- let (fields, recovered) = self.parse_record_struct_body("struct")?;
- let span = lo.to(self.prev_token.span);
- self.sess.gated_spans.gate(sym::unnamed_fields, span);
- TyKind::AnonymousStruct(fields, recovered)
} else if self.is_explicit_dyn_type() {
self.parse_dyn_ty(&mut impl_dyn_multi)?
} else if self.eat_lt() {
let declared_lib_features = &tcx.features().declared_lib_features;
let mut remaining_lib_features = FxHashMap::default();
for (feature, span) in declared_lib_features {
+ if !tcx.sess.opts.unstable_features.is_nightly_build() {
+ struct_span_err!(
+ tcx.sess,
+ *span,
+ E0554,
+ "`#![feature]` may not be used on the {} release channel",
+ env!("CFG_RELEASE_CHANNEL")
+ )
+ .emit();
+ }
if remaining_lib_features.contains_key(&feature) {
// Warn if the user enables a lib feature multiple times.
duplicate_feature_err(tcx.sess, *span, *feature);
impl<'a, K: DepKind + Decodable<opaque::Decoder<'a>>> Decodable<opaque::Decoder<'a>>
for SerializedDepGraph<K>
{
- #[instrument(skip(d))]
+ #[instrument(level = "debug", skip(d))]
fn decode(d: &mut opaque::Decoder<'a>) -> Result<SerializedDepGraph<K>, String> {
let start_position = d.position();
}
}
- #[instrument(skip(self, record_graph))]
+ #[instrument(level = "debug", skip(self, record_graph))]
fn encode_node(
&mut self,
node: &NodeInfo<K>,
fn parse_remap_path_prefix(
matches: &getopts::Matches,
+ debugging_opts: &DebuggingOptions,
error_format: ErrorOutputType,
) -> Vec<(PathBuf, PathBuf)> {
- matches
+ let mut mapping: Vec<(PathBuf, PathBuf)> = matches
.opt_strs("remap-path-prefix")
.into_iter()
.map(|remap| match remap.rsplit_once('=') {
),
Some((from, to)) => (PathBuf::from(from), PathBuf::from(to)),
})
- .collect()
+ .collect();
+ match &debugging_opts.remap_cwd_prefix {
+ Some(to) => match std::env::current_dir() {
+ Ok(cwd) => mapping.push((cwd, to.clone())),
+ Err(_) => (),
+ },
+ None => (),
+ };
+ mapping
}
pub fn build_session_options(matches: &getopts::Matches) -> Options {
let crate_name = matches.opt_str("crate-name");
- let remap_path_prefix = parse_remap_path_prefix(matches, error_format);
+ let remap_path_prefix = parse_remap_path_prefix(matches, &debugging_opts, error_format);
let pretty = parse_pretty(&debugging_opts, error_format);
+//! A module for searching for libraries
+
pub use self::FileMatch::*;
use std::env;
FileDoesntMatch,
}
-// A module for searching for libraries
-
#[derive(Clone)]
pub struct FileSearch<'a> {
sysroot: &'a Path,
FileSearch { sysroot, triple, search_paths, tlib_path, kind }
}
- // Returns just the directories within the search paths.
+ /// Returns just the directories within the search paths.
pub fn search_path_dirs(&self) -> Vec<PathBuf> {
self.search_paths().map(|sp| sp.dir.to_path_buf()).collect()
}
-
- // Returns a list of directories where target-specific tool binaries are located.
- pub fn get_tools_search_paths(&self, self_contained: bool) -> Vec<PathBuf> {
- let rustlib_path = rustc_target::target_rustlib_path(self.sysroot, &self.triple);
- let p = std::array::IntoIter::new([
- Path::new(&self.sysroot),
- Path::new(&rustlib_path),
- Path::new("bin"),
- ])
- .collect::<PathBuf>();
- if self_contained { vec![p.clone(), p.join("self-contained")] } else { vec![p] }
- }
}
pub fn make_target_lib_path(sysroot: &Path, target_triple: &str) -> PathBuf {
.collect::<PathBuf>()
}
-// This function checks if sysroot is found using env::args().next(), and if it
-// is not found, uses env::current_exe() to imply sysroot.
+/// This function checks if sysroot is found using env::args().next(), and if it
+/// is not found, uses env::current_exe() to imply sysroot.
pub fn get_or_default_sysroot() -> PathBuf {
// Follow symlinks. If the resolved path is relative, make it absolute.
fn canonicalize(path: PathBuf) -> PathBuf {
"whether ELF relocations can be relaxed"),
relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
"choose which RELRO level to use"),
+ remap_cwd_prefix: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
+ "remap paths under the current working directory to this path prefix"),
simulate_remapped_rust_src_base: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
"simulate the effect of remap-debuginfo = true at bootstrapping by remapping path \
to rust's source base directory. only meant for testing purposes"),
pub files: Vec<SearchPathFile>,
}
-// The obvious implementation of `SearchPath::files` is a `Vec<PathBuf>`. But
-// it is searched repeatedly by `find_library_crate`, and the searches involve
-// checking the prefix and suffix of the filename of each `PathBuf`. This is
-// doable, but very slow, because it involves calls to `file_name` and
-// `extension` that are themselves slow.
-//
-// This type augments the `PathBuf` with an `Option<String>` containing the
-// `PathBuf`'s filename. The prefix and suffix checking is much faster on the
-// `Option<String>` than the `PathBuf`. (It's an `Option` because
-// `Path::file_name` can fail; if that happens then all subsequent checking
-// will also fail, which is fine.)
+/// The obvious implementation of `SearchPath::files` is a `Vec<PathBuf>`. But
+/// it is searched repeatedly by `find_library_crate`, and the searches involve
+/// checking the prefix and suffix of the filename of each `PathBuf`. This is
+/// doable, but very slow, because it involves calls to `file_name` and
+/// `extension` that are themselves slow.
+///
+/// This type augments the `PathBuf` with an `Option<String>` containing the
+/// `PathBuf`'s filename. The prefix and suffix checking is much faster on the
+/// `Option<String>` than the `PathBuf`. (It's an `Option` because
+/// `Path::file_name` can fail; if that happens then all subsequent checking
+/// will also fail, which is fine.)
#[derive(Clone, Debug)]
pub struct SearchPathFile {
pub path: PathBuf,
use std::io::Write;
use std::num::NonZeroU32;
use std::ops::{Div, Mul};
-use std::path::PathBuf;
+use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::sync::Arc;
use std::time::Duration;
pub target: Target,
pub host: Target,
pub opts: config::Options,
- pub host_tlib_path: SearchPath,
- /// `None` if the host and target are the same.
- pub target_tlib_path: Option<SearchPath>,
+ pub host_tlib_path: Lrc<SearchPath>,
+ pub target_tlib_path: Lrc<SearchPath>,
pub parse_sess: ParseSess,
pub sysroot: PathBuf,
/// The name of the root source file of the crate, in the local file system.
&self.sysroot,
self.opts.target_triple.triple(),
&self.opts.search_paths,
- // `target_tlib_path == None` means it's the same as `host_tlib_path`.
- self.target_tlib_path.as_ref().unwrap_or(&self.host_tlib_path),
+ &self.target_tlib_path,
kind,
)
}
)
}
+ /// Returns a list of directories where target-specific tool binaries are located.
+ pub fn get_tools_search_paths(&self, self_contained: bool) -> Vec<PathBuf> {
+ let rustlib_path = rustc_target::target_rustlib_path(&self.sysroot, &config::host_triple());
+ let p = std::array::IntoIter::new([
+ Path::new(&self.sysroot),
+ Path::new(&rustlib_path),
+ Path::new("bin"),
+ ])
+ .collect::<PathBuf>();
+ if self_contained { vec![p.clone(), p.join("self-contained")] } else { vec![p] }
+ }
+
pub fn init_incr_comp_session(
&self,
session_dir: PathBuf,
let host_triple = config::host_triple();
let target_triple = sopts.target_triple.triple();
- let host_tlib_path = SearchPath::from_sysroot_and_triple(&sysroot, host_triple);
+ let host_tlib_path = Lrc::new(SearchPath::from_sysroot_and_triple(&sysroot, host_triple));
let target_tlib_path = if host_triple == target_triple {
- None
+ // Use the same `SearchPath` if host and target triple are identical to avoid unnecessary
+ // rescanning of the target lib path and an unnecessary allocation.
+ host_tlib_path.clone()
} else {
- Some(SearchPath::from_sysroot_and_triple(&sysroot, target_triple))
+ Lrc::new(SearchPath::from_sysroot_and_triple(&sysroot, target_triple))
};
let file_path_mapping = sopts.file_path_mapping();
// threads within the compilation session, but is not accessible outside the
// session.
pub struct SessionGlobals {
- symbol_interner: Lock<symbol::Interner>,
+ symbol_interner: symbol::Interner,
span_interner: Lock<span_encoding::SpanInterner>,
hygiene_data: Lock<hygiene::HygieneData>,
source_map: Lock<Option<Lrc<SourceMap>>>,
impl SessionGlobals {
pub fn new(edition: Edition) -> SessionGlobals {
SessionGlobals {
- symbol_interner: Lock::new(symbol::Interner::fresh()),
+ symbol_interner: symbol::Interner::fresh(),
span_interner: Lock::new(span_encoding::SpanInterner::default()),
hygiene_data: Lock::new(hygiene::HygieneData::new(edition)),
source_map: Lock::new(None),
use rustc_arena::DroplessArena;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
+use rustc_data_structures::sync::Lock;
use rustc_macros::HashStable_Generic;
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
panic_2021,
panic_abort,
panic_bounds_check,
+ panic_display,
panic_fmt,
panic_handler,
panic_impl,
panic_unwind,
panicking,
param_attrs,
- parent_trait,
partial_cmp,
partial_ord,
passes,
unix,
unlikely,
unmarked_api,
- unnamed_fields,
unpin,
unreachable,
unreachable_code,
wrapping_sub,
wreg,
write_bytes,
+ write_str,
x87_reg,
xer,
xmm_reg,
/// Maps a string to its interned representation.
pub fn intern(string: &str) -> Self {
- with_interner(|interner| interner.intern(string))
+ with_session_globals(|session_globals| session_globals.symbol_interner.intern(string))
}
/// Convert to a `SymbolStr`. This is a slowish operation because it
/// requires locking the symbol interner.
pub fn as_str(self) -> SymbolStr {
- with_interner(|interner| unsafe {
- SymbolStr { string: std::mem::transmute::<&str, &str>(interner.get(self)) }
+ with_session_globals(|session_globals| {
+ let symbol_str = session_globals.symbol_interner.get(self);
+ unsafe { SymbolStr { string: std::mem::transmute::<&str, &str>(symbol_str) } }
})
}
}
pub fn len(self) -> usize {
- with_interner(|interner| interner.get(self).len())
+ with_session_globals(|session_globals| session_globals.symbol_interner.get(self).len())
}
pub fn is_empty(self) -> bool {
}
}
+#[derive(Default)]
+pub(crate) struct Interner(Lock<InternerInner>);
+
// The `&'static str`s in this type actually point into the arena.
//
// The `FxHashMap`+`Vec` pair could be replaced by `FxIndexSet`, but #75278
// This type is private to prevent accidentally constructing more than one `Interner` on the same
// thread, which makes it easy to mixup `Symbol`s between `Interner`s.
#[derive(Default)]
-pub(crate) struct Interner {
+struct InternerInner {
arena: DroplessArena,
names: FxHashMap<&'static str, Symbol>,
strings: Vec<&'static str>,
impl Interner {
fn prefill(init: &[&'static str]) -> Self {
- Interner {
+ Interner(Lock::new(InternerInner {
strings: init.into(),
names: init.iter().copied().zip((0..).map(Symbol::new)).collect(),
..Default::default()
- }
+ }))
}
#[inline]
- pub fn intern(&mut self, string: &str) -> Symbol {
- if let Some(&name) = self.names.get(string) {
+ fn intern(&self, string: &str) -> Symbol {
+ let mut inner = self.0.lock();
+ if let Some(&name) = inner.names.get(string) {
return name;
}
- let name = Symbol::new(self.strings.len() as u32);
+ let name = Symbol::new(inner.strings.len() as u32);
// `from_utf8_unchecked` is safe since we just allocated a `&str` which is known to be
// UTF-8.
let string: &str =
- unsafe { str::from_utf8_unchecked(self.arena.alloc_slice(string.as_bytes())) };
+ unsafe { str::from_utf8_unchecked(inner.arena.alloc_slice(string.as_bytes())) };
// It is safe to extend the arena allocation to `'static` because we only access
// these while the arena is still alive.
let string: &'static str = unsafe { &*(string as *const str) };
- self.strings.push(string);
- self.names.insert(string, name);
+ inner.strings.push(string);
+ inner.names.insert(string, name);
name
}
// Get the symbol as a string. `Symbol::as_str()` should be used in
// preference to this function.
- pub fn get(&self, symbol: Symbol) -> &str {
- self.strings[symbol.0.as_usize()]
+ fn get(&self, symbol: Symbol) -> &str {
+ self.0.lock().strings[symbol.0.as_usize()]
}
}
}
}
-#[inline]
-fn with_interner<T, F: FnOnce(&mut Interner) -> T>(f: F) -> T {
- with_session_globals(|session_globals| f(&mut *session_globals.symbol_interner.lock()))
-}
-
/// An alternative to [`Symbol`], useful when the chars within the symbol need to
/// be accessed. It deliberately has limited functionality and should only be
/// used for temporary values.
#[test]
fn interner_tests() {
- let mut i: Interner = Interner::default();
+ let i = Interner::default();
// first one is zero:
assert_eq!(i.intern("dog"), Symbol::new(0));
// re-use gets the same entry:
/// - `substs`, the substs used to instantiate this opaque type
/// - `instantiated_ty`, the inferred type C1 -- fully resolved, lifted version of
/// `opaque_defn.concrete_ty`
- #[instrument(skip(self))]
+ #[instrument(level = "debug", skip(self))]
fn infer_opaque_definition_from_instantiation(
&self,
opaque_type_key: OpaqueTypeKey<'tcx>,
}
impl<'a, 'tcx> Instantiator<'a, 'tcx> {
- #[instrument(skip(self))]
+ #[instrument(level = "debug", skip(self))]
fn instantiate_opaque_types_in_map<T: TypeFoldable<'tcx>>(&mut self, value: T) -> T {
let tcx = self.infcx.tcx;
value.fold_with(&mut BottomUpFolder {
.map(|obligation| FulfillmentError {
obligation: obligation.clone(),
code: FulfillmentErrorCode::CodeAmbiguity,
- points_at_arg_span: false,
// FIXME - does Chalk have a notation of 'root obligation'?
// This is just for diagnostics, so it's okay if this is wrong
root_obligation: obligation.clone(),
code: FulfillmentErrorCode::CodeSelectionError(
SelectionError::Unimplemented,
),
- points_at_arg_span: false,
// FIXME - does Chalk have a notation of 'root obligation'?
// This is just for diagnostics, so it's okay if this is wrong
root_obligation: obligation,
code: FulfillmentErrorCode::CodeSelectionError(
SelectionError::Unimplemented,
),
- points_at_arg_span: false,
// FIXME - does Chalk have a notation of 'root obligation'?
// This is just for diagnostics, so it's okay if this is wrong
root_obligation: obligation,
root_obligation: &PredicateObligation<'tcx>,
error: &SelectionError<'tcx>,
fallback_has_occurred: bool,
- points_at_arg: bool,
);
/// Given some node representing a fn-like thing in the HIR map,
root_obligation: &PredicateObligation<'tcx>,
error: &SelectionError<'tcx>,
fallback_has_occurred: bool,
- points_at_arg: bool,
) {
let tcx = self.tcx;
let mut span = obligation.cause.span;
&obligation,
&mut err,
&trait_ref,
- points_at_arg,
have_alt_message,
) {
self.note_obligation_cause(&mut err, &obligation);
err.span_label(enclosing_scope_span, s.as_str());
}
- self.suggest_dereferences(&obligation, &mut err, trait_ref, points_at_arg);
- self.suggest_fn_call(&obligation, &mut err, trait_ref, points_at_arg);
+ self.suggest_dereferences(&obligation, &mut err, trait_ref);
+ self.suggest_fn_call(&obligation, &mut err, trait_ref);
self.suggest_remove_reference(&obligation, &mut err, trait_ref);
self.suggest_semicolon_removal(&obligation, &mut err, span, trait_ref);
self.note_version_mismatch(&mut err, &trait_ref);
// Changing mutability doesn't make a difference to whether we have
// an `Unsize` impl (Fixes ICE in #71036)
if !is_unsize {
- self.suggest_change_mut(
- &obligation,
- &mut err,
- trait_ref,
- points_at_arg,
- );
+ self.suggest_change_mut(&obligation, &mut err, trait_ref);
}
// If this error is due to `!: Trait` not implemented but `(): Trait` is
};
let found_did = match *found_trait_ty.kind() {
- ty::Closure(did, _) | ty::Foreign(did) | ty::FnDef(did, _) => Some(did),
+ ty::Closure(did, _)
+ | ty::Foreign(did)
+ | ty::FnDef(did, _)
+ | ty::Generator(did, ..) => Some(did),
ty::Adt(def, _) => Some(def.did),
_ => None,
};
&error.root_obligation,
selection_error,
fallback_has_occurred,
- error.points_at_arg_span,
);
}
FulfillmentErrorCode::CodeProjectionError(ref e) => {
flags.push((sym::from_method, Some(method.to_string())));
}
}
- if let Some((t, _)) = self.get_parent_trait_ref(&obligation.cause.code) {
- flags.push((sym::parent_trait, Some(t)));
- }
if let Some(k) = obligation.cause.span.desugaring_kind() {
flags.push((sym::from_desugaring, None));
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::stack::ensure_sufficient_stack;
+use rustc_data_structures::sync::Lrc;
use rustc_errors::{error_code, struct_span_err, Applicability, DiagnosticBuilder, Style};
use rustc_hir as hir;
use rustc_hir::def::DefKind;
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'tcx>,
trait_ref: ty::PolyTraitRef<'tcx>,
- points_at_arg: bool,
);
fn get_closure_name(
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'_>,
trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
- points_at_arg: bool,
);
fn suggest_add_reference_to_arg(
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'_>,
trait_ref: &ty::Binder<'tcx, ty::TraitRef<'tcx>>,
- points_at_arg: bool,
has_custom_message: bool,
) -> bool;
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'_>,
trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
- points_at_arg: bool,
);
fn suggest_semicolon_removal(
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'tcx>,
trait_ref: ty::PolyTraitRef<'tcx>,
- points_at_arg: bool,
) {
// It only make sense when suggesting dereferences for arguments
- if !points_at_arg {
+ let code = if let ObligationCauseCode::FunctionArgumentObligation { parent_code, .. } =
+ &obligation.cause.code
+ {
+ parent_code.clone()
+ } else {
return;
- }
+ };
let param_env = obligation.param_env;
let body_id = obligation.cause.body_id;
let span = obligation.cause.span;
- let real_trait_ref = match &obligation.cause.code {
+ let real_trait_ref = match &*code {
ObligationCauseCode::ImplDerivedObligation(cause)
| ObligationCauseCode::DerivedObligation(cause)
| ObligationCauseCode::BuiltinDerivedObligation(cause) => cause.parent_trait_ref,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'_>,
trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
- points_at_arg: bool,
) {
let self_ty = match trait_ref.self_ty().no_bound_vars() {
None => return,
}
_ => return,
};
- if points_at_arg {
+ if matches!(obligation.cause.code, ObligationCauseCode::FunctionArgumentObligation { .. }) {
// When the obligation error has been ensured to have been caused by
// an argument, the `obligation.cause.span` points at the expression
- // of the argument, so we can provide a suggestion. This is signaled
- // by `points_at_arg`. Otherwise, we give a more general note.
+ // of the argument, so we can provide a suggestion. Otherwise, we give
+ // a more general note.
err.span_suggestion_verbose(
obligation.cause.span.shrink_to_hi(),
&msg,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'_>,
trait_ref: &ty::Binder<'tcx, ty::TraitRef<'tcx>>,
- points_at_arg: bool,
has_custom_message: bool,
) -> bool {
let span = obligation.cause.span;
- let points_at_for_iter = matches!(
- span.ctxt().outer_expn_data().kind,
- ExpnKind::Desugaring(DesugaringKind::ForLoop(ForLoopLoc::IntoIter))
- );
- if !points_at_arg && !points_at_for_iter {
+ let code = if let ObligationCauseCode::FunctionArgumentObligation { parent_code, .. } =
+ &obligation.cause.code
+ {
+ parent_code.clone()
+ } else if let ExpnKind::Desugaring(DesugaringKind::ForLoop(ForLoopLoc::IntoIter)) =
+ span.ctxt().outer_expn_data().kind
+ {
+ Lrc::new(obligation.cause.code.clone())
+ } else {
return false;
- }
+ };
// List of traits for which it would be nonsensical to suggest borrowing.
// For instance, immutable references are always Copy, so suggesting to
return false;
};
- if let ObligationCauseCode::ImplDerivedObligation(obligation) = &obligation.cause.code {
+ if let ObligationCauseCode::ImplDerivedObligation(obligation) = &*code {
let expected_trait_ref = obligation.parent_trait_ref.skip_binder();
let new_imm_trait_ref =
ty::TraitRef::new(obligation.parent_trait_ref.def_id(), imm_substs);
return try_borrowing(new_mut_trait_ref, expected_trait_ref, true, &[]);
}
} else if let ObligationCauseCode::BindingObligation(_, _)
- | ObligationCauseCode::ItemObligation(_) = &obligation.cause.code
+ | ObligationCauseCode::ItemObligation(_) = &*code
{
if try_borrowing(
ty::TraitRef::new(trait_ref.def_id, imm_substs),
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'_>,
trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
- points_at_arg: bool,
) {
+ let points_at_arg = matches!(
+ obligation.cause.code,
+ ObligationCauseCode::FunctionArgumentObligation { .. },
+ );
+
let span = obligation.cause.span;
if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) {
let refs_number =
trait_ref: ty::PolyTraitRef<'tcx>,
) -> String {
let inputs = trait_ref.skip_binder().substs.type_at(1);
- let sig = if let ty::Tuple(inputs) = inputs.kind() {
- tcx.mk_fn_sig(
- inputs.iter().map(|k| k.expect_ty()),
- tcx.mk_ty_infer(ty::TyVar(ty::TyVid::from_u32(0))),
- false,
- hir::Unsafety::Normal,
- abi::Abi::Rust,
- )
- } else {
- tcx.mk_fn_sig(
+ let sig = match inputs.kind() {
+ ty::Tuple(inputs)
+ if tcx.fn_trait_kind_from_lang_item(trait_ref.def_id()).is_some() =>
+ {
+ tcx.mk_fn_sig(
+ inputs.iter().map(|k| k.expect_ty()),
+ tcx.mk_ty_infer(ty::TyVar(ty::TyVid::from_u32(0))),
+ false,
+ hir::Unsafety::Normal,
+ abi::Abi::Rust,
+ )
+ }
+ _ => tcx.mk_fn_sig(
std::iter::once(inputs),
tcx.mk_ty_infer(ty::TyVar(ty::TyVid::from_u32(0))),
false,
hir::Unsafety::Normal,
abi::Abi::Rust,
- )
+ ),
};
trait_ref.rebind(sig).to_string()
}
- let argument_is_closure = expected_ref.skip_binder().substs.type_at(0).is_closure();
+ let argument_kind = match expected_ref.skip_binder().substs.type_at(0) {
+ t if t.is_closure() => "closure",
+ t if t.is_generator() => "generator",
+ _ => "function",
+ };
let mut err = struct_span_err!(
self.tcx.sess,
span,
E0631,
"type mismatch in {} arguments",
- if argument_is_closure { "closure" } else { "function" }
+ argument_kind
);
let found_str = format!("expected signature of `{}`", build_fn_sig_string(self.tcx, found));
)
});
}
+ ObligationCauseCode::FunctionArgumentObligation {
+ arg_hir_id,
+ call_hir_id,
+ ref parent_code,
+ } => {
+ let hir = self.tcx.hir();
+ if let Some(Node::Expr(expr @ hir::Expr { kind: hir::ExprKind::Block(..), .. })) =
+ hir.find(arg_hir_id)
+ {
+ let in_progress_typeck_results =
+ self.in_progress_typeck_results.map(|t| t.borrow());
+ let parent_id = hir.local_def_id(hir.get_parent_item(arg_hir_id));
+ let typeck_results: &TypeckResults<'tcx> = match &in_progress_typeck_results {
+ Some(t) if t.hir_owner == parent_id => t,
+ _ => self.tcx.typeck(parent_id),
+ };
+ let ty = typeck_results.expr_ty_adjusted(expr);
+ let span = expr.peel_blocks().span;
+ if Some(span) != err.span.primary_span() {
+ err.span_label(
+ span,
+ &if ty.references_error() {
+ String::new()
+ } else {
+ format!("this tail expression is of type `{:?}`", ty)
+ },
+ );
+ }
+ }
+ if let Some(Node::Expr(hir::Expr {
+ kind:
+ hir::ExprKind::Call(hir::Expr { span, .. }, _)
+ | hir::ExprKind::MethodCall(_, span, ..),
+ ..
+ })) = hir.find(call_hir_id)
+ {
+ if Some(*span) != err.span.primary_span() {
+ err.span_label(*span, "required by a bound introduced by this call");
+ }
+ }
+ ensure_sufficient_stack(|| {
+ self.note_obligation_cause_code(
+ err,
+ predicate,
+ &parent_code,
+ obligated_types,
+ seen_requirements,
+ )
+ });
+ }
ObligationCauseCode::CompareImplMethodObligation {
item_name,
trait_item_def_id,
use super::util::{closure_trait_ref_and_return_type, predicate_for_trait_def};
use super::wf;
use super::DerivedObligationCause;
+use super::Normalized;
use super::Obligation;
use super::ObligationCauseCode;
use super::Selection;
use super::SelectionResult;
use super::TraitQueryMode;
-use super::{Normalized, ProjectionCacheKey};
use super::{ObligationCause, PredicateObligation, TraitObligation};
use super::{Overflow, SelectionError, Unimplemented};
use crate::infer::{InferCtxt, InferOk, TypeFreshener};
use crate::traits::error_reporting::InferCtxtExt;
-use crate::traits::project::ProjectionCacheKeyExt;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_data_structures::sync::Lrc;
match project::poly_project_and_unify_type(self, &project_obligation) {
Ok(Ok(Some(mut subobligations))) => {
self.add_depth(subobligations.iter_mut(), obligation.recursion_depth);
- let result = self
- .evaluate_predicates_recursively(previous_stack, subobligations);
- if let Some(key) =
- ProjectionCacheKey::from_poly_projection_predicate(self, data)
- {
- self.infcx.inner.borrow_mut().projection_cache().complete(key);
- }
- result
+ self.evaluate_predicates_recursively(previous_stack, subobligations)
}
Ok(Ok(None)) => Ok(EvaluatedToAmbig),
Ok(Err(project::InProgress)) => Ok(EvaluatedToRecur),
///
/// The weird return type of this function allows it to be used with the `try` (`?`)
/// operator within certain functions.
+ #[inline(always)]
fn check_recursion_limit<T: Display + TypeFoldable<'tcx>, V: Display + TypeFoldable<'tcx>>(
&self,
obligation: &Obligation<'tcx, T>,
arg_exprs: &'tcx [hir::Expr<'tcx>],
expected: Expectation<'tcx>,
) -> Ty<'tcx> {
- let original_callee_ty = self.check_expr(callee_expr);
+ let original_callee_ty = match &callee_expr.kind {
+ hir::ExprKind::Path(hir::QPath::Resolved(..) | hir::QPath::TypeRelative(..)) => self
+ .check_expr_with_expectation_and_args(
+ callee_expr,
+ Expectation::NoExpectation,
+ arg_exprs,
+ ),
+ _ => self.check_expr(callee_expr),
+ };
+
let expr_ty = self.structurally_resolved_type(call_expr.span, original_callee_ty);
let mut autoderef = self.autoderef(callee_expr.span, expr_ty);
// Object safety violations or miscellaneous.
Err(err) => {
- self.report_selection_error(
- obligation.clone(),
- &obligation,
- &err,
- false,
- false,
- );
+ self.report_selection_error(obligation.clone(), &obligation, &err, false);
// Treat this like an obligation and follow through
// with the unsizing - the lack of a coercion should
// be silent, as it causes a type mismatch later.
&self,
expr: &'tcx hir::Expr<'tcx>,
expected: Expectation<'tcx>,
+ ) -> Ty<'tcx> {
+ self.check_expr_with_expectation_and_args(expr, expected, &[])
+ }
+
+ /// Same as `check_expr_with_expectation`, but allows us to pass in the arguments of a
+ /// `ExprKind::Call` when evaluating its callee when it is an `ExprKind::Path`.
+ pub(super) fn check_expr_with_expectation_and_args(
+ &self,
+ expr: &'tcx hir::Expr<'tcx>,
+ expected: Expectation<'tcx>,
+ args: &'tcx [hir::Expr<'tcx>],
) -> Ty<'tcx> {
if self.tcx().sess.verbose() {
// make this code only run with -Zverbose because it is probably slow
let old_diverges = self.diverges.replace(Diverges::Maybe);
let old_has_errors = self.has_errors.replace(false);
- let ty = ensure_sufficient_stack(|| self.check_expr_kind(expr, expected));
+ let ty = ensure_sufficient_stack(|| match &expr.kind {
+ hir::ExprKind::Path(
+ qpath @ hir::QPath::Resolved(..) | qpath @ hir::QPath::TypeRelative(..),
+ ) => self.check_expr_path(qpath, expr, args),
+ _ => self.check_expr_kind(expr, expected),
+ });
// Warn for non-block expressions with diverging children.
match expr.kind {
ExprKind::Path(QPath::LangItem(lang_item, _)) => {
self.check_lang_item_path(lang_item, expr)
}
- ExprKind::Path(ref qpath) => self.check_expr_path(qpath, expr),
+ ExprKind::Path(ref qpath) => self.check_expr_path(qpath, expr, &[]),
ExprKind::InlineAsm(asm) => self.check_expr_asm(asm),
ExprKind::LlvmInlineAsm(asm) => {
for expr in asm.outputs_exprs.iter().chain(asm.inputs_exprs.iter()) {
self.resolve_lang_item_path(lang_item, expr.span, expr.hir_id).1
}
- fn check_expr_path(
+ pub(crate) fn check_expr_path(
&self,
qpath: &'tcx hir::QPath<'tcx>,
expr: &'tcx hir::Expr<'tcx>,
+ args: &'tcx [hir::Expr<'tcx>],
) -> Ty<'tcx> {
let tcx = self.tcx;
let (res, opt_ty, segs) =
// We just want to check sizedness, so instead of introducing
// placeholder lifetimes with probing, we just replace higher lifetimes
// with fresh vars.
+ let span = args.get(i).map(|a| a.span).unwrap_or(expr.span);
let input = self
.replace_bound_vars_with_fresh_vars(
- expr.span,
+ span,
infer::LateBoundRegionConversionTime::FnCall,
fn_sig.input(i),
)
.0;
self.require_type_is_sized_deferred(
input,
- expr.span,
+ span,
traits::SizedArgumentType(None),
);
}
expr_t
);
err.span_label(field.span, "method, not a field");
- if !self.expr_in_place(expr.hir_id) {
+ let expr_is_call =
+ if let hir::Node::Expr(hir::Expr { kind: ExprKind::Call(callee, _args), .. }) =
+ self.tcx.hir().get(self.tcx.hir().get_parent_node(expr.hir_id))
+ {
+ expr.hir_id == callee.hir_id
+ } else {
+ false
+ };
+ let expr_snippet =
+ self.tcx.sess.source_map().span_to_snippet(expr.span).unwrap_or(String::new());
+ if expr_is_call && expr_snippet.starts_with("(") && expr_snippet.ends_with(")") {
+ let after_open = expr.span.lo() + rustc_span::BytePos(1);
+ let before_close = expr.span.hi() - rustc_span::BytePos(1);
+ err.multipart_suggestion(
+ "remove wrapping parentheses to call the method",
+ vec![
+ (expr.span.with_hi(after_open), String::new()),
+ (expr.span.with_lo(before_close), String::new()),
+ ],
+ Applicability::MachineApplicable,
+ );
+ } else if !self.expr_in_place(expr.hir_id) {
self.suggest_method_call(
&mut err,
"use parentheses to call the method",
/// version (resolve_vars_if_possible), this version will
/// also select obligations if it seems useful, in an effort
/// to get more type information.
- pub(in super::super) fn resolve_vars_with_obligations(&self, mut ty: Ty<'tcx>) -> Ty<'tcx> {
+ pub(in super::super) fn resolve_vars_with_obligations(&self, ty: Ty<'tcx>) -> Ty<'tcx> {
+ self.resolve_vars_with_obligations_and_mutate_fulfillment(ty, |_| {})
+ }
+
+ pub(in super::super) fn resolve_vars_with_obligations_and_mutate_fulfillment(
+ &self,
+ mut ty: Ty<'tcx>,
+ mutate_fulfillment_errors: impl Fn(&mut Vec<traits::FulfillmentError<'tcx>>),
+ ) -> Ty<'tcx> {
debug!("resolve_vars_with_obligations(ty={:?})", ty);
// No Infer()? Nothing needs doing.
// possible. This can help substantially when there are
// indirect dependencies that don't seem worth tracking
// precisely.
- self.select_obligations_where_possible(false, |_| {});
+ self.select_obligations_where_possible(false, mutate_fulfillment_errors);
ty = self.resolve_vars_if_possible(ty);
debug!("resolve_vars_with_obligations: ty={:?}", ty);
};
use rustc_ast as ast;
+use rustc_data_structures::sync::Lrc;
use rustc_errors::{Applicability, DiagnosticBuilder, DiagnosticId};
use rustc_hir as hir;
use rustc_hir::def::{CtorOf, DefKind, Res};
self.point_at_arg_instead_of_call_if_possible(
errors,
&final_arg_types[..],
+ expr,
sp,
&args,
);
continue;
}
- debug!("checking the argument");
let formal_ty = formal_tys[i];
+ debug!("checking argument {}: {:?} = {:?}", i, arg, formal_ty);
// The special-cased logic below has three functions:
// 1. Provide as good of an expected type as possible.
// to, which is `expected_ty` if `rvalue_hint` returns an
// `ExpectHasType(expected_ty)`, or the `formal_ty` otherwise.
let coerce_ty = expected.only_has_type(self).unwrap_or(formal_ty);
+
+ // Cause selection errors caused by resolving a single argument to point at the
+ // argument and not the call. This is otherwise redundant with the `demand_coerce`
+ // call immediately after, but it lets us customize the span pointed to in the
+ // fulfillment error to be more accurate.
+ let _ = self.resolve_vars_with_obligations_and_mutate_fulfillment(
+ coerce_ty,
+ |errors| {
+ // This is not coming from a macro or a `derive`.
+ if sp.desugaring_kind().is_none()
+ && !arg.span.from_expansion()
+ // Do not change the spans of `async fn`s.
+ && !matches!(
+ expr.kind,
+ hir::ExprKind::Call(
+ hir::Expr {
+ kind: hir::ExprKind::Path(hir::QPath::LangItem(_, _)),
+ ..
+ },
+ _
+ )
+ ) {
+ for error in errors {
+ error.obligation.cause.make_mut().span = arg.span;
+ let code = error.obligation.cause.code.clone();
+ error.obligation.cause.make_mut().code =
+ ObligationCauseCode::FunctionArgumentObligation {
+ arg_hir_id: arg.hir_id,
+ call_hir_id: expr.hir_id,
+ parent_code: Lrc::new(code),
+ };
+ }
+ }
+ },
+ );
+
// We're processing function arguments so we definitely want to use
// two-phase borrows.
self.demand_coerce(&arg, checked_ty, coerce_ty, None, AllowTwoPhase::Yes);
Some((variant, ty))
} else {
- struct_span_err!(
- self.tcx.sess,
- path_span,
- E0071,
- "expected struct, variant or union type, found {}",
- ty.sort_string(self.tcx)
- )
- .span_label(path_span, "not a struct")
- .emit();
+ match ty.kind() {
+ ty::Error(_) => {
+ // E0071 might be caused by a spelling error, which will have
+ // already caused an error message and probably a suggestion
+ // elsewhere. Refrain from emitting more unhelpful errors here
+ // (issue #88844).
+ }
+ _ => {
+ struct_span_err!(
+ self.tcx.sess,
+ path_span,
+ E0071,
+ "expected struct, variant or union type, found {}",
+ ty.sort_string(self.tcx)
+ )
+ .span_label(path_span, "not a struct")
+ .emit();
+ }
+ }
None
}
}
&self,
errors: &mut Vec<traits::FulfillmentError<'tcx>>,
final_arg_types: &[(usize, Ty<'tcx>, Ty<'tcx>)],
+ expr: &'tcx hir::Expr<'tcx>,
call_sp: Span,
args: &'tcx [hir::Expr<'tcx>],
) {
// We make sure that only *one* argument matches the obligation failure
// and we assign the obligation's span to its expression's.
error.obligation.cause.make_mut().span = args[ref_in].span;
- error.points_at_arg_span = true;
+ let code = error.obligation.cause.code.clone();
+ error.obligation.cause.make_mut().code =
+ ObligationCauseCode::FunctionArgumentObligation {
+ arg_hir_id: args[ref_in].hir_id,
+ call_hir_id: expr.hir_id,
+ parent_code: Lrc::new(code),
+ };
}
}
}
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_middle::ty::subst::GenericArg;
use rustc_middle::ty::{self, Adt, BindingMode, Ty, TypeFoldable};
+use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS;
use rustc_span::hygiene::DesugaringKind;
use rustc_span::lev_distance::find_best_match_for_name;
use rustc_span::source_map::{Span, Spanned};
};
// Require `..` if struct has non_exhaustive attribute.
- if variant.is_field_list_non_exhaustive() && !adt.did.is_local() && !etc {
+ let non_exhaustive = variant.is_field_list_non_exhaustive() && !adt.did.is_local();
+ if non_exhaustive && !etc {
self.error_foreign_non_exhaustive_spat(pat, adt.variant_descr(), fields.is_empty());
}
if etc {
tcx.sess.struct_span_err(pat.span, "`..` cannot be used in union patterns").emit();
}
- } else if !etc && !unmentioned_fields.is_empty() {
+ } else if !unmentioned_fields.is_empty() {
let accessible_unmentioned_fields: Vec<_> = unmentioned_fields
.iter()
.copied()
field.vis.is_accessible_from(tcx.parent_module(pat.hir_id).to_def_id(), tcx)
})
.collect();
-
- if accessible_unmentioned_fields.is_empty() {
- unmentioned_err = Some(self.error_no_accessible_fields(pat, &fields));
- } else {
- unmentioned_err = Some(self.error_unmentioned_fields(
- pat,
- &accessible_unmentioned_fields,
- accessible_unmentioned_fields.len() != unmentioned_fields.len(),
- &fields,
- ));
+ if non_exhaustive {
+ self.non_exhaustive_reachable_pattern(pat, &accessible_unmentioned_fields, adt_ty)
+ } else if !etc {
+ if accessible_unmentioned_fields.is_empty() {
+ unmentioned_err = Some(self.error_no_accessible_fields(pat, &fields));
+ } else {
+ unmentioned_err = Some(self.error_unmentioned_fields(
+ pat,
+ &accessible_unmentioned_fields,
+ accessible_unmentioned_fields.len() != unmentioned_fields.len(),
+ &fields,
+ ));
+ }
}
}
match (inexistent_fields_err, unmentioned_err) {
err
}
+ /// Report that a pattern for a `#[non_exhaustive]` struct marked with `non_exhaustive_omitted_patterns`
+ /// is not exhaustive enough.
+ ///
+ /// Nb: the partner lint for enums lives in `compiler/rustc_mir_build/src/thir/pattern/usefulness.rs`.
+ fn non_exhaustive_reachable_pattern(
+ &self,
+ pat: &Pat<'_>,
+ unmentioned_fields: &[(&ty::FieldDef, Ident)],
+ ty: Ty<'tcx>,
+ ) {
+ fn joined_uncovered_patterns(witnesses: &[&Ident]) -> String {
+ const LIMIT: usize = 3;
+ match witnesses {
+ [] => bug!(),
+ [witness] => format!("`{}`", witness),
+ [head @ .., tail] if head.len() < LIMIT => {
+ let head: Vec<_> = head.iter().map(<_>::to_string).collect();
+ format!("`{}` and `{}`", head.join("`, `"), tail)
+ }
+ _ => {
+ let (head, tail) = witnesses.split_at(LIMIT);
+ let head: Vec<_> = head.iter().map(<_>::to_string).collect();
+ format!("`{}` and {} more", head.join("`, `"), tail.len())
+ }
+ }
+ }
+ let joined_patterns = joined_uncovered_patterns(
+ &unmentioned_fields.iter().map(|(_, i)| i).collect::<Vec<_>>(),
+ );
+
+ self.tcx.struct_span_lint_hir(NON_EXHAUSTIVE_OMITTED_PATTERNS, pat.hir_id, pat.span, |build| {
+ let mut lint = build.build("some fields are not explicitly listed");
+ lint.span_label(pat.span, format!("field{} {} not listed", rustc_errors::pluralize!(unmentioned_fields.len()), joined_patterns));
+
+ lint.help(
+ "ensure that all fields are mentioned explicitly by adding the suggested fields",
+ );
+ lint.note(&format!(
+ "the pattern is of type `{}` and the `non_exhaustive_omitted_patterns` attribute was found",
+ ty,
+ ));
+ lint.emit();
+ });
+ }
+
/// Returns a diagnostic reporting a struct pattern which does not mention some fields.
///
/// ```text
AngleBrackets::Missing => 0,
// Only lifetime arguments can be implied
AngleBrackets::Implied => self.gen_args.args.len(),
- AngleBrackets::Available => self.gen_args.args.iter().fold(0, |acc, arg| match arg {
- hir::GenericArg::Lifetime(_) => acc + 1,
- _ => acc,
- }),
+ AngleBrackets::Available => self.gen_args.num_lifetime_params(),
}
}
AngleBrackets::Missing => 0,
// Only lifetime arguments can be implied
AngleBrackets::Implied => 0,
- AngleBrackets::Available => self.gen_args.args.iter().fold(0, |acc, arg| match arg {
- hir::GenericArg::Type(_) | hir::GenericArg::Const(_) => acc + 1,
- _ => acc,
- }),
+ AngleBrackets::Available => self.gen_args.num_generic_params(),
}
}
let mut found_redundant = false;
for arg in self.gen_args.args {
match arg {
- hir::GenericArg::Type(_) | hir::GenericArg::Const(_) => {
+ hir::GenericArg::Type(_)
+ | hir::GenericArg::Const(_)
+ | hir::GenericArg::Infer(_) => {
gen_arg_spans.push(arg.span());
if gen_arg_spans.len() > self.num_expected_type_or_const_args() {
found_redundant = true;
}
#[stable(feature = "rust1", since = "1.0.0")]
-impl<B: ?Sized + ToOwned> Deref for Cow<'_, B> {
+#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
+impl<B: ?Sized + ToOwned> const Deref for Cow<'_, B>
+where
+ B::Owned: ~const Borrow<B>,
+{
type Target = B;
fn deref(&self) -> &B {
-Subproject commit 4f925f8d81dfa57067537217e501e1dff7433491
+Subproject commit cc89bb66f91b2b4a640b0b525ca5d753e3346d7e
/// If the iterator is empty, returns [`None`]; otherwise, returns the
/// result of the reduction.
///
+ /// The reducing function is a closure with two arguments: an 'accumulator', and an element.
/// For iterators with at least one element, this is the same as [`fold()`]
- /// with the first element of the iterator as the initial value, folding
+ /// with the first element of the iterator as the initial accumulator value, folding
/// every subsequent element into it.
///
/// [`fold()`]: Iterator::fold
/// where I: Iterator,
/// I::Item: Ord,
/// {
- /// iter.reduce(|a, b| {
- /// if a >= b { a } else { b }
+ /// iter.reduce(|accum, item| {
+ /// if accum >= item { accum } else { item }
/// })
/// }
/// let a = [10, 20, 5, -23, 0];
}
#[stable(feature = "manually_drop", since = "1.20.0")]
-impl<T: ?Sized> Deref for ManuallyDrop<T> {
+#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
+impl<T: ?Sized> const Deref for ManuallyDrop<T> {
type Target = T;
#[inline(always)]
fn deref(&self) -> &T {
}
#[stable(feature = "manually_drop", since = "1.20.0")]
-impl<T: ?Sized> DerefMut for ManuallyDrop<T> {
+#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
+impl<T: ?Sized> const DerefMut for ManuallyDrop<T> {
#[inline(always)]
fn deref_mut(&mut self) -> &mut T {
&mut self.value
///
/// assert_eq!(u32::MAX, (zero - one).0);
/// ```
+///
+/// # Layout
+///
+/// `Wrapping<T>` is guaranteed to have the same layout and ABI as `T`.
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Default, Hash)]
#[repr(transparent)]
}
#[stable(feature = "rust1", since = "1.0.0")]
-impl<T: ?Sized> Deref for &T {
+#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
+impl<T: ?Sized> const Deref for &T {
type Target = T;
#[rustc_diagnostic_item = "noop_method_deref"]
impl<T: ?Sized> !DerefMut for &T {}
#[stable(feature = "rust1", since = "1.0.0")]
-impl<T: ?Sized> Deref for &mut T {
+#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
+impl<T: ?Sized> const Deref for &mut T {
type Target = T;
fn deref(&self) -> &T {
($msg:literal $(,)?) => (
$crate::panicking::panic($msg)
),
+ // Use `panic_str` instead of `panic_display::<&str>` for non_fmt_panic lint.
($msg:expr $(,)?) => (
$crate::panicking::panic_str($msg)
),
+ // Special-case the single-argument case for const_panic.
+ ("{}", $arg:expr $(,)?) => (
+ $crate::panicking::panic_display(&$arg)
+ ),
($fmt:expr, $($arg:tt)+) => (
$crate::panicking::panic_fmt($crate::const_format_args!($fmt, $($arg)+))
),
() => (
$crate::panicking::panic("explicit panic")
),
+ // Special-case the single-argument case for const_panic.
+ ("{}", $arg:expr $(,)?) => (
+ $crate::panicking::panic_display(&$arg)
+ ),
($($t:tt)+) => (
$crate::panicking::panic_fmt($crate::const_format_args!($($t)+))
),
panic_fmt(format_args!("{}", expr));
}
+#[inline]
+#[track_caller]
+#[cfg_attr(not(bootstrap), lang = "panic_display")] // needed for const-evaluated panics
+pub fn panic_display<T: fmt::Display>(x: &T) -> ! {
+ panic_fmt(format_args!("{}", *x));
+}
+
#[cold]
#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))]
#[track_caller]
#[stable(feature = "cow_from_cstr", since = "1.28.0")]
impl<'a> From<CString> for Cow<'a, CStr> {
+ /// Converts a [`CString`] into an owned [`Cow`] without copying or allocating.
#[inline]
fn from(s: CString) -> Cow<'a, CStr> {
Cow::Owned(s)
#[stable(feature = "cow_from_cstr", since = "1.28.0")]
impl<'a> From<&'a CStr> for Cow<'a, CStr> {
+ /// Converts a [`CStr`] into a borrowed [`Cow`] without copying or allocating.
#[inline]
fn from(s: &'a CStr) -> Cow<'a, CStr> {
Cow::Borrowed(s)
#[stable(feature = "cow_from_cstr", since = "1.28.0")]
impl<'a> From<&'a CString> for Cow<'a, CStr> {
+ /// Converts a `&`[`CString`] into a borrowed [`Cow`] without copying or allocating.
#[inline]
fn from(s: &'a CString) -> Cow<'a, CStr> {
Cow::Borrowed(s.as_c_str())
/// '_inner: for j in 1..=200 {
/// println!(" inner iteration (j): {}", j);
/// if j >= 3 {
-/// // breaks from inner loop, let's outer loop continue.
+/// // breaks from inner loop, lets outer loop continue.
/// break;
/// }
/// if i >= 2 {
#![feature(const_trait_impl)]
#![feature(container_error_extra)]
#![feature(core_intrinsics)]
+#![feature(core_panic)]
#![feature(custom_test_frameworks)]
#![feature(decl_macro)]
#![feature(doc_cfg)]
listener: &'a TcpListener,
}
+/// An iterator that infinitely [`accept`]s connections on a [`TcpListener`].
+///
+/// This `struct` is created by the [`TcpListener::into_incoming`] method.
+/// See its documentation for more.
+///
+/// [`accept`]: TcpListener::accept
+#[derive(Debug)]
+#[unstable(feature = "tcplistener_into_incoming", issue = "88339")]
+pub struct IntoIncoming {
+ listener: TcpListener,
+}
+
impl TcpStream {
/// Opens a TCP connection to a remote host.
///
Incoming { listener: self }
}
+ /// Turn this into an iterator over the connections being received on this
+ /// listener.
+ ///
+ /// The returned iterator will never return [`None`] and will also not yield
+ /// the peer's [`SocketAddr`] structure. Iterating over it is equivalent to
+ /// calling [`TcpListener::accept`] in a loop.
+ ///
+ /// # Examples
+ ///
+ /// ```no_run
+ /// #![feature(tcplistener_into_incoming)]
+ /// use std::net::{TcpListener, TcpStream};
+ ///
+ /// fn listen_on(port: u16) -> impl Iterator<Item = TcpStream> {
+ /// let listener = TcpListener::bind("127.0.0.1:80").unwrap();
+ /// listener.into_incoming()
+ /// .filter_map(Result::ok) /* Ignore failed connections */
+ /// }
+ ///
+ /// fn main() -> std::io::Result<()> {
+ /// for stream in listen_on(80) {
+ /// /* handle the connection here */
+ /// }
+ /// Ok(())
+ /// }
+ /// ```
+ #[unstable(feature = "tcplistener_into_incoming", issue = "88339")]
+ pub fn into_incoming(self) -> IntoIncoming {
+ IntoIncoming { listener: self }
+ }
+
/// Sets the value for the `IP_TTL` option on this socket.
///
/// This value sets the time-to-live field that is used in every packet sent
}
}
+#[unstable(feature = "tcplistener_into_incoming", issue = "88339")]
+impl Iterator for IntoIncoming {
+ type Item = io::Result<TcpStream>;
+ fn next(&mut self) -> Option<io::Result<TcpStream>> {
+ Some(self.listener.accept().map(|p| p.0))
+ }
+}
+
impl AsInner<net_imp::TcpListener> for TcpListener {
fn as_inner(&self) -> &net_imp::TcpListener {
&self.0
use super::platform::fs::MetadataExt as _;
use crate::fs::{self, OpenOptions, Permissions};
use crate::io;
+use crate::os::unix::io::{AsFd, AsRawFd};
use crate::path::Path;
use crate::sys;
use crate::sys_common::{AsInner, AsInnerMut, FromInner};
}
}
+/// Change the owner and group of the specified path.
+///
+/// Specifying either the uid or gid as `None` will leave it unchanged.
+///
+/// Changing the owner typically requires privileges, such as root or a specific capability.
+/// Changing the group typically requires either being the owner and a member of the group, or
+/// having privileges.
+///
+/// If called on a symbolic link, this will change the owner and group of the link target. To
+/// change the owner and group of the link itself, see [`lchown`].
+///
+/// # Examples
+///
+/// ```no_run
+/// #![feature(unix_chown)]
+/// use std::os::unix::fs;
+///
+/// fn main() -> std::io::Result<()> {
+/// fs::chown("/sandbox", Some(0), Some(0))?;
+/// Ok(())
+/// }
+/// ```
+#[unstable(feature = "unix_chown", issue = "88989")]
+pub fn chown<P: AsRef<Path>>(dir: P, uid: Option<u32>, gid: Option<u32>) -> io::Result<()> {
+ sys::fs::chown(dir.as_ref(), uid.unwrap_or(u32::MAX), gid.unwrap_or(u32::MAX))
+}
+
+/// Change the owner and group of the file referenced by the specified open file descriptor.
+///
+/// For semantics and required privileges, see [`chown`].
+///
+/// # Examples
+///
+/// ```no_run
+/// #![feature(unix_chown)]
+/// use std::os::unix::fs;
+///
+/// fn main() -> std::io::Result<()> {
+/// let f = std::fs::File::open("/file")?;
+/// fs::fchown(f, Some(0), Some(0))?;
+/// Ok(())
+/// }
+/// ```
+#[unstable(feature = "unix_chown", issue = "88989")]
+pub fn fchown<F: AsFd>(fd: F, uid: Option<u32>, gid: Option<u32>) -> io::Result<()> {
+ sys::fs::fchown(fd.as_fd().as_raw_fd(), uid.unwrap_or(u32::MAX), gid.unwrap_or(u32::MAX))
+}
+
+/// Change the owner and group of the specified path, without dereferencing symbolic links.
+///
+/// Identical to [`chown`], except that if called on a symbolic link, this will change the owner
+/// and group of the link itself rather than the owner and group of the link target.
+///
+/// # Examples
+///
+/// ```no_run
+/// #![feature(unix_chown)]
+/// use std::os::unix::fs;
+///
+/// fn main() -> std::io::Result<()> {
+/// fs::lchown("/symlink", Some(0), Some(0))?;
+/// Ok(())
+/// }
+/// ```
+#[unstable(feature = "unix_chown", issue = "88989")]
+pub fn lchown<P: AsRef<Path>>(dir: P, uid: Option<u32>, gid: Option<u32>) -> io::Result<()> {
+ sys::fs::lchown(dir.as_ref(), uid.unwrap_or(u32::MAX), gid.unwrap_or(u32::MAX))
+}
+
/// Change the root directory of the current process to the specified path.
///
/// This typically requires privileges, such as root or a specific capability.
#[doc(hidden)]
#[unstable(feature = "edition_panic", issue = "none", reason = "use panic!() instead")]
-#[allow_internal_unstable(libstd_sys_internals, const_format_args)]
+#[allow_internal_unstable(libstd_sys_internals, const_format_args, core_panic)]
#[cfg_attr(not(test), rustc_diagnostic_item = "std_panic_2015_macro")]
#[rustc_macro_transparency = "semitransparent"]
pub macro panic_2015 {
($msg:expr $(,)?) => ({
$crate::rt::begin_panic($msg)
}),
+ // Special-case the single-argument case for const_panic.
+ ("{}", $arg:expr $(,)?) => ({
+ $crate::rt::panic_display(&$arg)
+ }),
($fmt:expr, $($arg:tt)+) => ({
$crate::rt::begin_panic_fmt(&$crate::const_format_args!($fmt, $($arg)+))
}),
// Re-export some of our utilities which are expected by other crates.
pub use crate::panicking::{begin_panic, begin_panic_fmt, panic_count};
+pub use core::panicking::panic_display;
// To reduce the generated code of the new `lang_start`, this function is doing
// the real work.
Ok(bytes_copied as u64)
}
+pub fn chown(path: &Path, uid: u32, gid: u32) -> io::Result<()> {
+ let path = cstr(path)?;
+ cvt(unsafe { libc::chown(path.as_ptr(), uid as libc::uid_t, gid as libc::gid_t) })?;
+ Ok(())
+}
+
+pub fn fchown(fd: c_int, uid: u32, gid: u32) -> io::Result<()> {
+ cvt(unsafe { libc::fchown(fd, uid as libc::uid_t, gid as libc::gid_t) })?;
+ Ok(())
+}
+
+pub fn lchown(path: &Path, uid: u32, gid: u32) -> io::Result<()> {
+ let path = cstr(path)?;
+ cvt(unsafe { libc::lchown(path.as_ptr(), uid as libc::uid_t, gid as libc::gid_t) })?;
+ Ok(())
+}
+
#[cfg(not(any(target_os = "fuchsia", target_os = "vxworks")))]
pub fn chroot(dir: &Path) -> io::Result<()> {
let dir = cstr(dir)?;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
let builder = run.builder;
- run.krate("rustc-main").default_condition(builder.config.docs)
+ run.krate("rustc-main").path("compiler").default_condition(builder.config.docs)
}
fn make_run(run: RunConfig<'_>) {
fn run(self, builder: &Builder<'_>) {
let stage = self.stage;
let target = self.target;
+ let mut is_explicit_request = false;
builder.info(&format!("Documenting stage{} compiler ({})", stage, target));
- if !builder.config.compiler_docs {
+ let paths = builder
+ .paths
+ .iter()
+ .map(components_simplified)
+ .filter_map(|path| {
+ if path.get(0) == Some(&"compiler") {
+ is_explicit_request = true;
+ path.get(1).map(|p| p.to_owned())
+ } else {
+ None
+ }
+ })
+ .collect::<Vec<_>>();
+
+ if !builder.config.compiler_docs && !is_explicit_request {
builder.info("\tskipping - compiler/librustdoc docs disabled");
return;
}
cargo.rustdocflag("-Zunstable-options");
cargo.rustdocflag("-Znormalize-docs");
cargo.rustdocflag("--show-type-layout");
+ cargo.rustdocflag("--generate-link-to-definition");
compile::rustc_cargo(builder, &mut cargo, target);
cargo.arg("-Zunstable-options");
cargo.arg("-Zskip-rustdoc-fingerprint");
cargo.rustdocflag("--extern-html-root-url");
cargo.rustdocflag("ena=https://docs.rs/ena/latest/");
- // Find dependencies for top level crates.
let mut compiler_crates = HashSet::new();
- for root_crate in &["rustc_driver", "rustc_codegen_llvm", "rustc_codegen_ssa"] {
- compiler_crates.extend(
- builder
- .in_tree_crates(root_crate, Some(target))
- .into_iter()
- .map(|krate| krate.name),
- );
+
+ if paths.is_empty() {
+ // Find dependencies for top level crates.
+ for root_crate in &["rustc_driver", "rustc_codegen_llvm", "rustc_codegen_ssa"] {
+ compiler_crates.extend(
+ builder
+ .in_tree_crates(root_crate, Some(target))
+ .into_iter()
+ .map(|krate| krate.name),
+ );
+ }
+ } else {
+ for root_crate in paths {
+ if !builder.src.join("compiler").join(&root_crate).exists() {
+ builder.info(&format!(
+ "\tskipping - compiler/{} (unknown compiler crate)",
+ root_crate
+ ));
+ } else {
+ compiler_crates.extend(
+ builder
+ .in_tree_crates(root_crate, Some(target))
+ .into_iter()
+ .map(|krate| krate.name),
+ );
+ }
+ }
}
+ let mut to_open = None;
for krate in &compiler_crates {
// Create all crate output directories first to make sure rustdoc uses
// relative links.
// FIXME: Cargo should probably do this itself.
t!(fs::create_dir_all(out_dir.join(krate)));
cargo.arg("-p").arg(krate);
+ if to_open.is_none() {
+ to_open = Some(krate);
+ }
}
builder.run(&mut cargo.into());
+ // Let's open the first crate documentation page:
+ if let Some(krate) = to_open {
+ let index = out.join(krate).join("index.html");
+ open(builder, &index);
+ }
}
}
-Subproject commit c3a51e23859554369e6bbb5128dcef0e4f159fb5
+Subproject commit 4c76da9ddb4650203c129fceffdea95a3466c205
-Subproject commit 04f489c889235fe3b6dfe678ae5410d07deda958
+Subproject commit 9d4132b56c4999cd3ce1aeca5f1b2f2cb0d11c24
-Subproject commit 95f1acf9a39d6f402f654e917e2c1dfdb779c5fc
+Subproject commit 9198465b6ca8bed669df0cbb67c0e6d0b140803c
--- /dev/null
+# `remap-cwd-prefix`
+
+The tracking issue for this feature is: [#87325](https://github.com/rust-lang/rust/issues/87325).
+
+------------------------
+
+This flag will rewrite absolute paths under the current working directory,
+replacing the current working directory prefix with a specified value.
+
+The given value may be absolute or relative, or empty. This switch takes
+precidence over `--remap-path-prefix` in case they would both match a given
+path.
+
+This flag helps to produce deterministic output, by removing the current working
+directory from build output, while allowing the command line to be universally
+reproducible, such that the same execution will work on all machines, regardless
+of build environment.
+
+## Example
+```sh
+# This would produce an absolute path to main.rs in build outputs of
+# "./main.rs".
+rustc -Z remap-cwd-prefix=. main.rs
+```
| Architecture | ABI name | Clobbered registers |
| ------------ | -------- | ------------------- |
-| x86-32 | `"C"`, `"system"`, `"efiapi"`, `"cdecl"`, `"stdcall"`, `"fastcall"` | `ax`, `cx`, `dx`, `xmm[0-7]`, `mm[0-7]`, `st([0-7])` |
-| x86-64 | `"C"`, `"system"` (on Windows), `"efiapi"`, `"win64"` | `ax`, `cx`, `dx`, `r[8-11]`, `xmm[0-31]`, `mm[0-7]`, `st([0-7])` |
-| x86-64 | `"C"`, `"system"` (on non-Windows), `"sysv64"` | `ax`, `cx`, `dx`, `si`, `di`, `r[8-11]`, `xmm[0-31]`, `mm[0-7]`, `st([0-7])` |
+| x86-32 | `"C"`, `"system"`, `"efiapi"`, `"cdecl"`, `"stdcall"`, `"fastcall"` | `ax`, `cx`, `dx`, `xmm[0-7]`, `mm[0-7]`, `k[1-7]`, `st([0-7])` |
+| x86-64 | `"C"`, `"system"` (on Windows), `"efiapi"`, `"win64"` | `ax`, `cx`, `dx`, `r[8-11]`, `xmm[0-31]`, `mm[0-7]`, `k[1-7]`, `st([0-7])` |
+| x86-64 | `"C"`, `"system"` (on non-Windows), `"sysv64"` | `ax`, `cx`, `dx`, `si`, `di`, `r[8-11]`, `xmm[0-31]`, `mm[0-7]`, `k[1-7]`, `st([0-7])` |
| AArch64 | `"C"`, `"system"`, `"efiapi"` | `x[0-17]`, `x30`, `v[0-31]`, `p[0-15]`, `ffr` |
| ARM | `"C"`, `"system"`, `"efiapi"`, `"aapcs"` | `r[0-3]`, `r12`, `r14`, `s[0-15]`, `d[0-7]`, `d[16-31]` |
| RISC-V | `"C"`, `"system"`, `"efiapi"` | `x1`, `x[5-7]`, `x[10-17]`, `x[28-31]`, `f[0-7]`, `f[10-17]`, `f[28-31]`, `v[0-31]` |
use std::fs;
use std::io;
-use std::path::Path;
+use std::path::{Path, PathBuf};
use std::string::ToString;
use std::sync::mpsc::Sender;
fs::create_dir_all(path)
}
- crate fn write<P, C, E>(&self, path: P, contents: C) -> Result<(), E>
+ crate fn write<E>(
+ &self,
+ path: PathBuf,
+ contents: impl 'static + Send + AsRef<[u8]>,
+ ) -> Result<(), E>
where
- P: AsRef<Path>,
- C: AsRef<[u8]>,
E: PathError,
{
if !self.sync_only && cfg!(windows) {
// A possible future enhancement after more detailed profiling would
// be to create the file sync so errors are reported eagerly.
- let path = path.as_ref().to_path_buf();
- let contents = contents.as_ref().to_vec();
let sender = self.errors.clone().expect("can't write after closing");
rayon::spawn(move || {
fs::write(&path, contents).unwrap_or_else(|e| {
|buf: &mut Buffer| all.print(buf),
&self.shared.style_files,
);
- self.shared.fs.write(final_file, v.as_bytes())?;
+ self.shared.fs.write(final_file, v)?;
// Generating settings page.
page.title = "Rustdoc settings";
)?,
&style_files,
);
- self.shared.fs.write(&settings_file, v.as_bytes())?;
+ self.shared.fs.write(settings_file, v)?;
if let Some(ref redirections) = self.shared.redirections {
if !redirections.borrow().is_empty() {
let redirect_map_path =
self.dst.join(&*crate_name.as_str()).join("redirect-map.json");
let paths = serde_json::to_string(&*redirections.borrow()).unwrap();
self.shared.ensure_dir(&self.dst.join(&*crate_name.as_str()))?;
- self.shared.fs.write(&redirect_map_path, paths.as_bytes())?;
+ self.shared.fs.write(redirect_map_path, paths)?;
}
}
if !buf.is_empty() {
self.shared.ensure_dir(&self.dst)?;
let joint_dst = self.dst.join("index.html");
- scx.fs.write(&joint_dst, buf.as_bytes())?;
+ scx.fs.write(joint_dst, buf)?;
}
// Render sidebar-items.js used throughout this module.
let items = self.build_sidebar_items(module);
let js_dst = self.dst.join("sidebar-items.js");
let v = format!("initSidebarItems({});", serde_json::to_string(&items).unwrap());
- scx.fs.write(&js_dst, &v)?;
+ scx.fs.write(js_dst, v)?;
}
Ok(())
}
let file_name = &item_path(item_type, &name.as_str());
self.shared.ensure_dir(&self.dst)?;
let joint_dst = self.dst.join(file_name);
- self.shared.fs.write(&joint_dst, buf.as_bytes())?;
+ self.shared.fs.write(joint_dst, buf)?;
if !self.render_redirect_pages {
self.shared.all.borrow_mut().append(full_path(self, &item), &item_type);
} else {
let v = layout::redirect(file_name);
let redir_dst = self.dst.join(redir_name);
- self.shared.fs.write(&redir_dst, v.as_bytes())?;
+ self.shared.fs.write(redir_dst, v)?;
}
}
}
self.dst.join(&filename)
}
- fn write_shared<C: AsRef<[u8]>>(
+ fn write_shared(
&self,
resource: SharedResource<'_>,
- contents: C,
+ contents: impl 'static + Send + AsRef<[u8]>,
emit: &[EmitType],
) -> Result<(), Error> {
if resource.should_emit(emit) {
fn write_minify(
&self,
resource: SharedResource<'_>,
- contents: &str,
+ contents: impl 'static + Send + AsRef<str> + AsRef<[u8]>,
minify: bool,
emit: &[EmitType],
) -> Result<(), Error> {
- let tmp;
- let contents = if minify {
- tmp = if resource.extension() == Some(&OsStr::new("css")) {
+ if minify {
+ let contents = contents.as_ref();
+ let contents = if resource.extension() == Some(&OsStr::new("css")) {
minifier::css::minify(contents).map_err(|e| {
Error::new(format!("failed to minify CSS file: {}", e), resource.path(self))
})?
} else {
minifier::js::minify(contents)
};
- tmp.as_bytes()
+ self.write_shared(resource, contents, emit)
} else {
- contents.as_bytes()
- };
-
- self.write_shared(resource, contents, emit)
+ self.write_shared(resource, contents, emit)
+ }
}
}
let lock_file = cx.dst.join(".lock");
let _lock = try_err!(flock::Lock::new(&lock_file, true, true, true), &lock_file);
- // The weird `: &_` is to work around a borrowck bug: https://github.com/rust-lang/rust/issues/41078#issuecomment-293646723
- let write_minify = |p, c: &_| {
+ // Minified resources are usually toolchain resources. If they're not, they should use `cx.write_minify` directly.
+ fn write_minify(
+ basename: &'static str,
+ contents: impl 'static + Send + AsRef<str> + AsRef<[u8]>,
+ cx: &Context<'_>,
+ options: &RenderOptions,
+ ) -> Result<(), Error> {
cx.write_minify(
- SharedResource::ToolchainSpecific { basename: p },
- c,
+ SharedResource::ToolchainSpecific { basename },
+ contents,
options.enable_minification,
&options.emit,
)
- };
+ }
+
// Toolchain resources should never be dynamic.
let write_toolchain = |p: &'static _, c: &'static _| {
cx.write_shared(SharedResource::ToolchainSpecific { basename: p }, c, &options.emit)
"details.undocumented > summary::before, details.rustdoc-toggle > summary::before",
"toggle-plus.svg",
);
- write_minify("rustdoc.css", &rustdoc_css)?;
+ write_minify("rustdoc.css", rustdoc_css, cx, options)?;
// Add all the static files. These may already exist, but we just
// overwrite them anyway to make sure that they're fresh and up-to-date.
- write_minify("settings.css", static_files::SETTINGS_CSS)?;
- write_minify("noscript.css", static_files::NOSCRIPT_CSS)?;
+ write_minify("settings.css", static_files::SETTINGS_CSS, cx, options)?;
+ write_minify("noscript.css", static_files::NOSCRIPT_CSS, cx, options)?;
// To avoid "light.css" to be overwritten, we'll first run over the received themes and only
// then we'll run over the "official" styles.
// Handle the official themes
match theme {
- "light" => write_minify("light.css", static_files::themes::LIGHT)?,
- "dark" => write_minify("dark.css", static_files::themes::DARK)?,
- "ayu" => write_minify("ayu.css", static_files::themes::AYU)?,
+ "light" => write_minify("light.css", static_files::themes::LIGHT, cx, options)?,
+ "dark" => write_minify("dark.css", static_files::themes::DARK, cx, options)?,
+ "ayu" => write_minify("ayu.css", static_files::themes::AYU, cx, options)?,
_ => {
// Handle added third-party themes
let filename = format!("{}.{}", theme, extension);
// Maybe we can change the representation to move this out of main.js?
write_minify(
"main.js",
- &static_files::MAIN_JS.replace(
- "/* INSERT THEMES HERE */",
- &format!(" = {}", serde_json::to_string(&themes).unwrap()),
- ),
+ static_files::MAIN_JS
+ .replace(
+ "/* INSERT THEMES HERE */",
+ &format!(" = {}", serde_json::to_string(&themes).unwrap()),
+ )
+ .replace(
+ "/* INSERT RUSTDOC_VERSION HERE */",
+ &format!(
+ "rustdoc {}",
+ rustc_interface::util::version_str().unwrap_or("unknown version")
+ ),
+ ),
+ cx,
+ options,
)?;
- write_minify("search.js", static_files::SEARCH_JS)?;
- write_minify("settings.js", static_files::SETTINGS_JS)?;
+ write_minify("search.js", static_files::SEARCH_JS, cx, options)?;
+ write_minify("settings.js", static_files::SETTINGS_JS, cx, options)?;
if cx.include_sources {
- write_minify("source-script.js", static_files::sidebar::SOURCE_SCRIPT)?;
+ write_minify("source-script.js", static_files::sidebar::SOURCE_SCRIPT, cx, options)?;
}
{
write_minify(
"storage.js",
- &format!(
+ format!(
"var resourcesSuffix = \"{}\";{}",
cx.shared.resource_suffix,
static_files::STORAGE_JS
),
+ cx,
+ options,
)?;
}
// This varies based on the invocation, so it can't go through the write_minify wrapper.
cx.write_minify(
SharedResource::InvocationSpecific { basename: "theme.css" },
- &buffer,
+ buffer,
options.enable_minification,
&options.emit,
)?;
}
- write_minify("normalize.css", static_files::NORMALIZE_CSS)?;
+ write_minify("normalize.css", static_files::NORMALIZE_CSS, cx, options)?;
for (name, contents) in &*FILES_UNVERSIONED {
cx.write_shared(SharedResource::Unversioned { name }, contents, &options.emit)?;
}
content,
&cx.shared.style_files,
);
- cx.shared.fs.write(&dst, v.as_bytes())?;
+ cx.shared.fs.write(dst, v)?;
}
}
}",
);
v.push_str("})()");
- cx.shared.fs.write(&mydst, &v)?;
+ cx.shared.fs.write(mydst, v)?;
}
Ok(())
}
},
&self.cx.shared.style_files,
);
- self.cx.shared.fs.write(&cur, v.as_bytes())?;
+ self.cx.shared.fs.write(cur, v)?;
self.emitted_local_sources.insert(p);
Ok(())
}
display: block;
margin-right: 0.5rem;
}
-#help > div > span {
+#help span.top, #help span.bottom {
text-align: center;
display: block;
- margin: 10px 0;
font-size: 18px;
- border-bottom: 1px solid #ccc;
+
+}
+#help span.top {
+ text-align: center;
+ display: block;
+ margin: 10px 0;
+ border-bottom: 1px solid;
padding-bottom: 4px;
margin-bottom: 6px;
}
+#help span.bottom {
+ clear: both;
+ border-top: 1px solid;
+}
#help dd { margin: 5px 35px; }
#help .infos { padding-left: 0; }
#help h1, #help h2 { margin-top: 0; }
border-radius: 4px;
}
-#help > div > span {
- border-bottom-color: #5c6773;
+#help span.bottom, #help span.top {
+ border-color: #5c6773;
}
.since {
border-color: #bfbfbf;
}
-#help > div > span {
- border-bottom-color: #bfbfbf;
+#help span.bottom, #help span.top {
+ border-color: #bfbfbf;
}
#help dt {
border-color: #bfbfbf;
}
-#help > div > span {
- border-bottom-color: #bfbfbf;
+#help span.bottom, #help span.top {
+ border-color: #bfbfbf;
}
.since {
});
var book_info = document.createElement("span");
+ book_info.className = "top";
book_info.innerHTML = "You can find more information in \
<a href=\"https://doc.rust-lang.org/rustdoc/\">the rustdoc book</a>.";
container.appendChild(div_shortcuts);
container.appendChild(div_infos);
+ var rustdoc_version = document.createElement("span");
+ rustdoc_version.className = "bottom";
+ var rustdoc_version_code = document.createElement("code");
+ rustdoc_version_code.innerText = "/* INSERT RUSTDOC_VERSION HERE */";
+ rustdoc_version.appendChild(rustdoc_version_code);
+
+ container.appendChild(rustdoc_version);
+
popup.appendChild(container);
insertAfter(popup, searchState.outputElement());
// So that it's only built once and then it'll do nothing when called!
if cx.tcx.hir().attrs(hir_id).lists(sym::doc).has_word(sym::hidden)
|| inherits_doc_hidden(cx.tcx, hir_id)
+ || cx.tcx.hir().span(hir_id).in_derive_expansion()
{
return false;
}
// cdb-only
// min-cdb-version: 10.0.21287.1005
// compile-flags:-g
+// FIXME: Failed on update to 10.0.22000.1
+// ignore-windows
// === CDB TESTS ==================================================================================
//
+++ /dev/null
-// Test for issue 85480
-// Pretty print anonymous struct and union types
-
-// pp-exact
-// pretty-compare-only
-
-struct Foo {
- _: union {
- _: struct {
- a: u8,
- b: u16,
- },
- c: u32,
- },
- d: u64,
- e: f32,
-}
-
-type A =
- struct {
- field: u8,
- };
-
-fn main() { }
opt \
link_paths \
remap_paths \
- different_source_dirs \
+ different_source_dirs_rlib \
+ remap_cwd_rlib \
+ remap_cwd_to_empty \
extern_flags
+# TODO: Builds of `bin` crate types are not deterministic with debuginfo=2 on
+# Windows.
+# See: https://github.com/rust-lang/rust/pull/87320#issuecomment-920105533
+# Issue: https://github.com/rust-lang/rust/issues/88982
+#
+# different_source_dirs_bin \
+# remap_cwd_bin \
+
smoke:
rm -rf $(TMPDIR) && mkdir $(TMPDIR)
$(RUSTC) linker.rs -O
$(RUSTC) reproducible-build.rs --crate-type rlib --remap-path-prefix=/b=/c
cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1
-different_source_dirs:
+different_source_dirs_bin:
+ rm -rf $(TMPDIR) && mkdir $(TMPDIR)
+ $(RUSTC) reproducible-build-aux.rs
+ mkdir $(TMPDIR)/test
+ cp reproducible-build.rs $(TMPDIR)/test
+ $(RUSTC) reproducible-build.rs --crate-type bin --remap-path-prefix=$$PWD=/b
+ cp $(TMPDIR)/reproducible-build $(TMPDIR)/foo
+ (cd $(TMPDIR)/test && $(RUSTC) reproducible-build.rs \
+ --remap-path-prefix=$(TMPDIR)/test=/b \
+ --crate-type bin)
+ cmp "$(TMPDIR)/reproducible-build" "$(TMPDIR)/foo" || exit 1
+
+different_source_dirs_rlib:
rm -rf $(TMPDIR) && mkdir $(TMPDIR)
$(RUSTC) reproducible-build-aux.rs
mkdir $(TMPDIR)/test
--crate-type rlib)
cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1
+remap_cwd_bin:
+ rm -rf $(TMPDIR) && mkdir $(TMPDIR)
+ $(RUSTC) reproducible-build-aux.rs
+ mkdir $(TMPDIR)/test
+ cp reproducible-build.rs $(TMPDIR)/test
+ $(RUSTC) reproducible-build.rs --crate-type bin -C debuginfo=2 \
+ -Z remap-cwd-prefix=.
+ cp $(TMPDIR)/reproducible-build $(TMPDIR)/first
+ (cd $(TMPDIR)/test && \
+ $(RUSTC) reproducible-build.rs --crate-type bin -C debuginfo=2 \
+ -Z remap-cwd-prefix=.)
+ cmp "$(TMPDIR)/first" "$(TMPDIR)/reproducible-build" || exit 1
+
+remap_cwd_rlib:
+ rm -rf $(TMPDIR) && mkdir $(TMPDIR)
+ $(RUSTC) reproducible-build-aux.rs
+ mkdir $(TMPDIR)/test
+ cp reproducible-build.rs $(TMPDIR)/test
+ $(RUSTC) reproducible-build.rs --crate-type rlib -C debuginfo=2 \
+ -Z remap-cwd-prefix=.
+ cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfirst.rlib
+ (cd $(TMPDIR)/test && \
+ $(RUSTC) reproducible-build.rs --crate-type rlib -C debuginfo=2 \
+ -Z remap-cwd-prefix=.)
+ cmp "$(TMPDIR)/libfirst.rlib" "$(TMPDIR)/libreproducible_build.rlib" || exit 1
+
+remap_cwd_to_empty:
+ rm -rf $(TMPDIR) && mkdir $(TMPDIR)
+ $(RUSTC) reproducible-build-aux.rs
+ mkdir $(TMPDIR)/test
+ cp reproducible-build.rs $(TMPDIR)/test
+ $(RUSTC) reproducible-build.rs --crate-type rlib -C debuginfo=2 \
+ -Z remap-cwd-prefix=
+ cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfirst.rlib
+ (cd $(TMPDIR)/test && \
+ $(RUSTC) reproducible-build.rs --crate-type rlib -C debuginfo=2 \
+ -Z remap-cwd-prefix=)
+ cmp "$(TMPDIR)/libfirst.rlib" "$(TMPDIR)/libreproducible_build.rlib" || exit 1
+
extern_flags:
rm -rf $(TMPDIR) && mkdir $(TMPDIR)
$(RUSTC) reproducible-build-aux.rs
return s
+def set_ld_lib_path():
+ var = os.environ.get("LD_LIB_PATH_ENVVAR")
+ rpath = os.environ.get("HOST_RPATH_DIR")
+ if var and rpath:
+ path = os.environ.get(var)
+ if path:
+ os.environ[var] = rpath + os.pathsep + path
+ else:
+ os.environ[var] = rpath
+
+
def exec_command(command, to_input=None):
child = None
if to_input is None:
if isfile(join(dir_path, f)) and f.endswith('.rlib') and f not in STABLE_CRATES]
+set_ld_lib_path()
sysroot = exec_command([os.environ['RUSTC'], '--print', 'sysroot'])[0].replace('\n', '')
+assert sysroot, "Could not read the rustc sysroot!"
libs = get_all_libs(join(sysroot, 'lib/rustlib/{}/lib'.format(os.environ['TARGET'])))
ret = 0
}
+
+/// doc
+///
+/// ```
+/// println!("hello");
+/// ```
+#[derive(Clone)]
+pub struct NiceStruct;
+
#[doc(hidden)]
pub mod foo {
pub fn bar() {}
LL | impl dyn Trait {
| ^^^^^^^^^ `Trait` cannot be made into an object
|
- = help: consider moving `N` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/associated-const-in-trait.rs:6:11
|
| ----- this trait cannot be made into an object...
LL | const N: usize;
| ^ ...because it contains this associated `const`
+ = help: consider moving `N` to another trait
error: aborting due to previous error
LL | impl dyn Bar {}
| ^^^^^^^ `Bar` cannot be made into an object
|
- = help: consider moving `X` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-48027.rs:2:11
|
| --- this trait cannot be made into an object...
LL | const X: usize;
| ^ ...because it contains this associated `const`
+ = help: consider moving `X` to another trait
error: aborting due to 2 previous errors
--> $DIR/associated-types-bound-failure.rs:19:19
|
LL | ToInt::to_int(&g.get())
- | ^^^^^^^^ the trait `ToInt` is not implemented for `<G as GetToInt>::R`
+ | ------------- ^^^^^^^^ the trait `ToInt` is not implemented for `<G as GetToInt>::R`
+ | |
+ | required by a bound introduced by this call
|
note: required by `ToInt::to_int`
--> $DIR/associated-types-bound-failure.rs:6:5
pub fn f1_uint_uint() {
f1(2u32, 4u32);
//~^ ERROR `u32: Foo` is not satisfied
- //~| ERROR `u32: Foo` is not satisfied
}
pub fn f1_uint_int() {
f1(2u32, 4i32);
//~^ ERROR `u32: Foo` is not satisfied
- //~| ERROR `u32: Foo` is not satisfied
}
pub fn f2_int() {
| ~~~
error[E0277]: the trait bound `u32: Foo` is not satisfied
- --> $DIR/associated-types-path-2.rs:29:5
+ --> $DIR/associated-types-path-2.rs:29:14
|
LL | f1(2u32, 4u32);
- | ^^ the trait `Foo` is not implemented for `u32`
+ | -- ^^^^ the trait `Foo` is not implemented for `u32`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `f1`
--> $DIR/associated-types-path-2.rs:13:14
| ^^^ required by this bound in `f1`
error[E0277]: the trait bound `u32: Foo` is not satisfied
- --> $DIR/associated-types-path-2.rs:29:5
- |
-LL | f1(2u32, 4u32);
- | ^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `u32`
-
-error[E0277]: the trait bound `u32: Foo` is not satisfied
- --> $DIR/associated-types-path-2.rs:35:5
+ --> $DIR/associated-types-path-2.rs:34:14
|
LL | f1(2u32, 4i32);
- | ^^ the trait `Foo` is not implemented for `u32`
+ | -- ^^^^ the trait `Foo` is not implemented for `u32`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `f1`
--> $DIR/associated-types-path-2.rs:13:14
LL | pub fn f1<T: Foo>(a: T, x: T::A) {}
| ^^^ required by this bound in `f1`
-error[E0277]: the trait bound `u32: Foo` is not satisfied
- --> $DIR/associated-types-path-2.rs:35:5
- |
-LL | f1(2u32, 4i32);
- | ^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `u32`
-
error[E0308]: mismatched types
- --> $DIR/associated-types-path-2.rs:41:18
+ --> $DIR/associated-types-path-2.rs:39:18
|
LL | let _: i32 = f2(2i32);
| --- ^^^^^^^^ expected `i32`, found `u32`
LL | let _: i32 = f2(2i32).try_into().unwrap();
| ++++++++++++++++++++
-error: aborting due to 6 previous errors
+error: aborting due to 4 previous errors
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
--- /dev/null
+trait From<Src> {
+ type Output;
+
+ fn from(src: Src) -> <Self as From<Src>>::Output;
+}
+
+trait To: Sized {
+ fn to<Dst: From<Self>>(self) ->
+ <Dst as From<Self>>::Dst
+ //~^ ERROR cannot find associated type `Dst` in trait `From`
+ {
+ From::from(self)
+ }
+}
+
+fn main() {}
--- /dev/null
+error[E0576]: cannot find associated type `Dst` in trait `From`
+ --> $DIR/issue-19883.rs:9:30
+ |
+LL | type Output;
+ | ------------ associated type `Output` defined here
+...
+LL | <Dst as From<Self>>::Dst
+ | ^^^
+ | |
+ | not found in `From`
+ | help: maybe you meant this associated type: `Output`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0576`.
--- /dev/null
+// check-pass
+// pretty-expanded FIXME #23616
+
+#![no_implicit_prelude]
+
+trait Iterator {
+ type Item;
+ fn dummy(&self) { }
+}
+
+impl<'a, T> Iterator for &'a mut (dyn Iterator<Item=T> + 'a) {
+ type Item = T;
+}
+
+fn main() {}
--> $DIR/issue-27675-unchecked-bounds.rs:15:31
|
LL | copy::<dyn Setup<From=T>>(t)
- | ^ the trait `Copy` is not implemented for `T`
+ | ------------------------- ^ the trait `Copy` is not implemented for `T`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `copy`
--> $DIR/issue-27675-unchecked-bounds.rs:10:12
--- /dev/null
+// compile-flags: -C opt-level=3
+// edition:2018
+
+use std::future::Future;
+use std::marker::PhantomData;
+use std::pin::Pin;
+use std::sync::atomic::AtomicUsize;
+use std::sync::Arc;
+use std::task::Poll::{Pending, Ready};
+use std::task::Waker;
+use std::task::{Context, Poll};
+use std::{
+ ptr,
+ task::{RawWaker, RawWakerVTable},
+};
+
+/// Future for the [`poll_fn`] function.
+pub struct PollFn<F> {
+ f: F,
+}
+
+impl<F> Unpin for PollFn<F> {}
+
+/// Creates a new future wrapping around a function returning [`Poll`].
+pub fn poll_fn<T, F>(f: F) -> PollFn<F>
+where
+ F: FnMut(&mut Context<'_>) -> Poll<T>,
+{
+ PollFn { f }
+}
+
+impl<T, F> Future for PollFn<F>
+where
+ F: FnMut(&mut Context<'_>) -> Poll<T>,
+{
+ type Output = T;
+
+ fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<T> {
+ (&mut self.f)(cx)
+ }
+}
+pub fn run<F: Future>(future: F) -> F::Output {
+ BasicScheduler.block_on(future)
+}
+
+pub(crate) struct BasicScheduler;
+
+impl BasicScheduler {
+ pub(crate) fn block_on<F>(&mut self, mut future: F) -> F::Output
+ where
+ F: Future,
+ {
+ let waker = unsafe { Waker::from_raw(raw_waker()) };
+ let mut cx = std::task::Context::from_waker(&waker);
+
+ let mut future = unsafe { Pin::new_unchecked(&mut future) };
+
+ loop {
+ if let Ready(v) = future.as_mut().poll(&mut cx) {
+ return v;
+ }
+ }
+ }
+}
+
+// ===== impl Spawner =====
+
+fn raw_waker() -> RawWaker {
+ RawWaker::new(ptr::null(), waker_vtable())
+}
+
+fn waker_vtable() -> &'static RawWakerVTable {
+ &RawWakerVTable::new(
+ clone_arc_raw,
+ wake_arc_raw,
+ wake_by_ref_arc_raw,
+ drop_arc_raw,
+ )
+}
+
+unsafe fn clone_arc_raw(_: *const ()) -> RawWaker {
+ raw_waker()
+}
+
+unsafe fn wake_arc_raw(_: *const ()) {}
+
+unsafe fn wake_by_ref_arc_raw(_: *const ()) {}
+
+unsafe fn drop_arc_raw(_: *const ()) {}
+
+struct AtomicWaker {}
+
+impl AtomicWaker {
+ /// Create an `AtomicWaker`
+ fn new() -> AtomicWaker {
+ AtomicWaker {}
+ }
+
+ fn register_by_ref(&self, _waker: &Waker) {}
+}
+
+#[allow(dead_code)]
+struct Tx<T> {
+ inner: Arc<Chan<T>>,
+}
+
+struct Rx<T> {
+ inner: Arc<Chan<T>>,
+}
+
+#[allow(dead_code)]
+struct Chan<T> {
+ tx: PhantomData<T>,
+ semaphore: Sema,
+ rx_waker: AtomicWaker,
+ rx_closed: bool,
+}
+
+fn channel<T>() -> (Tx<T>, Rx<T>) {
+ let chan = Arc::new(Chan {
+ tx: PhantomData,
+ semaphore: Sema(AtomicUsize::new(0)),
+ rx_waker: AtomicWaker::new(),
+ rx_closed: false,
+ });
+
+ (
+ Tx {
+ inner: chan.clone(),
+ },
+ Rx { inner: chan },
+ )
+}
+
+// ===== impl Rx =====
+
+impl<T> Rx<T> {
+ /// Receive the next value
+ fn recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<T>> {
+ self.inner.rx_waker.register_by_ref(cx.waker());
+
+ if self.inner.rx_closed && self.inner.semaphore.is_idle() {
+ Ready(None)
+ } else {
+ Pending
+ }
+ }
+}
+
+struct Sema(AtomicUsize);
+
+impl Sema {
+ fn is_idle(&self) -> bool {
+ false
+ }
+}
+
+pub struct UnboundedReceiver<T> {
+ chan: Rx<T>,
+}
+
+pub fn unbounded_channel<T>() -> UnboundedReceiver<T> {
+ let (tx, rx) = channel();
+
+ drop(tx);
+ let rx = UnboundedReceiver { chan: rx };
+
+ rx
+}
+
+impl<T> UnboundedReceiver<T> {
+ pub async fn recv(&mut self) -> Option<T> {
+ poll_fn(|cx| self.chan.recv(cx)).await
+ }
+}
--> $DIR/issue-72442.rs:12:36
|
LL | let mut f = File::open(path.to_str())?;
- | ^^^^^^^^^^^^^ the trait `AsRef<Path>` is not implemented for `Option<&str>`
+ | ---------- ^^^^^^^^^^^^^ the trait `AsRef<Path>` is not implemented for `Option<&str>`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `File::open`
--> $SRC_DIR/std/src/fs.rs:LL:COL
--- /dev/null
+// compile-flags: -C opt-level=3
+// aux-build: issue-72470-lib.rs
+// edition:2018
+// build-pass
+
+// Regression test for issue #72470, using the minimization
+// in https://github.com/jonas-schievink/llvm-error
+
+extern crate issue_72470_lib;
+
+use std::future::Future;
+use std::pin::Pin;
+use std::sync::Mutex;
+use std::task::Poll::{Pending, Ready};
+
+#[allow(dead_code)]
+enum Msg {
+ A(Vec<()>),
+ B,
+}
+
+#[allow(dead_code)]
+enum Out {
+ _0(Option<Msg>),
+ Disabled,
+}
+
+#[allow(unused_must_use)]
+fn main() {
+ let mut rx = issue_72470_lib::unbounded_channel::<Msg>();
+ let entity = Mutex::new(());
+ issue_72470_lib::run(async move {
+ {
+ let output = {
+ let mut fut = rx.recv();
+ issue_72470_lib::poll_fn(|cx| {
+ loop {
+ let fut = unsafe { Pin::new_unchecked(&mut fut) };
+ let out = match fut.poll(cx) {
+ Ready(out) => out,
+ Pending => {
+ break;
+ }
+ };
+ #[allow(unused_variables)]
+ match &out {
+ Some(_msg) => {}
+ _ => break,
+ }
+ return Ready(Out::_0(out));
+ }
+ Ready(Out::_0(None))
+ })
+ .await
+ };
+ match output {
+ Out::_0(Some(_msg)) => {
+ entity.lock();
+ }
+ Out::_0(None) => unreachable!(),
+ _ => unreachable!(),
+ }
+ }
+ entity.lock();
+ });
+}
+++ /dev/null
-#[macro_export]
-macro_rules! define_macro {
- ($i:ident) => {
- macro_rules! $i { () => {} }
- }
-}
+++ /dev/null
-// compile-flags: -C opt-level=3
-// edition:2018
-
-use std::future::Future;
-use std::marker::PhantomData;
-use std::pin::Pin;
-use std::sync::atomic::AtomicUsize;
-use std::sync::Arc;
-use std::task::Poll::{Pending, Ready};
-use std::task::Waker;
-use std::task::{Context, Poll};
-use std::{
- ptr,
- task::{RawWaker, RawWakerVTable},
-};
-
-/// Future for the [`poll_fn`] function.
-pub struct PollFn<F> {
- f: F,
-}
-
-impl<F> Unpin for PollFn<F> {}
-
-/// Creates a new future wrapping around a function returning [`Poll`].
-pub fn poll_fn<T, F>(f: F) -> PollFn<F>
-where
- F: FnMut(&mut Context<'_>) -> Poll<T>,
-{
- PollFn { f }
-}
-
-impl<T, F> Future for PollFn<F>
-where
- F: FnMut(&mut Context<'_>) -> Poll<T>,
-{
- type Output = T;
-
- fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<T> {
- (&mut self.f)(cx)
- }
-}
-pub fn run<F: Future>(future: F) -> F::Output {
- BasicScheduler.block_on(future)
-}
-
-pub(crate) struct BasicScheduler;
-
-impl BasicScheduler {
- pub(crate) fn block_on<F>(&mut self, mut future: F) -> F::Output
- where
- F: Future,
- {
- let waker = unsafe { Waker::from_raw(raw_waker()) };
- let mut cx = std::task::Context::from_waker(&waker);
-
- let mut future = unsafe { Pin::new_unchecked(&mut future) };
-
- loop {
- if let Ready(v) = future.as_mut().poll(&mut cx) {
- return v;
- }
- }
- }
-}
-
-// ===== impl Spawner =====
-
-fn raw_waker() -> RawWaker {
- RawWaker::new(ptr::null(), waker_vtable())
-}
-
-fn waker_vtable() -> &'static RawWakerVTable {
- &RawWakerVTable::new(
- clone_arc_raw,
- wake_arc_raw,
- wake_by_ref_arc_raw,
- drop_arc_raw,
- )
-}
-
-unsafe fn clone_arc_raw(_: *const ()) -> RawWaker {
- raw_waker()
-}
-
-unsafe fn wake_arc_raw(_: *const ()) {}
-
-unsafe fn wake_by_ref_arc_raw(_: *const ()) {}
-
-unsafe fn drop_arc_raw(_: *const ()) {}
-
-struct AtomicWaker {}
-
-impl AtomicWaker {
- /// Create an `AtomicWaker`
- fn new() -> AtomicWaker {
- AtomicWaker {}
- }
-
- fn register_by_ref(&self, _waker: &Waker) {}
-}
-
-#[allow(dead_code)]
-struct Tx<T> {
- inner: Arc<Chan<T>>,
-}
-
-struct Rx<T> {
- inner: Arc<Chan<T>>,
-}
-
-#[allow(dead_code)]
-struct Chan<T> {
- tx: PhantomData<T>,
- semaphore: Sema,
- rx_waker: AtomicWaker,
- rx_closed: bool,
-}
-
-fn channel<T>() -> (Tx<T>, Rx<T>) {
- let chan = Arc::new(Chan {
- tx: PhantomData,
- semaphore: Sema(AtomicUsize::new(0)),
- rx_waker: AtomicWaker::new(),
- rx_closed: false,
- });
-
- (
- Tx {
- inner: chan.clone(),
- },
- Rx { inner: chan },
- )
-}
-
-// ===== impl Rx =====
-
-impl<T> Rx<T> {
- /// Receive the next value
- fn recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<T>> {
- self.inner.rx_waker.register_by_ref(cx.waker());
-
- if self.inner.rx_closed && self.inner.semaphore.is_idle() {
- Ready(None)
- } else {
- Pending
- }
- }
-}
-
-struct Sema(AtomicUsize);
-
-impl Sema {
- fn is_idle(&self) -> bool {
- false
- }
-}
-
-pub struct UnboundedReceiver<T> {
- chan: Rx<T>,
-}
-
-pub fn unbounded_channel<T>() -> UnboundedReceiver<T> {
- let (tx, rx) = channel();
-
- drop(tx);
- let rx = UnboundedReceiver { chan: rx };
-
- rx
-}
-
-impl<T> UnboundedReceiver<T> {
- pub async fn recv(&mut self) -> Option<T> {
- poll_fn(|cx| self.chan.recv(cx)).await
- }
-}
LL | let x = Box::new(0);
| - captured outer variable
LL | Box::new(|| x)
- | ^ move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait
+ | ---^
+ | | |
+ | | move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait
+ | captured by this `Fn` closure
error: aborting due to previous error
error[E0507]: cannot move out of `bar`, a captured variable in an `FnMut` closure
--> $DIR/borrowck-move-by-capture.rs:9:29
|
-LL | let bar: Box<_> = box 3;
- | --- captured outer variable
-LL | let _g = to_fn_mut(|| {
-LL | let _h = to_fn_once(move || -> isize { *bar });
- | ^^^^^^^^^^^^^^^^ ----
- | | |
- | | move occurs because `bar` has type `Box<isize>`, which does not implement the `Copy` trait
- | | move occurs due to use in closure
- | move out of `bar` occurs here
+LL | let bar: Box<_> = box 3;
+ | --- captured outer variable
+LL | let _g = to_fn_mut(|| {
+ | ________________________-
+LL | | let _h = to_fn_once(move || -> isize { *bar });
+ | | ^^^^^^^^^^^^^^^^ ----
+ | | | |
+ | | | move occurs because `bar` has type `Box<isize>`, which does not implement the `Copy` trait
+ | | | move occurs due to use in closure
+ | | move out of `bar` occurs here
+LL | | });
+ | |_____- captured by this `FnMut` closure
error: aborting due to previous error
--- /dev/null
+// Regression test for #87456.
+
+fn take_mut(_val: impl FnMut()) {}
+
+fn main() {
+ let val = String::new();
+ //~^ NOTE: captured outer variable
+ take_mut(|| {
+ //~^ NOTE: captured by this `FnMut` closure
+ let _foo: String = val;
+ //~^ ERROR: cannot move out of `val`, a captured variable in an `FnMut` closure [E0507]
+ //~| NOTE: move occurs because
+ })
+}
--- /dev/null
+error[E0507]: cannot move out of `val`, a captured variable in an `FnMut` closure
+ --> $DIR/issue-87456-point-to-closure.rs:10:28
+ |
+LL | let val = String::new();
+ | --- captured outer variable
+LL |
+LL | take_mut(|| {
+ | ______________-
+LL | |
+LL | | let _foo: String = val;
+ | | ^^^
+ | | |
+ | | move occurs because `val` has type `String`, which does not implement the `Copy` trait
+ | | help: consider borrowing here: `&val`
+LL | |
+LL | |
+LL | | })
+ | |_____- captured by this `FnMut` closure
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0507`.
error[E0507]: cannot move out of `y`, a captured variable in an `Fn` closure
--> $DIR/unboxed-closures-move-upvar-from-non-once-ref-closure.rs:11:9
|
-LL | let y = vec![format!("World")];
- | - captured outer variable
-LL | call(|| {
-LL | y.into_iter();
- | ^ move occurs because `y` has type `Vec<String>`, which does not implement the `Copy` trait
+LL | let y = vec![format!("World")];
+ | - captured outer variable
+LL | call(|| {
+ | __________-
+LL | | y.into_iter();
+ | | ^ move occurs because `y` has type `Vec<String>`, which does not implement the `Copy` trait
+LL | |
+LL | | });
+ | |_____- captured by this `Fn` closure
error: aborting due to previous error
--> $DIR/into-boxed-slice-fail.rs:7:35
|
LL | let _ = Box::into_boxed_slice(boxed_slice);
- | ^^^^^^^^^^^ doesn't have a size known at compile-time
+ | --------------------- ^^^^^^^^^^^ doesn't have a size known at compile-time
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Sized` is not implemented for `[u8]`
note: required by `Box::<T, A>::into_boxed_slice`
--> $DIR/into-boxed-slice-fail.rs:11:35
|
LL | let _ = Box::into_boxed_slice(boxed_trait);
- | ^^^^^^^^^^^ doesn't have a size known at compile-time
+ | --------------------- ^^^^^^^^^^^ doesn't have a size known at compile-time
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Sized` is not implemented for `dyn Debug`
note: required by `Box::<T, A>::into_boxed_slice`
+++ /dev/null
-// run-pass
-
-trait Speak : Sized {
- fn say(&self, s:&str) -> String;
- fn hi(&self) -> String { hello(self) }
-}
-
-fn hello<S:Speak>(s:&S) -> String{
- s.say("hello")
-}
-
-impl Speak for isize {
- fn say(&self, s:&str) -> String {
- format!("{}: {}", s, *self)
- }
-}
-
-impl<T: Speak> Speak for Option<T> {
- fn say(&self, s:&str) -> String {
- match *self {
- None => format!("{} - none", s),
- Some(ref x) => { format!("something!{}", x.say(s)) }
- }
- }
-}
-
-
-pub fn main() {
- assert_eq!(3.hi(), "hello: 3".to_string());
- assert_eq!(Some(Some(3)).hi(),
- "something!something!hello: 3".to_string());
- assert_eq!(None::<isize>.hi(), "hello - none".to_string());
-
- assert_eq!(Some(None::<isize>).hi(), "something!hello - none".to_string());
- assert_eq!(Some(3).hi(), "something!hello: 3".to_string());
-}
--> $DIR/type_inference.rs:27:14
|
LL | only_bar(x);
- | ^ the trait `Bar` is not implemented for `{float}`
+ | -------- ^ the trait `Bar` is not implemented for `{float}`
+ | |
+ | required by a bound introduced by this call
|
= help: the following implementations were found:
<i32 as Bar>
--> $DIR/closure-expected.rs:3:23
|
LL | let y = x.or_else(4);
- | ^ expected an `FnOnce<()>` closure, found `{integer}`
+ | ------- ^ expected an `FnOnce<()>` closure, found `{integer}`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `FnOnce<()>` is not implemented for `{integer}`
= note: wrap the `{integer}` in a closure with no arguments: `|| { /* code */ }`
--> $DIR/closure-bounds-subtype.rs:13:22
|
LL | take_const_owned(f);
- | ^ `F` cannot be shared between threads safely
+ | ---------------- ^ `F` cannot be shared between threads safely
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `take_const_owned`
--> $DIR/closure-bounds-subtype.rs:4:50
--> $DIR/coerce-unsafe-to-closure.rs:2:44
|
LL | let x: Option<&[u8]> = Some("foo").map(std::mem::transmute);
- | ^^^^^^^^^^^^^^^^^^^ expected an `FnOnce<(&str,)>` closure, found `unsafe extern "rust-intrinsic" fn(_) -> _ {transmute::<_, _>}`
+ | --- ^^^^^^^^^^^^^^^^^^^ expected an `FnOnce<(&str,)>` closure, found `unsafe extern "rust-intrinsic" fn(_) -> _ {transmute::<_, _>}`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `FnOnce<(&str,)>` is not implemented for `unsafe extern "rust-intrinsic" fn(_) -> _ {transmute::<_, _>}`
--- /dev/null
+fn server() -> impl {
+//~^ ERROR at least one trait must be specified
+ ().map2(|| "")
+}
+
+trait FilterBase2 {
+ fn map2<F>(self, f: F) -> Map2<F> {}
+ //~^ ERROR mismatched types
+ //~^^ ERROR the size for values of type `Self` cannot be known at compilation time
+}
+
+struct Map2<Segment2> {
+ _func: F,
+ //~^ ERROR cannot find type `F` in this scope
+}
+
+impl<F> FilterBase2 for F {}
+
+fn main() {}
--- /dev/null
+error: at least one trait must be specified
+ --> $DIR/issue-78720.rs:1:16
+ |
+LL | fn server() -> impl {
+ | ^^^^
+
+error[E0412]: cannot find type `F` in this scope
+ --> $DIR/issue-78720.rs:13:12
+ |
+LL | _func: F,
+ | ^
+ |
+ ::: $SRC_DIR/core/src/ops/function.rs:LL:COL
+ |
+LL | pub trait Fn<Args>: FnMut<Args> {
+ | ------------------------------- similarly named trait `Fn` defined here
+ |
+help: a trait with a similar name exists
+ |
+LL | _func: Fn,
+ | ~~
+help: you might be missing a type parameter
+ |
+LL | struct Map2<Segment2, F> {
+ | +++
+
+error[E0308]: mismatched types
+ --> $DIR/issue-78720.rs:7:39
+ |
+LL | fn map2<F>(self, f: F) -> Map2<F> {}
+ | ^^ expected struct `Map2`, found `()`
+ |
+ = note: expected struct `Map2<F>`
+ found unit type `()`
+
+error[E0277]: the size for values of type `Self` cannot be known at compilation time
+ --> $DIR/issue-78720.rs:7:16
+ |
+LL | fn map2<F>(self, f: F) -> Map2<F> {}
+ | ^^^^ doesn't have a size known at compile-time
+ |
+ = help: unsized fn params are gated as an unstable feature
+help: consider further restricting `Self`
+ |
+LL | fn map2<F>(self, f: F) -> Map2<F> where Self: Sized {}
+ | +++++++++++++++++
+help: function arguments must have a statically known size, borrowed types always have a known size
+ |
+LL | fn map2<F>(&self, f: F) -> Map2<F> {}
+ | +
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0277, E0308, E0412.
+For more information about an error, try `rustc --explain E0277`.
LL | impl NotObjectSafe for dyn NotObjectSafe { }
| ^^^^^^^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object
|
- = help: consider moving `eq` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/coherence-impl-trait-for-trait-object-safe.rs:6:43
|
| ------------- ^^^^ ...because method `eq` references the `Self` type in this parameter
| |
| this trait cannot be made into an object...
+ = help: consider moving `eq` to another trait
error: aborting due to previous error
--> $DIR/coherence-unsafe-trait-object-impl.rs:15:13
|
LL | takes_t(t);
- | ^ the trait `Trait` is not implemented for `&dyn Trait`
+ | ------- ^ the trait `Trait` is not implemented for `&dyn Trait`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `takes_t`
--> $DIR/coherence-unsafe-trait-object-impl.rs:10:15
LL | fn use_dyn(v: &dyn Foo) {
| ^^^^^^^ `Foo` cannot be made into an object
|
- = help: consider moving `test` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/object-safety-err-ret.rs:8:23
|
| --- this trait cannot be made into an object...
LL | fn test(&self) -> [u8; bar::<Self>()];
| ^^^^^^^^^^^^^^^^^^^ ...because method `test` references the `Self` type in its return type
+ = help: consider moving `test` to another trait
error: aborting due to previous error
--> $DIR/issue-86530.rs:16:7
|
LL | z(" ");
- | ^^^ the trait `X` is not implemented for `&str`
+ | - ^^^ the trait `X` is not implemented for `&str`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `z`
--> $DIR/issue-86530.rs:10:8
--- /dev/null
+pub trait MyTrait {
+ type Assoc;
+}
+
+pub fn foo<S, T>(_s: S, _t: T)
+where
+ S: MyTrait,
+ T: MyTrait<Assoc == S::Assoc>,
+ //~^ ERROR: expected one of `,` or `>`, found `==`
+ //~| ERROR: this trait takes 0 generic arguments but 1 generic argument was supplied
+{
+}
+
+fn main() {}
--- /dev/null
+error: expected one of `,` or `>`, found `==`
+ --> $DIR/issue-87493.rs:8:22
+ |
+LL | T: MyTrait<Assoc == S::Assoc>,
+ | ^^ expected one of `,` or `>`
+ |
+help: if you meant to use an associated type binding, replace `==` with `=`
+ |
+LL | T: MyTrait<Assoc = S::Assoc>,
+ | ~
+
+error[E0107]: this trait takes 0 generic arguments but 1 generic argument was supplied
+ --> $DIR/issue-87493.rs:8:8
+ |
+LL | T: MyTrait<Assoc == S::Assoc>,
+ | ^^^^^^^------------------- help: remove these generics
+ | |
+ | expected 0 generic arguments
+ |
+note: trait defined here, with 0 generic parameters
+ --> $DIR/issue-87493.rs:1:11
+ |
+LL | pub trait MyTrait {
+ | ^^^^^^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0107`.
const X: () = std::unimplemented!();
//~^ ERROR evaluation of constant value failed
-//
+
const W: () = std::panic!(MSG);
//~^ ERROR evaluation of constant value failed
+const W2: () = std::panic!("{}", MSG);
+//~^ ERROR evaluation of constant value failed
+
const Z_CORE: () = core::panic!("cheese");
//~^ ERROR evaluation of constant value failed
const W_CORE: () = core::panic!(MSG);
//~^ ERROR evaluation of constant value failed
+
+const W2_CORE: () = core::panic!("{}", MSG);
+//~^ ERROR evaluation of constant value failed
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
- --> $DIR/const_panic.rs:22:20
+ --> $DIR/const_panic.rs:22:16
+ |
+LL | const W2: () = std::panic!("{}", MSG);
+ | ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic.rs:22:16
+ |
+ = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0080]: evaluation of constant value failed
+ --> $DIR/const_panic.rs:25:20
|
LL | const Z_CORE: () = core::panic!("cheese");
- | ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'cheese', $DIR/const_panic.rs:22:20
+ | ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'cheese', $DIR/const_panic.rs:25:20
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
- --> $DIR/const_panic.rs:25:21
+ --> $DIR/const_panic.rs:28:21
|
LL | const Z2_CORE: () = core::panic!();
- | ^^^^^^^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:25:21
+ | ^^^^^^^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:28:21
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
- --> $DIR/const_panic.rs:28:20
+ --> $DIR/const_panic.rs:31:20
|
LL | const Y_CORE: () = core::unreachable!();
- | ^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:28:20
+ | ^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:31:20
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
- --> $DIR/const_panic.rs:31:20
+ --> $DIR/const_panic.rs:34:20
|
LL | const X_CORE: () = core::unimplemented!();
- | ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:31:20
+ | ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:34:20
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
- --> $DIR/const_panic.rs:34:20
+ --> $DIR/const_panic.rs:37:20
|
LL | const W_CORE: () = core::panic!(MSG);
- | ^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic.rs:34:20
+ | ^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic.rs:37:20
+ |
+ = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0080]: evaluation of constant value failed
+ --> $DIR/const_panic.rs:40:21
+ |
+LL | const W2_CORE: () = core::panic!("{}", MSG);
+ | ^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic.rs:40:21
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
-error: aborting due to 10 previous errors
+error: aborting due to 12 previous errors
For more information about this error, try `rustc --explain E0080`.
#![feature(const_panic)]
#![crate_type = "lib"]
+const MSG: &str = "hello";
+
const A: () = std::panic!("blåhaj");
//~^ ERROR evaluation of constant value failed
const D: () = std::unimplemented!();
//~^ ERROR evaluation of constant value failed
-const E: () = core::panic!("shark");
+const E: () = std::panic!("{}", MSG);
+//~^ ERROR evaluation of constant value failed
+
+const A_CORE: () = core::panic!("shark");
+//~^ ERROR evaluation of constant value failed
+
+const B_CORE: () = core::panic!();
//~^ ERROR evaluation of constant value failed
-const F: () = core::panic!();
+const C_CORE: () = core::unreachable!();
//~^ ERROR evaluation of constant value failed
-const G: () = core::unreachable!();
+const D_CORE: () = core::unimplemented!();
//~^ ERROR evaluation of constant value failed
-const H: () = core::unimplemented!();
+const E_CORE: () = core::panic!("{}", MSG);
//~^ ERROR evaluation of constant value failed
error[E0080]: evaluation of constant value failed
- --> $DIR/const_panic_2021.rs:5:15
+ --> $DIR/const_panic_2021.rs:7:15
|
LL | const A: () = std::panic!("blåhaj");
- | ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'blåhaj', $DIR/const_panic_2021.rs:5:15
+ | ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'blåhaj', $DIR/const_panic_2021.rs:7:15
|
= note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
- --> $DIR/const_panic_2021.rs:8:15
+ --> $DIR/const_panic_2021.rs:10:15
|
LL | const B: () = std::panic!();
- | ^^^^^^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const_panic_2021.rs:8:15
+ | ^^^^^^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const_panic_2021.rs:10:15
|
= note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
- --> $DIR/const_panic_2021.rs:11:15
+ --> $DIR/const_panic_2021.rs:13:15
|
LL | const C: () = std::unreachable!();
- | ^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_2021.rs:11:15
+ | ^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_2021.rs:13:15
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
- --> $DIR/const_panic_2021.rs:14:15
+ --> $DIR/const_panic_2021.rs:16:15
|
LL | const D: () = std::unimplemented!();
- | ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic_2021.rs:14:15
+ | ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic_2021.rs:16:15
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
- --> $DIR/const_panic_2021.rs:17:15
+ --> $DIR/const_panic_2021.rs:19:15
|
-LL | const E: () = core::panic!("shark");
- | ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'shark', $DIR/const_panic_2021.rs:17:15
+LL | const E: () = std::panic!("{}", MSG);
+ | ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic_2021.rs:19:15
|
= note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
- --> $DIR/const_panic_2021.rs:20:15
+ --> $DIR/const_panic_2021.rs:22:20
|
-LL | const F: () = core::panic!();
- | ^^^^^^^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const_panic_2021.rs:20:15
+LL | const A_CORE: () = core::panic!("shark");
+ | ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'shark', $DIR/const_panic_2021.rs:22:20
|
= note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
- --> $DIR/const_panic_2021.rs:23:15
+ --> $DIR/const_panic_2021.rs:25:20
|
-LL | const G: () = core::unreachable!();
- | ^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_2021.rs:23:15
+LL | const B_CORE: () = core::panic!();
+ | ^^^^^^^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const_panic_2021.rs:25:20
+ |
+ = note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0080]: evaluation of constant value failed
+ --> $DIR/const_panic_2021.rs:28:20
+ |
+LL | const C_CORE: () = core::unreachable!();
+ | ^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_2021.rs:28:20
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
- --> $DIR/const_panic_2021.rs:26:15
+ --> $DIR/const_panic_2021.rs:31:20
|
-LL | const H: () = core::unimplemented!();
- | ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic_2021.rs:26:15
+LL | const D_CORE: () = core::unimplemented!();
+ | ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic_2021.rs:31:20
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
-error: aborting due to 8 previous errors
+error[E0080]: evaluation of constant value failed
+ --> $DIR/const_panic_2021.rs:34:20
+ |
+LL | const E_CORE: () = core::panic!("{}", MSG);
+ | ^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic_2021.rs:34:20
+ |
+ = note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 10 previous errors
For more information about this error, try `rustc --explain E0080`.
--- /dev/null
+// run-pass
+#![allow(unused_imports)]
+use std::fmt;
+
+const A_I8_T
+ : [u32; (i8::MAX as i8 - 1i8) as usize]
+ = [0; (i8::MAX as usize) - 1];
+
+fn main() {
+ foo(&A_I8_T[..]);
+}
+
+fn foo<T:fmt::Debug>(x: T) {
+ println!("{:?}", x);
+}
--- /dev/null
+// run-pass
+
+#![warn(pointer_structural_match)]
+#![allow(dead_code)]
+const C: *const u8 = &0;
+
+fn foo(x: *const u8) {
+ match x {
+ C => {}
+ _ => {}
+ }
+}
+
+const D: *const [u8; 4] = b"abcd";
+
+fn main() {
+ match D {
+ D => {}
+ _ => {}
+ }
+}
|
LL | impl<T: std::fmt::Debug> Foo<T> {
| ^
+LL |
+LL | const fn foo(&self) {}
+ | ------------------- function declared as const here
|
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
= help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
|
LL | impl<T: std::fmt::Debug + Sized> Foo<T> {
| ^
+LL |
+LL | const fn foo2(&self) {}
+ | -------------------- function declared as const here
|
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
= help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
|
LL | impl<T: Sync + Sized> Foo<T> {
| ^
+LL |
+LL | const fn foo3(&self) {}
+ | -------------------- function declared as const here
|
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
= help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
--> $DIR/min_const_fn.rs:139:41
|
LL | const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1 }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | |
+ | function declared as const here
|
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
= help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
--> $DIR/min_const_fn.rs:139:42
|
LL | const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1 }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | |
+ | function declared as const here
|
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
= help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
--> $DIR/min_const_fn.rs:139:42
|
LL | const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1 }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | |
+ | function declared as const here
|
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
= help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
--> $DIR/min_const_fn_dyn.rs:9:5
|
+LL | const fn no_inner_dyn_trait2(x: Hide) {
+ | ------------------------------------- function declared as const here
LL | x.0.field;
| ^^^^^^^^^
|
--> $DIR/min_const_fn_dyn.rs:12:66
|
LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) }
- | ^^
+ | ----------------------------------------- ^^
+ | |
+ | function declared as const here
|
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
= help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable
--> $DIR/deriving-copyclone.rs:31:13
|
LL | is_copy(B { a: 1, b: C });
- | ^^^^^^^^^^^^^^^^
- | |
- | expected an implementor of trait `Copy`
- | help: consider borrowing here: `&B { a: 1, b: C }`
+ | ------- ^^^^^^^^^^^^^^^^
+ | | |
+ | | expected an implementor of trait `Copy`
+ | | help: consider borrowing here: `&B { a: 1, b: C }`
+ | required by a bound introduced by this call
|
note: required because of the requirements on the impl of `Copy` for `B<C>`
--> $DIR/deriving-copyclone.rs:9:10
--> $DIR/deriving-copyclone.rs:32:14
|
LL | is_clone(B { a: 1, b: C });
- | ^^^^^^^^^^^^^^^^
- | |
- | expected an implementor of trait `Clone`
- | help: consider borrowing here: `&B { a: 1, b: C }`
+ | -------- ^^^^^^^^^^^^^^^^
+ | | |
+ | | expected an implementor of trait `Clone`
+ | | help: consider borrowing here: `&B { a: 1, b: C }`
+ | required by a bound introduced by this call
|
note: required because of the requirements on the impl of `Clone` for `B<C>`
--> $DIR/deriving-copyclone.rs:9:16
--> $DIR/deriving-copyclone.rs:35:13
|
LL | is_copy(B { a: 1, b: D });
- | ^^^^^^^^^^^^^^^^
- | |
- | expected an implementor of trait `Copy`
- | help: consider borrowing here: `&B { a: 1, b: D }`
+ | ------- ^^^^^^^^^^^^^^^^
+ | | |
+ | | expected an implementor of trait `Copy`
+ | | help: consider borrowing here: `&B { a: 1, b: D }`
+ | required by a bound introduced by this call
|
note: required because of the requirements on the impl of `Copy` for `B<D>`
--> $DIR/deriving-copyclone.rs:9:10
--- /dev/null
+// run-pass
+
+#[derive(PartialEq)]
+struct Bike {
+ name: String,
+}
+
+pub fn main() {
+ let town_bike = Bike { name: "schwinn".to_string() };
+ let my_bike = Bike { name: "surly".to_string() };
+
+ assert!(town_bike != my_bike);
+}
--> $DIR/issue-39802-show-5-trait-impls.rs:24:21
|
LL | Foo::<i32>::bar(&1i8);
- | ^^^^ the trait `Foo<i32>` is not implemented for `i8`
+ | --------------- ^^^^ the trait `Foo<i32>` is not implemented for `i8`
+ | |
+ | required by a bound introduced by this call
|
= help: the following implementations were found:
<i8 as Foo<bool>>
--> $DIR/issue-39802-show-5-trait-impls.rs:25:21
|
LL | Foo::<i32>::bar(&1u8);
- | ^^^^ the trait `Foo<i32>` is not implemented for `u8`
+ | --------------- ^^^^ the trait `Foo<i32>` is not implemented for `u8`
+ | |
+ | required by a bound introduced by this call
|
= help: the following implementations were found:
<u8 as Foo<bool>>
--> $DIR/issue-39802-show-5-trait-impls.rs:26:21
|
LL | Foo::<i32>::bar(&true);
- | ^^^^^ the trait `Foo<i32>` is not implemented for `bool`
+ | --------------- ^^^^^ the trait `Foo<i32>` is not implemented for `bool`
+ | |
+ | required by a bound introduced by this call
|
= help: the following implementations were found:
<bool as Foo<bool>>
+++ /dev/null
-// Test that enabling an unstable feature disables warnings
-
-// aux-build:stability-cfg2.rs
-
-#![feature(unstable_test_feature)]
-#![deny(non_snake_case)] // To trigger a hard error
-
-// Shouldn't generate a warning about unstable features
-extern crate stability_cfg2;
-
-pub fn BOGUS() { } //~ ERROR
-
-pub fn main() { }
+++ /dev/null
-error: function `BOGUS` should have a snake case name
- --> $DIR/enable-unstable-lib-feature.rs:11:8
- |
-LL | pub fn BOGUS() { }
- | ^^^^^ help: convert the identifier to snake case: `bogus`
- |
-note: the lint level is defined here
- --> $DIR/enable-unstable-lib-feature.rs:6:9
- |
-LL | #![deny(non_snake_case)] // To trigger a hard error
- | ^^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
LL | fn call_foo(x: Box<dyn Trait>) {
| ^^^^^^^^^ `Trait` cannot be made into an object
|
- = help: consider moving `foo` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/E0038.rs:2:22
|
| ----- this trait cannot be made into an object...
LL | fn foo(&self) -> Self;
| ^^^^ ...because method `foo` references the `Self` type in its return type
+ = help: consider moving `foo` to another trait
error: aborting due to previous error
--> $DIR/E0277.rs:15:15
|
LL | some_func(5i32);
- | ^^^^ the trait `Foo` is not implemented for `i32`
+ | --------- ^^^^ the trait `Foo` is not implemented for `i32`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `some_func`
--> $DIR/E0277.rs:7:17
--> $DIR/error-should-say-copy-not-pod.rs:6:17
|
LL | check_bound("nocopy".to_string());
- | ^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
+ | ----------- ^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check_bound`
--> $DIR/error-should-say-copy-not-pod.rs:3:18
+++ /dev/null
-// run-pass
-
-#![allow(dead_code)]
-// Issue #521
-
-// pretty-expanded FIXME #23616
-
-fn f() {
- let _x = match true {
- true => { 10 }
- false => { return }
- };
-}
-
-pub fn main() { }
| ^ not found in this scope
error[E0277]: expected a `FnOnce<({integer},)>` closure, found `Option<_>`
- --> $DIR/ruby_style_closure.rs:10:22
+ --> $DIR/ruby_style_closure.rs:10:31
|
-LL | let p = Some(45).and_then({
- | ^^^^^^^^ expected an `FnOnce<({integer},)>` closure, found `Option<_>`
+LL | let p = Some(45).and_then({
+ | ______________________--------_^
+ | | |
+ | | required by a bound introduced by this call
+LL | |
+LL | | |x| println!("doubling {}", x);
+LL | | Some(x * 2)
+ | | -----------
+LL | |
+LL | | });
+ | |_____^ expected an `FnOnce<({integer},)>` closure, found `Option<_>`
|
= help: the trait `FnOnce<({integer},)>` is not implemented for `Option<_>`
--> $DIR/extern-wrong-value-type.rs:9:11
|
LL | is_fn(f);
- | ^ expected an `Fn<()>` closure, found `extern "C" fn() {f}`
+ | ----- ^ expected an `Fn<()>` closure, found `extern "C" fn() {f}`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Fn<()>` is not implemented for `extern "C" fn() {f}`
= note: wrap the `extern "C" fn() {f}` in a closure with no arguments: `|| { /* code */ }`
LL | fn takes_non_object_safe_box(obj: Box<dyn NonObjectSafe3>) {
| ^^^^^^^^^^^^^^^^^^ `NonObjectSafe3` cannot be made into an object
|
- = help: consider moving `foo` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/feature-gate-object_safe_for_dispatch.rs:11:8
|
| -------------- this trait cannot be made into an object...
LL | fn foo<T>(&self);
| ^^^ ...because method `foo` has generic type parameters
+ = help: consider moving `foo` to another trait
error[E0038]: the trait `NonObjectSafe4` cannot be made into an object
--> $DIR/feature-gate-object_safe_for_dispatch.rs:31:35
LL | fn return_non_object_safe_rc() -> std::rc::Rc<dyn NonObjectSafe4> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `NonObjectSafe4` cannot be made into an object
|
- = help: consider moving `foo` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/feature-gate-object_safe_for_dispatch.rs:15:22
|
| -------------- this trait cannot be made into an object...
LL | fn foo(&self, s: &Self);
| ^^^^^ ...because method `foo` references the `Self` type in this parameter
+ = help: consider moving `foo` to another trait
error[E0038]: the trait `NonObjectSafe1` cannot be made into an object
--> $DIR/feature-gate-object_safe_for_dispatch.rs:38:16
+++ /dev/null
-struct Foo {
- foo: u8,
- _: union { //~ ERROR unnamed fields are not yet fully implemented [E0658]
- //~^ ERROR unnamed fields are not yet fully implemented [E0658]
- //~| ERROR anonymous unions are unimplemented
- bar: u8,
- baz: u16
- }
-}
-
-union Bar {
- foobar: u8,
- _: struct { //~ ERROR unnamed fields are not yet fully implemented [E0658]
- //~^ ERROR unnamed fields are not yet fully implemented [E0658]
- //~| ERROR anonymous structs are unimplemented
- //~| ERROR unions may not contain fields that need dropping [E0740]
- foobaz: u8,
- barbaz: u16
- }
-}
-
-struct S;
-struct Baz {
- _: S //~ ERROR unnamed fields are not yet fully implemented [E0658]
-}
-
-fn main(){}
+++ /dev/null
-error[E0658]: unnamed fields are not yet fully implemented
- --> $DIR/feature-gate-unnamed_fields.rs:3:5
- |
-LL | _: union {
- | ^
- |
- = note: see issue #49804 <https://github.com/rust-lang/rust/issues/49804> for more information
- = help: add `#![feature(unnamed_fields)]` to the crate attributes to enable
-
-error[E0658]: unnamed fields are not yet fully implemented
- --> $DIR/feature-gate-unnamed_fields.rs:3:8
- |
-LL | _: union {
- | ________^
-LL | |
-LL | |
-LL | | bar: u8,
-LL | | baz: u16
-LL | | }
- | |_____^
- |
- = note: see issue #49804 <https://github.com/rust-lang/rust/issues/49804> for more information
- = help: add `#![feature(unnamed_fields)]` to the crate attributes to enable
-
-error[E0658]: unnamed fields are not yet fully implemented
- --> $DIR/feature-gate-unnamed_fields.rs:13:5
- |
-LL | _: struct {
- | ^
- |
- = note: see issue #49804 <https://github.com/rust-lang/rust/issues/49804> for more information
- = help: add `#![feature(unnamed_fields)]` to the crate attributes to enable
-
-error[E0658]: unnamed fields are not yet fully implemented
- --> $DIR/feature-gate-unnamed_fields.rs:13:8
- |
-LL | _: struct {
- | ________^
-LL | |
-LL | |
-LL | |
-LL | | foobaz: u8,
-LL | | barbaz: u16
-LL | | }
- | |_____^
- |
- = note: see issue #49804 <https://github.com/rust-lang/rust/issues/49804> for more information
- = help: add `#![feature(unnamed_fields)]` to the crate attributes to enable
-
-error[E0658]: unnamed fields are not yet fully implemented
- --> $DIR/feature-gate-unnamed_fields.rs:24:5
- |
-LL | _: S
- | ^
- |
- = note: see issue #49804 <https://github.com/rust-lang/rust/issues/49804> for more information
- = help: add `#![feature(unnamed_fields)]` to the crate attributes to enable
-
-error: anonymous unions are unimplemented
- --> $DIR/feature-gate-unnamed_fields.rs:3:8
- |
-LL | _: union {
- | ________^
-LL | |
-LL | |
-LL | | bar: u8,
-LL | | baz: u16
-LL | | }
- | |_____^
-
-error: anonymous structs are unimplemented
- --> $DIR/feature-gate-unnamed_fields.rs:13:8
- |
-LL | _: struct {
- | ________^
-LL | |
-LL | |
-LL | |
-LL | | foobaz: u8,
-LL | | barbaz: u16
-LL | | }
- | |_____^
-
-error[E0740]: unions may not contain fields that need dropping
- --> $DIR/feature-gate-unnamed_fields.rs:13:5
- |
-LL | / _: struct {
-LL | |
-LL | |
-LL | |
-LL | | foobaz: u8,
-LL | | barbaz: u16
-LL | | }
- | |_____^
- |
-note: `std::mem::ManuallyDrop` can be used to wrap the type
- --> $DIR/feature-gate-unnamed_fields.rs:13:5
- |
-LL | / _: struct {
-LL | |
-LL | |
-LL | |
-LL | | foobaz: u8,
-LL | | barbaz: u16
-LL | | }
- | |_____^
-
-error: aborting due to 8 previous errors
-
-Some errors have detailed explanations: E0658, E0740.
-For more information about an error, try `rustc --explain E0658`.
| +
error[E0277]: the size for values of type `(dyn Foo + 'static)` cannot be known at compilation time
- --> $DIR/feature-gate-unsized_fn_params.rs:24:5
+ --> $DIR/feature-gate-unsized_fn_params.rs:24:9
|
LL | foo(*x);
- | ^^^ doesn't have a size known at compile-time
+ | ^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `(dyn Foo + 'static)`
= note: all function arguments must have a statically known size
--> $DIR/fn-trait-formatting.rs:19:14
|
LL | needs_fn(1);
- | ^ expected an `Fn<(isize,)>` closure, found `{integer}`
+ | -------- ^ expected an `Fn<(isize,)>` closure, found `{integer}`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Fn<(isize,)>` is not implemented for `{integer}`
note: required by a bound in `needs_fn`
--- /dev/null
+// Regression test for #88653, where a confusing warning about a
+// type mismatch in generator arguments was issued.
+
+#![feature(generators, generator_trait)]
+
+use std::ops::Generator;
+
+fn foo(bar: bool) -> impl Generator<(bool,)> {
+//~^ ERROR: type mismatch in generator arguments [E0631]
+//~| NOTE: expected signature of `fn((bool,)) -> _`
+ |bar| {
+ //~^ NOTE: found signature of `fn(bool) -> _`
+ if bar {
+ yield bar;
+ }
+ }
+}
+
+fn main() {}
--- /dev/null
+error[E0631]: type mismatch in generator arguments
+ --> $DIR/issue-88653.rs:8:22
+ |
+LL | fn foo(bar: bool) -> impl Generator<(bool,)> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^ expected signature of `fn((bool,)) -> _`
+...
+LL | |bar| {
+ | ----- found signature of `fn(bool) -> _`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0631`.
--> $DIR/static-not-unpin.rs:14:18
|
LL | assert_unpin(generator);
- | ^^^^^^^^^ the trait `Unpin` is not implemented for `[static generator@$DIR/static-not-unpin.rs:11:25: 13:6]`
+ | ------------ ^^^^^^^^^ the trait `Unpin` is not implemented for `[static generator@$DIR/static-not-unpin.rs:11:25: 13:6]`
+ | |
+ | required by a bound introduced by this call
|
= note: consider using `Box::pin`
note: required by a bound in `assert_unpin`
LL | fn f(_arg : Box<dyn for<'a> Foo<A<'a> = &'a ()>>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
|
- = help: consider moving `A` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/gat-in-trait-path.rs:5:10
|
| --- this trait cannot be made into an object...
LL | type A<'a> where Self: 'a;
| ^ ...because it contains the generic associated type `A`
+ = help: consider moving `A` to another trait
error: aborting due to previous error
LL | fn _func1<'a>(_x: Box<dyn X<Y<'a>=&'a ()>>) {}
| ^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
|
- = help: consider moving `Y` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-67510-pass.rs:4:10
|
| - this trait cannot be made into an object...
LL | type Y<'a>;
| ^ ...because it contains the generic associated type `Y`
+ = help: consider moving `Y` to another trait
error: aborting due to previous error
LL | let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object
|
- = help: consider moving `SubType` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-76535.rs:6:10
|
| ---------- this trait cannot be made into an object...
LL | type SubType<'a>: SubTrait;
| ^^^^^^^ ...because it contains the generic associated type `SubType`
+ = help: consider moving `SubType` to another trait
error[E0038]: the trait `SuperTrait` cannot be made into an object
--> $DIR/issue-76535.rs:36:57
LL | let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object
|
- = help: consider moving `SubType` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-76535.rs:6:10
|
| ---------- this trait cannot be made into an object...
LL | type SubType<'a>: SubTrait;
| ^^^^^^^ ...because it contains the generic associated type `SubType`
+ = help: consider moving `SubType` to another trait
= note: required because of the requirements on the impl of `CoerceUnsized<Box<dyn SuperTrait<SubType = SubStruct<'_>>>>` for `Box<SuperStruct>`
= note: required by cast to type `Box<dyn SuperTrait<SubType = SubStruct<'_>>>`
LL | Box::new(Family) as &dyn CollectionFamily<Member=usize>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `CollectionFamily` cannot be made into an object
|
- = help: consider moving `Member` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-78671.rs:4:10
|
| ---------------- this trait cannot be made into an object...
LL | type Member<T>;
| ^^^^^^ ...because it contains the generic associated type `Member`
+ = help: consider moving `Member` to another trait
error: aborting due to 2 previous errors
LL | as Box<dyn MapLike<u8, u8, VRefCont = dyn RefCont<'_, u8>>>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object
|
- = help: consider moving `VRefCont` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-79422.rs:20:10
|
| ------- this trait cannot be made into an object...
LL | type VRefCont<'a>: RefCont<'a, V>;
| ^^^^^^^^ ...because it contains the generic associated type `VRefCont`
+ = help: consider moving `VRefCont` to another trait
error[E0038]: the trait `MapLike` cannot be made into an object
--> $DIR/issue-79422.rs:41:13
LL | let m = Box::new(std::collections::BTreeMap::<u8, u8>::new())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object
|
- = help: consider moving `VRefCont` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-79422.rs:20:10
|
| ------- this trait cannot be made into an object...
LL | type VRefCont<'a>: RefCont<'a, V>;
| ^^^^^^^^ ...because it contains the generic associated type `VRefCont`
+ = help: consider moving `VRefCont` to another trait
= note: required because of the requirements on the impl of `CoerceUnsized<Box<dyn MapLike<u8, u8, VRefCont = (dyn RefCont<'_, u8> + 'static)>>>` for `Box<BTreeMap<u8, u8>>`
= note: required by cast to type `Box<dyn MapLike<u8, u8, VRefCont = (dyn RefCont<'_, u8> + 'static)>>`
LL | fn min_size(x: &mut dyn for<'a> StreamingIterator<Item<'a> = &'a i32>) -> usize {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `StreamingIterator` cannot be made into an object
|
- = help: consider moving `Item` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/trait-objects.rs:4:10
|
| ----------------- this trait cannot be made into an object...
LL | type Item<'a> where Self: 'a;
| ^^^^ ...because it contains the generic associated type `Item`
+ = help: consider moving `Item` to another trait
error: aborting due to previous error
--- /dev/null
+// run-pass
+
+#![allow(dead_code)]
+// pretty-expanded FIXME #23616
+
+struct S<T> {
+ contents: T,
+}
+
+impl<T> S<T> {
+ fn new<U>(x: T, _: U) -> S<T> {
+ S {
+ contents: x,
+ }
+ }
+}
+
+trait Trait<T> {
+ fn new<U>(x: T, y: U) -> Self;
+}
+
+struct S2 {
+ contents: isize,
+}
+
+impl Trait<isize> for S2 {
+ fn new<U>(x: isize, _: U) -> S2 {
+ S2 {
+ contents: x,
+ }
+ }
+}
+
+pub fn main() {
+ let _ = S::<isize>::new::<f64>(1, 1.0);
+ let _: S2 = Trait::<isize>::new::<f64>(1, 1.0);
+}
+++ /dev/null
-// run-pass
-
-#![allow(non_shorthand_field_patterns)]
-
-#[derive(Copy, Clone)]
-struct Pair { x: isize, y: isize }
-
-pub fn main() {
- let a: isize =
- match 10 { x if x < 7 => { 1 } x if x < 11 => { 2 } 10 => { 3 } _ => { 4 } };
- assert_eq!(a, 2);
-
- let b: isize =
- match (Pair {x: 10, y: 20}) {
- x if x.x < 5 && x.y < 5 => { 1 }
- Pair {x: x, y: y} if x == 10 && y == 20 => { 2 }
- Pair {x: _x, y: _y} => { 3 }
- };
- assert_eq!(b, 2);
-}
error[E0631]: type mismatch in closure arguments
--> $DIR/issue-62529-1.rs:80:10
|
-LL | task(annotate(
- | ^^^^^^^^ expected signature of `for<'r> fn(<RefMutFamily<usize> as FamilyLt<'r>>::Out) -> _`
-...
-LL | |value: &mut usize| {
- | ------------------- found signature of `for<'r> fn(&'r mut usize) -> _`
+LL | task(annotate(
+ | _____----_^
+ | | |
+ | | required by a bound introduced by this call
+LL | |
+LL | |
+LL | | Annotate::<RefMutFamily<usize>>::new(),
+LL | | |value: &mut usize| {
+ | | ------------------- found signature of `for<'r> fn(&'r mut usize) -> _`
+LL | | *value = 2;
+LL | | }
+LL | | ));
+ | |_____^ expected signature of `for<'r> fn(<RefMutFamily<usize> as FamilyLt<'r>>::Out) -> _`
|
note: required by a bound in `annotate`
--> $DIR/issue-62529-1.rs:44:8
--> $DIR/issue-62529-1.rs:80:10
|
LL | task(annotate(
- | __________^
+ | _____----_^
+ | | |
+ | | required by a bound introduced by this call
LL | |
LL | |
LL | | Annotate::<RefMutFamily<usize>>::new(),
--> $DIR/issue-62529-1.rs:80:10
|
LL | task(annotate(
- | __________^
+ | _____----_^
+ | | |
+ | | required by a bound introduced by this call
LL | |
LL | |
LL | | Annotate::<RefMutFamily<usize>>::new(),
--> $DIR/hrtb-higher-ranker-supertraits-transitive.rs:47:26
|
LL | want_bar_for_any_ccx(b);
- | ^ the trait `for<'ccx> Bar<'ccx>` is not implemented for `B`
+ | -------------------- ^ the trait `for<'ccx> Bar<'ccx>` is not implemented for `B`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `want_bar_for_any_ccx`
--> $DIR/hrtb-higher-ranker-supertraits-transitive.rs:32:15
--> $DIR/hrtb-higher-ranker-supertraits.rs:18:26
|
LL | want_foo_for_any_tcx(f);
- | ^ the trait `for<'tcx> Foo<'tcx>` is not implemented for `F`
+ | -------------------- ^ the trait `for<'tcx> Foo<'tcx>` is not implemented for `F`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `want_foo_for_any_tcx`
--> $DIR/hrtb-higher-ranker-supertraits.rs:22:15
--> $DIR/hrtb-higher-ranker-supertraits.rs:35:26
|
LL | want_bar_for_any_ccx(b);
- | ^ the trait `for<'ccx> Bar<'ccx>` is not implemented for `B`
+ | -------------------- ^ the trait `for<'ccx> Bar<'ccx>` is not implemented for `B`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `want_bar_for_any_ccx`
--> $DIR/hrtb-higher-ranker-supertraits.rs:39:15
--- /dev/null
+trait Foo {
+ type T;
+ fn foo(&self, t: Self::T);
+//~^ NOTE expected 0 type parameters
+}
+
+impl Foo for u32 {
+ type T = ();
+
+ fn foo(&self, t: impl Clone) {}
+//~^ ERROR method `foo` has 1 type parameter but its trait declaration has 0 type parameters
+//~| NOTE found 1 type parameter
+//~| NOTE `impl Trait` introduces an implicit type parameter
+}
+
+fn main() {}
--- /dev/null
+error[E0049]: method `foo` has 1 type parameter but its trait declaration has 0 type parameters
+ --> $DIR/type-arg-mismatch-due-to-impl-trait.rs:10:22
+ |
+LL | fn foo(&self, t: Self::T);
+ | - expected 0 type parameters
+...
+LL | fn foo(&self, t: impl Clone) {}
+ | ^^^^^^^^^^
+ | |
+ | found 1 type parameter
+ | `impl Trait` introduces an implicit type parameter
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0049`.
--- /dev/null
+fn foo(x: Result<i32, ()>) -> Result<(), ()> {
+ let y: u32 = x?;
+ //~^ ERROR: `?` operator has incompatible types
+ Ok(())
+}
+
+fn main() {}
--- /dev/null
+error[E0308]: `?` operator has incompatible types
+ --> $DIR/issue-71309.rs:2:18
+ |
+LL | let y: u32 = x?;
+ | ^^ expected `u32`, found `i32`
+ |
+ = note: `?` operator cannot convert from `i32` to `u32`
+help: you can convert an `i32` to a `u32` and panic if the converted value doesn't fit
+ |
+LL | let y: u32 = x?.try_into().unwrap();
+ | ++++++++++++++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
+++ /dev/null
-// compile-flags: -C opt-level=3
-// aux-build: issue-72470-lib.rs
-// edition:2018
-// build-pass
-
-// Regression test for issue #72470, using the minimization
-// in https://github.com/jonas-schievink/llvm-error
-
-extern crate issue_72470_lib;
-
-use std::future::Future;
-use std::pin::Pin;
-use std::sync::Mutex;
-use std::task::Poll::{Pending, Ready};
-
-#[allow(dead_code)]
-enum Msg {
- A(Vec<()>),
- B,
-}
-
-#[allow(dead_code)]
-enum Out {
- _0(Option<Msg>),
- Disabled,
-}
-
-#[allow(unused_must_use)]
-fn main() {
- let mut rx = issue_72470_lib::unbounded_channel::<Msg>();
- let entity = Mutex::new(());
- issue_72470_lib::run(async move {
- {
- let output = {
- let mut fut = rx.recv();
- issue_72470_lib::poll_fn(|cx| {
- loop {
- let fut = unsafe { Pin::new_unchecked(&mut fut) };
- let out = match fut.poll(cx) {
- Ready(out) => out,
- Pending => {
- break;
- }
- };
- #[allow(unused_variables)]
- match &out {
- Some(_msg) => {}
- _ => break,
- }
- return Ready(Out::_0(out));
- }
- Ready(Out::_0(None))
- })
- .await
- };
- match output {
- Out::_0(Some(_msg)) => {
- entity.lock();
- }
- Out::_0(None) => unreachable!(),
- _ => unreachable!(),
- }
- }
- entity.lock();
- });
-}
fn main() {
(|| Box::new(*(&[0][..])))();
//~^ ERROR the size for values of type
- //~| ERROR the size for values of type
}
--> $DIR/issue-17651.rs:5:18
|
LL | (|| Box::new(*(&[0][..])))();
- | ^^^^^^^^^^^ doesn't have a size known at compile-time
+ | -------- ^^^^^^^^^^^ doesn't have a size known at compile-time
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Sized` is not implemented for `[{integer}]`
note: required by `Box::<T>::new`
LL | pub fn new(x: T) -> Self {
| ^^^^^^^^^^^^^^^^^^^^^^^^
-error[E0277]: the size for values of type `[{integer}]` cannot be known at compilation time
- --> $DIR/issue-17651.rs:5:9
- |
-LL | (|| Box::new(*(&[0][..])))();
- | ^^^^^^^^ doesn't have a size known at compile-time
- |
- = help: the trait `Sized` is not implemented for `[{integer}]`
- = note: all function arguments must have a statically known size
- = help: unsized fn params are gated as an unstable feature
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.
LL | fn foo(b: &dyn Bar) {
| ^^^^^^^ `Bar` cannot be made into an object
|
- = help: consider moving `foo` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-18959.rs:1:20
|
| ^^^ ...because method `foo` has generic type parameters
LL | pub trait Bar: Foo { }
| --- this trait cannot be made into an object...
+ = help: consider moving `foo` to another trait
error: aborting due to previous error
LL | let test: &mut dyn Bar = &mut thing;
| ^^^^^^^^^^^^ `Bar` cannot be made into an object
|
- = help: consider moving `foo` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-19538.rs:2:8
|
...
LL | trait Bar: Foo { }
| --- this trait cannot be made into an object...
+ = help: consider moving `foo` to another trait
error[E0038]: the trait `Bar` cannot be made into an object
--> $DIR/issue-19538.rs:17:30
LL | let test: &mut dyn Bar = &mut thing;
| ^^^^^^^^^^ `Bar` cannot be made into an object
|
- = help: consider moving `foo` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-19538.rs:2:8
|
...
LL | trait Bar: Foo { }
| --- this trait cannot be made into an object...
+ = help: consider moving `foo` to another trait
= note: required because of the requirements on the impl of `CoerceUnsized<&mut dyn Bar>` for `&mut Thing`
= note: required by cast to type `&mut dyn Bar`
+++ /dev/null
-trait From<Src> {
- type Output;
-
- fn from(src: Src) -> <Self as From<Src>>::Output;
-}
-
-trait To: Sized {
- fn to<Dst: From<Self>>(self) ->
- <Dst as From<Self>>::Dst
- //~^ ERROR cannot find associated type `Dst` in trait `From`
- {
- From::from(self)
- }
-}
-
-fn main() {}
+++ /dev/null
-error[E0576]: cannot find associated type `Dst` in trait `From`
- --> $DIR/issue-19883.rs:9:30
- |
-LL | type Output;
- | ------------ associated type `Output` defined here
-...
-LL | <Dst as From<Self>>::Dst
- | ^^^
- | |
- | not found in `From`
- | help: maybe you meant this associated type: `Output`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0576`.
+++ /dev/null
-trait Array: Sized + Copy {}
-
-fn f<T: Array>(x: &T) {
- let _ = x
- //~^ ERROR `Array` cannot be made into an object
- as
- &dyn Array;
- //~^ ERROR `Array` cannot be made into an object
-}
-
-fn main() {}
+++ /dev/null
-error[E0038]: the trait `Array` cannot be made into an object
- --> $DIR/issue-20692.rs:7:5
- |
-LL | &dyn Array;
- | ^^^^^^^^^^ `Array` cannot be made into an object
- |
-note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
- --> $DIR/issue-20692.rs:1:14
- |
-LL | trait Array: Sized + Copy {}
- | ----- ^^^^^ ^^^^ ...because it requires `Self: Sized`
- | | |
- | | ...because it requires `Self: Sized`
- | this trait cannot be made into an object...
-
-error[E0038]: the trait `Array` cannot be made into an object
- --> $DIR/issue-20692.rs:4:13
- |
-LL | let _ = x
- | ^ `Array` cannot be made into an object
- |
-note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
- --> $DIR/issue-20692.rs:1:14
- |
-LL | trait Array: Sized + Copy {}
- | ----- ^^^^^ ^^^^ ...because it requires `Self: Sized`
- | | |
- | | ...because it requires `Self: Sized`
- | this trait cannot be made into an object...
- = note: required because of the requirements on the impl of `CoerceUnsized<&dyn Array>` for `&T`
- = note: required by cast to type `&dyn Array`
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0038`.
+++ /dev/null
-// check-pass
-// pretty-expanded FIXME #23616
-
-#![no_implicit_prelude]
-
-trait Iterator {
- type Item;
- fn dummy(&self) { }
-}
-
-impl<'a, T> Iterator for &'a mut (dyn Iterator<Item=T> + 'a) {
- type Item = T;
-}
-
-fn main() {}
+++ /dev/null
-// run-pass
-trait Stringify {
- fn to_string(&self) -> String;
-}
-
-impl Stringify for u32 {
- fn to_string(&self) -> String { format!("u32: {}", *self) }
-}
-
-impl Stringify for f32 {
- fn to_string(&self) -> String { format!("f32: {}", *self) }
-}
-
-fn print<T: Stringify>(x: T) -> String {
- x.to_string()
-}
-
-fn main() {
- assert_eq!(&print(5), "u32: 5");
- assert_eq!(&print(5.0), "f32: 5");
-}
+++ /dev/null
-// run-pass
-#![allow(unused_imports)]
-use std::fmt;
-
-const A_I8_T
- : [u32; (i8::MAX as i8 - 1i8) as usize]
- = [0; (i8::MAX as usize) - 1];
-
-fn main() {
- foo(&A_I8_T[..]);
-}
-
-fn foo<T:fmt::Debug>(x: T) {
- println!("{:?}", x);
-}
--> $DIR/issue-23966.rs:2:32
|
LL | "".chars().fold(|_, _| (), ());
- | ^^ expected an `FnMut<(_, char)>` closure, found `()`
+ | ---- ^^ expected an `FnMut<(_, char)>` closure, found `()`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `FnMut<(_, char)>` is not implemented for `()`
--> $DIR/issue-25076.rs:10:20
|
LL | do_fold(bot(), ());
- | ^^ the trait `InOut<_>` is not implemented for `()`
+ | ------- ^^ the trait `InOut<_>` is not implemented for `()`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `do_fold`
--> $DIR/issue-25076.rs:5:18
--> $DIR/issue-28098.rs:2:28
|
LL | let _ = Iterator::next(&mut ());
- | ^^^^^^^ `()` is not an iterator
+ | -------------- ^^^^^^^ `()` is not an iterator
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Iterator` is not implemented for `()`
note: required by `std::iter::Iterator::next`
--> $DIR/issue-28098.rs:9:28
|
LL | let _ = Iterator::next(&mut ());
- | ^^^^^^^ `()` is not an iterator
+ | -------------- ^^^^^^^ `()` is not an iterator
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Iterator` is not implemented for `()`
note: required by `std::iter::Iterator::next`
--> $DIR/issue-28098.rs:18:28
|
LL | let _ = Iterator::next(&mut ());
- | ^^^^^^^ `()` is not an iterator
+ | -------------- ^^^^^^^ `()` is not an iterator
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Iterator` is not implemented for `()`
note: required by `std::iter::Iterator::next`
--> $DIR/issue-28098.rs:22:28
|
LL | let _ = Iterator::next(&mut ());
- | ^^^^^^^ `()` is not an iterator
+ | -------------- ^^^^^^^ `()` is not an iterator
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Iterator` is not implemented for `()`
note: required by `std::iter::Iterator::next`
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
- --> $DIR/issue-30355.rs:5:6
+ --> $DIR/issue-30355.rs:5:8
|
LL | &X(*Y)
- | ^ doesn't have a size known at compile-time
+ | ^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[u8]`
= note: all function arguments must have a statically known size
+++ /dev/null
-// run-pass
-#![allow(unused_variables)]
-pub fn main() {
- let x = (0, 2);
-
- match x {
- (0, ref y) => {}
- (y, 0) => {}
- _ => (),
- }
-}
+++ /dev/null
-// build-pass
-#![allow(dead_code)]
-
-struct A {
- a: &'static (),
-}
-
-static B: &'static A = &A { a: &() };
-static C: &'static A = &B;
-
-fn main() {}
fn main() {
Test::Drill(field: 42);
- //~^ ERROR expected type, found
+ //~^ ERROR invalid `struct` delimiters or `fn` call arguments
}
-error: expected type, found `42`
- --> $DIR/issue-34255-1.rs:8:24
+error: invalid `struct` delimiters or `fn` call arguments
+ --> $DIR/issue-34255-1.rs:8:5
|
LL | Test::Drill(field: 42);
- | - ^^ expected type
- | |
- | tried to parse a type due to this type ascription
+ | ^^^^^^^^^^^^^^^^^^^^^^
|
- = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>`
- = note: see issue #23416 <https://github.com/rust-lang/rust/issues/23416> for more information
+help: if `Test::Drill` is a struct, use braces as delimiters
+ |
+LL | Test::Drill { field: 42 };
+ | ~ ~
+help: if `Test::Drill` is a function, use the arguments directly
+ |
+LL - Test::Drill(field: 42);
+LL + Test::Drill(42);
+ |
error: aborting due to previous error
+++ /dev/null
-// run-pass
-
-#![warn(pointer_structural_match)]
-#![allow(dead_code)]
-const C: *const u8 = &0;
-
-fn foo(x: *const u8) {
- match x {
- C => {}
- _ => {}
- }
-}
-
-const D: *const [u8; 4] = b"abcd";
-
-fn main() {
- match D {
- D => {}
- _ => {}
- }
-}
+++ /dev/null
-// check-pass
-#![feature(specialization)]
-//~^ WARN the feature `specialization` is incomplete
-
-fn main() {}
-
-pub trait Alpha<T> { }
-
-pub trait Beta {
- type Event;
-}
-
-pub trait Delta {
- type Handle;
- fn process(&self);
-}
-
-pub struct Parent<A, T>(A, T);
-
-impl<A, T> Delta for Parent<A, T>
-where A: Alpha<T::Handle>,
- T: Delta,
- T::Handle: Beta<Event = <Handle as Beta>::Event> {
- type Handle = Handle;
- default fn process(&self) {
- unimplemented!()
- }
-}
-
-impl<A, T> Delta for Parent<A, T>
-where A: Alpha<T::Handle> + Alpha<Handle>,
- T: Delta,
- T::Handle: Beta<Event = <Handle as Beta>::Event> {
- fn process(&self) {
- unimplemented!()
- }
-}
-
-pub struct Handle;
-
-impl Beta for Handle {
- type Event = ();
-}
+++ /dev/null
-warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/issue-35376.rs:2:12
- |
-LL | #![feature(specialization)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
- = help: consider using `min_specialization` instead, which is more stable and complete
-
-warning: 1 warning emitted
-
+++ /dev/null
-// run-pass
-// compile-flags:--test
-#![deny(private_in_public)]
-
-#[test] fn foo() {}
-mod foo {}
-
-#[test] fn core() {}
-extern crate core;
+++ /dev/null
-// build-fail
-// ignore-emscripten no llvm_asm! support
-
-#![feature(llvm_asm)]
-#![allow(deprecated)] // llvm_asm!
-
-fn main() {
- unsafe {
- llvm_asm!("" :: "r"(""));
- //~^ ERROR: invalid value for constraint in inline assembly
- }
-}
+++ /dev/null
-error[E0669]: invalid value for constraint in inline assembly
- --> $DIR/issue-37433.rs:9:29
- |
-LL | llvm_asm!("" :: "r"(""));
- | ^^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0669`.
+++ /dev/null
-// run-pass
-#![allow(dead_code)]
-// Check that constant ADTs are codegened OK, part k of N.
-
-enum Bar {
- C
-}
-
-enum Foo {
- A {},
- B {
- y: usize,
- z: Bar
- },
-}
-
-const LIST: [(usize, Foo); 2] = [
- (51, Foo::B { y: 42, z: Bar::C }),
- (52, Foo::B { y: 45, z: Bar::C }),
-];
-
-pub fn main() {
- match LIST {
- [
- (51, Foo::B { y: 42, z: Bar::C }),
- (52, Foo::B { y: 45, z: Bar::C })
- ] => {}
- _ => {
- // I would want to print the enum here, but if
- // the discriminant is garbage this causes an
- // `unreachable` and silent process exit.
- panic!("trivial match failed")
- }
- }
-}
+++ /dev/null
-// run-pass
-
-#[derive(PartialEq)]
-struct Bike {
- name: String,
-}
-
-pub fn main() {
- let town_bike = Bike { name: "schwinn".to_string() };
- let my_bike = Bike { name: "surly".to_string() };
-
- assert!(town_bike != my_bike);
-}
+++ /dev/null
-// Matching against float literals should result in a linter error
-
-#![feature(exclusive_range_pattern)]
-#![feature(half_open_range_patterns)]
-#![allow(unused)]
-#![forbid(illegal_floating_point_literal_pattern)]
-
-fn main() {
- let x = 42.0;
- match x {
- 5.0 => {}, //~ ERROR floating-point types cannot be used in patterns
- //~| WARNING hard error
- 5.0f32 => {}, //~ ERROR floating-point types cannot be used in patterns
- //~| WARNING hard error
- -5.0 => {}, //~ ERROR floating-point types cannot be used in patterns
- //~| WARNING hard error
- 1.0 .. 33.0 => {}, //~ ERROR floating-point types cannot be used in patterns
- //~| WARNING hard error
- //~| ERROR floating-point types cannot be used in patterns
- //~| WARNING hard error
- 39.0 ..= 70.0 => {}, //~ ERROR floating-point types cannot be used in patterns
- //~| ERROR floating-point types cannot be used in patterns
- //~| WARNING hard error
- //~| WARNING hard error
-
- ..71.0 => {}
- //~^ ERROR floating-point types cannot be used in patterns
- //~| WARNING this was previously accepted by the compiler
- ..=72.0 => {}
- //~^ ERROR floating-point types cannot be used in patterns
- //~| WARNING this was previously accepted by the compiler
- 71.0.. => {}
- //~^ ERROR floating-point types cannot be used in patterns
- //~| WARNING this was previously accepted by the compiler
- _ => {},
- };
- let y = 5.0;
- // Same for tuples
- match (x, 5) {
- (3.14, 1) => {}, //~ ERROR floating-point types cannot be used
- //~| WARNING hard error
- _ => {},
- }
- // Or structs
- struct Foo { x: f32 };
- match (Foo { x }) {
- Foo { x: 2.0 } => {}, //~ ERROR floating-point types cannot be used
- //~| WARNING hard error
- _ => {},
- }
-}
+++ /dev/null
-error: floating-point types cannot be used in patterns
- --> $DIR/issue-41255.rs:11:9
- |
-LL | 5.0 => {},
- | ^^^
- |
-note: the lint level is defined here
- --> $DIR/issue-41255.rs:6:11
- |
-LL | #![forbid(illegal_floating_point_literal_pattern)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
-
-error: floating-point types cannot be used in patterns
- --> $DIR/issue-41255.rs:13:9
- |
-LL | 5.0f32 => {},
- | ^^^^^^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
-
-error: floating-point types cannot be used in patterns
- --> $DIR/issue-41255.rs:15:10
- |
-LL | -5.0 => {},
- | ^^^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
-
-error: floating-point types cannot be used in patterns
- --> $DIR/issue-41255.rs:17:9
- |
-LL | 1.0 .. 33.0 => {},
- | ^^^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
-
-error: floating-point types cannot be used in patterns
- --> $DIR/issue-41255.rs:17:16
- |
-LL | 1.0 .. 33.0 => {},
- | ^^^^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
-
-error: floating-point types cannot be used in patterns
- --> $DIR/issue-41255.rs:21:9
- |
-LL | 39.0 ..= 70.0 => {},
- | ^^^^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
-
-error: floating-point types cannot be used in patterns
- --> $DIR/issue-41255.rs:21:18
- |
-LL | 39.0 ..= 70.0 => {},
- | ^^^^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
-
-error: floating-point types cannot be used in patterns
- --> $DIR/issue-41255.rs:26:11
- |
-LL | ..71.0 => {}
- | ^^^^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
-
-error: floating-point types cannot be used in patterns
- --> $DIR/issue-41255.rs:29:12
- |
-LL | ..=72.0 => {}
- | ^^^^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
-
-error: floating-point types cannot be used in patterns
- --> $DIR/issue-41255.rs:32:9
- |
-LL | 71.0.. => {}
- | ^^^^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
-
-error: floating-point types cannot be used in patterns
- --> $DIR/issue-41255.rs:40:10
- |
-LL | (3.14, 1) => {},
- | ^^^^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
-
-error: floating-point types cannot be used in patterns
- --> $DIR/issue-41255.rs:47:18
- |
-LL | Foo { x: 2.0 } => {},
- | ^^^
- |
- = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
- = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
-
-error: aborting due to 12 previous errors
-
+++ /dev/null
-mod foo {
- pub struct Bx(());
-}
-
-mod bar {
- use foo::Bx;
-
- fn foo() {
- Bx(());
- //~^ ERROR cannot initialize a tuple struct which contains private fields [E0423]
- }
-}
-
-mod baz {
- fn foo() {
- Bx(());
- //~^ ERROR cannot find function, tuple struct or tuple variant `Bx` in this scope [E0425]
- }
-}
-
-fn main() {}
+++ /dev/null
-error[E0423]: cannot initialize a tuple struct which contains private fields
- --> $DIR/issue-42944.rs:9:9
- |
-LL | Bx(());
- | ^^
- |
-note: constructor is not visible here due to private fields
- --> $DIR/issue-42944.rs:2:19
- |
-LL | pub struct Bx(());
- | ^^ private field
-
-error[E0425]: cannot find function, tuple struct or tuple variant `Bx` in this scope
- --> $DIR/issue-42944.rs:16:9
- |
-LL | Bx(());
- | ^^ not found in this scope
- |
-help: consider importing this tuple struct
- |
-LL | use foo::Bx;
- |
-
-error: aborting due to 2 previous errors
-
-Some errors have detailed explanations: E0423, E0425.
-For more information about an error, try `rustc --explain E0423`.
LL | fn f<'r, T>(v: &'r T) -> Box<dyn FnMut() -> T + 'r> {
| - captured outer variable
LL | id(Box::new(|| *v))
- | ^^ move occurs because `*v` has type `T`, which does not implement the `Copy` trait
+ | ---^^
+ | | |
+ | | move occurs because `*v` has type `T`, which does not implement the `Copy` trait
+ | captured by this `FnMut` closure
error: aborting due to previous error
+++ /dev/null
-error: unnecessary `unsafe` block
- --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:10:13
- |
-LL | unsafe {
- | ------ because it's nested under this `unsafe` block
-LL | let f = |v: &mut Vec<_>| {
-LL | unsafe {
- | ^^^^^^ unnecessary `unsafe` block
- |
-note: the lint level is defined here
- --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:4:8
- |
-LL | #[deny(unused_unsafe)]
- | ^^^^^^^^^^^^^
-
-error: unnecessary `unsafe` block
- --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:12:38
- |
-LL | unsafe {
- | ------ because it's nested under this `unsafe` block
-...
-LL | |w: &mut Vec<u32>| { unsafe {
- | ^^^^^^ unnecessary `unsafe` block
-
-error: unnecessary `unsafe` block
- --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:16:34
- |
-LL | unsafe {
- | ------ because it's nested under this `unsafe` block
-...
-LL | |x: &mut Vec<u32>| { unsafe {
- | ^^^^^^ unnecessary `unsafe` block
-
-error: aborting due to 3 previous errors
-
+++ /dev/null
-// revisions: mir thir
-// [thir]compile-flags: -Zthir-unsafeck
-
-#[deny(unused_unsafe)]
-fn main() {
- let mut v = Vec::<i32>::with_capacity(24);
-
- unsafe {
- let f = |v: &mut Vec<_>| {
- unsafe { //~ ERROR unnecessary `unsafe`
- v.set_len(24);
- |w: &mut Vec<u32>| { unsafe { //~ ERROR unnecessary `unsafe`
- w.set_len(32);
- } };
- }
- |x: &mut Vec<u32>| { unsafe { //~ ERROR unnecessary `unsafe`
- x.set_len(40);
- } };
- };
-
- v.set_len(0);
- f(&mut v);
- }
-
- |y: &mut Vec<u32>| { unsafe {
- y.set_len(48);
- } };
-}
+++ /dev/null
-error: unnecessary `unsafe` block
- --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:10:13
- |
-LL | unsafe {
- | ------ because it's nested under this `unsafe` block
-LL | let f = |v: &mut Vec<_>| {
-LL | unsafe {
- | ^^^^^^ unnecessary `unsafe` block
- |
-note: the lint level is defined here
- --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:4:8
- |
-LL | #[deny(unused_unsafe)]
- | ^^^^^^^^^^^^^
-
-error: unnecessary `unsafe` block
- --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:12:38
- |
-LL | unsafe {
- | ------ because it's nested under this `unsafe` block
-...
-LL | |w: &mut Vec<u32>| { unsafe {
- | ^^^^^^ unnecessary `unsafe` block
-
-error: unnecessary `unsafe` block
- --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:16:34
- |
-LL | unsafe {
- | ------ because it's nested under this `unsafe` block
-...
-LL | |x: &mut Vec<u32>| { unsafe {
- | ^^^^^^ unnecessary `unsafe` block
-
-error: aborting due to 3 previous errors
-
LL | fn f(&self, _: ()) {
| ------------------ takes 2 distinct arguments
LL | None::<()>.map(Self::f);
- | ^^^^^^^ expected function that takes a single 0-tuple as argument
+ | --- ^^^^^^^ expected function that takes a single 0-tuple as argument
+ | |
+ | required by a bound introduced by this call
error: aborting due to previous error
| ------------------------------------------ takes 2 arguments
...
LL | self.foo.map(Foo::new)
- | ^^^^^^^^ expected function that takes 1 argument
+ | --- ^^^^^^^^ expected function that takes 1 argument
+ | |
+ | required by a bound introduced by this call
error[E0593]: function is expected to take 0 arguments, but it takes 1 argument
--> $DIR/issue-47706.rs:27:9
| -------- takes 1 argument
...
LL | foo(Qux::Bar);
- | ^^^^^^^^ expected function that takes 0 arguments
+ | --- ^^^^^^^^ expected function that takes 0 arguments
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `foo`
--> $DIR/issue-47706.rs:22:8
fn forbidden_narratives() -> Result<isize, ()> {
missing_discourses()?
- //~^ ERROR try expression alternatives have incompatible types
+ //~^ ERROR: `?` operator has incompatible types
}
fn main() {}
-error[E0308]: try expression alternatives have incompatible types
+error[E0308]: `?` operator has incompatible types
--> $DIR/issue-51632-try-desugar-incompatible-types.rs:8:5
|
LL | missing_discourses()?
| ^^^^^^^^^^^^^^^^^^^^^ expected enum `Result`, found `isize`
|
+ = note: `?` operator cannot convert from `isize` to `Result<isize, ()>`
= note: expected enum `Result<isize, ()>`
found type `isize`
help: try removing this `?`
+++ /dev/null
-// build-pass
-
-// This test is the same code as in ui/symbol-names/issue-60925.rs but this checks that the
-// reproduction compiles successfully and doesn't segfault, whereas that test just checks that the
-// symbol mangling fix produces the correct result.
-
-fn dummy() {}
-
-mod llvm {
- pub(crate) struct Foo;
-}
-mod foo {
- pub(crate) struct Foo<T>(T);
-
- impl Foo<::llvm::Foo> {
- pub(crate) fn foo() {
- for _ in 0..0 {
- for _ in &[::dummy()] {
- ::dummy();
- ::dummy();
- ::dummy();
- }
- }
- }
- }
-
- pub(crate) fn foo() {
- Foo::foo();
- Foo::foo();
- }
-}
-
-pub fn foo() {
- foo::foo();
-}
-
-fn main() {}
+++ /dev/null
-#![allow(dead_code)]
-#![deny(unused_variables)]
-
-// This test aims to check that unused variable suggestions update bindings in all
-// match arms.
-
-fn main() {
- enum E {
- A(i32,),
- B(i32,),
- }
-
- match E::A(1) {
- E::A(x) | E::B(x) => {}
- //~^ ERROR unused variable: `x`
- }
-
- enum F {
- A(i32, i32,),
- B(i32, i32,),
- C(i32, i32,),
- }
-
- let _ = match F::A(1, 2) {
- F::A(x, y) | F::B(x, y) => { y },
- //~^ ERROR unused variable: `x`
- F::C(a, b) => { 3 }
- //~^ ERROR unused variable: `a`
- //~^^ ERROR unused variable: `b`
- };
-
- let _ = if let F::A(x, y) | F::B(x, y) = F::A(1, 2) {
- //~^ ERROR unused variable: `x`
- y
- } else {
- 3
- };
-
- while let F::A(x, y) | F::B(x, y) = F::A(1, 2) {
- //~^ ERROR unused variable: `x`
- let _ = y;
- break;
- }
-}
+++ /dev/null
-error: unused variable: `x`
- --> $DIR/issue-56685.rs:14:14
- |
-LL | E::A(x) | E::B(x) => {}
- | ^ ^
- |
-note: the lint level is defined here
- --> $DIR/issue-56685.rs:2:9
- |
-LL | #![deny(unused_variables)]
- | ^^^^^^^^^^^^^^^^
-help: if this is intentional, prefix it with an underscore
- |
-LL | E::A(_x) | E::B(_x) => {}
- | ~~ ~~
-
-error: unused variable: `x`
- --> $DIR/issue-56685.rs:25:14
- |
-LL | F::A(x, y) | F::B(x, y) => { y },
- | ^ ^
- |
-help: if this is intentional, prefix it with an underscore
- |
-LL | F::A(_x, y) | F::B(_x, y) => { y },
- | ~~ ~~
-
-error: unused variable: `a`
- --> $DIR/issue-56685.rs:27:14
- |
-LL | F::C(a, b) => { 3 }
- | ^ help: if this is intentional, prefix it with an underscore: `_a`
-
-error: unused variable: `b`
- --> $DIR/issue-56685.rs:27:17
- |
-LL | F::C(a, b) => { 3 }
- | ^ help: if this is intentional, prefix it with an underscore: `_b`
-
-error: unused variable: `x`
- --> $DIR/issue-56685.rs:32:25
- |
-LL | let _ = if let F::A(x, y) | F::B(x, y) = F::A(1, 2) {
- | ^ ^
- |
-help: if this is intentional, prefix it with an underscore
- |
-LL | let _ = if let F::A(_x, y) | F::B(_x, y) = F::A(1, 2) {
- | ~~ ~~
-
-error: unused variable: `x`
- --> $DIR/issue-56685.rs:39:20
- |
-LL | while let F::A(x, y) | F::B(x, y) = F::A(1, 2) {
- | ^ ^
- |
-help: if this is intentional, prefix it with an underscore
- |
-LL | while let F::A(_x, y) | F::B(_x, y) = F::A(1, 2) {
- | ~~ ~~
-
-error: aborting due to 6 previous errors
-
+++ /dev/null
-// check-pass
-
-// Tests that the `unreachable_pub` lint doesn't fire for `pub self::imp::f`.
-
-#![deny(unreachable_pub)]
-
-mod m {
- mod imp {
- pub fn f() {}
- }
-
- pub use self::imp::f;
-}
-
-pub use self::m::f;
-
-fn main() {}
+++ /dev/null
-// run-pass
-#![allow(dead_code)]
-#![warn(clashing_extern_declarations)]
-// pretty-expanded FIXME #23616
-
-extern "C" {
- #[link_name = "malloc"]
- fn malloc1(len: i32) -> *const u8;
- #[link_name = "malloc"]
- //~^ WARN `malloc2` redeclares `malloc` with a different signature
- fn malloc2(len: i32, foo: i32) -> *const u8;
-}
-
-pub fn main() {}
+++ /dev/null
-warning: `malloc2` redeclares `malloc` with a different signature
- --> $DIR/issue-5791.rs:9:5
- |
-LL | / #[link_name = "malloc"]
-LL | | fn malloc1(len: i32) -> *const u8;
- | |______________________________________- `malloc` previously declared here
-LL | / #[link_name = "malloc"]
-LL | |
-LL | | fn malloc2(len: i32, foo: i32) -> *const u8;
- | |________________________________________________^ this signature doesn't match the previous declaration
- |
-note: the lint level is defined here
- --> $DIR/issue-5791.rs:3:9
- |
-LL | #![warn(clashing_extern_declarations)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- = note: expected `unsafe extern "C" fn(i32) -> *const u8`
- found `unsafe extern "C" fn(i32, i32) -> *const u8`
-
-warning: 1 warning emitted
-
--> $DIR/issue-59494.rs:21:22
|
LL | let t8 = t8n(t7, t7p(f, g));
- | ^^^^^^^^^ expected an `Fn<(_,)>` closure, found `impl Fn<(((_, _), _),)>`
+ | --- ^^^^^^^^^ expected an `Fn<(_,)>` closure, found `impl Fn<(((_, _), _),)>`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Fn<(_,)>` is not implemented for `impl Fn<(((_, _), _),)>`
note: required by a bound in `t8n`
error[E0277]: the trait bound `&u32: Foo` is not satisfied
- --> $DIR/issue-60218.rs:18:5
+ --> $DIR/issue-60218.rs:18:27
|
LL | trigger_error(vec![], |x: &u32| x)
- | ^^^^^^^^^^^^^ the trait `Foo` is not implemented for `&u32`
+ | ------------- ^^^^^^^^^^^ the trait `Foo` is not implemented for `&u32`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `trigger_error`
--> $DIR/issue-60218.rs:13:72
--> $DIR/issue-60283.rs:17:13
|
LL | foo((), drop)
- | ^^^^
- | |
- | expected signature of `for<'a> fn(<() as Trait<'a>>::Item) -> _`
- | found signature of `fn(()) -> _`
+ | --- ^^^^
+ | | |
+ | | expected signature of `for<'a> fn(<() as Trait<'a>>::Item) -> _`
+ | | found signature of `fn(()) -> _`
+ | required by a bound introduced by this call
|
note: required by a bound in `foo`
--> $DIR/issue-60283.rs:12:16
--> $DIR/issue-60283.rs:17:13
|
LL | foo((), drop)
- | ^^^^ doesn't have a size known at compile-time
+ | --- ^^^^ doesn't have a size known at compile-time
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Sized` is not implemented for `<() as Trait<'_>>::Item`
note: required by a bound in `std::mem::drop`
--> $DIR/issue-66353.rs:12:41
|
LL | _Func::< <() as _A>::AssocT >::func(());
- | ^^ the trait `_Func<_>` is not implemented for `()`
+ | ----------------------------------- ^^ the trait `_Func<_>` is not implemented for `()`
+ | |
+ | required by a bound introduced by this call
|
note: required by `_Func::func`
--> $DIR/issue-66353.rs:4:5
+++ /dev/null
-// compile-flags:-Zpolymorphize=on
-// build-pass
-
-fn test<T>() {
- std::mem::size_of::<T>();
-}
-
-pub fn foo<T>(_: T) -> &'static fn() {
- &(test::<T> as fn())
-}
-
-fn outer<T>() {
- foo(|| ());
-}
-
-fn main() {
- outer::<u8>();
-}
+++ /dev/null
-fn server() -> impl {
-//~^ ERROR at least one trait must be specified
- ().map2(|| "")
-}
-
-trait FilterBase2 {
- fn map2<F>(self, f: F) -> Map2<F> {}
- //~^ ERROR mismatched types
- //~^^ ERROR the size for values of type `Self` cannot be known at compilation time
-}
-
-struct Map2<Segment2> {
- _func: F,
- //~^ ERROR cannot find type `F` in this scope
-}
-
-impl<F> FilterBase2 for F {}
-
-fn main() {}
+++ /dev/null
-error: at least one trait must be specified
- --> $DIR/issue-78720.rs:1:16
- |
-LL | fn server() -> impl {
- | ^^^^
-
-error[E0412]: cannot find type `F` in this scope
- --> $DIR/issue-78720.rs:13:12
- |
-LL | _func: F,
- | ^
- |
- ::: $SRC_DIR/core/src/ops/function.rs:LL:COL
- |
-LL | pub trait Fn<Args>: FnMut<Args> {
- | ------------------------------- similarly named trait `Fn` defined here
- |
-help: a trait with a similar name exists
- |
-LL | _func: Fn,
- | ~~
-help: you might be missing a type parameter
- |
-LL | struct Map2<Segment2, F> {
- | +++
-
-error[E0308]: mismatched types
- --> $DIR/issue-78720.rs:7:39
- |
-LL | fn map2<F>(self, f: F) -> Map2<F> {}
- | ^^ expected struct `Map2`, found `()`
- |
- = note: expected struct `Map2<F>`
- found unit type `()`
-
-error[E0277]: the size for values of type `Self` cannot be known at compilation time
- --> $DIR/issue-78720.rs:7:16
- |
-LL | fn map2<F>(self, f: F) -> Map2<F> {}
- | ^^^^ doesn't have a size known at compile-time
- |
- = help: unsized fn params are gated as an unstable feature
-help: consider further restricting `Self`
- |
-LL | fn map2<F>(self, f: F) -> Map2<F> where Self: Sized {}
- | +++++++++++++++++
-help: function arguments must have a statically known size, borrowed types always have a known size
- |
-LL | fn map2<F>(&self, f: F) -> Map2<F> {}
- | +
-
-error: aborting due to 4 previous errors
-
-Some errors have detailed explanations: E0277, E0308, E0412.
-For more information about an error, try `rustc --explain E0277`.
+++ /dev/null
-mod foo {
- pub struct Pub { private: () }
-
- pub enum Enum {
- Variant { x: (), y: () },
- Other
- }
-
- fn correct() {
- Pub {};
- //~^ ERROR missing field `private` in initializer of `Pub`
- Enum::Variant { x: () };
- //~^ ERROR missing field `y` in initializer of `Enum`
- }
-}
-
-fn correct() {
- foo::Pub {};
- //~^ ERROR cannot construct `Pub` with struct literal syntax due to inaccessible fields
-}
-
-fn wrong() {
- foo::Enum::Variant { x: () };
- //~^ ERROR missing field `y` in initializer of `Enum`
- foo::Enum::Variant { };
- //~^ ERROR missing fields `x` and `y` in initializer of `Enum`
-}
-
-fn main() {}
+++ /dev/null
-error[E0063]: missing field `private` in initializer of `Pub`
- --> $DIR/issue-79593.rs:10:9
- |
-LL | Pub {};
- | ^^^ missing `private`
-
-error[E0063]: missing field `y` in initializer of `Enum`
- --> $DIR/issue-79593.rs:12:9
- |
-LL | Enum::Variant { x: () };
- | ^^^^^^^^^^^^^ missing `y`
-
-error: cannot construct `Pub` with struct literal syntax due to inaccessible fields
- --> $DIR/issue-79593.rs:18:5
- |
-LL | foo::Pub {};
- | ^^^^^^^^
-
-error[E0063]: missing field `y` in initializer of `Enum`
- --> $DIR/issue-79593.rs:23:5
- |
-LL | foo::Enum::Variant { x: () };
- | ^^^^^^^^^^^^^^^^^^ missing `y`
-
-error[E0063]: missing fields `x` and `y` in initializer of `Enum`
- --> $DIR/issue-79593.rs:25:5
- |
-LL | foo::Enum::Variant { };
- | ^^^^^^^^^^^^^^^^^^ missing `x` and `y`
-
-error: aborting due to 5 previous errors
-
-For more information about this error, try `rustc --explain E0063`.
+++ /dev/null
-fn main() {
- let elem = 6i8;
- let e2 = 230;
- //~^ ERROR literal out of range for `i8`
- //~| HELP consider using the type `u8` instead
-
- let mut vec = Vec::new();
-
- vec.push(e2);
- vec.push(elem);
-
- println!("{:?}", vec);
-}
+++ /dev/null
-error: literal out of range for `i8`
- --> $DIR/issue-79744.rs:3:14
- |
-LL | let e2 = 230;
- | ^^^
- |
- = note: `#[deny(overflowing_literals)]` on by default
- = note: the literal `230` does not fit into the type `i8` whose range is `-128..=127`
- = help: consider using the type `u8` instead
-
-error: aborting due to previous error
-
--> $DIR/issue-87199.rs:18:22
|
LL | ref_arg::<[i32]>(&[5]);
- | ^^^^ doesn't have a size known at compile-time
+ | ---------------- ^^^^ doesn't have a size known at compile-time
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Sized` is not implemented for `[i32]`
note: required by a bound in `ref_arg`
+++ /dev/null
-trait Foo {
- type T;
- fn foo(&self, t: Self::T);
-//~^ NOTE expected 0 type parameters
-}
-
-impl Foo for u32 {
- type T = ();
-
- fn foo(&self, t: impl Clone) {}
-//~^ ERROR method `foo` has 1 type parameter but its trait declaration has 0 type parameters
-//~| NOTE found 1 type parameter
-//~| NOTE `impl Trait` introduces an implicit type parameter
-}
-
-fn main() {}
+++ /dev/null
-error[E0049]: method `foo` has 1 type parameter but its trait declaration has 0 type parameters
- --> $DIR/type-arg-mismatch-due-to-impl-trait.rs:10:22
- |
-LL | fn foo(&self, t: Self::T);
- | - expected 0 type parameters
-...
-LL | fn foo(&self, t: impl Clone) {}
- | ^^^^^^^^^^
- | |
- | found 1 type parameter
- | `impl Trait` introduces an implicit type parameter
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0049`.
--> $DIR/kindck-impl-type-params-2.rs:13:16
|
LL | take_param(&x);
- | ^^ the trait `Copy` is not implemented for `Box<{integer}>`
+ | ---------- ^^ the trait `Copy` is not implemented for `Box<{integer}>`
+ | |
+ | required by a bound introduced by this call
|
note: required because of the requirements on the impl of `Foo` for `Box<{integer}>`
--> $DIR/kindck-impl-type-params-2.rs:6:14
--> $DIR/kindck-inherited-copy-bound.rs:21:16
|
LL | take_param(&x);
- | ^^ the trait `Copy` is not implemented for `Box<{integer}>`
+ | ---------- ^^ the trait `Copy` is not implemented for `Box<{integer}>`
+ | |
+ | required by a bound introduced by this call
|
note: required because of the requirements on the impl of `Foo` for `Box<{integer}>`
--> $DIR/kindck-inherited-copy-bound.rs:14:14
--> $DIR/kindck-inherited-copy-bound.rs:21:16
|
LL | take_param(&x);
- | ^^ the trait `Copy` is not implemented for `Box<{integer}>`
+ | ---------- ^^ the trait `Copy` is not implemented for `Box<{integer}>`
+ | |
+ | required by a bound introduced by this call
|
note: required because of the requirements on the impl of `Foo` for `Box<{integer}>`
--> $DIR/kindck-inherited-copy-bound.rs:14:14
--- /dev/null
+// Test that enabling an unstable feature disables warnings
+
+// aux-build:stability-cfg2.rs
+
+#![feature(unstable_test_feature)]
+#![deny(non_snake_case)] // To trigger a hard error
+
+// Shouldn't generate a warning about unstable features
+extern crate stability_cfg2;
+
+pub fn BOGUS() { } //~ ERROR
+
+pub fn main() { }
--- /dev/null
+error: function `BOGUS` should have a snake case name
+ --> $DIR/enable-unstable-lib-feature.rs:11:8
+ |
+LL | pub fn BOGUS() { }
+ | ^^^^^ help: convert the identifier to snake case: `bogus`
+ |
+note: the lint level is defined here
+ --> $DIR/enable-unstable-lib-feature.rs:6:9
+ |
+LL | #![deny(non_snake_case)] // To trigger a hard error
+ | ^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// check-pass
+
+// Tests that the `unreachable_pub` lint doesn't fire for `pub self::imp::f`.
+
+#![deny(unreachable_pub)]
+
+mod m {
+ mod imp {
+ pub fn f() {}
+ }
+
+ pub use self::imp::f;
+}
+
+pub use self::m::f;
+
+fn main() {}
--- /dev/null
+fn main() {
+ let elem = 6i8;
+ let e2 = 230;
+ //~^ ERROR literal out of range for `i8`
+ //~| HELP consider using the type `u8` instead
+
+ let mut vec = Vec::new();
+
+ vec.push(e2);
+ vec.push(elem);
+
+ println!("{:?}", vec);
+}
--- /dev/null
+error: literal out of range for `i8`
+ --> $DIR/issue-79744.rs:3:14
+ |
+LL | let e2 = 230;
+ | ^^^
+ |
+ = note: `#[deny(overflowing_literals)]` on by default
+ = note: the literal `230` does not fit into the type `i8` whose range is `-128..=127`
+ = help: consider using the type `u8` instead
+
+error: aborting due to previous error
+
--- /dev/null
+// build-fail
+// ignore-emscripten no llvm_asm! support
+
+#![feature(llvm_asm)]
+#![allow(deprecated)] // llvm_asm!
+
+fn main() {
+ unsafe {
+ llvm_asm!("" :: "r"(""));
+ //~^ ERROR: invalid value for constraint in inline assembly
+ }
+}
--- /dev/null
+error[E0669]: invalid value for constraint in inline assembly
+ --> $DIR/issue-37433.rs:9:29
+ |
+LL | llvm_asm!("" :: "r"(""));
+ | ^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0669`.
--- /dev/null
+#[macro_export]
+macro_rules! define_macro {
+ ($i:ident) => {
+ macro_rules! $i { () => {} }
+ }
+}
--- /dev/null
+// aux-build:define-macro.rs
+
+macro_rules! bar { () => {} }
+define_macro!(bar);
+bar!(); //~ ERROR `bar` is ambiguous
+
+macro_rules! m { () => { #[macro_use] extern crate define_macro; } }
+m!();
+
+fn main() {}
--- /dev/null
+error[E0659]: `bar` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
+ --> $DIR/out-of-order-shadowing.rs:5:1
+ |
+LL | bar!();
+ | ^^^ ambiguous name
+ |
+note: `bar` could refer to the macro defined here
+ --> $DIR/out-of-order-shadowing.rs:4:1
+ |
+LL | define_macro!(bar);
+ | ^^^^^^^^^^^^^^^^^^^
+note: `bar` could also refer to the macro defined here
+ --> $DIR/out-of-order-shadowing.rs:3:1
+ |
+LL | macro_rules! bar { () => {} }
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = note: this error originates in the macro `define_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0659`.
--- /dev/null
+// run-pass
+
+#![allow(non_shorthand_field_patterns)]
+
+#[derive(Copy, Clone)]
+struct Pair { x: isize, y: isize }
+
+pub fn main() {
+ let a: isize =
+ match 10 { x if x < 7 => { 1 } x if x < 11 => { 2 } 10 => { 3 } _ => { 4 } };
+ assert_eq!(a, 2);
+
+ let b: isize =
+ match (Pair {x: 10, y: 20}) {
+ x if x.x < 5 && x.y < 5 => { 1 }
+ Pair {x: x, y: y} if x == 10 && y == 20 => { 2 }
+ Pair {x: _x, y: _y} => { 3 }
+ };
+ assert_eq!(b, 2);
+}
--- /dev/null
+// run-pass
+#![allow(unused_variables)]
+pub fn main() {
+ let x = (0, 2);
+
+ match x {
+ (0, ref y) => {}
+ (y, 0) => {}
+ _ => (),
+ }
+}
--- /dev/null
+// Matching against float literals should result in a linter error
+
+#![feature(exclusive_range_pattern)]
+#![feature(half_open_range_patterns)]
+#![allow(unused)]
+#![forbid(illegal_floating_point_literal_pattern)]
+
+fn main() {
+ let x = 42.0;
+ match x {
+ 5.0 => {}, //~ ERROR floating-point types cannot be used in patterns
+ //~| WARNING hard error
+ 5.0f32 => {}, //~ ERROR floating-point types cannot be used in patterns
+ //~| WARNING hard error
+ -5.0 => {}, //~ ERROR floating-point types cannot be used in patterns
+ //~| WARNING hard error
+ 1.0 .. 33.0 => {}, //~ ERROR floating-point types cannot be used in patterns
+ //~| WARNING hard error
+ //~| ERROR floating-point types cannot be used in patterns
+ //~| WARNING hard error
+ 39.0 ..= 70.0 => {}, //~ ERROR floating-point types cannot be used in patterns
+ //~| ERROR floating-point types cannot be used in patterns
+ //~| WARNING hard error
+ //~| WARNING hard error
+
+ ..71.0 => {}
+ //~^ ERROR floating-point types cannot be used in patterns
+ //~| WARNING this was previously accepted by the compiler
+ ..=72.0 => {}
+ //~^ ERROR floating-point types cannot be used in patterns
+ //~| WARNING this was previously accepted by the compiler
+ 71.0.. => {}
+ //~^ ERROR floating-point types cannot be used in patterns
+ //~| WARNING this was previously accepted by the compiler
+ _ => {},
+ };
+ let y = 5.0;
+ // Same for tuples
+ match (x, 5) {
+ (3.14, 1) => {}, //~ ERROR floating-point types cannot be used
+ //~| WARNING hard error
+ _ => {},
+ }
+ // Or structs
+ struct Foo { x: f32 };
+ match (Foo { x }) {
+ Foo { x: 2.0 } => {}, //~ ERROR floating-point types cannot be used
+ //~| WARNING hard error
+ _ => {},
+ }
+}
--- /dev/null
+error: floating-point types cannot be used in patterns
+ --> $DIR/issue-41255.rs:11:9
+ |
+LL | 5.0 => {},
+ | ^^^
+ |
+note: the lint level is defined here
+ --> $DIR/issue-41255.rs:6:11
+ |
+LL | #![forbid(illegal_floating_point_literal_pattern)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
+
+error: floating-point types cannot be used in patterns
+ --> $DIR/issue-41255.rs:13:9
+ |
+LL | 5.0f32 => {},
+ | ^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
+
+error: floating-point types cannot be used in patterns
+ --> $DIR/issue-41255.rs:15:10
+ |
+LL | -5.0 => {},
+ | ^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
+
+error: floating-point types cannot be used in patterns
+ --> $DIR/issue-41255.rs:17:9
+ |
+LL | 1.0 .. 33.0 => {},
+ | ^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
+
+error: floating-point types cannot be used in patterns
+ --> $DIR/issue-41255.rs:17:16
+ |
+LL | 1.0 .. 33.0 => {},
+ | ^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
+
+error: floating-point types cannot be used in patterns
+ --> $DIR/issue-41255.rs:21:9
+ |
+LL | 39.0 ..= 70.0 => {},
+ | ^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
+
+error: floating-point types cannot be used in patterns
+ --> $DIR/issue-41255.rs:21:18
+ |
+LL | 39.0 ..= 70.0 => {},
+ | ^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
+
+error: floating-point types cannot be used in patterns
+ --> $DIR/issue-41255.rs:26:11
+ |
+LL | ..71.0 => {}
+ | ^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
+
+error: floating-point types cannot be used in patterns
+ --> $DIR/issue-41255.rs:29:12
+ |
+LL | ..=72.0 => {}
+ | ^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
+
+error: floating-point types cannot be used in patterns
+ --> $DIR/issue-41255.rs:32:9
+ |
+LL | 71.0.. => {}
+ | ^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
+
+error: floating-point types cannot be used in patterns
+ --> $DIR/issue-41255.rs:40:10
+ |
+LL | (3.14, 1) => {},
+ | ^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
+
+error: floating-point types cannot be used in patterns
+ --> $DIR/issue-41255.rs:47:18
+ |
+LL | Foo { x: 2.0 } => {},
+ | ^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
+
+error: aborting due to 12 previous errors
+
--- /dev/null
+#![allow(dead_code)]
+#![deny(unused_variables)]
+
+// This test aims to check that unused variable suggestions update bindings in all
+// match arms.
+
+fn main() {
+ enum E {
+ A(i32,),
+ B(i32,),
+ }
+
+ match E::A(1) {
+ E::A(x) | E::B(x) => {}
+ //~^ ERROR unused variable: `x`
+ }
+
+ enum F {
+ A(i32, i32,),
+ B(i32, i32,),
+ C(i32, i32,),
+ }
+
+ let _ = match F::A(1, 2) {
+ F::A(x, y) | F::B(x, y) => { y },
+ //~^ ERROR unused variable: `x`
+ F::C(a, b) => { 3 }
+ //~^ ERROR unused variable: `a`
+ //~^^ ERROR unused variable: `b`
+ };
+
+ let _ = if let F::A(x, y) | F::B(x, y) = F::A(1, 2) {
+ //~^ ERROR unused variable: `x`
+ y
+ } else {
+ 3
+ };
+
+ while let F::A(x, y) | F::B(x, y) = F::A(1, 2) {
+ //~^ ERROR unused variable: `x`
+ let _ = y;
+ break;
+ }
+}
--- /dev/null
+error: unused variable: `x`
+ --> $DIR/issue-56685.rs:14:14
+ |
+LL | E::A(x) | E::B(x) => {}
+ | ^ ^
+ |
+note: the lint level is defined here
+ --> $DIR/issue-56685.rs:2:9
+ |
+LL | #![deny(unused_variables)]
+ | ^^^^^^^^^^^^^^^^
+help: if this is intentional, prefix it with an underscore
+ |
+LL | E::A(_x) | E::B(_x) => {}
+ | ~~ ~~
+
+error: unused variable: `x`
+ --> $DIR/issue-56685.rs:25:14
+ |
+LL | F::A(x, y) | F::B(x, y) => { y },
+ | ^ ^
+ |
+help: if this is intentional, prefix it with an underscore
+ |
+LL | F::A(_x, y) | F::B(_x, y) => { y },
+ | ~~ ~~
+
+error: unused variable: `a`
+ --> $DIR/issue-56685.rs:27:14
+ |
+LL | F::C(a, b) => { 3 }
+ | ^ help: if this is intentional, prefix it with an underscore: `_a`
+
+error: unused variable: `b`
+ --> $DIR/issue-56685.rs:27:17
+ |
+LL | F::C(a, b) => { 3 }
+ | ^ help: if this is intentional, prefix it with an underscore: `_b`
+
+error: unused variable: `x`
+ --> $DIR/issue-56685.rs:32:25
+ |
+LL | let _ = if let F::A(x, y) | F::B(x, y) = F::A(1, 2) {
+ | ^ ^
+ |
+help: if this is intentional, prefix it with an underscore
+ |
+LL | let _ = if let F::A(_x, y) | F::B(_x, y) = F::A(1, 2) {
+ | ~~ ~~
+
+error: unused variable: `x`
+ --> $DIR/issue-56685.rs:39:20
+ |
+LL | while let F::A(x, y) | F::B(x, y) = F::A(1, 2) {
+ | ^ ^
+ |
+help: if this is intentional, prefix it with an underscore
+ |
+LL | while let F::A(_x, y) | F::B(_x, y) = F::A(1, 2) {
+ | ~~ ~~
+
+error: aborting due to 6 previous errors
+
+++ /dev/null
-// run-pass
-
-#![allow(dead_code)]
-// pretty-expanded FIXME #23616
-
-struct S<T> {
- contents: T,
-}
-
-impl<T> S<T> {
- fn new<U>(x: T, _: U) -> S<T> {
- S {
- contents: x,
- }
- }
-}
-
-trait Trait<T> {
- fn new<U>(x: T, y: U) -> Self;
-}
-
-struct S2 {
- contents: isize,
-}
-
-impl Trait<isize> for S2 {
- fn new<U>(x: isize, _: U) -> S2 {
- S2 {
- contents: x,
- }
- }
-}
-
-pub fn main() {
- let _ = S::<isize>::new::<f64>(1, 1.0);
- let _: S2 = Trait::<isize>::new::<f64>(1, 1.0);
-}
--- /dev/null
+// Regression test for #88972. Used to cause a query cycle:
+// optimized mir -> remove zsts -> layout of a generator -> optimized mir.
+//
+// edition:2018
+// compile-flags: --crate-type=lib
+// build-pass
+
+pub async fn listen() -> Result<(), std::io::Error> {
+ let f = do_async();
+ std::mem::forget(f);
+ Ok(())
+}
+
+pub async fn do_async() {
+ listen().await.unwrap()
+}
| ------------ found signature of `fn(u64) -> _`
...
LL | foo(f);
- | ^ expected signature of `fn(usize) -> _`
+ | --- ^ expected signature of `fn(usize) -> _`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `foo`
--> $DIR/E0631.rs:3:11
| ------------ found signature of `fn(u64) -> _`
...
LL | bar(f);
- | ^ expected signature of `fn(usize) -> _`
+ | --- ^ expected signature of `fn(usize) -> _`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `bar`
--> $DIR/E0631.rs:4:11
--> $DIR/closure-arg-count.rs:24:57
|
LL | let _it = vec![1, 2, 3].into_iter().enumerate().map(foo);
- | ^^^ expected function that takes a single 2-tuple as argument
+ | --- ^^^ expected function that takes a single 2-tuple as argument
+ | |
+ | required by a bound introduced by this call
...
LL | fn foo() {}
| -------- takes 0 arguments
LL | let bar = |i, x, y| i;
| --------- takes 3 distinct arguments
LL | let _it = vec![1, 2, 3].into_iter().enumerate().map(bar);
- | ^^^ expected closure that takes a single 2-tuple as argument
+ | --- ^^^ expected closure that takes a single 2-tuple as argument
+ | |
+ | required by a bound introduced by this call
error[E0593]: function is expected to take a single 2-tuple as argument, but it takes 2 distinct arguments
--> $DIR/closure-arg-count.rs:29:57
|
LL | let _it = vec![1, 2, 3].into_iter().enumerate().map(qux);
- | ^^^ expected function that takes a single 2-tuple as argument
+ | --- ^^^ expected function that takes a single 2-tuple as argument
+ | |
+ | required by a bound introduced by this call
...
LL | fn qux(x: usize, y: usize) {}
| -------------------------- takes 2 distinct arguments
--> $DIR/closure-arg-count.rs:32:45
|
LL | let _it = vec![1, 2, 3].into_iter().map(usize::checked_add);
- | ^^^^^^^^^^^^^^^^^^ expected function that takes 1 argument
+ | --- ^^^^^^^^^^^^^^^^^^ expected function that takes 1 argument
+ | |
+ | required by a bound introduced by this call
error[E0593]: function is expected to take 0 arguments, but it takes 1 argument
--> $DIR/closure-arg-count.rs:35:10
|
LL | call(Foo);
- | ^^^ expected function that takes 0 arguments
+ | ---- ^^^ expected function that takes 0 arguments
+ | |
+ | required by a bound introduced by this call
...
LL | struct Foo(u8);
| --------------- takes 1 argument
| --------------------------- found signature of `for<'r> fn(&'r mut isize) -> _`
...
LL | apply(&3, takes_mut);
- | ^^^^^^^^^ expected signature of `fn(&{integer}) -> _`
+ | ----- ^^^^^^^^^ expected signature of `fn(&{integer}) -> _`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `apply`
--> $DIR/fn-variance-1.rs:5:37
| ----------------------- found signature of `for<'r> fn(&'r isize) -> _`
...
LL | apply(&mut 3, takes_imm);
- | ^^^^^^^^^ expected signature of `fn(&mut {integer}) -> _`
+ | ----- ^^^^^^^^^ expected signature of `fn(&mut {integer}) -> _`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `apply`
--> $DIR/fn-variance-1.rs:5:37
let z = call_it(3, f);
//~^ ERROR type mismatch
//~| NOTE expected signature of `fn(isize, isize) -> _`
+ //~| NOTE required by a bound introduced by this call
println!("{}", z);
}
| ----------------------------- found signature of `fn(usize, isize) -> _`
LL |
LL | let z = call_it(3, f);
- | ^ expected signature of `fn(isize, isize) -> _`
+ | ------- ^ expected signature of `fn(isize, isize) -> _`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `call_it`
--> $DIR/unboxed-closures-vtable-mismatch.rs:7:14
LL | let i = box 3;
| - captured outer variable
LL | let _f = to_fn(|| test(i));
- | ^ move occurs because `i` has type `Box<usize>`, which does not implement the `Copy` trait
+ | --------^-
+ | | |
+ | | move occurs because `i` has type `Box<usize>`, which does not implement the `Copy` trait
+ | captured by this `Fn` closure
error: aborting due to previous error
--> $DIR/mutexguard-sync.rs:11:15
|
LL | test_sync(guard);
- | ^^^^^ `Cell<i32>` cannot be shared between threads safely
+ | --------- ^^^^^ `Cell<i32>` cannot be shared between threads safely
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Sync` is not implemented for `Cell<i32>`
= note: required because of the requirements on the impl of `Sync` for `MutexGuard<'_, Cell<i32>>`
--> $DIR/namespace-mix.rs:33:11
|
LL | check(m1::S{});
- | ^^^^^^^ the trait `Impossible` is not implemented for `c::Item`
+ | ----- ^^^^^^^ the trait `Impossible` is not implemented for `c::Item`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:35:11
|
LL | check(m2::S{});
- | ^^^^^^^ the trait `Impossible` is not implemented for `c::S`
+ | ----- ^^^^^^^ the trait `Impossible` is not implemented for `c::S`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:36:11
|
LL | check(m2::S);
- | ^^^^^ the trait `Impossible` is not implemented for `c::Item`
+ | ----- ^^^^^ the trait `Impossible` is not implemented for `c::Item`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:39:11
|
LL | check(xm1::S{});
- | ^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item`
+ | ----- ^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:41:11
|
LL | check(xm2::S{});
- | ^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::S`
+ | ----- ^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::S`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:42:11
|
LL | check(xm2::S);
- | ^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item`
+ | ----- ^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:55:11
|
LL | check(m3::TS{});
- | ^^^^^^^^ the trait `Impossible` is not implemented for `c::Item`
+ | ----- ^^^^^^^^ the trait `Impossible` is not implemented for `c::Item`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:56:11
|
LL | check(m3::TS);
- | ^^^^^^ the trait `Impossible` is not implemented for `fn() -> c::TS {c::TS}`
+ | ----- ^^^^^^ the trait `Impossible` is not implemented for `fn() -> c::TS {c::TS}`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:57:11
|
LL | check(m4::TS{});
- | ^^^^^^^^ the trait `Impossible` is not implemented for `c::TS`
+ | ----- ^^^^^^^^ the trait `Impossible` is not implemented for `c::TS`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:58:11
|
LL | check(m4::TS);
- | ^^^^^^ the trait `Impossible` is not implemented for `c::Item`
+ | ----- ^^^^^^ the trait `Impossible` is not implemented for `c::Item`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:61:11
|
LL | check(xm3::TS{});
- | ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item`
+ | ----- ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:62:11
|
LL | check(xm3::TS);
- | ^^^^^^^ the trait `Impossible` is not implemented for `fn() -> namespace_mix::c::TS {namespace_mix::c::TS}`
+ | ----- ^^^^^^^ the trait `Impossible` is not implemented for `fn() -> namespace_mix::c::TS {namespace_mix::c::TS}`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:63:11
|
LL | check(xm4::TS{});
- | ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::TS`
+ | ----- ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::TS`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:64:11
|
LL | check(xm4::TS);
- | ^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item`
+ | ----- ^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:77:11
|
LL | check(m5::US{});
- | ^^^^^^^^ the trait `Impossible` is not implemented for `c::Item`
+ | ----- ^^^^^^^^ the trait `Impossible` is not implemented for `c::Item`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:78:11
|
LL | check(m5::US);
- | ^^^^^^ the trait `Impossible` is not implemented for `c::US`
+ | ----- ^^^^^^ the trait `Impossible` is not implemented for `c::US`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:79:11
|
LL | check(m6::US{});
- | ^^^^^^^^ the trait `Impossible` is not implemented for `c::US`
+ | ----- ^^^^^^^^ the trait `Impossible` is not implemented for `c::US`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:80:11
|
LL | check(m6::US);
- | ^^^^^^ the trait `Impossible` is not implemented for `c::Item`
+ | ----- ^^^^^^ the trait `Impossible` is not implemented for `c::Item`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:83:11
|
LL | check(xm5::US{});
- | ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item`
+ | ----- ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:84:11
|
LL | check(xm5::US);
- | ^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::US`
+ | ----- ^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::US`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:85:11
|
LL | check(xm6::US{});
- | ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::US`
+ | ----- ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::US`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:86:11
|
LL | check(xm6::US);
- | ^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item`
+ | ----- ^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:99:11
|
LL | check(m7::V{});
- | ^^^^^^^ the trait `Impossible` is not implemented for `c::Item`
+ | ----- ^^^^^^^ the trait `Impossible` is not implemented for `c::Item`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:101:11
|
LL | check(m8::V{});
- | ^^^^^^^ the trait `Impossible` is not implemented for `c::E`
+ | ----- ^^^^^^^ the trait `Impossible` is not implemented for `c::E`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:102:11
|
LL | check(m8::V);
- | ^^^^^ the trait `Impossible` is not implemented for `c::Item`
+ | ----- ^^^^^ the trait `Impossible` is not implemented for `c::Item`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:105:11
|
LL | check(xm7::V{});
- | ^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item`
+ | ----- ^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:107:11
|
LL | check(xm8::V{});
- | ^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::E`
+ | ----- ^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::E`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:108:11
|
LL | check(xm8::V);
- | ^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item`
+ | ----- ^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:121:11
|
LL | check(m9::TV{});
- | ^^^^^^^^ the trait `Impossible` is not implemented for `c::Item`
+ | ----- ^^^^^^^^ the trait `Impossible` is not implemented for `c::Item`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:122:11
|
LL | check(m9::TV);
- | ^^^^^^ the trait `Impossible` is not implemented for `fn() -> c::E {c::E::TV}`
+ | ----- ^^^^^^ the trait `Impossible` is not implemented for `fn() -> c::E {c::E::TV}`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:123:11
|
LL | check(mA::TV{});
- | ^^^^^^^^ the trait `Impossible` is not implemented for `c::E`
+ | ----- ^^^^^^^^ the trait `Impossible` is not implemented for `c::E`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:124:11
|
LL | check(mA::TV);
- | ^^^^^^ the trait `Impossible` is not implemented for `c::Item`
+ | ----- ^^^^^^ the trait `Impossible` is not implemented for `c::Item`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:127:11
|
LL | check(xm9::TV{});
- | ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item`
+ | ----- ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:128:11
|
LL | check(xm9::TV);
- | ^^^^^^^ the trait `Impossible` is not implemented for `fn() -> namespace_mix::c::E {namespace_mix::xm7::TV}`
+ | ----- ^^^^^^^ the trait `Impossible` is not implemented for `fn() -> namespace_mix::c::E {namespace_mix::xm7::TV}`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:129:11
|
LL | check(xmA::TV{});
- | ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::E`
+ | ----- ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::E`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:130:11
|
LL | check(xmA::TV);
- | ^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item`
+ | ----- ^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:143:11
|
LL | check(mB::UV{});
- | ^^^^^^^^ the trait `Impossible` is not implemented for `c::Item`
+ | ----- ^^^^^^^^ the trait `Impossible` is not implemented for `c::Item`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:144:11
|
LL | check(mB::UV);
- | ^^^^^^ the trait `Impossible` is not implemented for `c::E`
+ | ----- ^^^^^^ the trait `Impossible` is not implemented for `c::E`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:145:11
|
LL | check(mC::UV{});
- | ^^^^^^^^ the trait `Impossible` is not implemented for `c::E`
+ | ----- ^^^^^^^^ the trait `Impossible` is not implemented for `c::E`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:146:11
|
LL | check(mC::UV);
- | ^^^^^^ the trait `Impossible` is not implemented for `c::Item`
+ | ----- ^^^^^^ the trait `Impossible` is not implemented for `c::Item`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:149:11
|
LL | check(xmB::UV{});
- | ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item`
+ | ----- ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:150:11
|
LL | check(xmB::UV);
- | ^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::E`
+ | ----- ^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::E`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:151:11
|
LL | check(xmC::UV{});
- | ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::E`
+ | ----- ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::E`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--> $DIR/namespace-mix.rs:152:11
|
LL | check(xmC::UV);
- | ^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item`
+ | ----- ^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `check`
--> $DIR/namespace-mix.rs:21:13
--- /dev/null
+// run-pass
+
+#![allow(dead_code)]
+// Issue #521
+
+// pretty-expanded FIXME #23616
+
+fn f() {
+ let _x = match true {
+ true => { 10 }
+ false => { return }
+ };
+}
+
+pub fn main() { }
LL | let x = (vec![22], vec![44]);
| - captured outer variable
LL | expect_fn(|| drop(x.0));
- | ^^^ move occurs because `x.0` has type `Vec<i32>`, which does not implement the `Copy` trait
+ | --------^^^-
+ | | |
+ | | move occurs because `x.0` has type `Vec<i32>`, which does not implement the `Copy` trait
+ | captured by this `Fn` closure
error: aborting due to previous error
--> $DIR/no_send-rc.rs:7:9
|
LL | bar(x);
- | ^ `Rc<{integer}>` cannot be sent between threads safely
+ | --- ^ `Rc<{integer}>` cannot be sent between threads safely
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Send` is not implemented for `Rc<{integer}>`
note: required by a bound in `bar`
--> $DIR/no_send-struct.rs:15:9
|
LL | bar(x);
- | ^ `Foo` cannot be sent between threads safely
+ | --- ^ `Foo` cannot be sent between threads safely
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Send` is not implemented for `Foo`
note: required by a bound in `bar`
--> $DIR/no_share-struct.rs:12:9
|
LL | bar(x);
- | ^ `Foo` cannot be shared between threads safely
+ | --- ^ `Foo` cannot be shared between threads safely
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Sync` is not implemented for `Foo`
note: required by a bound in `bar`
--> $DIR/object-does-not-impl-trait.rs:6:44
|
LL | fn take_object(f: Box<dyn Foo>) { take_foo(f); }
- | ^ the trait `Foo` is not implemented for `Box<dyn Foo>`
+ | -------- ^ the trait `Foo` is not implemented for `Box<dyn Foo>`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `take_foo`
--> $DIR/object-does-not-impl-trait.rs:5:15
LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
| ^^^^^^^^ `Bar` cannot be made into an object
|
- = help: consider moving `X` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/object-safety-associated-consts.rs:9:11
|
| --- this trait cannot be made into an object...
LL | const X: usize;
| ^ ...because it contains this associated `const`
+ = help: consider moving `X` to another trait
error: aborting due to previous error
LL | t
| ^ `Bar` cannot be made into an object
|
- = help: consider moving `X` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/object-safety-associated-consts.rs:9:11
|
| --- this trait cannot be made into an object...
LL | const X: usize;
| ^ ...because it contains this associated `const`
+ = help: consider moving `X` to another trait
= note: required because of the requirements on the impl of `CoerceUnsized<&dyn Bar>` for `&T`
= note: required by cast to type `&dyn Bar`
LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
| ^^^^^^^^ `Bar` cannot be made into an object
|
- = help: consider moving `bar` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/object-safety-generics.rs:10:8
|
| --- this trait cannot be made into an object...
LL | fn bar<T>(&self, t: T);
| ^^^ ...because method `bar` has generic type parameters
+ = help: consider moving `bar` to another trait
error[E0038]: the trait `Bar` cannot be made into an object
--> $DIR/object-safety-generics.rs:24:39
LL | fn make_bar_explicit<T:Bar>(t: &T) -> &dyn Bar {
| ^^^^^^^^ `Bar` cannot be made into an object
|
- = help: consider moving `bar` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/object-safety-generics.rs:10:8
|
| --- this trait cannot be made into an object...
LL | fn bar<T>(&self, t: T);
| ^^^ ...because method `bar` has generic type parameters
+ = help: consider moving `bar` to another trait
error: aborting due to 2 previous errors
LL | t
| ^ `Bar` cannot be made into an object
|
- = help: consider moving `bar` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/object-safety-generics.rs:10:8
|
| --- this trait cannot be made into an object...
LL | fn bar<T>(&self, t: T);
| ^^^ ...because method `bar` has generic type parameters
+ = help: consider moving `bar` to another trait
= note: required because of the requirements on the impl of `CoerceUnsized<&dyn Bar>` for `&T`
= note: required by cast to type `&dyn Bar`
LL | t as &dyn Bar
| ^ `Bar` cannot be made into an object
|
- = help: consider moving `bar` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/object-safety-generics.rs:10:8
|
| --- this trait cannot be made into an object...
LL | fn bar<T>(&self, t: T);
| ^^^ ...because method `bar` has generic type parameters
+ = help: consider moving `bar` to another trait
= note: required because of the requirements on the impl of `CoerceUnsized<&dyn Bar>` for `&T`
= note: required by cast to type `&dyn Bar`
LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
| ^^^^^^^^ `Bar` cannot be made into an object
|
- = help: consider moving `bar` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/object-safety-mentions-Self.rs:11:22
|
| --- this trait cannot be made into an object...
LL | fn bar(&self, x: &Self);
| ^^^^^ ...because method `bar` references the `Self` type in this parameter
+ = help: consider moving `bar` to another trait
error[E0038]: the trait `Baz` cannot be made into an object
--> $DIR/object-safety-mentions-Self.rs:28:30
LL | fn make_baz<T:Baz>(t: &T) -> &dyn Baz {
| ^^^^^^^^ `Baz` cannot be made into an object
|
- = help: consider moving `baz` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/object-safety-mentions-Self.rs:15:22
|
| --- this trait cannot be made into an object...
LL | fn baz(&self) -> Self;
| ^^^^ ...because method `baz` references the `Self` type in its return type
+ = help: consider moving `baz` to another trait
error: aborting due to 2 previous errors
LL | t
| ^ `Bar` cannot be made into an object
|
- = help: consider moving `bar` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/object-safety-mentions-Self.rs:11:22
|
| --- this trait cannot be made into an object...
LL | fn bar(&self, x: &Self);
| ^^^^^ ...because method `bar` references the `Self` type in this parameter
+ = help: consider moving `bar` to another trait
= note: required because of the requirements on the impl of `CoerceUnsized<&dyn Bar>` for `&T`
= note: required by cast to type `&dyn Bar`
LL | t
| ^ `Baz` cannot be made into an object
|
- = help: consider moving `baz` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/object-safety-mentions-Self.rs:15:22
|
| --- this trait cannot be made into an object...
LL | fn baz(&self) -> Self;
| ^^^^ ...because method `baz` references the `Self` type in its return type
+ = help: consider moving `baz` to another trait
= note: required because of the requirements on the impl of `CoerceUnsized<&dyn Baz>` for `&T`
= note: required by cast to type `&dyn Baz`
LL | let x = || {
| _____________-
LL | | f(Foo{});
- | | ^^^^^ the trait `Trait` is not implemented for `Foo`
+ | | - ^^^^^ the trait `Trait` is not implemented for `Foo`
+ | | |
+ | | required by a bound introduced by this call
LL | | let y = || {
LL | | f(Foo{});
LL | | };
LL | let y = || {
| _________________-
LL | | f(Foo{});
- | | ^^^^^ the trait `Trait` is not implemented for `Foo`
+ | | - ^^^^^ the trait `Trait` is not implemented for `Foo`
+ | | |
+ | | required by a bound introduced by this call
LL | | };
| |_________- in this scope
|
LL | | let y = || {
... |
LL | | f(Foo{});
- | | ^^^^^ the trait `Trait` is not implemented for `Foo`
+ | | - ^^^^^ the trait `Trait` is not implemented for `Foo`
+ | | |
+ | | required by a bound introduced by this call
... |
LL | | f(Foo{});
LL | | }
LL | | let y = || {
... |
LL | | f(Foo{});
- | | ^^^^^ the trait `Trait` is not implemented for `Foo`
+ | | - ^^^^^ the trait `Trait` is not implemented for `Foo`
+ | | |
+ | | required by a bound introduced by this call
LL | | }
| |_- in this scope
|
--> $DIR/multiple-impls.rs:33:18
|
LL | Index::index(&[] as &[i32], 2u32);
- | ^^^^^^^^^^^^^ trait message
+ | ------------ ^^^^^^^^^^^^^ trait message
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Index<u32>` is not implemented for `[i32]`
note: required by `Index::index`
--> $DIR/multiple-impls.rs:36:18
|
LL | Index::index(&[] as &[i32], Foo(2u32));
- | ^^^^^^^^^^^^^ on impl for Foo
+ | ------------ ^^^^^^^^^^^^^ on impl for Foo
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Index<Foo<u32>>` is not implemented for `[i32]`
note: required by `Index::index`
--> $DIR/multiple-impls.rs:39:18
|
LL | Index::index(&[] as &[i32], Bar(2u32));
- | ^^^^^^^^^^^^^ on impl for Bar
+ | ------------ ^^^^^^^^^^^^^ on impl for Bar
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Index<Bar<u32>>` is not implemented for `[i32]`
note: required by `Index::index`
--> $DIR/on-impl.rs:22:25
|
LL | Index::<u32>::index(&[1, 2, 3] as &[i32], 2u32);
- | ^^^^^^^^^^^^^^^^^^^^ a usize is required to index into a slice
+ | ------------------- ^^^^^^^^^^^^^^^^^^^^ a usize is required to index into a slice
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Index<u32>` is not implemented for `[i32]`
note: required by `Index::index`
+++ /dev/null
-// aux-build:define-macro.rs
-
-macro_rules! bar { () => {} }
-define_macro!(bar);
-bar!(); //~ ERROR `bar` is ambiguous
-
-macro_rules! m { () => { #[macro_use] extern crate define_macro; } }
-m!();
-
-fn main() {}
+++ /dev/null
-error[E0659]: `bar` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
- --> $DIR/out-of-order-shadowing.rs:5:1
- |
-LL | bar!();
- | ^^^ ambiguous name
- |
-note: `bar` could refer to the macro defined here
- --> $DIR/out-of-order-shadowing.rs:4:1
- |
-LL | define_macro!(bar);
- | ^^^^^^^^^^^^^^^^^^^
-note: `bar` could also refer to the macro defined here
- --> $DIR/out-of-order-shadowing.rs:3:1
- |
-LL | macro_rules! bar { () => {} }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- = note: this error originates in the macro `define_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0659`.
macro_rules! foo {
($rest: tt) => {
- bar(baz: $rest)
+ bar(baz: $rest) //~ ERROR invalid `struct` delimiters or `fn` call arguments
}
}
fn main() {
- foo!(true); //~ ERROR expected type, found keyword
+ foo!(true);
//~^ ERROR expected identifier, found keyword
}
LL | foo!(r#true);
| ~~~~~~
-error: expected type, found keyword `true`
- --> $DIR/issue-44406.rs:8:10
+error: invalid `struct` delimiters or `fn` call arguments
+ --> $DIR/issue-44406.rs:3:9
|
LL | bar(baz: $rest)
- | - help: try using a semicolon: `;`
+ | ^^^^^^^^^^^^^^^
...
LL | foo!(true);
- | ^^^^ expected type
+ | ----------- in this macro invocation
+ |
+ = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: if `bar` is a struct, use braces as delimiters
+ |
+LL | bar { }
+ | ~
+help: if `bar` is a function, use the arguments directly
|
- = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>`
- = note: see issue #23416 <https://github.com/rust-lang/rust/issues/23416> for more information
+LL - bar(baz: $rest)
+LL + bar(true);
+ |
error: aborting due to 2 previous errors
--- /dev/null
+// check-pass
+
+#![allow(non_camel_case_types)]
+
+struct union;
+
+impl union {
+ pub fn new() -> Self {
+ union { }
+ }
+}
+
+fn main() {
+ let _u = union::new();
+}
--- /dev/null
+// check-pass
+
+use std::io::Write;
+
+fn main() -> Result<(), std::io::Error> {
+ vec! { 1, 2, 3 }.len();
+ write! { vec![], "" }?;
+ println!{""}
+ [0]; // separate statement, not indexing into the result of println.
+ Ok(())
+}
for ( elem in vec ) {
//~^ ERROR expected one of `)`, `,`, `@`, or `|`, found keyword `in`
- //~| ERROR unexpected closing `)`
+ //~| ERROR unexpected parenthesis surrounding `for` loop head
const RECOVERY_WITNESS: () = 0; //~ ERROR mismatched types
}
}
LL | for ( elem in vec ) {
| ^^ expected one of `)`, `,`, `@`, or `|`
-error: unexpected closing `)`
- --> $DIR/recover-for-loop-parens-around-head.rs:10:23
+error: unexpected parenthesis surrounding `for` loop head
+ --> $DIR/recover-for-loop-parens-around-head.rs:10:9
|
LL | for ( elem in vec ) {
- | --------------^
- | |
- | opening `(`
- | help: remove parenthesis in `for` loop: `elem in vec`
+ | ^ ^
+ |
+help: remove parenthesis in `for` loop
+ |
+LL - for ( elem in vec ) {
+LL + for elem in vec {
+ |
error[E0308]: mismatched types
--> $DIR/recover-for-loop-parens-around-head.rs:13:38
fn main() {
let x = Enum::Foo(a: 3, b: 4);
- //~^ ERROR expected type, found `3`
+ //~^ ERROR invalid `struct` delimiters or `fn` call arguments
match x {
Enum::Foo(a, b) => {}
//~^ ERROR expected tuple struct or tuple variant, found struct variant `Enum::Foo`
-error: expected type, found `3`
- --> $DIR/recover-from-bad-variant.rs:7:26
+error: invalid `struct` delimiters or `fn` call arguments
+ --> $DIR/recover-from-bad-variant.rs:7:13
|
LL | let x = Enum::Foo(a: 3, b: 4);
- | - ^ expected type
- | |
- | tried to parse a type due to this type ascription
+ | ^^^^^^^^^^^^^^^^^^^^^
|
- = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>`
- = note: see issue #23416 <https://github.com/rust-lang/rust/issues/23416> for more information
+help: if `Enum::Foo` is a struct, use braces as delimiters
+ |
+LL | let x = Enum::Foo { a: 3, b: 4 };
+ | ~ ~
+help: if `Enum::Foo` is a function, use the arguments directly
+ |
+LL - let x = Enum::Foo(a: 3, b: 4);
+LL + let x = Enum::Foo(3, 4);
+ |
error[E0532]: expected tuple struct or tuple variant, found struct variant `Enum::Foo`
--> $DIR/recover-from-bad-variant.rs:10:9
--> $DIR/phantom-auto-trait.rs:21:12
|
LL | is_zen(x)
- | ^ `T` cannot be shared between threads safely
+ | ------ ^ `T` cannot be shared between threads safely
+ | |
+ | required by a bound introduced by this call
|
note: required because of the requirements on the impl of `Zen` for `&T`
--> $DIR/phantom-auto-trait.rs:10:24
--> $DIR/phantom-auto-trait.rs:26:12
|
LL | is_zen(x)
- | ^ `T` cannot be shared between threads safely
+ | ------ ^ `T` cannot be shared between threads safely
+ | |
+ | required by a bound introduced by this call
|
note: required because of the requirements on the impl of `Zen` for `&T`
--> $DIR/phantom-auto-trait.rs:10:24
--- /dev/null
+// compile-flags:-Zpolymorphize=on
+// build-pass
+
+fn test<T>() {
+ std::mem::size_of::<T>();
+}
+
+pub fn foo<T>(_: T) -> &'static fn() {
+ &(test::<T> as fn())
+}
+
+fn outer<T>() {
+ foo(|| ());
+}
+
+fn main() {
+ outer::<u8>();
+}
--- /dev/null
+mod foo {
+ pub struct Pub { private: () }
+
+ pub enum Enum {
+ Variant { x: (), y: () },
+ Other
+ }
+
+ fn correct() {
+ Pub {};
+ //~^ ERROR missing field `private` in initializer of `Pub`
+ Enum::Variant { x: () };
+ //~^ ERROR missing field `y` in initializer of `Enum`
+ }
+}
+
+fn correct() {
+ foo::Pub {};
+ //~^ ERROR cannot construct `Pub` with struct literal syntax due to inaccessible fields
+}
+
+fn wrong() {
+ foo::Enum::Variant { x: () };
+ //~^ ERROR missing field `y` in initializer of `Enum`
+ foo::Enum::Variant { };
+ //~^ ERROR missing fields `x` and `y` in initializer of `Enum`
+}
+
+fn main() {}
--- /dev/null
+error[E0063]: missing field `private` in initializer of `Pub`
+ --> $DIR/issue-79593.rs:10:9
+ |
+LL | Pub {};
+ | ^^^ missing `private`
+
+error[E0063]: missing field `y` in initializer of `Enum`
+ --> $DIR/issue-79593.rs:12:9
+ |
+LL | Enum::Variant { x: () };
+ | ^^^^^^^^^^^^^ missing `y`
+
+error: cannot construct `Pub` with struct literal syntax due to inaccessible fields
+ --> $DIR/issue-79593.rs:18:5
+ |
+LL | foo::Pub {};
+ | ^^^^^^^^
+
+error[E0063]: missing field `y` in initializer of `Enum`
+ --> $DIR/issue-79593.rs:23:5
+ |
+LL | foo::Enum::Variant { x: () };
+ | ^^^^^^^^^^^^^^^^^^ missing `y`
+
+error[E0063]: missing fields `x` and `y` in initializer of `Enum`
+ --> $DIR/issue-79593.rs:25:5
+ |
+LL | foo::Enum::Variant { };
+ | ^^^^^^^^^^^^^^^^^^ missing `x` and `y`
+
+error: aborting due to 5 previous errors
+
+For more information about this error, try `rustc --explain E0063`.
--- /dev/null
+// Regression test for the ICE described in #87496.
+
+// check-pass
+
+#[repr(transparent)]
+struct TransparentCustomZst(());
+extern "C" {
+ fn good17(p: TransparentCustomZst);
+ //~^ WARNING: `extern` block uses type `TransparentCustomZst`, which is not FFI-safe
+}
+
+fn main() {}
--- /dev/null
+warning: `extern` block uses type `TransparentCustomZst`, which is not FFI-safe
+ --> $DIR/repr-transparent-issue-87496.rs:8:18
+ |
+LL | fn good17(p: TransparentCustomZst);
+ | ^^^^^^^^^^^^^^^^^^^^ not FFI-safe
+ |
+ = note: `#[warn(improper_ctypes)]` on by default
+ = note: this struct contains only zero-sized fields
+note: the type is defined here
+ --> $DIR/repr-transparent-issue-87496.rs:6:1
+ |
+LL | struct TransparentCustomZst(());
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+warning: 1 warning emitted
+
--- /dev/null
+mod foo {
+ pub struct Bx(());
+}
+
+mod bar {
+ use foo::Bx;
+
+ fn foo() {
+ Bx(());
+ //~^ ERROR cannot initialize a tuple struct which contains private fields [E0423]
+ }
+}
+
+mod baz {
+ fn foo() {
+ Bx(());
+ //~^ ERROR cannot find function, tuple struct or tuple variant `Bx` in this scope [E0425]
+ }
+}
+
+fn main() {}
--- /dev/null
+error[E0423]: cannot initialize a tuple struct which contains private fields
+ --> $DIR/issue-42944.rs:9:9
+ |
+LL | Bx(());
+ | ^^
+ |
+note: constructor is not visible here due to private fields
+ --> $DIR/issue-42944.rs:2:19
+ |
+LL | pub struct Bx(());
+ | ^^ private field
+
+error[E0425]: cannot find function, tuple struct or tuple variant `Bx` in this scope
+ --> $DIR/issue-42944.rs:16:9
+ |
+LL | Bx(());
+ | ^^ not found in this scope
+ |
+help: consider importing this tuple struct
+ |
+LL | use foo::Bx;
+ |
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0423, E0425.
+For more information about an error, try `rustc --explain E0423`.
--- /dev/null
+struct A;
+
+impl A {
+//~^ NOTE `Self` type implicitly declared here, by this `impl`
+ fn banana(&mut self) {
+ fn peach(this: &Self) {
+ //~^ ERROR can't use generic parameters from outer function
+ //~| NOTE use of generic parameter from outer function
+ //~| NOTE use a type here instead
+ }
+ }
+}
+
+fn main() {}
--- /dev/null
+error[E0401]: can't use generic parameters from outer function
+ --> $DIR/use-self-in-inner-fn.rs:6:25
+ |
+LL | impl A {
+ | ---- `Self` type implicitly declared here, by this `impl`
+...
+LL | fn peach(this: &Self) {
+ | ^^^^
+ | |
+ | use of generic parameter from outer function
+ | use a type here instead
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0401`.
pub enum NonExhaustiveEnum {
Unit,
Tuple(u32),
- Struct { field: u32 }
+ Struct { field: u32 },
+}
+
+#[non_exhaustive]
+pub enum NestedNonExhaustive {
+ A(NonExhaustiveEnum),
+ B,
+ C,
}
#[non_exhaustive]
pub enum EmptyNonExhaustiveEnum {}
+
+pub enum VariantNonExhaustive {
+ #[non_exhaustive]
+ Bar {
+ x: u32,
+ y: u64,
+ },
+ Baz(u32, u16),
+}
+
+#[non_exhaustive]
+pub enum NonExhaustiveSingleVariant {
+ A(bool),
+}
+#[derive(Default)]
#[non_exhaustive]
pub struct NormalStruct {
pub first_field: u16,
pub struct FunctionalRecord {
pub first_field: u16,
pub second_field: u16,
- pub third_field: bool
+ pub third_field: bool,
}
impl Default for FunctionalRecord {
FunctionalRecord { first_field: 640, second_field: 480, third_field: false }
}
}
+
+#[derive(Default)]
+#[non_exhaustive]
+pub struct NestedStruct {
+ pub foo: u16,
+ pub bar: NormalStruct,
+}
--- /dev/null
+// Test that the `non_exhaustive_omitted_patterns` lint is triggered correctly.
+
+// aux-build:enums.rs
+extern crate enums;
+
+// aux-build:structs.rs
+extern crate structs;
+
+use enums::{
+ EmptyNonExhaustiveEnum, NestedNonExhaustive, NonExhaustiveEnum, NonExhaustiveSingleVariant,
+ VariantNonExhaustive,
+};
+use structs::{FunctionalRecord, NestedStruct, NormalStruct};
+
+#[non_exhaustive]
+#[derive(Default)]
+pub struct Foo {
+ a: u8,
+ b: usize,
+ c: String,
+}
+
+#[non_exhaustive]
+pub enum Bar {
+ A,
+ B,
+ C,
+}
+
+fn main() {
+ let enumeration = Bar::A;
+
+ // Ok: this is a crate local non_exhaustive enum
+ match enumeration {
+ Bar::A => {}
+ Bar::B => {}
+ #[deny(non_exhaustive_omitted_patterns)]
+ _ => {}
+ }
+
+ let non_enum = NonExhaustiveEnum::Unit;
+
+ // Ok: without the attribute
+ match non_enum {
+ NonExhaustiveEnum::Unit => {}
+ NonExhaustiveEnum::Tuple(_) => {}
+ _ => {}
+ }
+
+ match non_enum {
+ NonExhaustiveEnum::Unit => {}
+ NonExhaustiveEnum::Tuple(_) => {}
+ #[deny(non_exhaustive_omitted_patterns)]
+ _ => {}
+ }
+ //~^^ some variants are not matched explicitly
+
+ match non_enum {
+ NonExhaustiveEnum::Unit | NonExhaustiveEnum::Struct { .. } => {}
+ #[deny(non_exhaustive_omitted_patterns)]
+ _ => {}
+ }
+ //~^^ some variants are not matched explicitly
+
+ let x = 5;
+ match non_enum {
+ NonExhaustiveEnum::Unit if x > 10 => {}
+ NonExhaustiveEnum::Tuple(_) => {}
+ NonExhaustiveEnum::Struct { .. } => {}
+ #[deny(non_exhaustive_omitted_patterns)]
+ _ => {}
+ }
+ //~^^ some variants are not matched explicitly
+
+ // Ok: all covered and not `unreachable-patterns`
+ #[deny(unreachable_patterns)]
+ match non_enum {
+ NonExhaustiveEnum::Unit => {}
+ NonExhaustiveEnum::Tuple(_) => {}
+ NonExhaustiveEnum::Struct { .. } => {}
+ #[deny(non_exhaustive_omitted_patterns)]
+ _ => {}
+ }
+
+ #[deny(non_exhaustive_omitted_patterns)]
+ match NestedNonExhaustive::B {
+ NestedNonExhaustive::A(NonExhaustiveEnum::Unit) => {}
+ NestedNonExhaustive::A(_) => {}
+ NestedNonExhaustive::B => {}
+ _ => {}
+ }
+ //~^^ some variants are not matched explicitly
+ //~^^^^^ some variants are not matched explicitly
+
+ // The io::ErrorKind has many `unstable` fields how do they interact with this
+ // lint
+ #[deny(non_exhaustive_omitted_patterns)]
+ match std::io::ErrorKind::Other {
+ std::io::ErrorKind::NotFound => {}
+ std::io::ErrorKind::PermissionDenied => {}
+ std::io::ErrorKind::ConnectionRefused => {}
+ std::io::ErrorKind::ConnectionReset => {}
+ std::io::ErrorKind::ConnectionAborted => {}
+ std::io::ErrorKind::NotConnected => {}
+ std::io::ErrorKind::AddrInUse => {}
+ std::io::ErrorKind::AddrNotAvailable => {}
+ std::io::ErrorKind::BrokenPipe => {}
+ std::io::ErrorKind::AlreadyExists => {}
+ std::io::ErrorKind::WouldBlock => {}
+ std::io::ErrorKind::InvalidInput => {}
+ std::io::ErrorKind::InvalidData => {}
+ std::io::ErrorKind::TimedOut => {}
+ std::io::ErrorKind::WriteZero => {}
+ std::io::ErrorKind::Interrupted => {}
+ std::io::ErrorKind::Other => {}
+ std::io::ErrorKind::UnexpectedEof => {}
+ std::io::ErrorKind::Unsupported => {}
+ std::io::ErrorKind::OutOfMemory => {}
+ // All stable variants are above and unstable in `_`
+ _ => {}
+ }
+ //~^^ some variants are not matched explicitly
+
+ #[warn(non_exhaustive_omitted_patterns)]
+ match VariantNonExhaustive::Baz(1, 2) {
+ VariantNonExhaustive::Baz(_, _) => {}
+ VariantNonExhaustive::Bar { x, .. } => {}
+ }
+ //~^^ some fields are not explicitly listed
+
+ #[warn(non_exhaustive_omitted_patterns)]
+ let FunctionalRecord { first_field, second_field, .. } = FunctionalRecord::default();
+ //~^ some fields are not explicitly listed
+
+ // Ok: this is local
+ #[warn(non_exhaustive_omitted_patterns)]
+ let Foo { a, b, .. } = Foo::default();
+
+ #[warn(non_exhaustive_omitted_patterns)]
+ let NestedStruct { bar: NormalStruct { first_field, .. }, .. } = NestedStruct::default();
+ //~^ some fields are not explicitly listed
+ //~^^ some fields are not explicitly listed
+
+ // Ok: because this only has 1 variant
+ #[deny(non_exhaustive_omitted_patterns)]
+ match NonExhaustiveSingleVariant::A(true) {
+ NonExhaustiveSingleVariant::A(true) => {}
+ _ => {}
+ }
+
+ #[deny(non_exhaustive_omitted_patterns)]
+ match NonExhaustiveSingleVariant::A(true) {
+ _ => {}
+ }
+ //~^^ some variants are not matched explicitly
+
+ // Ok: we don't lint on `if let` expressions
+ #[deny(non_exhaustive_omitted_patterns)]
+ if let NonExhaustiveEnum::Tuple(_) = non_enum {}
+}
--- /dev/null
+warning: some fields are not explicitly listed
+ --> $DIR/reachable-patterns.rs:127:9
+ |
+LL | VariantNonExhaustive::Bar { x, .. } => {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `y` not listed
+ |
+note: the lint level is defined here
+ --> $DIR/reachable-patterns.rs:124:12
+ |
+LL | #[warn(non_exhaustive_omitted_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = help: ensure that all fields are mentioned explicitly by adding the suggested fields
+ = note: the pattern is of type `VariantNonExhaustive` and the `non_exhaustive_omitted_patterns` attribute was found
+
+warning: some fields are not explicitly listed
+ --> $DIR/reachable-patterns.rs:132:9
+ |
+LL | let FunctionalRecord { first_field, second_field, .. } = FunctionalRecord::default();
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `third_field` not listed
+ |
+note: the lint level is defined here
+ --> $DIR/reachable-patterns.rs:131:12
+ |
+LL | #[warn(non_exhaustive_omitted_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = help: ensure that all fields are mentioned explicitly by adding the suggested fields
+ = note: the pattern is of type `FunctionalRecord` and the `non_exhaustive_omitted_patterns` attribute was found
+
+warning: some fields are not explicitly listed
+ --> $DIR/reachable-patterns.rs:140:29
+ |
+LL | let NestedStruct { bar: NormalStruct { first_field, .. }, .. } = NestedStruct::default();
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `second_field` not listed
+ |
+note: the lint level is defined here
+ --> $DIR/reachable-patterns.rs:139:12
+ |
+LL | #[warn(non_exhaustive_omitted_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = help: ensure that all fields are mentioned explicitly by adding the suggested fields
+ = note: the pattern is of type `NormalStruct` and the `non_exhaustive_omitted_patterns` attribute was found
+
+warning: some fields are not explicitly listed
+ --> $DIR/reachable-patterns.rs:140:9
+ |
+LL | let NestedStruct { bar: NormalStruct { first_field, .. }, .. } = NestedStruct::default();
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `foo` not listed
+ |
+ = help: ensure that all fields are mentioned explicitly by adding the suggested fields
+ = note: the pattern is of type `NestedStruct` and the `non_exhaustive_omitted_patterns` attribute was found
+
+error: some variants are not matched explicitly
+ --> $DIR/reachable-patterns.rs:54:9
+ |
+LL | _ => {}
+ | ^ pattern `Struct { .. }` not covered
+ |
+note: the lint level is defined here
+ --> $DIR/reachable-patterns.rs:53:16
+ |
+LL | #[deny(non_exhaustive_omitted_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = help: ensure that all variants are matched explicitly by adding the suggested match arms
+ = note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found
+
+error: some variants are not matched explicitly
+ --> $DIR/reachable-patterns.rs:61:9
+ |
+LL | _ => {}
+ | ^ pattern `Tuple(_)` not covered
+ |
+note: the lint level is defined here
+ --> $DIR/reachable-patterns.rs:60:16
+ |
+LL | #[deny(non_exhaustive_omitted_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = help: ensure that all variants are matched explicitly by adding the suggested match arms
+ = note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found
+
+error: some variants are not matched explicitly
+ --> $DIR/reachable-patterns.rs:71:9
+ |
+LL | _ => {}
+ | ^ pattern `Unit` not covered
+ |
+note: the lint level is defined here
+ --> $DIR/reachable-patterns.rs:70:16
+ |
+LL | #[deny(non_exhaustive_omitted_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = help: ensure that all variants are matched explicitly by adding the suggested match arms
+ = note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found
+
+error: some variants are not matched explicitly
+ --> $DIR/reachable-patterns.rs:88:32
+ |
+LL | NestedNonExhaustive::A(_) => {}
+ | ^ patterns `Tuple(_)` and `Struct { .. }` not covered
+ |
+note: the lint level is defined here
+ --> $DIR/reachable-patterns.rs:85:12
+ |
+LL | #[deny(non_exhaustive_omitted_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = help: ensure that all variants are matched explicitly by adding the suggested match arms
+ = note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found
+
+error: some variants are not matched explicitly
+ --> $DIR/reachable-patterns.rs:90:9
+ |
+LL | _ => {}
+ | ^ pattern `C` not covered
+ |
+ = help: ensure that all variants are matched explicitly by adding the suggested match arms
+ = note: the matched value is of type `NestedNonExhaustive` and the `non_exhaustive_omitted_patterns` attribute was found
+
+error: some variants are not matched explicitly
+ --> $DIR/reachable-patterns.rs:120:9
+ |
+LL | _ => {}
+ | ^ patterns `HostUnreachable`, `NetworkUnreachable`, `NetworkDown` and 18 more not covered
+ |
+note: the lint level is defined here
+ --> $DIR/reachable-patterns.rs:97:12
+ |
+LL | #[deny(non_exhaustive_omitted_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = help: ensure that all variants are matched explicitly by adding the suggested match arms
+ = note: the matched value is of type `ErrorKind` and the `non_exhaustive_omitted_patterns` attribute was found
+
+error: some variants are not matched explicitly
+ --> $DIR/reachable-patterns.rs:153:9
+ |
+LL | _ => {}
+ | ^ pattern `A(_)` not covered
+ |
+note: the lint level is defined here
+ --> $DIR/reachable-patterns.rs:151:12
+ |
+LL | #[deny(non_exhaustive_omitted_patterns)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = help: ensure that all variants are matched explicitly by adding the suggested match arms
+ = note: the matched value is of type `NonExhaustiveSingleVariant` and the `non_exhaustive_omitted_patterns` attribute was found
+
+error: aborting due to 7 previous errors; 4 warnings emitted
+
LL | let ts_explicit = structs::TupleStruct(640, 480);
| ^^^^^^^^^^^ private tuple struct constructor
|
- ::: $DIR/auxiliary/structs.rs:11:24
+ ::: $DIR/auxiliary/structs.rs:12:24
|
LL | pub struct TupleStruct(pub u16, pub u16);
| ---------------- a constructor is private if any of the fields is private
|
note: the tuple struct constructor `TupleStruct` is defined here
- --> $DIR/auxiliary/structs.rs:11:1
+ --> $DIR/auxiliary/structs.rs:12:1
|
LL | pub struct TupleStruct(pub u16, pub u16);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^ private unit struct
|
note: the unit struct `UnitStruct` is defined here
- --> $DIR/auxiliary/structs.rs:8:1
+ --> $DIR/auxiliary/structs.rs:9:1
|
LL | pub struct UnitStruct;
| ^^^^^^^^^^^^^^^^^^^^^^
--> $DIR/call-generic-method-nonconst.rs:19:34
|
LL | pub const EQ: bool = equals_self(&S);
- | ^^ no implementation for `S == S`
+ | ----------- ^^ no implementation for `S == S`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `PartialEq` is not implemented for `S`
note: required by a bound in `equals_self`
error[E0277]: the trait bound `NonTrivialDrop: Drop` is not satisfied
--> $DIR/const-drop-fail.rs:45:5
|
+LL | const _: () = check($exp);
+ | ----- required by a bound introduced by this call
+...
LL | NonTrivialDrop,
| ^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `NonTrivialDrop`
|
error[E0277]: the trait bound `ConstImplWithDropGlue: Drop` is not satisfied
--> $DIR/const-drop-fail.rs:47:5
|
+LL | const _: () = check($exp);
+ | ----- required by a bound introduced by this call
+...
LL | ConstImplWithDropGlue(NonTrivialDrop),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `ConstImplWithDropGlue`
|
error[E0277]: the trait bound `NonTrivialDrop: A` is not satisfied
--> $DIR/const-drop-fail.rs:49:5
|
+LL | const _: () = check($exp);
+ | ----- required by a bound introduced by this call
+...
LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `A` is not implemented for `NonTrivialDrop`
|
error[E0277]: the trait bound `NonTrivialDrop: Drop` is not satisfied
--> $DIR/const-drop-fail.rs:45:5
|
+LL | const _: () = check($exp);
+ | ----- required by a bound introduced by this call
+...
LL | NonTrivialDrop,
| ^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `NonTrivialDrop`
|
error[E0277]: the trait bound `ConstImplWithDropGlue: Drop` is not satisfied
--> $DIR/const-drop-fail.rs:47:5
|
+LL | const _: () = check($exp);
+ | ----- required by a bound introduced by this call
+...
LL | ConstImplWithDropGlue(NonTrivialDrop),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `ConstImplWithDropGlue`
|
error[E0277]: the trait bound `NonTrivialDrop: A` is not satisfied
--> $DIR/const-drop-fail.rs:49:5
|
+LL | const _: () = check($exp);
+ | ----- required by a bound introduced by this call
+...
LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `A` is not implemented for `NonTrivialDrop`
|
--> $DIR/fn-traits.rs:24:10
|
LL | call(foo);
- | ^^^ expected an `Fn<()>` closure, found `fn() {foo}`
+ | ---- ^^^ expected an `Fn<()>` closure, found `fn() {foo}`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Fn<()>` is not implemented for `fn() {foo}`
= note: wrap the `fn() {foo}` in a closure with no arguments: `|| { /* code */ }`
--> $DIR/fn-traits.rs:25:14
|
LL | call_mut(foo);
- | ^^^ expected an `FnMut<()>` closure, found `fn() {foo}`
+ | -------- ^^^ expected an `FnMut<()>` closure, found `fn() {foo}`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `FnMut<()>` is not implemented for `fn() {foo}`
= note: wrap the `fn() {foo}` in a closure with no arguments: `|| { /* code */ }`
--> $DIR/fn-traits.rs:26:15
|
LL | call_once(foo);
- | ^^^ expected an `FnOnce<()>` closure, found `fn() {foo}`
+ | --------- ^^^ expected an `FnOnce<()>` closure, found `fn() {foo}`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `FnOnce<()>` is not implemented for `fn() {foo}`
= note: wrap the `fn() {foo}` in a closure with no arguments: `|| { /* code */ }`
--> $DIR/fn-traits.rs:28:10
|
LL | call(foo_unsafe);
- | ^^^^^^^^^^ expected an `Fn<()>` closure, found `unsafe fn() {foo_unsafe}`
+ | ---- ^^^^^^^^^^ expected an `Fn<()>` closure, found `unsafe fn() {foo_unsafe}`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Fn<()>` is not implemented for `unsafe fn() {foo_unsafe}`
= note: wrap the `unsafe fn() {foo_unsafe}` in a closure with no arguments: `|| { /* code */ }`
--> $DIR/fn-traits.rs:30:14
|
LL | call_mut(foo_unsafe);
- | ^^^^^^^^^^ expected an `FnMut<()>` closure, found `unsafe fn() {foo_unsafe}`
+ | -------- ^^^^^^^^^^ expected an `FnMut<()>` closure, found `unsafe fn() {foo_unsafe}`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `FnMut<()>` is not implemented for `unsafe fn() {foo_unsafe}`
= note: wrap the `unsafe fn() {foo_unsafe}` in a closure with no arguments: `|| { /* code */ }`
--> $DIR/fn-traits.rs:32:15
|
LL | call_once(foo_unsafe);
- | ^^^^^^^^^^ expected an `FnOnce<()>` closure, found `unsafe fn() {foo_unsafe}`
+ | --------- ^^^^^^^^^^ expected an `FnOnce<()>` closure, found `unsafe fn() {foo_unsafe}`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `FnOnce<()>` is not implemented for `unsafe fn() {foo_unsafe}`
= note: wrap the `unsafe fn() {foo_unsafe}` in a closure with no arguments: `|| { /* code */ }`
error[E0507]: cannot move out of `f`, a captured variable in an `FnMut` closure
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:57:13
|
-LL | let mut f = move |g: Box<dyn FnMut(isize)>, b: isize| {
- | ----- captured outer variable
+LL | let mut f = move |g: Box<dyn FnMut(isize)>, b: isize| {
+ | ----- captured outer variable
...
-LL | foo(f);
- | ^ move occurs because `f` has type `[closure@$DIR/borrowck-call-is-borrow-issue-12224.rs:52:17: 54:6]`, which does not implement the `Copy` trait
+LL | f(Box::new(|a| {
+ | ________________-
+LL | |
+LL | | foo(f);
+ | | ^ move occurs because `f` has type `[closure@$DIR/borrowck-call-is-borrow-issue-12224.rs:52:17: 54:6]`, which does not implement the `Copy` trait
+LL | |
+LL | | }), 3);
+ | |_____- captured by this `FnMut` closure
error[E0505]: cannot move out of `f` because it is borrowed
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:55:16
--- /dev/null
+// check-pass
+#![feature(specialization)]
+//~^ WARN the feature `specialization` is incomplete
+
+fn main() {}
+
+pub trait Alpha<T> { }
+
+pub trait Beta {
+ type Event;
+}
+
+pub trait Delta {
+ type Handle;
+ fn process(&self);
+}
+
+pub struct Parent<A, T>(A, T);
+
+impl<A, T> Delta for Parent<A, T>
+where A: Alpha<T::Handle>,
+ T: Delta,
+ T::Handle: Beta<Event = <Handle as Beta>::Event> {
+ type Handle = Handle;
+ default fn process(&self) {
+ unimplemented!()
+ }
+}
+
+impl<A, T> Delta for Parent<A, T>
+where A: Alpha<T::Handle> + Alpha<Handle>,
+ T: Delta,
+ T::Handle: Beta<Event = <Handle as Beta>::Event> {
+ fn process(&self) {
+ unimplemented!()
+ }
+}
+
+pub struct Handle;
+
+impl Beta for Handle {
+ type Event = ();
+}
--- /dev/null
+warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/issue-35376.rs:2:12
+ |
+LL | #![feature(specialization)]
+ | ^^^^^^^^^^^^^^
+ |
+ = note: `#[warn(incomplete_features)]` on by default
+ = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
+ = help: consider using `min_specialization` instead, which is more stable and complete
+
+warning: 1 warning emitted
+
--- /dev/null
+// build-pass
+#![allow(dead_code)]
+
+struct A {
+ a: &'static (),
+}
+
+static B: &'static A = &A { a: &() };
+static C: &'static A = &B;
+
+fn main() {}
--> $DIR/str-idx.rs:4:19
|
LL | let _ = s.get(4);
- | ^ string indices are ranges of `usize`
+ | --- ^ string indices are ranges of `usize`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `SliceIndex<str>` is not implemented for `{integer}`
= note: you can use `.chars().nth()` or `.bytes().nth()`
--> $DIR/str-idx.rs:5:29
|
LL | let _ = s.get_unchecked(4);
- | ^ string indices are ranges of `usize`
+ | ------------- ^ string indices are ranges of `usize`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `SliceIndex<str>` is not implemented for `{integer}`
= note: you can use `.chars().nth()` or `.bytes().nth()`
--> $DIR/str-mut-idx.rs:9:15
|
LL | s.get_mut(1);
- | ^ string indices are ranges of `usize`
+ | ------- ^ string indices are ranges of `usize`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `SliceIndex<str>` is not implemented for `{integer}`
= note: you can use `.chars().nth()` or `.bytes().nth()`
--> $DIR/str-mut-idx.rs:11:25
|
LL | s.get_unchecked_mut(1);
- | ^ string indices are ranges of `usize`
+ | ----------------- ^ string indices are ranges of `usize`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `SliceIndex<str>` is not implemented for `{integer}`
= note: you can use `.chars().nth()` or `.bytes().nth()`
--- /dev/null
+// run-pass
+#![allow(dead_code)]
+// Check that constant ADTs are codegened OK, part k of N.
+
+enum Bar {
+ C
+}
+
+enum Foo {
+ A {},
+ B {
+ y: usize,
+ z: Bar
+ },
+}
+
+const LIST: [(usize, Foo); 2] = [
+ (51, Foo::B { y: 42, z: Bar::C }),
+ (52, Foo::B { y: 45, z: Bar::C }),
+];
+
+pub fn main() {
+ match LIST {
+ [
+ (51, Foo::B { y: 42, z: Bar::C }),
+ (52, Foo::B { y: 45, z: Bar::C })
+ ] => {}
+ _ => {
+ // I would want to print the enum here, but if
+ // the discriminant is garbage this causes an
+ // `unreachable` and silent process exit.
+ panic!("trivial match failed")
+ }
+ }
+}
| --- consider calling this function
...
LL | bar(foo);
- | ^^^ `fn() -> impl Future {foo}` is not a future
+ | --- ^^^ `fn() -> impl Future {foo}` is not a future
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Future` is not implemented for `fn() -> impl Future {foo}`
note: required by a bound in `bar`
LL | let async_closure = async || ();
| -------- consider calling this closure
LL | bar(async_closure);
- | ^^^^^^^^^^^^^ `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:36]` is not a future
+ | --- ^^^^^^^^^^^^^ `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:36]` is not a future
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Future` is not implemented for `[closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:36]`
note: required by a bound in `bar`
error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:28:21
|
-LL | let x = X(Y);
- | - captured outer variable
+LL | let x = X(Y);
+ | - captured outer variable
...
-LL | let X(_t) = x;
- | -- ^ help: consider borrowing here: `&x`
- | |
- | data moved here
- | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
+LL | consume_fn(|| {
+ | ________________-
+LL | | let X(_t) = x;
+ | | -- ^ help: consider borrowing here: `&x`
+ | | |
+ | | data moved here
+ | | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
+LL | |
+LL | |
+... |
+LL | | }
+LL | | });
+ | |_____- captured by this `Fn` closure
error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:32:34
|
-LL | let e = Either::One(X(Y));
- | - captured outer variable
+LL | let e = Either::One(X(Y));
+ | - captured outer variable
...
-LL | if let Either::One(_t) = e { }
- | -- ^ help: consider borrowing here: `&e`
- | |
- | data moved here
- | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+LL | consume_fn(|| {
+ | ________________-
+LL | | let X(_t) = x;
+LL | |
+LL | |
+LL | |
+LL | | if let Either::One(_t) = e { }
+ | | -- ^ help: consider borrowing here: `&e`
+ | | |
+ | | data moved here
+ | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+... |
+LL | | }
+LL | | });
+ | |_____- captured by this `Fn` closure
error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:36:37
|
-LL | let e = Either::One(X(Y));
- | - captured outer variable
+LL | let e = Either::One(X(Y));
+ | - captured outer variable
...
-LL | while let Either::One(_t) = e { }
- | -- ^ help: consider borrowing here: `&e`
- | |
- | data moved here
- | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+LL | consume_fn(|| {
+ | ________________-
+LL | | let X(_t) = x;
+LL | |
+LL | |
+... |
+LL | | while let Either::One(_t) = e { }
+ | | -- ^ help: consider borrowing here: `&e`
+ | | |
+ | | data moved here
+ | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+... |
+LL | | }
+LL | | });
+ | |_____- captured by this `Fn` closure
error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:40:15
|
-LL | let e = Either::One(X(Y));
- | - captured outer variable
+LL | let e = Either::One(X(Y));
+ | - captured outer variable
...
-LL | match e {
- | ^ help: consider borrowing here: `&e`
-...
-LL | Either::One(_t)
- | --
- | |
- | data moved here
- | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+LL | consume_fn(|| {
+ | ________________-
+LL | | let X(_t) = x;
+LL | |
+LL | |
+... |
+LL | | match e {
+ | | ^ help: consider borrowing here: `&e`
+... |
+LL | | Either::One(_t)
+ | | --
+ | | |
+ | | data moved here
+ | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+... |
+LL | | }
+LL | | });
+ | |_____- captured by this `Fn` closure
error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:47:15
|
-LL | let e = Either::One(X(Y));
- | - captured outer variable
-...
-LL | match e {
- | ^ help: consider borrowing here: `&e`
+LL | let e = Either::One(X(Y));
+ | - captured outer variable
...
-LL | Either::One(_t) => (),
- | --
- | |
- | data moved here
- | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+LL | consume_fn(|| {
+ | ________________-
+LL | | let X(_t) = x;
+LL | |
+LL | |
+... |
+LL | | match e {
+ | | ^ help: consider borrowing here: `&e`
+... |
+LL | | Either::One(_t) => (),
+ | | --
+ | | |
+ | | data moved here
+ | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+... |
+LL | | }
+LL | | });
+ | |_____- captured by this `Fn` closure
error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:56:25
|
-LL | let x = X(Y);
- | - captured outer variable
+LL | let x = X(Y);
+ | - captured outer variable
...
-LL | let X(mut _t) = x;
- | ------ ^ help: consider borrowing here: `&x`
- | |
- | data moved here
- | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
+LL | consume_fn(|| {
+ | ________________-
+LL | | let X(_t) = x;
+LL | |
+LL | |
+... |
+LL | | let X(mut _t) = x;
+ | | ------ ^ help: consider borrowing here: `&x`
+ | | |
+ | | data moved here
+ | | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
+... |
+LL | | }
+LL | | });
+ | |_____- captured by this `Fn` closure
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:60:38
|
-LL | let mut em = Either::One(X(Y));
- | ------ captured outer variable
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
...
-LL | if let Either::One(mut _t) = em { }
- | ------ ^^ help: consider borrowing here: `&em`
- | |
- | data moved here
- | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+LL | consume_fn(|| {
+ | ________________-
+LL | | let X(_t) = x;
+LL | |
+LL | |
+... |
+LL | | if let Either::One(mut _t) = em { }
+ | | ------ ^^ help: consider borrowing here: `&em`
+ | | |
+ | | data moved here
+ | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+... |
+LL | | }
+LL | | });
+ | |_____- captured by this `Fn` closure
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:64:41
|
-LL | let mut em = Either::One(X(Y));
- | ------ captured outer variable
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
...
-LL | while let Either::One(mut _t) = em { }
- | ------ ^^ help: consider borrowing here: `&em`
- | |
- | data moved here
- | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+LL | consume_fn(|| {
+ | ________________-
+LL | | let X(_t) = x;
+LL | |
+LL | |
+... |
+LL | | while let Either::One(mut _t) = em { }
+ | | ------ ^^ help: consider borrowing here: `&em`
+ | | |
+ | | data moved here
+ | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+... |
+LL | | }
+LL | | });
+ | |_____- captured by this `Fn` closure
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:68:15
|
-LL | let mut em = Either::One(X(Y));
- | ------ captured outer variable
-...
-LL | match em {
- | ^^ help: consider borrowing here: `&em`
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
...
-LL | Either::One(mut _t)
- | ------
- | |
- | data moved here
- | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+LL | consume_fn(|| {
+ | ________________-
+LL | | let X(_t) = x;
+LL | |
+LL | |
+... |
+LL | | match em {
+ | | ^^ help: consider borrowing here: `&em`
+... |
+LL | | Either::One(mut _t)
+ | | ------
+ | | |
+ | | data moved here
+ | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+... |
+LL | | }
+LL | | });
+ | |_____- captured by this `Fn` closure
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `Fn` closure
--> $DIR/move-into-closure.rs:75:15
|
-LL | let mut em = Either::One(X(Y));
- | ------ captured outer variable
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
...
-LL | match em {
- | ^^ help: consider borrowing here: `&em`
-...
-LL | Either::One(mut _t) => (),
- | ------
- | |
- | data moved here
- | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+LL | consume_fn(|| {
+ | ________________-
+LL | | let X(_t) = x;
+LL | |
+LL | |
+... |
+LL | | match em {
+ | | ^^ help: consider borrowing here: `&em`
+... |
+LL | | Either::One(mut _t) => (),
+ | | ------
+ | | |
+ | | data moved here
+ | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+... |
+LL | | }
+LL | | });
+ | |_____- captured by this `Fn` closure
error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:95:21
|
-LL | let x = X(Y);
- | - captured outer variable
+LL | let x = X(Y);
+ | - captured outer variable
...
-LL | let X(_t) = x;
- | -- ^ help: consider borrowing here: `&x`
- | |
- | data moved here
- | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
+LL | consume_fnmut(|| {
+ | ___________________-
+LL | | let X(_t) = x;
+ | | -- ^ help: consider borrowing here: `&x`
+ | | |
+ | | data moved here
+ | | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
+LL | |
+LL | |
+... |
+LL | | }
+LL | | });
+ | |_____- captured by this `FnMut` closure
error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:99:34
|
-LL | let e = Either::One(X(Y));
- | - captured outer variable
+LL | let e = Either::One(X(Y));
+ | - captured outer variable
...
-LL | if let Either::One(_t) = e { }
- | -- ^ help: consider borrowing here: `&e`
- | |
- | data moved here
- | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+LL | consume_fnmut(|| {
+ | ___________________-
+LL | | let X(_t) = x;
+LL | |
+LL | |
+LL | |
+LL | | if let Either::One(_t) = e { }
+ | | -- ^ help: consider borrowing here: `&e`
+ | | |
+ | | data moved here
+ | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+... |
+LL | | }
+LL | | });
+ | |_____- captured by this `FnMut` closure
error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:103:37
|
-LL | let e = Either::One(X(Y));
- | - captured outer variable
+LL | let e = Either::One(X(Y));
+ | - captured outer variable
...
-LL | while let Either::One(_t) = e { }
- | -- ^ help: consider borrowing here: `&e`
- | |
- | data moved here
- | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+LL | consume_fnmut(|| {
+ | ___________________-
+LL | | let X(_t) = x;
+LL | |
+LL | |
+... |
+LL | | while let Either::One(_t) = e { }
+ | | -- ^ help: consider borrowing here: `&e`
+ | | |
+ | | data moved here
+ | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+... |
+LL | | }
+LL | | });
+ | |_____- captured by this `FnMut` closure
error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:107:15
|
-LL | let e = Either::One(X(Y));
- | - captured outer variable
-...
-LL | match e {
- | ^ help: consider borrowing here: `&e`
+LL | let e = Either::One(X(Y));
+ | - captured outer variable
...
-LL | Either::One(_t)
- | --
- | |
- | data moved here
- | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+LL | consume_fnmut(|| {
+ | ___________________-
+LL | | let X(_t) = x;
+LL | |
+LL | |
+... |
+LL | | match e {
+ | | ^ help: consider borrowing here: `&e`
+... |
+LL | | Either::One(_t)
+ | | --
+ | | |
+ | | data moved here
+ | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+... |
+LL | | }
+LL | | });
+ | |_____- captured by this `FnMut` closure
error[E0507]: cannot move out of `e.0`, as `e` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:114:15
|
-LL | let e = Either::One(X(Y));
- | - captured outer variable
+LL | let e = Either::One(X(Y));
+ | - captured outer variable
...
-LL | match e {
- | ^ help: consider borrowing here: `&e`
-...
-LL | Either::One(_t) => (),
- | --
- | |
- | data moved here
- | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+LL | consume_fnmut(|| {
+ | ___________________-
+LL | | let X(_t) = x;
+LL | |
+LL | |
+... |
+LL | | match e {
+ | | ^ help: consider borrowing here: `&e`
+... |
+LL | | Either::One(_t) => (),
+ | | --
+ | | |
+ | | data moved here
+ | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+... |
+LL | | }
+LL | | });
+ | |_____- captured by this `FnMut` closure
error[E0507]: cannot move out of `x.0`, as `x` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:123:25
|
-LL | let x = X(Y);
- | - captured outer variable
+LL | let x = X(Y);
+ | - captured outer variable
...
-LL | let X(mut _t) = x;
- | ------ ^ help: consider borrowing here: `&x`
- | |
- | data moved here
- | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
+LL | consume_fnmut(|| {
+ | ___________________-
+LL | | let X(_t) = x;
+LL | |
+LL | |
+... |
+LL | | let X(mut _t) = x;
+ | | ------ ^ help: consider borrowing here: `&x`
+ | | |
+ | | data moved here
+ | | move occurs because `_t` has type `Y`, which does not implement the `Copy` trait
+... |
+LL | | }
+LL | | });
+ | |_____- captured by this `FnMut` closure
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:127:38
|
-LL | let mut em = Either::One(X(Y));
- | ------ captured outer variable
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
...
-LL | if let Either::One(mut _t) = em { }
- | ------ ^^ help: consider borrowing here: `&em`
- | |
- | data moved here
- | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+LL | consume_fnmut(|| {
+ | ___________________-
+LL | | let X(_t) = x;
+LL | |
+LL | |
+... |
+LL | | if let Either::One(mut _t) = em { }
+ | | ------ ^^ help: consider borrowing here: `&em`
+ | | |
+ | | data moved here
+ | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+... |
+LL | | }
+LL | | });
+ | |_____- captured by this `FnMut` closure
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:131:41
|
-LL | let mut em = Either::One(X(Y));
- | ------ captured outer variable
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
...
-LL | while let Either::One(mut _t) = em { }
- | ------ ^^ help: consider borrowing here: `&em`
- | |
- | data moved here
- | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+LL | consume_fnmut(|| {
+ | ___________________-
+LL | | let X(_t) = x;
+LL | |
+LL | |
+... |
+LL | | while let Either::One(mut _t) = em { }
+ | | ------ ^^ help: consider borrowing here: `&em`
+ | | |
+ | | data moved here
+ | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+... |
+LL | | }
+LL | | });
+ | |_____- captured by this `FnMut` closure
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:135:15
|
-LL | let mut em = Either::One(X(Y));
- | ------ captured outer variable
-...
-LL | match em {
- | ^^ help: consider borrowing here: `&em`
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
...
-LL | Either::One(mut _t)
- | ------
- | |
- | data moved here
- | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+LL | consume_fnmut(|| {
+ | ___________________-
+LL | | let X(_t) = x;
+LL | |
+LL | |
+... |
+LL | | match em {
+ | | ^^ help: consider borrowing here: `&em`
+... |
+LL | | Either::One(mut _t)
+ | | ------
+ | | |
+ | | data moved here
+ | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+... |
+LL | | }
+LL | | });
+ | |_____- captured by this `FnMut` closure
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:142:15
|
-LL | let mut em = Either::One(X(Y));
- | ------ captured outer variable
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
...
-LL | match em {
- | ^^ help: consider borrowing here: `&em`
-...
-LL | Either::One(mut _t) => (),
- | ------
- | |
- | data moved here
- | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+LL | consume_fnmut(|| {
+ | ___________________-
+LL | | let X(_t) = x;
+LL | |
+LL | |
+... |
+LL | | match em {
+ | | ^^ help: consider borrowing here: `&em`
+... |
+LL | | Either::One(mut _t) => (),
+ | | ------
+ | | |
+ | | data moved here
+ | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+... |
+LL | | }
+LL | | });
+ | |_____- captured by this `FnMut` closure
error[E0507]: cannot move out of `em.0`, as `em` is a captured variable in an `FnMut` closure
--> $DIR/move-into-closure.rs:150:15
|
-LL | let mut em = Either::One(X(Y));
- | ------ captured outer variable
-...
-LL | match em {
- | ^^ help: consider borrowing here: `&em`
+LL | let mut em = Either::One(X(Y));
+ | ------ captured outer variable
...
-LL | Either::One(mut _t) => (),
- | ------
- | |
- | data moved here
- | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+LL | consume_fnmut(|| {
+ | ___________________-
+LL | | let X(_t) = x;
+LL | |
+LL | |
+... |
+LL | | match em {
+ | | ^^ help: consider borrowing here: `&em`
+... |
+LL | | Either::One(mut _t) => (),
+ | | ------
+ | | |
+ | | data moved here
+ | | move occurs because `_t` has type `X`, which does not implement the `Copy` trait
+... |
+LL | | }
+LL | | });
+ | |_____- captured by this `FnMut` closure
error: aborting due to 21 previous errors
| --- consider calling this function
...
LL | bar(foo);
- | ^^^ the trait `T` is not implemented for `fn() -> impl T {foo}`
+ | --- ^^^ the trait `T` is not implemented for `fn() -> impl T {foo}`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `bar`
--> $DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:14:16
LL | let closure = || S;
| -- consider calling this closure
LL | bar(closure);
- | ^^^^^^^ the trait `T` is not implemented for `[closure@$DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:18:19: 18:23]`
+ | --- ^^^^^^^ the trait `T` is not implemented for `[closure@$DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:18:19: 18:23]`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `bar`
--> $DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:14:16
--> $DIR/imm-ref-trait-object-literal.rs:12:7
|
LL | foo(&s);
- | ^^ the trait `Trait` is not implemented for `&S`
+ | --- ^^ the trait `Trait` is not implemented for `&S`
+ | |
+ | required by a bound introduced by this call
|
= help: the following implementations were found:
<&'a mut S as Trait>
--> $DIR/imm-ref-trait-object-literal.rs:13:7
|
LL | foo(s);
- | ^
- | |
- | expected an implementor of trait `Trait`
- | help: consider mutably borrowing here: `&mut s`
+ | --- ^
+ | | |
+ | | expected an implementor of trait `Trait`
+ | | help: consider mutably borrowing here: `&mut s`
+ | required by a bound introduced by this call
|
note: required by a bound in `foo`
--> $DIR/imm-ref-trait-object-literal.rs:7:11
--> $DIR/impl-trait-with-missing-bounds.rs:14:13
|
LL | qux(constraint);
- | ^^^^^^^^^^ `<impl Iterator as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug`
+ | --- ^^^^^^^^^^ `<impl Iterator as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Debug` is not implemented for `<impl Iterator as Iterator>::Item`
note: required by a bound in `qux`
--> $DIR/impl-trait-with-missing-bounds.rs:22:13
|
LL | qux(constraint);
- | ^^^^^^^^^^ `<impl Iterator as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug`
+ | --- ^^^^^^^^^^ `<impl Iterator as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Debug` is not implemented for `<impl Iterator as Iterator>::Item`
note: required by a bound in `qux`
--> $DIR/impl-trait-with-missing-bounds.rs:30:13
|
LL | qux(constraint);
- | ^^^^^^^^^^ `<impl Iterator as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug`
+ | --- ^^^^^^^^^^ `<impl Iterator as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Debug` is not implemented for `<impl Iterator as Iterator>::Item`
note: required by a bound in `qux`
--> $DIR/impl-trait-with-missing-bounds.rs:37:13
|
LL | qux(constraint);
- | ^^^^^^^^^^ `<impl Iterator + std::fmt::Debug as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug`
+ | --- ^^^^^^^^^^ `<impl Iterator + std::fmt::Debug as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Debug` is not implemented for `<impl Iterator + std::fmt::Debug as Iterator>::Item`
note: required by a bound in `qux`
--> $DIR/impl-trait-with-missing-bounds.rs:6:13
|
LL | qux(constraint);
- | ^^^^^^^^^^ `<impl Iterator as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug`
+ | --- ^^^^^^^^^^ `<impl Iterator as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Debug` is not implemented for `<impl Iterator as Iterator>::Item`
note: required by a bound in `qux`
--> $DIR/impl-trait-with-missing-bounds.rs:45:13
|
LL | qux(constraint);
- | ^^^^^^^^^^ `<impl Iterator as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug`
+ | --- ^^^^^^^^^^ `<impl Iterator as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Debug` is not implemented for `<impl Iterator as Iterator>::Item`
note: required by a bound in `qux`
--> $DIR/issue-62843.rs:4:32
|
LL | println!("{:?}", line.find(pattern));
- | ^^^^^^^
- | |
- | expected an implementor of trait `Pattern<'_>`
- | help: consider borrowing here: `&pattern`
+ | ---- ^^^^^^^
+ | | |
+ | | expected an implementor of trait `Pattern<'_>`
+ | | help: consider borrowing here: `&pattern`
+ | required by a bound introduced by this call
|
= note: the trait bound `String: Pattern<'_>` is not satisfied
= note: required because of the requirements on the impl of `Pattern<'_>` for `String`
--> $DIR/issue-79843-impl-trait-with-missing-bounds-on-async-fn.rs:14:20
|
LL | assert_is_send(&bar);
- | ^^^^ `<impl Foo as Foo>::Bar` cannot be sent between threads safely
+ | -------------- ^^^^ `<impl Foo as Foo>::Bar` cannot be sent between threads safely
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Send` is not implemented for `<impl Foo as Foo>::Bar`
note: required by a bound in `assert_is_send`
--> $DIR/issue-79843-impl-trait-with-missing-bounds-on-async-fn.rs:24:20
|
LL | assert_is_send(&bar);
- | ^^^^ `<impl Foo as Foo>::Bar` cannot be sent between threads safely
+ | -------------- ^^^^ `<impl Foo as Foo>::Bar` cannot be sent between threads safely
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Send` is not implemented for `<impl Foo as Foo>::Bar`
note: required by a bound in `assert_is_send`
--> $DIR/issue-84973-2.rs:11:9
|
LL | foo(a);
- | ^
- | |
- | expected an implementor of trait `Tr`
- | help: consider mutably borrowing here: `&mut a`
+ | --- ^
+ | | |
+ | | expected an implementor of trait `Tr`
+ | | help: consider mutably borrowing here: `&mut a`
+ | required by a bound introduced by this call
|
note: required by a bound in `foo`
--> $DIR/issue-84973-2.rs:7:11
let ref_cl: &dyn Fn() -> () = &cl;
f_sized(*ref_cl);
//~^ ERROR: the size for values of type `dyn Fn()` cannot be known at compilation time [E0277]
- //~| ERROR: the size for values of type `dyn Fn()` cannot be known at compilation time [E0277]
use std::rc::Rc;
let rc = Rc::new(0);
--> $DIR/issue-84973-blacklist.rs:15:12
|
LL | f_copy("".to_string());
- | ^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
+ | ------ ^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `f_copy`
--> $DIR/issue-84973-blacklist.rs:6:14
--> $DIR/issue-84973-blacklist.rs:16:13
|
LL | f_clone(S);
- | ^ the trait `Clone` is not implemented for `S`
+ | ------- ^ the trait `Clone` is not implemented for `S`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `f_clone`
--> $DIR/issue-84973-blacklist.rs:7:15
--> $DIR/issue-84973-blacklist.rs:22:13
|
LL | f_sized(*ref_cl);
- | ^^^^^^^ doesn't have a size known at compile-time
+ | ------- ^^^^^^^ doesn't have a size known at compile-time
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Sized` is not implemented for `dyn Fn()`
note: required by a bound in `f_sized`
| ^ required by this bound in `f_sized`
error[E0277]: `Rc<{integer}>` cannot be sent between threads safely
- --> $DIR/issue-84973-blacklist.rs:28:12
+ --> $DIR/issue-84973-blacklist.rs:27:12
|
LL | f_send(rc);
- | ^^ `Rc<{integer}>` cannot be sent between threads safely
+ | ------ ^^ `Rc<{integer}>` cannot be sent between threads safely
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Send` is not implemented for `Rc<{integer}>`
note: required by a bound in `f_send`
LL | fn f_send<T: Send>(t: T) {}
| ^^^^ required by this bound in `f_send`
-error[E0277]: the size for values of type `dyn Fn()` cannot be known at compilation time
- --> $DIR/issue-84973-blacklist.rs:22:5
- |
-LL | f_sized(*ref_cl);
- | ^^^^^^^ doesn't have a size known at compile-time
- |
- = help: the trait `Sized` is not implemented for `dyn Fn()`
- = note: all function arguments must have a statically known size
- = help: unsized fn params are gated as an unstable feature
-
-error: aborting due to 6 previous errors
+error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0277`.
--> $DIR/issue-84973-negative.rs:10:9
|
LL | bar(a);
- | ^ the trait `Tr` is not implemented for `i32`
+ | --- ^ the trait `Tr` is not implemented for `i32`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `bar`
--> $DIR/issue-84973-negative.rs:5:11
--> $DIR/issue-84973-negative.rs:11:9
|
LL | bar(b);
- | ^
- | |
- | expected an implementor of trait `Tr`
- | help: consider borrowing here: `&b`
+ | --- ^
+ | | |
+ | | expected an implementor of trait `Tr`
+ | | help: consider borrowing here: `&b`
+ | required by a bound introduced by this call
|
note: required by a bound in `bar`
--> $DIR/issue-84973-negative.rs:5:11
--> $DIR/issue-84973.rs:6:24
|
LL | let o = Other::new(f);
- | ^
- | |
- | expected an implementor of trait `SomeTrait`
- | help: consider borrowing here: `&f`
+ | ---------- ^
+ | | |
+ | | expected an implementor of trait `SomeTrait`
+ | | help: consider borrowing here: `&f`
+ | required by a bound introduced by this call
|
note: required by `Other::<'a, G>::new`
--> $DIR/issue-84973.rs:27:5
--> $DIR/mut-borrow-needed-by-trait.rs:17:29
|
LL | let fp = BufWriter::new(fp);
- | ^^ the trait `std::io::Write` is not implemented for `&dyn std::io::Write`
+ | -------------- ^^ the trait `std::io::Write` is not implemented for `&dyn std::io::Write`
+ | |
+ | required by a bound introduced by this call
|
= note: `std::io::Write` is implemented for `&mut dyn std::io::Write`, but not for `&dyn std::io::Write`
note: required by `BufWriter::<W>::new`
LL | fn bar(x: &dyn Trait) {}
| ^^^^^^^^^ `Trait` cannot be made into an object
|
- = help: consider moving `baz` to another trait
- = help: consider moving `bat` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/object-unsafe-trait-references-self.rs:2:22
|
| ^^^^ ...because method `baz` references the `Self` type in this parameter
LL | fn bat(&self) -> Self {}
| ^^^^ ...because method `bat` references the `Self` type in its return type
+ = help: consider moving `baz` to another trait
+ = help: consider moving `bat` to another trait
error[E0038]: the trait `Other` cannot be made into an object
--> $DIR/object-unsafe-trait-references-self.rs:10:12
error[E0507]: cannot move out of `var`, a captured variable in an `FnMut` closure
--> $DIR/option-content-move2.rs:9:9
|
-LL | let mut var = None;
- | ------- captured outer variable
-...
-LL | move || {
- | ^^^^^^^ move out of `var` occurs here
-LL |
-LL | var = Some(NotCopyable);
- | ---
- | |
- | move occurs because `var` has type `Option<NotCopyable>`, which does not implement the `Copy` trait
- | move occurs due to use in closure
+LL | let mut var = None;
+ | ------- captured outer variable
+LL | func(|| {
+ | __________-
+LL | | // Shouldn't suggest `move ||.as_ref()` here
+LL | | move || {
+ | | ^^^^^^^ move out of `var` occurs here
+LL | |
+LL | | var = Some(NotCopyable);
+ | | ---
+ | | |
+ | | move occurs because `var` has type `Option<NotCopyable>`, which does not implement the `Copy` trait
+ | | move occurs due to use in closure
+LL | | }
+LL | | });
+ | |_____- captured by this `FnMut` closure
error: aborting due to previous error
--> $DIR/restrict-type-argument.rs:4:13
|
LL | is_send(val);
- | ^^^ `impl Sync` cannot be sent between threads safely
+ | ------- ^^^ `impl Sync` cannot be sent between threads safely
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `is_send`
--> $DIR/restrict-type-argument.rs:1:15
--> $DIR/restrict-type-argument.rs:8:13
|
LL | is_send(val);
- | ^^^ `S` cannot be sent between threads safely
+ | ------- ^^^ `S` cannot be sent between threads safely
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `is_send`
--> $DIR/restrict-type-argument.rs:1:15
--> $DIR/restrict-type-argument.rs:12:13
|
LL | is_send(val);
- | ^^^ `S` cannot be sent between threads safely
+ | ------- ^^^ `S` cannot be sent between threads safely
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `is_send`
--> $DIR/restrict-type-argument.rs:1:15
--> $DIR/restrict-type-argument.rs:20:13
|
LL | is_send(val);
- | ^^^ `S` cannot be sent between threads safely
+ | ------- ^^^ `S` cannot be sent between threads safely
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `is_send`
--> $DIR/restrict-type-argument.rs:1:15
--> $DIR/restrict-type-argument.rs:24:13
|
LL | is_send(val);
- | ^^^ `S` cannot be sent between threads safely
+ | ------- ^^^ `S` cannot be sent between threads safely
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `is_send`
--> $DIR/restrict-type-argument.rs:1:15
--> $DIR/restrict-type-argument.rs:28:13
|
LL | is_send(val);
- | ^^^ `S` cannot be sent between threads safely
+ | ------- ^^^ `S` cannot be sent between threads safely
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `is_send`
--> $DIR/restrict-type-argument.rs:1:15
--> $DIR/suggest-change-mut.rs:12:48
|
LL | let mut stream_reader = BufReader::new(&stream);
- | ^^^^^^^ the trait `std::io::Read` is not implemented for `&T`
+ | -------------- ^^^^^^^ the trait `std::io::Read` is not implemented for `&T`
+ | |
+ | required by a bound introduced by this call
|
note: required by `BufReader::<R>::new`
--> $SRC_DIR/std/src/io/buffered/bufreader.rs:LL:COL
--- /dev/null
+// build-pass
+
+// This test is the same code as in ui/symbol-names/issue-60925.rs but this checks that the
+// reproduction compiles successfully and doesn't segfault, whereas that test just checks that the
+// symbol mangling fix produces the correct result.
+
+fn dummy() {}
+
+mod llvm {
+ pub(crate) struct Foo;
+}
+mod foo {
+ pub(crate) struct Foo<T>(T);
+
+ impl Foo<::llvm::Foo> {
+ pub(crate) fn foo() {
+ for _ in 0..0 {
+ for _ in &[::dummy()] {
+ ::dummy();
+ ::dummy();
+ ::dummy();
+ }
+ }
+ }
+ }
+
+ pub(crate) fn foo() {
+ Foo::foo();
+ Foo::foo();
+ }
+}
+
+pub fn foo() {
+ foo::foo();
+}
+
+fn main() {}
--- /dev/null
+// run-pass
+// compile-flags:--test
+#![deny(private_in_public)]
+
+#[test] fn foo() {}
+mod foo {}
+
+#[test] fn core() {}
+extern crate core;
--- /dev/null
+// run-pass
+// ignore-emscripten no threads support
+// compile-flags: -O
+
+#![feature(thread_local)]
+
+#[thread_local]
+static S: u32 = 222;
+
+fn main() {
+ let local = &S as *const u32 as usize;
+ let foreign = std::thread::spawn(|| &S as *const u32 as usize).join().unwrap();
+ assert_ne!(local, foreign);
+}
+++ /dev/null
-// run-pass
-// ignore-emscripten no threads support
-// compile-flags: -O
-
-#![feature(thread_local)]
-
-#[thread_local]
-static S: u32 = 222;
-
-fn main() {
- let local = &S as *const u32 as usize;
- let foreign = std::thread::spawn(|| &S as *const u32 as usize).join().unwrap();
- assert_ne!(local, foreign);
-}
--> $DIR/same-crate-name.rs:31:20
|
LL | a::try_foo(foo);
- | ^^^ the trait `main::a::Bar` is not implemented for `Foo`
+ | ---------- ^^^ the trait `main::a::Bar` is not implemented for `Foo`
+ | |
+ | required by a bound introduced by this call
|
help: trait impl with same name found
--> $DIR/auxiliary/crate_a2.rs:5:1
--> $DIR/same-crate-name.rs:38:20
|
LL | a::try_foo(implements_no_traits);
- | ^^^^^^^^^^^^^^^^^^^^ the trait `main::a::Bar` is not implemented for `DoesNotImplementTrait`
+ | ---------- ^^^^^^^^^^^^^^^^^^^^ the trait `main::a::Bar` is not implemented for `DoesNotImplementTrait`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `try_foo`
--> $DIR/auxiliary/crate_a1.rs:3:24
--> $DIR/same-crate-name.rs:45:20
|
LL | a::try_foo(other_variant_implements_mismatched_trait);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `main::a::Bar` is not implemented for `ImplementsWrongTraitConditionally<isize>`
+ | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `main::a::Bar` is not implemented for `ImplementsWrongTraitConditionally<isize>`
+ | |
+ | required by a bound introduced by this call
|
help: trait impl with same name found
--> $DIR/auxiliary/crate_a2.rs:13:1
--> $DIR/same-crate-name.rs:51:20
|
LL | a::try_foo(other_variant_implements_correct_trait);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `main::a::Bar` is not implemented for `ImplementsTraitForUsize<isize>`
+ | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `main::a::Bar` is not implemented for `ImplementsTraitForUsize<isize>`
+ | |
+ | required by a bound introduced by this call
|
= help: the following implementations were found:
<ImplementsTraitForUsize<usize> as main::a::Bar>
--- /dev/null
+// run-pass
+
+trait Speak : Sized {
+ fn say(&self, s:&str) -> String;
+ fn hi(&self) -> String { hello(self) }
+}
+
+fn hello<S:Speak>(s:&S) -> String{
+ s.say("hello")
+}
+
+impl Speak for isize {
+ fn say(&self, s:&str) -> String {
+ format!("{}: {}", s, *self)
+ }
+}
+
+impl<T: Speak> Speak for Option<T> {
+ fn say(&self, s:&str) -> String {
+ match *self {
+ None => format!("{} - none", s),
+ Some(ref x) => { format!("something!{}", x.say(s)) }
+ }
+ }
+}
+
+
+pub fn main() {
+ assert_eq!(3.hi(), "hello: 3".to_string());
+ assert_eq!(Some(Some(3)).hi(),
+ "something!something!hello: 3".to_string());
+ assert_eq!(None::<isize>.hi(), "hello - none".to_string());
+
+ assert_eq!(Some(None::<isize>).hi(), "something!hello - none".to_string());
+ assert_eq!(Some(3).hi(), "something!hello: 3".to_string());
+}
--> $DIR/supertrait-auto-trait.rs:16:23
|
LL | let (a, b) = copy(NoClone);
- | ^^^^^^^ the trait `Copy` is not implemented for `NoClone`
+ | ---- ^^^^^^^ the trait `Copy` is not implemented for `NoClone`
+ | |
+ | required by a bound introduced by this call
|
= note: required because of the requirements on the impl of `Magic` for `NoClone`
note: required by a bound in `copy`
--- /dev/null
+trait Array: Sized + Copy {}
+
+fn f<T: Array>(x: &T) {
+ let _ = x
+ //~^ ERROR `Array` cannot be made into an object
+ as
+ &dyn Array;
+ //~^ ERROR `Array` cannot be made into an object
+}
+
+fn main() {}
--- /dev/null
+error[E0038]: the trait `Array` cannot be made into an object
+ --> $DIR/issue-20692.rs:7:5
+ |
+LL | &dyn Array;
+ | ^^^^^^^^^^ `Array` cannot be made into an object
+ |
+note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
+ --> $DIR/issue-20692.rs:1:14
+ |
+LL | trait Array: Sized + Copy {}
+ | ----- ^^^^^ ^^^^ ...because it requires `Self: Sized`
+ | | |
+ | | ...because it requires `Self: Sized`
+ | this trait cannot be made into an object...
+
+error[E0038]: the trait `Array` cannot be made into an object
+ --> $DIR/issue-20692.rs:4:13
+ |
+LL | let _ = x
+ | ^ `Array` cannot be made into an object
+ |
+note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
+ --> $DIR/issue-20692.rs:1:14
+ |
+LL | trait Array: Sized + Copy {}
+ | ----- ^^^^^ ^^^^ ...because it requires `Self: Sized`
+ | | |
+ | | ...because it requires `Self: Sized`
+ | this trait cannot be made into an object...
+ = note: required because of the requirements on the impl of `CoerceUnsized<&dyn Array>` for `&T`
+ = note: required by cast to type `&dyn Array`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0038`.
--- /dev/null
+// run-pass
+trait Stringify {
+ fn to_string(&self) -> String;
+}
+
+impl Stringify for u32 {
+ fn to_string(&self) -> String { format!("u32: {}", *self) }
+}
+
+impl Stringify for f32 {
+ fn to_string(&self) -> String { format!("f32: {}", *self) }
+}
+
+fn print<T: Stringify>(x: T) -> String {
+ x.to_string()
+}
+
+fn main() {
+ assert_eq!(&print(5), "u32: 5");
+ assert_eq!(&print(5.0), "f32: 5");
+}
LL | <dyn C>::A;
| ^^^^^ `assoc_const::C` cannot be made into an object
|
- = help: consider moving `C` to another trait
- = help: consider moving `B` to another trait
- = help: consider moving `A` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/item-privacy.rs:25:15
|
| - this trait cannot be made into an object...
LL | const C: u8 = 0;
| ^ ...because it contains this associated `const`
+ = help: consider moving `C` to another trait
+ = help: consider moving `A` to another trait
+ = help: consider moving `B` to another trait
error[E0223]: ambiguous associated type
--> $DIR/item-privacy.rs:115:12
--> $DIR/negated-auto-traits-error.rs:23:11
|
LL | Outer(TestType);
- | ^^^^^^^^ `dummy::TestType` cannot be sent between threads safely
+ | ----- ^^^^^^^^ `dummy::TestType` cannot be sent between threads safely
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Send` is not implemented for `dummy::TestType`
note: required by `Outer`
--> $DIR/negated-auto-traits-error.rs:32:13
|
LL | is_send(TestType);
- | ^^^^^^^^ `dummy1b::TestType` cannot be sent between threads safely
+ | ------- ^^^^^^^^ `dummy1b::TestType` cannot be sent between threads safely
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Send` is not implemented for `dummy1b::TestType`
note: required by a bound in `is_send`
--> $DIR/negated-auto-traits-error.rs:40:13
|
LL | is_send((8, TestType));
- | ^^^^^^^^^^^^^ `dummy1c::TestType` cannot be sent between threads safely
+ | ------- ^^^^^^^^^^^^^ `dummy1c::TestType` cannot be sent between threads safely
+ | |
+ | required by a bound introduced by this call
|
- = help: within `({integer}, dummy1c::TestType)`, the trait `Send` is not implemented for `dummy1c::TestType`
+ = help: the trait `Send` is not implemented for `dummy1c::TestType`
= note: required because it appears within the type `({integer}, dummy1c::TestType)`
note: required by a bound in `is_send`
--> $DIR/negated-auto-traits-error.rs:16:15
--> $DIR/negated-auto-traits-error.rs:48:13
|
LL | is_send(Box::new(TestType));
- | ^^^^^^^^^^^^^^^^^^
- | |
- | expected an implementor of trait `Send`
- | help: consider borrowing here: `&Box::new(TestType)`
+ | ------- ^^^^^^^^^^^^^^^^^^
+ | | |
+ | | expected an implementor of trait `Send`
+ | | help: consider borrowing here: `&Box::new(TestType)`
+ | required by a bound introduced by this call
|
= note: the trait bound `dummy2::TestType: Send` is not satisfied
= note: required because of the requirements on the impl of `Send` for `Unique<dummy2::TestType>`
--> $DIR/negated-auto-traits-error.rs:56:13
|
LL | is_send(Box::new(Outer2(TestType)));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `dummy3::TestType` cannot be sent between threads safely
+ | ------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ `dummy3::TestType` cannot be sent between threads safely
+ | |
+ | required by a bound introduced by this call
|
- = help: within `Outer2<dummy3::TestType>`, the trait `Send` is not implemented for `dummy3::TestType`
+ = help: the trait `Send` is not implemented for `dummy3::TestType`
note: required because it appears within the type `Outer2<dummy3::TestType>`
--> $DIR/negated-auto-traits-error.rs:12:8
|
--> $DIR/negated-auto-traits-error.rs:66:13
|
LL | is_sync(Outer2(TestType));
- | ^^^^^^^^^^^^^^^^
- | |
- | expected an implementor of trait `Sync`
- | help: consider borrowing here: `&Outer2(TestType)`
+ | ------- ^^^^^^^^^^^^^^^^
+ | | |
+ | | expected an implementor of trait `Sync`
+ | | help: consider borrowing here: `&Outer2(TestType)`
+ | required by a bound introduced by this call
|
= note: the trait bound `main::TestType: Sync` is not satisfied
note: required because of the requirements on the impl of `Sync` for `Outer2<main::TestType>`
--> $DIR/no-use.rs:10:26
|
LL | <() as MyTrait>::foo(&());
- | ^^^ the trait `MyTrait` is not implemented for `()`
+ | -------------------- ^^^ the trait `MyTrait` is not implemented for `()`
+ | |
+ | required by a bound introduced by this call
|
= help: the following implementations were found:
<() as MyTrait>
--> $DIR/issue-39029.rs:16:37
|
LL | let _errors = TcpListener::bind(&bad);
- | ^^^^
- | |
- | the trait `ToSocketAddrs` is not implemented for `NoToSocketAddrs`
- | help: consider adding dereference here: `&*bad`
+ | ----------------- ^^^^
+ | | |
+ | | the trait `ToSocketAddrs` is not implemented for `NoToSocketAddrs`
+ | | help: consider adding dereference here: `&*bad`
+ | required by a bound introduced by this call
|
= note: required because of the requirements on the impl of `ToSocketAddrs` for `&NoToSocketAddrs`
note: required by a bound in `TcpListener::bind`
--> $DIR/issue-62530.rs:13:26
|
LL | takes_type_parameter(&string); // Error
- | ^^^^^^^
- | |
- | the trait `SomeTrait` is not implemented for `&String`
- | help: consider adding dereference here: `&*string`
+ | -------------------- ^^^^^^^
+ | | |
+ | | the trait `SomeTrait` is not implemented for `&String`
+ | | help: consider adding dereference here: `&*string`
+ | required by a bound introduced by this call
|
note: required by a bound in `takes_type_parameter`
--> $DIR/issue-62530.rs:4:44
--> $DIR/multiple-0.rs:34:9
|
LL | foo(&baz);
- | ^^^^
- | |
- | the trait `Happy` is not implemented for `&Baz`
- | help: consider adding dereference here: `&***baz`
+ | --- ^^^^
+ | | |
+ | | the trait `Happy` is not implemented for `&Baz`
+ | | help: consider adding dereference here: `&***baz`
+ | required by a bound introduced by this call
|
note: required by a bound in `foo`
--> $DIR/multiple-0.rs:30:26
--> $DIR/multiple-1.rs:52:9
|
LL | foo(&mut baz);
- | ^^^^^^^^ the trait `Happy` is not implemented for `&mut Baz`
+ | --- ^^^^^^^^ the trait `Happy` is not implemented for `&mut Baz`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `foo`
--> $DIR/multiple-1.rs:45:26
LL | (box 10 as Box<dyn bar>).dup();
| ^^^^^^^^^^^^ `bar` cannot be made into an object
|
- = help: consider moving `dup` to another trait
- = help: consider moving `blah` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/test-2.rs:4:30
|
| | |
| | ...because method `dup` references the `Self` type in its return type
| this trait cannot be made into an object...
+ = help: consider moving `dup` to another trait
+ = help: consider moving `blah` to another trait
error[E0038]: the trait `bar` cannot be made into an object
--> $DIR/test-2.rs:13:6
LL | (box 10 as Box<dyn bar>).dup();
| ^^^^^^ `bar` cannot be made into an object
|
- = help: consider moving `dup` to another trait
- = help: consider moving `blah` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/test-2.rs:4:30
|
| | |
| | ...because method `dup` references the `Self` type in its return type
| this trait cannot be made into an object...
+ = help: consider moving `dup` to another trait
+ = help: consider moving `blah` to another trait
= note: required because of the requirements on the impl of `CoerceUnsized<Box<dyn bar>>` for `Box<{integer}>`
= note: required by cast to type `Box<dyn bar>`
--> $DIR/trivial-bounds-leak.rs:25:15
|
LL | Foo::test(&4i32);
- | ^^^^^ the trait `Foo` is not implemented for `i32`
+ | --------- ^^^^^ the trait `Foo` is not implemented for `i32`
+ | |
+ | required by a bound introduced by this call
|
note: required by `Foo::test`
--> $DIR/trivial-bounds-leak.rs:5:5
--> $DIR/trivial-bounds-leak.rs:26:22
|
LL | generic_function(5i32);
- | ^^^^ the trait `Foo` is not implemented for `i32`
+ | ---------------- ^^^^ the trait `Foo` is not implemented for `i32`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `generic_function`
--> $DIR/trivial-bounds-leak.rs:29:24
LL | let y = x as dyn MyAdd<i32>;
| ^^^^^^^^^^^^^^ `MyAdd` cannot be made into an object
|
- = help: consider moving `add` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/type-parameter-defaults-referencing-Self-ppaux.rs:6:55
|
| ----- ^^^^ ...because method `add` references the `Self` type in its return type
| |
| this trait cannot be made into an object...
+ = help: consider moving `add` to another trait
error: aborting due to 2 previous errors
--- /dev/null
+// run-rustfix
+
+fn main() {
+ let a = Some(42);
+ println!(
+ "The value is {}.",
+ a.unwrap() //~ERROR [E0615]
+ );
+}
--- /dev/null
+// run-rustfix
+
+fn main() {
+ let a = Some(42);
+ println!(
+ "The value is {}.",
+ (a.unwrap)() //~ERROR [E0615]
+ );
+}
--- /dev/null
+error[E0615]: attempted to take value of method `unwrap` on type `Option<{integer}>`
+ --> $DIR/issue-88803-call-expr-method.rs:7:12
+ |
+LL | (a.unwrap)()
+ | ^^^^^^ method, not a field
+ |
+help: remove wrapping parentheses to call the method
+ |
+LL - (a.unwrap)()
+LL + a.unwrap()
+ |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0615`.
--- /dev/null
+// Regression test for #88844.
+
+struct Struct { value: i32 }
+//~^ NOTE: similarly named struct `Struct` defined here
+
+impl Stuct {
+//~^ ERROR: cannot find type `Stuct` in this scope [E0412]
+//~| HELP: a struct with a similar name exists
+ fn new() -> Self {
+ Self { value: 42 }
+ }
+}
+
+fn main() {}
--- /dev/null
+error[E0412]: cannot find type `Stuct` in this scope
+ --> $DIR/issue-88844.rs:6:6
+ |
+LL | struct Struct { value: i32 }
+ | ------------- similarly named struct `Struct` defined here
+...
+LL | impl Stuct {
+ | ^^^^^ help: a struct with a similar name exists: `Struct`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0412`.
--> $DIR/typeck-unsafe-always-share.rs:19:10
|
LL | test(us);
- | ^^ `UnsafeCell<MySync<{integer}>>` cannot be shared between threads safely
+ | ---- ^^ `UnsafeCell<MySync<{integer}>>` cannot be shared between threads safely
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Sync` is not implemented for `UnsafeCell<MySync<{integer}>>`
note: required by a bound in `test`
--> $DIR/typeck-unsafe-always-share.rs:23:10
|
LL | test(uns);
- | ^^^ `UnsafeCell<NoSync>` cannot be shared between threads safely
+ | ---- ^^^ `UnsafeCell<NoSync>` cannot be shared between threads safely
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Sync` is not implemented for `UnsafeCell<NoSync>`
note: required by a bound in `test`
--> $DIR/typeck-unsafe-always-share.rs:30:10
|
LL | test(NoSync);
- | ^^^^^^ `NoSync` cannot be shared between threads safely
+ | ---- ^^^^^^ `NoSync` cannot be shared between threads safely
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Sync` is not implemented for `NoSync`
note: required by a bound in `test`
LL | let x = Box::new(0);
| - captured outer variable
LL | let f = to_fn(|| drop(x));
- | ^ move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait
+ | --------^-
+ | | |
+ | | move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait
+ | captured by this `Fn` closure
error[E0507]: cannot move out of `x`, a captured variable in an `FnMut` closure
--> $DIR/unboxed-closure-illegal-move.rs:19:35
LL | let x = Box::new(0);
| - captured outer variable
LL | let f = to_fn_mut(|| drop(x));
- | ^ move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait
+ | --------^-
+ | | |
+ | | move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait
+ | captured by this `FnMut` closure
error[E0507]: cannot move out of `x`, a captured variable in an `Fn` closure
--> $DIR/unboxed-closure-illegal-move.rs:28:36
LL | let x = Box::new(0);
| - captured outer variable
LL | let f = to_fn(move || drop(x));
- | ^ move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait
+ | -------------^-
+ | | |
+ | | move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait
+ | captured by this `Fn` closure
error[E0507]: cannot move out of `x`, a captured variable in an `FnMut` closure
--> $DIR/unboxed-closure-illegal-move.rs:32:40
LL | let x = Box::new(0);
| - captured outer variable
LL | let f = to_fn_mut(move || drop(x));
- | ^ move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait
+ | -------------^-
+ | | |
+ | | move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait
+ | captured by this `FnMut` closure
error: aborting due to 4 previous errors
--> $DIR/unboxed-closures-fnmut-as-fn.rs:28:21
|
LL | let x = call_it(&S, 22);
- | ^^ expected an `Fn<(isize,)>` closure, found `S`
+ | ------- ^^ expected an `Fn<(isize,)>` closure, found `S`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `Fn<(isize,)>` is not implemented for `S`
note: required by a bound in `call_it`
--> $DIR/unboxed-closures-unsafe-extern-fn.rs:20:21
|
LL | let x = call_it(&square, 22);
- | ^^^^^^^ expected an `Fn<(&isize,)>` closure, found `for<'r> unsafe fn(&'r isize) -> isize {square}`
+ | ------- ^^^^^^^ expected an `Fn<(&isize,)>` closure, found `for<'r> unsafe fn(&'r isize) -> isize {square}`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `for<'r> Fn<(&'r isize,)>` is not implemented for `for<'r> unsafe fn(&'r isize) -> isize {square}`
note: required by a bound in `call_it`
--> $DIR/unboxed-closures-unsafe-extern-fn.rs:25:25
|
LL | let y = call_it_mut(&mut square, 22);
- | ^^^^^^^^^^^ expected an `FnMut<(&isize,)>` closure, found `for<'r> unsafe fn(&'r isize) -> isize {square}`
+ | ----------- ^^^^^^^^^^^ expected an `FnMut<(&isize,)>` closure, found `for<'r> unsafe fn(&'r isize) -> isize {square}`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `for<'r> FnMut<(&'r isize,)>` is not implemented for `for<'r> unsafe fn(&'r isize) -> isize {square}`
note: required by a bound in `call_it_mut`
--> $DIR/unboxed-closures-unsafe-extern-fn.rs:30:26
|
LL | let z = call_it_once(square, 22);
- | ^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `for<'r> unsafe fn(&'r isize) -> isize {square}`
+ | ------------ ^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `for<'r> unsafe fn(&'r isize) -> isize {square}`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `for<'r> FnOnce<(&'r isize,)>` is not implemented for `for<'r> unsafe fn(&'r isize) -> isize {square}`
note: required by a bound in `call_it_once`
--> $DIR/unboxed-closures-wrong-abi.rs:20:21
|
LL | let x = call_it(&square, 22);
- | ^^^^^^^ expected an `Fn<(&isize,)>` closure, found `for<'r> extern "C" fn(&'r isize) -> isize {square}`
+ | ------- ^^^^^^^ expected an `Fn<(&isize,)>` closure, found `for<'r> extern "C" fn(&'r isize) -> isize {square}`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `for<'r> Fn<(&'r isize,)>` is not implemented for `for<'r> extern "C" fn(&'r isize) -> isize {square}`
note: required by a bound in `call_it`
--> $DIR/unboxed-closures-wrong-abi.rs:25:25
|
LL | let y = call_it_mut(&mut square, 22);
- | ^^^^^^^^^^^ expected an `FnMut<(&isize,)>` closure, found `for<'r> extern "C" fn(&'r isize) -> isize {square}`
+ | ----------- ^^^^^^^^^^^ expected an `FnMut<(&isize,)>` closure, found `for<'r> extern "C" fn(&'r isize) -> isize {square}`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `for<'r> FnMut<(&'r isize,)>` is not implemented for `for<'r> extern "C" fn(&'r isize) -> isize {square}`
note: required by a bound in `call_it_mut`
--> $DIR/unboxed-closures-wrong-abi.rs:30:26
|
LL | let z = call_it_once(square, 22);
- | ^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `for<'r> extern "C" fn(&'r isize) -> isize {square}`
+ | ------------ ^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `for<'r> extern "C" fn(&'r isize) -> isize {square}`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `for<'r> FnOnce<(&'r isize,)>` is not implemented for `for<'r> extern "C" fn(&'r isize) -> isize {square}`
note: required by a bound in `call_it_once`
--> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:21:21
|
LL | let x = call_it(&square, 22);
- | ^^^^^^^ expected an `Fn<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}`
+ | ------- ^^^^^^^ expected an `Fn<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `for<'r> Fn<(&'r isize,)>` is not implemented for `unsafe fn(isize) -> isize {square}`
note: required by a bound in `call_it`
--> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:26:25
|
LL | let y = call_it_mut(&mut square, 22);
- | ^^^^^^^^^^^ expected an `FnMut<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}`
+ | ----------- ^^^^^^^^^^^ expected an `FnMut<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `for<'r> FnMut<(&'r isize,)>` is not implemented for `unsafe fn(isize) -> isize {square}`
note: required by a bound in `call_it_mut`
--> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:31:26
|
LL | let z = call_it_once(square, 22);
- | ^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}`
+ | ------------ ^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}`
+ | |
+ | required by a bound introduced by this call
|
= help: the trait `for<'r> FnOnce<(&'r isize,)>` is not implemented for `unsafe fn(isize) -> isize {square}`
note: required by a bound in `call_it_once`
+++ /dev/null
-#![allow(incomplete_features)]
-#![feature(unnamed_fields)]
-
-fn f() -> struct { field: u8 } {} //~ ERROR anonymous structs are not allowed outside of unnamed struct or union fields
-//~^ ERROR anonymous structs are unimplemented
-
-fn f2(a: struct { field: u8 } ) {} //~ ERROR anonymous structs are not allowed outside of unnamed struct or union fields
-//~^ ERROR anonymous structs are unimplemented
-
-union G {
- field: struct { field: u8 } //~ ERROR anonymous structs are not allowed outside of unnamed struct or union fields
- //~^ ERROR anonymous structs are unimplemented
-}
-//~| ERROR unions may not contain fields that need dropping [E0740]
-
-struct H { _: u8 } // Should error after hir checks
-
-struct I(struct { field: u8 }, u8); //~ ERROR anonymous structs are not allowed outside of unnamed struct or union fields
-//~^ ERROR anonymous structs are unimplemented
-
-enum J {
- K(struct { field: u8 }), //~ ERROR anonymous structs are not allowed outside of unnamed struct or union fields
- //~^ ERROR anonymous structs are unimplemented
- L {
- _ : struct { field: u8 } //~ ERROR anonymous structs are not allowed outside of unnamed struct or union fields
- //~^ ERROR anonymous fields are not allowed outside of structs or unions
- //~| ERROR anonymous structs are unimplemented
- },
- M {
- _ : u8 //~ ERROR anonymous fields are not allowed outside of structs or unions
- }
-}
-
-static M: union { field: u8 } = 0; //~ ERROR anonymous unions are not allowed outside of unnamed struct or union fields
-//~^ ERROR anonymous unions are unimplemented
-
-type N = union { field: u8 }; //~ ERROR anonymous unions are not allowed outside of unnamed struct or union fields
-//~^ ERROR anonymous unions are unimplemented
-
-fn main() {
- const O: struct { field: u8 } = 0; //~ ERROR anonymous structs are not allowed outside of unnamed struct or union fields
- //~^ ERROR anonymous structs are unimplemented
-
- let p: [struct { field: u8 }; 1]; //~ ERROR anonymous structs are not allowed outside of unnamed struct or union fields
- //~^ ERROR anonymous structs are unimplemented
-
- let q: (struct { field: u8 }, u8); //~ ERROR anonymous structs are not allowed outside of unnamed struct or union fields
- //~^ ERROR anonymous structs are unimplemented
-
- let cl = || -> struct { field: u8 } {}; //~ ERROR anonymous structs are not allowed outside of unnamed struct or union fields
- //~^ ERROR anonymous structs are unimplemented
-}
+++ /dev/null
-error: anonymous structs are not allowed outside of unnamed struct or union fields
- --> $DIR/restrict_anonymous.rs:4:11
- |
-LL | fn f() -> struct { field: u8 } {}
- | ^^^^^^^^^^^^^^^^^^^^ anonymous struct declared here
-
-error: anonymous structs are not allowed outside of unnamed struct or union fields
- --> $DIR/restrict_anonymous.rs:7:10
- |
-LL | fn f2(a: struct { field: u8 } ) {}
- | ^^^^^^^^^^^^^^^^^^^^ anonymous struct declared here
-
-error: anonymous structs are not allowed outside of unnamed struct or union fields
- --> $DIR/restrict_anonymous.rs:11:12
- |
-LL | field: struct { field: u8 }
- | ^^^^^^^^^^^^^^^^^^^^ anonymous struct declared here
-
-error: anonymous structs are not allowed outside of unnamed struct or union fields
- --> $DIR/restrict_anonymous.rs:18:10
- |
-LL | struct I(struct { field: u8 }, u8);
- | ^^^^^^^^^^^^^^^^^^^^ anonymous struct declared here
-
-error: anonymous structs are not allowed outside of unnamed struct or union fields
- --> $DIR/restrict_anonymous.rs:22:7
- |
-LL | K(struct { field: u8 }),
- | ^^^^^^^^^^^^^^^^^^^^ anonymous struct declared here
-
-error: anonymous fields are not allowed outside of structs or unions
- --> $DIR/restrict_anonymous.rs:25:9
- |
-LL | _ : struct { field: u8 }
- | -^^^^^^^^^^^^^^^^^^^^^^^
- | |
- | anonymous field declared here
-
-error: anonymous structs are not allowed outside of unnamed struct or union fields
- --> $DIR/restrict_anonymous.rs:25:13
- |
-LL | _ : struct { field: u8 }
- | ^^^^^^^^^^^^^^^^^^^^ anonymous struct declared here
-
-error: anonymous fields are not allowed outside of structs or unions
- --> $DIR/restrict_anonymous.rs:30:9
- |
-LL | _ : u8
- | -^^^^^
- | |
- | anonymous field declared here
-
-error: anonymous unions are not allowed outside of unnamed struct or union fields
- --> $DIR/restrict_anonymous.rs:34:11
- |
-LL | static M: union { field: u8 } = 0;
- | ^^^^^^^^^^^^^^^^^^^ anonymous union declared here
-
-error: anonymous unions are not allowed outside of unnamed struct or union fields
- --> $DIR/restrict_anonymous.rs:37:10
- |
-LL | type N = union { field: u8 };
- | ^^^^^^^^^^^^^^^^^^^ anonymous union declared here
-
-error: anonymous structs are not allowed outside of unnamed struct or union fields
- --> $DIR/restrict_anonymous.rs:41:14
- |
-LL | const O: struct { field: u8 } = 0;
- | ^^^^^^^^^^^^^^^^^^^^ anonymous struct declared here
-
-error: anonymous structs are not allowed outside of unnamed struct or union fields
- --> $DIR/restrict_anonymous.rs:44:13
- |
-LL | let p: [struct { field: u8 }; 1];
- | ^^^^^^^^^^^^^^^^^^^^ anonymous struct declared here
-
-error: anonymous structs are not allowed outside of unnamed struct or union fields
- --> $DIR/restrict_anonymous.rs:47:13
- |
-LL | let q: (struct { field: u8 }, u8);
- | ^^^^^^^^^^^^^^^^^^^^ anonymous struct declared here
-
-error: anonymous structs are not allowed outside of unnamed struct or union fields
- --> $DIR/restrict_anonymous.rs:50:20
- |
-LL | let cl = || -> struct { field: u8 } {};
- | ^^^^^^^^^^^^^^^^^^^^ anonymous struct declared here
-
-error: anonymous structs are unimplemented
- --> $DIR/restrict_anonymous.rs:4:11
- |
-LL | fn f() -> struct { field: u8 } {}
- | ^^^^^^^^^^^^^^^^^^^^
-
-error: anonymous structs are unimplemented
- --> $DIR/restrict_anonymous.rs:7:10
- |
-LL | fn f2(a: struct { field: u8 } ) {}
- | ^^^^^^^^^^^^^^^^^^^^
-
-error: anonymous structs are unimplemented
- --> $DIR/restrict_anonymous.rs:11:12
- |
-LL | field: struct { field: u8 }
- | ^^^^^^^^^^^^^^^^^^^^
-
-error: anonymous structs are unimplemented
- --> $DIR/restrict_anonymous.rs:18:10
- |
-LL | struct I(struct { field: u8 }, u8);
- | ^^^^^^^^^^^^^^^^^^^^
-
-error: anonymous structs are unimplemented
- --> $DIR/restrict_anonymous.rs:22:7
- |
-LL | K(struct { field: u8 }),
- | ^^^^^^^^^^^^^^^^^^^^
-
-error: anonymous structs are unimplemented
- --> $DIR/restrict_anonymous.rs:25:13
- |
-LL | _ : struct { field: u8 }
- | ^^^^^^^^^^^^^^^^^^^^
-
-error: anonymous unions are unimplemented
- --> $DIR/restrict_anonymous.rs:34:11
- |
-LL | static M: union { field: u8 } = 0;
- | ^^^^^^^^^^^^^^^^^^^
-
-error: anonymous unions are unimplemented
- --> $DIR/restrict_anonymous.rs:37:10
- |
-LL | type N = union { field: u8 };
- | ^^^^^^^^^^^^^^^^^^^
-
-error: anonymous structs are unimplemented
- --> $DIR/restrict_anonymous.rs:44:13
- |
-LL | let p: [struct { field: u8 }; 1];
- | ^^^^^^^^^^^^^^^^^^^^
-
-error: anonymous structs are unimplemented
- --> $DIR/restrict_anonymous.rs:47:13
- |
-LL | let q: (struct { field: u8 }, u8);
- | ^^^^^^^^^^^^^^^^^^^^
-
-error: anonymous structs are unimplemented
- --> $DIR/restrict_anonymous.rs:50:20
- |
-LL | let cl = || -> struct { field: u8 } {};
- | ^^^^^^^^^^^^^^^^^^^^
-
-error: anonymous structs are unimplemented
- --> $DIR/restrict_anonymous.rs:41:14
- |
-LL | const O: struct { field: u8 } = 0;
- | ^^^^^^^^^^^^^^^^^^^^
-
-error[E0740]: unions may not contain fields that need dropping
- --> $DIR/restrict_anonymous.rs:11:5
- |
-LL | field: struct { field: u8 }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
- |
-note: `std::mem::ManuallyDrop` can be used to wrap the type
- --> $DIR/restrict_anonymous.rs:11:5
- |
-LL | field: struct { field: u8 }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: aborting due to 27 previous errors
-
-For more information about this error, try `rustc --explain E0740`.
--- /dev/null
+error: unnecessary `unsafe` block
+ --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:10:13
+ |
+LL | unsafe {
+ | ------ because it's nested under this `unsafe` block
+LL | let f = |v: &mut Vec<_>| {
+LL | unsafe {
+ | ^^^^^^ unnecessary `unsafe` block
+ |
+note: the lint level is defined here
+ --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:4:8
+ |
+LL | #[deny(unused_unsafe)]
+ | ^^^^^^^^^^^^^
+
+error: unnecessary `unsafe` block
+ --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:12:38
+ |
+LL | unsafe {
+ | ------ because it's nested under this `unsafe` block
+...
+LL | |w: &mut Vec<u32>| { unsafe {
+ | ^^^^^^ unnecessary `unsafe` block
+
+error: unnecessary `unsafe` block
+ --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:16:34
+ |
+LL | unsafe {
+ | ------ because it's nested under this `unsafe` block
+...
+LL | |x: &mut Vec<u32>| { unsafe {
+ | ^^^^^^ unnecessary `unsafe` block
+
+error: aborting due to 3 previous errors
+
--- /dev/null
+// revisions: mir thir
+// [thir]compile-flags: -Zthir-unsafeck
+
+#[deny(unused_unsafe)]
+fn main() {
+ let mut v = Vec::<i32>::with_capacity(24);
+
+ unsafe {
+ let f = |v: &mut Vec<_>| {
+ unsafe { //~ ERROR unnecessary `unsafe`
+ v.set_len(24);
+ |w: &mut Vec<u32>| { unsafe { //~ ERROR unnecessary `unsafe`
+ w.set_len(32);
+ } };
+ }
+ |x: &mut Vec<u32>| { unsafe { //~ ERROR unnecessary `unsafe`
+ x.set_len(40);
+ } };
+ };
+
+ v.set_len(0);
+ f(&mut v);
+ }
+
+ |y: &mut Vec<u32>| { unsafe {
+ y.set_len(48);
+ } };
+}
--- /dev/null
+error: unnecessary `unsafe` block
+ --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:10:13
+ |
+LL | unsafe {
+ | ------ because it's nested under this `unsafe` block
+LL | let f = |v: &mut Vec<_>| {
+LL | unsafe {
+ | ^^^^^^ unnecessary `unsafe` block
+ |
+note: the lint level is defined here
+ --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:4:8
+ |
+LL | #[deny(unused_unsafe)]
+ | ^^^^^^^^^^^^^
+
+error: unnecessary `unsafe` block
+ --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:12:38
+ |
+LL | unsafe {
+ | ------ because it's nested under this `unsafe` block
+...
+LL | |w: &mut Vec<u32>| { unsafe {
+ | ^^^^^^ unnecessary `unsafe` block
+
+error: unnecessary `unsafe` block
+ --> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:16:34
+ |
+LL | unsafe {
+ | ------ because it's nested under this `unsafe` block
+...
+LL | |x: &mut Vec<u32>| { unsafe {
+ | ^^^^^^ unnecessary `unsafe` block
+
+error: aborting due to 3 previous errors
+
--> $DIR/unsized-exprs.rs:24:22
|
LL | udrop::<A<[u8]>>(A { 0: *foo() });
- | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+ | ---------------- ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+ | |
+ | required by a bound introduced by this call
|
- = help: within `A<[u8]>`, the trait `Sized` is not implemented for `[u8]`
+ = help: the trait `Sized` is not implemented for `[u8]`
note: required because it appears within the type `A<[u8]>`
--> $DIR/unsized-exprs.rs:3:8
|
fn f10<X: ?Sized>(x1: Box<S<X>>) {
f5(&(32, *x1));
//~^ ERROR the size for values of type
- //~| ERROR the size for values of type
}
-pub fn main() {
-}
+pub fn main() {}
LL | fn f1<X: ?Sized>(x: &X) {
| - this type parameter needs to be `std::marker::Sized`
LL | f2::<X>(x);
- | ^ doesn't have a size known at compile-time
+ | ------- ^ doesn't have a size known at compile-time
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `f2`
--> $DIR/unsized3.rs:10:7
LL | fn f3<X: ?Sized + T>(x: &X) {
| - this type parameter needs to be `std::marker::Sized`
LL | f4::<X>(x);
- | ^ doesn't have a size known at compile-time
+ | ------- ^ doesn't have a size known at compile-time
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `f4`
--> $DIR/unsized3.rs:21:7
LL | fn f8<X: ?Sized>(x1: &S<X>, x2: &S<X>) {
| - this type parameter needs to be `std::marker::Sized`
LL | f5(x1);
- | ^^ doesn't have a size known at compile-time
+ | -- ^^ doesn't have a size known at compile-time
+ | |
+ | required by a bound introduced by this call
|
note: required because it appears within the type `S<X>`
--> $DIR/unsized3.rs:28:8
LL | fn f9<X: ?Sized>(x1: Box<S<X>>) {
| - this type parameter needs to be `std::marker::Sized`
LL | f5(&(*x1, 34));
- | ^^^^^^^^^^ doesn't have a size known at compile-time
+ | -- ^^^^^^^^^^ doesn't have a size known at compile-time
+ | |
+ | required by a bound introduced by this call
|
note: required because it appears within the type `S<X>`
--> $DIR/unsized3.rs:28:8
LL + fn f9<X>(x1: Box<S<X>>) {
|
-error[E0277]: the size for values of type `X` cannot be known at compilation time
- --> $DIR/unsized3.rs:45:9
- |
-LL | fn f10<X: ?Sized>(x1: Box<S<X>>) {
- | - this type parameter needs to be `std::marker::Sized`
-LL | f5(&(32, *x1));
- | ^^^^^^^^^ doesn't have a size known at compile-time
- |
-note: required because it appears within the type `S<X>`
- --> $DIR/unsized3.rs:28:8
- |
-LL | struct S<X: ?Sized> {
- | ^
- = note: required because it appears within the type `({integer}, S<X>)`
- = note: tuples must have a statically known size to be initialized
-help: consider removing the `?Sized` bound to make the type parameter `Sized`
- |
-LL - fn f10<X: ?Sized>(x1: Box<S<X>>) {
-LL + fn f10<X>(x1: Box<S<X>>) {
- |
-
error[E0277]: the size for values of type `X` cannot be known at compilation time
--> $DIR/unsized3.rs:45:8
|
LL | fn f10<X: ?Sized>(x1: Box<S<X>>) {
| - this type parameter needs to be `std::marker::Sized`
LL | f5(&(32, *x1));
- | ^^^^^^^^^^ doesn't have a size known at compile-time
+ | -- ^^^^^^^^^^ doesn't have a size known at compile-time
+ | |
+ | required by a bound introduced by this call
|
note: required because it appears within the type `S<X>`
--> $DIR/unsized3.rs:28:8
LL | struct S<X: ?Sized> {
| ^
= note: required because it appears within the type `({integer}, S<X>)`
-note: required by a bound in `f5`
- --> $DIR/unsized3.rs:24:7
- |
-LL | fn f5<Y>(x: &Y) {}
- | ^ required by this bound in `f5`
+ = note: tuples must have a statically known size to be initialized
help: consider removing the `?Sized` bound to make the type parameter `Sized`
|
LL - fn f10<X: ?Sized>(x1: Box<S<X>>) {
LL + fn f10<X>(x1: Box<S<X>>) {
|
-help: consider relaxing the implicit `Sized` restriction
- |
-LL | fn f5<Y: ?Sized>(x: &Y) {}
- | ++++++++
-error: aborting due to 6 previous errors
+error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0277`.
+++ /dev/null
-struct A;
-
-impl A {
-//~^ NOTE `Self` type implicitly declared here, by this `impl`
- fn banana(&mut self) {
- fn peach(this: &Self) {
- //~^ ERROR can't use generic parameters from outer function
- //~| NOTE use of generic parameter from outer function
- //~| NOTE use a type here instead
- }
- }
-}
-
-fn main() {}
+++ /dev/null
-error[E0401]: can't use generic parameters from outer function
- --> $DIR/use-self-in-inner-fn.rs:6:25
- |
-LL | impl A {
- | ---- `Self` type implicitly declared here, by this `impl`
-...
-LL | fn peach(this: &Self) {
- | ^^^^
- | |
- | use of generic parameter from outer function
- | use a type here instead
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0401`.
--> $DIR/vtable-res-trait-param.rs:17:18
|
LL | b.gimme_an_a(y)
- | ^ the trait `TraitA` is not implemented for `{integer}`
+ | ---------- ^ the trait `TraitA` is not implemented for `{integer}`
+ | |
+ | required by a bound introduced by this call
error: aborting due to previous error
LL | const CONST: (bool, dyn T);
| ^^^^^ `T` cannot be made into an object
|
- = help: consider moving `CONST` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/issue-87495.rs:4:11
|
| - this trait cannot be made into an object...
LL | const CONST: (bool, dyn T);
| ^^^^^ ...because it contains this associated `const`
+ = help: consider moving `CONST` to another trait
error: aborting due to previous error
LL | let _x: &dyn A;
| ^^^^^^ `A` cannot be made into an object
|
- = help: consider moving `foo` to another trait
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
--> $DIR/wf-object-safe.rs:5:23
|
| - this trait cannot be made into an object...
LL | fn foo(&self, _x: &Self);
| ^^^^^ ...because method `foo` references the `Self` type in this parameter
+ = help: consider moving `foo` to another trait
error: aborting due to previous error
--> $DIR/where-clause-constraints-are-local-for-inherent-impl.rs:13:22
|
LL | require_copy(self.x);
- | ^^^^^^ the trait `Copy` is not implemented for `T`
+ | ------------ ^^^^^^ the trait `Copy` is not implemented for `T`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `require_copy`
--> $DIR/where-clause-constraints-are-local-for-inherent-impl.rs:1:20
--> $DIR/where-clause-constraints-are-local-for-trait-impl.rs:18:22
|
LL | require_copy(self.x);
- | ^^^^^^ the trait `Copy` is not implemented for `T`
+ | ------------ ^^^^^^ the trait `Copy` is not implemented for `T`
+ | |
+ | required by a bound introduced by this call
|
note: required by a bound in `require_copy`
--> $DIR/where-clause-constraints-are-local-for-trait-impl.rs:1:20
--> $DIR/where-clauses-method-unsatisfied.rs:18:14
|
LL | x.equals(&x);
- | ^^ the trait `Eq` is not implemented for `Bar`
+ | ------ ^^ the trait `Eq` is not implemented for `Bar`
+ | |
+ | required by a bound introduced by this call
error: aborting due to previous error
-Subproject commit e515c3277bf0681bfc79a9e763861bfe26bb05db
+Subproject commit 33ee5f82edb50af87b952c5b28de0f5fb41ebf18
if repo:
github_token = os.environ.get('TOOLSTATE_REPO_ACCESS_TOKEN')
if github_token:
- validate_maintainers(repo, github_token)
+ # FIXME: This is currently broken. Starting on 2021-09-15, GitHub
+ # seems to have changed it so that to list the collaborators
+ # requires admin permissions. I think this will probably just need
+ # to be removed since we are probably not going to use an admin
+ # token, and I don't see another way to do this.
+ print('maintainer validation disabled')
+ # validate_maintainers(repo, github_token)
else:
print('skipping toolstate maintainers validation since no GitHub token is present')
# When validating maintainers don't run the full script.
use regex::Regex;
use rustc_ast::visit;
use rustc_ast::{ast, ptr};
-use rustc_span::{symbol, BytePos, Span};
+use rustc_span::{symbol, BytePos, Span, DUMMY_SP};
use crate::attr::filter_inline_attrs;
use crate::comment::{
use crate::utils::*;
use crate::vertical::rewrite_with_alignment;
use crate::visitor::FmtVisitor;
-use crate::DEFAULT_VISIBILITY;
+
+const DEFAULT_VISIBILITY: ast::Visibility = ast::Visibility {
+ kind: ast::VisibilityKind::Inherited,
+ span: DUMMY_SP,
+ tokens: None,
+};
fn type_annotation_separator(config: &Config) -> &str {
colon_spaces(config)
format_header(context, self.prefix, self.ident, self.vis, offset)
}
- pub(crate) fn from_variant(variant: &'a ast::Variant) -> Self {
+ fn from_variant(variant: &'a ast::Variant) -> Self {
StructParts {
prefix: "",
ident: variant.ident,
use std::rc::Rc;
use rustc_ast::ast;
-use rustc_span::{symbol, DUMMY_SP};
+use rustc_span::symbol;
use thiserror::Error;
use crate::comment::LineClasses;
mod vertical;
pub(crate) mod visitor;
-const DEFAULT_VISIBILITY: ast::Visibility = ast::Visibility {
- kind: ast::VisibilityKind::Inherited,
- span: DUMMY_SP,
- tokens: None,
-};
/// The various errors that can occur during formatting. Note that not all of
/// these can currently be propagated to clients.
#[derive(Error, Debug)]
use std::iter::ExactSizeIterator;
use std::ops::Deref;
-use rustc_ast::ast::{self, AttrVec, FnRetTy, Mutability};
-use rustc_span::{symbol::kw, symbol::Ident, BytePos, Pos, Span};
+use rustc_ast::ast::{self, FnRetTy, Mutability};
+use rustc_span::{symbol::kw, BytePos, Pos, Span};
+use crate::comment::{combine_strs_with_missing_comments, contains_comment};
use crate::config::lists::*;
use crate::config::{IndentStyle, TypeDensity, Version};
use crate::expr::{
format_expr, rewrite_assign_rhs, rewrite_call, rewrite_tuple, rewrite_unary_prefix, ExprType,
};
-use crate::items::StructParts;
use crate::lists::{
definitive_tactic, itemize_list, write_list, ListFormatting, ListItem, Separator,
};
colon_spaces, extra_offset, first_line_width, format_extern, format_mutability,
last_line_extendable, last_line_width, mk_sp, rewrite_ident,
};
-use crate::DEFAULT_VISIBILITY;
-use crate::{
- comment::{combine_strs_with_missing_comments, contains_comment},
- items::format_struct_struct,
-};
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub(crate) enum PathContext {
ast::TyKind::Tup(ref items) => {
rewrite_tuple(context, items.iter(), self.span, shape, items.len() == 1)
}
- ast::TyKind::AnonymousStruct(ref fields, recovered) => {
- let ident = Ident::new(
- kw::Struct,
- mk_sp(self.span.lo(), self.span.lo() + BytePos(6)),
- );
- let data = ast::VariantData::Struct(fields.clone(), recovered);
- let variant = ast::Variant {
- attrs: AttrVec::new(),
- id: self.id,
- span: self.span,
- vis: DEFAULT_VISIBILITY,
- ident,
- data,
- disr_expr: None,
- is_placeholder: false,
- };
- format_struct_struct(
- &context,
- &StructParts::from_variant(&variant),
- fields,
- shape.indent,
- None,
- )
- }
- ast::TyKind::AnonymousUnion(ref fields, recovered) => {
- let ident = Ident::new(
- kw::Union,
- mk_sp(self.span.lo(), self.span.lo() + BytePos(5)),
- );
- let data = ast::VariantData::Struct(fields.clone(), recovered);
- let variant = ast::Variant {
- attrs: AttrVec::new(),
- id: self.id,
- span: self.span,
- vis: DEFAULT_VISIBILITY,
- ident,
- data,
- disr_expr: None,
- is_placeholder: false,
- };
- format_struct_struct(
- &context,
- &StructParts::from_variant(&variant),
- fields,
- shape.indent,
- None,
- )
- }
ast::TyKind::Path(ref q_self, ref path) => {
rewrite_path(context, PathContext::Type, q_self.as_ref(), path, shape)
}
const ENTRY_LIMIT: usize = 1000;
// FIXME: The following limits should be reduced eventually.
-const ROOT_ENTRY_LIMIT: usize = 1345;
-const ISSUES_ENTRY_LIMIT: usize = 2525;
+const ROOT_ENTRY_LIMIT: usize = 1330;
+const ISSUES_ENTRY_LIMIT: usize = 2488;
fn check_entries(path: &Path, bad: &mut bool) {
let dirs = walkdir::WalkDir::new(&path.join("test/ui"))