diff options
137 files changed, 1193 insertions, 868 deletions
diff --git a/INSTALL.md b/INSTALL.md index a23ea4f1eee..9619ec2ce5c 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -151,8 +151,8 @@ toolchain. directory and uncomment the line `MSYS2_PATH_TYPE=inherit`. You could install and use MSYS2's version of git instead with `pacman`, - however this is not recommended as it's excrutiatingly slow, and not frequently - tested for compatability. + however this is not recommended as it's excruciatingly slow, and not frequently + tested for compatibility. 3. Start a MINGW64 or MINGW32 shell (depending on whether you want 32-bit or 64-bit Rust) either from your start menu, or by running `mingw64.exe` diff --git a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs index 8bd8b6ac144..6eff70410cb 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/expr.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/expr.rs @@ -75,7 +75,7 @@ pub(crate) struct FixupContext { } /// The default amount of fixing is minimal fixing. Fixups should be turned on -/// in a targetted fashion where needed. +/// in a targeted fashion where needed. impl Default for FixupContext { fn default() -> Self { FixupContext { diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index a206aac0467..dcf84a2e036 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -592,7 +592,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { } self.cx.borrowck_context.constraints.outlives_constraints.push(constraint) } - // If the region is live at at least one location in the promoted MIR, + // If the region is live at least one location in the promoted MIR, // then add a liveness constraint to the main MIR for this region // at the location provided as an argument to this method // diff --git a/compiler/rustc_builtin_macros/src/source_util.rs b/compiler/rustc_builtin_macros/src/source_util.rs index dbb86df6811..abcdfabcaed 100644 --- a/compiler/rustc_builtin_macros/src/source_util.rs +++ b/compiler/rustc_builtin_macros/src/source_util.rs @@ -3,17 +3,22 @@ use rustc_ast::ptr::P; use rustc_ast::token; use rustc_ast::tokenstream::TokenStream; use rustc_ast_pretty::pprust; -use rustc_expand::base::{check_zero_tts, get_single_str_from_tts, parse_expr, resolve_path}; +use rustc_data_structures::sync::Lrc; +use rustc_expand::base::{ + check_zero_tts, get_single_str_from_tts, get_single_str_spanned_from_tts, parse_expr, + resolve_path, +}; use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt}; use rustc_expand::base::{MacEager, MacResult, MacroExpanderResult}; use rustc_expand::module::DirOwnership; use rustc_parse::new_parser_from_file; use rustc_parse::parser::{ForceCollect, Parser}; use rustc_session::lint::builtin::INCOMPLETE_INCLUDE; +use rustc_span::source_map::SourceMap; use rustc_span::symbol::Symbol; use rustc_span::{Pos, Span}; - use smallvec::SmallVec; +use std::path::{Path, PathBuf}; use std::rc::Rc; // These macros all relate to the file system; they either return @@ -182,35 +187,26 @@ pub fn expand_include_str( tts: TokenStream, ) -> MacroExpanderResult<'static> { let sp = cx.with_def_site_ctxt(sp); - let ExpandResult::Ready(mac) = get_single_str_from_tts(cx, sp, tts, "include_str!") else { + let ExpandResult::Ready(mac) = get_single_str_spanned_from_tts(cx, sp, tts, "include_str!") + else { return ExpandResult::Retry(()); }; - let file = match mac { - Ok(file) => file, + let (path, path_span) = match mac { + Ok(res) => res, Err(guar) => return ExpandResult::Ready(DummyResult::any(sp, guar)), }; - let file = match resolve_path(&cx.sess, file.as_str(), sp) { - Ok(f) => f, - Err(err) => { - let guar = err.emit(); - return ExpandResult::Ready(DummyResult::any(sp, guar)); - } - }; - ExpandResult::Ready(match cx.source_map().load_binary_file(&file) { + ExpandResult::Ready(match load_binary_file(cx, path.as_str().as_ref(), sp, path_span) { Ok(bytes) => match std::str::from_utf8(&bytes) { Ok(src) => { let interned_src = Symbol::intern(src); MacEager::expr(cx.expr_str(sp, interned_src)) } Err(_) => { - let guar = cx.dcx().span_err(sp, format!("{} wasn't a utf-8 file", file.display())); + let guar = cx.dcx().span_err(sp, format!("`{path}` wasn't a utf-8 file")); DummyResult::any(sp, guar) } }, - Err(e) => { - let guar = cx.dcx().span_err(sp, format!("couldn't read {}: {}", file.display(), e)); - DummyResult::any(sp, guar) - } + Err(dummy) => dummy, }) } @@ -220,28 +216,127 @@ pub fn expand_include_bytes( tts: TokenStream, ) -> MacroExpanderResult<'static> { let sp = cx.with_def_site_ctxt(sp); - let ExpandResult::Ready(mac) = get_single_str_from_tts(cx, sp, tts, "include_bytes!") else { + let ExpandResult::Ready(mac) = get_single_str_spanned_from_tts(cx, sp, tts, "include_bytes!") + else { return ExpandResult::Retry(()); }; - let file = match mac { - Ok(file) => file, + let (path, path_span) = match mac { + Ok(res) => res, Err(guar) => return ExpandResult::Ready(DummyResult::any(sp, guar)), }; - let file = match resolve_path(&cx.sess, file.as_str(), sp) { - Ok(f) => f, + ExpandResult::Ready(match load_binary_file(cx, path.as_str().as_ref(), sp, path_span) { + Ok(bytes) => { + let expr = cx.expr(sp, ast::ExprKind::IncludedBytes(bytes)); + MacEager::expr(expr) + } + Err(dummy) => dummy, + }) +} + +fn load_binary_file( + cx: &mut ExtCtxt<'_>, + original_path: &Path, + macro_span: Span, + path_span: Span, +) -> Result<Lrc<[u8]>, Box<dyn MacResult>> { + let resolved_path = match resolve_path(&cx.sess, original_path, macro_span) { + Ok(path) => path, Err(err) => { let guar = err.emit(); - return ExpandResult::Ready(DummyResult::any(sp, guar)); + return Err(DummyResult::any(macro_span, guar)); } }; - ExpandResult::Ready(match cx.source_map().load_binary_file(&file) { - Ok(bytes) => { - let expr = cx.expr(sp, ast::ExprKind::IncludedBytes(bytes)); - MacEager::expr(expr) + match cx.source_map().load_binary_file(&resolved_path) { + Ok(data) => Ok(data), + Err(io_err) => { + let mut err = cx.dcx().struct_span_err( + macro_span, + format!("couldn't read `{}`: {io_err}", resolved_path.display()), + ); + + if original_path.is_relative() { + let source_map = cx.sess.source_map(); + let new_path = source_map + .span_to_filename(macro_span.source_callsite()) + .into_local_path() + .and_then(|src| find_path_suggestion(source_map, src.parent()?, original_path)) + .and_then(|path| path.into_os_string().into_string().ok()); + + if let Some(new_path) = new_path { + err.span_suggestion( + path_span, + "there is a file with the same name in a different directory", + format!("\"{}\"", new_path.replace('\\', "/").escape_debug()), + rustc_lint_defs::Applicability::MachineApplicable, + ); + } + } + let guar = err.emit(); + Err(DummyResult::any(macro_span, guar)) } - Err(e) => { - let guar = cx.dcx().span_err(sp, format!("couldn't read {}: {}", file.display(), e)); - DummyResult::any(sp, guar) + } +} + +fn find_path_suggestion( + source_map: &SourceMap, + base_dir: &Path, + wanted_path: &Path, +) -> Option<PathBuf> { + // Fix paths that assume they're relative to cargo manifest dir + let mut base_c = base_dir.components(); + let mut wanted_c = wanted_path.components(); + let mut without_base = None; + while let Some(wanted_next) = wanted_c.next() { + if wanted_c.as_path().file_name().is_none() { + break; } + // base_dir may be absolute + while let Some(base_next) = base_c.next() { + if base_next == wanted_next { + without_base = Some(wanted_c.as_path()); + break; + } + } + } + let root_absolute = without_base.into_iter().map(PathBuf::from); + + let base_dir_components = base_dir.components().count(); + // Avoid going all the way to the root dir + let max_parent_components = if base_dir.is_relative() { + base_dir_components + 1 + } else { + base_dir_components.saturating_sub(1) + }; + + // Try with additional leading ../ + let mut prefix = PathBuf::new(); + let add = std::iter::from_fn(|| { + prefix.push(".."); + Some(prefix.join(wanted_path)) }) + .take(max_parent_components.min(3)); + + // Try without leading directories + let mut trimmed_path = wanted_path; + let remove = std::iter::from_fn(|| { + let mut components = trimmed_path.components(); + let removed = components.next()?; + trimmed_path = components.as_path(); + let _ = trimmed_path.file_name()?; // ensure there is a file name left + Some([ + Some(trimmed_path.to_path_buf()), + (removed != std::path::Component::ParentDir) + .then(|| Path::new("..").join(trimmed_path)), + ]) + }) + .flatten() + .flatten() + .take(4); + + for new_path in root_absolute.chain(add).chain(remove) { + if source_map.file_exists(&base_dir.join(&new_path)) { + return Some(new_path); + } + } + None } diff --git a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs index 098a6201c4e..4283ebc99d2 100644 --- a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs +++ b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs @@ -409,7 +409,7 @@ fn const_validate_mplace<'mir, 'tcx>( } }; ecx.const_validate_operand(&mplace.into(), path, &mut ref_tracking, mode) - // Instead of just reporting the `InterpError` via the usual machinery, we give a more targetted + // Instead of just reporting the `InterpError` via the usual machinery, we give a more targeted // error about the validation failure. .map_err(|error| report_validation_error(&ecx, error, alloc_id))?; inner = true; diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index 30ee02ea3c0..b25dd8fe67b 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -1252,21 +1252,18 @@ pub fn resolve_path(sess: &Session, path: impl Into<PathBuf>, span: Span) -> PRe // after macro expansion (that is, they are unhygienic). if !path.is_absolute() { let callsite = span.source_callsite(); - let mut result = match sess.source_map().span_to_filename(callsite) { - FileName::Real(name) => name - .into_local_path() - .expect("attempting to resolve a file path in an external file"), - FileName::DocTest(path, _) => path, - other => { - return Err(sess.dcx().create_err(errors::ResolveRelativePath { - span, - path: sess.source_map().filename_for_diagnostics(&other).to_string(), - })); - } + let source_map = sess.source_map(); + let Some(mut base_path) = source_map.span_to_filename(callsite).into_local_path() else { + return Err(sess.dcx().create_err(errors::ResolveRelativePath { + span, + path: source_map + .filename_for_diagnostics(&source_map.span_to_filename(callsite)) + .to_string(), + })); }; - result.pop(); - result.push(path); - Ok(result) + base_path.pop(); + base_path.push(path); + Ok(base_path) } else { Ok(path) } @@ -1379,6 +1376,15 @@ pub fn get_single_str_from_tts( tts: TokenStream, name: &str, ) -> ExpandResult<Result<Symbol, ErrorGuaranteed>, ()> { + get_single_str_spanned_from_tts(cx, span, tts, name).map(|res| res.map(|(s, _)| s)) +} + +pub fn get_single_str_spanned_from_tts( + cx: &mut ExtCtxt<'_>, + span: Span, + tts: TokenStream, + name: &str, +) -> ExpandResult<Result<(Symbol, Span), ErrorGuaranteed>, ()> { let mut p = cx.new_parser_from_tts(tts); if p.token == token::Eof { let guar = cx.dcx().emit_err(errors::OnlyOneArgument { span, name }); @@ -1393,7 +1399,13 @@ pub fn get_single_str_from_tts( if p.token != token::Eof { cx.dcx().emit_err(errors::OnlyOneArgument { span, name }); } - expr_to_string(cx, ret, "argument must be a string literal").map(|s| s.map(|(s, _)| s)) + expr_to_spanned_string(cx, ret, "argument must be a string literal").map(|res| { + res.map_err(|err| match err { + Ok((err, _)) => err.emit(), + Err(guar) => guar, + }) + .map(|(symbol, _style, span)| (symbol, span)) + }) } /// Extracts comma-separated expressions from `tts`. diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs index 8c35da3ac7b..d9d36f5299b 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs @@ -11,7 +11,7 @@ use super::HirTyLowerer; impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { /// Prohibit or lint against *bare* trait object types depending on the edition. /// - /// *Bare* trait object types are ones that aren't preceeded by the keyword `dyn`. + /// *Bare* trait object types are ones that aren't preceded by the keyword `dyn`. /// In edition 2021 and onward we emit a hard error for them. pub(super) fn prohibit_or_lint_bare_trait_object_ty( &self, diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index a83b5b78f9c..8886a78c6ec 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -2212,6 +2212,17 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { try_emit("delegation with early bound generics"); } + // There is no way to instantiate `Self` param for caller if + // 1. callee is a trait method + // 2. delegation item isn't an associative item + if let DefKind::AssocFn = self.tcx().def_kind(sig_id) + && let DefKind::Fn = self.tcx().def_kind(self.item_def_id()) + && self.tcx().associated_item(sig_id).container + == ty::AssocItemContainer::TraitContainer + { + try_emit("delegation to a trait method from a free function"); + } + if self.tcx().asyncness(sig_id) == ty::Asyncness::Yes { try_emit("delegation to async functions"); } diff --git a/compiler/rustc_hir_analysis/src/outlives/utils.rs b/compiler/rustc_hir_analysis/src/outlives/utils.rs index 8077acea52e..d3bb22d715d 100644 --- a/compiler/rustc_hir_analysis/src/outlives/utils.rs +++ b/compiler/rustc_hir_analysis/src/outlives/utils.rs @@ -1,14 +1,14 @@ +use rustc_data_structures::fx::FxIndexMap; use rustc_infer::infer::outlives::components::{push_outlives_components, Component}; use rustc_middle::ty::{self, Region, Ty, TyCtxt}; use rustc_middle::ty::{GenericArg, GenericArgKind}; use rustc_span::Span; use smallvec::smallvec; -use std::collections::BTreeMap; /// Tracks the `T: 'a` or `'a: 'a` predicates that we have inferred /// must be added to the struct header. pub(crate) type RequiredPredicates<'tcx> = - BTreeMap<ty::OutlivesPredicate<GenericArg<'tcx>, ty::Region<'tcx>>, Span>; + FxIndexMap<ty::OutlivesPredicate<GenericArg<'tcx>, ty::Region<'tcx>>, Span>; /// Given a requirement `T: 'a` or `'b: 'a`, deduce the /// outlives_component and add it to `required_predicates` diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index 3a16884d5c7..80fd4be53e1 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -83,20 +83,6 @@ macro_rules! type_error_struct { }) } -/// If this `DefId` is a "primary tables entry", returns -/// `Some((body_id, body_ty, fn_sig))`. Otherwise, returns `None`. -/// -/// If this function returns `Some`, then `typeck_results(def_id)` will -/// succeed; if it returns `None`, then `typeck_results(def_id)` may or -/// may not succeed. In some cases where this function returns `None` -/// (notably closures), `typeck_results(def_id)` would wind up -/// redirecting to the owning function. -fn primary_body_of( - node: Node<'_>, -) -> Option<(hir::BodyId, Option<&hir::Ty<'_>>, Option<&hir::FnSig<'_>>)> { - Some((node.body_id()?, node.ty(), node.fn_sig())) -} - fn has_typeck_results(tcx: TyCtxt<'_>, def_id: DefId) -> bool { // Closures' typeck results come from their outermost function, // as they are part of the same "inference environment". @@ -106,7 +92,7 @@ fn has_typeck_results(tcx: TyCtxt<'_>, def_id: DefId) -> bool { } if let Some(def_id) = def_id.as_local() { - primary_body_of(tcx.hir_node_by_def_id(def_id)).is_some() + tcx.hir_node_by_def_id(def_id).body_id().is_some() } else { false } @@ -163,7 +149,7 @@ fn typeck_with_fallback<'tcx>( let span = tcx.hir().span(id); // Figure out what primary body this item has. - let (body_id, body_ty, fn_sig) = primary_body_of(node).unwrap_or_else(|| { + let body_id = node.body_id().unwrap_or_else(|| { span_bug!(span, "can't type-check body of {:?}", def_id); }); let body = tcx.hir().body(body_id); @@ -176,7 +162,7 @@ fn typeck_with_fallback<'tcx>( } let mut fcx = FnCtxt::new(&root_ctxt, param_env, def_id); - if let Some(hir::FnSig { header, decl, .. }) = fn_sig { + if let Some(hir::FnSig { header, decl, .. }) = node.fn_sig() { let fn_sig = if decl.output.get_infer_ret_ty().is_some() { fcx.lowerer().lower_fn_ty(id, header.unsafety, header.abi, decl, None, None) } else { @@ -191,42 +177,7 @@ fn typeck_with_fallback<'tcx>( check_fn(&mut fcx, fn_sig, None, decl, def_id, body, tcx.features().unsized_fn_params); } else { - let expected_type = if let Some(&hir::Ty { kind: hir::TyKind::Infer, span, .. }) = body_ty { - Some(fcx.next_ty_var(TypeVariableOrigin { - kind: TypeVariableOriginKind::TypeInference, - span, - })) - } else if let Node::AnonConst(_) = node { - match tcx.parent_hir_node(id) { - Node::Ty(&hir::Ty { kind: hir::TyKind::Typeof(ref anon_const), .. }) - if anon_const.hir_id == id => - { - Some(fcx.next_ty_var(TypeVariableOrigin { - kind: TypeVariableOriginKind::TypeInference, - span, - })) - } - Node::Expr(&hir::Expr { kind: hir::ExprKind::InlineAsm(asm), .. }) - | Node::Item(&hir::Item { kind: hir::ItemKind::GlobalAsm(asm), .. }) => { - asm.operands.iter().find_map(|(op, _op_sp)| match op { - hir::InlineAsmOperand::Const { anon_const } if anon_const.hir_id == id => { - // Inline assembly constants must be integers. - Some(fcx.next_int_var()) - } - hir::InlineAsmOperand::SymFn { anon_const } if anon_const.hir_id == id => { - Some(fcx.next_ty_var(TypeVariableOrigin { - kind: TypeVariableOriginKind::MiscVariable, - span, - })) - } - _ => None, - }) - } - _ => None, - } - } else { - None - }; + let expected_type = infer_type_if_missing(&fcx, node); let expected_type = expected_type.unwrap_or_else(fallback); let expected_type = fcx.normalize(body.value.span, expected_type); @@ -296,6 +247,59 @@ fn typeck_with_fallback<'tcx>( typeck_results } +fn infer_type_if_missing<'tcx>(fcx: &FnCtxt<'_, 'tcx>, node: Node<'tcx>) -> Option<Ty<'tcx>> { + let tcx = fcx.tcx; + let def_id = fcx.body_id; + let expected_type = if let Some(&hir::Ty { kind: hir::TyKind::Infer, span, .. }) = node.ty() { + if let Some(item) = tcx.opt_associated_item(def_id.into()) + && let ty::AssocKind::Const = item.kind + && let ty::ImplContainer = item.container + && let Some(trait_item) = item.trait_item_def_id + { + let args = + tcx.impl_trait_ref(item.container_id(tcx)).unwrap().instantiate_identity().args; + Some(tcx.type_of(trait_item).instantiate(tcx, args)) + } else { + Some(fcx.next_ty_var(TypeVariableOrigin { + kind: TypeVariableOriginKind::TypeInference, + span, + })) + } + } else if let Node::AnonConst(_) = node { + let id = tcx.local_def_id_to_hir_id(def_id); + match tcx.parent_hir_node(id) { + Node::Ty(&hir::Ty { kind: hir::TyKind::Typeof(ref anon_const), span, .. }) + if anon_const.hir_id == id => + { + Some(fcx.next_ty_var(TypeVariableOrigin { + kind: TypeVariableOriginKind::TypeInference, + span, + })) + } + Node::Expr(&hir::Expr { kind: hir::ExprKind::InlineAsm(asm), span, .. }) + | Node::Item(&hir::Item { kind: hir::ItemKind::GlobalAsm(asm), span, .. }) => { + asm.operands.iter().find_map(|(op, _op_sp)| match op { + hir::InlineAsmOperand::Const { anon_const } if anon_const.hir_id == id => { + // Inline assembly constants must be integers. + Some(fcx.next_int_var()) + } + hir::InlineAsmOperand::SymFn { anon_const } if anon_const.hir_id == id => { + Some(fcx.next_ty_var(TypeVariableOrigin { + kind: TypeVariableOriginKind::MiscVariable, + span, + })) + } + _ => None, + }) + } + _ => None, + } + } else { + None + }; + expected_type +} + /// When `check_fn` is invoked on a coroutine (i.e., a body that /// includes yield), it returns back some information about the yield /// points. diff --git a/compiler/rustc_hir_typeck/src/method/mod.rs b/compiler/rustc_hir_typeck/src/method/mod.rs index e9752d7a4a8..39d54f1a25e 100644 --- a/compiler/rustc_hir_typeck/src/method/mod.rs +++ b/compiler/rustc_hir_typeck/src/method/mod.rs @@ -81,7 +81,7 @@ pub struct NoMatchData<'tcx> { // A pared down enum describing just the places from which a method // candidate can arise. Used for error reporting only. -#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] +#[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum CandidateSource { Impl(DefId), Trait(DefId /* trait id */), diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 0dcde0cdecb..12f522d1adc 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -49,7 +49,6 @@ use std::borrow::Cow; use super::probe::{AutorefOrPtrAdjustment, IsSuggestion, Mode, ProbeScope}; use super::{CandidateSource, MethodError, NoMatchData}; use rustc_hir::intravisit::Visitor; -use std::cmp::{self, Ordering}; use std::iter; impl<'a, 'tcx> FnCtxt<'a, 'tcx> { @@ -1186,7 +1185,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }) .collect::<Vec<_>>(); if !inherent_impls_candidate.is_empty() { - inherent_impls_candidate.sort(); + inherent_impls_candidate.sort_by_key(|id| self.tcx.def_path_str(id)); inherent_impls_candidate.dedup(); // number of types to show at most @@ -1567,7 +1566,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { sources: &mut Vec<CandidateSource>, sugg_span: Option<Span>, ) { - sources.sort(); + sources.sort_by_key(|source| match source { + CandidateSource::Trait(id) => (0, self.tcx.def_path_str(id)), + CandidateSource::Impl(id) => (1, self.tcx.def_path_str(id)), + }); sources.dedup(); // Dynamic limit to avoid hiding just one candidate, which is silly. let limit = if sources.len() == 5 { 5 } else { 4 }; @@ -2549,7 +2551,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { _ => None, }) .collect(); - preds.sort_by_key(|pred| (pred.def_id(), pred.self_ty())); + preds.sort_by_key(|pred| pred.trait_ref.to_string()); let def_ids = preds .iter() .filter_map(|pred| match pred.self_ty().kind() { @@ -2663,7 +2665,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { traits.push(trait_pred.def_id()); } } - traits.sort(); + traits.sort_by_key(|id| self.tcx.def_path_str(id)); traits.dedup(); let len = traits.len(); @@ -2886,7 +2888,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) -> bool { if !valid_out_of_scope_traits.is_empty() { let mut candidates = valid_out_of_scope_traits; - candidates.sort(); + candidates.sort_by_key(|id| self.tcx.def_path_str(id)); candidates.dedup(); // `TryFrom` and `FromIterator` have no methods @@ -3212,8 +3214,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } if !candidates.is_empty() { - // Sort from most relevant to least relevant. - candidates.sort_by_key(|&info| cmp::Reverse(info)); + // Sort local crate results before others + candidates + .sort_by_key(|&info| (!info.def_id.is_local(), self.tcx.def_path_str(info.def_id))); candidates.dedup(); let param_type = match rcvr_ty.kind() { @@ -3561,33 +3564,11 @@ pub enum SelfSource<'a> { MethodCall(&'a hir::Expr<'a> /* rcvr */), } -#[derive(Copy, Clone)] +#[derive(Copy, Clone, PartialEq, Eq)] pub struct TraitInfo { pub def_id: DefId, } -impl PartialEq for TraitInfo { - fn eq(&self, other: &TraitInfo) -> bool { - self.cmp(other) == Ordering::Equal - } -} -impl Eq for TraitInfo {} -impl PartialOrd for TraitInfo { - fn partial_cmp(&self, other: &TraitInfo) -> Option<Ordering> { - Some(self.cmp(other)) - } -} -impl Ord for TraitInfo { - fn cmp(&self, other: &TraitInfo) -> Ordering { - // Local crates are more important than remote ones (local: - // `cnum == 0`), and otherwise we throw in the defid for totality. - - let lhs = (other.def_id.krate, other.def_id); - let rhs = (self.def_id.krate, self.def_id); - lhs.cmp(&rhs) - } -} - /// Retrieves all traits in this crate and any dependent crates, /// and wraps them into `TraitInfo` for custom sorting. pub fn all_traits(tcx: TyCtxt<'_>) -> Vec<TraitInfo> { diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index dd438736baa..0911e4f5063 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -1038,7 +1038,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let (sig, reg) = ty::print::FmtPrinter::new(self.tcx, Namespace::TypeNS) .name_all_regions(sig) .unwrap(); - let lts: Vec<String> = reg.into_values().map(|kind| kind.to_string()).collect(); + let lts: Vec<String> = + reg.into_items().map(|(_, kind)| kind.to_string()).into_sorted_stable_ord(); (if lts.is_empty() { String::new() } else { format!("for<{}> ", lts.join(", ")) }, sig) }; diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs index f684f83a261..b1162a34cda 100644 --- a/compiler/rustc_middle/src/thir.rs +++ b/compiler/rustc_middle/src/thir.rs @@ -1018,7 +1018,7 @@ impl<'tcx> PatRangeBoundary<'tcx> { (Finite(mir::Const::Ty(a)), Finite(mir::Const::Ty(b))) if matches!(ty.kind(), ty::Uint(_) | ty::Char) => { - return Some(a.kind().cmp(&b.kind())); + return Some(a.to_valtree().cmp(&b.to_valtree())); } ( Finite(mir::Const::Val(mir::ConstValue::Scalar(Scalar::Int(a)), _)), diff --git a/compiler/rustc_middle/src/ty/adt.rs b/compiler/rustc_middle/src/ty/adt.rs index a7144316769..a7f1ba46b61 100644 --- a/compiler/rustc_middle/src/ty/adt.rs +++ b/compiler/rustc_middle/src/ty/adt.rs @@ -18,7 +18,6 @@ use rustc_span::symbol::sym; use rustc_target::abi::{ReprOptions, VariantIdx, FIRST_VARIANT}; use std::cell::RefCell; -use std::cmp::Ordering; use std::hash::{Hash, Hasher}; use std::ops::Range; use std::str; @@ -102,20 +101,6 @@ pub struct AdtDefData { repr: ReprOptions, } -impl PartialOrd for AdtDefData { - fn partial_cmp(&self, other: &AdtDefData) -> Option<Ordering> { - Some(self.cmp(other)) - } -} - -/// There should be only one AdtDef for each `did`, therefore -/// it is fine to implement `Ord` only based on `did`. -impl Ord for AdtDefData { - fn cmp(&self, other: &AdtDefData) -> Ordering { - self.did.cmp(&other.did) - } -} - impl PartialEq for AdtDefData { #[inline] fn eq(&self, other: &Self) -> bool { @@ -180,7 +165,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for AdtDefData { } } -#[derive(Copy, Clone, PartialEq, Eq, Hash, Ord, PartialOrd, HashStable)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable)] #[rustc_pass_by_value] pub struct AdtDef<'tcx>(pub Interned<'tcx, AdtDefData>); diff --git a/compiler/rustc_middle/src/ty/consts.rs b/compiler/rustc_middle/src/ty/consts.rs index 0d621cd1cfd..3713883eb00 100644 --- a/compiler/rustc_middle/src/ty/consts.rs +++ b/compiler/rustc_middle/src/ty/consts.rs @@ -23,7 +23,7 @@ pub use valtree::*; pub type ConstKind<'tcx> = IrConstKind<TyCtxt<'tcx>>; /// Use this rather than `ConstData`, whenever possible. -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable)] #[rustc_pass_by_value] pub struct Const<'tcx>(pub(super) Interned<'tcx, WithCachedTypeInfo<ConstData<'tcx>>>); @@ -52,7 +52,7 @@ impl<'tcx> ConstTy<TyCtxt<'tcx>> for Const<'tcx> { } /// Typed constant value. -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Copy, Clone, PartialEq, Eq, Hash)] #[derive(HashStable, TyEncodable, TyDecodable)] pub struct ConstData<'tcx> { pub ty: Ty<'tcx>, diff --git a/compiler/rustc_middle/src/ty/consts/kind.rs b/compiler/rustc_middle/src/ty/consts/kind.rs index 705987d92fe..ea02faca5f3 100644 --- a/compiler/rustc_middle/src/ty/consts/kind.rs +++ b/compiler/rustc_middle/src/ty/consts/kind.rs @@ -7,7 +7,7 @@ use rustc_hir::def_id::DefId; use rustc_macros::HashStable; /// An unevaluated (potentially generic) constant used in the type-system. -#[derive(Copy, Clone, Eq, PartialEq, PartialOrd, Ord, TyEncodable, TyDecodable)] +#[derive(Copy, Clone, Eq, PartialEq, TyEncodable, TyDecodable)] #[derive(Hash, HashStable, TypeFoldable, TypeVisitable)] pub struct UnevaluatedConst<'tcx> { pub def: DefId, @@ -62,7 +62,7 @@ impl<'tcx> UnevaluatedConst<'tcx> { } } -#[derive(Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Hash)] +#[derive(Copy, Clone, Eq, PartialEq, Hash)] #[derive(HashStable, TyEncodable, TyDecodable, TypeVisitable, TypeFoldable)] pub enum Expr<'tcx> { Binop(mir::BinOp, Const<'tcx>, Const<'tcx>), diff --git a/compiler/rustc_middle/src/ty/fold.rs b/compiler/rustc_middle/src/ty/fold.rs index b57d4f372a7..fd3bee16e26 100644 --- a/compiler/rustc_middle/src/ty/fold.rs +++ b/compiler/rustc_middle/src/ty/fold.rs @@ -2,8 +2,6 @@ use crate::ty::{self, Binder, BoundTy, Ty, TyCtxt, TypeVisitableExt}; use rustc_data_structures::fx::FxIndexMap; use rustc_hir::def_id::DefId; -use std::collections::BTreeMap; - pub use rustc_type_ir::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder, TypeSuperFoldable}; /////////////////////////////////////////////////////////////////////////// @@ -254,12 +252,12 @@ impl<'tcx> TyCtxt<'tcx> { self, value: Binder<'tcx, T>, mut fld_r: F, - ) -> (T, BTreeMap<ty::BoundRegion, ty::Region<'tcx>>) + ) -> (T, FxIndexMap<ty::BoundRegion, ty::Region<'tcx>>) where F: FnMut(ty::BoundRegion) -> ty::Region<'tcx>, T: TypeFoldable<TyCtxt<'tcx>>, { - let mut region_map = BTreeMap::new(); + let mut region_map = FxIndexMap::default(); let real_fld_r = |br: ty::BoundRegion| *region_map.entry(br).or_insert_with(|| fld_r(br)); let value = self.instantiate_bound_regions_uncached(value, real_fld_r); (value, region_map) diff --git a/compiler/rustc_middle/src/ty/generic_args.rs b/compiler/rustc_middle/src/ty/generic_args.rs index 02b58c035d4..19cef927faf 100644 --- a/compiler/rustc_middle/src/ty/generic_args.rs +++ b/compiler/rustc_middle/src/ty/generic_args.rs @@ -17,7 +17,6 @@ use rustc_type_ir::WithCachedTypeInfo; use smallvec::SmallVec; use core::intrinsics; -use std::cmp::Ordering; use std::marker::PhantomData; use std::mem; use std::num::NonZero; @@ -68,7 +67,7 @@ const TYPE_TAG: usize = 0b00; const REGION_TAG: usize = 0b01; const CONST_TAG: usize = 0b10; -#[derive(Debug, TyEncodable, TyDecodable, PartialEq, Eq, PartialOrd, Ord, HashStable)] +#[derive(Debug, TyEncodable, TyDecodable, PartialEq, Eq, HashStable)] pub enum GenericArgKind<'tcx> { Lifetime(ty::Region<'tcx>), Type(Ty<'tcx>), @@ -100,18 +99,6 @@ impl<'tcx> GenericArgKind<'tcx> { } } -impl<'tcx> Ord for GenericArg<'tcx> { - fn cmp(&self, other: &GenericArg<'tcx>) -> Ordering { - self.unpack().cmp(&other.unpack()) - } -} - -impl<'tcx> PartialOrd for GenericArg<'tcx> { - fn partial_cmp(&self, other: &GenericArg<'tcx>) -> Option<Ordering> { - Some(self.cmp(other)) - } -} - impl<'tcx> From<ty::Region<'tcx>> for GenericArg<'tcx> { #[inline] fn from(r: ty::Region<'tcx>) -> GenericArg<'tcx> { diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index aad2f6a4cf8..d1d8a3ea072 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -517,7 +517,7 @@ pub struct CReaderCacheKey { } /// Use this rather than `TyKind`, whenever possible. -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable)] #[rustc_diagnostic_item = "Ty"] #[rustc_pass_by_value] pub struct Ty<'tcx>(Interned<'tcx, WithCachedTypeInfo<TyKind<'tcx>>>); @@ -702,7 +702,7 @@ const TAG_MASK: usize = 0b11; const TYPE_TAG: usize = 0b00; const CONST_TAG: usize = 0b01; -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, TyEncodable, TyDecodable)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable)] #[derive(HashStable, TypeFoldable, TypeVisitable)] pub enum TermKind<'tcx> { Ty(Ty<'tcx>), @@ -980,7 +980,7 @@ impl PlaceholderLike for PlaceholderType { } #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, HashStable)] -#[derive(TyEncodable, TyDecodable, PartialOrd, Ord)] +#[derive(TyEncodable, TyDecodable)] pub struct BoundConst<'tcx> { pub var: BoundVar, pub ty: Ty<'tcx>, diff --git a/compiler/rustc_middle/src/ty/predicate.rs b/compiler/rustc_middle/src/ty/predicate.rs index d3bc7dd22e7..05156dd5205 100644 --- a/compiler/rustc_middle/src/ty/predicate.rs +++ b/compiler/rustc_middle/src/ty/predicate.rs @@ -192,7 +192,7 @@ impl<'tcx> Clause<'tcx> { } } -#[derive(Debug, Copy, Clone, PartialEq, PartialOrd, Ord, Eq, Hash, TyEncodable, TyDecodable)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable)] #[derive(HashStable, TypeFoldable, TypeVisitable, Lift)] pub enum ExistentialPredicate<'tcx> { /// E.g., `Iterator`. @@ -336,7 +336,7 @@ impl<'tcx> ty::List<ty::PolyExistentialPredicate<'tcx>> { /// /// Trait references also appear in object types like `Foo<U>`, but in /// that case the `Self` parameter is absent from the generic parameters. -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable)] #[derive(HashStable, TypeFoldable, TypeVisitable, Lift)] pub struct TraitRef<'tcx> { pub def_id: DefId, @@ -420,7 +420,7 @@ impl<'tcx> IntoDiagArg for TraitRef<'tcx> { /// ``` /// The generic parameters don't include the erased `Self`, only trait /// type and lifetime parameters (`[X, Y]` and `['a, 'b]` above). -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable)] #[derive(HashStable, TypeFoldable, TypeVisitable, Lift)] pub struct ExistentialTraitRef<'tcx> { pub def_id: DefId, @@ -476,7 +476,7 @@ impl<'tcx> PolyExistentialTraitRef<'tcx> { } /// A `ProjectionPredicate` for an `ExistentialTraitRef`. -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, TyEncodable, TyDecodable)] #[derive(HashStable, TypeFoldable, TypeVisitable, Lift)] pub struct ExistentialProjection<'tcx> { pub def_id: DefId, diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 914b19efc7e..5ff98dc8c87 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -10,6 +10,7 @@ use crate::ty::{ use rustc_apfloat::ieee::{Double, Single}; use rustc_apfloat::Float; use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; +use rustc_data_structures::unord::UnordMap; use rustc_hir as hir; use rustc_hir::def::{self, CtorKind, DefKind, Namespace}; use rustc_hir::def_id::{DefIdMap, DefIdSet, ModDefId, CRATE_DEF_ID, LOCAL_CRATE}; @@ -24,7 +25,6 @@ use rustc_target::spec::abi::Abi; use smallvec::SmallVec; use std::cell::Cell; -use std::collections::BTreeMap; use std::fmt::{self, Write as _}; use std::iter; use std::ops::{Deref, DerefMut}; @@ -2537,7 +2537,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> { struct RegionFolder<'a, 'tcx> { tcx: TyCtxt<'tcx>, current_index: ty::DebruijnIndex, - region_map: BTreeMap<ty::BoundRegion, ty::Region<'tcx>>, + region_map: UnordMap<ty::BoundRegion, ty::Region<'tcx>>, name: &'a mut ( dyn FnMut( Option<ty::DebruijnIndex>, // Debruijn index of the folded late-bound region @@ -2614,7 +2614,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> { pub fn name_all_regions<T>( &mut self, value: &ty::Binder<'tcx, T>, - ) -> Result<(T, BTreeMap<ty::BoundRegion, ty::Region<'tcx>>), fmt::Error> + ) -> Result<(T, UnordMap<ty::BoundRegion, ty::Region<'tcx>>), fmt::Error> where T: Print<'tcx, Self> + TypeFoldable<TyCtxt<'tcx>>, { @@ -2691,7 +2691,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> { write!(self, "{var:?}")?; } start_or_continue(self, "", "> "); - (value.clone().skip_binder(), BTreeMap::default()) + (value.clone().skip_binder(), UnordMap::default()) } else { let tcx = self.tcx; @@ -2763,7 +2763,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> { tcx, current_index: ty::INNERMOST, name: &mut name, - region_map: BTreeMap::new(), + region_map: UnordMap::default(), }; let new_value = value.clone().skip_binder().fold_with(&mut folder); let region_map = folder.region_map; diff --git a/compiler/rustc_middle/src/ty/region.rs b/compiler/rustc_middle/src/ty/region.rs index c66b9864e46..867faf63261 100644 --- a/compiler/rustc_middle/src/ty/region.rs +++ b/compiler/rustc_middle/src/ty/region.rs @@ -14,7 +14,7 @@ use crate::ty::{self, BoundVar, TyCtxt, TypeFlags}; pub type RegionKind<'tcx> = IrRegionKind<TyCtxt<'tcx>>; /// Use this rather than `RegionKind`, whenever possible. -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable)] #[rustc_pass_by_value] pub struct Region<'tcx>(pub Interned<'tcx, RegionKind<'tcx>>); @@ -327,7 +327,7 @@ impl<'tcx> Deref for Region<'tcx> { } } -#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, PartialOrd, Ord)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable)] #[derive(HashStable)] pub struct EarlyParamRegion { pub def_id: DefId, @@ -358,7 +358,7 @@ impl Atom for RegionVid { } } -#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, TyEncodable, TyDecodable, Copy)] +#[derive(Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, Copy)] #[derive(HashStable)] /// The parameter representation of late-bound function parameters, "some region /// at least as big as the scope `fr.scope`". @@ -367,7 +367,7 @@ pub struct LateParamRegion { pub bound_region: BoundRegionKind, } -#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, TyEncodable, TyDecodable, Copy)] +#[derive(Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, Copy)] #[derive(HashStable)] pub enum BoundRegionKind { /// An anonymous region parameter for a given fn (&T) @@ -384,7 +384,7 @@ pub enum BoundRegionKind { BrEnv, } -#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, PartialOrd, Ord)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable)] #[derive(HashStable)] pub struct BoundRegion { pub var: BoundVar, diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 510a4b59520..57a675e4453 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -868,7 +868,7 @@ impl<'tcx> InlineConstArgs<'tcx> { } } -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, TyEncodable, TyDecodable)] #[derive(HashStable)] pub enum BoundVariableKind { Ty(BoundTyKind), @@ -908,7 +908,7 @@ impl BoundVariableKind { /// e.g., `liberate_late_bound_regions`). /// /// `Decodable` and `Encodable` are implemented for `Binder<T>` using the `impl_binder_encode_decode!` macro. -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] #[derive(HashStable, Lift)] pub struct Binder<'tcx, T> { value: T, @@ -1109,7 +1109,7 @@ where /// * For a projection, this would be `<Ty as Trait<...>>::N<...>`. /// * For an inherent projection, this would be `Ty::N<...>`. /// * For an opaque type, there is no explicit syntax. -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable)] #[derive(HashStable, TypeFoldable, TypeVisitable, Lift)] pub struct AliasTy<'tcx> { /// The parameters of the associated or opaque item. @@ -1278,7 +1278,7 @@ pub struct GenSig<'tcx> { /// - `inputs`: is the list of arguments and their modes. /// - `output`: is the return type. /// - `c_variadic`: indicates whether this is a C-variadic function. -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable)] #[derive(HashStable, TypeFoldable, TypeVisitable, Lift)] pub struct FnSig<'tcx> { pub inputs_and_output: &'tcx List<Ty<'tcx>>, @@ -1403,14 +1403,14 @@ impl ParamConst { } } -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable)] #[derive(HashStable)] pub struct BoundTy { pub var: BoundVar, pub kind: BoundTyKind, } -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, TyEncodable, TyDecodable)] #[derive(HashStable)] pub enum BoundTyKind { Anon, @@ -2661,7 +2661,7 @@ impl<'tcx> Ty<'tcx> { /// a miscompilation or unsoundness. /// /// When in doubt, use `VarianceDiagInfo::default()` -#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] pub enum VarianceDiagInfo<'tcx> { /// No additional information - this is the default. /// We will not add any additional information to error messages. diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 7e317c3df14..18fb858c84c 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -2768,7 +2768,7 @@ impl<'a> Parser<'a> { }; return if self.token.kind == token::CloseDelim(Delimiter::Parenthesis) { // We know for sure we have seen `for ($SOMETHING in $EXPR)`, so we recover the - // parser state and emit a targetted suggestion. + // parser state and emit a targeted suggestion. let span = vec![start_span, self.token.span]; let right = self.prev_token.span.between(self.look_ahead(1, |t| t.span)); self.bump(); // ) diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 476b31f44ae..4057bc9ffbd 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -2730,7 +2730,7 @@ pub(crate) fn import_candidates( ); } -type PathString<'a> = (String, &'a str, Option<DefId>, &'a Option<String>, bool); +type PathString<'a> = (String, &'a str, Option<Span>, &'a Option<String>, bool); /// When an entity with a given name is not available in scope, we search for /// entities with that name in all crates. This method allows outputting the @@ -2762,7 +2762,7 @@ fn show_candidates( accessible_path_strings.push(( pprust::path_to_string(&c.path), c.descr, - c.did, + c.did.and_then(|did| Some(tcx.source_span(did.as_local()?))), &c.note, c.via_import, )) @@ -2771,7 +2771,7 @@ fn show_candidates( inaccessible_path_strings.push(( pprust::path_to_string(&c.path), c.descr, - c.did, + c.did.and_then(|did| Some(tcx.source_span(did.as_local()?))), &c.note, c.via_import, )) @@ -2889,15 +2889,14 @@ fn show_candidates( } else if !(inaccessible_path_strings.is_empty() || matches!(mode, DiagMode::Import { .. })) { let prefix = if let DiagMode::Pattern = mode { "you might have meant to match on " } else { "" }; - if let [(name, descr, def_id, note, _)] = &inaccessible_path_strings[..] { + if let [(name, descr, source_span, note, _)] = &inaccessible_path_strings[..] { let msg = format!( "{prefix}{descr} `{name}`{} exists but is inaccessible", if let DiagMode::Pattern = mode { ", which" } else { "" } ); - if let Some(local_def_id) = def_id.and_then(|did| did.as_local()) { - let span = tcx.source_span(local_def_id); - let span = tcx.sess.source_map().guess_head_span(span); + if let Some(source_span) = source_span { + let span = tcx.sess.source_map().guess_head_span(*source_span); let mut multi_span = MultiSpan::from_span(span); multi_span.push_span_label(span, "not accessible"); err.span_note(multi_span, msg); @@ -2925,10 +2924,9 @@ fn show_candidates( let mut has_colon = false; let mut spans = Vec::new(); - for (name, _, def_id, _, _) in &inaccessible_path_strings { - if let Some(local_def_id) = def_id.and_then(|did| did.as_local()) { - let span = tcx.source_span(local_def_id); - let span = tcx.sess.source_map().guess_head_span(span); + for (name, _, source_span, _, _) in &inaccessible_path_strings { + if let Some(source_span) = source_span { + let span = tcx.sess.source_map().guess_head_span(*source_span); spans.push((name, span)); } else { if !has_colon { diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs index 0c811d7dff1..8f721bac951 100644 --- a/compiler/rustc_span/src/def_id.rs +++ b/compiler/rustc_span/src/def_id.rs @@ -218,8 +218,6 @@ rustc_index::newtype_index! { /// /// You can create a `DefId` from a `LocalDefId` using `local_def_id.to_def_id()`. #[derive(Clone, PartialEq, Eq, Copy)] -// Don't derive order on 64-bit big-endian, so we can be consistent regardless of field order. -#[cfg_attr(not(all(target_pointer_width = "64", target_endian = "big")), derive(PartialOrd, Ord))] // On below-64 bit systems we can simply use the derived `Hash` impl #[cfg_attr(not(target_pointer_width = "64"), derive(Hash))] #[repr(C)] @@ -236,6 +234,12 @@ pub struct DefId { pub index: DefIndex, } +// To ensure correctness of incremental compilation, +// `DefId` must not implement `Ord` or `PartialOrd`. +// See https://github.com/rust-lang/rust/issues/90317. +impl !Ord for DefId {} +impl !PartialOrd for DefId {} + // On 64-bit systems, we can hash the whole `DefId` as one `u64` instead of two `u32`s. This // improves performance without impairing `FxHash` quality. So the below code gets compiled to a // noop on little endian systems because the memory layout of `DefId` is as follows: @@ -261,22 +265,6 @@ impl Hash for DefId { } } -// Implement the same comparison as derived with the other field order. -#[cfg(all(target_pointer_width = "64", target_endian = "big"))] -impl Ord for DefId { - #[inline] - fn cmp(&self, other: &DefId) -> std::cmp::Ordering { - Ord::cmp(&(self.index, self.krate), &(other.index, other.krate)) - } -} -#[cfg(all(target_pointer_width = "64", target_endian = "big"))] -impl PartialOrd for DefId { - #[inline] - fn partial_cmp(&self, other: &DefId) -> Option<std::cmp::Ordering> { - Some(self.cmp(other)) - } -} - impl DefId { /// Makes a local `DefId` from the given `DefIndex`. #[inline] diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 616a7ccc7c6..0c974ef4ca3 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -427,6 +427,17 @@ impl FileName { src.hash(&mut hasher); FileName::InlineAsm(hasher.finish()) } + + /// Returns the path suitable for reading from the file system on the local host, + /// if this information exists. + /// Avoid embedding this in build artifacts; see `remapped_path_if_available()` for that. + pub fn into_local_path(self) -> Option<PathBuf> { + match self { + FileName::Real(path) => path.into_local_path(), + FileName::DocTest(path, _) => Some(path), + _ => None, + } + } } /// Represents a span. diff --git a/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs b/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs index 1c6a0f9cf4d..04b92fbd33b 100644 --- a/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs +++ b/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs @@ -1112,8 +1112,36 @@ pub fn typeid_for_instance<'tcx>( mut instance: Instance<'tcx>, options: TypeIdOptions, ) -> String { - if matches!(instance.def, ty::InstanceDef::Virtual(..)) { - instance.args = strip_receiver_auto(tcx, instance.args) + if (matches!(instance.def, ty::InstanceDef::Virtual(..)) + && Some(instance.def_id()) == tcx.lang_items().drop_in_place_fn()) + || matches!(instance.def, ty::InstanceDef::DropGlue(..)) + { + // Adjust the type ids of DropGlues + // + // DropGlues may have indirect calls to one or more given types drop function. Rust allows + // for types to be erased to any trait object and retains the drop function for the original + // type, which means at the indirect call sites in DropGlues, when typeid_for_fnabi is + // called a second time, it only has information after type erasure and it could be a call + // on any arbitrary trait object. Normalize them to a synthesized Drop trait object, both on + // declaration/definition, and during code generation at call sites so they have the same + // type id and match. + // + // FIXME(rcvalle): This allows a drop call on any trait object to call the drop function of + // any other type. + // + let def_id = tcx + .lang_items() + .drop_trait() + .unwrap_or_else(|| bug!("typeid_for_instance: couldn't get drop_trait lang item")); + let predicate = ty::ExistentialPredicate::Trait(ty::ExistentialTraitRef { + def_id: def_id, + args: List::empty(), + }); + let predicates = tcx.mk_poly_existential_predicates(&[ty::Binder::dummy(predicate)]); + let self_ty = Ty::new_dynamic(tcx, predicates, tcx.lifetimes.re_erased, ty::Dyn); + instance.args = tcx.mk_args_trait(self_ty, List::empty()); + } else if matches!(instance.def, ty::InstanceDef::Virtual(..)) { + instance.args = strip_receiver_auto(tcx, instance.args); } if let Some(impl_id) = tcx.impl_of_method(instance.def_id()) diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs index 3cc46b5c638..7a62030353d 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs @@ -21,6 +21,7 @@ use crate::traits::{ }; use core::ops::ControlFlow; use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; +use rustc_data_structures::unord::UnordSet; use rustc_errors::codes::*; use rustc_errors::{pluralize, struct_span_code_err, Applicability, MultiSpan, StringPart}; use rustc_errors::{Diag, EmissionGuarantee, ErrorGuaranteed, FatalError, StashKey}; @@ -2117,7 +2118,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { }) .collect(); - impl_candidates.sort(); + impl_candidates.sort_by_key(|tr| tr.to_string()); impl_candidates.dedup(); return report(impl_candidates, err); } @@ -2143,7 +2144,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { cand }) .collect(); - impl_candidates.sort_by_key(|cand| (cand.similarity, cand.trait_ref)); + impl_candidates.sort_by_key(|cand| (cand.similarity, cand.trait_ref.to_string())); let mut impl_candidates: Vec<_> = impl_candidates.into_iter().map(|cand| cand.trait_ref).collect(); impl_candidates.dedup(); @@ -2243,14 +2244,18 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { }; let required_trait_path = self.tcx.def_path_str(trait_ref.def_id()); - let traits_with_same_path: std::collections::BTreeSet<_> = self + let traits_with_same_path: UnordSet<_> = self .tcx .all_traits() .filter(|trait_def_id| *trait_def_id != trait_ref.def_id()) - .filter(|trait_def_id| self.tcx.def_path_str(*trait_def_id) == required_trait_path) + .map(|trait_def_id| (self.tcx.def_path_str(trait_def_id), trait_def_id)) + .filter(|(p, _)| *p == required_trait_path) .collect(); + + let traits_with_same_path = + traits_with_same_path.into_items().into_sorted_stable_ord_by_key(|(p, _)| p); let mut suggested = false; - for trait_with_same_path in traits_with_same_path { + for (_, trait_with_same_path) in traits_with_same_path { let trait_impls = get_trait_impls(trait_with_same_path); if trait_impls.is_empty() { continue; diff --git a/compiler/rustc_trait_selection/src/traits/util.rs b/compiler/rustc_trait_selection/src/traits/util.rs index 3f433a9e919..29d063321a7 100644 --- a/compiler/rustc_trait_selection/src/traits/util.rs +++ b/compiler/rustc_trait_selection/src/traits/util.rs @@ -2,7 +2,7 @@ use std::collections::BTreeMap; use super::NormalizeExt; use super::{ObligationCause, PredicateObligation, SelectionContext}; -use rustc_data_structures::fx::FxHashSet; +use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_errors::Diag; use rustc_hir::def_id::DefId; use rustc_infer::infer::{InferCtxt, InferOk}; @@ -431,8 +431,8 @@ pub struct BoundVarReplacer<'me, 'tcx> { // These three maps track the bound variable that were replaced by placeholders. It might be // nice to remove these since we already have the `kind` in the placeholder; we really just need // the `var` (but we *could* bring that into scope if we were to track them as we pass them). - mapped_regions: BTreeMap<ty::PlaceholderRegion, ty::BoundRegion>, - mapped_types: BTreeMap<ty::PlaceholderType, ty::BoundTy>, + mapped_regions: FxIndexMap<ty::PlaceholderRegion, ty::BoundRegion>, + mapped_types: FxIndexMap<ty::PlaceholderType, ty::BoundTy>, mapped_consts: BTreeMap<ty::PlaceholderConst, ty::BoundVar>, // The current depth relative to *this* folding, *not* the entire normalization. In other words, // the depth of binders we've passed here. @@ -451,12 +451,13 @@ impl<'me, 'tcx> BoundVarReplacer<'me, 'tcx> { value: T, ) -> ( T, - BTreeMap<ty::PlaceholderRegion, ty::BoundRegion>, - BTreeMap<ty::PlaceholderType, ty::BoundTy>, + FxIndexMap<ty::PlaceholderRegion, ty::BoundRegion>, + FxIndexMap<ty::PlaceholderType, ty::BoundTy>, BTreeMap<ty::PlaceholderConst, ty::BoundVar>, ) { - let mapped_regions: BTreeMap<ty::PlaceholderRegion, ty::BoundRegion> = BTreeMap::new(); - let mapped_types: BTreeMap<ty::PlaceholderType, ty::BoundTy> = BTreeMap::new(); + let mapped_regions: FxIndexMap<ty::PlaceholderRegion, ty::BoundRegion> = + FxIndexMap::default(); + let mapped_types: FxIndexMap<ty::PlaceholderType, ty::BoundTy> = FxIndexMap::default(); let mapped_consts: BTreeMap<ty::PlaceholderConst, ty::BoundVar> = BTreeMap::new(); let mut replacer = BoundVarReplacer { @@ -574,8 +575,8 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for BoundVarReplacer<'_, 'tcx> { /// The inverse of [`BoundVarReplacer`]: replaces placeholders with the bound vars from which they came. pub struct PlaceholderReplacer<'me, 'tcx> { infcx: &'me InferCtxt<'tcx>, - mapped_regions: BTreeMap<ty::PlaceholderRegion, ty::BoundRegion>, - mapped_types: BTreeMap<ty::PlaceholderType, ty::BoundTy>, + mapped_regions: FxIndexMap<ty::PlaceholderRegion, ty::BoundRegion>, + mapped_types: FxIndexMap<ty::PlaceholderType, ty::BoundTy>, mapped_consts: BTreeMap<ty::PlaceholderConst, ty::BoundVar>, universe_indices: &'me [Option<ty::UniverseIndex>], current_index: ty::DebruijnIndex, @@ -584,8 +585,8 @@ pub struct PlaceholderReplacer<'me, 'tcx> { impl<'me, 'tcx> PlaceholderReplacer<'me, 'tcx> { pub fn replace_placeholders<T: TypeFoldable<TyCtxt<'tcx>>>( infcx: &'me InferCtxt<'tcx>, - mapped_regions: BTreeMap<ty::PlaceholderRegion, ty::BoundRegion>, - mapped_types: BTreeMap<ty::PlaceholderType, ty::BoundTy>, + mapped_regions: FxIndexMap<ty::PlaceholderRegion, ty::BoundRegion>, + mapped_types: FxIndexMap<ty::PlaceholderType, ty::BoundTy>, mapped_consts: BTreeMap<ty::PlaceholderConst, ty::BoundVar>, universe_indices: &'me [Option<ty::UniverseIndex>], value: T, diff --git a/compiler/rustc_transmute/src/layout/mod.rs b/compiler/rustc_transmute/src/layout/mod.rs index a7c60c3b490..0377ed5d4c5 100644 --- a/compiler/rustc_transmute/src/layout/mod.rs +++ b/compiler/rustc_transmute/src/layout/mod.rs @@ -65,7 +65,7 @@ pub mod rustc { use std::fmt::{self, Write}; /// A reference in the layout. - #[derive(Debug, Hash, Eq, PartialEq, PartialOrd, Ord, Clone, Copy)] + #[derive(Debug, Hash, Eq, PartialEq, Clone, Copy)] pub struct Ref<'tcx> { pub lifetime: ty::Region<'tcx>, pub ty: Ty<'tcx>, diff --git a/compiler/rustc_type_ir/src/const_kind.rs b/compiler/rustc_type_ir/src/const_kind.rs index 0aaaad5af05..5b08140db3a 100644 --- a/compiler/rustc_type_ir/src/const_kind.rs +++ b/compiler/rustc_type_ir/src/const_kind.rs @@ -8,15 +8,7 @@ use self::ConstKind::*; /// Represents a constant in Rust. #[derive(derivative::Derivative)] -#[derivative( - Clone(bound = ""), - Copy(bound = ""), - PartialOrd(bound = ""), - PartialOrd = "feature_allow_slow_enum", - Ord(bound = ""), - Ord = "feature_allow_slow_enum", - Hash(bound = "") -)] +#[derivative(Clone(bound = ""), Copy(bound = ""), Hash(bound = ""))] #[cfg_attr(feature = "nightly", derive(TyEncodable, TyDecodable, HashStable_NoContext))] pub enum ConstKind<I: Interner> { /// A const generic parameter. diff --git a/compiler/rustc_type_ir/src/interner.rs b/compiler/rustc_type_ir/src/interner.rs index 373540de05e..ae1e1902f14 100644 --- a/compiler/rustc_type_ir/src/interner.rs +++ b/compiler/rustc_type_ir/src/interner.rs @@ -9,16 +9,16 @@ use crate::{ }; pub trait Interner: Sized { - type DefId: Copy + Debug + Hash + Ord; - type AdtDef: Copy + Debug + Hash + Ord; + type DefId: Copy + Debug + Hash + Eq; + type AdtDef: Copy + Debug + Hash + Eq; type GenericArgs: Copy + DebugWithInfcx<Self> + Hash - + Ord + + Eq + IntoIterator<Item = Self::GenericArg>; - type GenericArg: Copy + DebugWithInfcx<Self> + Hash + Ord; - type Term: Copy + Debug + Hash + Ord; + type GenericArg: Copy + DebugWithInfcx<Self> + Hash + Eq; + type Term: Copy + Debug + Hash + Eq; type Binder<T: TypeVisitable<Self>>: BoundVars<Self> + TypeSuperVisitable<Self>; type BoundVars: IntoIterator<Item = Self::BoundVar>; @@ -30,56 +30,56 @@ pub trait Interner: Sized { type Ty: Copy + DebugWithInfcx<Self> + Hash - + Ord + + Eq + Into<Self::GenericArg> + IntoKind<Kind = TyKind<Self>> + TypeSuperVisitable<Self> + Flags + new::Ty<Self>; - type Tys: Copy + Debug + Hash + Ord + IntoIterator<Item = Self::Ty>; - type AliasTy: Copy + DebugWithInfcx<Self> + Hash + Ord; - type ParamTy: Copy + Debug + Hash + Ord; - type BoundTy: Copy + Debug + Hash + Ord; - type PlaceholderTy: Copy + Debug + Hash + Ord + PlaceholderLike; + type Tys: Copy + Debug + Hash + Eq + IntoIterator<Item = Self::Ty>; + type AliasTy: Copy + DebugWithInfcx<Self> + Hash + Eq; + type ParamTy: Copy + Debug + Hash + Eq; + type BoundTy: Copy + Debug + Hash + Eq; + type PlaceholderTy: Copy + Debug + Hash + Eq + PlaceholderLike; // Things stored inside of tys - type ErrorGuaranteed: Copy + Debug + Hash + Ord; - type BoundExistentialPredicates: Copy + DebugWithInfcx<Self> + Hash + Ord; - type PolyFnSig: Copy + DebugWithInfcx<Self> + Hash + Ord; - type AllocId: Copy + Debug + Hash + Ord; + type ErrorGuaranteed: Copy + Debug + Hash + Eq; + type BoundExistentialPredicates: Copy + DebugWithInfcx<Self> + Hash + Eq; + type PolyFnSig: Copy + DebugWithInfcx<Self> + Hash + Eq; + type AllocId: Copy + Debug + Hash + Eq; // Kinds of consts type Const: Copy + DebugWithInfcx<Self> + Hash - + Ord + + Eq + Into<Self::GenericArg> + IntoKind<Kind = ConstKind<Self>> + ConstTy<Self> + TypeSuperVisitable<Self> + Flags + new::Const<Self>; - type AliasConst: Copy + DebugWithInfcx<Self> + Hash + Ord; - type PlaceholderConst: Copy + Debug + Hash + Ord + PlaceholderLike; - type ParamConst: Copy + Debug + Hash + Ord; - type BoundConst: Copy + Debug + Hash + Ord; - type ValueConst: Copy + Debug + Hash + Ord; - type ExprConst: Copy + DebugWithInfcx<Self> + Hash + Ord; + type AliasConst: Copy + DebugWithInfcx<Self> + Hash + Eq; + type PlaceholderConst: Copy + Debug + Hash + Eq + PlaceholderLike; + type ParamConst: Copy + Debug + Hash + Eq; + type BoundConst: Copy + Debug + Hash + Eq; + type ValueConst: Copy + Debug + Hash + Eq; + type ExprConst: Copy + DebugWithInfcx<Self> + Hash + Eq; // Kinds of regions type Region: Copy + DebugWithInfcx<Self> + Hash - + Ord + + Eq + Into<Self::GenericArg> + IntoKind<Kind = RegionKind<Self>> + Flags + new::Region<Self>; - type EarlyParamRegion: Copy + Debug + Hash + Ord; - type LateParamRegion: Copy + Debug + Hash + Ord; - type BoundRegion: Copy + Debug + Hash + Ord; - type InferRegion: Copy + DebugWithInfcx<Self> + Hash + Ord; - type PlaceholderRegion: Copy + Debug + Hash + Ord + PlaceholderLike; + type EarlyParamRegion: Copy + Debug + Hash + Eq; + type LateParamRegion: Copy + Debug + Hash + Eq; + type BoundRegion: Copy + Debug + Hash + Eq; + type InferRegion: Copy + DebugWithInfcx<Self> + Hash + Eq; + type PlaceholderRegion: Copy + Debug + Hash + Eq + PlaceholderLike; // Predicates type Predicate: Copy + Debug + Hash + Eq + TypeSuperVisitable<Self> + Flags; diff --git a/compiler/rustc_type_ir/src/region_kind.rs b/compiler/rustc_type_ir/src/region_kind.rs index 2e8481df56d..e1247e2661a 100644 --- a/compiler/rustc_type_ir/src/region_kind.rs +++ b/compiler/rustc_type_ir/src/region_kind.rs @@ -113,15 +113,7 @@ use self::RegionKind::*; /// [2]: https://smallcultfollowing.com/babysteps/blog/2013/11/04/intermingled-parameter-lists/ /// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/hrtb.html #[derive(derivative::Derivative)] -#[derivative( - Clone(bound = ""), - Copy(bound = ""), - PartialOrd(bound = ""), - PartialOrd = "feature_allow_slow_enum", - Ord(bound = ""), - Ord = "feature_allow_slow_enum", - Hash(bound = "") -)] +#[derivative(Clone(bound = ""), Copy(bound = ""), Hash(bound = ""))] #[cfg_attr(feature = "nightly", derive(TyEncodable, TyDecodable))] pub enum RegionKind<I: Interner> { /// A region parameter; for example `'a` in `impl<'a> Trait for &'a ()`. diff --git a/compiler/rustc_type_ir/src/ty_kind.rs b/compiler/rustc_type_ir/src/ty_kind.rs index 5ed73cd94f4..fad67fe3cbb 100644 --- a/compiler/rustc_type_ir/src/ty_kind.rs +++ b/compiler/rustc_type_ir/src/ty_kind.rs @@ -63,15 +63,7 @@ impl AliasKind { /// converted to this representation using `<dyn HirTyLowerer>::lower_ty`. #[cfg_attr(feature = "nightly", rustc_diagnostic_item = "IrTyKind")] #[derive(derivative::Derivative)] -#[derivative( - Clone(bound = ""), - Copy(bound = ""), - PartialOrd(bound = ""), - PartialOrd = "feature_allow_slow_enum", - Ord(bound = ""), - Ord = "feature_allow_slow_enum", - Hash(bound = "") -)] +#[derivative(Clone(bound = ""), Copy(bound = ""), Hash(bound = ""))] #[cfg_attr(feature = "nightly", derive(TyEncodable, TyDecodable, HashStable_NoContext))] pub enum TyKind<I: Interner> { /// The primitive boolean type. Written as `bool`. @@ -803,8 +795,6 @@ impl<I: Interner> DebugWithInfcx<I> for InferTy { #[derivative( Clone(bound = ""), Copy(bound = ""), - PartialOrd(bound = ""), - Ord(bound = ""), PartialEq(bound = ""), Eq(bound = ""), Hash(bound = ""), diff --git a/library/alloc/src/raw_vec.rs b/library/alloc/src/raw_vec.rs index 0ee293db73a..175e23b543c 100644 --- a/library/alloc/src/raw_vec.rs +++ b/library/alloc/src/raw_vec.rs @@ -114,7 +114,10 @@ impl<T> RawVec<T, Global> { #[must_use] #[inline] pub fn with_capacity(capacity: usize) -> Self { - handle_reserve(Self::try_allocate_in(capacity, AllocInit::Uninitialized, Global)) + match Self::try_allocate_in(capacity, AllocInit::Uninitialized, Global) { + Ok(res) => res, + Err(err) => handle_error(err), + } } /// Like `with_capacity`, but guarantees the buffer is zeroed. @@ -152,7 +155,10 @@ impl<T, A: Allocator> RawVec<T, A> { #[cfg(not(no_global_oom_handling))] #[inline] pub fn with_capacity_in(capacity: usize, alloc: A) -> Self { - handle_reserve(Self::try_allocate_in(capacity, AllocInit::Uninitialized, alloc)) + match Self::try_allocate_in(capacity, AllocInit::Uninitialized, alloc) { + Ok(res) => res, + Err(err) => handle_error(err), + } } /// Like `try_with_capacity`, but parameterized over the choice of @@ -167,7 +173,10 @@ impl<T, A: Allocator> RawVec<T, A> { #[cfg(not(no_global_oom_handling))] #[inline] pub fn with_capacity_zeroed_in(capacity: usize, alloc: A) -> Self { - handle_reserve(Self::try_allocate_in(capacity, AllocInit::Zeroed, alloc)) + match Self::try_allocate_in(capacity, AllocInit::Zeroed, alloc) { + Ok(res) => res, + Err(err) => handle_error(err), + } } /// Converts the entire buffer into `Box<[MaybeUninit<T>]>` with the specified `len`. @@ -326,7 +335,9 @@ impl<T, A: Allocator> RawVec<T, A> { len: usize, additional: usize, ) { - handle_reserve(slf.grow_amortized(len, additional)); + if let Err(err) = slf.grow_amortized(len, additional) { + handle_error(err); + } } if self.needs_to_grow(len, additional) { @@ -339,7 +350,9 @@ impl<T, A: Allocator> RawVec<T, A> { #[cfg(not(no_global_oom_handling))] #[inline(never)] pub fn reserve_for_push(&mut self, len: usize) { - handle_reserve(self.grow_amortized(len, 1)); + if let Err(err) = self.grow_amortized(len, 1) { + handle_error(err); + } } /// The same as `reserve`, but returns on errors instead of panicking or aborting. @@ -373,7 +386,9 @@ impl<T, A: Allocator> RawVec<T, A> { /// Aborts on OOM. #[cfg(not(no_global_oom_handling))] pub fn reserve_exact(&mut self, len: usize, additional: usize) { - handle_reserve(self.try_reserve_exact(len, additional)); + if let Err(err) = self.try_reserve_exact(len, additional) { + handle_error(err); + } } /// The same as `reserve_exact`, but returns on errors instead of panicking or aborting. @@ -404,7 +419,9 @@ impl<T, A: Allocator> RawVec<T, A> { /// Aborts on OOM. #[cfg(not(no_global_oom_handling))] pub fn shrink_to_fit(&mut self, cap: usize) { - handle_reserve(self.shrink(cap)); + if let Err(err) = self.shrink(cap) { + handle_error(err); + } } } @@ -559,12 +576,11 @@ unsafe impl<#[may_dangle] T, A: Allocator> Drop for RawVec<T, A> { // Central function for reserve error handling. #[cfg(not(no_global_oom_handling))] -#[inline] -fn handle_reserve<T>(result: Result<T, TryReserveError>) -> T { - match result.map_err(|e| e.kind()) { - Ok(res) => res, - Err(CapacityOverflow) => capacity_overflow(), - Err(AllocError { layout, .. }) => handle_alloc_error(layout), +#[cold] +fn handle_error(e: TryReserveError) -> ! { + match e.kind() { + CapacityOverflow => capacity_overflow(), + AllocError { layout, .. } => handle_alloc_error(layout), } } diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index c65ffbb98f2..1171407c07a 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -20,7 +20,15 @@ use super::{IntErrorKind, ParseIntError}; /// /// # Safety /// -/// Types implementing this trait must be primitves that are valid when zeroed. +/// Types implementing this trait must be primitives that are valid when zeroed. +/// +/// The associated `Self::NonZeroInner` type must have the same size+align as `Self`, +/// but with a niche and bit validity making it so the following `transmutes` are sound: +/// +/// - `Self::NonZeroInner` to `Option<Self::NonZeroInner>` +/// - `Option<Self::NonZeroInner>` to `Self` +/// +/// (And, consequently, `Self::NonZeroInner` to `Self`.) #[unstable( feature = "nonzero_internals", reason = "implementation detail which may disappear or be replaced at any time", @@ -434,17 +442,11 @@ where // of some not-inlined function, LLVM don't have range metadata // to understand that the value cannot be zero. // - // SAFETY: `Self` is guaranteed to have the same layout as `Option<Self>`. - match unsafe { intrinsics::transmute_unchecked(self) } { - None => { - // SAFETY: `NonZero` is guaranteed to only contain non-zero values, so this is unreachable. - unsafe { intrinsics::unreachable() } - } - Some(Self(inner)) => { - // SAFETY: `T::NonZeroInner` is guaranteed to have the same layout as `T`. - unsafe { intrinsics::transmute_unchecked(inner) } - } - } + // For now, using the transmute `assume`s the range at runtime. + // + // SAFETY: `ZeroablePrimitive` guarantees that the size and bit validity + // of `.0` is such that this transmute is sound. + unsafe { intrinsics::transmute_unchecked(self) } } } diff --git a/library/core/src/pin.rs b/library/core/src/pin.rs index d14cac9afb5..e843a5d5790 100644 --- a/library/core/src/pin.rs +++ b/library/core/src/pin.rs @@ -806,7 +806,7 @@ //! //! As a consequence, the struct *must not* be [`#[repr(packed)]`][packed]. //! -//! 3. *Structural Notice of Destruction.* You must uphold the the +//! 3. *Structural Notice of Destruction.* You must uphold the //! [`Drop` guarantee][drop-guarantee]: once your struct is pinned, the struct's storage cannot //! be re-used without calling the structurally-pinned fields' destructors, as well. //! diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index 00e75ec9a25..77002ef87aa 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -243,7 +243,7 @@ const EMULATE_ATOMIC_BOOL: bool = /// A boolean type which can be safely shared between threads. /// -/// This type has the same in-memory representation as a [`bool`]. +/// This type has the same size, alignment, and bit validity as a [`bool`]. /// /// **Note**: This type is only available on platforms that support atomic /// loads and stores of `u8`. @@ -272,7 +272,7 @@ unsafe impl Sync for AtomicBool {} /// A raw pointer type which can be safely shared between threads. /// -/// This type has the same in-memory representation as a `*mut T`. +/// This type has the same size and bit validity as a `*mut T`. /// /// **Note**: This type is only available on platforms that support atomic /// loads and stores of pointers. Its size depends on the target pointer's size. @@ -2121,7 +2121,7 @@ macro_rules! atomic_int { $int_type:ident $atomic_type:ident) => { /// An integer type which can be safely shared between threads. /// - /// This type has the same in-memory representation as the underlying + /// This type has the same size and bit validity as the underlying /// integer type, [` #[doc = $s_int_type] /// `]. diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 8b3a9e82aad..9017ba79714 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -385,7 +385,7 @@ impl File { /// See the [`OpenOptions::open`] function for more details. /// /// See also [`std::fs::write()`][self::write] for a simple function to - /// create a file with a given data. + /// create a file with some given data. /// /// # Examples /// @@ -1036,7 +1036,7 @@ impl OpenOptions { /// [`OpenOptions::append`] access must be used. /// /// See also [`std::fs::write()`][self::write] for a simple function to - /// create a file with a given data. + /// create a file with some given data. /// /// # Examples /// diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 026c6907999..48596af7ca0 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -2605,8 +2605,12 @@ impl Step for Crate { let mode = self.mode; // See [field@compile::Std::force_recompile]. - builder.ensure(compile::Std::force_recompile(compiler, target)); - builder.ensure(RemoteCopyLibs { compiler, target }); + builder.ensure(compile::Std::force_recompile(compiler, compiler.host)); + + if builder.config.build != target { + builder.ensure(compile::Std::force_recompile(compiler, target)); + builder.ensure(RemoteCopyLibs { compiler, target }); + } // If we're not doing a full bootstrap but we're testing a stage2 // version of libstd, then what we're actually testing is the libstd diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index ef707d179ea..0cdf52bfb00 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -41,7 +41,7 @@ use std::hash::Hash; use std::mem; use thin_vec::ThinVec; -use crate::core::{self, DocContext, ImplTraitParam}; +use crate::core::{self, DocContext}; use crate::formats::item_type::ItemType; use crate::visit_ast::Module as DocModule; @@ -761,7 +761,7 @@ fn clean_ty_generics<'tcx>( ) -> Generics { // Don't populate `cx.impl_trait_bounds` before `clean`ning `where` clauses, // since `Clean for ty::Predicate` would consume them. - let mut impl_trait = BTreeMap::<ImplTraitParam, Vec<GenericBound>>::default(); + let mut impl_trait = BTreeMap::<u32, Vec<GenericBound>>::default(); // Bounds in the type_params and lifetimes fields are repeated in the // predicates field (see rustc_hir_analysis::collect::ty_generics), so remove @@ -778,7 +778,7 @@ fn clean_ty_generics<'tcx>( return None; } if synthetic { - impl_trait.insert(param.index.into(), vec![]); + impl_trait.insert(param.index, vec![]); return None; } Some(clean_generic_param_def(param, cx)) @@ -823,7 +823,7 @@ fn clean_ty_generics<'tcx>( })(); if let Some(param_idx) = param_idx - && let Some(bounds) = impl_trait.get_mut(¶m_idx.into()) + && let Some(bounds) = impl_trait.get_mut(¶m_idx) { let pred = clean_predicate(*pred, cx)?; @@ -847,7 +847,7 @@ fn clean_ty_generics<'tcx>( }) .collect::<Vec<_>>(); - for (param, mut bounds) in impl_trait { + for (idx, mut bounds) in impl_trait { let mut has_sized = false; bounds.retain(|b| { if b.is_sized_bound(cx) { @@ -870,7 +870,6 @@ fn clean_ty_generics<'tcx>( bounds.insert(0, GenericBound::sized(cx)); } - let crate::core::ImplTraitParam::ParamIndex(idx) = param else { unreachable!() }; if let Some(proj) = impl_trait_proj.remove(&idx) { for (trait_did, name, rhs) in proj { let rhs = clean_middle_term(rhs, cx); @@ -878,7 +877,7 @@ fn clean_ty_generics<'tcx>( } } - cx.impl_trait_bounds.insert(param, bounds); + cx.impl_trait_bounds.insert(idx.into(), bounds); } // Now that `cx.impl_trait_bounds` is populated, we can process diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 80a30ac2727..25b78d9598d 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -509,7 +509,7 @@ impl<'tcx> Visitor<'tcx> for EmitIgnoredResolutionErrors<'tcx> { /// `DefId` or parameter index (`ty::ParamTy.index`) of a synthetic type parameter /// for `impl Trait` in argument position. -#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] pub(crate) enum ImplTraitParam { DefId(DefId), ParamIndex(u32), diff --git a/src/librustdoc/html/render/search_index.rs b/src/librustdoc/html/render/search_index.rs index f153a908329..be2786c99ec 100644 --- a/src/librustdoc/html/render/search_index.rs +++ b/src/librustdoc/html/render/search_index.rs @@ -65,8 +65,9 @@ pub(crate) fn build_index<'tcx>( // Sort search index items. This improves the compressibility of the search index. cache.search_index.sort_unstable_by(|k1, k2| { // `sort_unstable_by_key` produces lifetime errors - let k1 = (&k1.path, k1.name.as_str(), &k1.ty, &k1.parent); - let k2 = (&k2.path, k2.name.as_str(), &k2.ty, &k2.parent); + // HACK(rustdoc): should not be sorting `CrateNum` or `DefIndex`, this will soon go away, too + let k1 = (&k1.path, k1.name.as_str(), &k1.ty, k1.parent.map(|id| (id.index, id.krate))); + let k2 = (&k2.path, k2.name.as_str(), &k2.ty, k2.parent.map(|id| (id.index, id.krate))); Ord::cmp(&k1, &k2) }); diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs new file mode 100644 index 00000000000..3ec1988edd6 --- /dev/null +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs @@ -0,0 +1,27 @@ +// Verifies that type metadata identifiers for drop functions are emitted correctly. +// +//@ needs-sanitizer-cfi +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static + +#![crate_type="lib"] + +// CHECK-LABEL: define{{.*}}4core3ptr47drop_in_place$LT$dyn$u20$core..marker..Send$GT$ +// CHECK-SAME: {{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +// CHECK: call i1 @llvm.type.test(ptr {{%.+}}, metadata !"_ZTSFvPu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops4drop4Dropu6regionEE") + +struct EmptyDrop; +// CHECK: define{{.*}}4core3ptr{{[0-9]+}}drop_in_place$LT${{.*}}EmptyDrop$GT${{.*}}!type ![[TYPE1]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} + +struct NonEmptyDrop; + +impl Drop for NonEmptyDrop { + fn drop(&mut self) {} + // CHECK: define{{.*}}4core3ptr{{[0-9]+}}drop_in_place$LT${{.*}}NonEmptyDrop$GT${{.*}}!type ![[TYPE1]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +} + +pub fn foo() { + let _ = Box::new(EmptyDrop) as Box<dyn Send>; + let _ = Box::new(NonEmptyDrop) as Box<dyn Send>; +} + +// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvPu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops4drop4Dropu6regionEE"} diff --git a/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs b/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs index f08c9e6702e..f9c7cca3989 100644 --- a/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs +++ b/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs @@ -29,6 +29,8 @@ impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b trait Freeze { } #[lang="drop_in_place"] fn drop_in_place_fn<T>() { } +#[lang="drop"] +trait Drop { fn drop(&mut self); } pub trait Trait1 { fn foo(&self); diff --git a/tests/rustdoc-gui/target.goml b/tests/rustdoc-gui/target.goml index c5e7f813dd1..26071df8d04 100644 --- a/tests/rustdoc-gui/target.goml +++ b/tests/rustdoc-gui/target.goml @@ -1,4 +1,4 @@ -// Check that the targetted element has the expected styles. +// Check that the targeted element has the expected styles. go-to: "file://" + |DOC_PATH| + "/lib2/struct.Foo.html#method.a_method" show-text: true diff --git a/tests/ui/anonymous-higher-ranked-lifetime.stderr b/tests/ui/anonymous-higher-ranked-lifetime.stderr index cc27a0fcf95..c28d856ad55 100644 --- a/tests/ui/anonymous-higher-ranked-lifetime.stderr +++ b/tests/ui/anonymous-higher-ranked-lifetime.stderr @@ -70,7 +70,7 @@ LL | f4(|_: (), _: ()| {}); | | found signature defined here | expected due to this | - = note: expected closure signature `for<'r, 'a> fn(&'a (), &'r ()) -> _` + = note: expected closure signature `for<'a, 'r> fn(&'a (), &'r ()) -> _` found closure signature `fn((), ()) -> _` note: required by a bound in `f4` --> $DIR/anonymous-higher-ranked-lifetime.rs:19:25 @@ -217,7 +217,7 @@ LL | h2(|_: (), _: (), _: (), _: ()| {}); | | found signature defined here | expected due to this | - = note: expected closure signature `for<'t0, 'a> fn(&'a (), Box<(dyn for<'a> Fn(&'a ()) + 'static)>, &'t0 (), for<'a, 'b> fn(&'a (), &'b ())) -> _` + = note: expected closure signature `for<'a, 't0> fn(&'a (), Box<(dyn for<'a> Fn(&'a ()) + 'static)>, &'t0 (), for<'a, 'b> fn(&'a (), &'b ())) -> _` found closure signature `fn((), (), (), ()) -> _` note: required by a bound in `h2` --> $DIR/anonymous-higher-ranked-lifetime.rs:30:25 diff --git a/tests/ui/associated-consts/associated-const-ambiguity-report.stderr b/tests/ui/associated-consts/associated-const-ambiguity-report.stderr index 42d722291c3..35ee95d1215 100644 --- a/tests/ui/associated-consts/associated-const-ambiguity-report.stderr +++ b/tests/ui/associated-consts/associated-const-ambiguity-report.stderr @@ -4,16 +4,16 @@ error[E0034]: multiple applicable items in scope LL | const X: i32 = <i32>::ID; | ^^ multiple `ID` found | -note: candidate #1 is defined in an impl of the trait `Foo` for the type `i32` - --> $DIR/associated-const-ambiguity-report.rs:10:5 - | -LL | const ID: i32 = 1; - | ^^^^^^^^^^^^^ -note: candidate #2 is defined in an impl of the trait `Bar` for the type `i32` +note: candidate #1 is defined in an impl of the trait `Bar` for the type `i32` --> $DIR/associated-const-ambiguity-report.rs:14:5 | LL | const ID: i32 = 3; | ^^^^^^^^^^^^^ +note: candidate #2 is defined in an impl of the trait `Foo` for the type `i32` + --> $DIR/associated-const-ambiguity-report.rs:10:5 + | +LL | const ID: i32 = 1; + | ^^^^^^^^^^^^^ help: use fully-qualified syntax to disambiguate | LL | const X: i32 = <i32 as Bar>::ID; diff --git a/tests/ui/binop/binary-op-suggest-deref.stderr b/tests/ui/binop/binary-op-suggest-deref.stderr index 8a226d712ff..32bd2554abb 100644 --- a/tests/ui/binop/binary-op-suggest-deref.stderr +++ b/tests/ui/binop/binary-op-suggest-deref.stderr @@ -247,14 +247,14 @@ LL | _ = &&0 == Foo; | = help: the trait `PartialEq<Foo>` is not implemented for `&&{integer}` = help: the following other types implement trait `PartialEq<Rhs>`: - isize - i8 + f32 + f64 + i128 i16 i32 i64 - i128 - usize - u8 + i8 + isize and 6 others error[E0369]: binary operation `==` cannot be applied to type `Foo` @@ -303,10 +303,10 @@ LL | let _ = FOO & (*"Sized".to_string().into_boxed_str()); | = help: the trait `BitAnd<str>` is not implemented for `i32` = help: the following other types implement trait `BitAnd<Rhs>`: - <i32 as BitAnd> - <i32 as BitAnd<&i32>> <&'a i32 as BitAnd<i32>> <&i32 as BitAnd<&i32>> + <i32 as BitAnd<&i32>> + <i32 as BitAnd> error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/binary-op-suggest-deref.rs:78:17 diff --git a/tests/ui/binop/binop-mul-i32-f32.stderr b/tests/ui/binop/binop-mul-i32-f32.stderr index 6ed3e7b4447..29e1ff91834 100644 --- a/tests/ui/binop/binop-mul-i32-f32.stderr +++ b/tests/ui/binop/binop-mul-i32-f32.stderr @@ -6,10 +6,10 @@ LL | x * y | = help: the trait `Mul<f32>` is not implemented for `i32` = help: the following other types implement trait `Mul<Rhs>`: - <i32 as Mul> - <i32 as Mul<&i32>> <&'a i32 as Mul<i32>> <&i32 as Mul<&i32>> + <i32 as Mul<&i32>> + <i32 as Mul> error: aborting due to 1 previous error diff --git a/tests/ui/binop/shift-various-bad-types.stderr b/tests/ui/binop/shift-various-bad-types.stderr index b43672ef3b5..38db66f86b4 100644 --- a/tests/ui/binop/shift-various-bad-types.stderr +++ b/tests/ui/binop/shift-various-bad-types.stderr @@ -6,14 +6,14 @@ LL | 22 >> p.char; | = help: the trait `Shr<char>` is not implemented for `{integer}` = help: the following other types implement trait `Shr<Rhs>`: - <isize as Shr> - <isize as Shr<i8>> - <isize as Shr<i16>> - <isize as Shr<i32>> - <isize as Shr<i64>> - <isize as Shr<i128>> - <isize as Shr<usize>> - <isize as Shr<u8>> + <&'a i128 as Shr<i128>> + <&'a i128 as Shr<i16>> + <&'a i128 as Shr<i32>> + <&'a i128 as Shr<i64>> + <&'a i128 as Shr<i8>> + <&'a i128 as Shr<isize>> + <&'a i128 as Shr<u128>> + <&'a i128 as Shr<u16>> and 568 others error[E0277]: no implementation for `{integer} >> &str` @@ -24,14 +24,14 @@ LL | 22 >> p.str; | = help: the trait `Shr<&str>` is not implemented for `{integer}` = help: the following other types implement trait `Shr<Rhs>`: - <isize as Shr> - <isize as Shr<i8>> - <isize as Shr<i16>> - <isize as Shr<i32>> - <isize as Shr<i64>> - <isize as Shr<i128>> - <isize as Shr<usize>> - <isize as Shr<u8>> + <&'a i128 as Shr<i128>> + <&'a i128 as Shr<i16>> + <&'a i128 as Shr<i32>> + <&'a i128 as Shr<i64>> + <&'a i128 as Shr<i8>> + <&'a i128 as Shr<isize>> + <&'a i128 as Shr<u128>> + <&'a i128 as Shr<u16>> and 568 others error[E0277]: no implementation for `{integer} >> &Panolpy` @@ -42,14 +42,14 @@ LL | 22 >> p; | = help: the trait `Shr<&Panolpy>` is not implemented for `{integer}` = help: the following other types implement trait `Shr<Rhs>`: - <isize as Shr> - <isize as Shr<i8>> - <isize as Shr<i16>> - <isize as Shr<i32>> - <isize as Shr<i64>> - <isize as Shr<i128>> - <isize as Shr<usize>> - <isize as Shr<u8>> + <&'a i128 as Shr<i128>> + <&'a i128 as Shr<i16>> + <&'a i128 as Shr<i32>> + <&'a i128 as Shr<i64>> + <&'a i128 as Shr<i8>> + <&'a i128 as Shr<isize>> + <&'a i128 as Shr<u128>> + <&'a i128 as Shr<u16>> and 568 others error[E0308]: mismatched types diff --git a/tests/ui/const-generics/exhaustive-value.stderr b/tests/ui/const-generics/exhaustive-value.stderr index 42814c1fb70..acaa0cf1a50 100644 --- a/tests/ui/const-generics/exhaustive-value.stderr +++ b/tests/ui/const-generics/exhaustive-value.stderr @@ -6,13 +6,13 @@ LL | <() as Foo<N>>::test() | = help: the following other types implement trait `Foo<N>`: <() as Foo<0>> - <() as Foo<1>> - <() as Foo<2>> - <() as Foo<3>> - <() as Foo<4>> - <() as Foo<5>> - <() as Foo<6>> - <() as Foo<7>> + <() as Foo<100>> + <() as Foo<101>> + <() as Foo<102>> + <() as Foo<103>> + <() as Foo<104>> + <() as Foo<105>> + <() as Foo<106>> and 248 others error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/generic_arg_infer/issue-91614.stderr b/tests/ui/const-generics/generic_arg_infer/issue-91614.stderr index 6d3b0b8508c..5b296a14869 100644 --- a/tests/ui/const-generics/generic_arg_infer/issue-91614.stderr +++ b/tests/ui/const-generics/generic_arg_infer/issue-91614.stderr @@ -6,11 +6,11 @@ LL | let y = Mask::<_, _>::splat(false); | = note: cannot satisfy `_: MaskElement` = help: the following types implement trait `MaskElement`: - isize - i8 i16 i32 i64 + i8 + isize note: required by a bound in `Mask::<T, N>::splat` --> $SRC_DIR/core/src/../../portable-simd/crates/core_simd/src/masks.rs:LL:COL help: consider giving `y` an explicit type, where the type for type parameter `T` is specified diff --git a/tests/ui/const-generics/issues/issue-67185-2.stderr b/tests/ui/const-generics/issues/issue-67185-2.stderr index e39d43205c1..5cc3bb673bc 100644 --- a/tests/ui/const-generics/issues/issue-67185-2.stderr +++ b/tests/ui/const-generics/issues/issue-67185-2.stderr @@ -5,8 +5,8 @@ LL | <u8 as Baz>::Quaks: Bar, | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `[u16; 3]` | = help: the following other types implement trait `Bar`: - [u16; 4] [[u16; 3]; 3] + [u16; 4] = help: see issue #48214 help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | @@ -20,8 +20,8 @@ LL | [<u8 as Baz>::Quaks; 2]: Bar, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]` | = help: the following other types implement trait `Bar`: - [u16; 4] [[u16; 3]; 3] + [u16; 4] = help: see issue #48214 help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | @@ -35,8 +35,8 @@ LL | impl Foo for FooImpl {} | ^^^ the trait `Bar` is not implemented for `[u16; 3]`, which is required by `<u8 as Baz>::Quaks: Bar` | = help: the following other types implement trait `Bar`: - [u16; 4] [[u16; 3]; 3] + [u16; 4] note: required by a bound in `Foo` --> $DIR/issue-67185-2.rs:15:25 | @@ -53,8 +53,8 @@ LL | impl Foo for FooImpl {} | ^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]`, which is required by `[<u8 as Baz>::Quaks; 2]: Bar` | = help: the following other types implement trait `Bar`: - [u16; 4] [[u16; 3]; 3] + [u16; 4] note: required by a bound in `Foo` --> $DIR/issue-67185-2.rs:14:30 | @@ -71,8 +71,8 @@ LL | fn f(_: impl Foo) {} | ^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]` | = help: the following other types implement trait `Bar`: - [u16; 4] [[u16; 3]; 3] + [u16; 4] note: required by a bound in `Foo` --> $DIR/issue-67185-2.rs:14:30 | @@ -89,8 +89,8 @@ LL | fn f(_: impl Foo) {} | ^^^ the trait `Bar` is not implemented for `[u16; 3]` | = help: the following other types implement trait `Bar`: - [u16; 4] [[u16; 3]; 3] + [u16; 4] note: required by a bound in `Foo` --> $DIR/issue-67185-2.rs:15:25 | diff --git a/tests/ui/consts/const-eval/const-eval-overflow-3b.stderr b/tests/ui/consts/const-eval/const-eval-overflow-3b.stderr index 06e398edca9..05f33c33946 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-3b.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow-3b.stderr @@ -12,10 +12,10 @@ LL | = [0; (i8::MAX + 1u8) as usize]; | = help: the trait `Add<u8>` is not implemented for `i8` = help: the following other types implement trait `Add<Rhs>`: - <i8 as Add> - <i8 as Add<&i8>> <&'a i8 as Add<i8>> <&i8 as Add<&i8>> + <i8 as Add<&i8>> + <i8 as Add> error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr b/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr index 07ef2ac090f..d019f5920b5 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr @@ -12,10 +12,10 @@ LL | : [u32; (i8::MAX as i8 + 1u8) as usize] | = help: the trait `Add<u8>` is not implemented for `i8` = help: the following other types implement trait `Add<Rhs>`: - <i8 as Add> - <i8 as Add<&i8>> <&'a i8 as Add<i8>> <&i8 as Add<&i8>> + <i8 as Add<&i8>> + <i8 as Add> error[E0604]: only `u8` can be cast as `char`, not `i8` --> $DIR/const-eval-overflow-4b.rs:22:13 diff --git a/tests/ui/consts/missing-larger-array-impl.stderr b/tests/ui/consts/missing-larger-array-impl.stderr index acf38d00ec6..ff4fa36d684 100644 --- a/tests/ui/consts/missing-larger-array-impl.stderr +++ b/tests/ui/consts/missing-larger-array-impl.stderr @@ -5,14 +5,14 @@ LL | <[X; 35] as Default>::default(); | ^^^^^^^ the trait `Default` is not implemented for `[X; 35]` | = help: the following other types implement trait `Default`: + &[T] + &mut [T] [T; 0] - [T; 1] - [T; 2] - [T; 3] - [T; 4] - [T; 5] - [T; 6] - [T; 7] + [T; 10] + [T; 11] + [T; 12] + [T; 13] + [T; 14] and 27 others error: aborting due to 1 previous error diff --git a/tests/ui/consts/missing_assoc_const_type.rs b/tests/ui/consts/missing_assoc_const_type.rs new file mode 100644 index 00000000000..8d95e3dca63 --- /dev/null +++ b/tests/ui/consts/missing_assoc_const_type.rs @@ -0,0 +1,28 @@ +//! Test that we compute the right type for associated constants +//! of impls, even if the type is missing. We know it from the trait +//! declaration after all. + +trait Range { + const FIRST: u8; + const LAST: u8; +} + +struct TwoDigits; +impl Range for TwoDigits { + const FIRST: = 10; + //~^ ERROR: missing type for `const` item + const LAST: u8 = 99; +} + +const fn digits(x: u8) -> usize { + match x { + TwoDigits::FIRST..=TwoDigits::LAST => 0, + 0..=9 | 100..=255 => panic!(), + } +} + +const FOOMP: [(); { + digits(42) +}] = []; + +fn main() {} diff --git a/tests/ui/consts/missing_assoc_const_type.stderr b/tests/ui/consts/missing_assoc_const_type.stderr new file mode 100644 index 00000000000..28af1f0f321 --- /dev/null +++ b/tests/ui/consts/missing_assoc_const_type.stderr @@ -0,0 +1,8 @@ +error: missing type for `const` item + --> $DIR/missing_assoc_const_type.rs:12:17 + | +LL | const FIRST: = 10; + | ^ help: provide a type for the associated constant: `u8` + +error: aborting due to 1 previous error + diff --git a/tests/ui/consts/missing_assoc_const_type2.rs b/tests/ui/consts/missing_assoc_const_type2.rs new file mode 100644 index 00000000000..baf236700a3 --- /dev/null +++ b/tests/ui/consts/missing_assoc_const_type2.rs @@ -0,0 +1,21 @@ +//! Test that we compute the right type for associated constants +//! of impls, even if the type is missing. We know it from the trait +//! declaration after all. + +trait Range { + const FIRST: u8; + const LAST: u8; +} + +struct TwoDigits; +impl Range for TwoDigits { + const FIRST: = 10; + //~^ ERROR: missing type + const LAST: u8 = 99; +} + +const FOOMP: [(); { + TwoDigits::FIRST as usize +}] = [(); 10]; + +fn main() {} diff --git a/tests/ui/consts/missing_assoc_const_type2.stderr b/tests/ui/consts/missing_assoc_const_type2.stderr new file mode 100644 index 00000000000..1255ca2d102 --- /dev/null +++ b/tests/ui/consts/missing_assoc_const_type2.stderr @@ -0,0 +1,8 @@ +error: missing type for `const` item + --> $DIR/missing_assoc_const_type2.rs:12:17 + | +LL | const FIRST: = 10; + | ^ help: provide a type for the associated constant: `u8` + +error: aborting due to 1 previous error + diff --git a/tests/ui/consts/too_generic_eval_ice.stderr b/tests/ui/consts/too_generic_eval_ice.stderr index 4089c850c80..54dffa3befc 100644 --- a/tests/ui/consts/too_generic_eval_ice.stderr +++ b/tests/ui/consts/too_generic_eval_ice.stderr @@ -22,14 +22,14 @@ LL | [5; Self::HOST_SIZE] == [6; 0] | = help: the trait `PartialEq<[{integer}; 0]>` is not implemented for `[{integer}; Self::HOST_SIZE]` = help: the following other types implement trait `PartialEq<Rhs>`: - <[T; N] as PartialEq<[U; N]>> - <[T; N] as PartialEq<[U]>> + <&[T] as PartialEq<Vec<U, A>>> + <&[T] as PartialEq<[U; N]>> + <&mut [T] as PartialEq<Vec<U, A>>> + <&mut [T] as PartialEq<[U; N]>> <[T; N] as PartialEq<&[U]>> <[T; N] as PartialEq<&mut [U]>> - <[T] as PartialEq<Vec<U, A>>> - <[T] as PartialEq<[U; N]>> - <[T] as PartialEq<[U]>> - <&[T] as PartialEq<Vec<U, A>>> + <[T; N] as PartialEq<[U; N]>> + <[T; N] as PartialEq<[U]>> and 3 others error: aborting due to 3 previous errors diff --git a/tests/ui/delegation/bad-resolve.rs b/tests/ui/delegation/bad-resolve.rs index df456f94507..d2723dc32e0 100644 --- a/tests/ui/delegation/bad-resolve.rs +++ b/tests/ui/delegation/bad-resolve.rs @@ -1,5 +1,5 @@ #![feature(fn_delegation)] -//~^ WARN the feature `fn_delegation` is incomplete +#![allow(incomplete_features)] trait Trait { const C: u32 = 0; @@ -34,14 +34,6 @@ impl Trait for S { reuse foo { &self.0 } //~^ ERROR cannot find function `foo` in this scope - reuse F::foo { &self.0 } - //~^ ERROR cannot find function `foo` in `F` - //~| ERROR duplicate definitions with name `foo` -} - -impl S { - reuse F::foo { &self.0 } - //~^ ERROR cannot find function `foo` in `F` } fn main() {} diff --git a/tests/ui/delegation/bad-resolve.stderr b/tests/ui/delegation/bad-resolve.stderr index d5206637310..f669ac3730e 100644 --- a/tests/ui/delegation/bad-resolve.stderr +++ b/tests/ui/delegation/bad-resolve.stderr @@ -25,18 +25,6 @@ LL | reuse <F as Trait>::baz; | | help: there is an associated function with a similar name: `bar` | not a member of trait `Trait` -error[E0201]: duplicate definitions with name `foo`: - --> $DIR/bad-resolve.rs:37:5 - | -LL | fn foo(&self, x: i32) -> i32 { x } - | ---------------------------------- item in trait -... -LL | reuse foo { &self.0 } - | --------------------- previous definition here -LL | -LL | reuse F::foo { &self.0 } - | ^^^^^^^^^^^^^^^^^^^^^^^^ duplicate definition - error[E0423]: expected function, found associated constant `Trait::C` --> $DIR/bad-resolve.rs:24:11 | @@ -66,27 +54,6 @@ error[E0425]: cannot find function `foo` in this scope LL | reuse foo { &self.0 } | ^^^ not found in this scope -error[E0425]: cannot find function `foo` in `F` - --> $DIR/bad-resolve.rs:37:14 - | -LL | reuse F::foo { &self.0 } - | ^^^ not found in `F` - -error[E0425]: cannot find function `foo` in `F` - --> $DIR/bad-resolve.rs:43:14 - | -LL | reuse F::foo { &self.0 } - | ^^^ not found in `F` - -warning: the feature `fn_delegation` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/bad-resolve.rs:1:12 - | -LL | #![feature(fn_delegation)] - | ^^^^^^^^^^^^^ - | - = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0046]: not all trait items implemented, missing: `Type` --> $DIR/bad-resolve.rs:22:1 | @@ -96,7 +63,7 @@ LL | type Type; LL | impl Trait for S { | ^^^^^^^^^^^^^^^^ missing `Type` in implementation -error: aborting due to 11 previous errors; 1 warning emitted +error: aborting due to 8 previous errors -Some errors have detailed explanations: E0046, E0201, E0324, E0407, E0423, E0425, E0575, E0576. +Some errors have detailed explanations: E0046, E0324, E0407, E0423, E0425, E0575, E0576. For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/delegation/duplicate-definition-inside-trait-impl.rs b/tests/ui/delegation/duplicate-definition-inside-trait-impl.rs index bd685b40b2f..9c7afcef3ec 100644 --- a/tests/ui/delegation/duplicate-definition-inside-trait-impl.rs +++ b/tests/ui/delegation/duplicate-definition-inside-trait-impl.rs @@ -1,5 +1,5 @@ #![feature(fn_delegation)] -//~^ WARN the feature `fn_delegation` is incomplete +#![allow(incomplete_features)] trait Trait { fn foo(&self) -> u32 { 0 } diff --git a/tests/ui/delegation/duplicate-definition-inside-trait-impl.stderr b/tests/ui/delegation/duplicate-definition-inside-trait-impl.stderr index a5f9e6ad0bf..a0f157800cb 100644 --- a/tests/ui/delegation/duplicate-definition-inside-trait-impl.stderr +++ b/tests/ui/delegation/duplicate-definition-inside-trait-impl.stderr @@ -9,15 +9,6 @@ LL | reuse to_reuse::foo { self } LL | reuse Trait::foo; | ^^^^^^^^^^^^^^^^^ duplicate definition -warning: the feature `fn_delegation` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/duplicate-definition-inside-trait-impl.rs:1:12 - | -LL | #![feature(fn_delegation)] - | ^^^^^^^^^^^^^ - | - = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information - = note: `#[warn(incomplete_features)]` on by default - -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0201`. diff --git a/tests/ui/delegation/explicit-paths-in-traits-pass.rs b/tests/ui/delegation/explicit-paths-in-traits-pass.rs index 4abcc18b9b2..7d281ad150a 100644 --- a/tests/ui/delegation/explicit-paths-in-traits-pass.rs +++ b/tests/ui/delegation/explicit-paths-in-traits-pass.rs @@ -1,7 +1,7 @@ //@ run-pass #![feature(fn_delegation)] -//~^ WARN the feature `fn_delegation` is incomplete +#![allow(incomplete_features)] trait ToReuse { fn foo(&self, x: i32) -> i32 { x } diff --git a/tests/ui/delegation/explicit-paths-in-traits-pass.stderr b/tests/ui/delegation/explicit-paths-in-traits-pass.stderr deleted file mode 100644 index 8a320b44e63..00000000000 --- a/tests/ui/delegation/explicit-paths-in-traits-pass.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `fn_delegation` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/explicit-paths-in-traits-pass.rs:3:12 - | -LL | #![feature(fn_delegation)] - | ^^^^^^^^^^^^^ - | - = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/delegation/explicit-paths-pass.rs b/tests/ui/delegation/explicit-paths-pass.rs index 140605a2bc5..fada793bd11 100644 --- a/tests/ui/delegation/explicit-paths-pass.rs +++ b/tests/ui/delegation/explicit-paths-pass.rs @@ -1,7 +1,7 @@ //@ run-pass #![feature(fn_delegation)] -//~^ WARN the feature `fn_delegation` is incomplete +#![allow(incomplete_features)] trait Trait { fn bar(&self, x: i32) -> i32 { x } @@ -10,7 +10,6 @@ trait Trait { } fn static_method(x: i32) -> i32 { x } fn static_method2(x: i32, y: i32) -> i32 { x + y } - fn baz<'a>(&self, x: &'a i32) -> &'a i32 { x } } struct F; @@ -29,11 +28,9 @@ impl Trait for S { reuse Trait::description { &self.0 } reuse <F as Trait>::static_method; reuse <F as Trait>::static_method2 { S::static_method(self) } - reuse Trait::baz { &self.0 } } impl S { - reuse Trait::baz { &self.0 } reuse <F as Trait>::static_method { to_reuse::foo(self) } } @@ -49,16 +46,8 @@ fn main() { assert_eq!(42, <S as Trait>::static_method(42)); assert_eq!(21, S::static_method2(10, 10)); - reuse <S as Trait>::static_method; - reuse <S as Trait>::static_method2 { static_method(self) } #[inline] reuse to_reuse::foo; - assert_eq!(42, static_method(42)); - assert_eq!(21, static_method2(10, 10)); assert_eq!(43, foo(42)); assert_eq!(15, zero_args()); - - let x: i32 = 15; - assert_eq!(&x, <S as Trait>::baz(&s, &x)); - assert_eq!(&x, S::baz(&s, &x)); } diff --git a/tests/ui/delegation/explicit-paths-pass.stderr b/tests/ui/delegation/explicit-paths-pass.stderr deleted file mode 100644 index 6d25fb4a5a5..00000000000 --- a/tests/ui/delegation/explicit-paths-pass.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `fn_delegation` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/explicit-paths-pass.rs:3:12 - | -LL | #![feature(fn_delegation)] - | ^^^^^^^^^^^^^ - | - = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/delegation/explicit-paths-signature-pass.rs b/tests/ui/delegation/explicit-paths-signature-pass.rs index b53e5779924..8c16ad92393 100644 --- a/tests/ui/delegation/explicit-paths-signature-pass.rs +++ b/tests/ui/delegation/explicit-paths-signature-pass.rs @@ -1,7 +1,7 @@ //@ run-pass #![feature(fn_delegation)] -//~^ WARN the feature `fn_delegation` is incomplete +#![allow(incomplete_features)] mod to_reuse { use crate::S; diff --git a/tests/ui/delegation/explicit-paths-signature-pass.stderr b/tests/ui/delegation/explicit-paths-signature-pass.stderr deleted file mode 100644 index 6c81a2ea0af..00000000000 --- a/tests/ui/delegation/explicit-paths-signature-pass.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `fn_delegation` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/explicit-paths-signature-pass.rs:3:12 - | -LL | #![feature(fn_delegation)] - | ^^^^^^^^^^^^^ - | - = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/delegation/explicit-paths.rs b/tests/ui/delegation/explicit-paths.rs index 1feaaa73f79..a91ca4cb931 100644 --- a/tests/ui/delegation/explicit-paths.rs +++ b/tests/ui/delegation/explicit-paths.rs @@ -1,25 +1,84 @@ #![feature(fn_delegation)] -//~^ WARN the feature `fn_delegation` is incomplete +#![allow(incomplete_features)] trait Trait { - fn bar(&self) -> i32 { 42 } + fn foo1(&self, x: i32) -> i32 { x } + fn foo2(x: i32) -> i32 { x } } struct F; impl Trait for F {} - struct S(F); -impl Trait for S { - reuse <F as Trait>::bar; - //~^ ERROR mismatched types +pub mod to_reuse { + pub fn foo3() {} +} + +impl F { + fn foo4(&self) {} +} + +mod fn_to_other { + use super::*; + + reuse Trait::foo1; + //~^ ERROR delegation to a trait method from a free function is not supported yet + reuse <S as Trait>::foo2; + //~^ ERROR delegation to a trait method from a free function is not supported yet + reuse to_reuse::foo3; + reuse S::foo4; + //~^ ERROR cannot find function `foo4` in `S` +} + +mod inherent_impl_assoc_fn_to_other { + use crate::*; + + impl S { + reuse Trait::foo1 { &self.0 } + reuse <S as Trait>::foo2; + reuse to_reuse::foo3; + reuse F::foo4 { &self.0 } + //~^ ERROR cannot find function `foo4` in `F` + } +} + +mod trait_impl_assoc_fn_to_other { + use crate::*; + + impl Trait for S { + reuse Trait::foo1 { &self.0 } + reuse <F as Trait>::foo2; + reuse to_reuse::foo3; + //~^ ERROR method `foo3` is not a member of trait `Trait` + reuse F::foo4 { &self.0 } + //~^ ERROR method `foo4` is not a member of trait `Trait` + //~| ERROR cannot find function `foo4` in `F` + } +} + +mod trait_assoc_fn_to_other { + use crate::*; + + trait Trait2 : Trait { + reuse <F as Trait>::foo1 { self } + //~^ ERROR mismatched types + reuse <F as Trait>::foo2; + reuse to_reuse::foo3; + reuse F::foo4 { &F } + //~^ ERROR cannot find function `foo4` in `F` + } } -struct S2(F); +mod type_mismatch { + use crate::*; -impl Trait for S2 { - reuse <S2 as Trait>::bar { &self.0 } - //~^ ERROR mismatched types + struct S2; + impl Trait for S { + //~^ ERROR conflicting implementations of trait `Trait` for type `S` + reuse <S2 as Trait>::foo1; + //~^ ERROR mismatched types + //~| ERROR the trait bound `S2: Trait` is not satisfied + } } fn main() {} diff --git a/tests/ui/delegation/explicit-paths.stderr b/tests/ui/delegation/explicit-paths.stderr index 2994b2390de..30891c94c0e 100644 --- a/tests/ui/delegation/explicit-paths.stderr +++ b/tests/ui/delegation/explicit-paths.stderr @@ -1,38 +1,129 @@ -warning: the feature `fn_delegation` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/explicit-paths.rs:1:12 +error[E0407]: method `foo3` is not a member of trait `Trait` + --> $DIR/explicit-paths.rs:51:9 | -LL | #![feature(fn_delegation)] - | ^^^^^^^^^^^^^ +LL | reuse to_reuse::foo3; + | ^^^^^^^^^^^^^^^^----^ + | | | + | | help: there is an associated function with a similar name: `foo1` + | not a member of trait `Trait` + +error[E0407]: method `foo4` is not a member of trait `Trait` + --> $DIR/explicit-paths.rs:53:9 + | +LL | reuse F::foo4 { &self.0 } + | ^^^^^^^^^----^^^^^^^^^^^^ + | | | + | | help: there is an associated function with a similar name: `foo1` + | not a member of trait `Trait` + +error[E0425]: cannot find function `foo4` in `S` + --> $DIR/explicit-paths.rs:29:14 + | +LL | reuse S::foo4; + | ^^^^ not found in `S` + +error[E0425]: cannot find function `foo4` in `F` + --> $DIR/explicit-paths.rs:40:18 + | +LL | reuse F::foo4 { &self.0 } + | ^^^^ not found in `F` + | +note: function `fn_to_other::foo4` exists but is inaccessible + --> $DIR/explicit-paths.rs:29:5 + | +LL | reuse S::foo4; + | ^^^^^^^^^^^^^^ not accessible + +error[E0425]: cannot find function `foo4` in `F` + --> $DIR/explicit-paths.rs:53:18 + | +LL | reuse F::foo4 { &self.0 } + | ^^^^ not found in `F` + | +note: function `fn_to_other::foo4` exists but is inaccessible + --> $DIR/explicit-paths.rs:29:5 + | +LL | reuse S::foo4; + | ^^^^^^^^^^^^^^ not accessible + +error[E0425]: cannot find function `foo4` in `F` + --> $DIR/explicit-paths.rs:67:18 + | +LL | reuse F::foo4 { &F } + | ^^^^ not found in `F` + | +note: function `fn_to_other::foo4` exists but is inaccessible + --> $DIR/explicit-paths.rs:29:5 | - = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information - = note: `#[warn(incomplete_features)]` on by default +LL | reuse S::foo4; + | ^^^^^^^^^^^^^^ not accessible + +error[E0119]: conflicting implementations of trait `Trait` for type `S` + --> $DIR/explicit-paths.rs:76:5 + | +LL | impl Trait for S { + | ---------------- first implementation here +... +LL | impl Trait for S { + | ^^^^^^^^^^^^^^^^ conflicting implementation for `S` + +error: delegation to a trait method from a free function is not supported yet + --> $DIR/explicit-paths.rs:24:18 + | +LL | fn foo1(&self, x: i32) -> i32 { x } + | ----------------------------- callee defined here +... +LL | reuse Trait::foo1; + | ^^^^ + +error: delegation to a trait method from a free function is not supported yet + --> $DIR/explicit-paths.rs:26:25 + | +LL | fn foo2(x: i32) -> i32 { x } + | ---------------------- callee defined here +... +LL | reuse <S as Trait>::foo2; + | ^^^^ error[E0308]: mismatched types - --> $DIR/explicit-paths.rs:14:25 + --> $DIR/explicit-paths.rs:63:36 | -LL | reuse <F as Trait>::bar; - | --------------^^^ - | | | - | | expected `&F`, found `&S` - | arguments to this function are incorrect +LL | trait Trait2 : Trait { + | -------------------- found this type parameter +LL | reuse <F as Trait>::foo1 { self } + | ^^^^ expected `&F`, found `&Self` | = note: expected reference `&F` - found reference `&S` -note: method defined here - --> $DIR/explicit-paths.rs:5:8 + found reference `&Self` + +error[E0277]: the trait bound `S2: Trait` is not satisfied + --> $DIR/explicit-paths.rs:78:16 | -LL | fn bar(&self) -> i32 { 42 } - | ^^^ ----- +LL | reuse <S2 as Trait>::foo1; + | ^^ the trait `Trait` is not implemented for `S2` + | + = help: the following other types implement trait `Trait`: + F + S error[E0308]: mismatched types - --> $DIR/explicit-paths.rs:21:32 + --> $DIR/explicit-paths.rs:78:30 | -LL | reuse <S2 as Trait>::bar { &self.0 } - | ^^^^^^^ expected `&S2`, found `&F` +LL | reuse <S2 as Trait>::foo1; + | ---------------^^^^ + | | | + | | expected `&S2`, found `&S` + | arguments to this function are incorrect | = note: expected reference `&S2` - found reference `&F` + found reference `&S` +note: method defined here + --> $DIR/explicit-paths.rs:5:8 + | +LL | fn foo1(&self, x: i32) -> i32 { x } + | ^^^^ ----- -error: aborting due to 2 previous errors; 1 warning emitted +error: aborting due to 12 previous errors -For more information about this error, try `rustc --explain E0308`. +Some errors have detailed explanations: E0119, E0277, E0308, E0407, E0425. +For more information about an error, try `rustc --explain E0119`. diff --git a/tests/ui/delegation/not-supported.rs b/tests/ui/delegation/not-supported.rs index 23081b1e1fc..9dccb12b57a 100644 --- a/tests/ui/delegation/not-supported.rs +++ b/tests/ui/delegation/not-supported.rs @@ -1,6 +1,6 @@ #![feature(c_variadic)] #![feature(fn_delegation)] -//~^ WARN the feature `fn_delegation` is incomplete +#![allow(incomplete_features)] mod generics { trait GenericTrait<T> { diff --git a/tests/ui/delegation/not-supported.stderr b/tests/ui/delegation/not-supported.stderr index 324b79f3c53..f6c49366899 100644 --- a/tests/ui/delegation/not-supported.stderr +++ b/tests/ui/delegation/not-supported.stderr @@ -1,12 +1,3 @@ -warning: the feature `fn_delegation` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/not-supported.rs:2:12 - | -LL | #![feature(fn_delegation)] - | ^^^^^^^^^^^^^ - | - = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information - = note: `#[warn(incomplete_features)]` on by default - error: delegation with early bound generics is not supported yet --> $DIR/not-supported.rs:16:29 | @@ -178,7 +169,7 @@ LL | pub reuse to_reuse2::foo; LL | reuse to_reuse1::foo; | ^^^ -error: aborting due to 19 previous errors; 1 warning emitted +error: aborting due to 19 previous errors Some errors have detailed explanations: E0049, E0195. For more information about an error, try `rustc --explain E0049`. diff --git a/tests/ui/delegation/parse.rs b/tests/ui/delegation/parse.rs index 5e8026c5532..72b00bf6e0d 100644 --- a/tests/ui/delegation/parse.rs +++ b/tests/ui/delegation/parse.rs @@ -2,7 +2,7 @@ #![feature(decl_macro)] #![feature(fn_delegation)] -//~^ WARN the feature `fn_delegation` is incomplete +#![allow(incomplete_features)] macro_rules! reuse { {} => {} } diff --git a/tests/ui/delegation/parse.stderr b/tests/ui/delegation/parse.stderr deleted file mode 100644 index 1e420ceeec7..00000000000 --- a/tests/ui/delegation/parse.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `fn_delegation` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/parse.rs:4:12 - | -LL | #![feature(fn_delegation)] - | ^^^^^^^^^^^^^ - | - = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/delegation/target-expr-pass.rs b/tests/ui/delegation/target-expr-pass.rs index 1f2edf0dc13..9e326a19b8f 100644 --- a/tests/ui/delegation/target-expr-pass.rs +++ b/tests/ui/delegation/target-expr-pass.rs @@ -1,7 +1,7 @@ //@ run-pass #![feature(fn_delegation)] -//~^ WARN the feature `fn_delegation` is incomplete +#![allow(incomplete_features)] mod to_reuse { pub fn foo(x: i32) -> i32 { x } diff --git a/tests/ui/delegation/target-expr-pass.stderr b/tests/ui/delegation/target-expr-pass.stderr index dd1f3a14e0b..c8d73ec6e5a 100644 --- a/tests/ui/delegation/target-expr-pass.stderr +++ b/tests/ui/delegation/target-expr-pass.stderr @@ -1,12 +1,3 @@ -warning: the feature `fn_delegation` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/target-expr-pass.rs:3:12 - | -LL | #![feature(fn_delegation)] - | ^^^^^^^^^^^^^ - | - = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information - = note: `#[warn(incomplete_features)]` on by default - warning: trait `Trait` is never used --> $DIR/target-expr-pass.rs:17:7 | @@ -27,5 +18,5 @@ warning: struct `S` is never constructed LL | struct S(F); | ^ -warning: 4 warnings emitted +warning: 3 warnings emitted diff --git a/tests/ui/delegation/target-expr.rs b/tests/ui/delegation/target-expr.rs index b9c6fe92810..fd7ea943b9d 100644 --- a/tests/ui/delegation/target-expr.rs +++ b/tests/ui/delegation/target-expr.rs @@ -14,8 +14,9 @@ fn foo(x: i32) -> i32 { x } fn bar<T: Default>(_: T) { reuse Trait::static_method { - //~^ ERROR delegation with early bound generics is not supported yet - //~| ERROR mismatched types + //~^ ERROR delegation to a trait method from a free function is not supported yet + //~| ERROR delegation with early bound generics is not supported yet + //~| ERROR mismatched types let _ = T::Default(); //~^ ERROR can't use generic parameters from outer item } @@ -24,6 +25,7 @@ fn bar<T: Default>(_: T) { fn main() { let y = 0; reuse <S as Trait>::static_method { + //~^ ERROR delegation to a trait method from a free function is not supported yet let x = y; //~^ ERROR can't capture dynamic environment in a fn item foo(self); diff --git a/tests/ui/delegation/target-expr.stderr b/tests/ui/delegation/target-expr.stderr index da0fac2f5e4..b30f0c474c6 100644 --- a/tests/ui/delegation/target-expr.stderr +++ b/tests/ui/delegation/target-expr.stderr @@ -1,5 +1,5 @@ error[E0401]: can't use generic parameters from outer item - --> $DIR/target-expr.rs:19:17 + --> $DIR/target-expr.rs:20:17 | LL | fn bar<T: Default>(_: T) { | - type parameter from outer item @@ -10,7 +10,7 @@ LL | let _ = T::Default(); | ^^^^^^^^^^ use of generic parameter from outer item error[E0434]: can't capture dynamic environment in a fn item - --> $DIR/target-expr.rs:27:17 + --> $DIR/target-expr.rs:29:17 | LL | let x = y; | ^ @@ -18,7 +18,7 @@ LL | let x = y; = help: use the `|| { ... }` closure form instead error[E0424]: expected value, found module `self` - --> $DIR/target-expr.rs:34:5 + --> $DIR/target-expr.rs:36:5 | LL | fn main() { | ---- this function can't have a `self` parameter @@ -27,13 +27,13 @@ LL | self.0; | ^^^^ `self` value is a keyword only available in methods with a `self` parameter error[E0425]: cannot find value `x` in this scope - --> $DIR/target-expr.rs:36:13 + --> $DIR/target-expr.rs:38:13 | LL | let z = x; | ^ | help: the binding `x` is available in a different scope in the same function - --> $DIR/target-expr.rs:27:13 + --> $DIR/target-expr.rs:29:13 | LL | let x = y; | ^ @@ -47,6 +47,24 @@ LL | fn static_method(x: i32) -> i32 { x } LL | reuse Trait::static_method { | ^^^^^^^^^^^^^ +error: delegation to a trait method from a free function is not supported yet + --> $DIR/target-expr.rs:16:18 + | +LL | fn static_method(x: i32) -> i32 { x } + | ------------------------------- callee defined here +... +LL | reuse Trait::static_method { + | ^^^^^^^^^^^^^ + +error: delegation to a trait method from a free function is not supported yet + --> $DIR/target-expr.rs:27:25 + | +LL | fn static_method(x: i32) -> i32 { x } + | ------------------------------- callee defined here +... +LL | reuse <S as Trait>::static_method { + | ^^^^^^^^^^^^^ + error[E0308]: mismatched types --> $DIR/target-expr.rs:16:32 | @@ -54,12 +72,13 @@ LL | reuse Trait::static_method { | ________________________________^ LL | | LL | | +LL | | LL | | let _ = T::Default(); LL | | LL | | } | |_____^ expected `i32`, found `()` -error: aborting due to 6 previous errors +error: aborting due to 8 previous errors Some errors have detailed explanations: E0308, E0401, E0424, E0425, E0434. For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/deriving/issue-103157.stderr b/tests/ui/deriving/issue-103157.stderr index f76701860ef..612a7aff225 100644 --- a/tests/ui/deriving/issue-103157.stderr +++ b/tests/ui/deriving/issue-103157.stderr @@ -8,14 +8,14 @@ LL | Float(Option<f64>), | ^^^^^^^^^^^ the trait `Eq` is not implemented for `f64`, which is required by `Option<f64>: Eq` | = help: the following other types implement trait `Eq`: - isize - i8 + i128 i16 i32 i64 - i128 - usize - u8 + i8 + isize + u128 + u16 and 4 others = note: required for `Option<f64>` to implement `Eq` note: required by a bound in `AssertParamIsEq` diff --git a/tests/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr b/tests/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr index 6ac0bf21e4a..a2b7d804cb8 100644 --- a/tests/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr +++ b/tests/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr @@ -7,12 +7,12 @@ LL | f1.foo(1usize); | required by a bound introduced by this call | = help: the following other types implement trait `Foo<A>`: - <Bar as Foo<i8>> <Bar as Foo<i16>> <Bar as Foo<i32>> - <Bar as Foo<u8>> + <Bar as Foo<i8>> <Bar as Foo<u16>> <Bar as Foo<u32>> + <Bar as Foo<u8>> error: aborting due to 1 previous error diff --git a/tests/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr b/tests/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr index ae15e054f62..7229b9ac986 100644 --- a/tests/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr +++ b/tests/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr @@ -8,10 +8,10 @@ LL | Foo::<i32>::bar(&1i8); | = help: the following other types implement trait `Foo<B>`: <i8 as Foo<bool>> - <i8 as Foo<u8>> <i8 as Foo<u16>> <i8 as Foo<u32>> <i8 as Foo<u64>> + <i8 as Foo<u8>> error[E0277]: the trait bound `u8: Foo<i32>` is not satisfied --> $DIR/issue-39802-show-5-trait-impls.rs:25:21 @@ -38,10 +38,10 @@ LL | Foo::<i32>::bar(&true); = help: the following other types implement trait `Foo<B>`: <bool as Foo<bool>> <bool as Foo<i8>> - <bool as Foo<u8>> <bool as Foo<u16>> <bool as Foo<u32>> <bool as Foo<u64>> + <bool as Foo<u8>> error: aborting due to 3 previous errors diff --git a/tests/ui/fmt/ifmt-unimpl.stderr b/tests/ui/fmt/ifmt-unimpl.stderr index 3c5428e59fb..a22bba07c02 100644 --- a/tests/ui/fmt/ifmt-unimpl.stderr +++ b/tests/ui/fmt/ifmt-unimpl.stderr @@ -7,14 +7,14 @@ LL | format!("{:X}", "3"); | required by a bound introduced by this call | = help: the following other types implement trait `UpperHex`: - isize - i8 + &T + &mut T + NonZero<T> + Saturating<T> + Wrapping<T> + i128 i16 i32 - i64 - i128 - usize - u8 and 9 others = note: required for `&str` to implement `UpperHex` note: required by a bound in `core::fmt::rt::Argument::<'a>::new_upper_hex` diff --git a/tests/ui/impl-trait/equality.stderr b/tests/ui/impl-trait/equality.stderr index 9b8bff215e0..69f4cbbbf42 100644 --- a/tests/ui/impl-trait/equality.stderr +++ b/tests/ui/impl-trait/equality.stderr @@ -30,10 +30,10 @@ LL | n + sum_to(n - 1) | = help: the trait `Add<impl Foo>` is not implemented for `u32` = help: the following other types implement trait `Add<Rhs>`: - <u32 as Add> - <u32 as Add<&u32>> <&'a u32 as Add<u32>> <&u32 as Add<&u32>> + <u32 as Add<&u32>> + <u32 as Add> error: aborting due to 2 previous errors; 1 warning emitted diff --git a/tests/ui/impl-trait/impl_trait_projections.stderr b/tests/ui/impl-trait/impl_trait_projections.stderr index 421afc96eed..d62e3ac4183 100644 --- a/tests/ui/impl-trait/impl_trait_projections.stderr +++ b/tests/ui/impl-trait/impl_trait_projections.stderr @@ -35,14 +35,14 @@ LL | -> <::std::ops::Range<impl Debug> as Iterator>::Item | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Step` is not implemented for `impl Debug`, which is required by `std::ops::Range<impl Debug>: Iterator` | = help: the following other types implement trait `Step`: + Char + Ipv4Addr + Ipv6Addr char - isize - i8 + i128 i16 i32 i64 - i128 - usize and 8 others = note: required for `std::ops::Range<impl Debug>` to implement `Iterator` @@ -56,14 +56,14 @@ LL | | } | |_^ the trait `Step` is not implemented for `impl Debug`, which is required by `std::ops::Range<impl Debug>: Iterator` | = help: the following other types implement trait `Step`: + Char + Ipv4Addr + Ipv6Addr char - isize - i8 + i128 i16 i32 i64 - i128 - usize and 8 others = note: required for `std::ops::Range<impl Debug>` to implement `Iterator` diff --git a/tests/ui/impl-trait/no-method-suggested-traits.stderr b/tests/ui/impl-trait/no-method-suggested-traits.stderr index 7a4dc366618..676247d1a42 100644 --- a/tests/ui/impl-trait/no-method-suggested-traits.stderr +++ b/tests/ui/impl-trait/no-method-suggested-traits.stderr @@ -127,8 +127,8 @@ LL | Foo.method(); = note: the following traits define an item `method`, perhaps you need to implement one of them: candidate #1: `foo::Bar` candidate #2: `PubPub` - candidate #3: `no_method_suggested_traits::qux::PrivPub` - candidate #4: `Reexported` + candidate #3: `Reexported` + candidate #4: `no_method_suggested_traits::qux::PrivPub` error[E0599]: no method named `method` found for struct `Rc<&mut Box<&Foo>>` in the current scope --> $DIR/no-method-suggested-traits.rs:42:43 @@ -140,8 +140,8 @@ LL | std::rc::Rc::new(&mut Box::new(&Foo)).method(); = note: the following traits define an item `method`, perhaps you need to implement one of them: candidate #1: `foo::Bar` candidate #2: `PubPub` - candidate #3: `no_method_suggested_traits::qux::PrivPub` - candidate #4: `Reexported` + candidate #3: `Reexported` + candidate #4: `no_method_suggested_traits::qux::PrivPub` error[E0599]: no method named `method2` found for type `u64` in the current scope --> $DIR/no-method-suggested-traits.rs:45:10 diff --git a/tests/ui/include-macros/parent_dir.rs b/tests/ui/include-macros/parent_dir.rs new file mode 100644 index 00000000000..5fadff77a37 --- /dev/null +++ b/tests/ui/include-macros/parent_dir.rs @@ -0,0 +1,12 @@ +//@ normalize-stderr-test: "`: .*" -> "`: $$FILE_NOT_FOUND_MSG" + +fn main() { + let _ = include_str!("include-macros/file.txt"); //~ ERROR couldn't read + //~^HELP different directory + let _ = include_str!("hello.rs"); //~ ERROR couldn't read + //~^HELP different directory + let _ = include_bytes!("../../data.bin"); //~ ERROR couldn't read + //~^HELP different directory + let _ = include_str!("tests/ui/include-macros/file.txt"); //~ ERROR couldn't read + //~^HELP different directory +} diff --git a/tests/ui/include-macros/parent_dir.stderr b/tests/ui/include-macros/parent_dir.stderr new file mode 100644 index 00000000000..0470d5b1f1e --- /dev/null +++ b/tests/ui/include-macros/parent_dir.stderr @@ -0,0 +1,50 @@ +error: couldn't read `$DIR/include-macros/file.txt`: $FILE_NOT_FOUND_MSG + --> $DIR/parent_dir.rs:4:13 + | +LL | let _ = include_str!("include-macros/file.txt"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the macro `include_str` (in Nightly builds, run with -Z macro-backtrace for more info) +help: there is a file with the same name in a different directory + | +LL | let _ = include_str!("file.txt"); + | ~~~~~~~~~~ + +error: couldn't read `$DIR/hello.rs`: $FILE_NOT_FOUND_MSG + --> $DIR/parent_dir.rs:6:13 + | +LL | let _ = include_str!("hello.rs"); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the macro `include_str` (in Nightly builds, run with -Z macro-backtrace for more info) +help: there is a file with the same name in a different directory + | +LL | let _ = include_str!("../hello.rs"); + | ~~~~~~~~~~~~~ + +error: couldn't read `$DIR/../../data.bin`: $FILE_NOT_FOUND_MSG + --> $DIR/parent_dir.rs:8:13 + | +LL | let _ = include_bytes!("../../data.bin"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the macro `include_bytes` (in Nightly builds, run with -Z macro-backtrace for more info) +help: there is a file with the same name in a different directory + | +LL | let _ = include_bytes!("data.bin"); + | ~~~~~~~~~~ + +error: couldn't read `$DIR/tests/ui/include-macros/file.txt`: $FILE_NOT_FOUND_MSG + --> $DIR/parent_dir.rs:10:13 + | +LL | let _ = include_str!("tests/ui/include-macros/file.txt"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the macro `include_str` (in Nightly builds, run with -Z macro-backtrace for more info) +help: there is a file with the same name in a different directory + | +LL | let _ = include_str!("file.txt"); + | ~~~~~~~~~~ + +error: aborting due to 4 previous errors + diff --git a/tests/ui/issues/issue-11771.stderr b/tests/ui/issues/issue-11771.stderr index b37140f60f9..161fce4b031 100644 --- a/tests/ui/issues/issue-11771.stderr +++ b/tests/ui/issues/issue-11771.stderr @@ -6,14 +6,14 @@ LL | 1 + | = help: the trait `Add<()>` is not implemented for `{integer}` = help: the following other types implement trait `Add<Rhs>`: - <isize as Add> - <isize as Add<&isize>> - <i8 as Add> - <i8 as Add<&i8>> - <i16 as Add> - <i16 as Add<&i16>> - <i32 as Add> - <i32 as Add<&i32>> + <&'a f32 as Add<f32>> + <&'a f64 as Add<f64>> + <&'a i128 as Add<i128>> + <&'a i16 as Add<i16>> + <&'a i32 as Add<i32>> + <&'a i64 as Add<i64>> + <&'a i8 as Add<i8>> + <&'a isize as Add<isize>> and 48 others error[E0277]: cannot add `()` to `{integer}` @@ -24,14 +24,14 @@ LL | 1 + | = help: the trait `Add<()>` is not implemented for `{integer}` = help: the following other types implement trait `Add<Rhs>`: - <isize as Add> - <isize as Add<&isize>> - <i8 as Add> - <i8 as Add<&i8>> - <i16 as Add> - <i16 as Add<&i16>> - <i32 as Add> - <i32 as Add<&i32>> + <&'a f32 as Add<f32>> + <&'a f64 as Add<f64>> + <&'a i128 as Add<i128>> + <&'a i16 as Add<i16>> + <&'a i32 as Add<i32>> + <&'a i64 as Add<i64>> + <&'a i8 as Add<i8>> + <&'a isize as Add<isize>> and 48 others error: aborting due to 2 previous errors diff --git a/tests/ui/issues/issue-18446.stderr b/tests/ui/issues/issue-18446.stderr index d84c490df4d..08a9cfc644f 100644 --- a/tests/ui/issues/issue-18446.stderr +++ b/tests/ui/issues/issue-18446.stderr @@ -4,17 +4,17 @@ error[E0034]: multiple applicable items in scope LL | x.foo(); | ^^^ multiple `foo` found | -note: candidate #1 is defined in an impl for the type `(dyn T + 'a)` - --> $DIR/issue-18446.rs:9:5 - | -LL | fn foo(&self) {} - | ^^^^^^^^^^^^^ -note: candidate #2 is defined in the trait `T` +note: candidate #1 is defined in the trait `T` --> $DIR/issue-18446.rs:5:5 | LL | fn foo(&self); | ^^^^^^^^^^^^^^ -help: disambiguate the method for candidate #2 +note: candidate #2 is defined in an impl for the type `(dyn T + 'a)` + --> $DIR/issue-18446.rs:9:5 + | +LL | fn foo(&self) {} + | ^^^^^^^^^^^^^ +help: disambiguate the method for candidate #1 | LL | T::foo(&x); | ~~~~~~~~~~ diff --git a/tests/ui/issues/issue-24352.stderr b/tests/ui/issues/issue-24352.stderr index 015569cce06..a9f886158e1 100644 --- a/tests/ui/issues/issue-24352.stderr +++ b/tests/ui/issues/issue-24352.stderr @@ -6,10 +6,10 @@ LL | 1.0f64 - 1 | = help: the trait `Sub<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Sub<Rhs>`: - <f64 as Sub> - <f64 as Sub<&f64>> <&'a f64 as Sub<f64>> <&f64 as Sub<&f64>> + <f64 as Sub<&f64>> + <f64 as Sub> help: consider using a floating-point literal by writing it with `.0` | LL | 1.0f64 - 1.0 diff --git a/tests/ui/issues/issue-3702-2.stderr b/tests/ui/issues/issue-3702-2.stderr index 4edca796f43..7ab6520a0ca 100644 --- a/tests/ui/issues/issue-3702-2.stderr +++ b/tests/ui/issues/issue-3702-2.stderr @@ -4,24 +4,24 @@ error[E0034]: multiple applicable items in scope LL | self.to_int() + other.to_int() | ^^^^^^ multiple `to_int` found | -note: candidate #1 is defined in an impl of the trait `ToPrimitive` for the type `isize` - --> $DIR/issue-3702-2.rs:2:5 - | -LL | fn to_int(&self) -> isize { 0 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: candidate #2 is defined in an impl of the trait `Add` for the type `isize` +note: candidate #1 is defined in an impl of the trait `Add` for the type `isize` --> $DIR/issue-3702-2.rs:14:5 | LL | fn to_int(&self) -> isize { *self } | ^^^^^^^^^^^^^^^^^^^^^^^^^ -help: disambiguate the method for candidate #1 +note: candidate #2 is defined in an impl of the trait `ToPrimitive` for the type `isize` + --> $DIR/issue-3702-2.rs:2:5 | -LL | ToPrimitive::to_int(&self) + other.to_int() - | ~~~~~~~~~~~~~~~~~~~~~~~~~~ -help: disambiguate the method for candidate #2 +LL | fn to_int(&self) -> isize { 0 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +help: disambiguate the method for candidate #1 | LL | Add::to_int(&self) + other.to_int() | ~~~~~~~~~~~~~~~~~~ +help: disambiguate the method for candidate #2 + | +LL | ToPrimitive::to_int(&self) + other.to_int() + | ~~~~~~~~~~~~~~~~~~~~~~~~~~ error: aborting due to 1 previous error diff --git a/tests/ui/issues/issue-50582.stderr b/tests/ui/issues/issue-50582.stderr index 7b65fa25ae3..1967b51128f 100644 --- a/tests/ui/issues/issue-50582.stderr +++ b/tests/ui/issues/issue-50582.stderr @@ -16,14 +16,14 @@ LL | Vec::<[(); 1 + for x in 0..1 {}]>::new(); | = help: the trait `Add<()>` is not implemented for `{integer}` = help: the following other types implement trait `Add<Rhs>`: - <isize as Add> - <isize as Add<&isize>> - <i8 as Add> - <i8 as Add<&i8>> - <i16 as Add> - <i16 as Add<&i16>> - <i32 as Add> - <i32 as Add<&i32>> + <&'a f32 as Add<f32>> + <&'a f64 as Add<f64>> + <&'a i128 as Add<i128>> + <&'a i16 as Add<i16>> + <&'a i32 as Add<i32>> + <&'a i64 as Add<i64>> + <&'a i8 as Add<i8>> + <&'a isize as Add<isize>> and 48 others error: aborting due to 2 previous errors diff --git a/tests/ui/iterators/invalid-iterator-chain-fixable.stderr b/tests/ui/iterators/invalid-iterator-chain-fixable.stderr index 1bfe765e78a..4d1e4207fdc 100644 --- a/tests/ui/iterators/invalid-iterator-chain-fixable.stderr +++ b/tests/ui/iterators/invalid-iterator-chain-fixable.stderr @@ -33,8 +33,8 @@ LL | println!("{}", scores.sum::<i32>()); | = help: the trait `Sum<()>` is not implemented for `i32` = help: the following other types implement trait `Sum<A>`: - <i32 as Sum> <i32 as Sum<&'a i32>> + <i32 as Sum> note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain-fixable.rs:14:10 | @@ -66,8 +66,8 @@ LL | .sum::<i32>(), | = help: the trait `Sum<()>` is not implemented for `i32` = help: the following other types implement trait `Sum<A>`: - <i32 as Sum> <i32 as Sum<&'a i32>> + <i32 as Sum> note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain-fixable.rs:23:14 | @@ -99,8 +99,8 @@ LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>()); | = help: the trait `Sum<()>` is not implemented for `i32` = help: the following other types implement trait `Sum<A>`: - <i32 as Sum> <i32 as Sum<&'a i32>> + <i32 as Sum> note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain-fixable.rs:27:38 | diff --git a/tests/ui/iterators/invalid-iterator-chain-with-int-infer.stderr b/tests/ui/iterators/invalid-iterator-chain-with-int-infer.stderr index f68c596367e..9381a98e077 100644 --- a/tests/ui/iterators/invalid-iterator-chain-with-int-infer.stderr +++ b/tests/ui/iterators/invalid-iterator-chain-with-int-infer.stderr @@ -8,8 +8,8 @@ LL | let x = Some(()).iter().map(|()| 1).sum::<f32>(); | = help: the trait `Sum<{integer}>` is not implemented for `f32` = help: the following other types implement trait `Sum<A>`: - <f32 as Sum> <f32 as Sum<&'a f32>> + <f32 as Sum> note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain-with-int-infer.rs:2:29 | diff --git a/tests/ui/iterators/invalid-iterator-chain.stderr b/tests/ui/iterators/invalid-iterator-chain.stderr index 4dc13086912..6129a724f44 100644 --- a/tests/ui/iterators/invalid-iterator-chain.stderr +++ b/tests/ui/iterators/invalid-iterator-chain.stderr @@ -33,8 +33,8 @@ LL | println!("{}", scores.sum::<i32>()); | = help: the trait `Sum<()>` is not implemented for `i32` = help: the following other types implement trait `Sum<A>`: - <i32 as Sum> <i32 as Sum<&'a i32>> + <i32 as Sum> note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain.rs:12:10 | @@ -65,8 +65,8 @@ LL | .sum::<i32>(), | = help: the trait `Sum<()>` is not implemented for `i32` = help: the following other types implement trait `Sum<A>`: - <i32 as Sum> <i32 as Sum<&'a i32>> + <i32 as Sum> note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain.rs:25:14 | @@ -104,8 +104,8 @@ LL | .sum::<i32>(), | = help: the trait `Sum<f64>` is not implemented for `i32` = help: the following other types implement trait `Sum<A>`: - <i32 as Sum> <i32 as Sum<&'a i32>> + <i32 as Sum> note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain.rs:33:14 | @@ -134,8 +134,8 @@ LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>()); | = help: the trait `Sum<()>` is not implemented for `i32` = help: the following other types implement trait `Sum<A>`: - <i32 as Sum> <i32 as Sum<&'a i32>> + <i32 as Sum> note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain.rs:38:38 | @@ -162,8 +162,8 @@ LL | println!("{}", vec![(), ()].iter().sum::<i32>()); | = help: the trait `Sum<&()>` is not implemented for `i32` = help: the following other types implement trait `Sum<A>`: - <i32 as Sum> <i32 as Sum<&'a i32>> + <i32 as Sum> note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain.rs:39:33 | diff --git a/tests/ui/lazy-type-alias/trailing-where-clause.stderr b/tests/ui/lazy-type-alias/trailing-where-clause.stderr index baf4215bbf7..534df382eb6 100644 --- a/tests/ui/lazy-type-alias/trailing-where-clause.stderr +++ b/tests/ui/lazy-type-alias/trailing-where-clause.stderr @@ -5,12 +5,12 @@ LL | let _: Alias<()>; | ^^ the trait `From<()>` is not implemented for `String` | = help: the following other types implement trait `From<T>`: - <String as From<char>> + <String as From<&String>> + <String as From<&mut str>> + <String as From<&str>> <String as From<Box<str>>> <String as From<Cow<'a, str>>> - <String as From<&str>> - <String as From<&mut str>> - <String as From<&String>> + <String as From<char>> note: required by a bound in `Alias` --> $DIR/trailing-where-clause.rs:8:13 | diff --git a/tests/ui/macros/macros-nonfatal-errors.rs b/tests/ui/macros/macros-nonfatal-errors.rs index 20e6d705003..46e865031ec 100644 --- a/tests/ui/macros/macros-nonfatal-errors.rs +++ b/tests/ui/macros/macros-nonfatal-errors.rs @@ -1,4 +1,4 @@ -//@ normalize-stderr-test: "existed:.*\(" -> "existed: $$FILE_NOT_FOUND_MSG (" +//@ normalize-stderr-test: "`: .*" -> "`: $$FILE_NOT_FOUND_MSG" // test that errors in a (selection) of macros don't kill compilation // immediately, so that we get more errors listed at a time. diff --git a/tests/ui/macros/macros-nonfatal-errors.stderr b/tests/ui/macros/macros-nonfatal-errors.stderr index ca373ea6cd9..abf43e2a009 100644 --- a/tests/ui/macros/macros-nonfatal-errors.stderr +++ b/tests/ui/macros/macros-nonfatal-errors.stderr @@ -200,7 +200,7 @@ error: argument must be a string literal LL | include_str!(invalid); | ^^^^^^^ -error: couldn't read $DIR/i'd be quite surprised if a file with this name existed: $FILE_NOT_FOUND_MSG (os error 2) +error: couldn't read `$DIR/i'd be quite surprised if a file with this name existed`: $FILE_NOT_FOUND_MSG --> $DIR/macros-nonfatal-errors.rs:113:5 | LL | include_str!("i'd be quite surprised if a file with this name existed"); @@ -214,7 +214,7 @@ error: argument must be a string literal LL | include_bytes!(invalid); | ^^^^^^^ -error: couldn't read $DIR/i'd be quite surprised if a file with this name existed: $FILE_NOT_FOUND_MSG (os error 2) +error: couldn't read `$DIR/i'd be quite surprised if a file with this name existed`: $FILE_NOT_FOUND_MSG --> $DIR/macros-nonfatal-errors.rs:115:5 | LL | include_bytes!("i'd be quite surprised if a file with this name existed"); diff --git a/tests/ui/methods/method-ambig-two-traits-cross-crate.stderr b/tests/ui/methods/method-ambig-two-traits-cross-crate.stderr index 0c775612bfb..0fc0c909ea8 100644 --- a/tests/ui/methods/method-ambig-two-traits-cross-crate.stderr +++ b/tests/ui/methods/method-ambig-two-traits-cross-crate.stderr @@ -4,20 +4,20 @@ error[E0034]: multiple applicable items in scope LL | fn main() { 1_usize.me(); } | ^^ multiple `me` found | - = note: candidate #1 is defined in an impl of the trait `Me` for the type `usize` -note: candidate #2 is defined in an impl of the trait `Me2` for the type `usize` +note: candidate #1 is defined in an impl of the trait `Me2` for the type `usize` --> $DIR/method-ambig-two-traits-cross-crate.rs:10:22 | LL | impl Me2 for usize { fn me(&self) -> usize { *self } } | ^^^^^^^^^^^^^^^^^^^^^ + = note: candidate #2 is defined in an impl of the trait `Me` for the type `usize` help: disambiguate the method for candidate #1 | -LL | fn main() { Me::me(&1_usize); } - | ~~~~~~~~~~~~~~~~ -help: disambiguate the method for candidate #2 - | LL | fn main() { Me2::me(&1_usize); } | ~~~~~~~~~~~~~~~~~ +help: disambiguate the method for candidate #2 + | +LL | fn main() { Me::me(&1_usize); } + | ~~~~~~~~~~~~~~~~ error: aborting due to 1 previous error diff --git a/tests/ui/methods/method-ambig-two-traits-with-default-method.stderr b/tests/ui/methods/method-ambig-two-traits-with-default-method.stderr index 9da307436e9..b36ef77fb7e 100644 --- a/tests/ui/methods/method-ambig-two-traits-with-default-method.stderr +++ b/tests/ui/methods/method-ambig-two-traits-with-default-method.stderr @@ -4,23 +4,23 @@ error[E0034]: multiple applicable items in scope LL | 1_usize.method(); | ^^^^^^ multiple `method` found | -note: candidate #1 is defined in an impl of the trait `Foo` for the type `usize` - --> $DIR/method-ambig-two-traits-with-default-method.rs:5:13 - | -LL | trait Foo { fn method(&self) {} } - | ^^^^^^^^^^^^^^^^ -note: candidate #2 is defined in an impl of the trait `Bar` for the type `usize` +note: candidate #1 is defined in an impl of the trait `Bar` for the type `usize` --> $DIR/method-ambig-two-traits-with-default-method.rs:6:13 | LL | trait Bar { fn method(&self) {} } | ^^^^^^^^^^^^^^^^ +note: candidate #2 is defined in an impl of the trait `Foo` for the type `usize` + --> $DIR/method-ambig-two-traits-with-default-method.rs:5:13 + | +LL | trait Foo { fn method(&self) {} } + | ^^^^^^^^^^^^^^^^ help: disambiguate the method for candidate #1 | -LL | Foo::method(&1_usize); +LL | Bar::method(&1_usize); | ~~~~~~~~~~~~~~~~~~~~~ help: disambiguate the method for candidate #2 | -LL | Bar::method(&1_usize); +LL | Foo::method(&1_usize); | ~~~~~~~~~~~~~~~~~~~~~ error: aborting due to 1 previous error diff --git a/tests/ui/methods/method-call-err-msg.stderr b/tests/ui/methods/method-call-err-msg.stderr index 6df49e432a1..7d9b38fb29b 100644 --- a/tests/ui/methods/method-call-err-msg.stderr +++ b/tests/ui/methods/method-call-err-msg.stderr @@ -64,8 +64,8 @@ note: the trait `Iterator` must be implemented --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL = help: items from traits can only be used if the trait is implemented and in scope = note: the following traits define an item `take`, perhaps you need to implement one of them: - candidate #1: `std::io::Read` - candidate #2: `Iterator` + candidate #1: `Iterator` + candidate #2: `std::io::Read` error[E0061]: this method takes 3 arguments but 0 arguments were supplied --> $DIR/method-call-err-msg.rs:21:7 diff --git a/tests/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr b/tests/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr index 755179650bb..6159d87c73e 100644 --- a/tests/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr +++ b/tests/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr @@ -29,33 +29,33 @@ error[E0034]: multiple applicable items in scope LL | let z = x.foo(); | ^^^ multiple `foo` found | -note: candidate #1 is defined in an impl of the trait `X` for the type `T` - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:45:9 +note: candidate #1 is defined in the trait `FinalFoo` + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:59:5 | -LL | fn foo(self: Smaht<Self, u64>) -> u64 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(&self) -> u8; + | ^^^^^^^^^^^^^^^^^^^^ note: candidate #2 is defined in an impl of the trait `NuisanceFoo` for the type `T` --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:72:9 | LL | fn foo(self) {} | ^^^^^^^^^^^^ -note: candidate #3 is defined in the trait `FinalFoo` - --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:59:5 +note: candidate #3 is defined in an impl of the trait `X` for the type `T` + --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:45:9 | -LL | fn foo(&self) -> u8; - | ^^^^^^^^^^^^^^^^^^^^ +LL | fn foo(self: Smaht<Self, u64>) -> u64 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: disambiguate the method for candidate #1 | -LL | let z = X::foo(x); - | ~~~~~~~~~ +LL | let z = FinalFoo::foo(&x); + | ~~~~~~~~~~~~~~~~~ help: disambiguate the method for candidate #2 | LL | let z = NuisanceFoo::foo(x); | ~~~~~~~~~~~~~~~~~~~ help: disambiguate the method for candidate #3 | -LL | let z = FinalFoo::foo(&x); - | ~~~~~~~~~~~~~~~~~ +LL | let z = X::foo(x); + | ~~~~~~~~~ error[E0308]: mismatched types --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:139:24 diff --git a/tests/ui/methods/method-not-found-generic-arg-elision.stderr b/tests/ui/methods/method-not-found-generic-arg-elision.stderr index b97688d3868..a665500fd9e 100644 --- a/tests/ui/methods/method-not-found-generic-arg-elision.stderr +++ b/tests/ui/methods/method-not-found-generic-arg-elision.stderr @@ -35,10 +35,10 @@ LL | wrapper.method(); | ^^^^^^ method not found in `Wrapper<bool>` | = note: the method was found for - - `Wrapper<i8>` - `Wrapper<i16>` - `Wrapper<i32>` - `Wrapper<i64>` + - `Wrapper<i8>` and 2 more types error[E0599]: no method named `other` found for struct `Wrapper` in the current scope @@ -60,9 +60,9 @@ LL | wrapper.method(); | ^^^^^^ method not found in `Wrapper2<'_, bool, 3>` | = note: the method was found for - - `Wrapper2<'a, i8, C>` - `Wrapper2<'a, i16, C>` - `Wrapper2<'a, i32, C>` + - `Wrapper2<'a, i8, C>` error[E0599]: no method named `other` found for struct `Wrapper2` in the current scope --> $DIR/method-not-found-generic-arg-elision.rs:98:13 diff --git a/tests/ui/mismatched_types/binops.stderr b/tests/ui/mismatched_types/binops.stderr index b18ab7f7608..3585587ed4c 100644 --- a/tests/ui/mismatched_types/binops.stderr +++ b/tests/ui/mismatched_types/binops.stderr @@ -6,14 +6,14 @@ LL | 1 + Some(1); | = help: the trait `Add<Option<{integer}>>` is not implemented for `{integer}` = help: the following other types implement trait `Add<Rhs>`: - <isize as Add> - <isize as Add<&isize>> - <i8 as Add> - <i8 as Add<&i8>> - <i16 as Add> - <i16 as Add<&i16>> - <i32 as Add> - <i32 as Add<&i32>> + <&'a f32 as Add<f32>> + <&'a f64 as Add<f64>> + <&'a i128 as Add<i128>> + <&'a i16 as Add<i16>> + <&'a i32 as Add<i32>> + <&'a i64 as Add<i64>> + <&'a i8 as Add<i8>> + <&'a isize as Add<isize>> and 48 others error[E0277]: cannot subtract `Option<{integer}>` from `usize` @@ -24,10 +24,10 @@ LL | 2 as usize - Some(1); | = help: the trait `Sub<Option<{integer}>>` is not implemented for `usize` = help: the following other types implement trait `Sub<Rhs>`: - <usize as Sub> - <usize as Sub<&usize>> <&'a usize as Sub<usize>> <&usize as Sub<&usize>> + <usize as Sub<&usize>> + <usize as Sub> error[E0277]: cannot multiply `{integer}` by `()` --> $DIR/binops.rs:4:7 @@ -37,14 +37,14 @@ LL | 3 * (); | = help: the trait `Mul<()>` is not implemented for `{integer}` = help: the following other types implement trait `Mul<Rhs>`: - <isize as Mul> - <isize as Mul<&isize>> - <i8 as Mul> - <i8 as Mul<&i8>> - <i16 as Mul> - <i16 as Mul<&i16>> - <i32 as Mul> - <i32 as Mul<&i32>> + <&'a f32 as Mul<f32>> + <&'a f64 as Mul<f64>> + <&'a i128 as Mul<i128>> + <&'a i16 as Mul<i16>> + <&'a i32 as Mul<i32>> + <&'a i64 as Mul<i64>> + <&'a i8 as Mul<i8>> + <&'a isize as Mul<isize>> and 49 others error[E0277]: cannot divide `{integer}` by `&str` @@ -55,14 +55,14 @@ LL | 4 / ""; | = help: the trait `Div<&str>` is not implemented for `{integer}` = help: the following other types implement trait `Div<Rhs>`: - <isize as Div> - <isize as Div<&isize>> - <i8 as Div> - <i8 as Div<&i8>> - <i16 as Div> - <i16 as Div<&i16>> - <i32 as Div> - <i32 as Div<&i32>> + <&'a f32 as Div<f32>> + <&'a f64 as Div<f64>> + <&'a i128 as Div<i128>> + <&'a i16 as Div<i16>> + <&'a i32 as Div<i32>> + <&'a i64 as Div<i64>> + <&'a i8 as Div<i8>> + <&'a isize as Div<isize>> and 54 others error[E0277]: can't compare `{integer}` with `String` @@ -73,14 +73,14 @@ LL | 5 < String::new(); | = help: the trait `PartialOrd<String>` is not implemented for `{integer}` = help: the following other types implement trait `PartialOrd<Rhs>`: - isize - i8 + f32 + f64 + i128 i16 i32 i64 - i128 - usize - u8 + i8 + isize and 6 others error[E0277]: can't compare `{integer}` with `Result<{integer}, _>` @@ -91,14 +91,14 @@ LL | 6 == Ok(1); | = help: the trait `PartialEq<Result<{integer}, _>>` is not implemented for `{integer}` = help: the following other types implement trait `PartialEq<Rhs>`: - isize - i8 + f32 + f64 + i128 i16 i32 i64 - i128 - usize - u8 + i8 + isize and 6 others error: aborting due to 6 previous errors diff --git a/tests/ui/never_type/diverging-fallback-no-leak.fallback.stderr b/tests/ui/never_type/diverging-fallback-no-leak.fallback.stderr index ff28480bd99..01abf2e17f1 100644 --- a/tests/ui/never_type/diverging-fallback-no-leak.fallback.stderr +++ b/tests/ui/never_type/diverging-fallback-no-leak.fallback.stderr @@ -7,8 +7,8 @@ LL | unconstrained_arg(return); | required by a bound introduced by this call | = help: the following other types implement trait `Test`: - i32 () + i32 = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/48950> for more information) = help: did you intend to use the type `()` here instead? note: required by a bound in `unconstrained_arg` diff --git a/tests/ui/never_type/issue-13352.stderr b/tests/ui/never_type/issue-13352.stderr index 91885380b1f..1b979d93446 100644 --- a/tests/ui/never_type/issue-13352.stderr +++ b/tests/ui/never_type/issue-13352.stderr @@ -6,10 +6,10 @@ LL | 2_usize + (loop {}); | = help: the trait `Add<()>` is not implemented for `usize` = help: the following other types implement trait `Add<Rhs>`: - <usize as Add> - <usize as Add<&usize>> <&'a usize as Add<usize>> <&usize as Add<&usize>> + <usize as Add<&usize>> + <usize as Add> error: aborting due to 1 previous error diff --git a/tests/ui/numbers-arithmetic/not-suggest-float-literal.stderr b/tests/ui/numbers-arithmetic/not-suggest-float-literal.stderr index be0fc0f98e2..14685a3f937 100644 --- a/tests/ui/numbers-arithmetic/not-suggest-float-literal.stderr +++ b/tests/ui/numbers-arithmetic/not-suggest-float-literal.stderr @@ -6,10 +6,10 @@ LL | x + 100.0 | = help: the trait `Add<{float}>` is not implemented for `u8` = help: the following other types implement trait `Add<Rhs>`: - <u8 as Add> - <u8 as Add<&u8>> <&'a u8 as Add<u8>> <&u8 as Add<&u8>> + <u8 as Add<&u8>> + <u8 as Add> error[E0277]: cannot add `&str` to `f64` --> $DIR/not-suggest-float-literal.rs:6:7 @@ -19,10 +19,10 @@ LL | x + "foo" | = help: the trait `Add<&str>` is not implemented for `f64` = help: the following other types implement trait `Add<Rhs>`: - <f64 as Add> - <f64 as Add<&f64>> <&'a f64 as Add<f64>> <&f64 as Add<&f64>> + <f64 as Add<&f64>> + <f64 as Add> error[E0277]: cannot add `{integer}` to `f64` --> $DIR/not-suggest-float-literal.rs:11:7 @@ -32,10 +32,10 @@ LL | x + y | = help: the trait `Add<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Add<Rhs>`: - <f64 as Add> - <f64 as Add<&f64>> <&'a f64 as Add<f64>> <&f64 as Add<&f64>> + <f64 as Add<&f64>> + <f64 as Add> error[E0277]: cannot subtract `{float}` from `u8` --> $DIR/not-suggest-float-literal.rs:15:7 @@ -45,10 +45,10 @@ LL | x - 100.0 | = help: the trait `Sub<{float}>` is not implemented for `u8` = help: the following other types implement trait `Sub<Rhs>`: - <u8 as Sub> - <u8 as Sub<&u8>> <&'a u8 as Sub<u8>> <&u8 as Sub<&u8>> + <u8 as Sub<&u8>> + <u8 as Sub> error[E0277]: cannot subtract `&str` from `f64` --> $DIR/not-suggest-float-literal.rs:19:7 @@ -58,10 +58,10 @@ LL | x - "foo" | = help: the trait `Sub<&str>` is not implemented for `f64` = help: the following other types implement trait `Sub<Rhs>`: - <f64 as Sub> - <f64 as Sub<&f64>> <&'a f64 as Sub<f64>> <&f64 as Sub<&f64>> + <f64 as Sub<&f64>> + <f64 as Sub> error[E0277]: cannot subtract `{integer}` from `f64` --> $DIR/not-suggest-float-literal.rs:24:7 @@ -71,10 +71,10 @@ LL | x - y | = help: the trait `Sub<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Sub<Rhs>`: - <f64 as Sub> - <f64 as Sub<&f64>> <&'a f64 as Sub<f64>> <&f64 as Sub<&f64>> + <f64 as Sub<&f64>> + <f64 as Sub> error[E0277]: cannot multiply `u8` by `{float}` --> $DIR/not-suggest-float-literal.rs:28:7 @@ -84,10 +84,10 @@ LL | x * 100.0 | = help: the trait `Mul<{float}>` is not implemented for `u8` = help: the following other types implement trait `Mul<Rhs>`: - <u8 as Mul> - <u8 as Mul<&u8>> <&'a u8 as Mul<u8>> <&u8 as Mul<&u8>> + <u8 as Mul<&u8>> + <u8 as Mul> error[E0277]: cannot multiply `f64` by `&str` --> $DIR/not-suggest-float-literal.rs:32:7 @@ -97,10 +97,10 @@ LL | x * "foo" | = help: the trait `Mul<&str>` is not implemented for `f64` = help: the following other types implement trait `Mul<Rhs>`: - <f64 as Mul> - <f64 as Mul<&f64>> <&'a f64 as Mul<f64>> <&f64 as Mul<&f64>> + <f64 as Mul<&f64>> + <f64 as Mul> error[E0277]: cannot multiply `f64` by `{integer}` --> $DIR/not-suggest-float-literal.rs:37:7 @@ -110,10 +110,10 @@ LL | x * y | = help: the trait `Mul<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Mul<Rhs>`: - <f64 as Mul> - <f64 as Mul<&f64>> <&'a f64 as Mul<f64>> <&f64 as Mul<&f64>> + <f64 as Mul<&f64>> + <f64 as Mul> error[E0277]: cannot divide `u8` by `{float}` --> $DIR/not-suggest-float-literal.rs:41:7 @@ -123,11 +123,11 @@ LL | x / 100.0 | = help: the trait `Div<{float}>` is not implemented for `u8` = help: the following other types implement trait `Div<Rhs>`: - <u8 as Div> - <u8 as Div<NonZero<u8>>> - <u8 as Div<&u8>> <&'a u8 as Div<u8>> <&u8 as Div<&u8>> + <u8 as Div<&u8>> + <u8 as Div<NonZero<u8>>> + <u8 as Div> error[E0277]: cannot divide `f64` by `&str` --> $DIR/not-suggest-float-literal.rs:45:7 @@ -137,10 +137,10 @@ LL | x / "foo" | = help: the trait `Div<&str>` is not implemented for `f64` = help: the following other types implement trait `Div<Rhs>`: - <f64 as Div> - <f64 as Div<&f64>> <&'a f64 as Div<f64>> <&f64 as Div<&f64>> + <f64 as Div<&f64>> + <f64 as Div> error[E0277]: cannot divide `f64` by `{integer}` --> $DIR/not-suggest-float-literal.rs:50:7 @@ -150,10 +150,10 @@ LL | x / y | = help: the trait `Div<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Div<Rhs>`: - <f64 as Div> - <f64 as Div<&f64>> <&'a f64 as Div<f64>> <&f64 as Div<&f64>> + <f64 as Div<&f64>> + <f64 as Div> error: aborting due to 12 previous errors diff --git a/tests/ui/numbers-arithmetic/suggest-float-literal.stderr b/tests/ui/numbers-arithmetic/suggest-float-literal.stderr index 929a9e3b595..03779d35637 100644 --- a/tests/ui/numbers-arithmetic/suggest-float-literal.stderr +++ b/tests/ui/numbers-arithmetic/suggest-float-literal.stderr @@ -6,10 +6,10 @@ LL | x + 100 | = help: the trait `Add<{integer}>` is not implemented for `f32` = help: the following other types implement trait `Add<Rhs>`: - <f32 as Add> - <f32 as Add<&f32>> <&'a f32 as Add<f32>> <&f32 as Add<&f32>> + <f32 as Add<&f32>> + <f32 as Add> help: consider using a floating-point literal by writing it with `.0` | LL | x + 100.0 @@ -23,10 +23,10 @@ LL | x + 100 | = help: the trait `Add<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Add<Rhs>`: - <f64 as Add> - <f64 as Add<&f64>> <&'a f64 as Add<f64>> <&f64 as Add<&f64>> + <f64 as Add<&f64>> + <f64 as Add> help: consider using a floating-point literal by writing it with `.0` | LL | x + 100.0 @@ -40,10 +40,10 @@ LL | x - 100 | = help: the trait `Sub<{integer}>` is not implemented for `f32` = help: the following other types implement trait `Sub<Rhs>`: - <f32 as Sub> - <f32 as Sub<&f32>> <&'a f32 as Sub<f32>> <&f32 as Sub<&f32>> + <f32 as Sub<&f32>> + <f32 as Sub> help: consider using a floating-point literal by writing it with `.0` | LL | x - 100.0 @@ -57,10 +57,10 @@ LL | x - 100 | = help: the trait `Sub<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Sub<Rhs>`: - <f64 as Sub> - <f64 as Sub<&f64>> <&'a f64 as Sub<f64>> <&f64 as Sub<&f64>> + <f64 as Sub<&f64>> + <f64 as Sub> help: consider using a floating-point literal by writing it with `.0` | LL | x - 100.0 @@ -74,10 +74,10 @@ LL | x * 100 | = help: the trait `Mul<{integer}>` is not implemented for `f32` = help: the following other types implement trait `Mul<Rhs>`: - <f32 as Mul> - <f32 as Mul<&f32>> <&'a f32 as Mul<f32>> <&f32 as Mul<&f32>> + <f32 as Mul<&f32>> + <f32 as Mul> help: consider using a floating-point literal by writing it with `.0` | LL | x * 100.0 @@ -91,10 +91,10 @@ LL | x * 100 | = help: the trait `Mul<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Mul<Rhs>`: - <f64 as Mul> - <f64 as Mul<&f64>> <&'a f64 as Mul<f64>> <&f64 as Mul<&f64>> + <f64 as Mul<&f64>> + <f64 as Mul> help: consider using a floating-point literal by writing it with `.0` | LL | x * 100.0 @@ -108,10 +108,10 @@ LL | x / 100 | = help: the trait `Div<{integer}>` is not implemented for `f32` = help: the following other types implement trait `Div<Rhs>`: - <f32 as Div> - <f32 as Div<&f32>> <&'a f32 as Div<f32>> <&f32 as Div<&f32>> + <f32 as Div<&f32>> + <f32 as Div> help: consider using a floating-point literal by writing it with `.0` | LL | x / 100.0 @@ -125,10 +125,10 @@ LL | x / 100 | = help: the trait `Div<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Div<Rhs>`: - <f64 as Div> - <f64 as Div<&f64>> <&'a f64 as Div<f64>> <&f64 as Div<&f64>> + <f64 as Div<&f64>> + <f64 as Div> help: consider using a floating-point literal by writing it with `.0` | LL | x / 100.0 diff --git a/tests/ui/on-unimplemented/multiple-impls.stderr b/tests/ui/on-unimplemented/multiple-impls.stderr index f59c93a7c37..b50dc251baa 100644 --- a/tests/ui/on-unimplemented/multiple-impls.stderr +++ b/tests/ui/on-unimplemented/multiple-impls.stderr @@ -8,8 +8,8 @@ LL | Index::index(&[] as &[i32], 2u32); | = help: the trait `Index<u32>` is not implemented for `[i32]` = help: the following other types implement trait `Index<Idx>`: - <[i32] as Index<Foo<usize>>> <[i32] as Index<Bar<usize>>> + <[i32] as Index<Foo<usize>>> error[E0277]: the trait bound `[i32]: Index<Foo<u32>>` is not satisfied --> $DIR/multiple-impls.rs:36:33 @@ -21,8 +21,8 @@ LL | Index::index(&[] as &[i32], Foo(2u32)); | = help: the trait `Index<Foo<u32>>` is not implemented for `[i32]` = help: the following other types implement trait `Index<Idx>`: - <[i32] as Index<Foo<usize>>> <[i32] as Index<Bar<usize>>> + <[i32] as Index<Foo<usize>>> error[E0277]: the trait bound `[i32]: Index<Bar<u32>>` is not satisfied --> $DIR/multiple-impls.rs:39:33 @@ -34,8 +34,8 @@ LL | Index::index(&[] as &[i32], Bar(2u32)); | = help: the trait `Index<Bar<u32>>` is not implemented for `[i32]` = help: the following other types implement trait `Index<Idx>`: - <[i32] as Index<Foo<usize>>> <[i32] as Index<Bar<usize>>> + <[i32] as Index<Foo<usize>>> error[E0277]: the trait bound `[i32]: Index<u32>` is not satisfied --> $DIR/multiple-impls.rs:33:5 @@ -45,8 +45,8 @@ LL | Index::index(&[] as &[i32], 2u32); | = help: the trait `Index<u32>` is not implemented for `[i32]` = help: the following other types implement trait `Index<Idx>`: - <[i32] as Index<Foo<usize>>> <[i32] as Index<Bar<usize>>> + <[i32] as Index<Foo<usize>>> error[E0277]: the trait bound `[i32]: Index<Foo<u32>>` is not satisfied --> $DIR/multiple-impls.rs:36:5 @@ -56,8 +56,8 @@ LL | Index::index(&[] as &[i32], Foo(2u32)); | = help: the trait `Index<Foo<u32>>` is not implemented for `[i32]` = help: the following other types implement trait `Index<Idx>`: - <[i32] as Index<Foo<usize>>> <[i32] as Index<Bar<usize>>> + <[i32] as Index<Foo<usize>>> error[E0277]: the trait bound `[i32]: Index<Bar<u32>>` is not satisfied --> $DIR/multiple-impls.rs:39:5 @@ -67,8 +67,8 @@ LL | Index::index(&[] as &[i32], Bar(2u32)); | = help: the trait `Index<Bar<u32>>` is not implemented for `[i32]` = help: the following other types implement trait `Index<Idx>`: - <[i32] as Index<Foo<usize>>> <[i32] as Index<Bar<usize>>> + <[i32] as Index<Foo<usize>>> error: aborting due to 6 previous errors diff --git a/tests/ui/on-unimplemented/slice-index.stderr b/tests/ui/on-unimplemented/slice-index.stderr index c0314fa42d7..f17f3cfce8d 100644 --- a/tests/ui/on-unimplemented/slice-index.stderr +++ b/tests/ui/on-unimplemented/slice-index.stderr @@ -17,8 +17,8 @@ LL | x[..1i32]; | = help: the trait `SliceIndex<[i32]>` is not implemented for `RangeTo<i32>`, which is required by `[i32]: Index<_>` = help: the following other types implement trait `SliceIndex<T>`: - <RangeTo<usize> as SliceIndex<str>> <RangeTo<usize> as SliceIndex<[T]>> + <RangeTo<usize> as SliceIndex<str>> = note: required for `[i32]` to implement `Index<RangeTo<i32>>` error: aborting due to 2 previous errors diff --git a/tests/ui/on-unimplemented/sum.stderr b/tests/ui/on-unimplemented/sum.stderr index 257dec20074..65bab458cf1 100644 --- a/tests/ui/on-unimplemented/sum.stderr +++ b/tests/ui/on-unimplemented/sum.stderr @@ -8,8 +8,8 @@ LL | vec![(), ()].iter().sum::<i32>(); | = help: the trait `Sum<&()>` is not implemented for `i32` = help: the following other types implement trait `Sum<A>`: - <i32 as Sum> <i32 as Sum<&'a i32>> + <i32 as Sum> note: the method call chain might not have had the expected associated types --> $DIR/sum.rs:4:18 | @@ -30,8 +30,8 @@ LL | vec![(), ()].iter().product::<i32>(); | = help: the trait `Product<&()>` is not implemented for `i32` = help: the following other types implement trait `Product<A>`: - <i32 as Product> <i32 as Product<&'a i32>> + <i32 as Product> note: the method call chain might not have had the expected associated types --> $DIR/sum.rs:7:18 | diff --git a/tests/ui/range/range-1.stderr b/tests/ui/range/range-1.stderr index 3d9b7a940b7..f98420557c6 100644 --- a/tests/ui/range/range-1.stderr +++ b/tests/ui/range/range-1.stderr @@ -11,14 +11,14 @@ LL | for i in false..true {} | ^^^^^^^^^^^ the trait `Step` is not implemented for `bool`, which is required by `std::ops::Range<bool>: IntoIterator` | = help: the following other types implement trait `Step`: + Char + Ipv4Addr + Ipv6Addr char - isize - i8 + i128 i16 i32 i64 - i128 - usize and 8 others = note: required for `std::ops::Range<bool>` to implement `Iterator` = note: required for `std::ops::Range<bool>` to implement `IntoIterator` diff --git a/tests/ui/sanitizer/cfi-drop-in-place.rs b/tests/ui/sanitizer/cfi-drop-in-place.rs new file mode 100644 index 00000000000..8ce2c432602 --- /dev/null +++ b/tests/ui/sanitizer/cfi-drop-in-place.rs @@ -0,0 +1,20 @@ +// Verifies that drops can be called on arbitrary trait objects. +// +// FIXME(#122848): Remove only-linux when fixed. +//@ only-linux +//@ needs-sanitizer-cfi +//@ compile-flags: -Clto -Copt-level=0 -Cprefer-dynamic=off -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ run-pass + +struct EmptyDrop; + +struct NonEmptyDrop; + +impl Drop for NonEmptyDrop { + fn drop(&mut self) {} +} + +fn main() { + let _ = Box::new(EmptyDrop) as Box<dyn Send>; + let _ = Box::new(NonEmptyDrop) as Box<dyn Send>; +} diff --git a/tests/ui/span/multiline-span-simple.stderr b/tests/ui/span/multiline-span-simple.stderr index f0eec632aa1..2de792b03d7 100644 --- a/tests/ui/span/multiline-span-simple.stderr +++ b/tests/ui/span/multiline-span-simple.stderr @@ -6,10 +6,10 @@ LL | foo(1 as u32 + | = help: the trait `Add<()>` is not implemented for `u32` = help: the following other types implement trait `Add<Rhs>`: - <u32 as Add> - <u32 as Add<&u32>> <&'a u32 as Add<u32>> <&u32 as Add<&u32>> + <u32 as Add<&u32>> + <u32 as Add> error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/impl-trait-return-trailing-semicolon.stderr b/tests/ui/suggestions/impl-trait-return-trailing-semicolon.stderr index 6465eeb8bc6..e74c2c4214f 100644 --- a/tests/ui/suggestions/impl-trait-return-trailing-semicolon.stderr +++ b/tests/ui/suggestions/impl-trait-return-trailing-semicolon.stderr @@ -16,8 +16,8 @@ LL | fn bar() -> impl Bar { | ^^^^^^^^ the trait `Bar` is not implemented for `()` | = help: the following other types implement trait `Bar`: - i32 Qux + i32 error: aborting due to 2 previous errors diff --git a/tests/ui/suggestions/into-str.stderr b/tests/ui/suggestions/into-str.stderr index d10a294c7d2..2fdfab8bdc5 100644 --- a/tests/ui/suggestions/into-str.stderr +++ b/tests/ui/suggestions/into-str.stderr @@ -8,12 +8,12 @@ LL | foo(String::new()); | = note: to coerce a `String` into a `&str`, use `&*` as a prefix = help: the following other types implement trait `From<T>`: - <String as From<char>> + <String as From<&String>> + <String as From<&mut str>> + <String as From<&str>> <String as From<Box<str>>> <String as From<Cow<'a, str>>> - <String as From<&str>> - <String as From<&mut str>> - <String as From<&String>> + <String as From<char>> = note: required for `String` to implement `Into<&str>` note: required by a bound in `foo` --> $DIR/into-str.rs:1:31 diff --git a/tests/ui/suggestions/issue-71394-no-from-impl.stderr b/tests/ui/suggestions/issue-71394-no-from-impl.stderr index 0f6bfbeec45..e626b5b0eb7 100644 --- a/tests/ui/suggestions/issue-71394-no-from-impl.stderr +++ b/tests/ui/suggestions/issue-71394-no-from-impl.stderr @@ -5,14 +5,14 @@ LL | let _: &[i8] = data.into(); | ^^^^ the trait `From<&[u8]>` is not implemented for `&[i8]`, which is required by `&[u8]: Into<_>` | = help: the following other types implement trait `From<T>`: - <[bool; N] as From<Mask<T, N>>> - <[T; N] as From<Simd<T, N>>> + <[T; 10] as From<(T, T, T, T, T, T, T, T, T, T)>> + <[T; 11] as From<(T, T, T, T, T, T, T, T, T, T, T)>> + <[T; 12] as From<(T, T, T, T, T, T, T, T, T, T, T, T)>> <[T; 1] as From<(T,)>> <[T; 2] as From<(T, T)>> <[T; 3] as From<(T, T, T)>> <[T; 4] as From<(T, T, T, T)>> <[T; 5] as From<(T, T, T, T, T)>> - <[T; 6] as From<(T, T, T, T, T, T)>> and 6 others = note: required for `&[u8]` to implement `Into<&[i8]>` diff --git a/tests/ui/traits/bound/assoc-fn-bound-root-obligation.stderr b/tests/ui/traits/bound/assoc-fn-bound-root-obligation.stderr index bd9838bc623..27006f59b90 100644 --- a/tests/ui/traits/bound/assoc-fn-bound-root-obligation.stderr +++ b/tests/ui/traits/bound/assoc-fn-bound-root-obligation.stderr @@ -6,13 +6,13 @@ LL | s.strip_suffix(b'\n').unwrap_or(s) | = help: the trait `FnMut<(char,)>` is not implemented for `u8`, which is required by `u8: Pattern<'_>` = help: the following other types implement trait `Pattern<'a>`: - char - [char; N] &'b String &'b [char; N] &'b [char] - &'c &'b str &'b str + &'c &'b str + [char; N] + char = note: required for `u8` to implement `Pattern<'_>` error: aborting due to 1 previous error diff --git a/tests/ui/traits/method-on-unbounded-type-param.stderr b/tests/ui/traits/method-on-unbounded-type-param.stderr index 0d8bd8ee964..4d968e7bee1 100644 --- a/tests/ui/traits/method-on-unbounded-type-param.stderr +++ b/tests/ui/traits/method-on-unbounded-type-param.stderr @@ -9,10 +9,10 @@ LL | a.cmp(&b) = help: items from traits can only be used if the type parameter is bounded by the trait help: the following traits define an item `cmp`, perhaps you need to restrict type parameter `T` with one of them: | -LL | fn f<T: Ord>(a: T, b: T) -> std::cmp::Ordering { - | +++++ LL | fn f<T: Iterator>(a: T, b: T) -> std::cmp::Ordering { | ++++++++++ +LL | fn f<T: Ord>(a: T, b: T) -> std::cmp::Ordering { + | +++++ error[E0599]: the method `cmp` exists for reference `&T`, but its trait bounds were not satisfied --> $DIR/method-on-unbounded-type-param.rs:5:10 @@ -30,10 +30,10 @@ LL | (&a).cmp(&b) = help: items from traits can only be used if the type parameter is bounded by the trait help: the following traits define an item `cmp`, perhaps you need to restrict type parameter `T` with one of them: | -LL | fn g<T: Ord>(a: T, b: T) -> std::cmp::Ordering { - | +++++ LL | fn g<T: Iterator>(a: T, b: T) -> std::cmp::Ordering { | ++++++++++ +LL | fn g<T: Ord>(a: T, b: T) -> std::cmp::Ordering { + | +++++ error[E0599]: the method `cmp` exists for reference `&T`, but its trait bounds were not satisfied --> $DIR/method-on-unbounded-type-param.rs:8:7 @@ -51,10 +51,10 @@ LL | a.cmp(&b) = help: items from traits can only be used if the type parameter is bounded by the trait help: the following traits define an item `cmp`, perhaps you need to restrict type parameter `T` with one of them: | -LL | fn h<T: Ord>(a: &T, b: T) -> std::cmp::Ordering { - | +++++ LL | fn h<T: Iterator>(a: &T, b: T) -> std::cmp::Ordering { | ++++++++++ +LL | fn h<T: Ord>(a: &T, b: T) -> std::cmp::Ordering { + | +++++ error[E0599]: the method `cmp` exists for struct `Box<dyn T>`, but its trait bounds were not satisfied --> $DIR/method-on-unbounded-type-param.rs:14:7 @@ -76,8 +76,8 @@ LL | x.cmp(&x); which is required by `&mut dyn T: Iterator` = help: items from traits can only be used if the trait is implemented and in scope = note: the following traits define an item `cmp`, perhaps you need to implement one of them: - candidate #1: `Ord` - candidate #2: `Iterator` + candidate #1: `Iterator` + candidate #2: `Ord` error: aborting due to 4 previous errors diff --git a/tests/ui/traits/question-mark-result-err-mismatch.stderr b/tests/ui/traits/question-mark-result-err-mismatch.stderr index 79f270fd1bb..8a6c5fc10c5 100644 --- a/tests/ui/traits/question-mark-result-err-mismatch.stderr +++ b/tests/ui/traits/question-mark-result-err-mismatch.stderr @@ -31,12 +31,12 @@ LL | .map_err(|_| ())?; | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait = help: the following other types implement trait `From<T>`: - <String as From<char>> + <String as From<&String>> + <String as From<&mut str>> + <String as From<&str>> <String as From<Box<str>>> <String as From<Cow<'a, str>>> - <String as From<&str>> - <String as From<&mut str>> - <String as From<&String>> + <String as From<char>> = note: required for `Result<(), String>` to implement `FromResidual<Result<Infallible, ()>>` error[E0277]: `?` couldn't convert the error to `String` diff --git a/tests/ui/try-trait/bad-interconversion.stderr b/tests/ui/try-trait/bad-interconversion.stderr index 817acc8fc99..e3edec6a4c7 100644 --- a/tests/ui/try-trait/bad-interconversion.stderr +++ b/tests/ui/try-trait/bad-interconversion.stderr @@ -10,8 +10,8 @@ LL | Ok(Err(123_i32)?) | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait = help: the following other types implement trait `From<T>`: - <u8 as From<bool>> <u8 as From<Char>> + <u8 as From<bool>> = note: required for `Result<u64, u8>` to implement `FromResidual<Result<Infallible, i32>>` error[E0277]: the `?` operator can only be used on `Result`s, not `Option`s, in a function that returns `Result` @@ -24,8 +24,8 @@ LL | Some(3)?; | = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `Result<u64, String>` = help: the following other types implement trait `FromResidual<R>`: - <Result<T, F> as FromResidual<Yeet<E>>> <Result<T, F> as FromResidual<Result<Infallible, E>>> + <Result<T, F> as FromResidual<Yeet<E>>> error[E0277]: the `?` operator can only be used on `Result`s in a function that returns `Result` --> $DIR/bad-interconversion.rs:17:31 @@ -37,8 +37,8 @@ LL | Ok(ControlFlow::Break(123)?) | = help: the trait `FromResidual<ControlFlow<{integer}, Infallible>>` is not implemented for `Result<u64, String>` = help: the following other types implement trait `FromResidual<R>`: - <Result<T, F> as FromResidual<Yeet<E>>> <Result<T, F> as FromResidual<Result<Infallible, E>>> + <Result<T, F> as FromResidual<Yeet<E>>> error[E0277]: the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option` --> $DIR/bad-interconversion.rs:22:22 diff --git a/tests/ui/try-trait/issue-32709.stderr b/tests/ui/try-trait/issue-32709.stderr index 34618de78cd..a0dd18fa039 100644 --- a/tests/ui/try-trait/issue-32709.stderr +++ b/tests/ui/try-trait/issue-32709.stderr @@ -10,7 +10,6 @@ LL | Err(5)?; | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait = help: the following other types implement trait `From<T>`: - <(T,) as From<[T; 1]>> <(T, T) as From<[T; 2]>> <(T, T, T) as From<[T; 3]>> <(T, T, T, T) as From<[T; 4]>> @@ -18,6 +17,7 @@ LL | Err(5)?; <(T, T, T, T, T, T) as From<[T; 6]>> <(T, T, T, T, T, T, T) as From<[T; 7]>> <(T, T, T, T, T, T, T, T) as From<[T; 8]>> + <(T, T, T, T, T, T, T, T, T) as From<[T; 9]>> and 4 others = note: required for `Result<i32, ()>` to implement `FromResidual<Result<Infallible, {integer}>>` diff --git a/tests/ui/try-trait/option-to-result.stderr b/tests/ui/try-trait/option-to-result.stderr index 1c4d718f1ee..fabc1ff2c76 100644 --- a/tests/ui/try-trait/option-to-result.stderr +++ b/tests/ui/try-trait/option-to-result.stderr @@ -9,8 +9,8 @@ LL | a?; | = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `Result<(), ()>` = help: the following other types implement trait `FromResidual<R>`: - <Result<T, F> as FromResidual<Yeet<E>>> <Result<T, F> as FromResidual<Result<Infallible, E>>> + <Result<T, F> as FromResidual<Yeet<E>>> error[E0277]: the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option` --> $DIR/option-to-result.rs:11:6 diff --git a/tests/ui/try-trait/try-on-option.stderr b/tests/ui/try-trait/try-on-option.stderr index eeb0439df29..fad6a1fe823 100644 --- a/tests/ui/try-trait/try-on-option.stderr +++ b/tests/ui/try-trait/try-on-option.stderr @@ -9,8 +9,8 @@ LL | x?; | = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `Result<u32, ()>` = help: the following other types implement trait `FromResidual<R>`: - <Result<T, F> as FromResidual<Yeet<E>>> <Result<T, F> as FromResidual<Result<Infallible, E>>> + <Result<T, F> as FromResidual<Yeet<E>>> error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) --> $DIR/try-on-option.rs:11:6 diff --git a/tests/ui/type-alias-impl-trait/nested-tait-inference2.stderr b/tests/ui/type-alias-impl-trait/nested-tait-inference2.stderr index c549ca5b2ce..241342b0509 100644 --- a/tests/ui/type-alias-impl-trait/nested-tait-inference2.stderr +++ b/tests/ui/type-alias-impl-trait/nested-tait-inference2.stderr @@ -8,8 +8,8 @@ LL | () | -- return type was inferred to be `()` here | = help: the following other types implement trait `Foo<A>`: - <() as Foo<u32>> <() as Foo<()>> + <() as Foo<u32>> error: aborting due to 1 previous error diff --git a/tests/ui/type/type-check-defaults.stderr b/tests/ui/type/type-check-defaults.stderr index 10d600cbfcc..9ba63ffe9c9 100644 --- a/tests/ui/type/type-check-defaults.stderr +++ b/tests/ui/type/type-check-defaults.stderr @@ -66,10 +66,10 @@ LL | trait ProjectionPred<T:Iterator = IntoIter<i32>> where T::Item : Add<u8> {} | = help: the trait `Add<u8>` is not implemented for `i32` = help: the following other types implement trait `Add<Rhs>`: - <i32 as Add> - <i32 as Add<&i32>> <&'a i32 as Add<i32>> <&i32 as Add<&i32>> + <i32 as Add<&i32>> + <i32 as Add> error: aborting due to 7 previous errors diff --git a/tests/ui/typeck/issue-81293.stderr b/tests/ui/typeck/issue-81293.stderr index 292c63070ae..6976be71135 100644 --- a/tests/ui/typeck/issue-81293.stderr +++ b/tests/ui/typeck/issue-81293.stderr @@ -21,10 +21,10 @@ LL | a = c + b * 5; | = help: the trait `Add<u16>` is not implemented for `usize` = help: the following other types implement trait `Add<Rhs>`: - <usize as Add> - <usize as Add<&usize>> <&'a usize as Add<usize>> <&usize as Add<&usize>> + <usize as Add<&usize>> + <usize as Add> error: aborting due to 3 previous errors diff --git a/tests/ui/typeck/issue-90101.stderr b/tests/ui/typeck/issue-90101.stderr index d5ba157974d..800d7e9594a 100644 --- a/tests/ui/typeck/issue-90101.stderr +++ b/tests/ui/typeck/issue-90101.stderr @@ -7,11 +7,11 @@ LL | func(Path::new("hello").to_path_buf().to_string_lossy(), "world") | required by a bound introduced by this call | = help: the following other types implement trait `From<T>`: + <PathBuf as From<&T>> <PathBuf as From<Box<Path>>> <PathBuf as From<Cow<'a, Path>>> <PathBuf as From<OsString>> <PathBuf as From<String>> - <PathBuf as From<&T>> = note: required for `Cow<'_, str>` to implement `Into<PathBuf>` note: required by a bound in `func` --> $DIR/issue-90101.rs:3:20 diff --git a/tests/ui/typeck/typeck_type_placeholder_item.stderr b/tests/ui/typeck/typeck_type_placeholder_item.stderr index 8bcad56916a..7977504dae1 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item.stderr +++ b/tests/ui/typeck/typeck_type_placeholder_item.stderr @@ -546,6 +546,15 @@ help: use type parameters instead LL | fn fn_test10<T>(&self, _x : T) { } | +++ ~ +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants + --> $DIR/typeck_type_placeholder_item.rs:194:14 + | +LL | const D: _ = 42; + | ^ + | | + | not allowed in type signatures + | help: replace with the correct type: `i32` + error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/typeck_type_placeholder_item.rs:217:31 | @@ -574,19 +583,7 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures --> $DIR/typeck_type_placeholder_item.rs:209:14 | LL | const D: _ = 42; - | ^ - | | - | not allowed in type signatures - | help: replace with the correct type: `i32` - -error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants - --> $DIR/typeck_type_placeholder_item.rs:194:14 - | -LL | const D: _ = 42; - | ^ - | | - | not allowed in type signatures - | help: replace with the correct type: `i32` + | ^ not allowed in type signatures error[E0046]: not all trait items implemented, missing: `F` --> $DIR/typeck_type_placeholder_item.rs:200:1 diff --git a/tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr b/tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr index c1281ce6a42..964fd4af009 100644 --- a/tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr +++ b/tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr @@ -6,10 +6,10 @@ LL | <i32 as Add<u32>>::add(1, 2); | = help: the trait `Add<u32>` is not implemented for `i32` = help: the following other types implement trait `Add<Rhs>`: - <i32 as Add> - <i32 as Add<&i32>> <&'a i32 as Add<i32>> <&i32 as Add<&i32>> + <i32 as Add<&i32>> + <i32 as Add> error[E0277]: cannot add `u32` to `i32` --> $DIR/ufcs-qpath-self-mismatch.rs:4:5 @@ -19,10 +19,10 @@ LL | <i32 as Add<u32>>::add(1, 2); | = help: the trait `Add<u32>` is not implemented for `i32` = help: the following other types implement trait `Add<Rhs>`: - <i32 as Add> - <i32 as Add<&i32>> <&'a i32 as Add<i32>> <&i32 as Add<&i32>> + <i32 as Add<&i32>> + <i32 as Add> error[E0308]: mismatched types --> $DIR/ufcs-qpath-self-mismatch.rs:7:28 diff --git a/triagebot.toml b/triagebot.toml index 62a706fafe1..0df71c60d54 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -717,6 +717,9 @@ cc = ["@rust-lang/project-exploit-mitigations", "@rcvalle"] [mentions."src/doc/unstable-book/src/compiler-flags/check-cfg.md"] cc = ["@Urgau"] +[mentions."src/doc/rustc/src/platform-support"] +cc = ["@Nilstrieb"] + [mentions."tests/codegen/sanitizer"] cc = ["@rust-lang/project-exploit-mitigations", "@rcvalle"] |
