diff --git a/compiler/rustc_attr_parsing/src/attributes/stability.rs b/compiler/rustc_attr_parsing/src/attributes/stability.rs index 5a26178f84b58..c7a809d7d881a 100644 --- a/compiler/rustc_attr_parsing/src/attributes/stability.rs +++ b/compiler/rustc_attr_parsing/src/attributes/stability.rs @@ -54,6 +54,7 @@ const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[ Allow(Target::Static), Allow(Target::ForeignFn), Allow(Target::ForeignStatic), + Allow(Target::ExternCrate), ]); #[derive(Default)] diff --git a/compiler/rustc_borrowck/src/type_check/relate_tys.rs b/compiler/rustc_borrowck/src/type_check/relate_tys.rs index 84ca9bad2c144..7ac2dff12f756 100644 --- a/compiler/rustc_borrowck/src/type_check/relate_tys.rs +++ b/compiler/rustc_borrowck/src/type_check/relate_tys.rs @@ -124,8 +124,13 @@ impl<'a, 'b, 'tcx> NllTypeRelating<'a, 'b, 'tcx> { // by using `ty_vid rel B` and then finally and end by equating `ty_vid` to // the opaque. let mut enable_subtyping = |ty, opaque_is_expected| { - let ty_vid = infcx.next_ty_var_id_in_universe(self.span(), ty::UniverseIndex::ROOT); - + // We create the fresh inference variable in the highest universe. + // In theory we could limit it to the highest universe in the args of + // the opaque but that isn't really worth the effort. + // + // We'll make sure that the opaque type can actually name everything + // in its hidden type later on. + let ty_vid = infcx.next_ty_vid(self.span()); let variance = if opaque_is_expected { self.ambient_variance } else { diff --git a/compiler/rustc_builtin_macros/src/deriving/from.rs b/compiler/rustc_builtin_macros/src/deriving/from.rs index ef0e6ca324a32..ab25de7c91752 100644 --- a/compiler/rustc_builtin_macros/src/deriving/from.rs +++ b/compiler/rustc_builtin_macros/src/deriving/from.rs @@ -27,21 +27,39 @@ pub(crate) fn expand_deriving_from( cx.dcx().bug("derive(From) used on something else than an item"); }; - // #[derive(From)] is currently usable only on structs with exactly one field. - let field = if let ItemKind::Struct(_, _, data) = &item.kind - && let [field] = data.fields() - { - Some(field.clone()) - } else { - None + let err_span = || { + let item_span = item.kind.ident().map(|ident| ident.span).unwrap_or(item.span); + MultiSpan::from_spans(vec![span, item_span]) }; - let from_type = match &field { - Some(field) => Ty::AstTy(field.ty.clone()), - // We don't have a type to put into From<...> if we don't have a single field, so just put - // unit there. - None => Ty::Unit, + // `#[derive(From)]` is currently usable only on structs with exactly one field. + let field = match &item.kind { + ItemKind::Struct(_, _, data) => { + if let [field] = data.fields() { + Ok(field.clone()) + } else { + let guar = cx.dcx().emit_err(errors::DeriveFromWrongFieldCount { + span: err_span(), + multiple_fields: data.fields().len() > 1, + }); + Err(guar) + } + } + ItemKind::Enum(_, _, _) | ItemKind::Union(_, _, _) => { + let guar = cx.dcx().emit_err(errors::DeriveFromWrongTarget { + span: err_span(), + kind: &format!("{} {}", item.kind.article(), item.kind.descr()), + }); + Err(guar) + } + _ => cx.dcx().bug("Invalid derive(From) ADT input"), }; + + let from_type = Ty::AstTy(match field { + Ok(ref field) => field.ty.clone(), + Err(guar) => cx.ty(span, ast::TyKind::Err(guar)), + }); + let path = Path::new_(pathvec_std!(convert::From), vec![Box::new(from_type.clone())], PathKind::Std); @@ -71,34 +89,17 @@ pub(crate) fn expand_deriving_from( attributes: thin_vec![cx.attr_word(sym::inline, span)], fieldless_variants_strategy: FieldlessVariantsStrategy::Default, combine_substructure: combine_substructure(Box::new(|cx, span, substructure| { - let Some(field) = &field else { - let item_span = item.kind.ident().map(|ident| ident.span).unwrap_or(item.span); - let err_span = MultiSpan::from_spans(vec![span, item_span]); - let error = match &item.kind { - ItemKind::Struct(_, _, data) => { - cx.dcx().emit_err(errors::DeriveFromWrongFieldCount { - span: err_span, - multiple_fields: data.fields().len() > 1, - }) - } - ItemKind::Enum(_, _, _) | ItemKind::Union(_, _, _) => { - cx.dcx().emit_err(errors::DeriveFromWrongTarget { - span: err_span, - kind: &format!("{} {}", item.kind.article(), item.kind.descr()), - }) - } - _ => cx.dcx().bug("Invalid derive(From) ADT input"), - }; - - return BlockOrExpr::new_expr(DummyResult::raw_expr(span, Some(error))); + let field = match field { + Ok(ref field) => field, + Err(guar) => { + return BlockOrExpr::new_expr(DummyResult::raw_expr(span, Some(guar))); + } }; let self_kw = Ident::new(kw::SelfUpper, span); let expr: Box = match substructure.fields { SubstructureFields::StaticStruct(variant, _) => match variant { - // Self { - // field: value - // } + // Self { field: value } VariantData::Struct { .. } => cx.expr_struct_ident( span, self_kw, diff --git a/compiler/rustc_builtin_macros/src/lib.rs b/compiler/rustc_builtin_macros/src/lib.rs index 86a4927f3903f..1bcea95fbb7b0 100644 --- a/compiler/rustc_builtin_macros/src/lib.rs +++ b/compiler/rustc_builtin_macros/src/lib.rs @@ -8,7 +8,6 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(rust_logo)] #![feature(assert_matches)] -#![feature(autodiff)] #![feature(box_patterns)] #![feature(decl_macro)] #![feature(if_let_guard)] diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index a6daacd95ef80..8f1218bb505fb 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -497,7 +497,7 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>( to_add.push(llvm::CreateAttrStringValue(cx.llcx, "wasm-import-module", module)); let name = - codegen_fn_attrs.link_name.unwrap_or_else(|| cx.tcx.item_name(instance.def_id())); + codegen_fn_attrs.symbol_name.unwrap_or_else(|| cx.tcx.item_name(instance.def_id())); let name = name.as_str(); to_add.push(llvm::CreateAttrStringValue(cx.llcx, "wasm-import-name", name)); } diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index 2d91ae64e2dd2..4a7de7d2e69e2 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -471,6 +471,15 @@ pub(crate) unsafe fn create_module<'ll>( } } + if sess.opts.unstable_opts.indirect_branch_cs_prefix { + llvm::add_module_flag_u32( + llmod, + llvm::ModuleFlagMergeBehavior::Override, + "indirect_branch_cs_prefix", + 1, + ); + } + match (sess.opts.unstable_opts.small_data_threshold, sess.target.small_data_threshold_support()) { // Set up the small-data optimization limit for architectures that use diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index 67cd1f4cd41a0..8abaf201abae2 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -858,7 +858,7 @@ pub fn is_call_from_compiler_builtins_to_upstream_monomorphization<'tcx>( instance: Instance<'tcx>, ) -> bool { fn is_llvm_intrinsic(tcx: TyCtxt<'_>, def_id: DefId) -> bool { - if let Some(name) = tcx.codegen_fn_attrs(def_id).link_name { + if let Some(name) = tcx.codegen_fn_attrs(def_id).symbol_name { name.as_str().starts_with("llvm.") } else { false diff --git a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs index af70f0deb0706..20385ba8e4cb5 100644 --- a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs +++ b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs @@ -6,7 +6,6 @@ use rustc_ast::{LitKind, MetaItem, MetaItemInner, attr}; use rustc_hir::attrs::{AttributeKind, InlineAttr, InstructionSetAttr, UsedBy}; use rustc_hir::def::DefKind; use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId}; -use rustc_hir::weak_lang_items::WEAK_LANG_ITEMS; use rustc_hir::{self as hir, Attribute, LangItem, find_attr, lang_items}; use rustc_middle::middle::codegen_fn_attrs::{ CodegenFnAttrFlags, CodegenFnAttrs, PatchableFunctionEntry, @@ -182,7 +181,7 @@ fn process_builtin_attrs( match p { AttributeKind::Cold(_) => codegen_fn_attrs.flags |= CodegenFnAttrFlags::COLD, AttributeKind::ExportName { name, .. } => { - codegen_fn_attrs.export_name = Some(*name) + codegen_fn_attrs.symbol_name = Some(*name) } AttributeKind::Inline(inline, span) => { codegen_fn_attrs.inline = *inline; @@ -190,7 +189,13 @@ fn process_builtin_attrs( } AttributeKind::Naked(_) => codegen_fn_attrs.flags |= CodegenFnAttrFlags::NAKED, AttributeKind::Align { align, .. } => codegen_fn_attrs.alignment = Some(*align), - AttributeKind::LinkName { name, .. } => codegen_fn_attrs.link_name = Some(*name), + AttributeKind::LinkName { name, .. } => { + // FIXME Remove check for foreign functions once #[link_name] on non-foreign + // functions is a hard error + if tcx.is_foreign_item(did) { + codegen_fn_attrs.symbol_name = Some(*name); + } + } AttributeKind::LinkOrdinal { ordinal, span } => { codegen_fn_attrs.link_ordinal = Some(*ordinal); interesting_spans.link_ordinal = Some(*span); @@ -410,7 +415,7 @@ fn apply_overrides(tcx: TyCtxt<'_>, did: LocalDefId, codegen_fn_attrs: &mut Code // * `#[rustc_std_internal_symbol]` mangles the symbol name in a special way // both for exports and imports through foreign items. This is handled further, // during symbol mangling logic. - } else if codegen_fn_attrs.link_name.is_some() { + } else if codegen_fn_attrs.symbol_name.is_some() { // * This can be overridden with the `#[link_name]` attribute } else { // NOTE: there's one more exception that we cannot apply here. On wasm, @@ -465,7 +470,7 @@ fn check_result( } // error when specifying link_name together with link_ordinal - if let Some(_) = codegen_fn_attrs.link_name + if let Some(_) = codegen_fn_attrs.symbol_name && let Some(_) = codegen_fn_attrs.link_ordinal { let msg = "cannot use `#[link_name]` with `#[link_ordinal]`"; @@ -512,14 +517,11 @@ fn handle_lang_items( // strippable by the linker. // // Additionally weak lang items have predetermined symbol names. - if let Some(lang_item) = lang_item { - if WEAK_LANG_ITEMS.contains(&lang_item) { - codegen_fn_attrs.flags |= CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL; - } - if let Some(link_name) = lang_item.link_name() { - codegen_fn_attrs.export_name = Some(link_name); - codegen_fn_attrs.link_name = Some(link_name); - } + if let Some(lang_item) = lang_item + && let Some(link_name) = lang_item.link_name() + { + codegen_fn_attrs.flags |= CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL; + codegen_fn_attrs.symbol_name = Some(link_name); } // error when using no_mangle on a lang item item diff --git a/compiler/rustc_codegen_ssa/src/target_features.rs b/compiler/rustc_codegen_ssa/src/target_features.rs index 7e4341a823667..b5aa50f485125 100644 --- a/compiler/rustc_codegen_ssa/src/target_features.rs +++ b/compiler/rustc_codegen_ssa/src/target_features.rs @@ -180,6 +180,7 @@ fn parse_rust_feature_flag<'a>( while let Some(new_feature) = new_features.pop() { if features.insert(new_feature) { if let Some(implied_features) = inverse_implied_features.get(&new_feature) { + #[allow(rustc::potential_query_instability)] new_features.extend(implied_features) } } diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index a8a1ac1c9809e..9681d89ce35f2 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -325,8 +325,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { let _trace = enter_trace_span!( M, "instantiate_from_frame_and_normalize_erasing_regions", - "{}", - frame.instance + %frame.instance ); frame .instance @@ -583,6 +582,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { span: Span, layout: Option>, ) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> { + let _trace = enter_trace_span!(M, const_eval::eval_mir_constant, ?val); let const_val = val.eval(*self.tcx, self.typing_env, span).map_err(|err| { if M::ALL_CONSTS_ARE_PRECHECKED { match err { diff --git a/compiler/rustc_const_eval/src/interpret/stack.rs b/compiler/rustc_const_eval/src/interpret/stack.rs index 73cc87508ef95..7cabfd961212f 100644 --- a/compiler/rustc_const_eval/src/interpret/stack.rs +++ b/compiler/rustc_const_eval/src/interpret/stack.rs @@ -20,7 +20,7 @@ use super::{ MemoryKind, Operand, PlaceTy, Pointer, Provenance, ReturnAction, Scalar, from_known_layout, interp_ok, throw_ub, throw_unsup, }; -use crate::errors; +use crate::{enter_trace_span, errors}; // The Phantomdata exists to prevent this type from being `Send`. If it were sent across a thread // boundary and dropped in the other thread, it would exit the span in the other thread. @@ -386,6 +386,9 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { // Make sure all the constants required by this frame evaluate successfully (post-monomorphization check). for &const_ in body.required_consts() { + // We can't use `eval_mir_constant` here as that assumes that all required consts have + // already been checked, so we need a separate tracing call. + let _trace = enter_trace_span!(M, const_eval::required_consts, ?const_.const_); let c = self.instantiate_from_current_frame_and_normalize_erasing_regions(const_.const_)?; c.eval(*self.tcx, self.typing_env, const_.span).map_err(|err| { diff --git a/compiler/rustc_const_eval/src/interpret/step.rs b/compiler/rustc_const_eval/src/interpret/step.rs index f1995b3f132f6..5143278e69a01 100644 --- a/compiler/rustc_const_eval/src/interpret/step.rs +++ b/compiler/rustc_const_eval/src/interpret/step.rs @@ -436,7 +436,10 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { .map(|arg| self.eval_fn_call_argument(&arg.node)) .collect::>>()?; - let fn_sig_binder = func.layout.ty.fn_sig(*self.tcx); + let fn_sig_binder = { + let _trace = enter_trace_span!(M, "fn_sig", ty = ?func.layout.ty.kind()); + func.layout.ty.fn_sig(*self.tcx) + }; let fn_sig = self.tcx.normalize_erasing_late_bound_regions(self.typing_env, fn_sig_binder); let extra_args = &args[fn_sig.inputs().len()..]; let extra_args = diff --git a/compiler/rustc_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs index 5e8bee65706b8..02e3d90f4af70 100644 --- a/compiler/rustc_const_eval/src/interpret/validity.rs +++ b/compiler/rustc_const_eval/src/interpret/validity.rs @@ -1418,7 +1418,9 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { let _trace = enter_trace_span!( M, "validate_operand", - "recursive={recursive}, reset_provenance_and_padding={reset_provenance_and_padding}, val={val:?}" + recursive, + reset_provenance_and_padding, + ?val, ); // Note that we *could* actually be in CTFE here with `-Zextra-const-ub-checks`, but it's diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 97c47fa9b9a53..749bba5de1273 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -17,7 +17,7 @@ use std::path::Path; use std::sync::Arc; use derive_setters::Setters; -use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet}; +use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; use rustc_data_structures::sync::{DynSend, IntoDynSyncSend}; use rustc_error_messages::{FluentArgs, SpanLabel}; use rustc_lexer; @@ -1853,7 +1853,7 @@ impl HumanEmitter { && line_idx + 1 == annotated_file.lines.len(), ); - let mut to_add = FxHashMap::default(); + let mut to_add = FxIndexMap::default(); for (depth, style) in depths { // FIXME(#120456) - is `swap_remove` correct? diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index bced02ae4dabb..8b43f852b2638 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -596,6 +596,7 @@ pub(super) fn try_match_macro_attr<'matcher, T: Tracker<'matcher>>( match result { Success(body_named_matches) => { psess.gated_spans.merge(gated_spans_snapshot); + #[allow(rustc::potential_query_instability)] named_matches.extend(body_named_matches); return Ok((i, rule, named_matches)); } diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index 82d4856df39c7..9ff06bda89bad 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -782,22 +782,30 @@ impl<'tcx> InferCtxt<'tcx> { self.inner.borrow_mut().type_variables().num_vars() } - pub fn next_ty_var(&self, span: Span) -> Ty<'tcx> { - self.next_ty_var_with_origin(TypeVariableOrigin { span, param_def_id: None }) + pub fn next_ty_vid(&self, span: Span) -> TyVid { + self.next_ty_vid_with_origin(TypeVariableOrigin { span, param_def_id: None }) } - pub fn next_ty_var_with_origin(&self, origin: TypeVariableOrigin) -> Ty<'tcx> { - let vid = self.inner.borrow_mut().type_variables().new_var(self.universe(), origin); - Ty::new_var(self.tcx, vid) + pub fn next_ty_vid_with_origin(&self, origin: TypeVariableOrigin) -> TyVid { + self.inner.borrow_mut().type_variables().new_var(self.universe(), origin) } - pub fn next_ty_var_id_in_universe(&self, span: Span, universe: ty::UniverseIndex) -> TyVid { + pub fn next_ty_vid_in_universe(&self, span: Span, universe: ty::UniverseIndex) -> TyVid { let origin = TypeVariableOrigin { span, param_def_id: None }; self.inner.borrow_mut().type_variables().new_var(universe, origin) } + pub fn next_ty_var(&self, span: Span) -> Ty<'tcx> { + self.next_ty_var_with_origin(TypeVariableOrigin { span, param_def_id: None }) + } + + pub fn next_ty_var_with_origin(&self, origin: TypeVariableOrigin) -> Ty<'tcx> { + let vid = self.next_ty_vid_with_origin(origin); + Ty::new_var(self.tcx, vid) + } + pub fn next_ty_var_in_universe(&self, span: Span, universe: ty::UniverseIndex) -> Ty<'tcx> { - let vid = self.next_ty_var_id_in_universe(span, universe); + let vid = self.next_ty_vid_in_universe(span, universe); Ty::new_var(self.tcx, vid) } diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index c46e879b976ac..8f131f45bbddb 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -285,7 +285,9 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec) -> Ch .expecteds .entry(name.name) .and_modify(|v| match v { - ExpectedValues::Some(v) if !values_any_specified => { + ExpectedValues::Some(v) if !values_any_specified => + { + #[allow(rustc::potential_query_instability)] v.extend(values.clone()) } ExpectedValues::Some(_) => *v = ExpectedValues::Any, diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 0a764808f9538..4425877308a78 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -807,6 +807,7 @@ fn test_unstable_options_tracking_hash() { tracked!(hint_mostly_unused, true); tracked!(human_readable_cgu_names, true); tracked!(incremental_ignore_spans, true); + tracked!(indirect_branch_cs_prefix, true); tracked!(inline_mir, Some(true)); tracked!(inline_mir_hint_threshold, Some(123)); tracked!(inline_mir_threshold, Some(123)); diff --git a/compiler/rustc_lint/src/foreign_modules.rs b/compiler/rustc_lint/src/foreign_modules.rs index 759e6c927b828..3267e70f1de26 100644 --- a/compiler/rustc_lint/src/foreign_modules.rs +++ b/compiler/rustc_lint/src/foreign_modules.rs @@ -179,7 +179,7 @@ impl ClashingExternDeclarations { /// symbol's name. fn name_of_extern_decl(tcx: TyCtxt<'_>, fi: hir::OwnerId) -> SymbolName { if let Some((overridden_link_name, overridden_link_name_span)) = - tcx.codegen_fn_attrs(fi).link_name.map(|overridden_link_name| { + tcx.codegen_fn_attrs(fi).symbol_name.map(|overridden_link_name| { // FIXME: Instead of searching through the attributes again to get span // information, we could have codegen_fn_attrs also give span information back for // where the attribute was defined. However, until this is found to be a diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index 016ff17f5d7ea..e1fbe39222b66 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -1,10 +1,10 @@ //! Some lints that are only useful in the compiler or crates that use compiler internals, such as //! Clippy. -use rustc_hir::HirId; use rustc_hir::def::Res; use rustc_hir::def_id::DefId; -use rustc_middle::ty::{self, GenericArgsRef, Ty as MiddleTy}; +use rustc_hir::{Expr, ExprKind, HirId}; +use rustc_middle::ty::{self, ClauseKind, GenericArgsRef, PredicatePolarity, TraitPredicate, Ty}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::hygiene::{ExpnKind, MacroKind}; use rustc_span::{Span, sym}; @@ -56,25 +56,6 @@ impl LateLintPass<'_> for DefaultHashTypes { } } -/// Helper function for lints that check for expressions with calls and use typeck results to -/// get the `DefId` and `GenericArgsRef` of the function. -fn typeck_results_of_method_fn<'tcx>( - cx: &LateContext<'tcx>, - expr: &hir::Expr<'_>, -) -> Option<(Span, DefId, ty::GenericArgsRef<'tcx>)> { - match expr.kind { - hir::ExprKind::MethodCall(segment, ..) - if let Some(def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) => - { - Some((segment.ident.span, def_id, cx.typeck_results().node_args(expr.hir_id))) - } - _ => match cx.typeck_results().node_type(expr.hir_id).kind() { - &ty::FnDef(def_id, args) => Some((expr.span, def_id, args)), - _ => None, - }, - } -} - declare_tool_lint! { /// The `potential_query_instability` lint detects use of methods which can lead to /// potential query instability, such as iterating over a `HashMap`. @@ -101,10 +82,12 @@ declare_tool_lint! { declare_lint_pass!(QueryStability => [POTENTIAL_QUERY_INSTABILITY, UNTRACKED_QUERY_INFORMATION]); -impl LateLintPass<'_> for QueryStability { - fn check_expr(&mut self, cx: &LateContext<'_>, expr: &hir::Expr<'_>) { - let Some((span, def_id, args)) = typeck_results_of_method_fn(cx, expr) else { return }; - if let Ok(Some(instance)) = ty::Instance::try_resolve(cx.tcx, cx.typing_env(), def_id, args) +impl<'tcx> LateLintPass<'tcx> for QueryStability { + fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) { + if let Some((callee_def_id, span, generic_args, _recv, _args)) = + get_callee_span_generic_args_and_args(cx, expr) + && let Ok(Some(instance)) = + ty::Instance::try_resolve(cx.tcx, cx.typing_env(), callee_def_id, generic_args) { let def_id = instance.def_id(); if cx.tcx.has_attr(def_id, sym::rustc_lint_query_instability) { @@ -113,7 +96,15 @@ impl LateLintPass<'_> for QueryStability { span, QueryInstability { query: cx.tcx.item_name(def_id) }, ); + } else if has_unstable_into_iter_predicate(cx, callee_def_id, generic_args) { + let call_span = span.with_hi(expr.span.hi()); + cx.emit_span_lint( + POTENTIAL_QUERY_INSTABILITY, + call_span, + QueryInstability { query: sym::into_iter }, + ); } + if cx.tcx.has_attr(def_id, sym::rustc_lint_untracked_query_information) { cx.emit_span_lint( UNTRACKED_QUERY_INFORMATION, @@ -125,6 +116,64 @@ impl LateLintPass<'_> for QueryStability { } } +fn has_unstable_into_iter_predicate<'tcx>( + cx: &LateContext<'tcx>, + callee_def_id: DefId, + generic_args: GenericArgsRef<'tcx>, +) -> bool { + let Some(into_iterator_def_id) = cx.tcx.get_diagnostic_item(sym::IntoIterator) else { + return false; + }; + let Some(into_iter_fn_def_id) = cx.tcx.lang_items().into_iter_fn() else { + return false; + }; + let predicates = cx.tcx.predicates_of(callee_def_id).instantiate(cx.tcx, generic_args); + for (predicate, _) in predicates { + let ClauseKind::Trait(TraitPredicate { trait_ref, polarity: PredicatePolarity::Positive }) = + predicate.kind().skip_binder() + else { + continue; + }; + // Does the function or method require any of its arguments to implement `IntoIterator`? + if trait_ref.def_id != into_iterator_def_id { + continue; + } + let Ok(Some(instance)) = + ty::Instance::try_resolve(cx.tcx, cx.typing_env(), into_iter_fn_def_id, trait_ref.args) + else { + continue; + }; + // Does the input type's `IntoIterator` implementation have the + // `rustc_lint_query_instability` attribute on its `into_iter` method? + if cx.tcx.has_attr(instance.def_id(), sym::rustc_lint_query_instability) { + return true; + } + } + false +} + +/// Checks whether an expression is a function or method call and, if so, returns its `DefId`, +/// `Span`, `GenericArgs`, and arguments. This is a slight augmentation of a similarly named Clippy +/// function, `get_callee_generic_args_and_args`. +fn get_callee_span_generic_args_and_args<'tcx>( + cx: &LateContext<'tcx>, + expr: &'tcx Expr<'tcx>, +) -> Option<(DefId, Span, GenericArgsRef<'tcx>, Option<&'tcx Expr<'tcx>>, &'tcx [Expr<'tcx>])> { + if let ExprKind::Call(callee, args) = expr.kind + && let callee_ty = cx.typeck_results().expr_ty(callee) + && let ty::FnDef(callee_def_id, generic_args) = callee_ty.kind() + { + return Some((*callee_def_id, callee.span, generic_args, None, args)); + } + if let ExprKind::MethodCall(segment, recv, args, _) = expr.kind + && let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) + { + let generic_args = cx.typeck_results().node_args(expr.hir_id); + return Some((method_def_id, segment.ident.span, generic_args, Some(recv), args)); + } + None +} + declare_tool_lint! { /// The `usage_of_ty_tykind` lint detects usages of `ty::TyKind::`, /// where `ty::` would suffice. @@ -461,33 +510,22 @@ declare_tool_lint! { declare_lint_pass!(Diagnostics => [UNTRANSLATABLE_DIAGNOSTIC, DIAGNOSTIC_OUTSIDE_OF_IMPL]); impl LateLintPass<'_> for Diagnostics { - fn check_expr(&mut self, cx: &LateContext<'_>, expr: &hir::Expr<'_>) { + fn check_expr<'tcx>(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) { let collect_args_tys_and_spans = |args: &[hir::Expr<'_>], reserve_one_extra: bool| { let mut result = Vec::with_capacity(args.len() + usize::from(reserve_one_extra)); result.extend(args.iter().map(|arg| (cx.typeck_results().expr_ty(arg), arg.span))); result }; // Only check function calls and method calls. - let (span, def_id, fn_gen_args, arg_tys_and_spans) = match expr.kind { - hir::ExprKind::Call(callee, args) => { - match cx.typeck_results().node_type(callee.hir_id).kind() { - &ty::FnDef(def_id, fn_gen_args) => { - (callee.span, def_id, fn_gen_args, collect_args_tys_and_spans(args, false)) - } - _ => return, // occurs for fns passed as args - } - } - hir::ExprKind::MethodCall(_segment, _recv, args, _span) => { - let Some((span, def_id, fn_gen_args)) = typeck_results_of_method_fn(cx, expr) - else { - return; - }; - let mut args = collect_args_tys_and_spans(args, true); - args.insert(0, (cx.tcx.types.self_param, _recv.span)); // dummy inserted for `self` - (span, def_id, fn_gen_args, args) - } - _ => return, + let Some((def_id, span, fn_gen_args, recv, args)) = + get_callee_span_generic_args_and_args(cx, expr) + else { + return; }; + let mut arg_tys_and_spans = collect_args_tys_and_spans(args, recv.is_some()); + if let Some(recv) = recv { + arg_tys_and_spans.insert(0, (cx.tcx.types.self_param, recv.span)); // dummy inserted for `self` + } Self::diagnostic_outside_of_impl(cx, span, expr.hir_id, def_id, fn_gen_args); Self::untranslatable_diagnostic(cx, def_id, &arg_tys_and_spans); @@ -496,7 +534,7 @@ impl LateLintPass<'_> for Diagnostics { impl Diagnostics { // Is the type `{D,Subd}iagMessage`? - fn is_diag_message<'cx>(cx: &LateContext<'cx>, ty: MiddleTy<'cx>) -> bool { + fn is_diag_message<'cx>(cx: &LateContext<'cx>, ty: Ty<'cx>) -> bool { if let Some(adt_def) = ty.ty_adt_def() && let Some(name) = cx.tcx.get_diagnostic_name(adt_def.did()) && matches!(name, sym::DiagMessage | sym::SubdiagMessage) @@ -510,7 +548,7 @@ impl Diagnostics { fn untranslatable_diagnostic<'cx>( cx: &LateContext<'cx>, def_id: DefId, - arg_tys_and_spans: &[(MiddleTy<'cx>, Span)], + arg_tys_and_spans: &[(Ty<'cx>, Span)], ) { let fn_sig = cx.tcx.fn_sig(def_id).instantiate_identity().skip_binder(); let predicates = cx.tcx.predicates_of(def_id).instantiate_identity(cx.tcx).predicates; diff --git a/compiler/rustc_macros/src/print_attribute.rs b/compiler/rustc_macros/src/print_attribute.rs index 9023520c75043..0114e0dfde0db 100644 --- a/compiler/rustc_macros/src/print_attribute.rs +++ b/compiler/rustc_macros/src/print_attribute.rs @@ -4,7 +4,7 @@ use syn::spanned::Spanned; use syn::{Data, Fields, Ident}; use synstructure::Structure; -fn print_fields(name: &Ident, fields: &Fields) -> (TokenStream, TokenStream, TokenStream) { +fn print_fields(name: &Ident, fields: &Fields) -> (TokenStream, TokenStream) { let string_name = name.to_string(); let mut disps = vec![quote! {let mut __printed_anything = false;}]; @@ -43,7 +43,6 @@ fn print_fields(name: &Ident, fields: &Fields) -> (TokenStream, TokenStream, Tok #(#disps)* __p.word("}"); }, - quote! { true }, ) } Fields::Unnamed(fields_unnamed) => { @@ -76,10 +75,9 @@ fn print_fields(name: &Ident, fields: &Fields) -> (TokenStream, TokenStream, Tok #(#disps)* __p.pclose(); }, - quote! { true }, ) } - Fields::Unit => (quote! {}, quote! { __p.word(#string_name) }, quote! { true }), + Fields::Unit => (quote! {}, quote! { __p.word(#string_name) }), } } @@ -89,51 +87,33 @@ pub(crate) fn print_attribute(input: Structure<'_>) -> TokenStream { }; // Must be applied to an enum type. - let (code, printed) = match &input.ast().data { + let code = match &input.ast().data { Data::Enum(e) => { - let (arms, printed) = e + let arms = e .variants .iter() .map(|x| { let ident = &x.ident; - let (pat, code, printed) = print_fields(ident, &x.fields); + let (pat, code) = print_fields(ident, &x.fields); - ( - quote! { - Self::#ident #pat => {#code} - }, - quote! { - Self::#ident #pat => {#printed} - }, - ) + quote! { + Self::#ident #pat => {#code} + } }) - .unzip::<_, _, Vec<_>, Vec<_>>(); + .collect::>(); - ( - quote! { - match self { - #(#arms)* - } - }, - quote! { - match self { - #(#printed)* - } - }, - ) + quote! { + match self { + #(#arms)* + } + } } Data::Struct(s) => { - let (pat, code, printed) = print_fields(&input.ast().ident, &s.fields); - ( - quote! { - let Self #pat = self; - #code - }, - quote! { - let Self #pat = self; - #printed - }, - ) + let (pat, code) = print_fields(&input.ast().ident, &s.fields); + quote! { + let Self #pat = self; + #code + } } Data::Union(u) => { return span_error(u.union_token.span(), "can't derive PrintAttribute on unions"); @@ -144,7 +124,7 @@ pub(crate) fn print_attribute(input: Structure<'_>) -> TokenStream { input.gen_impl(quote! { #[allow(unused)] gen impl PrintAttribute for @Self { - fn should_render(&self) -> bool { #printed } + fn should_render(&self) -> bool { true } fn print_attribute(&self, __p: &mut rustc_ast_pretty::pp::Printer) { #code } } }) diff --git a/compiler/rustc_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs index 958e314efabb4..63f1b51df1c6b 100644 --- a/compiler/rustc_metadata/src/native_libs.rs +++ b/compiler/rustc_metadata/src/native_libs.rs @@ -701,7 +701,7 @@ impl<'tcx> Collector<'tcx> { .link_ordinal .map_or(import_name_type, |ord| Some(PeImportNameType::Ordinal(ord))); - let name = codegen_fn_attrs.link_name.unwrap_or_else(|| self.tcx.item_name(item)); + let name = codegen_fn_attrs.symbol_name.unwrap_or_else(|| self.tcx.item_name(item)); if self.tcx.sess.target.binary_format == BinaryFormat::Elf { let name = name.as_str(); diff --git a/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs b/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs index 7d2fc0995aa0b..4de7814c8c757 100644 --- a/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs +++ b/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs @@ -35,14 +35,10 @@ pub struct CodegenFnAttrs { pub inline: InlineAttr, /// Parsed representation of the `#[optimize]` attribute pub optimize: OptimizeAttr, - /// The `#[export_name = "..."]` attribute, indicating a custom symbol a - /// function should be exported under - pub export_name: Option, - /// The `#[link_name = "..."]` attribute, indicating a custom symbol an - /// imported function should be imported as. Note that `export_name` - /// probably isn't set when this is set, this is for foreign items while - /// `#[export_name]` is for Rust-defined functions. - pub link_name: Option, + /// The name this function will be imported/exported under. This can be set + /// using the `#[export_name = "..."]` or `#[link_name = "..."]` attribute + /// depending on if this is a function definition or foreign function. + pub symbol_name: Option, /// The `#[link_ordinal = "..."]` attribute, indicating an ordinal an /// imported function has in the dynamic library. Note that this must not /// be set when `link_name` is set. This is for foreign items with the @@ -167,8 +163,7 @@ impl CodegenFnAttrs { flags: CodegenFnAttrFlags::empty(), inline: InlineAttr::None, optimize: OptimizeAttr::Default, - export_name: None, - link_name: None, + symbol_name: None, link_ordinal: None, target_features: vec![], safe_target_features: false, @@ -196,7 +191,7 @@ impl CodegenFnAttrs { self.flags.contains(CodegenFnAttrFlags::NO_MANGLE) || self.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL) - || self.export_name.is_some() + || self.symbol_name.is_some() || match self.linkage { // These are private, so make sure we don't try to consider // them external. diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index f2d5b13cbc88f..128ae8549f7cb 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -929,7 +929,10 @@ impl<'tcx> TerminatorKind<'tcx> { } Yield { value, resume_arg, .. } => write!(fmt, "{resume_arg:?} = yield({value:?})"), Unreachable => write!(fmt, "unreachable"), - Drop { place, .. } => write!(fmt, "drop({place:?})"), + Drop { place, async_fut: None, .. } => write!(fmt, "drop({place:?})"), + Drop { place, async_fut: Some(async_fut), .. } => { + write!(fmt, "async drop({place:?}; poll={async_fut:?})") + } Call { func, args, destination, .. } => { write!(fmt, "{destination:?} = ")?; write!(fmt, "{func:?}(")?; diff --git a/compiler/rustc_middle/src/mir/visit.rs b/compiler/rustc_middle/src/mir/visit.rs index 42a68b29ec754..904d78d69b61c 100644 --- a/compiler/rustc_middle/src/mir/visit.rs +++ b/compiler/rustc_middle/src/mir/visit.rs @@ -531,13 +531,20 @@ macro_rules! make_mir_visitor { unwind: _, replace: _, drop: _, - async_fut: _, + async_fut, } => { self.visit_place( place, PlaceContext::MutatingUse(MutatingUseContext::Drop), location ); + if let Some(async_fut) = async_fut { + self.visit_local( + $(&$mutability)? *async_fut, + PlaceContext::MutatingUse(MutatingUseContext::Borrow), + location + ); + } } TerminatorKind::Call { diff --git a/compiler/rustc_middle/src/query/on_disk_cache.rs b/compiler/rustc_middle/src/query/on_disk_cache.rs index a7ac34428986e..546791135ba61 100644 --- a/compiler/rustc_middle/src/query/on_disk_cache.rs +++ b/compiler/rustc_middle/src/query/on_disk_cache.rs @@ -645,34 +645,29 @@ impl<'a, 'tcx> SpanDecoder for CacheDecoder<'a, 'tcx> { let parent = Option::::decode(self); let tag: u8 = Decodable::decode(self); - if tag == TAG_PARTIAL_SPAN { - return Span::new(BytePos(0), BytePos(0), ctxt, parent); - } else if tag == TAG_RELATIVE_SPAN { - let dlo = u32::decode(self); - let dto = u32::decode(self); - - let enclosing = self.tcx.source_span_untracked(parent.unwrap()).data_untracked(); - let span = Span::new( - enclosing.lo + BytePos::from_u32(dlo), - enclosing.lo + BytePos::from_u32(dto), - ctxt, - parent, - ); - - return span; - } else { - debug_assert_eq!(tag, TAG_FULL_SPAN); - } - - let file_lo_index = SourceFileIndex::decode(self); - let line_lo = usize::decode(self); - let col_lo = RelativeBytePos::decode(self); - let len = BytePos::decode(self); - - let file_lo = self.file_index_to_file(file_lo_index); - let lo = file_lo.lines()[line_lo - 1] + col_lo; - let lo = file_lo.absolute_position(lo); - let hi = lo + len; + let (lo, hi) = match tag { + TAG_PARTIAL_SPAN => (BytePos(0), BytePos(0)), + TAG_RELATIVE_SPAN => { + let dlo = u32::decode(self); + let dto = u32::decode(self); + + let enclosing = self.tcx.source_span_untracked(parent.unwrap()).data_untracked(); + (enclosing.lo + BytePos::from_u32(dlo), enclosing.lo + BytePos::from_u32(dto)) + } + TAG_FULL_SPAN => { + let file_lo_index = SourceFileIndex::decode(self); + let line_lo = usize::decode(self); + let col_lo = RelativeBytePos::decode(self); + let len = BytePos::decode(self); + + let file_lo = self.file_index_to_file(file_lo_index); + let lo = file_lo.lines()[line_lo - 1] + col_lo; + let lo = file_lo.absolute_position(lo); + let hi = lo + len; + (lo, hi) + } + _ => unreachable!(), + }; Span::new(lo, hi, ctxt, parent) } diff --git a/compiler/rustc_next_trait_solver/src/canonicalizer.rs b/compiler/rustc_next_trait_solver/src/canonicalizer.rs index 1bc35e599c706..3e1f48610ffc0 100644 --- a/compiler/rustc_next_trait_solver/src/canonicalizer.rs +++ b/compiler/rustc_next_trait_solver/src/canonicalizer.rs @@ -27,7 +27,7 @@ enum CanonicalizeInputKind { ParamEnv, /// When canonicalizing predicates, we don't keep `'static`. If we're /// currently outside of the trait solver and canonicalize the root goal - /// during HIR typeck, we replace each occurance of a region with a + /// during HIR typeck, we replace each occurrence of a region with a /// unique region variable. See the comment on `InferCtxt::in_hir_typeck` /// for more details. Predicate { is_hir_typeck_root_goal: bool }, diff --git a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs index 04ede365a2149..891ecab041a33 100644 --- a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs +++ b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs @@ -6,8 +6,8 @@ use rustc_type_ir::inherent::*; use rustc_type_ir::lang_items::TraitSolverLangItem; use rustc_type_ir::solve::{CanonicalResponse, SizedTraitKind}; use rustc_type_ir::{ - self as ty, Interner, Movability, TraitPredicate, TraitRef, TypeVisitableExt as _, TypingMode, - Upcast as _, elaborate, + self as ty, Interner, Movability, PredicatePolarity, TraitPredicate, TraitRef, + TypeVisitableExt as _, TypingMode, Upcast as _, elaborate, }; use tracing::{debug, instrument, trace}; @@ -133,19 +133,26 @@ where cx: I, clause_def_id: I::DefId, goal_def_id: I::DefId, + polarity: PredicatePolarity, ) -> bool { clause_def_id == goal_def_id // PERF(sized-hierarchy): Sizedness supertraits aren't elaborated to improve perf, so // check for a `MetaSized` supertrait being matched against a `Sized` assumption. // // `PointeeSized` bounds are syntactic sugar for a lack of bounds so don't need this. - || (cx.is_lang_item(clause_def_id, TraitSolverLangItem::Sized) + || (polarity == PredicatePolarity::Positive + && cx.is_lang_item(clause_def_id, TraitSolverLangItem::Sized) && cx.is_lang_item(goal_def_id, TraitSolverLangItem::MetaSized)) } if let Some(trait_clause) = assumption.as_trait_clause() && trait_clause.polarity() == goal.predicate.polarity - && trait_def_id_matches(ecx.cx(), trait_clause.def_id(), goal.predicate.def_id()) + && trait_def_id_matches( + ecx.cx(), + trait_clause.def_id(), + goal.predicate.def_id(), + goal.predicate.polarity, + ) && DeepRejectCtxt::relate_rigid_rigid(ecx.cx()).args_may_unify( goal.predicate.trait_ref.args, trait_clause.skip_binder().trait_ref.args, @@ -168,6 +175,8 @@ where // PERF(sized-hierarchy): Sizedness supertraits aren't elaborated to improve perf, so // check for a `Sized` subtrait when looking for `MetaSized`. `PointeeSized` bounds // are syntactic sugar for a lack of bounds so don't need this. + // We don't need to check polarity, `fast_reject_assumption` already rejected non-`Positive` + // polarity `Sized` assumptions as matching non-`Positive` `MetaSized` goals. if ecx.cx().is_lang_item(goal.predicate.def_id(), TraitSolverLangItem::MetaSized) && ecx.cx().is_lang_item(trait_clause.def_id(), TraitSolverLangItem::Sized) { diff --git a/compiler/rustc_parse/messages.ftl b/compiler/rustc_parse/messages.ftl index 9e0075c21b9ed..a107a682184ce 100644 --- a/compiler/rustc_parse/messages.ftl +++ b/compiler/rustc_parse/messages.ftl @@ -748,9 +748,6 @@ parse_parentheses_with_struct_fields = invalid `struct` delimiters or `fn` call .suggestion_braces_for_struct = if `{$type}` is a struct, use braces as delimiters .suggestion_no_fields_for_fn = if `{$type}` is a function, use the arguments directly -parse_parenthesized_lifetime = parenthesized lifetime bounds are not supported -parse_parenthesized_lifetime_suggestion = remove the parentheses - parse_path_double_colon = path separator must be a double colon .suggestion = use a double colon instead diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index a105dd1909e93..2c046329e33b4 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -3163,27 +3163,6 @@ pub(crate) struct ModifierLifetime { pub modifier: &'static str, } -#[derive(Subdiagnostic)] -#[multipart_suggestion( - parse_parenthesized_lifetime_suggestion, - applicability = "machine-applicable" -)] -pub(crate) struct RemoveParens { - #[suggestion_part(code = "")] - pub lo: Span, - #[suggestion_part(code = "")] - pub hi: Span, -} - -#[derive(Diagnostic)] -#[diag(parse_parenthesized_lifetime)] -pub(crate) struct ParenthesizedLifetime { - #[primary_span] - pub span: Span, - #[subdiagnostic] - pub sugg: RemoveParens, -} - #[derive(Diagnostic)] #[diag(parse_underscore_literal_suffix)] pub(crate) struct UnderscoreLiteralSuffix { diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index 85af5a615aef2..7c7e7e50b2765 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -49,6 +49,7 @@ pub(crate) fn lex_token_trees<'psess, 'src>( mut src: &'src str, mut start_pos: BytePos, override_span: Option, + frontmatter_allowed: FrontmatterAllowed, ) -> Result>> { // Skip `#!`, if present. if let Some(shebang_len) = rustc_lexer::strip_shebang(src) { @@ -56,7 +57,7 @@ pub(crate) fn lex_token_trees<'psess, 'src>( start_pos = start_pos + BytePos::from_usize(shebang_len); } - let cursor = Cursor::new(src, FrontmatterAllowed::Yes); + let cursor = Cursor::new(src, frontmatter_allowed); let mut lexer = Lexer { psess, start_pos, diff --git a/compiler/rustc_parse/src/lib.rs b/compiler/rustc_parse/src/lib.rs index 2050c5f960877..adad575187136 100644 --- a/compiler/rustc_parse/src/lib.rs +++ b/compiler/rustc_parse/src/lib.rs @@ -20,6 +20,7 @@ use rustc_ast::tokenstream::TokenStream; use rustc_ast::{AttrItem, Attribute, MetaItemInner, token}; use rustc_ast_pretty::pprust; use rustc_errors::{Diag, EmissionGuarantee, FatalError, PResult, pluralize}; +use rustc_lexer::FrontmatterAllowed; use rustc_session::parse::ParseSess; use rustc_span::source_map::SourceMap; use rustc_span::{FileName, SourceFile, Span}; @@ -146,7 +147,7 @@ fn new_parser_from_source_file( source_file: Arc, ) -> Result, Vec>> { let end_pos = source_file.end_position(); - let stream = source_file_to_stream(psess, source_file, None)?; + let stream = source_file_to_stream(psess, source_file, None, FrontmatterAllowed::Yes)?; let mut parser = Parser::new(psess, stream, None); if parser.token == token::Eof { parser.token.span = Span::new(end_pos, end_pos, parser.token.span.ctxt(), None); @@ -161,7 +162,9 @@ pub fn source_str_to_stream( override_span: Option, ) -> Result>> { let source_file = psess.source_map().new_source_file(name, source); - source_file_to_stream(psess, source_file, override_span) + // used mainly for `proc_macro` and the likes, not for our parsing purposes, so don't parse + // frontmatters as frontmatters. + source_file_to_stream(psess, source_file, override_span, FrontmatterAllowed::No) } /// Given a source file, produces a sequence of token trees. Returns any buffered errors from @@ -170,6 +173,7 @@ fn source_file_to_stream<'psess>( psess: &'psess ParseSess, source_file: Arc, override_span: Option, + frontmatter_allowed: FrontmatterAllowed, ) -> Result>> { let src = source_file.src.as_ref().unwrap_or_else(|| { psess.dcx().bug(format!( @@ -178,7 +182,13 @@ fn source_file_to_stream<'psess>( )); }); - lexer::lex_token_trees(psess, src.as_str(), source_file.start_pos, override_span) + lexer::lex_token_trees( + psess, + src.as_str(), + source_file.start_pos, + override_span, + frontmatter_allowed, + ) } /// Runs the given subparser `f` on the tokens of the given `attr`'s item. diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index d0604f763171b..ea8cd3754a06f 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -2397,12 +2397,12 @@ impl<'a> Parser<'a> { let before = self.prev_token; let binder = if self.check_keyword(exp!(For)) { let lo = self.token.span; - let (lifetime_defs, _) = self.parse_late_bound_lifetime_defs()?; + let (bound_vars, _) = self.parse_higher_ranked_binder()?; let span = lo.to(self.prev_token.span); self.psess.gated_spans.gate(sym::closure_lifetime_binder, span); - ClosureBinder::For { span, generic_params: lifetime_defs } + ClosureBinder::For { span, generic_params: bound_vars } } else { ClosureBinder::NotPresent }; diff --git a/compiler/rustc_parse/src/parser/generics.rs b/compiler/rustc_parse/src/parser/generics.rs index 4a8530a2b3869..eb684c3a62f9f 100644 --- a/compiler/rustc_parse/src/parser/generics.rs +++ b/compiler/rustc_parse/src/parser/generics.rs @@ -172,8 +172,11 @@ impl<'a> Parser<'a> { }) } - /// Parses a (possibly empty) list of lifetime and type parameters, possibly including - /// a trailing comma and erroneous trailing attributes. + /// Parse a (possibly empty) list of generic (lifetime, type, const) parameters. + /// + /// ```ebnf + /// GenericParams = (GenericParam ("," GenericParam)* ","?)? + /// ``` pub(super) fn parse_generic_params(&mut self) -> PResult<'a, ThinVec> { let mut params = ThinVec::new(); let mut done = false; @@ -520,7 +523,7 @@ impl<'a> Parser<'a> { // * `for<'a> Trait1<'a>: Trait2<'a /* ok */>` // * `(for<'a> Trait1<'a>): Trait2<'a /* not ok */>` // * `for<'a> for<'b> Trait1<'a, 'b>: Trait2<'a /* ok */, 'b /* not ok */>` - let (lifetime_defs, _) = self.parse_late_bound_lifetime_defs()?; + let (bound_vars, _) = self.parse_higher_ranked_binder()?; // Parse type with mandatory colon and (possibly empty) bounds, // or with mandatory equality sign and the second type. @@ -528,7 +531,7 @@ impl<'a> Parser<'a> { if self.eat(exp!(Colon)) { let bounds = self.parse_generic_bounds()?; Ok(ast::WherePredicateKind::BoundPredicate(ast::WhereBoundPredicate { - bound_generic_params: lifetime_defs, + bound_generic_params: bound_vars, bounded_ty: ty, bounds, })) diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs index 290f0a440aff0..899a43955ab77 100644 --- a/compiler/rustc_parse/src/parser/ty.rs +++ b/compiler/rustc_parse/src/parser/ty.rs @@ -308,11 +308,11 @@ impl<'a> Parser<'a> { // Function pointer type or bound list (trait object type) starting with a poly-trait. // `for<'lt> [unsafe] [extern "ABI"] fn (&'lt S) -> T` // `for<'lt> Trait1<'lt> + Trait2 + 'a` - let (lifetime_defs, _) = self.parse_late_bound_lifetime_defs()?; + let (bound_vars, _) = self.parse_higher_ranked_binder()?; if self.check_fn_front_matter(false, Case::Sensitive) { self.parse_ty_fn_ptr( lo, - lifetime_defs, + bound_vars, Some(self.prev_token.span.shrink_to_lo()), recover_return_sign, )? @@ -326,7 +326,7 @@ impl<'a> Parser<'a> { let path = self.parse_path(PathStyle::Type)?; let parse_plus = allow_plus == AllowPlus::Yes && self.check_plus(); let kind = self.parse_remaining_bounds_path( - lifetime_defs, + bound_vars, path, lo, parse_plus, @@ -359,7 +359,7 @@ impl<'a> Parser<'a> { let path = self.parse_path(PathStyle::Type)?; let parse_plus = allow_plus == AllowPlus::Yes && self.check_plus(); self.parse_remaining_bounds_path( - lifetime_defs, + bound_vars, path, lo, parse_plus, @@ -443,7 +443,7 @@ impl<'a> Parser<'a> { let ty = ts.into_iter().next().unwrap(); let maybe_bounds = allow_plus == AllowPlus::Yes && self.token.is_like_plus(); match ty.kind { - // `(TY_BOUND_NOPAREN) + BOUND + ...`. + // `"(" BareTraitBound ")" "+" Bound "+" ...`. TyKind::Path(None, path) if maybe_bounds => self.parse_remaining_bounds_path( ThinVec::new(), path, @@ -853,10 +853,13 @@ impl<'a> Parser<'a> { Ok(TyKind::ImplTrait(ast::DUMMY_NODE_ID, bounds)) } - fn parse_precise_capturing_args( - &mut self, - ) -> PResult<'a, (ThinVec, Span)> { - let lo = self.token.span; + /// Parse a use-bound aka precise capturing list. + /// + /// ```ebnf + /// UseBound = "use" "<" (PreciseCapture ("," PreciseCapture)* ","?)? ">" + /// PreciseCapture = "Self" | Ident | Lifetime + /// ``` + fn parse_use_bound(&mut self, lo: Span, parens: ast::Parens) -> PResult<'a, GenericBound> { self.expect_lt()?; let (args, _, _) = self.parse_seq_to_before_tokens( &[exp!(Gt)], @@ -882,7 +885,13 @@ impl<'a> Parser<'a> { }, )?; self.expect_gt()?; - Ok((args, lo.to(self.prev_token.span))) + + if let ast::Parens::Yes = parens { + self.expect(exp!(CloseParen))?; + self.report_parenthesized_bound(lo, self.prev_token.span, "precise capturing lists"); + } + + Ok(GenericBound::Use(args, lo.to(self.prev_token.span))) } /// Is a `dyn B0 + ... + Bn` type allowed here? @@ -940,9 +949,10 @@ impl<'a> Parser<'a> { self.parse_generic_bounds_common(AllowPlus::Yes) } - /// Parses bounds of a type parameter `BOUND + BOUND + ...`, possibly with trailing `+`. + /// Parse generic bounds. /// - /// See `parse_generic_bound` for the `BOUND` grammar. + /// Only if `allow_plus` this parses a `+`-separated list of bounds (trailing `+` is admitted). + /// Otherwise, this only parses a single bound or none. fn parse_generic_bounds_common(&mut self, allow_plus: AllowPlus) -> PResult<'a, GenericBounds> { let mut bounds = Vec::new(); @@ -988,48 +998,56 @@ impl<'a> Parser<'a> { || self.check_keyword(exp!(Use)) } - /// Parses a bound according to the grammar: + /// Parse a bound. + /// /// ```ebnf - /// BOUND = TY_BOUND | LT_BOUND + /// Bound = LifetimeBound | UseBound | TraitBound /// ``` fn parse_generic_bound(&mut self) -> PResult<'a, GenericBound> { - let lo = self.token.span; let leading_token = self.prev_token; + let lo = self.token.span; + + // We only admit parenthesized *trait* bounds. However, we want to gracefully recover from + // other kinds of parenthesized bounds, so parse the opening parenthesis *here*. + // + // In the future we might want to lift this syntactic restriction and + // introduce "`GenericBound::Paren(Box)`". let parens = if self.eat(exp!(OpenParen)) { ast::Parens::Yes } else { ast::Parens::No }; - let bound = if self.token.is_lifetime() { - self.parse_generic_lt_bound(lo, parens)? + if self.token.is_lifetime() { + self.parse_lifetime_bound(lo, parens) } else if self.eat_keyword(exp!(Use)) { - // parse precise captures, if any. This is `use<'lt, 'lt, P, P>`; a list of - // lifetimes and ident params (including SelfUpper). These are validated later - // for order, duplication, and whether they actually reference params. - let use_span = self.prev_token.span; - let (args, args_span) = self.parse_precise_capturing_args()?; - GenericBound::Use(args, use_span.to(args_span)) + self.parse_use_bound(lo, parens) } else { - self.parse_generic_ty_bound(lo, parens, &leading_token)? - }; - - Ok(bound) + self.parse_trait_bound(lo, parens, &leading_token) + } } - /// Parses a lifetime ("outlives") bound, e.g. `'a`, according to: + /// Parse a lifetime-bound aka outlives-bound. + /// /// ```ebnf - /// LT_BOUND = LIFETIME + /// LifetimeBound = Lifetime /// ``` - fn parse_generic_lt_bound( - &mut self, - lo: Span, - parens: ast::Parens, - ) -> PResult<'a, GenericBound> { + fn parse_lifetime_bound(&mut self, lo: Span, parens: ast::Parens) -> PResult<'a, GenericBound> { let lt = self.expect_lifetime(); - let bound = GenericBound::Outlives(lt); + if let ast::Parens::Yes = parens { - // FIXME(Centril): Consider not erroring here and accepting `('lt)` instead, - // possibly introducing `GenericBound::Paren(Box)`? - self.recover_paren_lifetime(lo)?; + self.expect(exp!(CloseParen))?; + self.report_parenthesized_bound(lo, self.prev_token.span, "lifetime bounds"); } - Ok(bound) + + Ok(GenericBound::Outlives(lt)) + } + + fn report_parenthesized_bound(&self, lo: Span, hi: Span, kind: &str) -> ErrorGuaranteed { + let mut diag = + self.dcx().struct_span_err(lo.to(hi), format!("{kind} may not be parenthesized")); + diag.multipart_suggestion( + "remove the parentheses", + vec![(lo, String::new()), (hi, String::new())], + Applicability::MachineApplicable, + ); + diag.emit() } /// Emits an error if any trait bound modifiers were present. @@ -1074,27 +1092,17 @@ impl<'a> Parser<'a> { unreachable!("lifetime bound intercepted in `parse_generic_ty_bound` but no modifiers?") } - /// Recover on `('lifetime)` with `(` already eaten. - fn recover_paren_lifetime(&mut self, lo: Span) -> PResult<'a, ()> { - self.expect(exp!(CloseParen))?; - let span = lo.to(self.prev_token.span); - let sugg = errors::RemoveParens { lo, hi: self.prev_token.span }; - - self.dcx().emit_err(errors::ParenthesizedLifetime { span, sugg }); - Ok(()) - } - /// Parses the modifiers that may precede a trait in a bound, e.g. `?Trait` or `[const] Trait`. /// /// If no modifiers are present, this does not consume any tokens. /// /// ```ebnf - /// CONSTNESS = [["["] "const" ["]"]] - /// ASYNCNESS = ["async"] - /// POLARITY = ["?" | "!"] + /// Constness = ("const" | "[" "const" "]")? + /// Asyncness = "async"? + /// Polarity = ("?" | "!")? /// ``` /// - /// See `parse_generic_ty_bound` for the complete grammar of trait bound modifiers. + /// See `parse_trait_bound` for more context. fn parse_trait_bound_modifiers(&mut self) -> PResult<'a, TraitBoundModifiers> { let modifier_lo = self.token.span; let constness = self.parse_bound_constness()?; @@ -1187,20 +1195,21 @@ impl<'a> Parser<'a> { }) } - /// Parses a type bound according to: + /// Parse a trait bound. + /// /// ```ebnf - /// TY_BOUND = TY_BOUND_NOPAREN | (TY_BOUND_NOPAREN) - /// TY_BOUND_NOPAREN = [for CONSTNESS ASYNCNESS | POLARITY] SIMPLE_PATH + /// TraitBound = BareTraitBound | "(" BareTraitBound ")" + /// BareTraitBound = + /// (HigherRankedBinder Constness Asyncness | Polarity) + /// TypePath /// ``` - /// - /// For example, this grammar accepts `for<'a: 'b> [const] ?m::Trait<'a>`. - fn parse_generic_ty_bound( + fn parse_trait_bound( &mut self, lo: Span, parens: ast::Parens, leading_token: &Token, ) -> PResult<'a, GenericBound> { - let (mut lifetime_defs, binder_span) = self.parse_late_bound_lifetime_defs()?; + let (mut bound_vars, binder_span) = self.parse_higher_ranked_binder()?; let modifiers_lo = self.token.span; let modifiers = self.parse_trait_bound_modifiers()?; @@ -1223,11 +1232,11 @@ impl<'a> Parser<'a> { // e.g. `T: for<'a> 'a` or `T: [const] 'a`. if self.token.is_lifetime() { let _: ErrorGuaranteed = self.error_lt_bound_with_modifiers(modifiers, binder_span); - return self.parse_generic_lt_bound(lo, parens); + return self.parse_lifetime_bound(lo, parens); } - if let (more_lifetime_defs, Some(binder_span)) = self.parse_late_bound_lifetime_defs()? { - lifetime_defs.extend(more_lifetime_defs); + if let (more_bound_vars, Some(binder_span)) = self.parse_higher_ranked_binder()? { + bound_vars.extend(more_bound_vars); self.dcx().emit_err(errors::BinderBeforeModifiers { binder_span, modifiers_span }); } @@ -1287,7 +1296,7 @@ impl<'a> Parser<'a> { }; if self.may_recover() && self.token == TokenKind::OpenParen { - self.recover_fn_trait_with_lifetime_params(&mut path, &mut lifetime_defs)?; + self.recover_fn_trait_with_lifetime_params(&mut path, &mut bound_vars)?; } if let ast::Parens::Yes = parens { @@ -1310,7 +1319,7 @@ impl<'a> Parser<'a> { } let poly_trait = - PolyTraitRef::new(lifetime_defs, path, modifiers, lo.to(self.prev_token.span), parens); + PolyTraitRef::new(bound_vars, path, modifiers, lo.to(self.prev_token.span), parens); Ok(GenericBound::Trait(poly_trait)) } @@ -1349,8 +1358,12 @@ impl<'a> Parser<'a> { } } - /// Optionally parses `for<$generic_params>`. - pub(super) fn parse_late_bound_lifetime_defs( + /// Parse an optional higher-ranked binder. + /// + /// ```ebnf + /// HigherRankedBinder = ("for" "<" GenericParams ">")? + /// ``` + pub(super) fn parse_higher_ranked_binder( &mut self, ) -> PResult<'a, (ThinVec, Option)> { if self.eat_keyword(exp!(For)) { diff --git a/compiler/rustc_resolve/messages.ftl b/compiler/rustc_resolve/messages.ftl index 05b5abc3dc674..47280a936779f 100644 --- a/compiler/rustc_resolve/messages.ftl +++ b/compiler/rustc_resolve/messages.ftl @@ -93,6 +93,9 @@ resolve_consider_adding_a_derive = resolve_consider_adding_macro_export = consider adding a `#[macro_export]` to the macro in the imported module +resolve_consider_marking_as_pub_crate = + in case you want to use the macro within this crate only, reduce the visibility to `pub(crate)` + resolve_consider_declaring_with_pub = consider declaring type or module `{$ident}` with `pub` diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index 1eb4e1199e622..214038040c951 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -474,6 +474,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> { root_span, root_id, vis, + vis_span: item.vis.span, }); self.r.indeterminate_imports.push(import); @@ -966,6 +967,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> { span: item.span, module_path: Vec::new(), vis, + vis_span: item.vis.span, }); if used { self.r.import_use_map.insert(import, Used::Other); @@ -1100,6 +1102,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> { span, module_path: Vec::new(), vis: Visibility::Restricted(CRATE_DEF_ID), + vis_span: item.vis.span, }) }; @@ -1270,6 +1273,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> { span, module_path: Vec::new(), vis, + vis_span: item.vis.span, }); self.r.import_use_map.insert(import, Used::Other); let import_binding = self.r.import(binding, import); diff --git a/compiler/rustc_resolve/src/errors.rs b/compiler/rustc_resolve/src/errors.rs index a1d62ba7a6834..63d6fa23a148d 100644 --- a/compiler/rustc_resolve/src/errors.rs +++ b/compiler/rustc_resolve/src/errors.rs @@ -775,6 +775,17 @@ pub(crate) struct ConsiderAddingMacroExport { pub(crate) span: Span, } +#[derive(Subdiagnostic)] +#[suggestion( + resolve_consider_marking_as_pub_crate, + code = "pub(crate)", + applicability = "maybe-incorrect" +)] +pub(crate) struct ConsiderMarkingAsPubCrate { + #[primary_span] + pub(crate) vis_span: Span, +} + #[derive(Subdiagnostic)] #[note(resolve_consider_marking_as_pub)] pub(crate) struct ConsiderMarkingAsPub { diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index 7c93fdb88ee44..d3790394d2a9a 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -30,7 +30,7 @@ use crate::diagnostics::{DiagMode, Suggestion, import_candidates}; use crate::errors::{ CannotBeReexportedCratePublic, CannotBeReexportedCratePublicNS, CannotBeReexportedPrivate, CannotBeReexportedPrivateNS, CannotDetermineImportResolution, CannotGlobImportAllCrates, - ConsiderAddingMacroExport, ConsiderMarkingAsPub, + ConsiderAddingMacroExport, ConsiderMarkingAsPub, ConsiderMarkingAsPubCrate, }; use crate::{ AmbiguityError, AmbiguityKind, BindingKey, CmResolver, Determinacy, Finalize, ImportSuggestion, @@ -184,6 +184,9 @@ pub(crate) struct ImportData<'ra> { /// |`use foo` | `ModuleOrUniformRoot::CurrentScope` | - | pub imported_module: Cell>>, pub vis: Visibility, + + /// Span of the visibility. + pub vis_span: Span, } /// All imports are unique and allocated on a same arena, @@ -866,7 +869,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { } ImportKind::Glob { .. } => { // FIXME: Use mutable resolver directly as a hack, this should be an output of - // specualtive resolution. + // speculative resolution. self.get_mut_unchecked().resolve_glob_import(import); return 0; } @@ -903,7 +906,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { // We need the `target`, `source` can be extracted. let imported_binding = this.import(binding, import); // FIXME: Use mutable resolver directly as a hack, this should be an output of - // specualtive resolution. + // speculative resolution. this.get_mut_unchecked().define_binding_local( parent, target, @@ -917,7 +920,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { if target.name != kw::Underscore { let key = BindingKey::new(target, ns); // FIXME: Use mutable resolver directly as a hack, this should be an output of - // specualtive resolution. + // speculative resolution. this.get_mut_unchecked().update_local_resolution( parent, key, @@ -1368,6 +1371,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { err.subdiagnostic( ConsiderAddingMacroExport { span: binding.span, }); + err.subdiagnostic( ConsiderMarkingAsPubCrate { + vis_span: import.vis_span, + }); } _ => { err.subdiagnostic( ConsiderMarkingAsPub { diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 5200f9340e115..679e663f88614 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -4270,7 +4270,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { if path.len() == 2 && let [segment] = prefix_path { - // Delay to check whether methond name is an associated function or not + // Delay to check whether method name is an associated function or not // ``` // let foo = Foo {}; // foo::bar(); // possibly suggest to foo.bar(); diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index ca9c124fca63c..04ff76e6bd6be 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -781,7 +781,10 @@ impl<'ra> std::ops::Deref for Module<'ra> { impl<'ra> fmt::Debug for Module<'ra> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{:?}", self.res()) + match self.kind { + ModuleKind::Block => write!(f, "block"), + ModuleKind::Def(..) => write!(f, "{:?}", self.res()), + } } } diff --git a/compiler/rustc_session/messages.ftl b/compiler/rustc_session/messages.ftl index 528c52eace7cb..80754964c43d7 100644 --- a/compiler/rustc_session/messages.ftl +++ b/compiler/rustc_session/messages.ftl @@ -49,6 +49,8 @@ session_hexadecimal_float_literal_not_supported = hexadecimal float literal is n session_incompatible_linker_flavor = linker flavor `{$flavor}` is incompatible with the current target .note = compatible flavors are: {$compatible_list} +session_indirect_branch_cs_prefix_requires_x86_or_x86_64 = `-Zindirect-branch-cs-prefix` is only supported on x86 and x86_64 + session_instrumentation_not_supported = {$us} instrumentation is not supported for this target session_int_literal_too_large = integer literal is too large diff --git a/compiler/rustc_session/src/errors.rs b/compiler/rustc_session/src/errors.rs index bf95014843d23..9471807df0188 100644 --- a/compiler/rustc_session/src/errors.rs +++ b/compiler/rustc_session/src/errors.rs @@ -471,6 +471,10 @@ pub(crate) struct FunctionReturnRequiresX86OrX8664; #[diag(session_function_return_thunk_extern_requires_non_large_code_model)] pub(crate) struct FunctionReturnThunkExternRequiresNonLargeCodeModel; +#[derive(Diagnostic)] +#[diag(session_indirect_branch_cs_prefix_requires_x86_or_x86_64)] +pub(crate) struct IndirectBranchCsPrefixRequiresX86OrX8664; + #[derive(Diagnostic)] #[diag(session_unsupported_regparm)] pub(crate) struct UnsupportedRegparm { diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 0e112edc73316..6d5be2d92cd2a 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -2295,6 +2295,8 @@ options! { - hashes of green query instances - hash collisions of query keys - hash collisions when creating dep-nodes"), + indirect_branch_cs_prefix: bool = (false, parse_bool, [TRACKED TARGET_MODIFIER], + "add `cs` prefix to `call` and `jmp` to indirect thunks (default: no)"), inline_llvm: bool = (true, parse_bool, [TRACKED], "enable LLVM inlining (default: yes)"), inline_mir: Option = (None, parse_opt_bool, [TRACKED], diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index c6956cf5f23b5..c8f4b511a7ef3 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -1368,6 +1368,12 @@ fn validate_commandline_args_with_session_available(sess: &Session) { } } + if sess.opts.unstable_opts.indirect_branch_cs_prefix { + if sess.target.arch != "x86" && sess.target.arch != "x86_64" { + sess.dcx().emit_err(errors::IndirectBranchCsPrefixRequiresX86OrX8664); + } + } + if let Some(regparm) = sess.opts.unstable_opts.regparm { if regparm > 3 { sess.dcx().emit_err(errors::UnsupportedRegparm { regparm }); diff --git a/compiler/rustc_span/src/caching_source_map_view.rs b/compiler/rustc_span/src/caching_source_map_view.rs index a887b50ec1ebe..41cfaa3ee34e5 100644 --- a/compiler/rustc_span/src/caching_source_map_view.rs +++ b/compiler/rustc_span/src/caching_source_map_view.rs @@ -123,27 +123,25 @@ impl<'sm> CachingSourceMapView<'sm> { if lo_cache_idx != -1 && hi_cache_idx != -1 { // Cache hit for span lo and hi. Check if they belong to the same file. - let result = { - let lo = &self.line_cache[lo_cache_idx as usize]; - let hi = &self.line_cache[hi_cache_idx as usize]; + let lo_file_index = self.line_cache[lo_cache_idx as usize].file_index; + let hi_file_index = self.line_cache[hi_cache_idx as usize].file_index; - if lo.file_index != hi.file_index { - return None; - } - - ( - lo.file.stable_id, - lo.line_number, - span_data.lo - lo.line.start, - hi.line_number, - span_data.hi - hi.line.start, - ) - }; + if lo_file_index != hi_file_index { + return None; + } self.line_cache[lo_cache_idx as usize].touch(self.time_stamp); self.line_cache[hi_cache_idx as usize].touch(self.time_stamp); - return Some(result); + let lo = &self.line_cache[lo_cache_idx as usize]; + let hi = &self.line_cache[hi_cache_idx as usize]; + return Some(( + lo.file.stable_id, + lo.line_number, + span_data.lo - lo.line.start, + hi.line_number, + span_data.hi - hi.line.start, + )); } // No cache hit or cache hit for only one of span lo and hi. diff --git a/compiler/rustc_symbol_mangling/src/lib.rs b/compiler/rustc_symbol_mangling/src/lib.rs index f3c96f641902e..d97ee95652530 100644 --- a/compiler/rustc_symbol_mangling/src/lib.rs +++ b/compiler/rustc_symbol_mangling/src/lib.rs @@ -193,29 +193,20 @@ fn compute_symbol_name<'tcx>( // defining crate. // Weak lang items automatically get #[rustc_std_internal_symbol] // applied by the code computing the CodegenFnAttrs. - // We are mangling all #[rustc_std_internal_symbol] items that don't - // also have #[no_mangle] as a combination of the rustc version and the - // unmangled linkage name. This is to ensure that if we link against a - // staticlib compiled by a different rustc version, we don't get symbol - // conflicts or even UB due to a different implementation/ABI. Rust - // staticlibs currently export all symbols, including those that are - // hidden in cdylibs. + // We are mangling all #[rustc_std_internal_symbol] items as a + // combination of the rustc version and the unmangled linkage name. + // This is to ensure that if we link against a staticlib compiled by a + // different rustc version, we don't get symbol conflicts or even UB + // due to a different implementation/ABI. Rust staticlibs currently + // export all symbols, including those that are hidden in cdylibs. // We are using the v0 symbol mangling scheme here as we need to be // consistent across all crates and in some contexts the legacy symbol // mangling scheme can't be used. For example both the GCC backend and // Rust-for-Linux don't support some of the characters used by the // legacy symbol mangling scheme. - let name = if tcx.is_foreign_item(def_id) { - if let Some(name) = attrs.link_name { name } else { tcx.item_name(def_id) } - } else { - if let Some(name) = attrs.export_name { name } else { tcx.item_name(def_id) } - }; + let name = if let Some(name) = attrs.symbol_name { name } else { tcx.item_name(def_id) }; - if attrs.flags.contains(CodegenFnAttrFlags::NO_MANGLE) { - return name.to_string(); - } else { - return v0::mangle_internal_symbol(tcx, name.as_str()); - } + return v0::mangle_internal_symbol(tcx, name.as_str()); } let wasm_import_module_exception_force_mangling = { @@ -240,23 +231,16 @@ fn compute_symbol_name<'tcx>( && tcx.wasm_import_module_map(LOCAL_CRATE).contains_key(&def_id.into()) }; - if let Some(name) = attrs.link_name - && !wasm_import_module_exception_force_mangling - { - // Use provided name - return name.to_string(); - } - - if let Some(name) = attrs.export_name { - // Use provided name - return name.to_string(); - } + if !wasm_import_module_exception_force_mangling { + if let Some(name) = attrs.symbol_name { + // Use provided name + return name.to_string(); + } - if attrs.flags.contains(CodegenFnAttrFlags::NO_MANGLE) - && !wasm_import_module_exception_force_mangling - { - // Don't mangle - return tcx.item_name(def_id).to_string(); + if attrs.flags.contains(CodegenFnAttrFlags::NO_MANGLE) { + // Don't mangle + return tcx.item_name(def_id).to_string(); + } } // If we're dealing with an instance of a function that's inlined from diff --git a/compiler/rustc_trait_selection/src/traits/util.rs b/compiler/rustc_trait_selection/src/traits/util.rs index 83c0969762f4a..335942d5bcc54 100644 --- a/compiler/rustc_trait_selection/src/traits/util.rs +++ b/compiler/rustc_trait_selection/src/traits/util.rs @@ -9,8 +9,8 @@ pub use rustc_infer::traits::util::*; use rustc_middle::bug; use rustc_middle::ty::fast_reject::DeepRejectCtxt; use rustc_middle::ty::{ - self, PolyTraitPredicate, SizedTraitKind, TraitPredicate, TraitRef, Ty, TyCtxt, TypeFoldable, - TypeFolder, TypeSuperFoldable, TypeVisitableExt, + self, PolyTraitPredicate, PredicatePolarity, SizedTraitKind, TraitPredicate, TraitRef, Ty, + TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt, }; pub use rustc_next_trait_solver::placeholder::BoundVarReplacer; use rustc_span::Span; @@ -427,7 +427,9 @@ pub(crate) fn lazily_elaborate_sizedness_candidate<'tcx>( return candidate; } - if obligation.predicate.polarity() != candidate.polarity() { + if obligation.predicate.polarity() != PredicatePolarity::Positive + || candidate.polarity() != PredicatePolarity::Positive + { return candidate; } diff --git a/library/core/src/num/dec2flt/mod.rs b/library/core/src/num/dec2flt/mod.rs index 1844cd9808268..3118a6e5ca62e 100644 --- a/library/core/src/num/dec2flt/mod.rs +++ b/library/core/src/num/dec2flt/mod.rs @@ -124,6 +124,8 @@ macro_rules! from_str_float_impl { /// * '2.5E-10' /// * '5.' /// * '.5', or, equivalently, '0.5' + /// * '7' + /// * '007' /// * 'inf', '-inf', '+infinity', 'NaN' /// /// Note that alphabetical characters are not case-sensitive. diff --git a/library/core/src/num/int_macros.rs b/library/core/src/num/int_macros.rs index bd2f7445612a7..dbcccdf497c2c 100644 --- a/library/core/src/num/int_macros.rs +++ b/library/core/src/num/int_macros.rs @@ -2494,8 +2494,7 @@ macro_rules! int_impl { /// /// # Examples /// - /// Please note that this example is shared between integer types. - /// Which explains why `i32` is used here. + /// Please note that this example is shared among integer types, which is why `i32` is used. /// /// ``` /// #![feature(bigint_helper_methods)] @@ -2525,8 +2524,7 @@ macro_rules! int_impl { /// /// # Examples /// - /// Please note that this example is shared between integer types. - /// Which explains why `i32` is used here. + /// Please note that this example is shared among integer types, which is why `i32` is used. /// /// ``` /// #![feature(bigint_helper_methods)] @@ -2563,8 +2561,7 @@ macro_rules! int_impl { /// /// # Examples /// - /// Please note that this example is shared between integer types. - /// Which explains why `i32` is used here. + /// Please note that this example is shared among integer types, which is why `i32` is used. /// /// ``` /// #![feature(bigint_helper_methods)] diff --git a/library/core/src/num/saturating.rs b/library/core/src/num/saturating.rs index c7040721b9353..365a82a57e0b9 100644 --- a/library/core/src/num/saturating.rs +++ b/library/core/src/num/saturating.rs @@ -729,8 +729,8 @@ macro_rules! saturating_int_impl { /// /// # Examples /// - /// Please note that this example is shared between integer types. - /// Which explains why `i16` is used here. + /// Please note that this example is shared among integer types, which is why `i16` + /// is used. /// /// ``` /// use std::num::Saturating; diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs index 0afad09bdc6b8..186c6f32cffaa 100644 --- a/library/core/src/num/uint_macros.rs +++ b/library/core/src/num/uint_macros.rs @@ -2115,8 +2115,7 @@ macro_rules! uint_impl { /// /// # Examples /// - /// Please note that this example is shared between integer types. - /// Which explains why `u8` is used here. + /// Please note that this example is shared among integer types, which is why `u8` is used. /// /// ``` /// assert_eq!(10u8.wrapping_mul(12), 120); @@ -2606,8 +2605,8 @@ macro_rules! uint_impl { /// /// # Examples /// - /// Please note that this example is shared between integer types. - /// Which explains why `u32` is used here. + /// Please note that this example is shared among integer types, which is why why `u32` + /// is used. /// /// ``` /// assert_eq!(5u32.overflowing_mul(2), (10, false)); @@ -2633,8 +2632,7 @@ macro_rules! uint_impl { /// /// # Examples /// - /// Please note that this example is shared between integer types. - /// Which explains why `u32` is used here. + /// Please note that this example is shared among integer types, which is why `u32` is used. /// /// ``` /// #![feature(bigint_helper_methods)] @@ -2664,8 +2662,7 @@ macro_rules! uint_impl { /// /// # Examples /// - /// Please note that this example is shared between integer types. - /// Which explains why `u32` is used here. + /// Please note that this example is shared among integer types, which is why `u32` is used. /// /// ``` /// #![feature(bigint_helper_methods)] diff --git a/library/core/src/num/wrapping.rs b/library/core/src/num/wrapping.rs index 9ccad4b6459cd..881fe615f800f 100644 --- a/library/core/src/num/wrapping.rs +++ b/library/core/src/num/wrapping.rs @@ -765,8 +765,8 @@ macro_rules! wrapping_int_impl { /// /// # Examples /// - /// Please note that this example is shared between integer types. - /// Which explains why `i16` is used here. + /// Please note that this example is shared among integer types, which is why `i16` + /// is used. /// /// Basic usage: /// diff --git a/library/core/src/unicode/mod.rs b/library/core/src/unicode/mod.rs index 49dbdeb1a6d1c..191fe7711f97a 100644 --- a/library/core/src/unicode/mod.rs +++ b/library/core/src/unicode/mod.rs @@ -1,5 +1,6 @@ +//! Unicode internals used in liballoc and libstd. Not public API. #![unstable(feature = "unicode_internals", issue = "none")] -#![allow(missing_docs)] +#![doc(hidden)] // for use in alloc, not re-exported in std. #[rustfmt::skip] @@ -31,5 +32,4 @@ mod unicode_data; /// /// The version numbering scheme is explained in /// [Unicode 11.0 or later, Section 3.1 Versions of the Unicode Standard](https://www.unicode.org/versions/Unicode11.0.0/ch03.pdf#page=4). -#[stable(feature = "unicode_version", since = "1.45.0")] pub const UNICODE_VERSION: (u8, u8, u8) = unicode_data::UNICODE_VERSION; diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs index 8d7edc732aff3..1214490caadf3 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -137,7 +137,7 @@ impl OsString { #[stable(feature = "rust1", since = "1.0.0")] #[must_use] #[inline] - #[rustc_const_unstable(feature = "const_pathbuf_osstring_new", issue = "141520")] + #[rustc_const_stable(feature = "const_pathbuf_osstring_new", since = "CURRENT_RUSTC_VERSION")] pub const fn new() -> OsString { OsString { inner: Buf::from_string(String::new()) } } diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index d4a584f4d14ff..1ed4f2f9f0c66 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -3156,6 +3156,25 @@ pub fn set_permissions>(path: P, perm: Permissions) -> io::Result fs_imp::set_permissions(path.as_ref(), perm.0) } +/// Set the permissions of a file, unless it is a symlink. +/// +/// Note that the non-final path elements are allowed to be symlinks. +/// +/// # Platform-specific behavior +/// +/// Currently unimplemented on Windows. +/// +/// On Unix platforms, this results in a [`FilesystemLoop`] error if the last element is a symlink. +/// +/// This behavior may change in the future. +/// +/// [`FilesystemLoop`]: crate::io::ErrorKind::FilesystemLoop +#[doc(alias = "chmod", alias = "SetFileAttributes")] +#[unstable(feature = "set_permissions_nofollow", issue = "141607")] +pub fn set_permissions_nofollow>(path: P, perm: Permissions) -> io::Result<()> { + fs_imp::set_permissions_nofollow(path.as_ref(), perm) +} + impl DirBuilder { /// Creates a new set of options with default mode/security settings for all /// platforms and also non-recursive. diff --git a/library/std/src/io/buffered/bufreader/buffer.rs b/library/std/src/io/buffered/bufreader/buffer.rs index 574288e579e0b..9b600cd55758b 100644 --- a/library/std/src/io/buffered/bufreader/buffer.rs +++ b/library/std/src/io/buffered/bufreader/buffer.rs @@ -122,7 +122,7 @@ impl Buffer { /// Remove bytes that have already been read from the buffer. pub fn backshift(&mut self) { - self.buf.copy_within(self.pos.., 0); + self.buf.copy_within(self.pos..self.filled, 0); self.filled -= self.pos; self.pos = 0; } diff --git a/library/std/src/path.rs b/library/std/src/path.rs index 3b52804d6be40..d231e25fef67b 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -1191,7 +1191,7 @@ impl PathBuf { #[stable(feature = "rust1", since = "1.0.0")] #[must_use] #[inline] - #[rustc_const_unstable(feature = "const_pathbuf_osstring_new", issue = "141520")] + #[rustc_const_stable(feature = "const_pathbuf_osstring_new", since = "CURRENT_RUSTC_VERSION")] pub const fn new() -> PathBuf { PathBuf { inner: OsString::new() } } diff --git a/library/std/src/sync/nonpoison/mutex.rs b/library/std/src/sync/nonpoison/mutex.rs index b6861c78f001d..fd1e671d7a3d3 100644 --- a/library/std/src/sync/nonpoison/mutex.rs +++ b/library/std/src/sync/nonpoison/mutex.rs @@ -100,7 +100,7 @@ pub struct MutexGuard<'a, T: ?Sized + 'a> { lock: &'a Mutex, } -/// A [`MutexGuard`] is not `Send` to maximize platform portablity. +/// A [`MutexGuard`] is not `Send` to maximize platform portability. /// /// On platforms that use POSIX threads (commonly referred to as pthreads) there is a requirement to /// release mutex locks on the same thread they were acquired. diff --git a/library/std/src/sync/poison/mutex.rs b/library/std/src/sync/poison/mutex.rs index 6205c4fa4ca4b..720c212c65cf7 100644 --- a/library/std/src/sync/poison/mutex.rs +++ b/library/std/src/sync/poison/mutex.rs @@ -279,7 +279,7 @@ pub struct MutexGuard<'a, T: ?Sized + 'a> { poison: poison::Guard, } -/// A [`MutexGuard`] is not `Send` to maximize platform portablity. +/// A [`MutexGuard`] is not `Send` to maximize platform portability. /// /// On platforms that use POSIX threads (commonly referred to as pthreads) there is a requirement to /// release mutex locks on the same thread they were acquired. diff --git a/library/std/src/sys/fs/mod.rs b/library/std/src/sys/fs/mod.rs index d55e28074fe8c..d7f98c86e6e5b 100644 --- a/library/std/src/sys/fs/mod.rs +++ b/library/std/src/sys/fs/mod.rs @@ -108,6 +108,21 @@ pub fn set_permissions(path: &Path, perm: FilePermissions) -> io::Result<()> { with_native_path(path, &|path| imp::set_perm(path, perm.clone())) } +#[cfg(unix)] +pub fn set_permissions_nofollow(path: &Path, perm: crate::fs::Permissions) -> io::Result<()> { + use crate::fs::OpenOptions; + use crate::os::unix::fs::OpenOptionsExt; + + OpenOptions::new().custom_flags(libc::O_NOFOLLOW).open(path)?.set_permissions(perm) +} + +#[cfg(not(unix))] +pub fn set_permissions_nofollow(_path: &Path, _perm: crate::fs::Permissions) -> io::Result<()> { + crate::unimplemented!( + "`set_permissions_nofollow` is currently only implemented on Unix platforms" + ) +} + pub fn canonicalize(path: &Path) -> io::Result { with_native_path(path, &imp::canonicalize) } diff --git a/library/std/src/sys/fs/unix.rs b/library/std/src/sys/fs/unix.rs index b310db2dac485..4643ced9ad818 100644 --- a/library/std/src/sys/fs/unix.rs +++ b/library/std/src/sys/fs/unix.rs @@ -1263,6 +1263,7 @@ impl File { target_os = "fuchsia", target_os = "linux", target_os = "netbsd", + target_os = "openbsd", target_vendor = "apple", ))] pub fn lock(&self) -> io::Result<()> { @@ -1275,6 +1276,7 @@ impl File { target_os = "fuchsia", target_os = "linux", target_os = "netbsd", + target_os = "openbsd", target_vendor = "apple", )))] pub fn lock(&self) -> io::Result<()> { @@ -1286,6 +1288,7 @@ impl File { target_os = "fuchsia", target_os = "linux", target_os = "netbsd", + target_os = "openbsd", target_vendor = "apple", ))] pub fn lock_shared(&self) -> io::Result<()> { @@ -1298,6 +1301,7 @@ impl File { target_os = "fuchsia", target_os = "linux", target_os = "netbsd", + target_os = "openbsd", target_vendor = "apple", )))] pub fn lock_shared(&self) -> io::Result<()> { @@ -1309,6 +1313,7 @@ impl File { target_os = "fuchsia", target_os = "linux", target_os = "netbsd", + target_os = "openbsd", target_vendor = "apple", ))] pub fn try_lock(&self) -> Result<(), TryLockError> { @@ -1329,6 +1334,7 @@ impl File { target_os = "fuchsia", target_os = "linux", target_os = "netbsd", + target_os = "openbsd", target_vendor = "apple", )))] pub fn try_lock(&self) -> Result<(), TryLockError> { @@ -1343,6 +1349,7 @@ impl File { target_os = "fuchsia", target_os = "linux", target_os = "netbsd", + target_os = "openbsd", target_vendor = "apple", ))] pub fn try_lock_shared(&self) -> Result<(), TryLockError> { @@ -1363,6 +1370,7 @@ impl File { target_os = "fuchsia", target_os = "linux", target_os = "netbsd", + target_os = "openbsd", target_vendor = "apple", )))] pub fn try_lock_shared(&self) -> Result<(), TryLockError> { @@ -1377,6 +1385,7 @@ impl File { target_os = "fuchsia", target_os = "linux", target_os = "netbsd", + target_os = "openbsd", target_vendor = "apple", ))] pub fn unlock(&self) -> io::Result<()> { @@ -1389,6 +1398,7 @@ impl File { target_os = "fuchsia", target_os = "linux", target_os = "netbsd", + target_os = "openbsd", target_vendor = "apple", )))] pub fn unlock(&self) -> io::Result<()> { diff --git a/library/std/src/sys/mod.rs b/library/std/src/sys/mod.rs index 8ec0a0e33023f..6324c1a232af4 100644 --- a/library/std/src/sys/mod.rs +++ b/library/std/src/sys/mod.rs @@ -1,7 +1,7 @@ #![allow(unsafe_op_in_unsafe_fn)] /// The configure builtins provides runtime support compiler-builtin features -/// which require dynamic intialization to work as expected, e.g. aarch64 +/// which require dynamic initialization to work as expected, e.g. aarch64 /// outline-atomics. mod configure_builtins; diff --git a/library/std/src/sys/pal/uefi/time.rs b/library/std/src/sys/pal/uefi/time.rs index df5611b2dddc1..748178659412f 100644 --- a/library/std/src/sys/pal/uefi/time.rs +++ b/library/std/src/sys/pal/uefi/time.rs @@ -188,7 +188,7 @@ pub(crate) mod system_time_internal { Duration::new(epoch, t.nanosecond) } - /// This algorithm is a modifed version of the one described in the post: + /// This algorithm is a modified version of the one described in the post: /// https://howardhinnant.github.io/date_algorithms.html#clive_from_days /// /// The changes are to use 1900-01-01-00:00:00 with timezone -1440 as anchor instead of UNIX @@ -197,7 +197,7 @@ pub(crate) mod system_time_internal { // Check timzone validity assert!(timezone <= 1440 && timezone >= -1440); - // FIXME(#126043): use checked_sub_signed once stablized + // FIXME(#126043): use checked_sub_signed once stabilized let secs = dur.as_secs().checked_add_signed((-timezone as i64) * SECS_IN_MINUTE as i64).unwrap(); diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 997a152a31fcb..eb4e54de0a4a0 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -12,6 +12,7 @@ use std::ffi::OsStr; use std::io::BufReader; use std::io::prelude::*; use std::path::{Path, PathBuf}; +use std::time::SystemTime; use std::{env, fs, str}; use serde_derive::Deserialize; @@ -38,7 +39,7 @@ use crate::{ }; /// Build a standard library for the given `target` using the given `build_compiler`. -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Std { pub target: TargetSelection, /// Compiler that builds the standard library. @@ -939,7 +940,7 @@ fn cp_rustc_component_to_ci_sysroot(builder: &Builder<'_>, sysroot: &Path, conte /// so that it can compile build scripts and proc macros when building this `rustc`. /// - Makes sure that `build_compiler` has a standard library prepared for `target`, /// so that the built `rustc` can *link to it* and use it at runtime. -#[derive(Debug, PartialOrd, Ord, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Rustc { /// The target on which rustc will run (its host). pub target: TargetSelection, @@ -1918,7 +1919,7 @@ impl Step for Sysroot { /// linker wrappers (LLD, LLVM bitcode linker, etc.). /// /// This will assemble a compiler in `build/$target/stage$stage`. -#[derive(Debug, PartialOrd, Ord, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Assemble { /// The compiler which we will produce in this step. Assemble itself will /// take care of ensuring that the necessary prerequisites to do so exist, @@ -2568,7 +2569,17 @@ pub fn strip_debug(builder: &Builder<'_>, target: TargetSelection, path: &Path) } let previous_mtime = t!(t!(path.metadata()).modified()); - command("strip").arg("--strip-debug").arg(path).run_capture(builder); + let stamp = BuildStamp::new(path.parent().unwrap()) + .with_prefix(path.file_name().unwrap().to_str().unwrap()) + .with_prefix("strip") + .add_stamp(previous_mtime.duration_since(SystemTime::UNIX_EPOCH).unwrap().as_nanos()); + + // Running strip can be relatively expensive (~1s on librustc_driver.so), so we don't rerun it + // if the file is unchanged. + if !stamp.is_up_to_date() { + command("strip").arg("--strip-debug").arg(path).run_capture(builder); + } + t!(stamp.write()); let file = t!(fs::File::open(path)); diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index 133e6f894afd8..beb71e70035b6 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -54,7 +54,7 @@ fn should_build_extended_tool(builder: &Builder<'_>, tool: &str) -> bool { builder.config.tools.as_ref().is_none_or(|tools| tools.contains(tool)) } -#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Docs { pub host: TargetSelection, } @@ -91,7 +91,7 @@ impl Step for Docs { } } -#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct JsonDocs { build_compiler: Compiler, target: TargetSelection, @@ -354,7 +354,7 @@ fn get_cc_search_dirs( (bin_path, lib_path) } -#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Mingw { pub host: TargetSelection, } @@ -394,7 +394,7 @@ impl Step for Mingw { } } -#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Rustc { pub compiler: Compiler, } @@ -730,7 +730,7 @@ fn copy_target_libs( } } -#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Std { pub compiler: Compiler, pub target: TargetSelection, @@ -785,7 +785,7 @@ impl Step for Std { /// `rust.download-rustc`. /// /// (Don't confuse this with [`RustDev`], without the `c`!) -#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct RustcDev { pub compiler: Compiler, pub target: TargetSelection, @@ -1026,7 +1026,7 @@ fn copy_src_dirs( } } -#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Src; impl Step for Src { @@ -1087,7 +1087,7 @@ impl Step for Src { } } -#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct PlainSourceTarball; impl Step for PlainSourceTarball { @@ -1233,7 +1233,7 @@ impl Step for PlainSourceTarball { } } -#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Cargo { pub build_compiler: Compiler, pub target: TargetSelection, @@ -1287,7 +1287,7 @@ impl Step for Cargo { } } -#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct RustAnalyzer { pub build_compiler: Compiler, pub target: TargetSelection, @@ -1563,7 +1563,7 @@ impl Step for Rustfmt { } } -#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Extended { stage: u32, host: TargetSelection, @@ -2404,7 +2404,7 @@ impl Step for LlvmTools { /// Distributes the `llvm-bitcode-linker` tool so that it can be used by a compiler whose host /// is `target`. -#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct LlvmBitcodeLinker { /// The linker will be compiled by this compiler. pub build_compiler: Compiler, diff --git a/src/bootstrap/src/core/build_steps/doc.rs b/src/bootstrap/src/core/build_steps/doc.rs index f6b27d8312063..7fe19c00ef5fa 100644 --- a/src/bootstrap/src/core/build_steps/doc.rs +++ b/src/bootstrap/src/core/build_steps/doc.rs @@ -580,7 +580,7 @@ impl Step for SharedAssets { } /// Document the standard library using `build_compiler`. -#[derive(Debug, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Std { build_compiler: Compiler, target: TargetSelection, @@ -715,7 +715,7 @@ impl Step for Std { /// or remote link. const STD_PUBLIC_CRATES: [&str; 5] = ["core", "alloc", "std", "proc_macro", "test"]; -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum DocumentationFormat { Html, Json, @@ -1230,7 +1230,7 @@ fn symlink_dir_force(config: &Config, original: &Path, link: &Path) { } /// Builds the Rust compiler book. -#[derive(Ord, PartialOrd, Debug, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct RustcBook { build_compiler: Compiler, target: TargetSelection, @@ -1334,7 +1334,7 @@ impl Step for RustcBook { /// Documents the reference. /// It has to always be done using a stage 1+ compiler, because it references in-tree /// compiler/stdlib concepts. -#[derive(Ord, PartialOrd, Debug, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct Reference { build_compiler: Compiler, target: TargetSelection, diff --git a/src/bootstrap/src/core/build_steps/run.rs b/src/bootstrap/src/core/build_steps/run.rs index 7f1a7d0025742..c6288f6384718 100644 --- a/src/bootstrap/src/core/build_steps/run.rs +++ b/src/bootstrap/src/core/build_steps/run.rs @@ -17,7 +17,7 @@ use crate::core::config::flags::get_completion; use crate::utils::exec::command; use crate::{Mode, t}; -#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct BuildManifest; impl Step for BuildManifest { @@ -56,7 +56,7 @@ impl Step for BuildManifest { } } -#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct BumpStage0; impl Step for BumpStage0 { @@ -78,7 +78,7 @@ impl Step for BumpStage0 { } } -#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct ReplaceVersionPlaceholder; impl Step for ReplaceVersionPlaceholder { @@ -169,7 +169,7 @@ impl Step for Miri { } } -#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct CollectLicenseMetadata; impl Step for CollectLicenseMetadata { @@ -200,7 +200,7 @@ impl Step for CollectLicenseMetadata { } } -#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct GenerateCopyright; impl Step for GenerateCopyright { @@ -264,7 +264,7 @@ impl Step for GenerateCopyright { } } -#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct GenerateWindowsSys; impl Step for GenerateWindowsSys { @@ -326,7 +326,7 @@ impl Step for GenerateCompletions { } } -#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct UnicodeTableGenerator; impl Step for UnicodeTableGenerator { @@ -348,7 +348,7 @@ impl Step for UnicodeTableGenerator { } } -#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct FeaturesStatusDump; impl Step for FeaturesStatusDump { @@ -408,7 +408,7 @@ impl Step for CyclicStep { /// /// The coverage-dump tool is an internal detail of coverage tests, so this run /// step is only needed when testing coverage-dump manually. -#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct CoverageDump; impl Step for CoverageDump { diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 4006bed4ac524..e7a57a7f3755b 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -2732,7 +2732,7 @@ fn prepare_cargo_test( /// FIXME(Zalathar): Try to split this into two separate steps: a user-visible /// step for testing standard library crates, and an internal step used for both /// library crates and compiler crates. -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Crate { pub compiler: Compiler, pub target: TargetSelection, @@ -3747,7 +3747,7 @@ impl Step for TestFloatParse { /// Runs the tool `src/tools/collect-license-metadata` in `ONLY_CHECK=1` mode, /// which verifies that `license-metadata.json` is up-to-date and therefore /// running the tool normally would not update anything. -#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct CollectLicenseMetadata; impl Step for CollectLicenseMetadata { diff --git a/src/bootstrap/src/core/config/mod.rs b/src/bootstrap/src/core/config/mod.rs index 285d20917e7da..8c5f903725147 100644 --- a/src/bootstrap/src/core/config/mod.rs +++ b/src/bootstrap/src/core/config/mod.rs @@ -324,7 +324,7 @@ impl FromStr for LlvmLibunwind { } } -#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Hash)] pub enum SplitDebuginfo { Packed, Unpacked, diff --git a/src/bootstrap/src/core/config/target_selection.rs b/src/bootstrap/src/core/config/target_selection.rs index ebd3fe7a8c68c..40b63a7f9c752 100644 --- a/src/bootstrap/src/core/config/target_selection.rs +++ b/src/bootstrap/src/core/config/target_selection.rs @@ -14,7 +14,7 @@ pub struct TargetSelection { } /// Newtype over `Vec` so we can implement custom parsing logic -#[derive(Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] +#[derive(Clone, Default, PartialEq, Eq, Hash, Debug)] pub struct TargetSelectionList(pub Vec); pub fn target_selection_list(s: &str) -> Result { diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 55e74f9e4d996..0165a7b70dd16 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -279,7 +279,7 @@ pub enum DependencyType { /// /// These entries currently correspond to the various output directories of the /// build system, with each mod generating output in a different directory. -#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq)] pub enum Mode { /// Build the standard library, placing output in the "stageN-std" directory. Std, @@ -357,7 +357,7 @@ pub enum RemapScheme { NonCompiler, } -#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq)] pub enum CLang { C, Cxx, diff --git a/src/bootstrap/src/utils/change_tracker.rs b/src/bootstrap/src/utils/change_tracker.rs index b454a8ddefb35..b2f9960a4492a 100644 --- a/src/bootstrap/src/utils/change_tracker.rs +++ b/src/bootstrap/src/utils/change_tracker.rs @@ -506,4 +506,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[ severity: ChangeSeverity::Warning, summary: "It is no longer possible to `x clippy` with stage 0. All clippy commands have to be on stage 1+.", }, + ChangeInfo { + change_id: 145379, + severity: ChangeSeverity::Info, + summary: "Build/check now supports forwarding `--timings` flag to cargo.", + }, ]; diff --git a/src/ci/docker/host-x86_64/tidy/Dockerfile b/src/ci/docker/host-x86_64/tidy/Dockerfile index ee1ae5410ee81..c8558689d3ba9 100644 --- a/src/ci/docker/host-x86_64/tidy/Dockerfile +++ b/src/ci/docker/host-x86_64/tidy/Dockerfile @@ -45,4 +45,4 @@ RUN bash -c 'npm install -g eslint@$(cat /tmp/eslint.version)' # NOTE: intentionally uses python2 for x.py so we can test it still works. # validate-toolstate only runs in our CI, so it's ok for it to only support python3. ENV SCRIPT TIDY_PRINT_DIFF=1 python2.7 ../x.py test --stage 0 \ - src/tools/tidy tidyselftest --extra-checks=py,cpp,js + src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck diff --git a/src/doc/rustc/src/codegen-options/index.md b/src/doc/rustc/src/codegen-options/index.md index 07eafdf4c4c62..445b10188e3f8 100644 --- a/src/doc/rustc/src/codegen-options/index.md +++ b/src/doc/rustc/src/codegen-options/index.md @@ -375,12 +375,12 @@ linking time. It takes one of the following values: * `y`, `yes`, `on`, `true`, `fat`, or no value: perform "fat" LTO which attempts to perform optimizations across all crates within the dependency graph. -* `n`, `no`, `off`, `false`: disables LTO. * `thin`: perform ["thin" LTO](http://blog.llvm.org/2016/06/thinlto-scalable-and-incremental-lto.html). This is similar to "fat", but takes substantially less time to run while still achieving performance gains similar to "fat". For larger projects like the Rust compiler, ThinLTO can even result in better performance than fat LTO. +* `n`, `no`, `off`, `false`: disables LTO. If `-C lto` is not specified, then the compiler will attempt to perform "thin local LTO" which performs "thin" LTO on the local crate only across its diff --git a/src/doc/rustc/src/platform-support/openharmony.md b/src/doc/rustc/src/platform-support/openharmony.md index 3acdc3707a840..de3b83d6c2c7f 100644 --- a/src/doc/rustc/src/platform-support/openharmony.md +++ b/src/doc/rustc/src/platform-support/openharmony.md @@ -16,7 +16,7 @@ system. ## Target maintainers [@Amanieu](https://github.com/Amanieu) -[@lubinglun](https://github.com/lubinglun) +[@cceerczw](https://github.com/cceerczw) ## Requirements diff --git a/src/doc/rustc/src/target-tier-policy.md b/src/doc/rustc/src/target-tier-policy.md index a0acfdf0e4ab5..28d3dc32a63ee 100644 --- a/src/doc/rustc/src/target-tier-policy.md +++ b/src/doc/rustc/src/target-tier-policy.md @@ -534,10 +534,10 @@ tests, and will reject patches that fail to build or pass the testsuite on a target. We hold tier 1 targets to our highest standard of requirements. A proposed new tier 1 target must be reviewed and approved by the compiler team -based on these requirements. In addition, the release team must approve the -viability and value of supporting the target. For a tier 1 target, this will +based on these requirements. In addition, the infra team must approve the +viability of supporting the target. For a tier 1 target, this will typically take place via a full RFC proposing the target, to be jointly -reviewed and approved by the compiler team and release team. +reviewed and approved by the compiler team and infra team. In addition, the infrastructure team must approve the integration of the target into Continuous Integration (CI), and the tier 1 CI-related requirements. This @@ -617,7 +617,7 @@ including the infrastructure team in the RFC proposing the target. A tier 1 target may be demoted if it no longer meets these requirements but still meets the requirements for a lower tier. Any proposal for demotion of a tier 1 target requires a full RFC process, with approval by the compiler and -release teams. Any such proposal will be communicated widely to the Rust +infra teams. Any such proposal will be communicated widely to the Rust community, both when initially proposed and before being dropped from a stable release. A tier 1 target is highly unlikely to be directly removed without first being demoted to tier 2 or tier 3. (The amount of time between such @@ -628,7 +628,7 @@ planned and scheduled action.) Raising the baseline expectations of a tier 1 target (such as the minimum CPU features or OS version required) requires the approval of the compiler and -release teams, and should be widely communicated as well, but does not +infra teams, and should be widely communicated as well, but does not necessarily require a full RFC. ### Tier 1 with host tools @@ -638,11 +638,11 @@ host (such as `rustc` and `cargo`). This allows the target to be used as a development platform, not just a compilation target. A proposed new tier 1 target with host tools must be reviewed and approved by -the compiler team based on these requirements. In addition, the release team -must approve the viability and value of supporting host tools for the target. +the compiler team based on these requirements. In addition, the infra team +must approve the viability of supporting host tools for the target. For a tier 1 target, this will typically take place via a full RFC proposing the target, to be jointly reviewed and approved by the compiler team and -release team. +infra team. In addition, the infrastructure team must approve the integration of the target's host tools into Continuous Integration (CI), and the CI-related @@ -697,7 +697,7 @@ target with host tools may be demoted (including having its host tools dropped, or being demoted to tier 2 with host tools) if it no longer meets these requirements but still meets the requirements for a lower tier. Any proposal for demotion of a tier 1 target (with or without host tools) requires a full -RFC process, with approval by the compiler and release teams. Any such proposal +RFC process, with approval by the compiler and infra teams. Any such proposal will be communicated widely to the Rust community, both when initially proposed and before being dropped from a stable release. diff --git a/src/doc/unstable-book/src/compiler-flags/indirect-branch-cs-prefix.md b/src/doc/unstable-book/src/compiler-flags/indirect-branch-cs-prefix.md new file mode 100644 index 0000000000000..040e2d4170131 --- /dev/null +++ b/src/doc/unstable-book/src/compiler-flags/indirect-branch-cs-prefix.md @@ -0,0 +1,19 @@ +# `indirect-branch-cs-prefix` + +The tracking issue for this feature is: https://github.com/rust-lang/rust/issues/116852. + +------------------------ + +Option `-Zindirect-branch-cs-prefix` controls whether a `cs` prefix is added to +`call` and `jmp` to indirect thunks. + +It is equivalent to [Clang]'s and [GCC]'s `-mindirect-branch-cs-prefix`. The +Linux kernel uses it for RETPOLINE builds. For details, see +[LLVM commit 6f867f910283] ("[X86] Support ``-mindirect-branch-cs-prefix`` for +call and jmp to indirect thunk") which introduces the feature. + +Only x86 and x86_64 are supported. + +[Clang]: https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mindirect-branch-cs-prefix +[GCC]: https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html#index-mindirect-branch-cs-prefix +[LLVM commit 6f867f910283]: https://github.com/llvm/llvm-project/commit/6f867f9102838ebe314c1f3661fdf95700386e5a diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs index 80399cf3842aa..3cd28426925af 100644 --- a/src/librustdoc/formats/cache.rs +++ b/src/librustdoc/formats/cache.rs @@ -48,7 +48,7 @@ pub(crate) struct Cache { /// Similar to `paths`, but only holds external paths. This is only used for /// generating explicit hyperlinks to other crates. - pub(crate) external_paths: FxHashMap, ItemType)>, + pub(crate) external_paths: FxIndexMap, ItemType)>, /// Maps local `DefId`s of exported types to fully qualified paths. /// Unlike 'paths', this mapping ignores any renames that occur diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 8e3d07b3a1c28..21d154edf5d2a 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -1529,7 +1529,7 @@ function preLoadCss(cssUrl) { ["⏎", "Go to active search result"], ["+", "Expand all sections"], ["-", "Collapse all sections"], - // for the sake of brevity, we don't say "inherint impl blocks", + // for the sake of brevity, we don't say "inherit impl blocks", // although that would be more correct, // since trait impl blocks are collapsed by - ["_", "Collapse all sections, including impl blocks"], diff --git a/src/tools/miri/src/machine.rs b/src/tools/miri/src/machine.rs index 49021b1c4a2c4..4cad36cf3831c 100644 --- a/src/tools/miri/src/machine.rs +++ b/src/tools/miri/src/machine.rs @@ -1111,6 +1111,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> { ) -> InterpResult<'tcx, Option<(&'tcx mir::Body<'tcx>, ty::Instance<'tcx>)>> { // For foreign items, try to see if we can emulate them. if ecx.tcx.is_foreign_item(instance.def_id()) { + let _trace = enter_trace_span!("emulate_foreign_item"); // An external function call that does not have a MIR body. We either find MIR elsewhere // or emulate its effect. // This will be Ok(None) if we're emulating the intrinsic entirely within Miri (no need @@ -1123,6 +1124,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> { } // Otherwise, load the MIR. + let _trace = enter_trace_span!("load_mir"); interp_ok(Some((ecx.load_mir(instance.def, None)?, instance))) } diff --git a/src/tools/miri/src/shims/foreign_items.rs b/src/tools/miri/src/shims/foreign_items.rs index 21545b680299c..23b1d0c4f6ecf 100644 --- a/src/tools/miri/src/shims/foreign_items.rs +++ b/src/tools/miri/src/shims/foreign_items.rs @@ -146,7 +146,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { return interp_ok(()); } // Skip over items without an explicitly defined symbol name. - if !(attrs.export_name.is_some() + if !(attrs.symbol_name.is_some() || attrs.flags.contains(CodegenFnAttrFlags::NO_MANGLE) || attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL)) { diff --git a/src/tools/tidy/src/extra_checks/mod.rs b/src/tools/tidy/src/extra_checks/mod.rs index f90f716cd9501..31169ec596775 100644 --- a/src/tools/tidy/src/extra_checks/mod.rs +++ b/src/tools/tidy/src/extra_checks/mod.rs @@ -41,7 +41,6 @@ const RUFF_CONFIG_PATH: &[&str] = &["src", "tools", "tidy", "config", "ruff.toml const RUFF_CACHE_PATH: &[&str] = &["cache", "ruff_cache"]; const PIP_REQ_PATH: &[&str] = &["src", "tools", "tidy", "config", "requirements.txt"]; -// this must be kept in sync with with .github/workflows/spellcheck.yml const SPELLCHECK_DIRS: &[&str] = &["compiler", "library", "src/bootstrap", "src/librustdoc"]; pub fn check( @@ -51,6 +50,7 @@ pub fn check( librustdoc_path: &Path, tools_path: &Path, npm: &Path, + cargo: &Path, bless: bool, extra_checks: Option<&str>, pos_args: &[String], @@ -63,6 +63,7 @@ pub fn check( librustdoc_path, tools_path, npm, + cargo, bless, extra_checks, pos_args, @@ -78,6 +79,7 @@ fn check_impl( librustdoc_path: &Path, tools_path: &Path, npm: &Path, + cargo: &Path, bless: bool, extra_checks: Option<&str>, pos_args: &[String], @@ -293,7 +295,7 @@ fn check_impl( } else { eprintln!("spellcheck files"); } - spellcheck_runner(&args)?; + spellcheck_runner(root_path, &outdir, &cargo, &args)?; } if js_lint || js_typecheck { @@ -576,34 +578,25 @@ fn shellcheck_runner(args: &[&OsStr]) -> Result<(), Error> { if status.success() { Ok(()) } else { Err(Error::FailedCheck("shellcheck")) } } -/// Check that spellchecker is installed then run it at the given path -fn spellcheck_runner(args: &[&str]) -> Result<(), Error> { - // sync version with .github/workflows/spellcheck.yml - let expected_version = "typos-cli 1.34.0"; - match Command::new("typos").arg("--version").output() { - Ok(o) => { - let stdout = String::from_utf8_lossy(&o.stdout); - if stdout.trim() != expected_version { - return Err(Error::Version { - program: "typos", - required: expected_version, - installed: stdout.trim().to_string(), - }); +/// Ensure that spellchecker is installed then run it at the given path +fn spellcheck_runner( + src_root: &Path, + outdir: &Path, + cargo: &Path, + args: &[&str], +) -> Result<(), Error> { + let bin_path = + crate::ensure_version_or_cargo_install(outdir, cargo, "typos-cli", "typos", "1.34.0")?; + match Command::new(bin_path).current_dir(src_root).args(args).status() { + Ok(status) => { + if status.success() { + Ok(()) + } else { + Err(Error::FailedCheck("typos")) } } - Err(e) if e.kind() == io::ErrorKind::NotFound => { - return Err(Error::MissingReq( - "typos", - "spellcheck file checks", - // sync version with .github/workflows/spellcheck.yml - Some("install tool via `cargo install typos-cli@1.34.0`".to_owned()), - )); - } - Err(e) => return Err(e.into()), + Err(err) => Err(Error::Generic(format!("failed to run typos tool: {err:?}"))), } - - let status = Command::new("typos").args(args).status()?; - if status.success() { Ok(()) } else { Err(Error::FailedCheck("typos")) } } /// Check git for tracked files matching an extension diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index 4ea9d051ddb5e..37713cbf75e9b 100644 --- a/src/tools/tidy/src/lib.rs +++ b/src/tools/tidy/src/lib.rs @@ -4,7 +4,9 @@ //! to be used by tools. use std::ffi::OsStr; +use std::path::{Path, PathBuf}; use std::process::Command; +use std::{env, io}; use build_helper::ci::CiEnv; use build_helper::git::{GitConfig, get_closest_upstream_commit}; @@ -180,6 +182,70 @@ pub fn files_modified(ci_info: &CiInfo, pred: impl Fn(&str) -> bool) -> bool { !v.is_empty() } +/// If the given executable is installed with the given version, use that, +/// otherwise install via cargo. +pub fn ensure_version_or_cargo_install( + build_dir: &Path, + cargo: &Path, + pkg_name: &str, + bin_name: &str, + version: &str, +) -> io::Result { + // ignore the process exit code here and instead just let the version number check fail. + // we also importantly don't return if the program wasn't installed, + // instead we want to continue to the fallback. + 'ck: { + // FIXME: rewrite as if-let chain once this crate is 2024 edition. + let Ok(output) = Command::new(bin_name).arg("--version").output() else { + break 'ck; + }; + let Ok(s) = str::from_utf8(&output.stdout) else { + break 'ck; + }; + let Some(v) = s.trim().split_whitespace().last() else { + break 'ck; + }; + if v == version { + return Ok(PathBuf::from(bin_name)); + } + } + + let tool_root_dir = build_dir.join("misc-tools"); + let tool_bin_dir = tool_root_dir.join("bin"); + eprintln!("building external tool {bin_name} from package {pkg_name}@{version}"); + // use --force to ensure that if the required version is bumped, we update it. + // use --target-dir to ensure we have a build cache so repeated invocations aren't slow. + // modify PATH so that cargo doesn't print a warning telling the user to modify the path. + let cargo_exit_code = Command::new(cargo) + .args(["install", "--locked", "--force", "--quiet"]) + .arg("--root") + .arg(&tool_root_dir) + .arg("--target-dir") + .arg(tool_root_dir.join("target")) + .arg(format!("{pkg_name}@{version}")) + .env( + "PATH", + env::join_paths( + env::split_paths(&env::var("PATH").unwrap()) + .chain(std::iter::once(tool_bin_dir.clone())), + ) + .expect("build dir contains invalid char"), + ) + .env("RUSTFLAGS", "-Copt-level=0") + .spawn()? + .wait()?; + if !cargo_exit_code.success() { + return Err(io::Error::other("cargo install failed")); + } + let bin_path = tool_bin_dir.join(bin_name); + assert!( + matches!(bin_path.try_exists(), Ok(true)), + "cargo install did not produce the expected binary" + ); + eprintln!("finished building tool {bin_name}"); + Ok(bin_path) +} + pub mod alphabetical; pub mod bins; pub mod debug_artifacts; diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs index cd2567ddb64bf..bfe30258915ea 100644 --- a/src/tools/tidy/src/main.rs +++ b/src/tools/tidy/src/main.rs @@ -184,6 +184,7 @@ fn main() { &librustdoc_path, &tools_path, &npm, + &cargo, bless, extra_checks, pos_args diff --git a/tests/assembly-llvm/x86_64-indirect-branch-cs-prefix.rs b/tests/assembly-llvm/x86_64-indirect-branch-cs-prefix.rs new file mode 100644 index 0000000000000..8e4470ee4514c --- /dev/null +++ b/tests/assembly-llvm/x86_64-indirect-branch-cs-prefix.rs @@ -0,0 +1,27 @@ +// Test that the `cs` prefix is (not) added into a `call` and a `jmp` to the +// indirect thunk when the `-Zindirect-branch-cs-prefix` flag is (not) set. + +//@ revisions: unset set +//@ assembly-output: emit-asm +//@ compile-flags: -Copt-level=3 -Cunsafe-allow-abi-mismatch=retpoline,retpoline-external-thunk,indirect-branch-cs-prefix -Zretpoline-external-thunk +//@ [set] compile-flags: -Zindirect-branch-cs-prefix +//@ only-x86_64 +//@ ignore-apple Symbol is called `___x86_indirect_thunk` (Darwin's extra underscore) + +#![crate_type = "lib"] + +// CHECK-LABEL: foo: +#[no_mangle] +pub fn foo(g: fn()) { + // unset-NOT: cs + // unset: callq {{__x86_indirect_thunk.*}} + // set: cs + // set-NEXT: callq {{__x86_indirect_thunk.*}} + g(); + + // unset-NOT: cs + // unset: jmp {{__x86_indirect_thunk.*}} + // set: cs + // set-NEXT: jmp {{__x86_indirect_thunk.*}} + g(); +} diff --git a/tests/codegen-llvm/indirect-branch-cs-prefix.rs b/tests/codegen-llvm/indirect-branch-cs-prefix.rs new file mode 100644 index 0000000000000..df25008d5f09b --- /dev/null +++ b/tests/codegen-llvm/indirect-branch-cs-prefix.rs @@ -0,0 +1,18 @@ +// Test that the `indirect_branch_cs_prefix` module attribute is (not) +// emitted when the `-Zindirect-branch-cs-prefix` flag is (not) set. + +//@ add-core-stubs +//@ revisions: unset set +//@ needs-llvm-components: x86 +//@ compile-flags: --target x86_64-unknown-linux-gnu +//@ [set] compile-flags: -Zindirect-branch-cs-prefix + +#![crate_type = "lib"] +#![feature(no_core, lang_items)] +#![no_core] + +extern crate minicore; +use minicore::*; + +// unset-NOT: !{{[0-9]+}} = !{i32 4, !"indirect_branch_cs_prefix", i32 1} +// set: !{{[0-9]+}} = !{i32 4, !"indirect_branch_cs_prefix", i32 1} diff --git a/tests/ui-fulldeps/internal-lints/query_stability.rs b/tests/ui-fulldeps/internal-lints/query_stability.rs index 7b897fabd2d80..92c1d6bf7f8e9 100644 --- a/tests/ui-fulldeps/internal-lints/query_stability.rs +++ b/tests/ui-fulldeps/internal-lints/query_stability.rs @@ -1,4 +1,5 @@ //@ compile-flags: -Z unstable-options +//@ ignore-stage1 #![feature(rustc_private)] #![deny(rustc::potential_query_instability)] @@ -34,4 +35,16 @@ fn main() { //~^ ERROR using `values_mut` can result in unstable query results *val = *val + 10; } + + FxHashMap::::default().extend(x); + //~^ ERROR using `into_iter` can result in unstable query results +} + +fn hide_into_iter(x: impl IntoIterator) -> impl Iterator { + x.into_iter() +} + +fn take(map: std::collections::HashMap) { + _ = hide_into_iter(map); + //~^ ERROR using `into_iter` can result in unstable query results } diff --git a/tests/ui-fulldeps/internal-lints/query_stability.stderr b/tests/ui-fulldeps/internal-lints/query_stability.stderr index 43b156dc20a3c..e5bb0453f90d5 100644 --- a/tests/ui-fulldeps/internal-lints/query_stability.stderr +++ b/tests/ui-fulldeps/internal-lints/query_stability.stderr @@ -1,18 +1,18 @@ error: using `drain` can result in unstable query results - --> $DIR/query_stability.rs:13:16 + --> $DIR/query_stability.rs:14:16 | LL | for _ in x.drain() {} | ^^^^^ | = note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale note: the lint level is defined here - --> $DIR/query_stability.rs:4:9 + --> $DIR/query_stability.rs:5:9 | LL | #![deny(rustc::potential_query_instability)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: using `iter` can result in unstable query results - --> $DIR/query_stability.rs:16:16 + --> $DIR/query_stability.rs:17:16 | LL | for _ in x.iter() {} | ^^^^ @@ -20,7 +20,7 @@ LL | for _ in x.iter() {} = note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale error: using `iter_mut` can result in unstable query results - --> $DIR/query_stability.rs:19:36 + --> $DIR/query_stability.rs:20:36 | LL | for _ in Some(&mut x).unwrap().iter_mut() {} | ^^^^^^^^ @@ -28,7 +28,7 @@ LL | for _ in Some(&mut x).unwrap().iter_mut() {} = note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale error: using `into_iter` can result in unstable query results - --> $DIR/query_stability.rs:22:14 + --> $DIR/query_stability.rs:23:14 | LL | for _ in x {} | ^ @@ -36,7 +36,7 @@ LL | for _ in x {} = note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale error: using `keys` can result in unstable query results - --> $DIR/query_stability.rs:26:15 + --> $DIR/query_stability.rs:27:15 | LL | let _ = x.keys(); | ^^^^ @@ -44,7 +44,7 @@ LL | let _ = x.keys(); = note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale error: using `values` can result in unstable query results - --> $DIR/query_stability.rs:29:15 + --> $DIR/query_stability.rs:30:15 | LL | let _ = x.values(); | ^^^^^^ @@ -52,12 +52,28 @@ LL | let _ = x.values(); = note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale error: using `values_mut` can result in unstable query results - --> $DIR/query_stability.rs:33:18 + --> $DIR/query_stability.rs:34:18 | LL | for val in x.values_mut() { | ^^^^^^^^^^ | = note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale -error: aborting due to 7 previous errors +error: using `into_iter` can result in unstable query results + --> $DIR/query_stability.rs:39:38 + | +LL | FxHashMap::::default().extend(x); + | ^^^^^^^^^ + | + = note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale + +error: using `into_iter` can result in unstable query results + --> $DIR/query_stability.rs:48:9 + | +LL | _ = hide_into_iter(map); + | ^^^^^^^^^^^^^^^^^^^ + | + = note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale + +error: aborting due to 9 previous errors diff --git a/tests/ui/issues/issue-8498.rs b/tests/ui/array-slice-vec/matching-on-vector-slice-option-8498.rs similarity index 91% rename from tests/ui/issues/issue-8498.rs rename to tests/ui/array-slice-vec/matching-on-vector-slice-option-8498.rs index 92904e2198f68..e243a247ed518 100644 --- a/tests/ui/issues/issue-8498.rs +++ b/tests/ui/array-slice-vec/matching-on-vector-slice-option-8498.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/8498 //@ run-pass pub fn main() { diff --git a/tests/ui/issues/issue-7784.rs b/tests/ui/array-slice-vec/pattern-matching-fixed-length-vectors-7784.rs similarity index 93% rename from tests/ui/issues/issue-7784.rs rename to tests/ui/array-slice-vec/pattern-matching-fixed-length-vectors-7784.rs index 90b88ae572764..7d987e92b63aa 100644 --- a/tests/ui/issues/issue-7784.rs +++ b/tests/ui/array-slice-vec/pattern-matching-fixed-length-vectors-7784.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/7784 //@ run-pass use std::ops::Add; diff --git a/tests/ui/issues/issue-78622.rs b/tests/ui/associated-consts/ambiguous-associated-type-error-78622.rs similarity index 67% rename from tests/ui/issues/issue-78622.rs rename to tests/ui/associated-consts/ambiguous-associated-type-error-78622.rs index c00fd26606367..9763be1ecb219 100644 --- a/tests/ui/issues/issue-78622.rs +++ b/tests/ui/associated-consts/ambiguous-associated-type-error-78622.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/78622 #![crate_type = "lib"] struct S; diff --git a/tests/ui/issues/issue-78622.stderr b/tests/ui/associated-consts/ambiguous-associated-type-error-78622.stderr similarity index 87% rename from tests/ui/issues/issue-78622.stderr rename to tests/ui/associated-consts/ambiguous-associated-type-error-78622.stderr index 432913a0fc9c1..4dff1364af777 100644 --- a/tests/ui/issues/issue-78622.stderr +++ b/tests/ui/associated-consts/ambiguous-associated-type-error-78622.stderr @@ -1,5 +1,5 @@ error[E0223]: ambiguous associated type - --> $DIR/issue-78622.rs:5:5 + --> $DIR/ambiguous-associated-type-error-78622.rs:6:5 | LL | S::A:: {} | ^^^^ diff --git a/tests/ui/issues/issue-78957.rs b/tests/ui/attributes/invalid-attributes-on-const-params-78957.rs similarity index 95% rename from tests/ui/issues/issue-78957.rs rename to tests/ui/attributes/invalid-attributes-on-const-params-78957.rs index 2ff92612e1852..106b9ae269068 100644 --- a/tests/ui/issues/issue-78957.rs +++ b/tests/ui/attributes/invalid-attributes-on-const-params-78957.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/78957 #![deny(unused_attributes)] use std::marker::PhantomData; diff --git a/tests/ui/issues/issue-78957.stderr b/tests/ui/attributes/invalid-attributes-on-const-params-78957.stderr similarity index 80% rename from tests/ui/issues/issue-78957.stderr rename to tests/ui/attributes/invalid-attributes-on-const-params-78957.stderr index d271b1840fb5a..f8010b4ea687c 100644 --- a/tests/ui/issues/issue-78957.stderr +++ b/tests/ui/attributes/invalid-attributes-on-const-params-78957.stderr @@ -1,5 +1,5 @@ error: `#[inline]` attribute cannot be used on function params - --> $DIR/issue-78957.rs:5:16 + --> $DIR/invalid-attributes-on-const-params-78957.rs:6:16 | LL | pub struct Foo<#[inline] const N: usize>; | ^^^^^^^^^ @@ -7,7 +7,7 @@ LL | pub struct Foo<#[inline] const N: usize>; = help: `#[inline]` can only be applied to functions error: `#[inline]` attribute cannot be used on function params - --> $DIR/issue-78957.rs:13:17 + --> $DIR/invalid-attributes-on-const-params-78957.rs:14:17 | LL | pub struct Foo2<#[inline] 'a>(PhantomData<&'a ()>); | ^^^^^^^^^ @@ -15,7 +15,7 @@ LL | pub struct Foo2<#[inline] 'a>(PhantomData<&'a ()>); = help: `#[inline]` can only be applied to functions error: `#[inline]` attribute cannot be used on function params - --> $DIR/issue-78957.rs:21:17 + --> $DIR/invalid-attributes-on-const-params-78957.rs:22:17 | LL | pub struct Foo3<#[inline] T>(PhantomData); | ^^^^^^^^^ @@ -23,25 +23,25 @@ LL | pub struct Foo3<#[inline] T>(PhantomData); = help: `#[inline]` can only be applied to functions error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-78957.rs:10:23 + --> $DIR/invalid-attributes-on-const-params-78957.rs:11:23 | LL | pub struct Baz<#[repr(C)] const N: usize>; | ^ -------------- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-78957.rs:18:24 + --> $DIR/invalid-attributes-on-const-params-78957.rs:19:24 | LL | pub struct Baz2<#[repr(C)] 'a>(PhantomData<&'a ()>); | ^ -- not a struct, enum, or union error[E0517]: attribute should be applied to a struct, enum, or union - --> $DIR/issue-78957.rs:26:24 + --> $DIR/invalid-attributes-on-const-params-78957.rs:27:24 | LL | pub struct Baz3<#[repr(C)] T>(PhantomData); | ^ - not a struct, enum, or union error: `#[cold]` attribute cannot be used on function params - --> $DIR/issue-78957.rs:7:16 + --> $DIR/invalid-attributes-on-const-params-78957.rs:8:16 | LL | pub struct Bar<#[cold] const N: usize>; | ^^^^^^^ @@ -49,13 +49,13 @@ LL | pub struct Bar<#[cold] const N: usize>; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = help: `#[cold]` can only be applied to functions note: the lint level is defined here - --> $DIR/issue-78957.rs:1:9 + --> $DIR/invalid-attributes-on-const-params-78957.rs:2:9 | LL | #![deny(unused_attributes)] | ^^^^^^^^^^^^^^^^^ error: `#[cold]` attribute cannot be used on function params - --> $DIR/issue-78957.rs:15:17 + --> $DIR/invalid-attributes-on-const-params-78957.rs:16:17 | LL | pub struct Bar2<#[cold] 'a>(PhantomData<&'a ()>); | ^^^^^^^ @@ -64,7 +64,7 @@ LL | pub struct Bar2<#[cold] 'a>(PhantomData<&'a ()>); = help: `#[cold]` can only be applied to functions error: `#[cold]` attribute cannot be used on function params - --> $DIR/issue-78957.rs:23:17 + --> $DIR/invalid-attributes-on-const-params-78957.rs:24:17 | LL | pub struct Bar3<#[cold] T>(PhantomData); | ^^^^^^^ diff --git a/tests/ui/issues/issue-77218/issue-77218.fixed b/tests/ui/binding/invalid-assignment-in-while-loop-77218.fixed similarity index 73% rename from tests/ui/issues/issue-77218/issue-77218.fixed rename to tests/ui/binding/invalid-assignment-in-while-loop-77218.fixed index 6ce9dd1c2c57a..aa662ead21ac8 100644 --- a/tests/ui/issues/issue-77218/issue-77218.fixed +++ b/tests/ui/binding/invalid-assignment-in-while-loop-77218.fixed @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/77218 //@ run-rustfix fn main() { let value = [7u8]; diff --git a/tests/ui/issues/issue-77218/issue-77218.rs b/tests/ui/binding/invalid-assignment-in-while-loop-77218.rs similarity index 73% rename from tests/ui/issues/issue-77218/issue-77218.rs rename to tests/ui/binding/invalid-assignment-in-while-loop-77218.rs index 14edc065d0e63..9f249180e83a2 100644 --- a/tests/ui/issues/issue-77218/issue-77218.rs +++ b/tests/ui/binding/invalid-assignment-in-while-loop-77218.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/77218 //@ run-rustfix fn main() { let value = [7u8]; diff --git a/tests/ui/issues/issue-77218/issue-77218.stderr b/tests/ui/binding/invalid-assignment-in-while-loop-77218.stderr similarity index 88% rename from tests/ui/issues/issue-77218/issue-77218.stderr rename to tests/ui/binding/invalid-assignment-in-while-loop-77218.stderr index e98e69314d91d..e6baf349d28ad 100644 --- a/tests/ui/issues/issue-77218/issue-77218.stderr +++ b/tests/ui/binding/invalid-assignment-in-while-loop-77218.stderr @@ -1,5 +1,5 @@ error[E0070]: invalid left-hand side of assignment - --> $DIR/issue-77218.rs:4:19 + --> $DIR/invalid-assignment-in-while-loop-77218.rs:5:19 | LL | while Some(0) = value.get(0) {} | - ^ diff --git a/tests/ui/issues/issue-78192.rs b/tests/ui/borrowck/incorrect-use-after-storage-end-78192.rs similarity index 82% rename from tests/ui/issues/issue-78192.rs rename to tests/ui/borrowck/incorrect-use-after-storage-end-78192.rs index bec2a82910cfa..99a1d37eb4de7 100644 --- a/tests/ui/issues/issue-78192.rs +++ b/tests/ui/borrowck/incorrect-use-after-storage-end-78192.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/78192 //@ run-pass #![allow(unused_assignments)] diff --git a/tests/ui/issues/issue-7660.rs b/tests/ui/borrowck/rvalue-lifetime-match-equivalence-7660.rs similarity index 88% rename from tests/ui/issues/issue-7660.rs rename to tests/ui/borrowck/rvalue-lifetime-match-equivalence-7660.rs index 104cdad8f7bb7..90526de14e758 100644 --- a/tests/ui/issues/issue-7660.rs +++ b/tests/ui/borrowck/rvalue-lifetime-match-equivalence-7660.rs @@ -1,9 +1,9 @@ +// https://github.com/rust-lang/rust/issues/7660 //@ run-pass #![allow(unused_variables)] // Regression test for issue 7660 // rvalue lifetime too short when equivalent `match` works - use std::collections::HashMap; struct A(isize, isize); diff --git a/tests/ui/issues/issue-76042.rs b/tests/ui/codegen/i128-shift-overflow-check-76042.rs similarity index 85% rename from tests/ui/issues/issue-76042.rs rename to tests/ui/codegen/i128-shift-overflow-check-76042.rs index 279e860459d2c..7ae0806216cd6 100644 --- a/tests/ui/issues/issue-76042.rs +++ b/tests/ui/codegen/i128-shift-overflow-check-76042.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/76042 //@ run-pass //@ compile-flags: -Coverflow-checks=off -Ccodegen-units=1 -Copt-level=0 diff --git a/tests/ui/issues/issue-8248.rs b/tests/ui/coercion/mut-trait-coercion-8248.rs similarity index 81% rename from tests/ui/issues/issue-8248.rs rename to tests/ui/coercion/mut-trait-coercion-8248.rs index 95f626658cc67..a45a4d94315f1 100644 --- a/tests/ui/issues/issue-8248.rs +++ b/tests/ui/coercion/mut-trait-coercion-8248.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/8248 //@ run-pass trait A { diff --git a/tests/ui/issues/issue-8248.stderr b/tests/ui/coercion/mut-trait-coercion-8248.stderr similarity index 83% rename from tests/ui/issues/issue-8248.stderr rename to tests/ui/coercion/mut-trait-coercion-8248.stderr index 8570bfaefadbe..2f79a9ba1c868 100644 --- a/tests/ui/issues/issue-8248.stderr +++ b/tests/ui/coercion/mut-trait-coercion-8248.stderr @@ -1,5 +1,5 @@ warning: method `dummy` is never used - --> $DIR/issue-8248.rs:4:8 + --> $DIR/mut-trait-coercion-8248.rs:5:8 | LL | trait A { | - method in this trait diff --git a/tests/ui/issues/issue-8398.rs b/tests/ui/coercion/mut-trait-object-coercion-8398.rs similarity index 79% rename from tests/ui/issues/issue-8398.rs rename to tests/ui/coercion/mut-trait-object-coercion-8398.rs index 7d100b855fd1a..d87d27582bab6 100644 --- a/tests/ui/issues/issue-8398.rs +++ b/tests/ui/coercion/mut-trait-object-coercion-8398.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/8398 //@ check-pass #![allow(dead_code)] diff --git a/tests/ui/issues/issue-76191.rs b/tests/ui/consts/const-range-matching-76191.rs similarity index 89% rename from tests/ui/issues/issue-76191.rs rename to tests/ui/consts/const-range-matching-76191.rs index d2de44380c372..b579a4b3258a7 100644 --- a/tests/ui/issues/issue-76191.rs +++ b/tests/ui/consts/const-range-matching-76191.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/76191 // Regression test for diagnostic issue #76191 #![allow(non_snake_case)] diff --git a/tests/ui/issues/issue-76191.stderr b/tests/ui/consts/const-range-matching-76191.stderr similarity index 92% rename from tests/ui/issues/issue-76191.stderr rename to tests/ui/consts/const-range-matching-76191.stderr index d8b54be88f4bf..5c358d0fa1cf5 100644 --- a/tests/ui/issues/issue-76191.stderr +++ b/tests/ui/consts/const-range-matching-76191.stderr @@ -1,11 +1,11 @@ error[E0080]: evaluation panicked: explicit panic - --> $DIR/issue-76191.rs:8:37 + --> $DIR/const-range-matching-76191.rs:9:37 | LL | const RANGE2: RangeInclusive = panic!(); | ^^^^^^^^ evaluation of `RANGE2` failed here error[E0308]: mismatched types - --> $DIR/issue-76191.rs:14:9 + --> $DIR/const-range-matching-76191.rs:15:9 | LL | const RANGE: RangeInclusive = 0..=255; | -------------------------------- constant defined here @@ -27,7 +27,7 @@ LL + 0..=255 => {} | error[E0308]: mismatched types - --> $DIR/issue-76191.rs:16:9 + --> $DIR/const-range-matching-76191.rs:17:9 | LL | const RANGE2: RangeInclusive = panic!(); | --------------------------------- constant defined here diff --git a/tests/ui/issues/auxiliary/issue-7899.rs b/tests/ui/cross-crate/auxiliary/aux-7899.rs similarity index 100% rename from tests/ui/issues/auxiliary/issue-7899.rs rename to tests/ui/cross-crate/auxiliary/aux-7899.rs diff --git a/tests/ui/issues/auxiliary/issue-8259.rs b/tests/ui/cross-crate/auxiliary/aux-8259.rs similarity index 100% rename from tests/ui/issues/auxiliary/issue-8259.rs rename to tests/ui/cross-crate/auxiliary/aux-8259.rs diff --git a/tests/ui/issues/issue-8259.rs b/tests/ui/cross-crate/static-regions-in-cross-crate-8259.rs similarity index 55% rename from tests/ui/issues/issue-8259.rs rename to tests/ui/cross-crate/static-regions-in-cross-crate-8259.rs index e843f7f9c5083..347cfa2aee130 100644 --- a/tests/ui/issues/issue-8259.rs +++ b/tests/ui/cross-crate/static-regions-in-cross-crate-8259.rs @@ -1,11 +1,11 @@ +// https://github.com/rust-lang/rust/issues/8259 //@ run-pass #![allow(dead_code)] #![allow(non_upper_case_globals)] -//@ aux-build:issue-8259.rs +//@ aux-build:aux-8259.rs - -extern crate issue_8259 as other; +extern crate aux_8259 as other; static a: other::Foo<'static> = other::Foo::A; pub fn main() {} diff --git a/tests/ui/cross-crate/tuple-like-structs-cross-crate-7899.rs b/tests/ui/cross-crate/tuple-like-structs-cross-crate-7899.rs new file mode 100644 index 0000000000000..ce3ea7dd5796a --- /dev/null +++ b/tests/ui/cross-crate/tuple-like-structs-cross-crate-7899.rs @@ -0,0 +1,10 @@ +// https://github.com/rust-lang/rust/issues/7899 +//@ run-pass +#![allow(unused_variables)] +//@ aux-build:aux-7899.rs + +extern crate aux_7899 as testcrate; + +fn main() { + let f = testcrate::V2(1.0f32, 2.0f32); +} diff --git a/tests/ui/deriving/deriving-from-wrong-target.rs b/tests/ui/deriving/deriving-from-wrong-target.rs index 57e009cae69eb..ebeb3cb29db72 100644 --- a/tests/ui/deriving/deriving-from-wrong-target.rs +++ b/tests/ui/deriving/deriving-from-wrong-target.rs @@ -28,8 +28,6 @@ struct S4 { enum E1 {} #[derive(From)] -//~^ ERROR the size for values of type `T` cannot be known at compilation time [E0277] -//~| ERROR the size for values of type `T` cannot be known at compilation time [E0277] struct SUnsizedField { last: T, //~^ ERROR the size for values of type `T` cannot be known at compilation time [E0277] diff --git a/tests/ui/deriving/deriving-from-wrong-target.stderr b/tests/ui/deriving/deriving-from-wrong-target.stderr index 13593c95973e4..751c6c8ac7cf1 100644 --- a/tests/ui/deriving/deriving-from-wrong-target.stderr +++ b/tests/ui/deriving/deriving-from-wrong-target.stderr @@ -54,45 +54,7 @@ LL | enum E1 {} = note: `#[derive(From)]` can only be used on structs with exactly one field error[E0277]: the size for values of type `T` cannot be known at compilation time - --> $DIR/deriving-from-wrong-target.rs:30:10 - | -LL | #[derive(From)] - | ^^^^ doesn't have a size known at compile-time -... -LL | struct SUnsizedField { - | - this type parameter needs to be `Sized` - | -note: required by an implicit `Sized` bound in `From` - --> $SRC_DIR/core/src/convert/mod.rs:LL:COL -help: consider removing the `?Sized` bound to make the type parameter `Sized` - | -LL - struct SUnsizedField { -LL + struct SUnsizedField { - | - -error[E0277]: the size for values of type `T` cannot be known at compilation time - --> $DIR/deriving-from-wrong-target.rs:30:10 - | -LL | #[derive(From)] - | ^^^^ doesn't have a size known at compile-time -... -LL | struct SUnsizedField { - | - this type parameter needs to be `Sized` - | -note: required because it appears within the type `SUnsizedField` - --> $DIR/deriving-from-wrong-target.rs:33:8 - | -LL | struct SUnsizedField { - | ^^^^^^^^^^^^^ - = note: the return type of a function must have a statically known size -help: consider removing the `?Sized` bound to make the type parameter `Sized` - | -LL - struct SUnsizedField { -LL + struct SUnsizedField { - | - -error[E0277]: the size for values of type `T` cannot be known at compilation time - --> $DIR/deriving-from-wrong-target.rs:34:11 + --> $DIR/deriving-from-wrong-target.rs:32:11 | LL | struct SUnsizedField { | - this type parameter needs to be `Sized` @@ -110,6 +72,6 @@ help: function arguments must have a statically known size, borrowed types alway LL | last: &T, | + -error: aborting due to 8 previous errors +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/issues/auxiliary/issue-8401.rs b/tests/ui/dyn-keyword/auxiliary/aux-8401.rs similarity index 100% rename from tests/ui/issues/auxiliary/issue-8401.rs rename to tests/ui/dyn-keyword/auxiliary/aux-8401.rs diff --git a/tests/ui/dyn-keyword/methods-with-mut-trait-and-polymorphic-objects-issue-8401.rs b/tests/ui/dyn-keyword/methods-with-mut-trait-and-polymorphic-objects-issue-8401.rs new file mode 100644 index 0000000000000..313c6891720ac --- /dev/null +++ b/tests/ui/dyn-keyword/methods-with-mut-trait-and-polymorphic-objects-issue-8401.rs @@ -0,0 +1,7 @@ +//@ run-pass +//@ aux-build:aux-8401.rs +// https://github.com/rust-lang/rust/issues/8401 + +extern crate aux_8401; + +pub fn main() {} diff --git a/tests/ui/issues/issue-8761.rs b/tests/ui/enum/enum-discriminant-type-mismatch-8761.rs similarity index 80% rename from tests/ui/issues/issue-8761.rs rename to tests/ui/enum/enum-discriminant-type-mismatch-8761.rs index 5883bb9669562..ae09b919dc152 100644 --- a/tests/ui/issues/issue-8761.rs +++ b/tests/ui/enum/enum-discriminant-type-mismatch-8761.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/8761 enum Foo { A = 1i64, //~^ ERROR mismatched types diff --git a/tests/ui/issues/issue-8761.stderr b/tests/ui/enum/enum-discriminant-type-mismatch-8761.stderr similarity index 83% rename from tests/ui/issues/issue-8761.stderr rename to tests/ui/enum/enum-discriminant-type-mismatch-8761.stderr index 4a9db56891386..f1645183e176b 100644 --- a/tests/ui/issues/issue-8761.stderr +++ b/tests/ui/enum/enum-discriminant-type-mismatch-8761.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-8761.rs:2:9 + --> $DIR/enum-discriminant-type-mismatch-8761.rs:3:9 | LL | A = 1i64, | ^^^^ expected `isize`, found `i64` @@ -11,7 +11,7 @@ LL + A = 1isize, | error[E0308]: mismatched types - --> $DIR/issue-8761.rs:5:9 + --> $DIR/enum-discriminant-type-mismatch-8761.rs:6:9 | LL | B = 2u8 | ^^^ expected `isize`, found `u8` diff --git a/tests/ui/issues/issue-80607.rs b/tests/ui/enum/enum-variant-field-error-80607.rs similarity index 82% rename from tests/ui/issues/issue-80607.rs rename to tests/ui/enum/enum-variant-field-error-80607.rs index 63f4df359b831..aa3f2f7c526f6 100644 --- a/tests/ui/issues/issue-80607.rs +++ b/tests/ui/enum/enum-variant-field-error-80607.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/80607 // This tests makes sure the diagnostics print the offending enum variant, not just the type. pub enum Enum { V1(i32), diff --git a/tests/ui/issues/issue-80607.stderr b/tests/ui/enum/enum-variant-field-error-80607.stderr similarity index 89% rename from tests/ui/issues/issue-80607.stderr rename to tests/ui/enum/enum-variant-field-error-80607.stderr index 8f9f494c8b7a4..8d088ef04bbbf 100644 --- a/tests/ui/issues/issue-80607.stderr +++ b/tests/ui/enum/enum-variant-field-error-80607.stderr @@ -1,5 +1,5 @@ error[E0559]: variant `Enum::V1` has no field named `x` - --> $DIR/issue-80607.rs:7:16 + --> $DIR/enum-variant-field-error-80607.rs:8:16 | LL | V1(i32), | -- `Enum::V1` defined here diff --git a/tests/ui/issues/issue-8506.rs b/tests/ui/enum/simple-enum-usage-8506.rs similarity index 78% rename from tests/ui/issues/issue-8506.rs rename to tests/ui/enum/simple-enum-usage-8506.rs index 30a789a3e27bf..ebe095d84e437 100644 --- a/tests/ui/issues/issue-8506.rs +++ b/tests/ui/enum/simple-enum-usage-8506.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/8506 //@ run-pass #![allow(non_upper_case_globals)] diff --git a/tests/ui/issues/issue-75283.rs b/tests/ui/extern/function-definition-in-extern-block-75283.rs similarity index 70% rename from tests/ui/issues/issue-75283.rs rename to tests/ui/extern/function-definition-in-extern-block-75283.rs index d556132e47ffd..e2b7358743ba1 100644 --- a/tests/ui/issues/issue-75283.rs +++ b/tests/ui/extern/function-definition-in-extern-block-75283.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/75283 extern "C" { fn lol() { //~ ERROR incorrect function inside `extern` block println!(""); diff --git a/tests/ui/issues/issue-75283.stderr b/tests/ui/extern/function-definition-in-extern-block-75283.stderr similarity index 91% rename from tests/ui/issues/issue-75283.stderr rename to tests/ui/extern/function-definition-in-extern-block-75283.stderr index 240d9716a5561..67be1c2959922 100644 --- a/tests/ui/issues/issue-75283.stderr +++ b/tests/ui/extern/function-definition-in-extern-block-75283.stderr @@ -1,5 +1,5 @@ error: incorrect function inside `extern` block - --> $DIR/issue-75283.rs:2:8 + --> $DIR/function-definition-in-extern-block-75283.rs:3:8 | LL | extern "C" { | ---------- `extern` blocks define existing foreign functions and functions inside of them cannot have a body diff --git a/tests/ui/frontmatter/auxiliary/makro.rs b/tests/ui/frontmatter/auxiliary/makro.rs index 78e7417afb5f6..70707b27bff95 100644 --- a/tests/ui/frontmatter/auxiliary/makro.rs +++ b/tests/ui/frontmatter/auxiliary/makro.rs @@ -3,6 +3,6 @@ use proc_macro::TokenStream; #[proc_macro] pub fn check(_: TokenStream) -> TokenStream { - assert!("---\n---".parse::().unwrap().is_empty()); + assert_eq!(6, "---\n---".parse::().unwrap().into_iter().count()); Default::default() } diff --git a/tests/ui/frontmatter/proc-macro-observer.rs b/tests/ui/frontmatter/proc-macro-observer.rs index bafbe912032eb..b1cc1460933f2 100644 --- a/tests/ui/frontmatter/proc-macro-observer.rs +++ b/tests/ui/frontmatter/proc-macro-observer.rs @@ -2,11 +2,10 @@ //@ proc-macro: makro.rs //@ edition: 2021 -#![feature(frontmatter)] - makro::check!(); -// checks that a proc-macro cannot observe frontmatter tokens. +// checks that a proc-macro doesn't know or parse frontmatters at all and instead treats +// it as normal Rust code. // see auxiliary/makro.rs for how it is tested. fn main() {} diff --git a/tests/ui/issues/issue-86756.rs b/tests/ui/generics/duplicate-generic-parameter-error-86756.rs similarity index 89% rename from tests/ui/issues/issue-86756.rs rename to tests/ui/generics/duplicate-generic-parameter-error-86756.rs index 55a6c144839e8..acc281cb8c456 100644 --- a/tests/ui/issues/issue-86756.rs +++ b/tests/ui/generics/duplicate-generic-parameter-error-86756.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/86756 //@ edition: 2015 trait Foo {} //~^ ERROR the name `T` is already used for a generic parameter in this item's generic parameters diff --git a/tests/ui/issues/issue-86756.stderr b/tests/ui/generics/duplicate-generic-parameter-error-86756.stderr similarity index 82% rename from tests/ui/issues/issue-86756.stderr rename to tests/ui/generics/duplicate-generic-parameter-error-86756.stderr index b650b32c2a367..d4b2169ffd2dd 100644 --- a/tests/ui/issues/issue-86756.stderr +++ b/tests/ui/generics/duplicate-generic-parameter-error-86756.stderr @@ -1,5 +1,5 @@ error[E0403]: the name `T` is already used for a generic parameter in this item's generic parameters - --> $DIR/issue-86756.rs:2:14 + --> $DIR/duplicate-generic-parameter-error-86756.rs:3:14 | LL | trait Foo {} | - ^ already used @@ -7,13 +7,13 @@ LL | trait Foo {} | first use of `T` error[E0412]: cannot find type `dyn` in this scope - --> $DIR/issue-86756.rs:6:10 + --> $DIR/duplicate-generic-parameter-error-86756.rs:7:10 | LL | eq:: | ^^^ not found in this scope warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/issue-86756.rs:6:15 + --> $DIR/duplicate-generic-parameter-error-86756.rs:7:15 | LL | eq:: | ^^^ @@ -27,13 +27,13 @@ LL | eq:: | +++ error[E0107]: missing generics for trait `Foo` - --> $DIR/issue-86756.rs:6:15 + --> $DIR/duplicate-generic-parameter-error-86756.rs:7:15 | LL | eq:: | ^^^ expected at least 1 generic argument | note: trait defined here, with at least 1 generic parameter: `T` - --> $DIR/issue-86756.rs:2:7 + --> $DIR/duplicate-generic-parameter-error-86756.rs:3:7 | LL | trait Foo {} | ^^^ - diff --git a/tests/ui/impl-trait/precise-capturing/parenthesized.rs b/tests/ui/impl-trait/precise-capturing/parenthesized.rs new file mode 100644 index 0000000000000..e3f80fc1d9f06 --- /dev/null +++ b/tests/ui/impl-trait/precise-capturing/parenthesized.rs @@ -0,0 +1,8 @@ +// Ensure that we forbid parenthesized use-bounds. In the future we might want +// to lift this restriction but for now they bear no use whatsoever. + +fn f() -> impl Sized + (use<>) {} +//~^ ERROR precise capturing lists may not be parenthesized +//~| HELP remove the parentheses + +fn main() {} diff --git a/tests/ui/impl-trait/precise-capturing/parenthesized.stderr b/tests/ui/impl-trait/precise-capturing/parenthesized.stderr new file mode 100644 index 0000000000000..c97fa9972ef01 --- /dev/null +++ b/tests/ui/impl-trait/precise-capturing/parenthesized.stderr @@ -0,0 +1,14 @@ +error: precise capturing lists may not be parenthesized + --> $DIR/parenthesized.rs:4:24 + | +LL | fn f() -> impl Sized + (use<>) {} + | ^^^^^^^ + | +help: remove the parentheses + | +LL - fn f() -> impl Sized + (use<>) {} +LL + fn f() -> impl Sized + use<> {} + | + +error: aborting due to 1 previous error + diff --git a/tests/ui/issues/issue-85461.rs b/tests/ui/instrument-coverage/link-regex-crate-with-instrument-coverage-85461.rs similarity index 91% rename from tests/ui/issues/issue-85461.rs rename to tests/ui/instrument-coverage/link-regex-crate-with-instrument-coverage-85461.rs index 72538081ccb3a..ffb535e69ee56 100644 --- a/tests/ui/issues/issue-85461.rs +++ b/tests/ui/instrument-coverage/link-regex-crate-with-instrument-coverage-85461.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/85461 //@ compile-flags: -Cinstrument-coverage -Ccodegen-units=4 --crate-type dylib -Copt-level=0 //@ build-pass //@ needs-profiler-runtime diff --git a/tests/ui/invalid-compile-flags/indirect-branch-cs-prefix/requires-x86-or-x86_64.aarch64.stderr b/tests/ui/invalid-compile-flags/indirect-branch-cs-prefix/requires-x86-or-x86_64.aarch64.stderr new file mode 100644 index 0000000000000..e3f7871da3524 --- /dev/null +++ b/tests/ui/invalid-compile-flags/indirect-branch-cs-prefix/requires-x86-or-x86_64.aarch64.stderr @@ -0,0 +1,4 @@ +error: `-Zindirect-branch-cs-prefix` is only supported on x86 and x86_64 + +error: aborting due to 1 previous error + diff --git a/tests/ui/invalid-compile-flags/indirect-branch-cs-prefix/requires-x86-or-x86_64.rs b/tests/ui/invalid-compile-flags/indirect-branch-cs-prefix/requires-x86-or-x86_64.rs new file mode 100644 index 0000000000000..bc81c993d26ef --- /dev/null +++ b/tests/ui/invalid-compile-flags/indirect-branch-cs-prefix/requires-x86-or-x86_64.rs @@ -0,0 +1,21 @@ +//@ revisions: x86 x86_64 aarch64 + +//@ compile-flags: -Zindirect-branch-cs-prefix + +//@[x86] check-pass +//@[x86] needs-llvm-components: x86 +//@[x86] compile-flags: --target i686-unknown-linux-gnu + +//@[x86_64] check-pass +//@[x86_64] needs-llvm-components: x86 +//@[x86_64] compile-flags: --target x86_64-unknown-linux-gnu + +//@[aarch64] check-fail +//@[aarch64] needs-llvm-components: aarch64 +//@[aarch64] compile-flags: --target aarch64-unknown-linux-gnu + +#![feature(no_core)] +#![no_core] +#![no_main] + +//[aarch64]~? ERROR `-Zindirect-branch-cs-prefix` is only supported on x86 and x86_64 diff --git a/tests/ui/issues/issue-77218/issue-77218-2.fixed b/tests/ui/issues/issue-77218/issue-77218-2.fixed deleted file mode 100644 index 98d79b5da6561..0000000000000 --- a/tests/ui/issues/issue-77218/issue-77218-2.fixed +++ /dev/null @@ -1,6 +0,0 @@ -//@ run-rustfix -fn main() { - let value = [7u8]; - while let Some(0) = value.get(0) { //~ ERROR invalid left-hand side of assignment - } -} diff --git a/tests/ui/issues/issue-77218/issue-77218-2.rs b/tests/ui/issues/issue-77218/issue-77218-2.rs deleted file mode 100644 index 3be38f8f721da..0000000000000 --- a/tests/ui/issues/issue-77218/issue-77218-2.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ run-rustfix -fn main() { - let value = [7u8]; - while Some(0) = value.get(0) { //~ ERROR invalid left-hand side of assignment - } -} diff --git a/tests/ui/issues/issue-77218/issue-77218-2.stderr b/tests/ui/issues/issue-77218/issue-77218-2.stderr deleted file mode 100644 index dfed0b6e67e33..0000000000000 --- a/tests/ui/issues/issue-77218/issue-77218-2.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0070]: invalid left-hand side of assignment - --> $DIR/issue-77218-2.rs:4:19 - | -LL | while Some(0) = value.get(0) { - | - ^ - | | - | cannot assign to this expression - | -help: you might have meant to use pattern destructuring - | -LL | while let Some(0) = value.get(0) { - | +++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0070`. diff --git a/tests/ui/issues/issue-7899.rs b/tests/ui/issues/issue-7899.rs deleted file mode 100644 index 4b69f3e3d89aa..0000000000000 --- a/tests/ui/issues/issue-7899.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass -#![allow(unused_variables)] -//@ aux-build:issue-7899.rs - - -extern crate issue_7899 as testcrate; - -fn main() { - let f = testcrate::V2(1.0f32, 2.0f32); -} diff --git a/tests/ui/issues/issue-8044.rs b/tests/ui/issues/issue-8044.rs deleted file mode 100644 index 3c10bbca6342b..0000000000000 --- a/tests/ui/issues/issue-8044.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass -//@ aux-build:issue-8044.rs - - -extern crate issue_8044 as minimal; -use minimal::{BTree, leaf}; - -pub fn main() { - BTree:: { node: leaf(1) }; -} diff --git a/tests/ui/issues/issue-8401.rs b/tests/ui/issues/issue-8401.rs deleted file mode 100644 index 1df63516fb0be..0000000000000 --- a/tests/ui/issues/issue-8401.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ run-pass -//@ aux-build:issue-8401.rs - - -extern crate issue_8401; - -pub fn main() {} diff --git a/tests/ui/issues/issue-9123.rs b/tests/ui/issues/issue-9123.rs deleted file mode 100644 index bbf6c13341c27..0000000000000 --- a/tests/ui/issues/issue-9123.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ run-pass -//@ aux-build:issue-9123.rs - - -extern crate issue_9123; - -pub fn main() {} diff --git a/tests/ui/issues/issue-81584.fixed b/tests/ui/iterators/iterator-scope-collect-suggestion-81584.fixed similarity index 84% rename from tests/ui/issues/issue-81584.fixed rename to tests/ui/iterators/iterator-scope-collect-suggestion-81584.fixed index c3d33a1b4f8bc..0e3d48fe27d8a 100644 --- a/tests/ui/issues/issue-81584.fixed +++ b/tests/ui/iterators/iterator-scope-collect-suggestion-81584.fixed @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/81584 //@ run-rustfix fn main() { let _ = vec![vec![0, 1], vec![2]] diff --git a/tests/ui/issues/issue-81584.rs b/tests/ui/iterators/iterator-scope-collect-suggestion-81584.rs similarity index 83% rename from tests/ui/issues/issue-81584.rs rename to tests/ui/iterators/iterator-scope-collect-suggestion-81584.rs index 27db73aaa2c86..3fba39517fcc5 100644 --- a/tests/ui/issues/issue-81584.rs +++ b/tests/ui/iterators/iterator-scope-collect-suggestion-81584.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/81584 //@ run-rustfix fn main() { let _ = vec![vec![0, 1], vec![2]] diff --git a/tests/ui/issues/issue-81584.stderr b/tests/ui/iterators/iterator-scope-collect-suggestion-81584.stderr similarity index 89% rename from tests/ui/issues/issue-81584.stderr rename to tests/ui/iterators/iterator-scope-collect-suggestion-81584.stderr index eb97916ad75ef..e180183e7e387 100644 --- a/tests/ui/issues/issue-81584.stderr +++ b/tests/ui/iterators/iterator-scope-collect-suggestion-81584.stderr @@ -1,5 +1,5 @@ error[E0515]: cannot return value referencing function parameter `y` - --> $DIR/issue-81584.rs:5:22 + --> $DIR/iterator-scope-collect-suggestion-81584.rs:6:22 | LL | .map(|y| y.iter().map(|x| x + 1)) | -^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/issues/issue-7970a.rs b/tests/ui/macros/macro-invocation-span-error-7970.rs similarity index 51% rename from tests/ui/issues/issue-7970a.rs rename to tests/ui/macros/macro-invocation-span-error-7970.rs index dae906410ed61..df7e1cfea88bc 100644 --- a/tests/ui/issues/issue-7970a.rs +++ b/tests/ui/macros/macro-invocation-span-error-7970.rs @@ -1,5 +1,8 @@ +// https://github.com/rust-lang/rust/issues/7970 macro_rules! one_arg_macro { - ($fmt:expr) => (print!(concat!($fmt, "\n"))); + ($fmt:expr) => { + print!(concat!($fmt, "\n")) + }; } fn main() { diff --git a/tests/ui/issues/issue-7970a.stderr b/tests/ui/macros/macro-invocation-span-error-7970.stderr similarity index 73% rename from tests/ui/issues/issue-7970a.stderr rename to tests/ui/macros/macro-invocation-span-error-7970.stderr index 1e6bb92ea579e..beb54e0599248 100644 --- a/tests/ui/issues/issue-7970a.stderr +++ b/tests/ui/macros/macro-invocation-span-error-7970.stderr @@ -1,5 +1,5 @@ error: unexpected end of macro invocation - --> $DIR/issue-7970a.rs:6:5 + --> $DIR/macro-invocation-span-error-7970.rs:9:5 | LL | macro_rules! one_arg_macro { | -------------------------- when calling this macro @@ -8,9 +8,9 @@ LL | one_arg_macro!(); | ^^^^^^^^^^^^^^^^ missing tokens in macro arguments | note: while trying to match meta-variable `$fmt:expr` - --> $DIR/issue-7970a.rs:2:6 + --> $DIR/macro-invocation-span-error-7970.rs:3:6 | -LL | ($fmt:expr) => (print!(concat!($fmt, "\n"))); +LL | ($fmt:expr) => { | ^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/issues/issue-8521.rs b/tests/ui/macros/macro-path-type-bounds-8521.rs similarity index 84% rename from tests/ui/issues/issue-8521.rs rename to tests/ui/macros/macro-path-type-bounds-8521.rs index 78ce85787d5cf..975d3dc402e1f 100644 --- a/tests/ui/issues/issue-8521.rs +++ b/tests/ui/macros/macro-path-type-bounds-8521.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/8521 //@ check-pass trait Foo1 {} diff --git a/tests/ui/issues/issue-7911.rs b/tests/ui/macros/macro-self-mutability-7911.rs similarity index 95% rename from tests/ui/issues/issue-7911.rs rename to tests/ui/macros/macro-self-mutability-7911.rs index 11da4df5285f1..5313f86d97f5f 100644 --- a/tests/ui/issues/issue-7911.rs +++ b/tests/ui/macros/macro-self-mutability-7911.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/7911 //@ run-pass // (Closes #7911) Test that we can use the same self expression // with different mutability in macro in two methods diff --git a/tests/ui/issues/issue-7911.stderr b/tests/ui/macros/macro-self-mutability-7911.stderr similarity index 83% rename from tests/ui/issues/issue-7911.stderr rename to tests/ui/macros/macro-self-mutability-7911.stderr index ead7ee191ac9b..7fc2abe06eb39 100644 --- a/tests/ui/issues/issue-7911.stderr +++ b/tests/ui/macros/macro-self-mutability-7911.stderr @@ -1,5 +1,5 @@ warning: method `dummy` is never used - --> $DIR/issue-7911.rs:7:8 + --> $DIR/macro-self-mutability-7911.rs:8:8 | LL | trait FooBar { | ------ method in this trait diff --git a/tests/ui/issues/issue-7867.rs b/tests/ui/match/mismatched-types-in-match-pattern-7867.rs similarity index 87% rename from tests/ui/issues/issue-7867.rs rename to tests/ui/match/mismatched-types-in-match-pattern-7867.rs index 87e7c831e6855..9ff8755c81956 100644 --- a/tests/ui/issues/issue-7867.rs +++ b/tests/ui/match/mismatched-types-in-match-pattern-7867.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/7867 //@ dont-require-annotations: NOTE enum A { B, C } diff --git a/tests/ui/issues/issue-7867.stderr b/tests/ui/match/mismatched-types-in-match-pattern-7867.stderr similarity index 88% rename from tests/ui/issues/issue-7867.stderr rename to tests/ui/match/mismatched-types-in-match-pattern-7867.stderr index fcb69d775face..8997f36114a89 100644 --- a/tests/ui/issues/issue-7867.stderr +++ b/tests/ui/match/mismatched-types-in-match-pattern-7867.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-7867.rs:9:9 + --> $DIR/mismatched-types-in-match-pattern-7867.rs:10:9 | LL | enum A { B, C } | - unit variant defined here diff --git a/tests/ui/issues/issue-7575.rs b/tests/ui/methods/trait-method-self-param-error-7575.rs similarity index 83% rename from tests/ui/issues/issue-7575.rs rename to tests/ui/methods/trait-method-self-param-error-7575.rs index 8b1fdf6c851e2..9793d43cc24fc 100644 --- a/tests/ui/issues/issue-7575.rs +++ b/tests/ui/methods/trait-method-self-param-error-7575.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/7575 //@ run-pass trait Foo { //~ WARN trait `Foo` is never used diff --git a/tests/ui/issues/issue-7575.stderr b/tests/ui/methods/trait-method-self-param-error-7575.stderr similarity index 74% rename from tests/ui/issues/issue-7575.stderr rename to tests/ui/methods/trait-method-self-param-error-7575.stderr index 2f987d19c80ce..5c10a7e1da9d0 100644 --- a/tests/ui/issues/issue-7575.stderr +++ b/tests/ui/methods/trait-method-self-param-error-7575.stderr @@ -1,5 +1,5 @@ warning: trait `Foo` is never used - --> $DIR/issue-7575.rs:3:7 + --> $DIR/trait-method-self-param-error-7575.rs:4:7 | LL | trait Foo { | ^^^ diff --git a/tests/ui/issues/issue-81918.rs b/tests/ui/mir/mir-cfg-unpretty-check-81918.rs similarity index 81% rename from tests/ui/issues/issue-81918.rs rename to tests/ui/mir/mir-cfg-unpretty-check-81918.rs index ee9721c2493de..4798a6543755d 100644 --- a/tests/ui/issues/issue-81918.rs +++ b/tests/ui/mir/mir-cfg-unpretty-check-81918.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/81918 //@ check-pass //@ dont-check-compiler-stdout //@ compile-flags: -Z unpretty=mir-cfg diff --git a/tests/ui/issues/issue-87490.rs b/tests/ui/mismatched_types/mismatched-types-in-trait-implementation-87490.rs similarity index 80% rename from tests/ui/issues/issue-87490.rs rename to tests/ui/mismatched_types/mismatched-types-in-trait-implementation-87490.rs index 998f61a6bd32d..67e16ec6ce3ab 100644 --- a/tests/ui/issues/issue-87490.rs +++ b/tests/ui/mismatched_types/mismatched-types-in-trait-implementation-87490.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/87490 fn main() {} trait StreamOnce { type Position; diff --git a/tests/ui/issues/issue-87490.stderr b/tests/ui/mismatched_types/mismatched-types-in-trait-implementation-87490.stderr similarity index 87% rename from tests/ui/issues/issue-87490.stderr rename to tests/ui/mismatched_types/mismatched-types-in-trait-implementation-87490.stderr index 5a4ec55833bea..bbd73347d0272 100644 --- a/tests/ui/issues/issue-87490.stderr +++ b/tests/ui/mismatched_types/mismatched-types-in-trait-implementation-87490.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-87490.rs:9:5 + --> $DIR/mismatched-types-in-trait-implementation-87490.rs:10:5 | LL | fn follow(_: &str) -> <&str as StreamOnce>::Position { | ------------------------------ expected `usize` because of return type diff --git a/tests/ui/parser/trait-object-lifetime-parens.e2015.stderr b/tests/ui/parser/trait-object-lifetime-parens.e2015.stderr index cf0b3d77f5b5a..4f4f89de5d135 100644 --- a/tests/ui/parser/trait-object-lifetime-parens.e2015.stderr +++ b/tests/ui/parser/trait-object-lifetime-parens.e2015.stderr @@ -1,4 +1,4 @@ -error: parenthesized lifetime bounds are not supported +error: lifetime bounds may not be parenthesized --> $DIR/trait-object-lifetime-parens.rs:9:21 | LL | fn f<'a, T: Trait + ('a)>() {} @@ -10,7 +10,7 @@ LL - fn f<'a, T: Trait + ('a)>() {} LL + fn f<'a, T: Trait + 'a>() {} | -error: parenthesized lifetime bounds are not supported +error: lifetime bounds may not be parenthesized --> $DIR/trait-object-lifetime-parens.rs:12:24 | LL | let _: Box; diff --git a/tests/ui/parser/trait-object-lifetime-parens.e2021.stderr b/tests/ui/parser/trait-object-lifetime-parens.e2021.stderr index b65c079788a9c..a4e2501cfdf67 100644 --- a/tests/ui/parser/trait-object-lifetime-parens.e2021.stderr +++ b/tests/ui/parser/trait-object-lifetime-parens.e2021.stderr @@ -1,4 +1,4 @@ -error: parenthesized lifetime bounds are not supported +error: lifetime bounds may not be parenthesized --> $DIR/trait-object-lifetime-parens.rs:9:21 | LL | fn f<'a, T: Trait + ('a)>() {} @@ -10,7 +10,7 @@ LL - fn f<'a, T: Trait + ('a)>() {} LL + fn f<'a, T: Trait + 'a>() {} | -error: parenthesized lifetime bounds are not supported +error: lifetime bounds may not be parenthesized --> $DIR/trait-object-lifetime-parens.rs:12:24 | LL | let _: Box; diff --git a/tests/ui/parser/trait-object-lifetime-parens.rs b/tests/ui/parser/trait-object-lifetime-parens.rs index 0ff4660bb0d58..47a6884b31622 100644 --- a/tests/ui/parser/trait-object-lifetime-parens.rs +++ b/tests/ui/parser/trait-object-lifetime-parens.rs @@ -6,10 +6,10 @@ trait Trait {} -fn f<'a, T: Trait + ('a)>() {} //~ ERROR parenthesized lifetime bounds are not supported +fn f<'a, T: Trait + ('a)>() {} //~ ERROR lifetime bounds may not be parenthesized fn check<'a>() { - let _: Box; //~ ERROR parenthesized lifetime bounds are not supported + let _: Box; //~ ERROR lifetime bounds may not be parenthesized //[e2021]~^ ERROR expected a type, found a trait // FIXME: It'd be great if we could suggest removing the parentheses here too. //[e2015]~v ERROR lifetimes must be followed by `+` to form a trait object type diff --git a/tests/ui/issues/issue-8391.rs b/tests/ui/pattern/match-with-at-binding-8391.rs similarity index 73% rename from tests/ui/issues/issue-8391.rs rename to tests/ui/pattern/match-with-at-binding-8391.rs index 20698eed18b7b..bc4e7be798929 100644 --- a/tests/ui/issues/issue-8391.rs +++ b/tests/ui/pattern/match-with-at-binding-8391.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/8391 //@ run-pass fn main() { diff --git a/tests/ui/issues/issue-8860.rs b/tests/ui/pattern/ref-in-function-parameter-patterns-8860.rs similarity index 94% rename from tests/ui/issues/issue-8860.rs rename to tests/ui/pattern/ref-in-function-parameter-patterns-8860.rs index 3af61576fe1a2..1a67caf021cf7 100644 --- a/tests/ui/issues/issue-8860.rs +++ b/tests/ui/pattern/ref-in-function-parameter-patterns-8860.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/8860 //@ run-pass // FIXME(static_mut_refs): this could use an atomic #![allow(static_mut_refs)] diff --git a/tests/ui/issues/issue-76077-inaccesible-private-fields/issue-76077-1.fixed b/tests/ui/privacy/inaccessible-fields-pattern-matching-76077.fixed similarity index 90% rename from tests/ui/issues/issue-76077-inaccesible-private-fields/issue-76077-1.fixed rename to tests/ui/privacy/inaccessible-fields-pattern-matching-76077.fixed index 6fde4e390fa1a..7d648543a2071 100644 --- a/tests/ui/issues/issue-76077-inaccesible-private-fields/issue-76077-1.fixed +++ b/tests/ui/privacy/inaccessible-fields-pattern-matching-76077.fixed @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/76077 //@ run-rustfix #![allow(dead_code, unused_variables)] diff --git a/tests/ui/issues/issue-76077-inaccesible-private-fields/issue-76077-1.rs b/tests/ui/privacy/inaccessible-fields-pattern-matching-76077.rs similarity index 90% rename from tests/ui/issues/issue-76077-inaccesible-private-fields/issue-76077-1.rs rename to tests/ui/privacy/inaccessible-fields-pattern-matching-76077.rs index 30a8535faf5cc..f3b51187ae316 100644 --- a/tests/ui/issues/issue-76077-inaccesible-private-fields/issue-76077-1.rs +++ b/tests/ui/privacy/inaccessible-fields-pattern-matching-76077.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/76077 //@ run-rustfix #![allow(dead_code, unused_variables)] diff --git a/tests/ui/issues/issue-76077-inaccesible-private-fields/issue-76077-1.stderr b/tests/ui/privacy/inaccessible-fields-pattern-matching-76077.stderr similarity index 83% rename from tests/ui/issues/issue-76077-inaccesible-private-fields/issue-76077-1.stderr rename to tests/ui/privacy/inaccessible-fields-pattern-matching-76077.stderr index f54990d5d8618..070fa1a53a547 100644 --- a/tests/ui/issues/issue-76077-inaccesible-private-fields/issue-76077-1.stderr +++ b/tests/ui/privacy/inaccessible-fields-pattern-matching-76077.stderr @@ -1,5 +1,5 @@ error: pattern requires `..` due to inaccessible fields - --> $DIR/issue-76077-1.rs:13:9 + --> $DIR/inaccessible-fields-pattern-matching-76077.rs:14:9 | LL | let foo::Foo {} = foo::Foo::default(); | ^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | let foo::Foo { .. } = foo::Foo::default(); | ++ error: pattern requires `..` due to inaccessible fields - --> $DIR/issue-76077-1.rs:16:9 + --> $DIR/inaccessible-fields-pattern-matching-76077.rs:17:9 | LL | let foo::Bar { visible } = foo::Bar::default(); | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/privacy/macro-private-reexport.stderr b/tests/ui/privacy/macro-private-reexport.stderr index b8768f3612e61..aa02715c20298 100644 --- a/tests/ui/privacy/macro-private-reexport.stderr +++ b/tests/ui/privacy/macro-private-reexport.stderr @@ -11,6 +11,10 @@ LL | / macro_rules! bar { LL | | () => {}; LL | | } | |_____^ +help: in case you want to use the macro within this crate only, reduce the visibility to `pub(crate)` + | +LL | pub(crate) use bar as _; + | +++++++ error[E0364]: `baz` is private, and cannot be re-exported --> $DIR/macro-private-reexport.rs:14:13 diff --git a/tests/ui/issues/issue-76077-inaccesible-private-fields/issue-76077.rs b/tests/ui/privacy/private-field-struct-construction-76077.rs similarity index 80% rename from tests/ui/issues/issue-76077-inaccesible-private-fields/issue-76077.rs rename to tests/ui/privacy/private-field-struct-construction-76077.rs index 2d29093b01b02..7fc3473e8decc 100644 --- a/tests/ui/issues/issue-76077-inaccesible-private-fields/issue-76077.rs +++ b/tests/ui/privacy/private-field-struct-construction-76077.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/76077 pub mod foo { pub struct Foo { you_cant_use_this_field: bool, diff --git a/tests/ui/issues/issue-76077-inaccesible-private-fields/issue-76077.stderr b/tests/ui/privacy/private-field-struct-construction-76077.stderr similarity index 80% rename from tests/ui/issues/issue-76077-inaccesible-private-fields/issue-76077.stderr rename to tests/ui/privacy/private-field-struct-construction-76077.stderr index 3fef5ffce30dc..5131db72fe3bf 100644 --- a/tests/ui/issues/issue-76077-inaccesible-private-fields/issue-76077.stderr +++ b/tests/ui/privacy/private-field-struct-construction-76077.stderr @@ -1,5 +1,5 @@ error: cannot construct `Foo` with struct literal syntax due to private fields - --> $DIR/issue-76077.rs:8:5 + --> $DIR/private-field-struct-construction-76077.rs:9:5 | LL | foo::Foo {}; | ^^^^^^^^ diff --git a/tests/ui/issues/issue-8727.rs b/tests/ui/recursion/infinite-function-recursion-error-8727.rs similarity index 90% rename from tests/ui/issues/issue-8727.rs rename to tests/ui/recursion/infinite-function-recursion-error-8727.rs index c1b60e8e08509..a4037f761098e 100644 --- a/tests/ui/issues/issue-8727.rs +++ b/tests/ui/recursion/infinite-function-recursion-error-8727.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/8727 // Verify the compiler fails with an error on infinite function // recursions. @@ -9,7 +10,6 @@ fn generic() { //~ WARN function cannot return without recursing } //~^^ ERROR reached the recursion limit while instantiating `generic:: at least once to trigger instantiation. generic::(); diff --git a/tests/ui/issues/issue-8727.stderr b/tests/ui/recursion/infinite-function-recursion-error-8727.stderr similarity index 76% rename from tests/ui/issues/issue-8727.stderr rename to tests/ui/recursion/infinite-function-recursion-error-8727.stderr index 9fb09a7d4f42d..13d57ecb3b2f0 100644 --- a/tests/ui/issues/issue-8727.stderr +++ b/tests/ui/recursion/infinite-function-recursion-error-8727.stderr @@ -1,5 +1,5 @@ warning: function cannot return without recursing - --> $DIR/issue-8727.rs:7:1 + --> $DIR/infinite-function-recursion-error-8727.rs:8:1 | LL | fn generic() { | ^^^^^^^^^^^^^^^ cannot return without recursing @@ -10,17 +10,17 @@ LL | generic::>(); = note: `#[warn(unconditional_recursion)]` on by default error: reached the recursion limit while instantiating `generic::>>>>` - --> $DIR/issue-8727.rs:8:5 + --> $DIR/infinite-function-recursion-error-8727.rs:9:5 | LL | generic::>(); | ^^^^^^^^^^^^^^^^^^^^^^ | note: `generic` defined here - --> $DIR/issue-8727.rs:7:1 + --> $DIR/infinite-function-recursion-error-8727.rs:8:1 | LL | fn generic() { | ^^^^^^^^^^^^^^^ - = note: the full name for the type has been written to '$TEST_BUILD_DIR/issue-8727.long-type-$LONG_TYPE_HASH.txt' + = note: the full name for the type has been written to '$TEST_BUILD_DIR/infinite-function-recursion-error-8727.long-type-$LONG_TYPE_HASH.txt' = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/issues/issue-7663.rs b/tests/ui/resolve/module-import-resolution-7663.rs similarity index 91% rename from tests/ui/issues/issue-7663.rs rename to tests/ui/resolve/module-import-resolution-7663.rs index d2b2c727cab25..872806594fc40 100644 --- a/tests/ui/issues/issue-7663.rs +++ b/tests/ui/resolve/module-import-resolution-7663.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/7663 //@ run-pass #![allow(unused_imports, dead_code)] diff --git a/tests/ui/rust-2018/uniform-paths/macro-rules.stderr b/tests/ui/rust-2018/uniform-paths/macro-rules.stderr index 661d667eb9a54..43eacd5413f1c 100644 --- a/tests/ui/rust-2018/uniform-paths/macro-rules.stderr +++ b/tests/ui/rust-2018/uniform-paths/macro-rules.stderr @@ -9,6 +9,10 @@ help: consider adding a `#[macro_export]` to the macro in the imported module | LL | macro_rules! legacy_macro { () => () } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: in case you want to use the macro within this crate only, reduce the visibility to `pub(crate)` + | +LL | pub(crate) use legacy_macro as _; + | +++++++ error: aborting due to 1 previous error diff --git a/tests/ui/issues/issue-8578.rs b/tests/ui/static/static-struct-with-option-8578.rs similarity index 90% rename from tests/ui/issues/issue-8578.rs rename to tests/ui/static/static-struct-with-option-8578.rs index 9baa2f70a02db..d490a3f50b419 100644 --- a/tests/ui/issues/issue-8578.rs +++ b/tests/ui/static/static-struct-with-option-8578.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/8578 //@ check-pass #![allow(dead_code)] #![allow(non_camel_case_types)] diff --git a/tests/ui/issues/auxiliary/issue-8044.rs b/tests/ui/structs-enums/auxiliary/aux-8044.rs similarity index 100% rename from tests/ui/issues/auxiliary/issue-8044.rs rename to tests/ui/structs-enums/auxiliary/aux-8044.rs diff --git a/tests/ui/structs-enums/struct-and-enum-usage-8044.rs b/tests/ui/structs-enums/struct-and-enum-usage-8044.rs new file mode 100644 index 0000000000000..9b544f33f1c2d --- /dev/null +++ b/tests/ui/structs-enums/struct-and-enum-usage-8044.rs @@ -0,0 +1,10 @@ +// https://github.com/rust-lang/rust/issues/8044 +//@ run-pass +//@ aux-build:aux-8044.rs + +extern crate aux_8044 as minimal; +use minimal::{BTree, leaf}; + +pub fn main() { + BTree:: { node: leaf(1) }; +} diff --git a/tests/ui/issues/issue-8783.rs b/tests/ui/structs/destructuring-struct-type-inference-8783.rs similarity index 88% rename from tests/ui/issues/issue-8783.rs rename to tests/ui/structs/destructuring-struct-type-inference-8783.rs index d0ff79f8ac800..60bc4bf3289e5 100644 --- a/tests/ui/issues/issue-8783.rs +++ b/tests/ui/structs/destructuring-struct-type-inference-8783.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/8783 //@ run-pass #![allow(unused_variables)] diff --git a/tests/ui/issues/issue-83048.rs b/tests/ui/thir-print/break-outside-loop-error-83048.rs similarity index 72% rename from tests/ui/issues/issue-83048.rs rename to tests/ui/thir-print/break-outside-loop-error-83048.rs index 6c941133a152c..6dcebd77c27b2 100644 --- a/tests/ui/issues/issue-83048.rs +++ b/tests/ui/thir-print/break-outside-loop-error-83048.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/83048 //@ compile-flags: -Z unpretty=thir-tree pub fn main() { diff --git a/tests/ui/issues/issue-83048.stderr b/tests/ui/thir-print/break-outside-loop-error-83048.stderr similarity index 83% rename from tests/ui/issues/issue-83048.stderr rename to tests/ui/thir-print/break-outside-loop-error-83048.stderr index 672bf69a7325b..65a08e62e3df6 100644 --- a/tests/ui/issues/issue-83048.stderr +++ b/tests/ui/thir-print/break-outside-loop-error-83048.stderr @@ -1,5 +1,5 @@ error[E0268]: `break` outside of a loop or labeled block - --> $DIR/issue-83048.rs:4:5 + --> $DIR/break-outside-loop-error-83048.rs:5:5 | LL | break; | ^^^^^ cannot `break` outside of a loop or labeled block diff --git a/tests/ui/issues/issue-87707.rs b/tests/ui/track-diagnostics/track-caller-for-once-87707.rs similarity index 87% rename from tests/ui/issues/issue-87707.rs rename to tests/ui/track-diagnostics/track-caller-for-once-87707.rs index a0da8a740ac39..9b450943f5d7a 100644 --- a/tests/ui/issues/issue-87707.rs +++ b/tests/ui/track-diagnostics/track-caller-for-once-87707.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/87707 // test for #87707 //@ edition:2018 //@ run-fail diff --git a/tests/ui/issues/issue-87707.run.stderr b/tests/ui/track-diagnostics/track-caller-for-once-87707.run.stderr similarity index 50% rename from tests/ui/issues/issue-87707.run.stderr rename to tests/ui/track-diagnostics/track-caller-for-once-87707.run.stderr index 8485c0578b82c..093df62836bfa 100644 --- a/tests/ui/issues/issue-87707.run.stderr +++ b/tests/ui/track-diagnostics/track-caller-for-once-87707.run.stderr @@ -1,7 +1,7 @@ -thread 'main' ($TID) panicked at $DIR/issue-87707.rs:14:24: +thread 'main' ($TID) panicked at $DIR/track-caller-for-once-87707.rs:15:24: Here Once instance is poisoned. note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread 'main' ($TID) panicked at $DIR/issue-87707.rs:16:7: +thread 'main' ($TID) panicked at $DIR/track-caller-for-once-87707.rs:17:7: Once instance has previously been poisoned diff --git a/tests/ui/issues/issue-87199.rs b/tests/ui/trait-bounds/relaxed-bounds-assumed-unsized-87199.rs similarity index 94% rename from tests/ui/issues/issue-87199.rs rename to tests/ui/trait-bounds/relaxed-bounds-assumed-unsized-87199.rs index dd9dfc74ca352..f3baa4b1feb8d 100644 --- a/tests/ui/issues/issue-87199.rs +++ b/tests/ui/trait-bounds/relaxed-bounds-assumed-unsized-87199.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/87199 // Regression test for issue #87199, where attempting to relax a bound // other than the only supported `?Sized` would still cause the compiler // to assume that the `Sized` bound was relaxed. diff --git a/tests/ui/issues/issue-87199.stderr b/tests/ui/trait-bounds/relaxed-bounds-assumed-unsized-87199.stderr similarity index 80% rename from tests/ui/issues/issue-87199.stderr rename to tests/ui/trait-bounds/relaxed-bounds-assumed-unsized-87199.stderr index 8a930a3d704c1..16223676c067e 100644 --- a/tests/ui/issues/issue-87199.stderr +++ b/tests/ui/trait-bounds/relaxed-bounds-assumed-unsized-87199.stderr @@ -1,23 +1,23 @@ error: bound modifier `?` can only be applied to `Sized` - --> $DIR/issue-87199.rs:8:11 + --> $DIR/relaxed-bounds-assumed-unsized-87199.rs:9:11 | LL | fn arg(_: T) {} | ^^^^^ error: bound modifier `?` can only be applied to `Sized` - --> $DIR/issue-87199.rs:10:15 + --> $DIR/relaxed-bounds-assumed-unsized-87199.rs:11:15 | LL | fn ref_arg(_: &T) {} | ^^^^^ error: bound modifier `?` can only be applied to `Sized` - --> $DIR/issue-87199.rs:12:40 + --> $DIR/relaxed-bounds-assumed-unsized-87199.rs:13:40 | LL | fn ret() -> impl Iterator + ?Send { std::iter::empty() } | ^^^^^ error: bound modifier `?` can only be applied to `Sized` - --> $DIR/issue-87199.rs:12:40 + --> $DIR/relaxed-bounds-assumed-unsized-87199.rs:13:40 | LL | fn ret() -> impl Iterator + ?Send { std::iter::empty() } | ^^^^^ @@ -25,14 +25,14 @@ LL | fn ret() -> impl Iterator + ?Send { std::iter::empty() } = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the size for values of type `[i32]` cannot be known at compilation time - --> $DIR/issue-87199.rs:19:15 + --> $DIR/relaxed-bounds-assumed-unsized-87199.rs:20:15 | LL | ref_arg::<[i32]>(&[5]); | ^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[i32]` note: required by an implicit `Sized` bound in `ref_arg` - --> $DIR/issue-87199.rs:10:12 + --> $DIR/relaxed-bounds-assumed-unsized-87199.rs:11:12 | LL | fn ref_arg(_: &T) {} | ^ required by the implicit `Sized` requirement on this type parameter in `ref_arg` diff --git a/tests/ui/issues/auxiliary/issue-9123.rs b/tests/ui/traits/auxiliary/aux-9123.rs similarity index 100% rename from tests/ui/issues/auxiliary/issue-9123.rs rename to tests/ui/traits/auxiliary/aux-9123.rs diff --git a/tests/ui/traits/default-method-fn-call-9123.rs b/tests/ui/traits/default-method-fn-call-9123.rs new file mode 100644 index 0000000000000..266b95ca960c5 --- /dev/null +++ b/tests/ui/traits/default-method-fn-call-9123.rs @@ -0,0 +1,7 @@ +// https://github.com/rust-lang/rust/issues/9123 +//@ run-pass +//@ aux-build:aux-9123.rs + +extern crate aux_9123; + +pub fn main() {} diff --git a/tests/ui/issues/issue-8249.rs b/tests/ui/traits/mut-trait-in-struct-8249.rs similarity index 80% rename from tests/ui/issues/issue-8249.rs rename to tests/ui/traits/mut-trait-in-struct-8249.rs index 2364fc14d31ac..b6dcd848b8b34 100644 --- a/tests/ui/issues/issue-8249.rs +++ b/tests/ui/traits/mut-trait-in-struct-8249.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/8249 //@ run-pass #![allow(dead_code)] diff --git a/tests/ui/traits/negative-bounds/negative-metasized.current.stderr b/tests/ui/traits/negative-bounds/negative-metasized.current.stderr new file mode 100644 index 0000000000000..4ff516513364a --- /dev/null +++ b/tests/ui/traits/negative-bounds/negative-metasized.current.stderr @@ -0,0 +1,39 @@ +error[E0277]: the trait bound `T: !MetaSized` is not satisfied + --> $DIR/negative-metasized.rs:12:11 + | +LL | foo::(); + | ^ the trait bound `T: !MetaSized` is not satisfied + | +note: required by a bound in `foo` + --> $DIR/negative-metasized.rs:9:11 + | +LL | fn foo() {} + | ^^^^^^^^^^ required by this bound in `foo` + +error[E0277]: the trait bound `(): !MetaSized` is not satisfied + --> $DIR/negative-metasized.rs:17:11 + | +LL | foo::<()>(); + | ^^ the trait bound `(): !MetaSized` is not satisfied + | +note: required by a bound in `foo` + --> $DIR/negative-metasized.rs:9:11 + | +LL | fn foo() {} + | ^^^^^^^^^^ required by this bound in `foo` + +error[E0277]: the trait bound `str: !MetaSized` is not satisfied + --> $DIR/negative-metasized.rs:19:11 + | +LL | foo::(); + | ^^^ the trait bound `str: !MetaSized` is not satisfied + | +note: required by a bound in `foo` + --> $DIR/negative-metasized.rs:9:11 + | +LL | fn foo() {} + | ^^^^^^^^^^ required by this bound in `foo` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/negative-bounds/negative-metasized.next.stderr b/tests/ui/traits/negative-bounds/negative-metasized.next.stderr new file mode 100644 index 0000000000000..4ff516513364a --- /dev/null +++ b/tests/ui/traits/negative-bounds/negative-metasized.next.stderr @@ -0,0 +1,39 @@ +error[E0277]: the trait bound `T: !MetaSized` is not satisfied + --> $DIR/negative-metasized.rs:12:11 + | +LL | foo::(); + | ^ the trait bound `T: !MetaSized` is not satisfied + | +note: required by a bound in `foo` + --> $DIR/negative-metasized.rs:9:11 + | +LL | fn foo() {} + | ^^^^^^^^^^ required by this bound in `foo` + +error[E0277]: the trait bound `(): !MetaSized` is not satisfied + --> $DIR/negative-metasized.rs:17:11 + | +LL | foo::<()>(); + | ^^ the trait bound `(): !MetaSized` is not satisfied + | +note: required by a bound in `foo` + --> $DIR/negative-metasized.rs:9:11 + | +LL | fn foo() {} + | ^^^^^^^^^^ required by this bound in `foo` + +error[E0277]: the trait bound `str: !MetaSized` is not satisfied + --> $DIR/negative-metasized.rs:19:11 + | +LL | foo::(); + | ^^^ the trait bound `str: !MetaSized` is not satisfied + | +note: required by a bound in `foo` + --> $DIR/negative-metasized.rs:9:11 + | +LL | fn foo() {} + | ^^^^^^^^^^ required by this bound in `foo` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/negative-bounds/negative-metasized.rs b/tests/ui/traits/negative-bounds/negative-metasized.rs new file mode 100644 index 0000000000000..479037be852f4 --- /dev/null +++ b/tests/ui/traits/negative-bounds/negative-metasized.rs @@ -0,0 +1,21 @@ +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +#![feature(negative_bounds)] +#![feature(sized_hierarchy)] + +use std::marker::MetaSized; + +fn foo() {} + +fn bar() { + foo::(); + //~^ ERROR the trait bound `T: !MetaSized` is not satisfied +} + +fn main() { + foo::<()>(); + //~^ ERROR the trait bound `(): !MetaSized` is not satisfied + foo::(); + //~^ ERROR the trait bound `str: !MetaSized` is not satisfied +} diff --git a/tests/ui/issues/issue-7673-cast-generically-implemented-trait.rs b/tests/ui/traits/polymorphic-trait-creation-7673.rs similarity index 85% rename from tests/ui/issues/issue-7673-cast-generically-implemented-trait.rs rename to tests/ui/traits/polymorphic-trait-creation-7673.rs index edba3284e3175..643818ffe1e52 100644 --- a/tests/ui/issues/issue-7673-cast-generically-implemented-trait.rs +++ b/tests/ui/traits/polymorphic-trait-creation-7673.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/7673 //@ check-pass #![allow(dead_code)] diff --git a/tests/ui/issues/issue-8171-default-method-self-inherit-builtin-trait.rs b/tests/ui/traits/self-implements-kinds-in-default-methods-8171.rs similarity index 85% rename from tests/ui/issues/issue-8171-default-method-self-inherit-builtin-trait.rs rename to tests/ui/traits/self-implements-kinds-in-default-methods-8171.rs index 6a03404cdca71..59ea62c7690ee 100644 --- a/tests/ui/issues/issue-8171-default-method-self-inherit-builtin-trait.rs +++ b/tests/ui/traits/self-implements-kinds-in-default-methods-8171.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/8171 //@ check-pass #![allow(dead_code)] diff --git a/tests/ui/issues/issue-7563.rs b/tests/ui/traits/trait-implementation-and-usage-7563.rs similarity index 91% rename from tests/ui/issues/issue-7563.rs rename to tests/ui/traits/trait-implementation-and-usage-7563.rs index 9ee8857b99960..8cfc7a14ffe66 100644 --- a/tests/ui/issues/issue-7563.rs +++ b/tests/ui/traits/trait-implementation-and-usage-7563.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/7563 //@ run-pass #![allow(dead_code)] trait IDummy { diff --git a/tests/ui/type-alias-impl-trait/higher_kinded_params3.rs b/tests/ui/type-alias-impl-trait/higher_kinded_params3.rs index 4fb2e60b5c5a3..04208fadddecf 100644 --- a/tests/ui/type-alias-impl-trait/higher_kinded_params3.rs +++ b/tests/ui/type-alias-impl-trait/higher_kinded_params3.rs @@ -24,8 +24,7 @@ type Successors<'a> = impl std::fmt::Debug + 'a; impl Terminator { #[define_opaque(Successors, Tait)] fn successors(&self, mut f: for<'x> fn(&'x ()) -> <&'x A as B>::C) -> Successors<'_> { - f = g; - //~^ ERROR mismatched types + f = g; //~ ERROR expected generic lifetime parameter, found `'x` } } diff --git a/tests/ui/type-alias-impl-trait/higher_kinded_params3.stderr b/tests/ui/type-alias-impl-trait/higher_kinded_params3.stderr index 558792987f31c..8e6778bdd0b53 100644 --- a/tests/ui/type-alias-impl-trait/higher_kinded_params3.stderr +++ b/tests/ui/type-alias-impl-trait/higher_kinded_params3.stderr @@ -1,15 +1,12 @@ -error[E0308]: mismatched types +error[E0792]: expected generic lifetime parameter, found `'x` --> $DIR/higher_kinded_params3.rs:27:9 | LL | type Tait<'a> = impl std::fmt::Debug + 'a; - | ------------------------- the expected opaque type + | -- this generic parameter must be used with a generic lifetime parameter ... LL | f = g; - | ^^^^^ one type is more general than the other - | - = note: expected fn pointer `for<'x> fn(&'x ()) -> Tait<'x>` - found fn pointer `for<'a> fn(&'a ()) -> &'a ()` + | ^^^^^ error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0308`. +For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/type-alias-impl-trait/hkl_forbidden3.rs b/tests/ui/type-alias-impl-trait/hkl_forbidden3.rs index c7f04dc07bb12..ba75b114a1188 100644 --- a/tests/ui/type-alias-impl-trait/hkl_forbidden3.rs +++ b/tests/ui/type-alias-impl-trait/hkl_forbidden3.rs @@ -8,7 +8,7 @@ fn foo<'a>(x: &'a ()) -> &'a () { #[define_opaque(Opaque)] fn test() -> for<'a> fn(&'a ()) -> Opaque<'a> { - foo //~ ERROR: mismatched types + foo //~ ERROR: expected generic lifetime parameter, found `'a` } fn main() {} diff --git a/tests/ui/type-alias-impl-trait/hkl_forbidden3.stderr b/tests/ui/type-alias-impl-trait/hkl_forbidden3.stderr index b8c04185a7d14..d699059e3972c 100644 --- a/tests/ui/type-alias-impl-trait/hkl_forbidden3.stderr +++ b/tests/ui/type-alias-impl-trait/hkl_forbidden3.stderr @@ -1,15 +1,12 @@ -error[E0308]: mismatched types +error[E0792]: expected generic lifetime parameter, found `'a` --> $DIR/hkl_forbidden3.rs:11:5 | LL | type Opaque<'a> = impl Sized + 'a; - | --------------- the expected opaque type + | -- this generic parameter must be used with a generic lifetime parameter ... LL | foo - | ^^^ one type is more general than the other - | - = note: expected fn pointer `for<'a> fn(&'a ()) -> Opaque<'a>` - found fn pointer `for<'a> fn(&'a ()) -> &'a ()` + | ^^^ error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0308`. +For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/issues/issue-8767.rs b/tests/ui/typeck/impl-for-nonexistent-type-error-8767.rs similarity index 59% rename from tests/ui/issues/issue-8767.rs rename to tests/ui/typeck/impl-for-nonexistent-type-error-8767.rs index 972101a0bc3ee..005c676ed39b3 100644 --- a/tests/ui/issues/issue-8767.rs +++ b/tests/ui/typeck/impl-for-nonexistent-type-error-8767.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/8767 impl B { //~ ERROR cannot find type `B` in this scope } diff --git a/tests/ui/issues/issue-8767.stderr b/tests/ui/typeck/impl-for-nonexistent-type-error-8767.stderr similarity index 79% rename from tests/ui/issues/issue-8767.stderr rename to tests/ui/typeck/impl-for-nonexistent-type-error-8767.stderr index 66141628e28d2..0e37391a00f7b 100644 --- a/tests/ui/issues/issue-8767.stderr +++ b/tests/ui/typeck/impl-for-nonexistent-type-error-8767.stderr @@ -1,5 +1,5 @@ error[E0412]: cannot find type `B` in this scope - --> $DIR/issue-8767.rs:1:6 + --> $DIR/impl-for-nonexistent-type-error-8767.rs:2:6 | LL | impl B { | ^ not found in this scope diff --git a/triagebot.toml b/triagebot.toml index 2f31a30019bce..eaa50cc8fcb03 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -1003,11 +1003,12 @@ cc = ["@calebzulawski", "@programmerjake"] [mentions."library/core/src/unicode/unicode_data.rs"] message = """ -`library/core/src/unicode/unicode_data.rs` is generated by -`src/tools/unicode-table-generator` via `./x run -src/tools/unicode-table-generator`. If you want to modify `unicode_data.rs`, -please modify the tool then regenerate the library source file with the tool -instead of editing the library source file manually. +`library/core/src/unicode/unicode_data.rs` is generated by the \ +`src/tools/unicode-table-generator` tool. + +If you want to modify `unicode_data.rs`, please modify the tool then regenerate the library \ +source file via `./x run src/tools/unicode-table-generator` instead of editing \ +`unicode_data.rs` manually. """ [mentions."src/librustdoc/html/static"] @@ -1070,7 +1071,7 @@ cc = ["@rust-lang/rustfmt"] [mentions."compiler/rustc_middle/src/mir/syntax.rs"] message = "This PR changes MIR" -cc = ["@oli-obk", "@RalfJung", "@JakobDegen", "@davidtwco", "@vakaras"] +cc = ["@oli-obk", "@RalfJung", "@JakobDegen", "@vakaras"] [mentions."compiler/rustc_error_messages"] message = "`rustc_error_messages` was changed" @@ -1404,7 +1405,6 @@ arena = [ "@spastorino", ] mir = [ - "@davidtwco", "@oli-obk", "@matthewjasper", "@saethlin", @@ -1591,6 +1591,8 @@ days-threshold = 28 # Prevents mentions in commits to avoid users being spammed # Documentation at: https://forge.rust-lang.org/triagebot/no-mentions.html [no-mentions] +# Subtree update authors can't fix it, no point in warning. +exclude-titles = ["subtree update"] # Allow members to formally register concerns (`@rustbot concern my concern`) # Documentation at: https://forge.rust-lang.org/triagebot/concern.html diff --git a/typos.toml b/typos.toml index 317aafc861565..b0ff48f8fa28b 100644 --- a/typos.toml +++ b/typos.toml @@ -33,6 +33,7 @@ misformed = "misformed" targetting = "targetting" publically = "publically" clonable = "clonable" +moreso = "moreso" # this can be valid word, depends on dictionary edition #matcheable = "matcheable"