diff options
| author | bors <bors@rust-lang.org> | 2024-06-25 22:33:35 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-06-25 22:33:35 +0000 |
| commit | fc94ce216ede9f89a1032b13e2563ddba0ae4194 (patch) | |
| tree | e520b53ebf7d874cc6dfdc2aa17257bb9ff8dac8 | |
| parent | 8a8b357bf11ed4f7ba28916c5975f74dde55f0ea (diff) | |
| parent | 8f688d2634b10da6c6a91a57bf8f39557c333b31 (diff) | |
| download | rust-fc94ce216ede9f89a1032b13e2563ddba0ae4194.tar.gz rust-fc94ce216ede9f89a1032b13e2563ddba0ae4194.zip | |
Auto merge of #3711 - saethlin:rustup, r=saethlin
Manual Rustup This bumps us to a rustc commit that doesn't have the chatty `./miri fmt` reported in https://rust-lang.zulipchat.com/#narrow/stream/269128-miri/topic/.22rewriting.20static.22.20printed.20during.20.2E.2Fmiri.20build
901 files changed, 8244 insertions, 7017 deletions
diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index a6662d4e0e4..31c66a56bea 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -427,11 +427,13 @@ pub struct Size { raw: u64, } -// Safety: Ord is implement as just comparing numerical values and numerical values -// are not changed by (de-)serialization. #[cfg(feature = "nightly")] -unsafe impl StableOrd for Size { +impl StableOrd for Size { const CAN_USE_UNSTABLE_SORT: bool = true; + + // `Ord` is implemented as just comparing numerical values and numerical values + // are not changed by (de-)serialization. + const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } // This is debug-printed a lot in larger structs, don't waste too much space there diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index c9d2f5c779b..ed8bf58eb23 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -429,10 +429,10 @@ pub fn noop_flat_map_pat_field<T: MutVisitor>( ) -> SmallVec<[PatField; 1]> { let PatField { attrs, id, ident, is_placeholder: _, is_shorthand: _, pat, span } = &mut fp; vis.visit_id(id); + visit_attrs(attrs, vis); vis.visit_ident(ident); vis.visit_pat(pat); vis.visit_span(span); - visit_attrs(attrs, vis); smallvec![fp] } @@ -443,8 +443,8 @@ fn noop_visit_use_tree<T: MutVisitor>(use_tree: &mut UseTree, vis: &mut T) { UseTreeKind::Simple(rename) => visit_opt(rename, |rename| vis.visit_ident(rename)), UseTreeKind::Nested { items, .. } => { for (tree, id) in items { - vis.visit_use_tree(tree); vis.visit_id(id); + vis.visit_use_tree(tree); } } UseTreeKind::Glob => {} @@ -454,8 +454,8 @@ fn noop_visit_use_tree<T: MutVisitor>(use_tree: &mut UseTree, vis: &mut T) { pub fn noop_flat_map_arm<T: MutVisitor>(mut arm: Arm, vis: &mut T) -> SmallVec<[Arm; 1]> { let Arm { attrs, pat, guard, body, span, id, is_placeholder: _ } = &mut arm; - visit_attrs(attrs, vis); vis.visit_id(id); + visit_attrs(attrs, vis); vis.visit_pat(pat); visit_opt(guard, |guard| vis.visit_expr(guard)); visit_opt(body, |body| vis.visit_expr(body)); @@ -548,10 +548,10 @@ pub fn noop_flat_map_variant<T: MutVisitor>( visitor: &mut T, ) -> SmallVec<[Variant; 1]> { let Variant { ident, vis, attrs, id, data, disr_expr, span, is_placeholder: _ } = &mut variant; + visitor.visit_id(id); + visit_attrs(attrs, visitor); visitor.visit_ident(ident); visitor.visit_vis(vis); - visit_attrs(attrs, visitor); - visitor.visit_id(id); visitor.visit_variant_data(data); visit_opt(disr_expr, |disr_expr| visitor.visit_anon_const(disr_expr)); visitor.visit_span(span); @@ -565,8 +565,8 @@ fn noop_visit_ident<T: MutVisitor>(Ident { name: _, span }: &mut Ident, vis: &mu fn noop_visit_path<T: MutVisitor>(Path { segments, span, tokens }: &mut Path, vis: &mut T) { vis.visit_span(span); for PathSegment { ident, id, args } in segments { - vis.visit_ident(ident); vis.visit_id(id); + vis.visit_ident(ident); visit_opt(args, |args| vis.visit_generic_args(args)); } visit_lazy_tts(tokens, vis); @@ -620,6 +620,7 @@ fn noop_visit_parenthesized_parameter_data<T: MutVisitor>( fn noop_visit_local<T: MutVisitor>(local: &mut P<Local>, vis: &mut T) { let Local { id, pat, ty, kind, span, colon_sp, attrs, tokens } = local.deref_mut(); vis.visit_id(id); + visit_attrs(attrs, vis); vis.visit_pat(pat); visit_opt(ty, |ty| vis.visit_ty(ty)); match kind { @@ -634,7 +635,6 @@ fn noop_visit_local<T: MutVisitor>(local: &mut P<Local>, vis: &mut T) { } vis.visit_span(span); visit_opt(colon_sp, |sp| vis.visit_span(sp)); - visit_attrs(attrs, vis); visit_lazy_tts(tokens, vis); } @@ -894,9 +894,9 @@ fn noop_visit_coroutine_kind<T: MutVisitor>(coroutine_kind: &mut CoroutineKind, CoroutineKind::Async { span, closure_id, return_impl_trait_id } | CoroutineKind::Gen { span, closure_id, return_impl_trait_id } | CoroutineKind::AsyncGen { span, closure_id, return_impl_trait_id } => { - vis.visit_span(span); vis.visit_id(closure_id); vis.visit_id(return_impl_trait_id); + vis.visit_span(span); } } } @@ -932,8 +932,8 @@ fn noop_visit_precise_capturing_arg<T: MutVisitor>(arg: &mut PreciseCapturingArg vis.visit_lifetime(lt); } PreciseCapturingArg::Arg(path, id) => { - vis.visit_path(path); vis.visit_id(id); + vis.visit_path(path); } } } @@ -944,11 +944,11 @@ pub fn noop_flat_map_generic_param<T: MutVisitor>( ) -> SmallVec<[GenericParam; 1]> { let GenericParam { id, ident, attrs, bounds, kind, colon_span, is_placeholder: _ } = &mut param; vis.visit_id(id); + visit_attrs(attrs, vis); vis.visit_ident(ident); if let Some(colon_span) = colon_span { vis.visit_span(colon_span); } - visit_attrs(attrs, vis); visit_vec(bounds, |bound| noop_visit_param_bound(bound, vis)); match kind { GenericParamKind::Lifetime => {} @@ -1015,16 +1015,16 @@ fn noop_visit_variant_data<T: MutVisitor>(vdata: &mut VariantData, vis: &mut T) fields.flat_map_in_place(|field| vis.flat_map_field_def(field)); } VariantData::Tuple(fields, id) => { - fields.flat_map_in_place(|field| vis.flat_map_field_def(field)); vis.visit_id(id); + fields.flat_map_in_place(|field| vis.flat_map_field_def(field)); } VariantData::Unit(id) => vis.visit_id(id), } } fn noop_visit_trait_ref<T: MutVisitor>(TraitRef { path, ref_id }: &mut TraitRef, vis: &mut T) { - vis.visit_path(path); vis.visit_id(ref_id); + vis.visit_path(path); } fn noop_visit_poly_trait_ref<T: MutVisitor>(p: &mut PolyTraitRef, vis: &mut T) { @@ -1039,12 +1039,12 @@ pub fn noop_flat_map_field_def<T: MutVisitor>( visitor: &mut T, ) -> SmallVec<[FieldDef; 1]> { let FieldDef { span, ident, vis, id, ty, attrs, is_placeholder: _ } = &mut fd; + visitor.visit_id(id); + visit_attrs(attrs, visitor); visitor.visit_span(span); visit_opt(ident, |ident| visitor.visit_ident(ident)); visitor.visit_vis(vis); - visitor.visit_id(id); visitor.visit_ty(ty); - visit_attrs(attrs, visitor); smallvec![fd] } @@ -1053,11 +1053,11 @@ pub fn noop_flat_map_expr_field<T: MutVisitor>( vis: &mut T, ) -> SmallVec<[ExprField; 1]> { let ExprField { ident, expr, span, is_shorthand: _, attrs, id, is_placeholder: _ } = &mut f; + vis.visit_id(id); + visit_attrs(attrs, vis); vis.visit_ident(ident); vis.visit_expr(expr); - vis.visit_id(id); vis.visit_span(span); - visit_attrs(attrs, vis); smallvec![f] } @@ -1429,6 +1429,8 @@ pub fn noop_visit_expr<T: MutVisitor>( Expr { kind, id, span, attrs, tokens }: &mut Expr, vis: &mut T, ) { + vis.visit_id(id); + visit_attrs(attrs, vis); match kind { ExprKind::Array(exprs) => visit_thin_exprs(exprs, vis), ExprKind::ConstBlock(anon_const) => { @@ -1449,8 +1451,8 @@ pub fn noop_visit_expr<T: MutVisitor>( args: call_args, span, }) => { - vis.visit_ident(ident); vis.visit_id(id); + vis.visit_ident(ident); visit_opt(seg_args, |args| vis.visit_generic_args(args)); vis.visit_method_receiver_expr(receiver); visit_thin_exprs(call_args, vis); @@ -1601,9 +1603,7 @@ pub fn noop_visit_expr<T: MutVisitor>( ExprKind::TryBlock(body) => vis.visit_block(body), ExprKind::Lit(_) | ExprKind::IncludedBytes(..) | ExprKind::Err(_) | ExprKind::Dummy => {} } - vis.visit_id(id); vis.visit_span(span); - visit_attrs(attrs, vis); visit_lazy_tts(tokens, vis); } @@ -1645,8 +1645,8 @@ fn noop_flat_map_stmt_kind<T: MutVisitor>(kind: StmtKind, vis: &mut T) -> SmallV StmtKind::Empty => smallvec![StmtKind::Empty], StmtKind::MacCall(mut mac) => { let MacCallStmt { mac: mac_, style: _, attrs, tokens } = mac.deref_mut(); - vis.visit_mac_call(mac_); visit_attrs(attrs, vis); + vis.visit_mac_call(mac_); visit_lazy_tts(tokens, vis); smallvec![StmtKind::MacCall(mac)] } @@ -1657,8 +1657,8 @@ fn noop_visit_vis<T: MutVisitor>(visibility: &mut Visibility, vis: &mut T) { match &mut visibility.kind { VisibilityKind::Public | VisibilityKind::Inherited => {} VisibilityKind::Restricted { path, id, shorthand: _ } => { - vis.visit_path(path); vis.visit_id(id); + vis.visit_path(path); } } vis.visit_span(&mut visibility.span); diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index ce38a67ea69..e2ef0542bf9 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -298,8 +298,8 @@ pub trait Visitor<'ast>: Sized { } pub fn walk_crate<'a, V: Visitor<'a>>(visitor: &mut V, krate: &'a Crate) -> V::Result { - walk_list!(visitor, visit_item, &krate.items); walk_list!(visitor, visit_attribute, &krate.attrs); + walk_list!(visitor, visit_item, &krate.items); V::Result::output() } @@ -462,25 +462,25 @@ pub fn walk_variant<'a, V: Visitor<'a>>(visitor: &mut V, variant: &'a Variant) - where V: Visitor<'a>, { + walk_list!(visitor, visit_attribute, &variant.attrs); try_visit!(visitor.visit_ident(variant.ident)); try_visit!(visitor.visit_vis(&variant.vis)); try_visit!(visitor.visit_variant_data(&variant.data)); visit_opt!(visitor, visit_variant_discr, &variant.disr_expr); - walk_list!(visitor, visit_attribute, &variant.attrs); V::Result::output() } pub fn walk_expr_field<'a, V: Visitor<'a>>(visitor: &mut V, f: &'a ExprField) -> V::Result { + walk_list!(visitor, visit_attribute, &f.attrs); try_visit!(visitor.visit_expr(&f.expr)); try_visit!(visitor.visit_ident(f.ident)); - walk_list!(visitor, visit_attribute, &f.attrs); V::Result::output() } pub fn walk_pat_field<'a, V: Visitor<'a>>(visitor: &mut V, fp: &'a PatField) -> V::Result { + walk_list!(visitor, visit_attribute, &fp.attrs); try_visit!(visitor.visit_ident(fp.ident)); try_visit!(visitor.visit_pat(&fp.pat)); - walk_list!(visitor, visit_attribute, &fp.attrs); V::Result::output() } @@ -722,8 +722,8 @@ pub fn walk_generic_param<'a, V: Visitor<'a>>( visitor: &mut V, param: &'a GenericParam, ) -> V::Result { - try_visit!(visitor.visit_ident(param.ident)); walk_list!(visitor, visit_attribute, ¶m.attrs); + try_visit!(visitor.visit_ident(param.ident)); walk_list!(visitor, visit_param_bound, ¶m.bounds, BoundKind::Bound); match ¶m.kind { GenericParamKind::Lifetime => (), @@ -882,10 +882,10 @@ pub fn walk_assoc_item<'a, V: Visitor<'a>>( ctxt: AssocCtxt, ) -> V::Result { let &Item { id: _, span: _, ident, ref vis, ref attrs, ref kind, tokens: _ } = item; + walk_list!(visitor, visit_attribute, attrs); try_visit!(visitor.visit_vis(vis)); try_visit!(visitor.visit_ident(ident)); try_visit!(kind.walk(item, ctxt, visitor)); - walk_list!(visitor, visit_attribute, attrs); V::Result::output() } @@ -898,10 +898,10 @@ pub fn walk_struct_def<'a, V: Visitor<'a>>( } pub fn walk_field_def<'a, V: Visitor<'a>>(visitor: &mut V, field: &'a FieldDef) -> V::Result { + walk_list!(visitor, visit_attribute, &field.attrs); try_visit!(visitor.visit_vis(&field.vis)); visit_opt!(visitor, visit_ident, field.ident); try_visit!(visitor.visit_ty(&field.ty)); - walk_list!(visitor, visit_attribute, &field.attrs); V::Result::output() } @@ -918,8 +918,8 @@ pub fn walk_stmt<'a, V: Visitor<'a>>(visitor: &mut V, statement: &'a Stmt) -> V: StmtKind::Empty => {} StmtKind::MacCall(mac) => { let MacCallStmt { mac, attrs, style: _, tokens: _ } = &**mac; - try_visit!(visitor.visit_mac_call(mac)); walk_list!(visitor, visit_attribute, attrs); + try_visit!(visitor.visit_mac_call(mac)); } } V::Result::output() @@ -1141,10 +1141,10 @@ pub fn walk_param<'a, V: Visitor<'a>>(visitor: &mut V, param: &'a Param) -> V::R } pub fn walk_arm<'a, V: Visitor<'a>>(visitor: &mut V, arm: &'a Arm) -> V::Result { + walk_list!(visitor, visit_attribute, &arm.attrs); try_visit!(visitor.visit_pat(&arm.pat)); visit_opt!(visitor, visit_expr, &arm.guard); visit_opt!(visitor, visit_expr, &arm.body); - walk_list!(visitor, visit_attribute, &arm.attrs); V::Result::output() } diff --git a/compiler/rustc_borrowck/src/borrowck_errors.rs b/compiler/rustc_borrowck/src/borrowck_errors.rs index 8a2936c2657..f26f8711dd4 100644 --- a/compiler/rustc_borrowck/src/borrowck_errors.rs +++ b/compiler/rustc_borrowck/src/borrowck_errors.rs @@ -6,7 +6,7 @@ use rustc_middle::span_bug; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_span::Span; -impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { +impl<'tcx> crate::MirBorrowckCtxt<'_, '_, '_, 'tcx> { pub fn dcx(&self) -> DiagCtxtHandle<'tcx> { self.infcx.dcx() } diff --git a/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs index 5e10f14f31b..d46febffba8 100644 --- a/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs @@ -52,7 +52,7 @@ impl<'tcx> UniverseInfo<'tcx> { pub(crate) fn report_error( &self, - mbcx: &mut MirBorrowckCtxt<'_, 'tcx>, + mbcx: &mut MirBorrowckCtxt<'_, '_, '_, 'tcx>, placeholder: ty::PlaceholderRegion, error_element: RegionElement, cause: ObligationCause<'tcx>, @@ -151,7 +151,7 @@ trait TypeOpInfo<'tcx> { fn nice_error( &self, - mbcx: &mut MirBorrowckCtxt<'_, 'tcx>, + mbcx: &mut MirBorrowckCtxt<'_, '_, '_, 'tcx>, cause: ObligationCause<'tcx>, placeholder_region: ty::Region<'tcx>, error_region: Option<ty::Region<'tcx>>, @@ -160,7 +160,7 @@ trait TypeOpInfo<'tcx> { #[instrument(level = "debug", skip(self, mbcx))] fn report_error( &self, - mbcx: &mut MirBorrowckCtxt<'_, 'tcx>, + mbcx: &mut MirBorrowckCtxt<'_, '_, '_, 'tcx>, placeholder: ty::PlaceholderRegion, error_element: RegionElement, cause: ObligationCause<'tcx>, @@ -233,7 +233,7 @@ impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> { fn nice_error( &self, - mbcx: &mut MirBorrowckCtxt<'_, 'tcx>, + mbcx: &mut MirBorrowckCtxt<'_, '_, '_, 'tcx>, cause: ObligationCause<'tcx>, placeholder_region: ty::Region<'tcx>, error_region: Option<ty::Region<'tcx>>, @@ -270,7 +270,7 @@ where fn nice_error( &self, - mbcx: &mut MirBorrowckCtxt<'_, 'tcx>, + mbcx: &mut MirBorrowckCtxt<'_, '_, '_, 'tcx>, cause: ObligationCause<'tcx>, placeholder_region: ty::Region<'tcx>, error_region: Option<ty::Region<'tcx>>, @@ -310,7 +310,7 @@ impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> { fn nice_error( &self, - mbcx: &mut MirBorrowckCtxt<'_, 'tcx>, + mbcx: &mut MirBorrowckCtxt<'_, '_, '_, 'tcx>, cause: ObligationCause<'tcx>, placeholder_region: ty::Region<'tcx>, error_region: Option<ty::Region<'tcx>>, @@ -336,7 +336,7 @@ impl<'tcx> TypeOpInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tcx> { fn nice_error( &self, - mbcx: &mut MirBorrowckCtxt<'_, 'tcx>, + mbcx: &mut MirBorrowckCtxt<'_, '_, '_, 'tcx>, _cause: ObligationCause<'tcx>, placeholder_region: ty::Region<'tcx>, error_region: Option<ty::Region<'tcx>>, diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 197da3eb641..1cc7fee718e 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -73,7 +73,7 @@ enum StorageDeadOrDrop<'tcx> { Destructor(Ty<'tcx>), } -impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { +impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> { pub(crate) fn report_use_of_moved_or_uninitialized( &mut self, location: Location, @@ -4243,7 +4243,11 @@ enum AnnotatedBorrowFnSignature<'tcx> { impl<'tcx> AnnotatedBorrowFnSignature<'tcx> { /// Annotate the provided diagnostic with information about borrow from the fn signature that /// helps explain. - pub(crate) fn emit(&self, cx: &MirBorrowckCtxt<'_, 'tcx>, diag: &mut Diag<'_>) -> String { + pub(crate) fn emit( + &self, + cx: &MirBorrowckCtxt<'_, '_, '_, 'tcx>, + diag: &mut Diag<'_>, + ) -> String { match self { &AnnotatedBorrowFnSignature::Closure { argument_ty, argument_span } => { diag.span_label( diff --git a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs index e3ad92a5b2b..6165a718a30 100644 --- a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs +++ b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs @@ -389,7 +389,7 @@ impl<'tcx> BorrowExplanation<'tcx> { } } -impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { +impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> { fn free_region_constraint_info( &self, borrow_region: RegionVid, diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index 5b4269caccb..842ed38f1e2 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -69,7 +69,7 @@ pub(super) struct DescribePlaceOpt { pub(super) struct IncludingTupleField(pub(super) bool); -impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { +impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> { /// Adds a suggestion when a closure is invoked twice with a moved variable or when a closure /// is moved after being invoked. /// @@ -771,7 +771,7 @@ struct CapturedMessageOpt { maybe_reinitialized_locations_is_empty: bool, } -impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { +impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> { /// Finds the spans associated to a move or copy of move_place at location. pub(super) fn move_spans( &self, diff --git a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs index 5a7bca9ab03..12fa4c4f5ee 100644 --- a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs @@ -93,7 +93,7 @@ enum GroupedMoveError<'tcx> { }, } -impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { +impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> { pub(crate) fn report_move_errors(&mut self) { let grouped_errors = self.group_move_errors(); for error in grouped_errors { diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index e0b18536dd5..93fac3181ba 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -30,7 +30,7 @@ pub(crate) enum AccessKind { Mutate, } -impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { +impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> { pub(crate) fn report_mutability_error( &mut self, access_place: Place<'tcx>, diff --git a/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs b/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs index 1a42e551597..082111a642c 100644 --- a/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs +++ b/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs @@ -75,7 +75,7 @@ impl OutlivesSuggestionBuilder { /// Returns a name for the region if it is suggestable. See `region_name_is_suggestable`. fn region_vid_to_name( &self, - mbcx: &MirBorrowckCtxt<'_, '_>, + mbcx: &MirBorrowckCtxt<'_, '_, '_, '_>, region: RegionVid, ) -> Option<RegionName> { mbcx.give_region_a_name(region).filter(Self::region_name_is_suggestable) @@ -84,7 +84,7 @@ impl OutlivesSuggestionBuilder { /// Compiles a list of all suggestions to be printed in the final big suggestion. fn compile_all_suggestions( &self, - mbcx: &MirBorrowckCtxt<'_, '_>, + mbcx: &MirBorrowckCtxt<'_, '_, '_, '_>, ) -> SmallVec<[SuggestedConstraint; 2]> { let mut suggested = SmallVec::new(); @@ -160,7 +160,7 @@ impl OutlivesSuggestionBuilder { /// Emit an intermediate note on the given `Diag` if the involved regions are suggestable. pub(crate) fn intermediate_suggestion( &mut self, - mbcx: &MirBorrowckCtxt<'_, '_>, + mbcx: &MirBorrowckCtxt<'_, '_, '_, '_>, errci: &ErrorConstraintInfo<'_>, diag: &mut Diag<'_>, ) { @@ -179,7 +179,7 @@ impl OutlivesSuggestionBuilder { /// If there is a suggestion to emit, add a diagnostic to the buffer. This is the final /// suggestion including all collected constraints. - pub(crate) fn add_suggestion(&self, mbcx: &mut MirBorrowckCtxt<'_, '_>) { + pub(crate) fn add_suggestion(&self, mbcx: &mut MirBorrowckCtxt<'_, '_, '_, '_>) { // No constraints to add? Done. if self.constraints_to_add.is_empty() { debug!("No constraints to suggest."); diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs index c214c52880a..245ce790e49 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs @@ -160,7 +160,7 @@ pub struct ErrorConstraintInfo<'tcx> { pub(super) span: Span, } -impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { +impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> { /// Converts a region inference variable into a `ty::Region` that /// we can use for error reporting. If `r` is universally bound, /// then we use the name that we have on record for it. If `r` is diff --git a/compiler/rustc_borrowck/src/diagnostics/region_name.rs b/compiler/rustc_borrowck/src/diagnostics/region_name.rs index 25a0d40218b..356416d1a75 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_name.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_name.rs @@ -198,7 +198,7 @@ impl rustc_errors::IntoDiagArg for RegionName { } } -impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { +impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> { pub(crate) fn mir_def_id(&self) -> hir::def_id::LocalDefId { self.body.source.def_id().expect_local() } diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index b3b53e9cb79..69efee2fbdc 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -310,11 +310,11 @@ fn do_mir_borrowck<'tcx>( promoted_mbcx.report_move_errors(); diags = promoted_mbcx.diags; - struct MoveVisitor<'a, 'cx, 'tcx> { - ctxt: &'a mut MirBorrowckCtxt<'cx, 'tcx>, + struct MoveVisitor<'a, 'b, 'mir, 'cx, 'tcx> { + ctxt: &'a mut MirBorrowckCtxt<'b, 'mir, 'cx, 'tcx>, } - impl<'tcx> Visitor<'tcx> for MoveVisitor<'_, '_, 'tcx> { + impl<'tcx> Visitor<'tcx> for MoveVisitor<'_, '_, '_, '_, 'tcx> { fn visit_operand(&mut self, operand: &Operand<'tcx>, location: Location) { if let Operand::Move(place) = operand { self.ctxt.check_movable_place(location, *place); @@ -528,15 +528,15 @@ impl<'tcx> Deref for BorrowckInferCtxt<'tcx> { } } -struct MirBorrowckCtxt<'cx, 'tcx> { +struct MirBorrowckCtxt<'a, 'mir, 'cx, 'tcx> { infcx: &'cx BorrowckInferCtxt<'tcx>, param_env: ParamEnv<'tcx>, - body: &'cx Body<'tcx>, - move_data: &'cx MoveData<'tcx>, + body: &'mir Body<'tcx>, + move_data: &'a MoveData<'tcx>, /// Map from MIR `Location` to `LocationIndex`; created /// when MIR borrowck begins. - location_table: &'cx LocationTable, + location_table: &'a LocationTable, movable_coroutine: bool, /// This keeps track of whether local variables are free-ed when the function @@ -605,14 +605,16 @@ struct MirBorrowckCtxt<'cx, 'tcx> { // 2. loans made in overlapping scopes do not conflict // 3. assignments do not affect things loaned out as immutable // 4. moves do not affect things loaned out in any way -impl<'cx, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx, R> for MirBorrowckCtxt<'cx, 'tcx> { - type FlowState = Flows<'cx, 'tcx>; +impl<'mir, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'mir, 'tcx, R> + for MirBorrowckCtxt<'_, 'mir, '_, 'tcx> +{ + type FlowState = Flows<'mir, 'tcx>; fn visit_statement_before_primary_effect( &mut self, _results: &mut R, - flow_state: &Flows<'cx, 'tcx>, - stmt: &'cx Statement<'tcx>, + flow_state: &Flows<'mir, 'tcx>, + stmt: &'mir Statement<'tcx>, location: Location, ) { debug!("MirBorrowckCtxt::process_statement({:?}, {:?}): {:?}", location, stmt, flow_state); @@ -681,8 +683,8 @@ impl<'cx, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx, R> for MirBorro fn visit_terminator_before_primary_effect( &mut self, _results: &mut R, - flow_state: &Flows<'cx, 'tcx>, - term: &'cx Terminator<'tcx>, + flow_state: &Flows<'mir, 'tcx>, + term: &'mir Terminator<'tcx>, loc: Location, ) { debug!("MirBorrowckCtxt::process_terminator({:?}, {:?}): {:?}", loc, term, flow_state); @@ -792,8 +794,8 @@ impl<'cx, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx, R> for MirBorro fn visit_terminator_after_primary_effect( &mut self, _results: &mut R, - flow_state: &Flows<'cx, 'tcx>, - term: &'cx Terminator<'tcx>, + flow_state: &Flows<'mir, 'tcx>, + term: &'mir Terminator<'tcx>, loc: Location, ) { let span = term.source_info.span; @@ -969,8 +971,8 @@ impl InitializationRequiringAction { } } -impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { - fn body(&self) -> &'cx Body<'tcx> { +impl<'mir, 'tcx> MirBorrowckCtxt<'_, 'mir, '_, 'tcx> { + fn body(&self) -> &'mir Body<'tcx> { self.body } @@ -986,7 +988,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { place_span: (Place<'tcx>, Span), kind: (AccessDepth, ReadOrWrite), is_local_mutation_allowed: LocalMutationIsAllowed, - flow_state: &Flows<'cx, 'tcx>, + flow_state: &Flows<'mir, 'tcx>, ) { let (sd, rw) = kind; @@ -1036,7 +1038,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { place_span: (Place<'tcx>, Span), sd: AccessDepth, rw: ReadOrWrite, - flow_state: &Flows<'cx, 'tcx>, + flow_state: &Flows<'mir, 'tcx>, ) -> bool { let mut error_reported = false; let borrow_set = Rc::clone(&self.borrow_set); @@ -1177,7 +1179,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { location: Location, place_span: (Place<'tcx>, Span), kind: AccessDepth, - flow_state: &Flows<'cx, 'tcx>, + flow_state: &Flows<'mir, 'tcx>, ) { // Write of P[i] or *P requires P init'd. self.check_if_assigned_path_is_moved(location, place_span, flow_state); @@ -1194,8 +1196,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { fn consume_rvalue( &mut self, location: Location, - (rvalue, span): (&'cx Rvalue<'tcx>, Span), - flow_state: &Flows<'cx, 'tcx>, + (rvalue, span): (&'mir Rvalue<'tcx>, Span), + flow_state: &Flows<'mir, 'tcx>, ) { match rvalue { &Rvalue::Ref(_ /*rgn*/, bk, place) => { @@ -1452,8 +1454,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { fn consume_operand( &mut self, location: Location, - (operand, span): (&'cx Operand<'tcx>, Span), - flow_state: &Flows<'cx, 'tcx>, + (operand, span): (&'mir Operand<'tcx>, Span), + flow_state: &Flows<'mir, 'tcx>, ) { match *operand { Operand::Copy(place) => { @@ -1573,7 +1575,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } } - fn check_activations(&mut self, location: Location, span: Span, flow_state: &Flows<'cx, 'tcx>) { + fn check_activations( + &mut self, + location: Location, + span: Span, + flow_state: &Flows<'mir, 'tcx>, + ) { // Two-phase borrow support: For each activation that is newly // generated at this statement, check if it interferes with // another borrow. @@ -1736,7 +1743,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { location: Location, desired_action: InitializationRequiringAction, place_span: (PlaceRef<'tcx>, Span), - flow_state: &Flows<'cx, 'tcx>, + flow_state: &Flows<'mir, 'tcx>, ) { let maybe_uninits = &flow_state.uninits; @@ -1841,7 +1848,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { location: Location, desired_action: InitializationRequiringAction, place_span: (PlaceRef<'tcx>, Span), - flow_state: &Flows<'cx, 'tcx>, + flow_state: &Flows<'mir, 'tcx>, ) { let maybe_uninits = &flow_state.uninits; @@ -1940,7 +1947,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { &mut self, location: Location, (place, span): (Place<'tcx>, Span), - flow_state: &Flows<'cx, 'tcx>, + flow_state: &Flows<'mir, 'tcx>, ) { debug!("check_if_assigned_path_is_moved place: {:?}", place); @@ -2001,12 +2008,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } } - fn check_parent_of_field<'cx, 'tcx>( - this: &mut MirBorrowckCtxt<'cx, 'tcx>, + fn check_parent_of_field<'mir, 'tcx>( + this: &mut MirBorrowckCtxt<'_, 'mir, '_, 'tcx>, location: Location, base: PlaceRef<'tcx>, span: Span, - flow_state: &Flows<'cx, 'tcx>, + flow_state: &Flows<'mir, 'tcx>, ) { // rust-lang/rust#21232: Until Rust allows reads from the // initialized parts of partially initialized structs, we @@ -2097,7 +2104,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { (place, span): (Place<'tcx>, Span), kind: ReadOrWrite, is_local_mutation_allowed: LocalMutationIsAllowed, - flow_state: &Flows<'cx, 'tcx>, + flow_state: &Flows<'mir, 'tcx>, location: Location, ) -> bool { debug!( @@ -2213,7 +2220,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { fn is_local_ever_initialized( &self, local: Local, - flow_state: &Flows<'cx, 'tcx>, + flow_state: &Flows<'mir, 'tcx>, ) -> Option<InitIndex> { let mpi = self.move_data.rev_lookup.find_local(local)?; let ii = &self.move_data.init_path_map[mpi]; @@ -2221,7 +2228,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } /// Adds the place into the used mutable variables set - fn add_used_mut(&mut self, root_place: RootPlace<'tcx>, flow_state: &Flows<'cx, 'tcx>) { + fn add_used_mut(&mut self, root_place: RootPlace<'tcx>, flow_state: &Flows<'mir, 'tcx>) { match root_place { RootPlace { place_local: local, place_projection: [], is_local_mutation_allowed } => { // If the local may have been initialized, and it is now currently being @@ -2476,7 +2483,7 @@ mod diags { } } - impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { + impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> { pub fn buffer_error(&mut self, diag: Diag<'tcx>) { self.diags.buffer_error(diag); } diff --git a/compiler/rustc_borrowck/src/prefixes.rs b/compiler/rustc_borrowck/src/prefixes.rs index 8a3a089d0ee..5d3ac1c409a 100644 --- a/compiler/rustc_borrowck/src/prefixes.rs +++ b/compiler/rustc_borrowck/src/prefixes.rs @@ -34,7 +34,7 @@ pub(super) enum PrefixSet { Shallow, } -impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { +impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> { /// Returns an iterator over the prefixes of `place` /// (inclusive) from longest to smallest, potentially /// terminating the iteration early based on `kind`. diff --git a/compiler/rustc_borrowck/src/used_muts.rs b/compiler/rustc_borrowck/src/used_muts.rs index dea1c7823a5..25e1f6268e0 100644 --- a/compiler/rustc_borrowck/src/used_muts.rs +++ b/compiler/rustc_borrowck/src/used_muts.rs @@ -6,7 +6,7 @@ use rustc_middle::mir::{ use crate::MirBorrowckCtxt; -impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { +impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> { /// Walks the MIR adding to the set of `used_mut` locals that will be ignored for the purposes /// of the `unused_mut` lint. /// @@ -45,13 +45,13 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { /// MIR visitor for collecting used mutable variables. /// The 'visit lifetime represents the duration of the MIR walk. -struct GatherUsedMutsVisitor<'visit, 'cx, 'tcx> { +struct GatherUsedMutsVisitor<'visit, 'a, 'mir, 'cx, 'tcx> { temporary_used_locals: FxIndexSet<Local>, never_initialized_mut_locals: &'visit mut FxIndexSet<Local>, - mbcx: &'visit mut MirBorrowckCtxt<'cx, 'tcx>, + mbcx: &'visit mut MirBorrowckCtxt<'a, 'mir, 'cx, 'tcx>, } -impl GatherUsedMutsVisitor<'_, '_, '_> { +impl GatherUsedMutsVisitor<'_, '_, '_, '_, '_> { fn remove_never_initialized_mut_locals(&mut self, into: Place<'_>) { // Remove any locals that we found were initialized from the // `never_initialized_mut_locals` set. At the end, the only remaining locals will @@ -63,7 +63,7 @@ impl GatherUsedMutsVisitor<'_, '_, '_> { } } -impl<'visit, 'cx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'cx, 'tcx> { +impl<'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'_, '_, '_, '_, 'tcx> { fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) { debug!("visit_terminator: terminator={:?}", terminator); match &terminator.kind { diff --git a/compiler/rustc_builtin_macros/src/deriving/mod.rs b/compiler/rustc_builtin_macros/src/deriving/mod.rs index e3a93ae13e4..32936ac183d 100644 --- a/compiler/rustc_builtin_macros/src/deriving/mod.rs +++ b/compiler/rustc_builtin_macros/src/deriving/mod.rs @@ -27,6 +27,7 @@ pub(crate) mod decodable; pub(crate) mod default; pub(crate) mod encodable; pub(crate) mod hash; +pub(crate) mod smart_ptr; #[path = "cmp/eq.rs"] pub(crate) mod eq; diff --git a/compiler/rustc_builtin_macros/src/deriving/smart_ptr.rs b/compiler/rustc_builtin_macros/src/deriving/smart_ptr.rs new file mode 100644 index 00000000000..ea054a7e355 --- /dev/null +++ b/compiler/rustc_builtin_macros/src/deriving/smart_ptr.rs @@ -0,0 +1,140 @@ +use std::mem::swap; + +use ast::HasAttrs; +use rustc_ast::{ + self as ast, GenericArg, GenericBound, GenericParamKind, ItemKind, MetaItem, + TraitBoundModifiers, +}; +use rustc_expand::base::{Annotatable, ExtCtxt}; +use rustc_span::symbol::{sym, Ident}; +use rustc_span::Span; +use smallvec::{smallvec, SmallVec}; +use thin_vec::{thin_vec, ThinVec}; + +macro_rules! path { + ($span:expr, $($part:ident)::*) => { vec![$(Ident::new(sym::$part, $span),)*] } +} + +pub fn expand_deriving_smart_ptr( + cx: &ExtCtxt<'_>, + span: Span, + _mitem: &MetaItem, + item: &Annotatable, + push: &mut dyn FnMut(Annotatable), + _is_const: bool, +) { + let (name_ident, generics) = if let Annotatable::Item(aitem) = item + && let ItemKind::Struct(_, g) = &aitem.kind + { + (aitem.ident, g) + } else { + cx.dcx().struct_span_err(span, "`SmartPointer` can only be derived on `struct`s").emit(); + return; + }; + + // Convert generic parameters (from the struct) into generic args. + let mut pointee_param = None; + let mut multiple_pointee_diag: SmallVec<[_; 2]> = smallvec![]; + let self_params = generics + .params + .iter() + .enumerate() + .map(|(idx, p)| match p.kind { + GenericParamKind::Lifetime => GenericArg::Lifetime(cx.lifetime(p.span(), p.ident)), + GenericParamKind::Type { .. } => { + if p.attrs().iter().any(|attr| attr.has_name(sym::pointee)) { + if pointee_param.is_some() { + multiple_pointee_diag.push(cx.dcx().struct_span_err( + p.span(), + "`SmartPointer` can only admit one type as pointee", + )); + } else { + pointee_param = Some(idx); + } + } + GenericArg::Type(cx.ty_ident(p.span(), p.ident)) + } + GenericParamKind::Const { .. } => GenericArg::Const(cx.const_ident(p.span(), p.ident)), + }) + .collect::<Vec<_>>(); + let Some(pointee_param_idx) = pointee_param else { + cx.dcx().struct_span_err( + span, + "At least one generic type should be designated as `#[pointee]` in order to derive `SmartPointer` traits", + ).emit(); + return; + }; + if !multiple_pointee_diag.is_empty() { + for diag in multiple_pointee_diag { + diag.emit(); + } + return; + } + + // Create the type of `self`. + let path = cx.path_all(span, false, vec![name_ident], self_params.clone()); + let self_type = cx.ty_path(path); + + // Declare helper function that adds implementation blocks. + // FIXME(dingxiangfei2009): Investigate the set of attributes on target struct to be propagated to impls + let attrs = thin_vec![cx.attr_word(sym::automatically_derived, span),]; + let mut add_impl_block = |generics, trait_symbol, trait_args| { + let mut parts = path!(span, core::ops); + parts.push(Ident::new(trait_symbol, span)); + let trait_path = cx.path_all(span, true, parts, trait_args); + let trait_ref = cx.trait_ref(trait_path); + let item = cx.item( + span, + Ident::empty(), + attrs.clone(), + ast::ItemKind::Impl(Box::new(ast::Impl { + safety: ast::Safety::Default, + polarity: ast::ImplPolarity::Positive, + defaultness: ast::Defaultness::Final, + constness: ast::Const::No, + generics, + of_trait: Some(trait_ref), + self_ty: self_type.clone(), + items: ThinVec::new(), + })), + ); + push(Annotatable::Item(item)); + }; + + // Create unsized `self`, that is, one where the `#[pointee]` type arg is replaced with `__S`. For + // example, instead of `MyType<'a, T>`, it will be `MyType<'a, __S>`. + let s_ty = cx.ty_ident(span, Ident::new(sym::__S, span)); + let mut alt_self_params = self_params; + alt_self_params[pointee_param_idx] = GenericArg::Type(s_ty.clone()); + let alt_self_type = cx.ty_path(cx.path_all(span, false, vec![name_ident], alt_self_params)); + + // Find the `#[pointee]` parameter and add an `Unsize<__S>` bound to it. + let mut impl_generics = generics.clone(); + { + let p = &mut impl_generics.params[pointee_param_idx]; + let arg = GenericArg::Type(s_ty.clone()); + let unsize = cx.path_all(span, true, path!(span, core::marker::Unsize), vec![arg]); + p.bounds.push(cx.trait_bound(unsize, false)); + let mut attrs = thin_vec![]; + swap(&mut p.attrs, &mut attrs); + p.attrs = attrs.into_iter().filter(|attr| !attr.has_name(sym::pointee)).collect(); + } + + // Add the `__S: ?Sized` extra parameter to the impl block. + let sized = cx.path_global(span, path!(span, core::marker::Sized)); + let bound = GenericBound::Trait( + cx.poly_trait_ref(span, sized), + TraitBoundModifiers { + polarity: ast::BoundPolarity::Maybe(span), + constness: ast::BoundConstness::Never, + asyncness: ast::BoundAsyncness::Normal, + }, + ); + let extra_param = cx.typaram(span, Ident::new(sym::__S, span), vec![bound], None); + impl_generics.params.push(extra_param); + + // Add the impl blocks for `DispatchFromDyn` and `CoerceUnsized`. + let gen_args = vec![GenericArg::Type(alt_self_type.clone())]; + add_impl_block(impl_generics.clone(), sym::DispatchFromDyn, gen_args.clone()); + add_impl_block(impl_generics.clone(), sym::CoerceUnsized, gen_args.clone()); +} diff --git a/compiler/rustc_builtin_macros/src/lib.rs b/compiler/rustc_builtin_macros/src/lib.rs index 35b0f43d8af..8ac59605bc1 100644 --- a/compiler/rustc_builtin_macros/src/lib.rs +++ b/compiler/rustc_builtin_macros/src/lib.rs @@ -127,6 +127,7 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) { PartialOrd: partial_ord::expand_deriving_partial_ord, RustcDecodable: decodable::expand_deriving_rustc_decodable, RustcEncodable: encodable::expand_deriving_rustc_encodable, + SmartPointer: smart_ptr::expand_deriving_smart_ptr, } let client = proc_macro::bridge::client::Client::expand1(proc_macro::quote); diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index bbfc697407b..5e481eb98f5 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -564,9 +564,6 @@ pub(crate) unsafe fn llvm_optimize( let llvm_plugins = config.llvm_plugins.join(","); - // FIXME: NewPM doesn't provide a facility to pass custom InlineParams. - // We would have to add upstream support for this first, before we can support - // config.inline_threshold and our more aggressive default thresholds. let result = llvm::LLVMRustOptimize( module.module_llvm.llmod(), &*module.module_llvm.tm, diff --git a/compiler/rustc_codegen_ssa/messages.ftl b/compiler/rustc_codegen_ssa/messages.ftl index 1a851ad04a1..000fe2e3ce0 100644 --- a/compiler/rustc_codegen_ssa/messages.ftl +++ b/compiler/rustc_codegen_ssa/messages.ftl @@ -27,8 +27,6 @@ codegen_ssa_create_temp_dir = couldn't create a temp dir: {$error} codegen_ssa_error_creating_remark_dir = failed to create remark directory: {$error} -codegen_ssa_expected_coverage_symbol = expected `coverage(off)` or `coverage(on)` - codegen_ssa_expected_used_symbol = expected `used`, `used(compiler)` or `used(linker)` codegen_ssa_extern_funcs_not_found = some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index 064be4988bd..0e48eee3dd5 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -120,7 +120,6 @@ pub struct ModuleConfig { pub vectorize_loop: bool, pub vectorize_slp: bool, pub merge_functions: bool, - pub inline_threshold: Option<u32>, pub emit_lifetime_markers: bool, pub llvm_plugins: Vec<String>, } @@ -280,7 +279,6 @@ impl ModuleConfig { } }, - inline_threshold: sess.opts.cg.inline_threshold, emit_lifetime_markers: sess.emit_lifetime_markers(), llvm_plugins: if_regular!(sess.opts.unstable_opts.llvm_plugins.clone(), vec![]), } diff --git a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs index 15955170e87..fb71cdaa8ff 100644 --- a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs +++ b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs @@ -15,11 +15,7 @@ use rustc_span::{sym, Span}; use rustc_target::spec::{abi, SanitizerSet}; use crate::errors; -use crate::target_features::from_target_feature; -use crate::{ - errors::{ExpectedCoverageSymbol, ExpectedUsedSymbol}, - target_features::check_target_feature_trait_unsafe, -}; +use crate::target_features::{check_target_feature_trait_unsafe, from_target_feature}; fn linkage_by_name(tcx: TyCtxt<'_>, def_id: LocalDefId, name: &str) -> Linkage { use rustc_middle::mir::mono::Linkage::*; @@ -139,7 +135,8 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs { // coverage on a smaller scope within an excluded larger scope. } Some(_) | None => { - tcx.dcx().emit_err(ExpectedCoverageSymbol { span: attr.span }); + tcx.dcx() + .span_delayed_bug(attr.span, "unexpected value of coverage attribute"); } } } @@ -174,7 +171,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs { codegen_fn_attrs.flags |= CodegenFnAttrFlags::USED; } Some(_) => { - tcx.dcx().emit_err(ExpectedUsedSymbol { span: attr.span }); + tcx.dcx().emit_err(errors::ExpectedUsedSymbol { span: attr.span }); } None => { // Unfortunately, unconditionally using `llvm.used` causes diff --git a/compiler/rustc_codegen_ssa/src/errors.rs b/compiler/rustc_codegen_ssa/src/errors.rs index e6ba31c5165..e9d31db9254 100644 --- a/compiler/rustc_codegen_ssa/src/errors.rs +++ b/compiler/rustc_codegen_ssa/src/errors.rs @@ -565,13 +565,6 @@ pub struct UnknownArchiveKind<'a> { } #[derive(Diagnostic)] -#[diag(codegen_ssa_expected_coverage_symbol)] -pub struct ExpectedCoverageSymbol { - #[primary_span] - pub span: Span, -} - -#[derive(Diagnostic)] #[diag(codegen_ssa_expected_used_symbol)] pub struct ExpectedUsedSymbol { #[primary_span] diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs index 9781aae22eb..cddc67d1578 100644 --- a/compiler/rustc_data_structures/src/lib.rs +++ b/compiler/rustc_data_structures/src/lib.rs @@ -27,7 +27,6 @@ #![feature(lint_reasons)] #![feature(macro_metavar_expr)] #![feature(map_try_insert)] -#![feature(maybe_uninit_uninit_array)] #![feature(min_specialization)] #![feature(negative_impls)] #![feature(never_type)] diff --git a/compiler/rustc_data_structures/src/sip128.rs b/compiler/rustc_data_structures/src/sip128.rs index 4c9acfe0f71..fed23df10dc 100644 --- a/compiler/rustc_data_structures/src/sip128.rs +++ b/compiler/rustc_data_structures/src/sip128.rs @@ -188,7 +188,7 @@ impl SipHasher128 { pub fn new_with_keys(key0: u64, key1: u64) -> SipHasher128 { let mut hasher = SipHasher128 { nbuf: 0, - buf: MaybeUninit::uninit_array(), + buf: [MaybeUninit::uninit(); BUFFER_WITH_SPILL_CAPACITY], state: State { v0: key0 ^ 0x736f6d6570736575, // The XOR with 0xee is only done on 128-bit algorithm version. diff --git a/compiler/rustc_data_structures/src/stable_hasher.rs b/compiler/rustc_data_structures/src/stable_hasher.rs index b5bdf2e1790..a57f5067dd8 100644 --- a/compiler/rustc_data_structures/src/stable_hasher.rs +++ b/compiler/rustc_data_structures/src/stable_hasher.rs @@ -238,12 +238,21 @@ pub trait ToStableHashKey<HCX> { /// The associated constant `CAN_USE_UNSTABLE_SORT` denotes whether /// unstable sorting can be used for this type. Set to true if and /// only if `a == b` implies `a` and `b` are fully indistinguishable. -pub unsafe trait StableOrd: Ord { +pub trait StableOrd: Ord { const CAN_USE_UNSTABLE_SORT: bool; + + /// Marker to ensure that implementors have carefully considered + /// whether their `Ord` implementation obeys this trait's contract. + const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: (); } -unsafe impl<T: StableOrd> StableOrd for &T { +impl<T: StableOrd> StableOrd for &T { const CAN_USE_UNSTABLE_SORT: bool = T::CAN_USE_UNSTABLE_SORT; + + // Ordering of a reference is exactly that of the referent, and since + // the ordering of the referet is stable so must be the ordering of the + // reference. + const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } /// This is a companion trait to `StableOrd`. Some types like `Symbol` can be @@ -290,8 +299,12 @@ macro_rules! impl_stable_traits_for_trivial_type { } } - unsafe impl $crate::stable_hasher::StableOrd for $t { + impl $crate::stable_hasher::StableOrd for $t { const CAN_USE_UNSTABLE_SORT: bool = true; + + // Encoding and decoding doesn't change the bytes of trivial types + // and `Ord::cmp` depends only on those bytes. + const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } }; } @@ -327,8 +340,12 @@ impl<CTX> HashStable<CTX> for Hash128 { } } -unsafe impl StableOrd for Hash128 { +impl StableOrd for Hash128 { const CAN_USE_UNSTABLE_SORT: bool = true; + + // Encoding and decoding doesn't change the bytes of `Hash128` + // and `Ord::cmp` depends only on those bytes. + const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } impl<CTX> HashStable<CTX> for ! { @@ -392,8 +409,12 @@ impl<T1: HashStable<CTX>, T2: HashStable<CTX>, CTX> HashStable<CTX> for (T1, T2) } } -unsafe impl<T1: StableOrd, T2: StableOrd> StableOrd for (T1, T2) { +impl<T1: StableOrd, T2: StableOrd> StableOrd for (T1, T2) { const CAN_USE_UNSTABLE_SORT: bool = T1::CAN_USE_UNSTABLE_SORT && T2::CAN_USE_UNSTABLE_SORT; + + // Ordering of tuples is a pure function of their elements' ordering, and since + // the ordering of each element is stable so must be the ordering of the tuple. + const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } impl<T1, T2, T3, CTX> HashStable<CTX> for (T1, T2, T3) @@ -410,9 +431,13 @@ where } } -unsafe impl<T1: StableOrd, T2: StableOrd, T3: StableOrd> StableOrd for (T1, T2, T3) { +impl<T1: StableOrd, T2: StableOrd, T3: StableOrd> StableOrd for (T1, T2, T3) { const CAN_USE_UNSTABLE_SORT: bool = T1::CAN_USE_UNSTABLE_SORT && T2::CAN_USE_UNSTABLE_SORT && T3::CAN_USE_UNSTABLE_SORT; + + // Ordering of tuples is a pure function of their elements' ordering, and since + // the ordering of each element is stable so must be the ordering of the tuple. + const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } impl<T1, T2, T3, T4, CTX> HashStable<CTX> for (T1, T2, T3, T4) @@ -431,13 +456,15 @@ where } } -unsafe impl<T1: StableOrd, T2: StableOrd, T3: StableOrd, T4: StableOrd> StableOrd - for (T1, T2, T3, T4) -{ +impl<T1: StableOrd, T2: StableOrd, T3: StableOrd, T4: StableOrd> StableOrd for (T1, T2, T3, T4) { const CAN_USE_UNSTABLE_SORT: bool = T1::CAN_USE_UNSTABLE_SORT && T2::CAN_USE_UNSTABLE_SORT && T3::CAN_USE_UNSTABLE_SORT && T4::CAN_USE_UNSTABLE_SORT; + + // Ordering of tuples is a pure function of their elements' ordering, and since + // the ordering of each element is stable so must be the ordering of the tuple. + const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } impl<T: HashStable<CTX>, CTX> HashStable<CTX> for [T] { @@ -530,8 +557,12 @@ impl<CTX> HashStable<CTX> for str { } } -unsafe impl StableOrd for &str { +impl StableOrd for &str { const CAN_USE_UNSTABLE_SORT: bool = true; + + // Encoding and decoding doesn't change the bytes of string slices + // and `Ord::cmp` depends only on those bytes. + const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } impl<CTX> HashStable<CTX> for String { @@ -541,10 +572,12 @@ impl<CTX> HashStable<CTX> for String { } } -// Safety: String comparison only depends on their contents and the -// contents are not changed by (de-)serialization. -unsafe impl StableOrd for String { +impl StableOrd for String { const CAN_USE_UNSTABLE_SORT: bool = true; + + // String comparison only depends on their contents and the + // contents are not changed by (de-)serialization. + const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } impl<HCX> ToStableHashKey<HCX> for String { @@ -570,9 +603,11 @@ impl<CTX> HashStable<CTX> for bool { } } -// Safety: sort order of bools is not changed by (de-)serialization. -unsafe impl StableOrd for bool { +impl StableOrd for bool { const CAN_USE_UNSTABLE_SORT: bool = true; + + // sort order of bools is not changed by (de-)serialization. + const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } impl<T, CTX> HashStable<CTX> for Option<T> @@ -590,9 +625,11 @@ where } } -// Safety: the Option wrapper does not add instability to comparison. -unsafe impl<T: StableOrd> StableOrd for Option<T> { +impl<T: StableOrd> StableOrd for Option<T> { const CAN_USE_UNSTABLE_SORT: bool = T::CAN_USE_UNSTABLE_SORT; + + // the Option wrapper does not add instability to comparison. + const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } impl<T1, T2, CTX> HashStable<CTX> for Result<T1, T2> diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 5ffa3a6099c..bbe9741bf44 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -30,7 +30,7 @@ use rustc_errors::{ }; use rustc_feature::find_gated_cfg; use rustc_interface::util::{self, get_codegen_backend}; -use rustc_interface::{interface, Queries}; +use rustc_interface::{interface, passes, Queries}; use rustc_lint::unerased_lint_store; use rustc_metadata::creader::MetadataLoader; use rustc_metadata::locator; @@ -367,18 +367,17 @@ fn run_compiler( return early_exit(); } - let early_dcx = EarlyDiagCtxt::new(sess.opts.error_format); - - if print_crate_info(&early_dcx, codegen_backend, sess, has_input) == Compilation::Stop { + if print_crate_info(codegen_backend, sess, has_input) == Compilation::Stop { return early_exit(); } if !has_input { - early_dcx.early_fatal("no input filename given"); // this is fatal + #[allow(rustc::diagnostic_outside_of_impl)] + sess.dcx().fatal("no input filename given"); // this is fatal } if !sess.opts.unstable_opts.ls.is_empty() { - list_metadata(&early_dcx, sess, &*codegen_backend.metadata_loader()); + list_metadata(sess, &*codegen_backend.metadata_loader()); return early_exit(); } @@ -399,7 +398,9 @@ fn run_compiler( Ok(()) })?; - queries.write_dep_info()?; + queries.global_ctxt()?.enter(|tcx| { + passes::write_dep_info(tcx); + }); } else { let krate = queries.parse()?; pretty::print( @@ -427,7 +428,9 @@ fn run_compiler( return early_exit(); } - queries.write_dep_info()?; + queries.global_ctxt()?.enter(|tcx| { + passes::write_dep_info(tcx); + }); if sess.opts.output_types.contains_key(&OutputType::DepInfo) && sess.opts.output_types.len() == 1 @@ -670,7 +673,7 @@ fn process_rlink(sess: &Session, compiler: &interface::Compiler) { } } -fn list_metadata(early_dcx: &EarlyDiagCtxt, sess: &Session, metadata_loader: &dyn MetadataLoader) { +fn list_metadata(sess: &Session, metadata_loader: &dyn MetadataLoader) { match sess.io.input { Input::File(ref ifile) => { let path = &(*ifile); @@ -687,13 +690,13 @@ fn list_metadata(early_dcx: &EarlyDiagCtxt, sess: &Session, metadata_loader: &dy safe_println!("{}", String::from_utf8(v).unwrap()); } Input::Str { .. } => { - early_dcx.early_fatal("cannot list metadata for stdin"); + #[allow(rustc::diagnostic_outside_of_impl)] + sess.dcx().fatal("cannot list metadata for stdin"); } } } fn print_crate_info( - early_dcx: &EarlyDiagCtxt, codegen_backend: &dyn CodegenBackend, sess: &Session, parse_attrs: bool, @@ -877,8 +880,8 @@ fn print_crate_info( .expect("unknown Apple target OS"); println_info!("deployment_target={}", format!("{major}.{minor}")) } else { - early_dcx - .early_fatal("only Apple targets currently support deployment version info") + #[allow(rustc::diagnostic_outside_of_impl)] + sess.dcx().fatal("only Apple targets currently support deployment version info") } } } @@ -1133,7 +1136,11 @@ pub fn describe_flag_categories(early_dcx: &EarlyDiagCtxt, matches: &Matches) -> } if cg_flags.iter().any(|x| *x == "no-stack-check") { - early_dcx.early_warn("the --no-stack-check flag is deprecated and does nothing"); + early_dcx.early_warn("the `-Cno-stack-check` flag is deprecated and does nothing"); + } + + if cg_flags.iter().any(|x| x.starts_with("inline-threshold")) { + early_dcx.early_warn("the `-Cinline-threshold` flag is deprecated and does nothing (consider using `-Cllvm-args=--inline-threshold=...`)"); } if cg_flags.iter().any(|x| *x == "passes=list") { diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 7405705dd33..45118bcc58a 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -902,7 +902,7 @@ impl HumanEmitter { // <EMPTY LINE> // let mut annotations_position = vec![]; - let mut line_len = 0; + let mut line_len: usize = 0; let mut p = 0; for (i, annotation) in annotations.iter().enumerate() { for (j, next) in annotations.iter().enumerate() { @@ -973,6 +973,31 @@ impl HumanEmitter { return vec![]; } + if annotations_position + .iter() + .all(|(_, ann)| matches!(ann.annotation_type, AnnotationType::MultilineStart(_))) + && let Some(max_pos) = annotations_position.iter().map(|(pos, _)| *pos).max() + { + // Special case the following, so that we minimize overlapping multiline spans. + // + // 3 │ X0 Y0 Z0 + // │ ┏━━━━━┛ │ │ < We are writing these lines + // │ ┃┌───────┘ │ < by reverting the "depth" of + // │ ┃│┌─────────┘ < their multilne spans. + // 4 │ ┃││ X1 Y1 Z1 + // 5 │ ┃││ X2 Y2 Z2 + // │ ┃│└────╿──│──┘ `Z` label + // │ ┃└─────│──┤ + // │ ┗━━━━━━┥ `Y` is a good letter too + // ╰╴ `X` is a good letter + for (pos, _) in &mut annotations_position { + *pos = max_pos - *pos; + } + // We know then that we don't need an additional line for the span label, saving us + // one line of vertical space. + line_len = line_len.saturating_sub(1); + } + // Write the column separator. // // After this we will have: diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 5e83e0d27e1..c53bf965139 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -105,6 +105,9 @@ pub struct AttributeTemplate { pub word: bool, /// If `Some`, the attribute is allowed to take a list of items like `#[allow(..)]`. pub list: Option<&'static str>, + /// If non-empty, the attribute is allowed to take a list containing exactly + /// one of the listed words, like `#[coverage(off)]`. + pub one_of: &'static [Symbol], /// If `Some`, the attribute is allowed to be a name/value pair where the /// value is a string, like `#[must_use = "reason"]`. pub name_value_str: Option<&'static str>, @@ -165,19 +168,20 @@ pub enum AttributeDuplicates { /// E.g., `template!(Word, List: "description")` means that the attribute /// supports forms `#[attr]` and `#[attr(description)]`. macro_rules! template { - (Word) => { template!(@ true, None, None) }; - (List: $descr: expr) => { template!(@ false, Some($descr), None) }; - (NameValueStr: $descr: expr) => { template!(@ false, None, Some($descr)) }; - (Word, List: $descr: expr) => { template!(@ true, Some($descr), None) }; - (Word, NameValueStr: $descr: expr) => { template!(@ true, None, Some($descr)) }; + (Word) => { template!(@ true, None, &[], None) }; + (List: $descr: expr) => { template!(@ false, Some($descr), &[], None) }; + (OneOf: $one_of: expr) => { template!(@ false, None, $one_of, None) }; + (NameValueStr: $descr: expr) => { template!(@ false, None, &[], Some($descr)) }; + (Word, List: $descr: expr) => { template!(@ true, Some($descr), &[], None) }; + (Word, NameValueStr: $descr: expr) => { template!(@ true, None, &[], Some($descr)) }; (List: $descr1: expr, NameValueStr: $descr2: expr) => { - template!(@ false, Some($descr1), Some($descr2)) + template!(@ false, Some($descr1), &[], Some($descr2)) }; (Word, List: $descr1: expr, NameValueStr: $descr2: expr) => { - template!(@ true, Some($descr1), Some($descr2)) + template!(@ true, Some($descr1), &[], Some($descr2)) }; - (@ $word: expr, $list: expr, $name_value_str: expr) => { AttributeTemplate { - word: $word, list: $list, name_value_str: $name_value_str + (@ $word: expr, $list: expr, $one_of: expr, $name_value_str: expr) => { AttributeTemplate { + word: $word, list: $list, one_of: $one_of, name_value_str: $name_value_str } }; } @@ -478,8 +482,8 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ EncodeCrossCrate::No, experimental!(no_sanitize) ), gated!( - coverage, Normal, template!(Word, List: "on|off"), - WarnFollowing, EncodeCrossCrate::No, + coverage, Normal, template!(OneOf: &[sym::off, sym::on]), + ErrorPreceding, EncodeCrossCrate::No, coverage_attribute, experimental!(coverage) ), @@ -575,6 +579,12 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ EncodeCrossCrate::No, coroutines, experimental!(coroutines) ), + // `#[pointee]` attribute to designate the pointee type in SmartPointer derive-macro + gated!( + pointee, Normal, template!(Word), ErrorFollowing, + EncodeCrossCrate::No, derive_smart_pointer, experimental!(pointee) + ), + // ========================================================================== // Internal attributes: Stability, deprecation, and unsafe: // ========================================================================== diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index f66c9604cbe..2dfaac8f6e7 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -436,6 +436,8 @@ declare_features! ( (unstable, deprecated_suggestion, "1.61.0", Some(94785)), /// Allows deref patterns. (incomplete, deref_patterns, "1.79.0", Some(87121)), + /// Allows deriving `SmartPointer` traits + (unstable, derive_smart_pointer, "1.79.0", Some(123430)), /// Controls errors in trait implementations. (unstable, do_not_recommend, "1.67.0", Some(51992)), /// Tells rustdoc to automatically generate `#[doc(cfg(...))]`. diff --git a/compiler/rustc_hir/src/hir_id.rs b/compiler/rustc_hir/src/hir_id.rs index ac487469507..c0ca1a8017e 100644 --- a/compiler/rustc_hir/src/hir_id.rs +++ b/compiler/rustc_hir/src/hir_id.rs @@ -165,10 +165,12 @@ impl ItemLocalId { pub const INVALID: ItemLocalId = ItemLocalId::MAX; } -// Safety: Ord is implement as just comparing the ItemLocalId's numerical -// values and these are not changed by (de-)serialization. -unsafe impl StableOrd for ItemLocalId { +impl StableOrd for ItemLocalId { const CAN_USE_UNSTABLE_SORT: bool = true; + + // `Ord` is implemented as just comparing the ItemLocalId's numerical + // values and these are not changed by (de-)serialization. + const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } /// The `HirId` corresponding to `CRATE_NODE_ID` and `CRATE_DEF_ID`. diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 3b53c253195..e13ea1a1935 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -719,7 +719,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) { tcx, assoc_item, assoc_item, - ty::TraitRef::new(tcx, def_id.to_def_id(), trait_args), + ty::TraitRef::new_from_args(tcx, def_id.to_def_id(), trait_args), ); } _ => {} diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index 550f38af8b5..7fa5c96bc9a 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -2032,7 +2032,7 @@ pub(super) fn check_type_bounds<'tcx>( // to its definition type. This should be the param-env we use to *prove* the // predicate too, but we don't do that because of performance issues. // See <https://github.com/rust-lang/rust/pull/117542#issue-1976337685>. - let trait_projection_ty = Ty::new_projection(tcx, trait_ty.def_id, rebased_args); + let trait_projection_ty = Ty::new_projection_from_args(tcx, trait_ty.def_id, rebased_args); let impl_identity_ty = tcx.type_of(impl_ty.def_id).instantiate_identity(); let normalize_param_env = param_env_with_gat_bounds(tcx, impl_ty, impl_trait_ref); for mut obligation in util::elaborate(tcx, obligations) { @@ -2230,7 +2230,11 @@ fn param_env_with_gat_bounds<'tcx>( _ => predicates.push( ty::Binder::bind_with_vars( ty::ProjectionPredicate { - projection_term: ty::AliasTerm::new(tcx, trait_ty.def_id, rebased_args), + projection_term: ty::AliasTerm::new_from_args( + tcx, + trait_ty.def_id, + rebased_args, + ), term: normalize_impl_ty.into(), }, bound_vars, diff --git a/compiler/rustc_hir_analysis/src/check/intrinsic.rs b/compiler/rustc_hir_analysis/src/check/intrinsic.rs index 683709f43f2..f21aeb4c0b9 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsic.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsic.rs @@ -504,7 +504,11 @@ pub fn check_intrinsic_type( ty::Region::new_bound(tcx, ty::INNERMOST, br), param(0), )], - Ty::new_projection(tcx, discriminant_def_id, tcx.mk_args(&[param(0).into()])), + Ty::new_projection_from_args( + tcx, + discriminant_def_id, + tcx.mk_args(&[param(0).into()]), + ), ) } diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index e5bd147352d..e7892f17660 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -423,7 +423,7 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> { item_segment, trait_ref.args, ); - Ty::new_projection(self.tcx(), item_def_id, item_args) + Ty::new_projection_from_args(self.tcx(), item_def_id, item_args) } else { // There are no late-bound regions; we can just ignore the binder. let (mut mpart_sugg, mut inferred_sugg) = (None, None); @@ -1607,7 +1607,7 @@ pub fn suggest_impl_trait<'tcx>( let item_ty = ocx.normalize( &ObligationCause::dummy(), param_env, - Ty::new_projection(infcx.tcx, assoc_item_def_id, args), + Ty::new_projection_from_args(infcx.tcx, assoc_item_def_id, args), ); // FIXME(compiler-errors): We may benefit from resolving regions here. if ocx.select_where_possible().is_empty() diff --git a/compiler/rustc_hir_analysis/src/collect/item_bounds.rs b/compiler/rustc_hir_analysis/src/collect/item_bounds.rs index 9f198933dee..d084d3aefeb 100644 --- a/compiler/rustc_hir_analysis/src/collect/item_bounds.rs +++ b/compiler/rustc_hir_analysis/src/collect/item_bounds.rs @@ -23,7 +23,7 @@ fn associated_type_bounds<'tcx>( span: Span, filter: PredicateFilter, ) -> &'tcx [(ty::Clause<'tcx>, Span)] { - let item_ty = Ty::new_projection( + let item_ty = Ty::new_projection_from_args( tcx, assoc_item_def_id.to_def_id(), GenericArgs::identity_for_item(tcx, assoc_item_def_id), @@ -108,7 +108,7 @@ pub(super) fn explicit_item_bounds_with_filter( tcx, opaque_def_id.expect_local(), opaque_ty.bounds, - Ty::new_projection( + Ty::new_projection_from_args( tcx, def_id.to_def_id(), ty::GenericArgs::identity_for_item(tcx, def_id), diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs index c7699b0b310..802215b2843 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs @@ -409,7 +409,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { ); debug!(?alias_args); - ty::AliasTerm::new(tcx, assoc_item.def_id, alias_args) + ty::AliasTerm::new_from_args(tcx, assoc_item.def_id, alias_args) }); // Provide the resolved type of the associated constant to `type_of(AnonConst)`. diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index 5911d5bb4e1..24ea328889c 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -693,7 +693,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { debug!(?bound_vars); let poly_trait_ref = ty::Binder::bind_with_vars( - ty::TraitRef::new(tcx, trait_def_id, generic_args), + ty::TraitRef::new_from_args(tcx, trait_def_id, generic_args), bound_vars, ); @@ -759,7 +759,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { Some((trait_def_id, trait_segment, span)), ); } - ty::TraitRef::new(self.tcx(), trait_def_id, generic_args) + ty::TraitRef::new_from_args(self.tcx(), trait_def_id, generic_args) } fn probe_trait_that_defines_assoc_item( @@ -789,7 +789,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { // Type aliases defined in crates that have the // feature `lazy_type_alias` enabled get encoded as a type alias that normalization will // then actually instantiate the where bounds of. - let alias_ty = ty::AliasTy::new(tcx, did, args); + let alias_ty = ty::AliasTy::new_from_args(tcx, did, args); Ty::new_alias(tcx, ty::Weak, alias_ty) } else { tcx.at(span).type_of(did).instantiate(tcx, args) @@ -1267,7 +1267,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { .chain(args.into_iter().skip(parent_args.len())), ); - let ty = Ty::new_alias(tcx, ty::Inherent, ty::AliasTy::new(tcx, assoc_item, args)); + let ty = + Ty::new_alias(tcx, ty::Inherent, ty::AliasTy::new_from_args(tcx, assoc_item, args)); Ok(Some((ty, assoc_item))) } @@ -1534,7 +1535,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { let item_args = self.lower_generic_args_of_assoc_item(span, item_def_id, item_segment, trait_ref.args); - Ty::new_projection(tcx, item_def_id, item_args) + Ty::new_projection_from_args(tcx, item_def_id, item_args) } pub fn prohibit_generic_args<'a>( @@ -2302,7 +2303,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { debug!(?args); if in_trait { - Ty::new_projection(tcx, def_id, args) + Ty::new_projection_from_args(tcx, def_id, args) } else { Ty::new_opaque(tcx, def_id, args) } diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index 31f85e21d71..0551b9bc1f0 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -1245,11 +1245,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expr, ); - return self + return Err(self .commit_if_ok(|_| { - self.at(cause, self.param_env).lub(DefineOpaqueTypes::No, prev_ty, new_ty) + self.at(cause, self.param_env).lub(DefineOpaqueTypes::Yes, prev_ty, new_ty) }) - .map(|ok| self.register_infer_ok_obligations(ok)); + .unwrap_err()); } } @@ -1259,10 +1259,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Some(e) = first_error { Err(e) } else { - self.commit_if_ok(|_| { - self.at(cause, self.param_env).lub(DefineOpaqueTypes::No, prev_ty, new_ty) - }) - .map(|ok| self.register_infer_ok_obligations(ok)) + Err(self + .commit_if_ok(|_| { + self.at(cause, self.param_env).lub( + DefineOpaqueTypes::Yes, + prev_ty, + new_ty, + ) + }) + .unwrap_err()) } } Ok(ok) => { diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 233dc2afa9b..f4e1e461953 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -3108,7 +3108,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let element_ty = ocx.normalize( &cause, self.param_env, - Ty::new_projection(self.tcx, index_trait_output_def_id, impl_trait_ref.args), + Ty::new_projection_from_args( + self.tcx, + index_trait_output_def_id, + impl_trait_ref.args, + ), ); let true_errors = ocx.select_where_possible(); diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs index 4edc11d7ab1..f7abba35706 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs @@ -569,7 +569,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // For the purposes of this function, we hope that it is a `struct` type, and that our current `expr` is a literal of // that struct type. let impl_trait_self_ref = if self.tcx.is_trait_alias(obligation.impl_or_alias_def_id) { - ty::TraitRef::new( + ty::TraitRef::new_from_args( self.tcx, obligation.impl_or_alias_def_id, ty::GenericArgs::identity_for_item(self.tcx, obligation.impl_or_alias_def_id), diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs index 1713d75092e..c0d60477967 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs @@ -297,7 +297,7 @@ impl<'tcx> HirTyLowerer<'tcx> for FnCtxt<'_, 'tcx> { trait_ref.args, ); - Ty::new_projection(self.tcx(), item_def_id, item_args) + Ty::new_projection_from_args(self.tcx(), item_def_id, item_args) } fn probe_adt(&self, span: Span, ty: Ty<'tcx>) -> Option<ty::AdtDef<'tcx>> { diff --git a/compiler/rustc_hir_typeck/src/intrinsicck.rs b/compiler/rustc_hir_typeck/src/intrinsicck.rs index fb8863c143f..5eafc60a04e 100644 --- a/compiler/rustc_hir_typeck/src/intrinsicck.rs +++ b/compiler/rustc_hir_typeck/src/intrinsicck.rs @@ -73,7 +73,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Special-case transmuting from `typeof(function)` and // `Option<typeof(function)>` to present a clearer error. let from = unpack_option_like(tcx, from); - if let (&ty::FnDef(..), SizeSkeleton::Known(size_to)) = (from.kind(), sk_to) + if let (&ty::FnDef(..), SizeSkeleton::Known(size_to, _)) = (from.kind(), sk_to) && size_to == Pointer(dl.instruction_address_space).size(&tcx) { struct_span_code_err!(tcx.dcx(), span, E0591, "can't transmute zero-sized type") @@ -88,7 +88,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Try to display a sensible error with as much information as possible. let skeleton_string = |ty: Ty<'tcx>, sk: Result<_, &_>| match sk { Ok(SizeSkeleton::Pointer { tail, .. }) => format!("pointer to `{tail}`"), - Ok(SizeSkeleton::Known(size)) => { + Ok(SizeSkeleton::Known(size, _)) => { if let Some(v) = u128::from(size.bytes()).checked_mul(8) { format!("{v} bits") } else { diff --git a/compiler/rustc_hir_typeck/src/method/mod.rs b/compiler/rustc_hir_typeck/src/method/mod.rs index 1f90d5e4c88..e1223307b53 100644 --- a/compiler/rustc_hir_typeck/src/method/mod.rs +++ b/compiler/rustc_hir_typeck/src/method/mod.rs @@ -333,7 +333,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.var_for_def(cause.span, param) }); - let trait_ref = ty::TraitRef::new(self.tcx, trait_def_id, args); + let trait_ref = ty::TraitRef::new_from_args(self.tcx, trait_def_id, args); // Construct an obligation let poly_trait_ref = ty::Binder::dummy(trait_ref); diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index 47ea221d1a1..9747a91ccbf 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -870,7 +870,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { trait_def_id: DefId, ) { let trait_args = self.fresh_args_for_item(self.span, trait_def_id); - let trait_ref = ty::TraitRef::new(self.tcx, trait_def_id, trait_args); + let trait_ref = ty::TraitRef::new_from_args(self.tcx, trait_def_id, trait_args); if self.tcx.is_trait_alias(trait_def_id) { // For trait aliases, recursively assume all explicitly named traits are relevant diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index ec0cb7a67ba..a385bc70e35 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -1978,7 +1978,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err, self_source, args, - ty::TraitRef::new( + ty::TraitRef::new_from_args( self.tcx, trait_did, self.fresh_args_for_item(sugg_span, trait_did), diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs index e125f1858dd..80b7e3b4fa5 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs @@ -256,12 +256,12 @@ impl<'tcx> NiceRegionError<'_, 'tcx> { (false, None, None, Some(span), String::new()) }; - let expected_trait_ref = self.cx.resolve_vars_if_possible(ty::TraitRef::new( + let expected_trait_ref = self.cx.resolve_vars_if_possible(ty::TraitRef::new_from_args( self.cx.tcx, trait_def_id, expected_args, )); - let actual_trait_ref = self.cx.resolve_vars_if_possible(ty::TraitRef::new( + let actual_trait_ref = self.cx.resolve_vars_if_possible(ty::TraitRef::new_from_args( self.cx.tcx, trait_def_id, actual_args, diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index 41c8b941717..dba20e4a335 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -495,9 +495,8 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se let res = { // If `f` panics, `finish_diagnostics` will run during // unwinding because of the `defer`. - let mut guar = None; let sess_abort_guard = defer(|| { - guar = compiler.sess.finish_diagnostics(&config.registry); + compiler.sess.finish_diagnostics(&config.registry); }); let res = f(&compiler); @@ -506,16 +505,14 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se // normally when `sess_abort_guard` is dropped. drop(sess_abort_guard); - // If `finish_diagnostics` emits errors (e.g. stashed - // errors) we can't return an error directly, because the - // return type of this function is `R`, not `Result<R, E>`. - // But we need to communicate the errors' existence to the - // caller, otherwise the caller might mistakenly think that - // no errors occurred and return a zero exit code. So we - // abort (panic) instead, similar to if `f` had panicked. - if guar.is_some() { - compiler.sess.dcx().abort_if_errors(); - } + // If error diagnostics have been emitted, we can't return an + // error directly, because the return type of this function + // is `R`, not `Result<R, E>`. But we need to communicate the + // errors' existence to the caller, otherwise the caller might + // mistakenly think that no errors occurred and return a zero + // exit code. So we abort (panic) instead, similar to if `f` + // had panicked. + compiler.sess.dcx().abort_if_errors(); res }; diff --git a/compiler/rustc_interface/src/lib.rs b/compiler/rustc_interface/src/lib.rs index 0c3d4e19ef8..38f64ebb04e 100644 --- a/compiler/rustc_interface/src/lib.rs +++ b/compiler/rustc_interface/src/lib.rs @@ -8,7 +8,7 @@ mod callbacks; mod errors; pub mod interface; -mod passes; +pub mod passes; mod proc_macro_decls; mod queries; pub mod util; diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index f881d53858a..2951f50b1f5 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -7,16 +7,16 @@ use rustc_ast::{self as ast, visit}; use rustc_codegen_ssa::traits::CodegenBackend; use rustc_data_structures::parallel; use rustc_data_structures::steal::Steal; -use rustc_data_structures::sync::{Lrc, OnceLock, WorkerLocal}; -use rustc_errors::PResult; +use rustc_data_structures::sync::{AppendOnlyIndexVec, FreezeLock, Lrc, OnceLock, WorkerLocal}; use rustc_expand::base::{ExtCtxt, LintStoreExpand}; use rustc_feature::Features; use rustc_fs_util::try_canonicalize; -use rustc_hir::def_id::{StableCrateId, LOCAL_CRATE}; +use rustc_hir::def_id::{StableCrateId, StableCrateIdMap, LOCAL_CRATE}; +use rustc_hir::definitions::Definitions; +use rustc_incremental::setup_dep_graph; use rustc_lint::{unerased_lint_store, BufferedEarlyLint, EarlyCheckNode, LintStore}; use rustc_metadata::creader::CStore; use rustc_middle::arena::Arena; -use rustc_middle::dep_graph::DepGraph; use rustc_middle::ty::{self, GlobalCtxt, RegisteredTools, TyCtxt}; use rustc_middle::util::Providers; use rustc_parse::{ @@ -28,6 +28,7 @@ use rustc_session::code_stats::VTableSizeInfo; use rustc_session::config::{CrateType, Input, OutFileName, OutputFilenames, OutputType}; use rustc_session::cstore::Untracked; use rustc_session::output::filename_for_input; +use rustc_session::output::{collect_crate_types, find_crate_name}; use rustc_session::search_paths::PathKind; use rustc_session::{Limit, Session}; use rustc_span::symbol::{sym, Symbol}; @@ -39,20 +40,22 @@ use std::any::Any; use std::ffi::OsString; use std::io::{self, BufWriter, Write}; use std::path::{Path, PathBuf}; -use std::sync::LazyLock; +use std::sync::{Arc, LazyLock}; use std::{env, fs, iter}; use tracing::{info, instrument}; -pub fn parse<'a>(sess: &'a Session) -> PResult<'a, ast::Crate> { - let krate = sess.time("parse_crate", || { - let mut parser = unwrap_or_emit_fatal(match &sess.io.input { - Input::File(file) => new_parser_from_file(&sess.psess, file, None), - Input::Str { input, name } => { - new_parser_from_source_str(&sess.psess, name.clone(), input.clone()) - } - }); - parser.parse_crate_mod() - })?; +pub(crate) fn parse<'a>(sess: &'a Session) -> Result<ast::Crate> { + let krate = sess + .time("parse_crate", || { + let mut parser = unwrap_or_emit_fatal(match &sess.io.input { + Input::File(file) => new_parser_from_file(&sess.psess, file, None), + Input::Str { input, name } => { + new_parser_from_source_str(&sess.psess, name.clone(), input.clone()) + } + }); + parser.parse_crate_mod() + }) + .map_err(|parse_error| parse_error.emit())?; if sess.opts.unstable_opts.input_stats { eprintln!("Lines of code: {}", sess.source_map().count_lines()); @@ -559,7 +562,7 @@ fn resolver_for_lowering_raw<'tcx>( (tcx.arena.alloc(Steal::new((untracked_resolver_for_lowering, Lrc::new(krate)))), resolutions) } -pub(crate) fn write_dep_info(tcx: TyCtxt<'_>) { +pub fn write_dep_info(tcx: TyCtxt<'_>) { // Make sure name resolution and macro expansion is run for // the side-effect of providing a complete set of all // accessed files and env vars. @@ -640,22 +643,48 @@ pub static DEFAULT_QUERY_PROVIDERS: LazyLock<Providers> = LazyLock::new(|| { *providers }); -pub fn create_global_ctxt<'tcx>( +pub(crate) fn create_global_ctxt<'tcx>( compiler: &'tcx Compiler, - crate_types: Vec<CrateType>, - stable_crate_id: StableCrateId, - dep_graph: DepGraph, - untracked: Untracked, + mut krate: rustc_ast::Crate, gcx_cell: &'tcx OnceLock<GlobalCtxt<'tcx>>, arena: &'tcx WorkerLocal<Arena<'tcx>>, hir_arena: &'tcx WorkerLocal<rustc_hir::Arena<'tcx>>, -) -> &'tcx GlobalCtxt<'tcx> { +) -> Result<&'tcx GlobalCtxt<'tcx>> { + let sess = &compiler.sess; + + rustc_builtin_macros::cmdline_attrs::inject( + &mut krate, + &sess.psess, + &sess.opts.unstable_opts.crate_attr, + ); + + let pre_configured_attrs = rustc_expand::config::pre_configure_attrs(sess, &krate.attrs); + + // parse `#[crate_name]` even if `--crate-name` was passed, to make sure it matches. + let crate_name = find_crate_name(sess, &pre_configured_attrs); + let crate_types = collect_crate_types(sess, &pre_configured_attrs); + let stable_crate_id = StableCrateId::new( + crate_name, + crate_types.contains(&CrateType::Executable), + sess.opts.cg.metadata.clone(), + sess.cfg_version, + ); + let outputs = util::build_output_filenames(&pre_configured_attrs, sess); + let dep_graph = setup_dep_graph(sess)?; + + let cstore = + FreezeLock::new(Box::new(CStore::new(compiler.codegen_backend.metadata_loader())) as _); + let definitions = FreezeLock::new(Definitions::new(stable_crate_id)); + + let stable_crate_ids = FreezeLock::new(StableCrateIdMap::default()); + let untracked = + Untracked { cstore, source_span: AppendOnlyIndexVec::new(), definitions, stable_crate_ids }; + // We're constructing the HIR here; we don't care what we will // read, since we haven't even constructed the *input* to // incr. comp. yet. dep_graph.assert_ignored(); - let sess = &compiler.sess; let query_result_on_disk_cache = rustc_incremental::load_query_result_cache(sess); let codegen_backend = &compiler.codegen_backend; @@ -669,7 +698,7 @@ pub fn create_global_ctxt<'tcx>( let incremental = dep_graph.is_fully_enabled(); sess.time("setup_global_ctxt", || { - gcx_cell.get_or_init(move || { + let qcx = gcx_cell.get_or_init(move || { TyCtxt::create_global_ctxt( sess, crate_types, @@ -688,7 +717,23 @@ pub fn create_global_ctxt<'tcx>( providers.hooks, compiler.current_gcx.clone(), ) - }) + }); + + qcx.enter(|tcx| { + let feed = tcx.create_crate_num(stable_crate_id).unwrap(); + assert_eq!(feed.key(), LOCAL_CRATE); + feed.crate_name(crate_name); + + let feed = tcx.feed_unit_query(); + feed.features_query(tcx.arena.alloc(rustc_expand::config::features( + sess, + &pre_configured_attrs, + crate_name, + ))); + feed.crate_for_resolver(tcx.arena.alloc(Steal::new((krate, pre_configured_attrs)))); + feed.output_filenames(Arc::new(outputs)); + }); + Ok(qcx) }) } @@ -924,12 +969,56 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> { Ok(()) } +/// Check for the `#[rustc_error]` annotation, which forces an error in codegen. This is used +/// to write UI tests that actually test that compilation succeeds without reporting +/// an error. +fn check_for_rustc_errors_attr(tcx: TyCtxt<'_>) { + let Some((def_id, _)) = tcx.entry_fn(()) else { return }; + for attr in tcx.get_attrs(def_id, sym::rustc_error) { + match attr.meta_item_list() { + // Check if there is a `#[rustc_error(delayed_bug_from_inside_query)]`. + Some(list) + if list.iter().any(|list_item| { + matches!( + list_item.ident().map(|i| i.name), + Some(sym::delayed_bug_from_inside_query) + ) + }) => + { + tcx.ensure().trigger_delayed_bug(def_id); + } + + // Bare `#[rustc_error]`. + None => { + tcx.dcx().emit_fatal(errors::RustcErrorFatal { span: tcx.def_span(def_id) }); + } + + // Some other attribute. + Some(_) => { + tcx.dcx().emit_warn(errors::RustcErrorUnexpectedAnnotation { + span: tcx.def_span(def_id), + }); + } + } + } +} + /// Runs the codegen backend, after which the AST and analysis can /// be discarded. -pub fn start_codegen<'tcx>( +pub(crate) fn start_codegen<'tcx>( codegen_backend: &dyn CodegenBackend, tcx: TyCtxt<'tcx>, -) -> Box<dyn Any> { +) -> Result<Box<dyn Any>> { + // Don't do code generation if there were any errors. Likewise if + // there were any delayed bugs, because codegen will likely cause + // more ICEs, obscuring the original problem. + if let Some(guar) = tcx.sess.dcx().has_errors_or_delayed_bugs() { + return Err(guar); + } + + // Hook for UI tests. + check_for_rustc_errors_attr(tcx); + info!("Pre-codegen\n{:?}", tcx.debug_stats()); let (metadata, need_metadata_module) = rustc_metadata::fs::encode_and_write_metadata(tcx); @@ -952,7 +1041,7 @@ pub fn start_codegen<'tcx>( } } - codegen + Ok(codegen) } fn get_recursion_limit(krate_attrs: &[ast::Attribute], sess: &Session) -> Limit { diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs index 1b9165342d4..cfd4304e893 100644 --- a/compiler/rustc_interface/src/queries.rs +++ b/compiler/rustc_interface/src/queries.rs @@ -1,26 +1,20 @@ -use crate::errors::{FailedWritingFile, RustcErrorFatal, RustcErrorUnexpectedAnnotation}; +use crate::errors::FailedWritingFile; use crate::interface::{Compiler, Result}; -use crate::{errors, passes, util}; +use crate::{errors, passes}; use rustc_ast as ast; use rustc_codegen_ssa::traits::CodegenBackend; use rustc_codegen_ssa::CodegenResults; use rustc_data_structures::steal::Steal; use rustc_data_structures::svh::Svh; -use rustc_data_structures::sync::{AppendOnlyIndexVec, FreezeLock, OnceLock, WorkerLocal}; -use rustc_hir::def_id::{StableCrateId, StableCrateIdMap, LOCAL_CRATE}; -use rustc_hir::definitions::Definitions; -use rustc_incremental::setup_dep_graph; -use rustc_metadata::creader::CStore; +use rustc_data_structures::sync::{OnceLock, WorkerLocal}; +use rustc_hir::def_id::LOCAL_CRATE; use rustc_middle::arena::Arena; use rustc_middle::dep_graph::DepGraph; use rustc_middle::ty::{GlobalCtxt, TyCtxt}; use rustc_serialize::opaque::FileEncodeResult; -use rustc_session::config::{self, CrateType, OutputFilenames, OutputType}; -use rustc_session::cstore::Untracked; -use rustc_session::output::{collect_crate_types, find_crate_name}; +use rustc_session::config::{self, OutputFilenames, OutputType}; use rustc_session::Session; -use rustc_span::symbol::sym; use std::any::Any; use std::cell::{RefCell, RefMut}; use std::sync::Arc; @@ -106,133 +100,26 @@ impl<'tcx> Queries<'tcx> { } pub fn parse(&self) -> Result<QueryResult<'_, ast::Crate>> { - self.parse.compute(|| { - passes::parse(&self.compiler.sess).map_err(|parse_error| parse_error.emit()) - }) + self.parse.compute(|| passes::parse(&self.compiler.sess)) } pub fn global_ctxt(&'tcx self) -> Result<QueryResult<'_, &'tcx GlobalCtxt<'tcx>>> { self.gcx.compute(|| { - let sess = &self.compiler.sess; - - let mut krate = self.parse()?.steal(); - - rustc_builtin_macros::cmdline_attrs::inject( - &mut krate, - &sess.psess, - &sess.opts.unstable_opts.crate_attr, - ); - - let pre_configured_attrs = - rustc_expand::config::pre_configure_attrs(sess, &krate.attrs); - - // parse `#[crate_name]` even if `--crate-name` was passed, to make sure it matches. - let crate_name = find_crate_name(sess, &pre_configured_attrs); - let crate_types = collect_crate_types(sess, &pre_configured_attrs); - let stable_crate_id = StableCrateId::new( - crate_name, - crate_types.contains(&CrateType::Executable), - sess.opts.cg.metadata.clone(), - sess.cfg_version, - ); - let outputs = util::build_output_filenames(&pre_configured_attrs, sess); - let dep_graph = setup_dep_graph(sess)?; - - let cstore = FreezeLock::new(Box::new(CStore::new( - self.compiler.codegen_backend.metadata_loader(), - )) as _); - let definitions = FreezeLock::new(Definitions::new(stable_crate_id)); - - let stable_crate_ids = FreezeLock::new(StableCrateIdMap::default()); - let untracked = Untracked { - cstore, - source_span: AppendOnlyIndexVec::new(), - definitions, - stable_crate_ids, - }; - - let qcx = passes::create_global_ctxt( + let krate = self.parse()?.steal(); + + passes::create_global_ctxt( self.compiler, - crate_types, - stable_crate_id, - dep_graph, - untracked, + krate, &self.gcx_cell, &self.arena, &self.hir_arena, - ); - - qcx.enter(|tcx| { - let feed = tcx.create_crate_num(stable_crate_id).unwrap(); - assert_eq!(feed.key(), LOCAL_CRATE); - feed.crate_name(crate_name); - - let feed = tcx.feed_unit_query(); - feed.features_query(tcx.arena.alloc(rustc_expand::config::features( - sess, - &pre_configured_attrs, - crate_name, - ))); - feed.crate_for_resolver(tcx.arena.alloc(Steal::new((krate, pre_configured_attrs)))); - feed.output_filenames(Arc::new(outputs)); - }); - Ok(qcx) + ) }) } - pub fn write_dep_info(&'tcx self) -> Result<()> { - self.global_ctxt()?.enter(|tcx| { - passes::write_dep_info(tcx); - }); - Ok(()) - } - - /// Check for the `#[rustc_error]` annotation, which forces an error in codegen. This is used - /// to write UI tests that actually test that compilation succeeds without reporting - /// an error. - fn check_for_rustc_errors_attr(tcx: TyCtxt<'_>) { - let Some((def_id, _)) = tcx.entry_fn(()) else { return }; - for attr in tcx.get_attrs(def_id, sym::rustc_error) { - match attr.meta_item_list() { - // Check if there is a `#[rustc_error(delayed_bug_from_inside_query)]`. - Some(list) - if list.iter().any(|list_item| { - matches!( - list_item.ident().map(|i| i.name), - Some(sym::delayed_bug_from_inside_query) - ) - }) => - { - tcx.ensure().trigger_delayed_bug(def_id); - } - - // Bare `#[rustc_error]`. - None => { - tcx.dcx().emit_fatal(RustcErrorFatal { span: tcx.def_span(def_id) }); - } - - // Some other attribute. - Some(_) => { - tcx.dcx() - .emit_warn(RustcErrorUnexpectedAnnotation { span: tcx.def_span(def_id) }); - } - } - } - } - pub fn codegen_and_build_linker(&'tcx self) -> Result<Linker> { self.global_ctxt()?.enter(|tcx| { - // Don't do code generation if there were any errors. Likewise if - // there were any delayed bugs, because codegen will likely cause - // more ICEs, obscuring the original problem. - if let Some(guar) = self.compiler.sess.dcx().has_errors_or_delayed_bugs() { - return Err(guar); - } - - // Hook for UI tests. - Self::check_for_rustc_errors_attr(tcx); - - let ongoing_codegen = passes::start_codegen(&*self.compiler.codegen_backend, tcx); + let ongoing_codegen = passes::start_codegen(&*self.compiler.codegen_backend, tcx)?; Ok(Linker { dep_graph: tcx.dep_graph.clone(), diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index eac5083ffbf..46cf87d1e3c 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -604,6 +604,9 @@ lint_opaque_hidden_inferred_bound_sugg = add this bound lint_or_patterns_back_compat = the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro .suggestion = use pat_param to preserve semantics +lint_out_of_scope_macro_calls = cannot find macro `{$path}` in this scope + .help = import `macro_rules` with `use` to make it callable above its definition + lint_overflowing_bin_hex = literal out of range for `{$ty}` .negative_note = the literal `{$lit}` (decimal `{$dec}`) does not fit into the type `{$ty}` .negative_becomes_note = and the value `-{$lit}` will become `{$actually}{$ty}` diff --git a/compiler/rustc_lint/src/context/diagnostics.rs b/compiler/rustc_lint/src/context/diagnostics.rs index adb2a3275c0..05e075205c4 100644 --- a/compiler/rustc_lint/src/context/diagnostics.rs +++ b/compiler/rustc_lint/src/context/diagnostics.rs @@ -434,5 +434,8 @@ pub(super) fn decorate_lint(sess: &Session, diagnostic: BuiltinLintDiag, diag: & lints::InnerAttributeUnstable::CustomInnerAttribute } .decorate_lint(diag), + BuiltinLintDiag::OutOfScopeMacroCalls { path } => { + lints::OutOfScopeMacroCalls { path }.decorate_lint(diag) + } } } diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 6df3a11deb0..14084405d0e 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -2911,3 +2911,10 @@ pub struct UnsafeAttrOutsideUnsafeSuggestion { #[suggestion_part(code = ")")] pub right: Span, } + +#[derive(LintDiagnostic)] +#[diag(lint_out_of_scope_macro_calls)] +#[help] +pub struct OutOfScopeMacroCalls { + pub path: String, +} diff --git a/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs b/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs index 7aef6321eeb..8b669bcc13f 100644 --- a/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs +++ b/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs @@ -109,7 +109,7 @@ impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound { return; } - let proj_ty = Ty::new_projection( + let proj_ty = Ty::new_projection_from_args( cx.tcx, proj.projection_term.def_id, proj.projection_term.args, diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 265779c9374..a023d6161df 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -4945,3 +4945,42 @@ declare_lint! { reference: "issue #123757 <https://github.com/rust-lang/rust/issues/123757>", }; } + +declare_lint! { + /// The `out_of_scope_macro_calls` lint detects `macro_rules` called when they are not in scope, + /// above their definition, which may happen in key-value attributes. + /// + /// ### Example + /// + /// ```rust + /// #![doc = in_root!()] + /// + /// macro_rules! in_root { () => { "" } } + /// + /// fn main() {} + /// ``` + /// + /// {{produces}} + /// + /// ### Explanation + /// + /// The scope in which a `macro_rules` item is visible starts at that item and continues + /// below it. This is more similar to `let` than to other items, which are in scope both above + /// and below their definition. + /// Due to a bug `macro_rules` were accidentally in scope inside some key-value attributes + /// above their definition. The lint catches such cases. + /// To address the issue turn the `macro_rules` into a regularly scoped item by importing it + /// with `use`. + /// + /// This is a [future-incompatible] lint to transition this to a + /// hard error in the future. + /// + /// [future-incompatible]: ../index.md#future-incompatible-lints + pub OUT_OF_SCOPE_MACRO_CALLS, + Warn, + "detects out of scope calls to `macro_rules` in key-value attributes", + @future_incompatible = FutureIncompatibleInfo { + reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps, + reference: "issue #124535 <https://github.com/rust-lang/rust/issues/124535>", + }; +} diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index f33aadfbbc8..b44eb252167 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -744,6 +744,9 @@ pub enum BuiltinLintDiag { InnerAttributeUnstable { is_macro: bool, }, + OutOfScopeMacroCalls { + path: String, + }, } /// Lints that are buffered up early on in the `Session` before the diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 01cefc75194..ef88b253864 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -1817,11 +1817,11 @@ mod size_asserts { use super::*; use rustc_data_structures::static_assert_size; // tidy-alphabetical-start - static_assert_size!(BasicBlockData<'_>, 144); + static_assert_size!(BasicBlockData<'_>, 128); static_assert_size!(LocalDecl<'_>, 40); static_assert_size!(SourceScopeData<'_>, 64); static_assert_size!(Statement<'_>, 32); - static_assert_size!(Terminator<'_>, 112); + static_assert_size!(Terminator<'_>, 96); static_assert_size!(VarDebugInfo<'_>, 88); // tidy-alphabetical-end } diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs index 0fc84ea5c62..2c2884f1897 100644 --- a/compiler/rustc_middle/src/mir/syntax.rs +++ b/compiler/rustc_middle/src/mir/syntax.rs @@ -730,7 +730,7 @@ pub enum TerminatorKind<'tcx> { /// reused across function calls without duplicating the contents. /// The span for each arg is also included /// (e.g. `a` and `b` in `x.foo(a, b)`). - args: Vec<Spanned<Operand<'tcx>>>, + args: Box<[Spanned<Operand<'tcx>>]>, /// Where the returned value will be written destination: Place<'tcx>, /// Where to go after this call returns. If none, the call necessarily diverges. @@ -837,7 +837,7 @@ pub enum TerminatorKind<'tcx> { template: &'tcx [InlineAsmTemplatePiece], /// The operands for the inline assembly, as `Operand`s or `Place`s. - operands: Vec<InlineAsmOperand<'tcx>>, + operands: Box<[InlineAsmOperand<'tcx>]>, /// Miscellaneous options for the inline assembly. options: InlineAsmOptions, @@ -849,7 +849,7 @@ pub enum TerminatorKind<'tcx> { /// Valid targets for the inline assembly. /// The first element is the fallthrough destination, unless /// InlineAsmOptions::NORETURN is set. - targets: Vec<BasicBlock>, + targets: Box<[BasicBlock]>, /// Action to be taken if the inline assembly unwinds. This is present /// if and only if InlineAsmOptions::MAY_UNWIND is set. @@ -1561,6 +1561,6 @@ mod size_asserts { static_assert_size!(PlaceElem<'_>, 24); static_assert_size!(Rvalue<'_>, 40); static_assert_size!(StatementKind<'_>, 16); - static_assert_size!(TerminatorKind<'_>, 96); + static_assert_size!(TerminatorKind<'_>, 80); // tidy-alphabetical-end } diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 7848aa21eac..4bac9396e59 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -240,7 +240,7 @@ impl<'tcx> Interner for TyCtxt<'tcx> { assert_matches!(self.def_kind(trait_def_id), DefKind::Trait); let trait_generics = self.generics_of(trait_def_id); ( - ty::TraitRef::new(self, trait_def_id, args.truncate_to(self, trait_generics)), + ty::TraitRef::new_from_args(self, trait_def_id, args.truncate_to(self, trait_generics)), &args[trait_generics.count()..], ) } @@ -261,12 +261,8 @@ impl<'tcx> Interner for TyCtxt<'tcx> { self.check_args_compatible(def_id, args) } - fn check_and_mk_args( - self, - def_id: DefId, - args: impl IntoIterator<Item: Into<ty::GenericArg<'tcx>>>, - ) -> ty::GenericArgsRef<'tcx> { - self.check_and_mk_args(def_id, args) + fn debug_assert_args_compatible(self, def_id: DefId, args: ty::GenericArgsRef<'tcx>) { + self.debug_assert_args_compatible(def_id, args); } fn intern_canonical_goal_evaluation_step( diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index f608b02f42c..eb25aecd9ce 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -309,7 +309,8 @@ impl<'tcx> LayoutCalculator for LayoutCx<'tcx, TyCtxt<'tcx>> { #[derive(Copy, Clone, Debug)] pub enum SizeSkeleton<'tcx> { /// Any statically computable Layout. - Known(Size), + /// Alignment can be `None` if unknown. + Known(Size, Option<Align>), /// This is a generic const expression (i.e. N * 2), which may contain some parameters. /// It must be of type usize, and represents the size of a type in bytes. @@ -339,7 +340,12 @@ impl<'tcx> SizeSkeleton<'tcx> { // First try computing a static layout. let err = match tcx.layout_of(param_env.and(ty)) { Ok(layout) => { - return Ok(SizeSkeleton::Known(layout.size)); + if layout.abi.is_sized() { + return Ok(SizeSkeleton::Known(layout.size, Some(layout.align.abi))); + } else { + // Just to be safe, don't claim a known layout for unsized types. + return Err(tcx.arena.alloc(LayoutError::Unknown(ty))); + } } Err(err @ LayoutError::Unknown(_)) => err, // We can't extract SizeSkeleton info from other layout errors @@ -389,19 +395,20 @@ impl<'tcx> SizeSkeleton<'tcx> { ty::Array(inner, len) if tcx.features().transmute_generic_consts => { let len_eval = len.try_eval_target_usize(tcx, param_env); if len_eval == Some(0) { - return Ok(SizeSkeleton::Known(Size::from_bytes(0))); + return Ok(SizeSkeleton::Known(Size::from_bytes(0), None)); } match SizeSkeleton::compute(inner, tcx, param_env)? { // This may succeed because the multiplication of two types may overflow // but a single size of a nested array will not. - SizeSkeleton::Known(s) => { + SizeSkeleton::Known(s, a) => { if let Some(c) = len_eval { let size = s .bytes() .checked_mul(c) .ok_or_else(|| &*tcx.arena.alloc(LayoutError::SizeOverflow(ty)))?; - return Ok(SizeSkeleton::Known(Size::from_bytes(size))); + // Alignment is unchanged by arrays. + return Ok(SizeSkeleton::Known(Size::from_bytes(size), a)); } Err(tcx.arena.alloc(LayoutError::Unknown(ty))) } @@ -427,8 +434,10 @@ impl<'tcx> SizeSkeleton<'tcx> { for field in fields { let field = field?; match field { - SizeSkeleton::Known(size) => { - if size.bytes() > 0 { + SizeSkeleton::Known(size, align) => { + let is_1zst = size.bytes() == 0 + && align.is_some_and(|align| align.bytes() == 1); + if !is_1zst { return Err(err); } } @@ -492,7 +501,7 @@ impl<'tcx> SizeSkeleton<'tcx> { pub fn same_size(self, other: SizeSkeleton<'tcx>) -> bool { match (self, other) { - (SizeSkeleton::Known(a), SizeSkeleton::Known(b)) => a == b, + (SizeSkeleton::Known(a, _), SizeSkeleton::Known(b, _)) => a == b, (SizeSkeleton::Pointer { tail: a, .. }, SizeSkeleton::Pointer { tail: b, .. }) => { a == b } diff --git a/compiler/rustc_middle/src/ty/list.rs b/compiler/rustc_middle/src/ty/list.rs index 71a93cc520d..73eba93194e 100644 --- a/compiler/rustc_middle/src/ty/list.rs +++ b/compiler/rustc_middle/src/ty/list.rs @@ -133,6 +133,20 @@ impl<H, T> RawList<H, T> { } } +impl<'a, H, T: Copy> rustc_type_ir::inherent::SliceLike for &'a RawList<H, T> { + type Item = T; + + type IntoIter = iter::Copied<<&'a [T] as IntoIterator>::IntoIter>; + + fn iter(self) -> Self::IntoIter { + (*self).iter() + } + + fn as_slice(&self) -> &[Self::Item] { + (*self).as_slice() + } +} + macro_rules! impl_list_empty { ($header_ty:ty, $header_init:expr) => { impl<T> RawList<$header_ty, T> { diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 709c5fe2305..ff40a726fbc 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -499,7 +499,7 @@ impl<'tcx> Ty<'tcx> { #[inline] pub fn new_opaque(tcx: TyCtxt<'tcx>, def_id: DefId, args: GenericArgsRef<'tcx>) -> Ty<'tcx> { - Ty::new_alias(tcx, ty::Opaque, AliasTy::new(tcx, def_id, args)) + Ty::new_alias(tcx, ty::Opaque, AliasTy::new_from_args(tcx, def_id, args)) } /// Constructs a `TyKind::Error` type with current `ErrorGuaranteed` @@ -670,6 +670,15 @@ impl<'tcx> Ty<'tcx> { } #[inline] + pub fn new_projection_from_args( + tcx: TyCtxt<'tcx>, + item_def_id: DefId, + args: ty::GenericArgsRef<'tcx>, + ) -> Ty<'tcx> { + Ty::new_alias(tcx, ty::Projection, AliasTy::new_from_args(tcx, item_def_id, args)) + } + + #[inline] pub fn new_projection( tcx: TyCtxt<'tcx>, item_def_id: DefId, @@ -1409,7 +1418,7 @@ impl<'tcx> Ty<'tcx> { let assoc_items = tcx.associated_item_def_ids( tcx.require_lang_item(hir::LangItem::DiscriminantKind, None), ); - Ty::new_projection(tcx, assoc_items[0], tcx.mk_args(&[self.into()])) + Ty::new_projection_from_args(tcx, assoc_items[0], tcx.mk_args(&[self.into()])) } ty::Pat(ty, _) => ty.discriminant_ty(tcx), diff --git a/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs b/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs index 7549481c1b3..94ab2fb4581 100644 --- a/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs +++ b/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs @@ -170,7 +170,7 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> { .map(|arg| Ok(Spanned { node: self.parse_operand(*arg)?, span: self.thir.exprs[*arg].span } ) ) - .collect::<PResult<Vec<_>>>()?; + .collect::<PResult<Box<[_]>>>()?; Ok(TerminatorKind::Call { func: fun, args, diff --git a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs index 9f9b566bb8f..c5ee6db5999 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs @@ -152,10 +152,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { source_info, TerminatorKind::Call { func: exchange_malloc, - args: vec![ + args: [ Spanned { node: Operand::Move(size), span: DUMMY_SP }, Spanned { node: Operand::Move(align), span: DUMMY_SP }, - ], + ] + .into(), destination: storage, target: Some(success), unwind: UnwindAction::Continue, diff --git a/compiler/rustc_mir_build/src/build/expr/into.rs b/compiler/rustc_mir_build/src/build/expr/into.rs index 6b4dd8b64a4..76bdc26a501 100644 --- a/compiler/rustc_mir_build/src/build/expr/into.rs +++ b/compiler/rustc_mir_build/src/build/expr/into.rs @@ -238,7 +238,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } ExprKind::Call { ty: _, fun, ref args, from_hir_call, fn_span } => { let fun = unpack!(block = this.as_local_operand(block, fun)); - let args: Vec<_> = args + let args: Box<[_]> = args .into_iter() .copied() .map(|arg| Spanned { @@ -485,7 +485,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { operands, options, line_spans, - targets, + targets: targets.into_boxed_slice(), unwind: if options.contains(InlineAsmOptions::MAY_UNWIND) { UnwindAction::Continue } else { diff --git a/compiler/rustc_mir_build/src/build/matches/test.rs b/compiler/rustc_mir_build/src/build/matches/test.rs index 11d3e2a8180..d29874a5ad4 100644 --- a/compiler/rustc_mir_build/src/build/matches/test.rs +++ b/compiler/rustc_mir_build/src/build/matches/test.rs @@ -324,7 +324,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { user_ty: None, const_: method, })), - args: vec![Spanned { node: Operand::Move(ref_src), span }], + args: [Spanned { node: Operand::Move(ref_src), span }].into(), destination: temp, target: Some(target_block), unwind: UnwindAction::Continue, @@ -486,10 +486,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { const_: method, })), - args: vec![ + args: [ Spanned { node: Operand::Copy(val), span: DUMMY_SP }, Spanned { node: expect, span: DUMMY_SP }, - ], + ] + .into(), destination: eq_result, target: Some(eq_block), unwind: UnwindAction::Continue, diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs index dda6c88008b..8c6c9e10cdf 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs @@ -220,7 +220,7 @@ impl<'tcx> ConstToPat<'tcx> { tcx, ObligationCause::dummy(), self.param_env, - ty::TraitRef::new( + ty::TraitRef::new_from_args( tcx, partial_eq_trait_id, tcx.with_opt_host_effect_param( diff --git a/compiler/rustc_mir_dataflow/src/elaborate_drops.rs b/compiler/rustc_mir_dataflow/src/elaborate_drops.rs index 654020164db..e0da9600ae3 100644 --- a/compiler/rustc_mir_dataflow/src/elaborate_drops.rs +++ b/compiler/rustc_mir_dataflow/src/elaborate_drops.rs @@ -650,10 +650,8 @@ where [ty.into()], self.source_info.span, ), - args: vec![Spanned { - node: Operand::Move(Place::from(ref_place)), - span: DUMMY_SP, - }], + args: [Spanned { node: Operand::Move(Place::from(ref_place)), span: DUMMY_SP }] + .into(), destination: unit_temp, target: Some(succ), unwind: unwind.into_action(), diff --git a/compiler/rustc_mir_dataflow/src/framework/tests.rs b/compiler/rustc_mir_dataflow/src/framework/tests.rs index 6b338efd569..52db931b68e 100644 --- a/compiler/rustc_mir_dataflow/src/framework/tests.rs +++ b/compiler/rustc_mir_dataflow/src/framework/tests.rs @@ -34,7 +34,7 @@ fn mock_body<'tcx>() -> mir::Body<'tcx> { 2, mir::TerminatorKind::Call { func: mir::Operand::Copy(dummy_place.clone()), - args: vec![], + args: [].into(), destination: dummy_place.clone(), target: Some(mir::START_BLOCK), unwind: mir::UnwindAction::Continue, @@ -48,7 +48,7 @@ fn mock_body<'tcx>() -> mir::Body<'tcx> { 4, mir::TerminatorKind::Call { func: mir::Operand::Copy(dummy_place.clone()), - args: vec![], + args: [].into(), destination: dummy_place.clone(), target: Some(mir::START_BLOCK), unwind: mir::UnwindAction::Continue, diff --git a/compiler/rustc_mir_transform/src/coroutine.rs b/compiler/rustc_mir_transform/src/coroutine.rs index bf79b4e133a..05674792426 100644 --- a/compiler/rustc_mir_transform/src/coroutine.rs +++ b/compiler/rustc_mir_transform/src/coroutine.rs @@ -677,8 +677,8 @@ fn transform_async_context<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { fn eliminate_get_context_call<'tcx>(bb_data: &mut BasicBlockData<'tcx>) -> Local { let terminator = bb_data.terminator.take().unwrap(); - if let TerminatorKind::Call { mut args, destination, target, .. } = terminator.kind { - let arg = args.pop().unwrap(); + if let TerminatorKind::Call { args, destination, target, .. } = terminator.kind { + let [arg] = *Box::try_from(args).unwrap(); let local = arg.node.place().unwrap().local; let arg = Rvalue::Use(arg.node); diff --git a/compiler/rustc_mir_transform/src/coverage/tests.rs b/compiler/rustc_mir_transform/src/coverage/tests.rs index 048547dc9f5..63a9f303b85 100644 --- a/compiler/rustc_mir_transform/src/coverage/tests.rs +++ b/compiler/rustc_mir_transform/src/coverage/tests.rs @@ -134,7 +134,7 @@ impl<'tcx> MockBlocks<'tcx> { some_from_block, TerminatorKind::Call { func: Operand::Copy(self.dummy_place.clone()), - args: vec![], + args: [].into(), destination: self.dummy_place.clone(), target: Some(TEMP_BLOCK), unwind: UnwindAction::Continue, diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index 32b5d812025..0a5fc697d03 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -624,8 +624,7 @@ impl<'tcx> Inliner<'tcx> { }; // Copy the arguments if needed. - let args: Vec<_> = - self.make_call_args(args, &callsite, caller_body, &callee_body, return_block); + let args = self.make_call_args(args, &callsite, caller_body, &callee_body, return_block); let mut integrator = Integrator { args: &args, @@ -736,12 +735,12 @@ impl<'tcx> Inliner<'tcx> { fn make_call_args( &self, - args: Vec<Spanned<Operand<'tcx>>>, + args: Box<[Spanned<Operand<'tcx>>]>, callsite: &CallSite<'tcx>, caller_body: &mut Body<'tcx>, callee_body: &Body<'tcx>, return_block: Option<BasicBlock>, - ) -> Vec<Local> { + ) -> Box<[Local]> { let tcx = self.tcx; // There is a bit of a mismatch between the *caller* of a closure and the *callee*. @@ -768,7 +767,8 @@ impl<'tcx> Inliner<'tcx> { // // and the vector is `[closure_ref, tmp0, tmp1, tmp2]`. if callsite.fn_sig.abi() == Abi::RustCall && callee_body.spread_arg.is_none() { - let mut args = args.into_iter(); + // FIXME(edition_2024): switch back to a normal method call. + let mut args = <_>::into_iter(args); let self_ = self.create_temp_if_necessary( args.next().unwrap().node, callsite, @@ -802,7 +802,8 @@ impl<'tcx> Inliner<'tcx> { closure_ref_arg.chain(tuple_tmp_args).collect() } else { - args.into_iter() + // FIXME(edition_2024): switch back to a normal method call. + <_>::into_iter(args) .map(|a| self.create_temp_if_necessary(a.node, callsite, caller_body, return_block)) .collect() } diff --git a/compiler/rustc_mir_transform/src/instsimplify.rs b/compiler/rustc_mir_transform/src/instsimplify.rs index 6806c517c17..8209e5e2711 100644 --- a/compiler/rustc_mir_transform/src/instsimplify.rs +++ b/compiler/rustc_mir_transform/src/instsimplify.rs @@ -1,6 +1,7 @@ //! Performs various peephole optimizations. use crate::simplify::simplify_duplicate_switch_targets; +use crate::take_array; use rustc_ast::attr; use rustc_middle::bug; use rustc_middle::mir::*; @@ -285,7 +286,8 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> { return; } - let Some(arg_place) = args.pop().unwrap().node.place() else { return }; + let Ok([arg]) = take_array(args) else { return }; + let Some(arg_place) = arg.node.place() else { return }; statements.push(Statement { source_info: terminator.source_info, diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index fe195f0112f..f7056702cb4 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -160,8 +160,9 @@ fn remap_mir_for_const_eval_select<'tcx>( } if let ty::FnDef(def_id, _) = *const_.ty().kind() && tcx.is_intrinsic(def_id, sym::const_eval_select) => { - let [tupled_args, called_in_const, called_at_rt]: [_; 3] = - std::mem::take(args).try_into().unwrap(); + let Ok([tupled_args, called_in_const, called_at_rt]) = take_array(args) else { + unreachable!() + }; let ty = tupled_args.node.ty(&body.local_decls, tcx); let fields = ty.tuple_fields(); let num_args = fields.len(); @@ -211,6 +212,11 @@ fn remap_mir_for_const_eval_select<'tcx>( body } +fn take_array<T, const N: usize>(b: &mut Box<[T]>) -> Result<[T; N], Box<[T]>> { + let b: Box<[T; N]> = std::mem::take(b).try_into()?; + Ok(*b) +} + fn is_mir_available(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { tcx.mir_keys(()).contains(&def_id) } diff --git a/compiler/rustc_mir_transform/src/lower_intrinsics.rs b/compiler/rustc_mir_transform/src/lower_intrinsics.rs index 3ffc447217d..6aa90394355 100644 --- a/compiler/rustc_mir_transform/src/lower_intrinsics.rs +++ b/compiler/rustc_mir_transform/src/lower_intrinsics.rs @@ -1,5 +1,6 @@ //! Lowers intrinsic calls +use crate::take_array; use rustc_middle::mir::*; use rustc_middle::ty::{self, TyCtxt}; use rustc_middle::{bug, span_bug}; @@ -50,42 +51,34 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics { } sym::copy_nonoverlapping => { let target = target.unwrap(); - let mut args = args.drain(..); + let Ok([src, dst, count]) = take_array(args) else { + bug!("Wrong arguments for copy_non_overlapping intrinsic"); + }; block.statements.push(Statement { source_info: terminator.source_info, kind: StatementKind::Intrinsic(Box::new( NonDivergingIntrinsic::CopyNonOverlapping( rustc_middle::mir::CopyNonOverlapping { - src: args.next().unwrap().node, - dst: args.next().unwrap().node, - count: args.next().unwrap().node, + src: src.node, + dst: dst.node, + count: count.node, }, ), )), }); - assert_eq!( - args.next(), - None, - "Extra argument for copy_non_overlapping intrinsic" - ); - drop(args); terminator.kind = TerminatorKind::Goto { target }; } sym::assume => { let target = target.unwrap(); - let mut args = args.drain(..); + let Ok([arg]) = take_array(args) else { + bug!("Wrong arguments for assume intrinsic"); + }; block.statements.push(Statement { source_info: terminator.source_info, kind: StatementKind::Intrinsic(Box::new( - NonDivergingIntrinsic::Assume(args.next().unwrap().node), + NonDivergingIntrinsic::Assume(arg.node), )), }); - assert_eq!( - args.next(), - None, - "Extra argument for copy_non_overlapping intrinsic" - ); - drop(args); terminator.kind = TerminatorKind::Goto { target }; } sym::wrapping_add @@ -100,13 +93,9 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics { | sym::unchecked_shl | sym::unchecked_shr => { let target = target.unwrap(); - let lhs; - let rhs; - { - let mut args = args.drain(..); - lhs = args.next().unwrap(); - rhs = args.next().unwrap(); - } + let Ok([lhs, rhs]) = take_array(args) else { + bug!("Wrong arguments for {} intrinsic", intrinsic.name); + }; let bin_op = match intrinsic.name { sym::wrapping_add => BinOp::Add, sym::wrapping_sub => BinOp::Sub, @@ -132,13 +121,9 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics { } sym::add_with_overflow | sym::sub_with_overflow | sym::mul_with_overflow => { if let Some(target) = *target { - let lhs; - let rhs; - { - let mut args = args.drain(..); - lhs = args.next().unwrap(); - rhs = args.next().unwrap(); - } + let Ok([lhs, rhs]) = take_array(args) else { + bug!("Wrong arguments for {} intrinsic", intrinsic.name); + }; let bin_op = match intrinsic.name { sym::add_with_overflow => BinOp::AddWithOverflow, sym::sub_with_overflow => BinOp::SubWithOverflow, @@ -174,7 +159,7 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics { } } sym::read_via_copy => { - let [arg] = args.as_slice() else { + let Ok([arg]) = take_array(args) else { span_bug!(terminator.source_info.span, "Wrong number of arguments"); }; let derefed_place = if let Some(place) = arg.node.place() @@ -207,7 +192,7 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics { } sym::write_via_move => { let target = target.unwrap(); - let Ok([ptr, val]) = <[_; 2]>::try_from(std::mem::take(args)) else { + let Ok([ptr, val]) = take_array(args) else { span_bug!( terminator.source_info.span, "Wrong number of arguments for write_via_move intrinsic", @@ -247,7 +232,7 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics { } sym::offset => { let target = target.unwrap(); - let Ok([ptr, delta]) = <[_; 2]>::try_from(std::mem::take(args)) else { + let Ok([ptr, delta]) = take_array(args) else { span_bug!( terminator.source_info.span, "Wrong number of arguments for offset intrinsic", @@ -264,7 +249,7 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics { } sym::transmute | sym::transmute_unchecked => { let dst_ty = destination.ty(local_decls, tcx).ty; - let Ok([arg]) = <[_; 1]>::try_from(std::mem::take(args)) else { + let Ok([arg]) = take_array(args) else { span_bug!( terminator.source_info.span, "Wrong number of arguments for transmute intrinsic", @@ -289,7 +274,7 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics { } } sym::aggregate_raw_ptr => { - let Ok([data, meta]) = <[_; 2]>::try_from(std::mem::take(args)) else { + let Ok([data, meta]) = take_array(args) else { span_bug!( terminator.source_info.span, "Wrong number of arguments for aggregate_raw_ptr intrinsic", @@ -317,7 +302,7 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics { terminator.kind = TerminatorKind::Goto { target }; } sym::ptr_metadata => { - let Ok([ptr]) = <[_; 1]>::try_from(std::mem::take(args)) else { + let Ok([ptr]) = take_array(args) else { span_bug!( terminator.source_info.span, "Wrong number of arguments for ptr_metadata intrinsic", diff --git a/compiler/rustc_mir_transform/src/shim.rs b/compiler/rustc_mir_transform/src/shim.rs index 825f8957187..25577e88e28 100644 --- a/compiler/rustc_mir_transform/src/shim.rs +++ b/compiler/rustc_mir_transform/src/shim.rs @@ -562,7 +562,7 @@ impl<'tcx> CloneShimBuilder<'tcx> { vec![statement], TerminatorKind::Call { func, - args: vec![Spanned { node: Operand::Move(ref_loc), span: DUMMY_SP }], + args: [Spanned { node: Operand::Move(ref_loc), span: DUMMY_SP }].into(), destination: dest, target: Some(next), unwind: UnwindAction::Cleanup(cleanup), @@ -843,7 +843,7 @@ fn build_call_shim<'tcx>( }; // BB #0 - let args = args.into_iter().map(|a| Spanned { node: a, span: DUMMY_SP }).collect::<Vec<_>>(); + let args = args.into_iter().map(|a| Spanned { node: a, span: DUMMY_SP }).collect(); block( &mut blocks, statements, diff --git a/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs b/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs index cae9c5c8567..ee7279a43b2 100644 --- a/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs @@ -527,7 +527,7 @@ where }; for assumption in - self.cx().item_bounds(alias_ty.def_id).iter_instantiated(self.cx(), &alias_ty.args) + self.cx().item_bounds(alias_ty.def_id).iter_instantiated(self.cx(), alias_ty.args) { candidates.extend(G::probe_and_consider_implied_clause( self, @@ -603,7 +603,7 @@ where // Consider all of the auto-trait and projection bounds, which don't // need to be recorded as a `BuiltinImplSource::Object` since they don't // really have a vtable base... - for bound in bounds { + for bound in bounds.iter() { match bound.skip_binder() { ty::ExistentialPredicate::Trait(_) => { // Skip principal diff --git a/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs b/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs index b10be5a9ba7..2df039c766c 100644 --- a/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs +++ b/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs @@ -58,7 +58,7 @@ where ty::Tuple(tys) => { // (T1, ..., Tn) -- meets any bound that all of T1...Tn meet - Ok(tys.into_iter().map(ty::Binder::dummy).collect()) + Ok(tys.iter().map(ty::Binder::dummy).collect()) } ty::Closure(_, args) => Ok(vec![ty::Binder::dummy(args.as_closure().tupled_upvars_ty())]), @@ -79,23 +79,21 @@ where .cx() .bound_coroutine_hidden_types(def_id) .into_iter() - .map(|bty| bty.instantiate(tcx, &args)) + .map(|bty| bty.instantiate(tcx, args)) .collect()), // For `PhantomData<T>`, we pass `T`. ty::Adt(def, args) if def.is_phantom_data() => Ok(vec![ty::Binder::dummy(args.type_at(0))]), - ty::Adt(def, args) => Ok(def - .all_field_tys(tcx) - .iter_instantiated(tcx, &args) - .map(ty::Binder::dummy) - .collect()), + ty::Adt(def, args) => { + Ok(def.all_field_tys(tcx).iter_instantiated(tcx, args).map(ty::Binder::dummy).collect()) + } ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => { // We can resolve the `impl Trait` to its concrete type, // which enforces a DAG between the functions requiring // the auto trait bounds in question. - Ok(vec![ty::Binder::dummy(tcx.type_of(def_id).instantiate(tcx, &args))]) + Ok(vec![ty::Binder::dummy(tcx.type_of(def_id).instantiate(tcx, args))]) } } } @@ -147,7 +145,7 @@ where // impl Sized for () // impl Sized for (T1, T2, .., Tn) where Tn: Sized if n >= 1 - ty::Tuple(tys) => Ok(tys.last().map_or_else(Vec::new, |&ty| vec![ty::Binder::dummy(ty)])), + ty::Tuple(tys) => Ok(tys.last().map_or_else(Vec::new, |ty| vec![ty::Binder::dummy(ty)])), // impl Sized for Adt<Args...> where sized_constraint(Adt)<Args...>: Sized // `sized_constraint(Adt)` is the deepest struct trail that can be determined @@ -160,7 +158,7 @@ where // if the ADT is sized for all possible args. ty::Adt(def, args) => { if let Some(sized_crit) = def.sized_constraint(ecx.cx()) { - Ok(vec![ty::Binder::dummy(sized_crit.instantiate(ecx.cx(), &args))]) + Ok(vec![ty::Binder::dummy(sized_crit.instantiate(ecx.cx(), args))]) } else { Ok(vec![]) } @@ -213,7 +211,7 @@ where } // impl Copy/Clone for (T1, T2, .., Tn) where T1: Copy/Clone, T2: Copy/Clone, .. Tn: Copy/Clone - ty::Tuple(tys) => Ok(tys.into_iter().map(ty::Binder::dummy).collect()), + ty::Tuple(tys) => Ok(tys.iter().map(ty::Binder::dummy).collect()), // impl Copy/Clone for Closure where Self::TupledUpvars: Copy/Clone ty::Closure(_, args) => Ok(vec![ty::Binder::dummy(args.as_closure().tupled_upvars_ty())]), @@ -242,7 +240,7 @@ where .cx() .bound_coroutine_hidden_types(def_id) .into_iter() - .map(|bty| bty.instantiate(ecx.cx(), &args)) + .map(|bty| bty.instantiate(ecx.cx(), args)) .collect()), } } @@ -259,8 +257,8 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_callable<I: Intern let sig = tcx.fn_sig(def_id); if sig.skip_binder().is_fn_trait_compatible() && !tcx.has_target_features(def_id) { Ok(Some( - sig.instantiate(tcx, &args) - .map_bound(|sig| (Ty::new_tup(tcx, &sig.inputs()), sig.output())), + sig.instantiate(tcx, args) + .map_bound(|sig| (Ty::new_tup(tcx, sig.inputs().as_slice()), sig.output())), )) } else { Err(NoSolution) @@ -269,7 +267,9 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_callable<I: Intern // keep this in sync with assemble_fn_pointer_candidates until the old solver is removed. ty::FnPtr(sig) => { if sig.is_fn_trait_compatible() { - Ok(Some(sig.map_bound(|sig| (Ty::new_tup(tcx, &sig.inputs()), sig.output())))) + Ok(Some( + sig.map_bound(|sig| (Ty::new_tup(tcx, sig.inputs().as_slice()), sig.output())), + )) } else { Err(NoSolution) } @@ -292,7 +292,9 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_callable<I: Intern } } } - Ok(Some(closure_args.sig().map_bound(|sig| (sig.inputs()[0], sig.output())))) + Ok(Some( + closure_args.sig().map_bound(|sig| (sig.inputs().get(0).unwrap(), sig.output())), + )) } // Coroutine-closures don't implement `Fn` traits the normal way. @@ -470,7 +472,7 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_async_callable<I: let future_output_ty = Ty::new_projection(tcx, future_output_def_id, [sig.output()]); Ok(( bound_sig.rebind(AsyncCallableRelevantTypes { - tupled_inputs_ty: Ty::new_tup(tcx, &sig.inputs()), + tupled_inputs_ty: Ty::new_tup(tcx, sig.inputs().as_slice()), output_coroutine_ty: sig.output(), coroutine_return_ty: future_output_ty, }), @@ -521,7 +523,7 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_async_callable<I: let future_output_ty = Ty::new_projection(tcx, future_output_def_id, [sig.output()]); Ok(( bound_sig.rebind(AsyncCallableRelevantTypes { - tupled_inputs_ty: sig.inputs()[0], + tupled_inputs_ty: sig.inputs().get(0).unwrap(), output_coroutine_ty: sig.output(), coroutine_return_ty: future_output_ty, }), @@ -669,7 +671,7 @@ where let tcx = ecx.cx(); let mut requirements = vec![]; requirements - .extend(tcx.super_predicates_of(trait_ref.def_id).iter_instantiated(tcx, &trait_ref.args)); + .extend(tcx.super_predicates_of(trait_ref.def_id).iter_instantiated(tcx, trait_ref.args)); // FIXME(associated_const_equality): Also add associated consts to // the requirements here. @@ -680,13 +682,12 @@ where continue; } - requirements.extend( - tcx.item_bounds(associated_type_def_id).iter_instantiated(tcx, &trait_ref.args), - ); + requirements + .extend(tcx.item_bounds(associated_type_def_id).iter_instantiated(tcx, trait_ref.args)); } let mut replace_projection_with = HashMap::default(); - for bound in object_bounds { + for bound in object_bounds.iter() { if let ty::ExistentialPredicate::Projection(proj) = bound.skip_binder() { let proj = proj.with_self_ty(tcx, trait_ref.self_ty()); let old_ty = replace_projection_with.insert(proj.def_id(), bound.rebind(proj)); diff --git a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs index f1d4864a84b..0a313c6a951 100644 --- a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs +++ b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs @@ -267,7 +267,9 @@ where // We therefore instantiate the existential variable in the canonical response with the // inference variable of the input right away, which is more performant. let mut opt_values = IndexVec::from_elem_n(None, response.variables.len()); - for (original_value, result_value) in iter::zip(original_values, var_values.var_values) { + for (original_value, result_value) in + iter::zip(original_values, var_values.var_values.iter()) + { match result_value.kind() { ty::GenericArgKind::Type(t) => { if let ty::Bound(debruijn, b) = t.kind() { @@ -291,7 +293,7 @@ where } let var_values = delegate.cx().mk_args_from_iter( - response.variables.into_iter().enumerate().map(|(index, info)| { + response.variables.iter().enumerate().map(|(index, info)| { if info.universe() != ty::UniverseIndex::ROOT { // A variable from inside a binder of the query. While ideally these shouldn't // exist at all (see the FIXME at the start of this method), we have to deal with @@ -344,7 +346,7 @@ where ) { assert_eq!(original_values.len(), var_values.len()); - for (&orig, response) in iter::zip(original_values, var_values.var_values) { + for (&orig, response) in iter::zip(original_values, var_values.var_values.iter()) { let goals = delegate.eq_structurally_relating_aliases(param_env, orig, response).unwrap(); assert!(goals.is_empty()); @@ -413,7 +415,8 @@ where // In case any fresh inference variables have been created between `state` // and the previous instantiation, extend `orig_values` for it. assert!(orig_values.len() <= state.value.var_values.len()); - for &arg in &state.value.var_values.var_values[orig_values.len()..state.value.var_values.len()] + for &arg in &state.value.var_values.var_values.as_slice() + [orig_values.len()..state.value.var_values.len()] { // FIXME: This is so ugly. let unconstrained = delegate.fresh_var_for_kind_with_span(arg, span); diff --git a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs index 6644fff2140..04dce2780b0 100644 --- a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs @@ -787,7 +787,7 @@ where // Alternatively we could modify `Equate` for this case by adding another // variant to `StructurallyRelateAliases`. let identity_args = self.fresh_args_for_item(alias.def_id); - let rigid_ctor = ty::AliasTerm::new(tcx, alias.def_id, identity_args); + let rigid_ctor = ty::AliasTerm::new_from_args(tcx, alias.def_id, identity_args); let ctor_term = rigid_ctor.to_term(tcx); let obligations = self.delegate.eq_structurally_relating_aliases(param_env, term, ctor_term)?; @@ -875,7 +875,7 @@ where pub(super) fn fresh_args_for_item(&mut self, def_id: I::DefId) -> I::GenericArgs { let args = self.delegate.fresh_args_for_item(def_id); - for arg in args { + for arg in args.iter() { self.inspect.add_var_value(arg); } args @@ -979,7 +979,7 @@ where result: *result, }) .enter(|ecx| { - for (a, b) in std::iter::zip(candidate_key.args, key.args) { + for (a, b) in std::iter::zip(candidate_key.args.iter(), key.args.iter()) { ecx.eq(param_env, a, b)?; } ecx.eq(param_env, candidate_ty, ty)?; diff --git a/compiler/rustc_next_trait_solver/src/solve/inspect/build.rs b/compiler/rustc_next_trait_solver/src/solve/inspect/build.rs index ae59f0c5e95..4fc58e06d67 100644 --- a/compiler/rustc_next_trait_solver/src/solve/inspect/build.rs +++ b/compiler/rustc_next_trait_solver/src/solve/inspect/build.rs @@ -7,6 +7,7 @@ use std::marker::PhantomData; use std::mem; +use rustc_type_ir::inherent::*; use rustc_type_ir::{self as ty, Interner}; use crate::delegate::SolverDelegate; diff --git a/compiler/rustc_next_trait_solver/src/solve/mod.rs b/compiler/rustc_next_trait_solver/src/solve/mod.rs index b76b4c09852..e29ae7ac0a2 100644 --- a/compiler/rustc_next_trait_solver/src/solve/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/mod.rs @@ -182,7 +182,7 @@ where return self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes); } ty::ConstKind::Unevaluated(uv) => { - self.cx().type_of(uv.def).instantiate(self.cx(), &uv.args) + self.cx().type_of(uv.def).instantiate(self.cx(), uv.args) } ty::ConstKind::Expr(_) => unimplemented!( "`feature(generic_const_exprs)` is not supported in the new trait solver" diff --git a/compiler/rustc_next_trait_solver/src/solve/normalizes_to/inherent.rs b/compiler/rustc_next_trait_solver/src/solve/normalizes_to/inherent.rs index 827fe5f2ca4..004ecf2d2c4 100644 --- a/compiler/rustc_next_trait_solver/src/solve/normalizes_to/inherent.rs +++ b/compiler/rustc_next_trait_solver/src/solve/normalizes_to/inherent.rs @@ -29,7 +29,7 @@ where self.eq( goal.param_env, inherent.self_ty(), - tcx.type_of(impl_def_id).instantiate(tcx, &impl_args), + tcx.type_of(impl_def_id).instantiate(tcx, impl_args), )?; // Equate IAT with the RHS of the project goal @@ -44,11 +44,11 @@ where self.add_goals( GoalSource::Misc, tcx.predicates_of(inherent.def_id) - .iter_instantiated(tcx, &inherent_args) + .iter_instantiated(tcx, inherent_args) .map(|pred| goal.with(tcx, pred)), ); - let normalized = tcx.type_of(inherent.def_id).instantiate(tcx, &inherent_args); + let normalized = tcx.type_of(inherent.def_id).instantiate(tcx, inherent_args); self.instantiate_normalizes_to_term(goal, normalized.into()); self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) } diff --git a/compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs b/compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs index f58384d86cd..bc5233c4887 100644 --- a/compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs @@ -121,7 +121,7 @@ where ecx.add_goals( GoalSource::Misc, tcx.own_predicates_of(goal.predicate.def_id()) - .iter_instantiated(tcx, &goal.predicate.alias.args) + .iter_instantiated(tcx, goal.predicate.alias.args) .map(|pred| goal.with(tcx, pred)), ); @@ -163,13 +163,13 @@ where ecx.probe_trait_candidate(CandidateSource::Impl(impl_def_id)).enter(|ecx| { let impl_args = ecx.fresh_args_for_item(impl_def_id); - let impl_trait_ref = impl_trait_ref.instantiate(tcx, &impl_args); + let impl_trait_ref = impl_trait_ref.instantiate(tcx, impl_args); ecx.eq(goal.param_env, goal_trait_ref, impl_trait_ref)?; let where_clause_bounds = tcx .predicates_of(impl_def_id) - .iter_instantiated(tcx, &impl_args) + .iter_instantiated(tcx, impl_args) .map(|pred| goal.with(tcx, pred)); ecx.add_goals(GoalSource::ImplWhereBound, where_clause_bounds); @@ -177,7 +177,7 @@ where ecx.add_goals( GoalSource::Misc, tcx.own_predicates_of(goal.predicate.def_id()) - .iter_instantiated(tcx, &goal.predicate.alias.args) + .iter_instantiated(tcx, goal.predicate.alias.args) .map(|pred| goal.with(tcx, pred)), ); @@ -254,7 +254,7 @@ where kind => panic!("expected projection, found {kind:?}"), }; - ecx.instantiate_normalizes_to_term(goal, term.instantiate(tcx, &target_args)); + ecx.instantiate_normalizes_to_term(goal, term.instantiate(tcx, target_args)); ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) }) } @@ -467,7 +467,7 @@ where tupled_inputs_ty, tupled_upvars_ty, coroutine_captures_by_ref_ty, - ] = **goal.predicate.alias.args + ] = *goal.predicate.alias.args.as_slice() else { panic!(); }; @@ -567,14 +567,14 @@ where ty::Adt(def, args) if def.is_struct() => match def.struct_tail_ty(tcx) { None => Ty::new_unit(tcx), Some(tail_ty) => { - Ty::new_projection(tcx, metadata_def_id, [tail_ty.instantiate(tcx, &args)]) + Ty::new_projection(tcx, metadata_def_id, [tail_ty.instantiate(tcx, args)]) } }, ty::Adt(_, _) => Ty::new_unit(tcx), ty::Tuple(elements) => match elements.last() { None => Ty::new_unit(tcx), - Some(&tail_ty) => Ty::new_projection(tcx, metadata_def_id, [tail_ty]), + Some(tail_ty) => Ty::new_projection(tcx, metadata_def_id, [tail_ty]), }, ty::Infer( @@ -895,7 +895,7 @@ where } else { let target_args = self.fresh_args_for_item(target_container_def_id); let target_trait_ref = - tcx.impl_trait_ref(target_container_def_id).instantiate(tcx, &target_args); + tcx.impl_trait_ref(target_container_def_id).instantiate(tcx, target_args); // Relate source impl to target impl by equating trait refs. self.eq(goal.param_env, impl_trait_ref, target_trait_ref)?; // Also add predicates since they may be needed to constrain the @@ -903,7 +903,7 @@ where self.add_goals( GoalSource::Misc, tcx.predicates_of(target_container_def_id) - .iter_instantiated(tcx, &target_args) + .iter_instantiated(tcx, target_args) .map(|pred| goal.with(tcx, pred)), ); goal.predicate.alias.args.rebase_onto(tcx, impl_trait_ref.def_id, target_args) diff --git a/compiler/rustc_next_trait_solver/src/solve/normalizes_to/opaque_types.rs b/compiler/rustc_next_trait_solver/src/solve/normalizes_to/opaque_types.rs index f3494328d9e..a16f9e64f2f 100644 --- a/compiler/rustc_next_trait_solver/src/solve/normalizes_to/opaque_types.rs +++ b/compiler/rustc_next_trait_solver/src/solve/normalizes_to/opaque_types.rs @@ -86,7 +86,7 @@ where } (Reveal::All, _) => { // FIXME: Add an assertion that opaque type storage is empty. - let actual = tcx.type_of(opaque_ty.def_id).instantiate(tcx, &opaque_ty.args); + let actual = tcx.type_of(opaque_ty.def_id).instantiate(tcx, opaque_ty.args); self.eq(goal.param_env, expected, actual)?; self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) } @@ -102,7 +102,7 @@ pub fn uses_unique_placeholders_ignoring_regions<I: Interner>( args: I::GenericArgs, ) -> Result<(), NotUniqueParam<I>> { let mut seen = GrowableBitSet::default(); - for arg in args { + for arg in args.iter() { match arg.kind() { // Ignore regions, since we can't resolve those in a canonicalized // query in the trait solver. diff --git a/compiler/rustc_next_trait_solver/src/solve/normalizes_to/weak_types.rs b/compiler/rustc_next_trait_solver/src/solve/normalizes_to/weak_types.rs index 27d5ae07729..ca90bc17cc7 100644 --- a/compiler/rustc_next_trait_solver/src/solve/normalizes_to/weak_types.rs +++ b/compiler/rustc_next_trait_solver/src/solve/normalizes_to/weak_types.rs @@ -25,11 +25,11 @@ where self.add_goals( GoalSource::Misc, tcx.predicates_of(weak_ty.def_id) - .iter_instantiated(tcx, &weak_ty.args) + .iter_instantiated(tcx, weak_ty.args) .map(|pred| goal.with(tcx, pred)), ); - let actual = tcx.type_of(weak_ty.def_id).instantiate(tcx, &weak_ty.args); + let actual = tcx.type_of(weak_ty.def_id).instantiate(tcx, weak_ty.args); self.instantiate_normalizes_to_term(goal, actual.into()); self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) 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 2ddb3c981db..9746c836aff 100644 --- a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs +++ b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs @@ -77,12 +77,12 @@ where ecx.probe_trait_candidate(CandidateSource::Impl(impl_def_id)).enter(|ecx| { let impl_args = ecx.fresh_args_for_item(impl_def_id); ecx.record_impl_args(impl_args); - let impl_trait_ref = impl_trait_ref.instantiate(tcx, &impl_args); + let impl_trait_ref = impl_trait_ref.instantiate(tcx, impl_args); ecx.eq(goal.param_env, goal.predicate.trait_ref, impl_trait_ref)?; let where_clause_bounds = tcx .predicates_of(impl_def_id) - .iter_instantiated(tcx, &impl_args) + .iter_instantiated(tcx, impl_args) .map(|pred| goal.with(tcx, pred)); ecx.add_goals(GoalSource::ImplWhereBound, where_clause_bounds); @@ -186,7 +186,7 @@ where ecx.probe_builtin_trait_candidate(BuiltinImplSource::Misc).enter(|ecx| { let nested_obligations = tcx .predicates_of(goal.predicate.def_id()) - .iter_instantiated(tcx, &goal.predicate.trait_ref.args) + .iter_instantiated(tcx, goal.predicate.trait_ref.args) .map(|p| goal.with(tcx, p)); // FIXME(-Znext-solver=coinductive): Should this be `GoalSource::ImplWhereBound`? ecx.add_goals(GoalSource::Misc, nested_obligations); @@ -373,7 +373,7 @@ where ecx: &mut EvalCtxt<'_, D>, goal: Goal<I, Self>, ) -> Result<Candidate<I>, NoSolution> { - let [closure_fn_kind_ty, goal_kind_ty] = **goal.predicate.trait_ref.args else { + let [closure_fn_kind_ty, goal_kind_ty] = *goal.predicate.trait_ref.args.as_slice() else { panic!(); }; @@ -783,7 +783,7 @@ where // (i.e. the principal, all of the associated types match, and any auto traits) ecx.add_goals( GoalSource::ImplWhereBound, - b_data.into_iter().map(|pred| goal.with(tcx, pred.with_self_ty(tcx, a_ty))), + b_data.iter().map(|pred| goal.with(tcx, pred.with_self_ty(tcx, a_ty))), ); // The type must be `Sized` to be unsized. @@ -851,7 +851,7 @@ where }; self.probe_trait_candidate(source).enter(|ecx| { - for bound in b_data { + for bound in b_data.iter() { match bound.skip_binder() { // Check that a's supertrait (upcast_principal) is compatible // with the target (b_ty). @@ -953,18 +953,15 @@ where let tail_field_ty = def.struct_tail_ty(tcx).unwrap(); - let a_tail_ty = tail_field_ty.instantiate(tcx, &a_args); - let b_tail_ty = tail_field_ty.instantiate(tcx, &b_args); + let a_tail_ty = tail_field_ty.instantiate(tcx, a_args); + let b_tail_ty = tail_field_ty.instantiate(tcx, b_args); // Instantiate just the unsizing params from B into A. The type after // this instantiation must be equal to B. This is so we don't unsize // unrelated type parameters. - let new_a_args = tcx.mk_args_from_iter( - a_args - .iter() - .enumerate() - .map(|(i, a)| if unsizing_params.contains(i as u32) { b_args[i] } else { *a }), - ); + let new_a_args = tcx.mk_args_from_iter(a_args.iter().enumerate().map(|(i, a)| { + if unsizing_params.contains(i as u32) { b_args.get(i).unwrap() } else { a } + })); let unsized_a_ty = Ty::new_adt(tcx, def, new_a_args); // Finally, we require that `TailA: Unsize<TailB>` for the tail field @@ -1005,7 +1002,7 @@ where let Goal { predicate: (_a_ty, b_ty), .. } = goal; let (&a_last_ty, a_rest_tys) = a_tys.split_last().unwrap(); - let &b_last_ty = b_tys.last().unwrap(); + let b_last_ty = b_tys.last().unwrap(); // Instantiate just the tail field of B., and require that they're equal. let unsized_a_ty = diff --git a/compiler/rustc_parse/src/parser/tests.rs b/compiler/rustc_parse/src/parser/tests.rs index 3a4690670af..42392ad2163 100644 --- a/compiler/rustc_parse/src/parser/tests.rs +++ b/compiler/rustc_parse/src/parser/tests.rs @@ -322,9 +322,8 @@ error: foo --> test.rs:3:3 | 3 | X0 Y0 - | ___^__- - | |___| - | || + | ____^ - + | | ______| 4 | || X1 Y1 5 | || X2 Y2 | ||____^__- `Y` is a good letter too @@ -361,9 +360,8 @@ error: foo --> test.rs:3:3 | 3 | X0 Y0 - | ___^__- - | |___| - | || + | ____^ - + | | ______| 4 | || Y1 X1 | ||____-__^ `X` is a good letter | |____| @@ -445,10 +443,9 @@ error: foo --> test.rs:3:3 | 3 | X0 Y0 Z0 - | ___^__-__- - | |___|__| - | ||___| - | ||| + | _____^ - - + | | _______| | + | || _________| 4 | ||| X1 Y1 Z1 5 | ||| X2 Y2 Z2 | |||____^__-__- `Z` label diff --git a/compiler/rustc_parse/src/validate_attr.rs b/compiler/rustc_parse/src/validate_attr.rs index bcb1131cc19..3d5e6371f4c 100644 --- a/compiler/rustc_parse/src/validate_attr.rs +++ b/compiler/rustc_parse/src/validate_attr.rs @@ -4,8 +4,10 @@ use crate::{errors, parse_in}; use rustc_ast::token::Delimiter; use rustc_ast::tokenstream::DelimSpan; -use rustc_ast::MetaItemKind; -use rustc_ast::{self as ast, AttrArgs, AttrArgsEq, Attribute, DelimArgs, MetaItem, Safety}; +use rustc_ast::{ + self as ast, AttrArgs, AttrArgsEq, Attribute, DelimArgs, MetaItem, MetaItemKind, + NestedMetaItem, Safety, +}; use rustc_errors::{Applicability, FatalError, PResult}; use rustc_feature::{ AttributeSafety, AttributeTemplate, BuiltinAttribute, Features, BUILTIN_ATTRIBUTE_MAP, @@ -184,9 +186,13 @@ pub(super) fn check_cfg_attr_bad_delim(psess: &ParseSess, span: DelimSpan, delim /// Checks that the given meta-item is compatible with this `AttributeTemplate`. fn is_attr_template_compatible(template: &AttributeTemplate, meta: &ast::MetaItemKind) -> bool { + let is_one_allowed_subword = |items: &[NestedMetaItem]| match items { + [item] => item.is_word() && template.one_of.iter().any(|&word| item.has_name(word)), + _ => false, + }; match meta { MetaItemKind::Word => template.word, - MetaItemKind::List(..) => template.list.is_some(), + MetaItemKind::List(items) => template.list.is_some() || is_one_allowed_subword(items), MetaItemKind::NameValue(lit) if lit.kind.is_str() => template.name_value_str.is_some(), MetaItemKind::NameValue(..) => false, } @@ -230,6 +236,7 @@ fn emit_malformed_attribute( if let Some(descr) = template.list { suggestions.push(format!("#{inner}[{name}({descr})]")); } + suggestions.extend(template.one_of.iter().map(|&word| format!("#{inner}[{name}({word})]"))); if let Some(descr) = template.name_value_str { suggestions.push(format!("#{inner}[{name} = \"{descr}\"]")); } diff --git a/compiler/rustc_passes/messages.ftl b/compiler/rustc_passes/messages.ftl index 9a830b0f49b..5a560325ab9 100644 --- a/compiler/rustc_passes/messages.ftl +++ b/compiler/rustc_passes/messages.ftl @@ -103,18 +103,9 @@ passes_continue_labeled_block = .label = labeled blocks cannot be `continue`'d .block_label = labeled block the `continue` points to -passes_coverage_fn_defn = - `#[coverage]` may only be applied to function definitions - -passes_coverage_ignored_function_prototype = - `#[coverage]` is ignored on function prototypes - -passes_coverage_not_coverable = - `#[coverage]` must be applied to coverable code - .label = not coverable code - -passes_coverage_propagate = - `#[coverage]` does not propagate into items and must be applied to the contained functions directly +passes_coverage_not_fn_or_closure = + attribute should be applied to a function definition or closure + .label = not a function or closure passes_dead_codes = { $multiple -> diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 2ed5bba85c6..d33f12a973f 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -122,7 +122,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { self.check_diagnostic_on_unimplemented(attr.span, hir_id, target) } [sym::inline] => self.check_inline(hir_id, attr, span, target), - [sym::coverage] => self.check_coverage(hir_id, attr, span, target), + [sym::coverage] => self.check_coverage(attr, span, target), [sym::non_exhaustive] => self.check_non_exhaustive(hir_id, attr, span, target), [sym::marker] => self.check_marker(hir_id, attr, span, target), [sym::target_feature] => { @@ -369,47 +369,15 @@ impl<'tcx> CheckAttrVisitor<'tcx> { } } - /// Checks if a `#[coverage]` is applied directly to a function - fn check_coverage(&self, hir_id: HirId, attr: &Attribute, span: Span, target: Target) -> bool { + /// Checks that `#[coverage(..)]` is applied to a function or closure. + fn check_coverage(&self, attr: &Attribute, span: Span, target: Target) -> bool { match target { - // #[coverage] on function is fine + // #[coverage(..)] on function is fine Target::Fn | Target::Closure | Target::Method(MethodKind::Trait { body: true } | MethodKind::Inherent) => true, - - // function prototypes can't be covered - Target::Method(MethodKind::Trait { body: false }) | Target::ForeignFn => { - self.tcx.emit_node_span_lint( - UNUSED_ATTRIBUTES, - hir_id, - attr.span, - errors::IgnoredCoverageFnProto, - ); - true - } - - Target::Mod | Target::ForeignMod | Target::Impl | Target::Trait => { - self.tcx.emit_node_span_lint( - UNUSED_ATTRIBUTES, - hir_id, - attr.span, - errors::IgnoredCoveragePropagate, - ); - true - } - - Target::Expression | Target::Statement | Target::Arm => { - self.tcx.emit_node_span_lint( - UNUSED_ATTRIBUTES, - hir_id, - attr.span, - errors::IgnoredCoverageFnDefn, - ); - true - } - _ => { - self.dcx().emit_err(errors::IgnoredCoverageNotCoverable { + self.dcx().emit_err(errors::CoverageNotFnOrClosure { attr_span: attr.span, defn_span: span, }); diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index 69386c0fbdb..7c7700dd859 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -1010,6 +1010,22 @@ impl<'tcx> DeadVisitor<'tcx> { parent_item: Option<LocalDefId>, report_on: ReportOn, ) { + fn get_parent_if_enum_variant<'tcx>( + tcx: TyCtxt<'tcx>, + may_variant: LocalDefId, + ) -> LocalDefId { + if let Node::Variant(_) = tcx.hir_node_by_def_id(may_variant) + && let Some(enum_did) = tcx.opt_parent(may_variant.to_def_id()) + && let Some(enum_local_id) = enum_did.as_local() + && let Node::Item(item) = tcx.hir_node_by_def_id(enum_local_id) + && let ItemKind::Enum(_, _) = item.kind + { + enum_local_id + } else { + may_variant + } + } + let Some(&first_item) = dead_codes.first() else { return; }; @@ -1053,6 +1069,9 @@ impl<'tcx> DeadVisitor<'tcx> { }; let encl_def_id = parent_item.unwrap_or(first_item.def_id); + // If parent of encl_def_id is an enum, use the parent ID intead. + let encl_def_id = get_parent_if_enum_variant(tcx, encl_def_id); + let ignored_derived_impls = if let Some(ign_traits) = self.ignored_derived_traits.get(&encl_def_id) { let trait_list = ign_traits diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index f0596568092..7734dba3670 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -60,21 +60,9 @@ pub struct InlineNotFnOrClosure { pub defn_span: Span, } -#[derive(LintDiagnostic)] -#[diag(passes_coverage_ignored_function_prototype)] -pub struct IgnoredCoverageFnProto; - -#[derive(LintDiagnostic)] -#[diag(passes_coverage_propagate)] -pub struct IgnoredCoveragePropagate; - -#[derive(LintDiagnostic)] -#[diag(passes_coverage_fn_defn)] -pub struct IgnoredCoverageFnDefn; - #[derive(Diagnostic)] -#[diag(passes_coverage_not_coverable, code = E0788)] -pub struct IgnoredCoverageNotCoverable { +#[diag(passes_coverage_not_fn_or_closure, code = E0788)] +pub struct CoverageNotFnOrClosure { #[primary_span] pub attr_span: Span, #[label] diff --git a/compiler/rustc_query_system/src/dep_graph/dep_node.rs b/compiler/rustc_query_system/src/dep_graph/dep_node.rs index 5f1a03502a7..f2a68e35671 100644 --- a/compiler/rustc_query_system/src/dep_graph/dep_node.rs +++ b/compiler/rustc_query_system/src/dep_graph/dep_node.rs @@ -301,9 +301,12 @@ impl<HCX> ToStableHashKey<HCX> for WorkProductId { self.hash } } -unsafe impl StableOrd for WorkProductId { +impl StableOrd for WorkProductId { // Fingerprint can use unstable (just a tuple of `u64`s), so WorkProductId can as well const CAN_USE_UNSTABLE_SORT: bool = true; + + // `WorkProductId` sort order is not affected by (de)serialization. + const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } // Some types are used a lot. Make sure they don't unintentionally get bigger. diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index e035749fc39..4e0f2792d97 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -14,7 +14,7 @@ use crate::{Determinacy, ExternPreludeEntry, Finalize, Module, ModuleKind, Modul use crate::{NameBinding, NameBindingKind, ParentScope, PathResult, ResolutionError}; use crate::{Resolver, ResolverArenas, Segment, ToNameBinding, Used, VisResolutionError}; -use rustc_ast::visit::{self, AssocCtxt, Visitor}; +use rustc_ast::visit::{self, AssocCtxt, Visitor, WalkItemKind}; use rustc_ast::{self as ast, AssocItem, AssocItemKind, MetaItemKind, StmtKind}; use rustc_ast::{Block, ForeignItem, ForeignItemKind, Impl, Item, ItemKind, NodeId}; use rustc_attr as attr; @@ -1313,7 +1313,17 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> { _ => { let orig_macro_rules_scope = self.parent_scope.macro_rules; self.build_reduced_graph_for_item(item); - visit::walk_item(self, item); + match item.kind { + ItemKind::Mod(..) => { + // Visit attributes after items for backward compatibility. + // This way they can use `macro_rules` defined later. + self.visit_vis(&item.vis); + self.visit_ident(item.ident); + item.kind.walk(item, AssocCtxt::Trait, self); + visit::walk_list!(self, visit_attribute, &item.attrs); + } + _ => visit::walk_item(self, item), + } match item.kind { ItemKind::Mod(..) if self.contains_macro_use(&item.attrs) => { self.parent_scope.macro_rules @@ -1514,7 +1524,10 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> { if krate.is_placeholder { self.visit_invoc_in_module(krate.id); } else { - visit::walk_crate(self, krate); + // Visit attributes after items for backward compatibility. + // This way they can use `macro_rules` defined later. + visit::walk_list!(self, visit_item, &krate.items); + visit::walk_list!(self, visit_attribute, &krate.attrs); self.contains_macro_use(&krate.attrs); } } diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs index 87794d11cea..026a2ca1412 100644 --- a/compiler/rustc_resolve/src/macros.rs +++ b/compiler/rustc_resolve/src/macros.rs @@ -5,7 +5,7 @@ use crate::errors::CannotDetermineMacroResolution; use crate::errors::{self, AddAsNonDerive, CannotFindIdentInThisScope}; use crate::errors::{MacroExpectedFound, RemoveSurroundingDerive}; use crate::Namespace::*; -use crate::{BindingKey, BuiltinMacroState, Determinacy, MacroData, Used}; +use crate::{BindingKey, BuiltinMacroState, Determinacy, MacroData, NameBindingKind, Used}; use crate::{DeriveData, Finalize, ParentScope, ResolutionError, Resolver, ScopeSet}; use crate::{ModuleKind, ModuleOrUniformRoot, NameBinding, PathResult, Segment, ToNameBinding}; use rustc_ast::expand::StrippedCfgItem; @@ -18,15 +18,18 @@ use rustc_errors::{Applicability, StashKey}; use rustc_expand::base::{Annotatable, DeriveResolution, Indeterminate, ResolverExpand}; use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind}; use rustc_expand::compile_declarative_macro; -use rustc_expand::expand::{AstFragment, Invocation, InvocationKind, SupportsMacroExpansion}; +use rustc_expand::expand::{ + AstFragment, AstFragmentKind, Invocation, InvocationKind, SupportsMacroExpansion, +}; use rustc_hir::def::{self, DefKind, Namespace, NonMacroAttrKind}; use rustc_hir::def_id::{CrateNum, DefId, LocalDefId}; use rustc_middle::middle::stability; use rustc_middle::ty::RegisteredTools; use rustc_middle::ty::{TyCtxt, Visibility}; -use rustc_session::lint::builtin::UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES; -use rustc_session::lint::builtin::{LEGACY_DERIVE_HELPERS, SOFT_UNSTABLE}; -use rustc_session::lint::builtin::{UNUSED_MACROS, UNUSED_MACRO_RULES}; +use rustc_session::lint::builtin::{ + LEGACY_DERIVE_HELPERS, OUT_OF_SCOPE_MACRO_CALLS, SOFT_UNSTABLE, + UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES, UNUSED_MACROS, UNUSED_MACRO_RULES, +}; use rustc_session::lint::BuiltinLintDiag; use rustc_session::parse::feature_err; use rustc_span::edit_distance::edit_distance; @@ -140,9 +143,10 @@ pub(crate) fn registered_tools(tcx: TyCtxt<'_>, (): ()) -> RegisteredTools { } } } - // We implicitly add `rustfmt`, `clippy`, `diagnostic` to known tools, - // but it's not an error to register them explicitly. - let predefined_tools = [sym::clippy, sym::rustfmt, sym::diagnostic, sym::miri]; + // We implicitly add `rustfmt`, `clippy`, `diagnostic`, `miri` and `rust_analyzer` to known + // tools, but it's not an error to register them explicitly. + let predefined_tools = + [sym::clippy, sym::rustfmt, sym::diagnostic, sym::miri, sym::rust_analyzer]; registered_tools.extend(predefined_tools.iter().cloned().map(Ident::with_dummy_span)); registered_tools } @@ -288,6 +292,16 @@ impl<'a, 'tcx> ResolverExpand for Resolver<'a, 'tcx> { let parent_scope = &ParentScope { derives, ..parent_scope }; let supports_macro_expansion = invoc.fragment_kind.supports_macro_expansion(); let node_id = invoc.expansion_data.lint_node_id; + // This is a heuristic, but it's good enough for the lint. + let looks_like_invoc_in_mod_inert_attr = self + .invocation_parents + .get(&invoc_id) + .or_else(|| self.invocation_parents.get(&eager_expansion_root)) + .map(|&(mod_def_id, _)| mod_def_id) + .filter(|&mod_def_id| { + invoc.fragment_kind == AstFragmentKind::Expr + && self.tcx.def_kind(mod_def_id) == DefKind::Mod + }); let (ext, res) = self.smart_resolve_macro_path( path, kind, @@ -298,6 +312,7 @@ impl<'a, 'tcx> ResolverExpand for Resolver<'a, 'tcx> { force, soft_custom_inner_attributes_gate(path, invoc), deleg_impl, + looks_like_invoc_in_mod_inert_attr, )?; let span = invoc.span(); @@ -520,6 +535,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { force: bool, soft_custom_inner_attributes_gate: bool, deleg_impl: Option<LocalDefId>, + invoc_in_mod_inert_attr: Option<LocalDefId>, ) -> Result<(Lrc<SyntaxExtension>, Res), Indeterminate> { let (ext, res) = match self.resolve_macro_or_delegation_path( path, @@ -528,6 +544,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { true, force, deleg_impl, + invoc_in_mod_inert_attr.map(|def_id| (def_id, node_id)), ) { Ok((Some(ext), res)) => (ext, res), Ok((None, res)) => (self.dummy_ext(kind), res), @@ -682,20 +699,21 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { trace: bool, force: bool, ) -> Result<(Option<Lrc<SyntaxExtension>>, Res), Determinacy> { - self.resolve_macro_or_delegation_path(path, kind, parent_scope, trace, force, None) + self.resolve_macro_or_delegation_path(path, kind, parent_scope, trace, force, None, None) } fn resolve_macro_or_delegation_path( &mut self, - path: &ast::Path, + ast_path: &ast::Path, kind: Option<MacroKind>, parent_scope: &ParentScope<'a>, trace: bool, force: bool, deleg_impl: Option<LocalDefId>, + invoc_in_mod_inert_attr: Option<(LocalDefId, NodeId)>, ) -> Result<(Option<Lrc<SyntaxExtension>>, Res), Determinacy> { - let path_span = path.span; - let mut path = Segment::from_path(path); + let path_span = ast_path.span; + let mut path = Segment::from_path(ast_path); // Possibly apply the macro helper hack if deleg_impl.is_none() @@ -761,6 +779,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { let res = binding.map(|binding| binding.res()); self.prohibit_imported_non_macro_attrs(binding.ok(), res.ok(), path_span); + self.report_out_of_scope_macro_calls( + ast_path, + parent_scope, + invoc_in_mod_inert_attr, + binding.ok(), + ); res }; @@ -1013,6 +1037,45 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } } + fn report_out_of_scope_macro_calls( + &mut self, + path: &ast::Path, + parent_scope: &ParentScope<'a>, + invoc_in_mod_inert_attr: Option<(LocalDefId, NodeId)>, + binding: Option<NameBinding<'a>>, + ) { + if let Some((mod_def_id, node_id)) = invoc_in_mod_inert_attr + && let Some(binding) = binding + // This is a `macro_rules` itself, not some import. + && let NameBindingKind::Res(res) = binding.kind + && let Res::Def(DefKind::Macro(MacroKind::Bang), def_id) = res + // And the `macro_rules` is defined inside the attribute's module, + // so it cannot be in scope unless imported. + && self.tcx.is_descendant_of(def_id, mod_def_id.to_def_id()) + { + // Try to resolve our ident ignoring `macro_rules` scopes. + // If such resolution is successful and gives the same result + // (e.g. if the macro is re-imported), then silence the lint. + let no_macro_rules = self.arenas.alloc_macro_rules_scope(MacroRulesScope::Empty); + let fallback_binding = self.early_resolve_ident_in_lexical_scope( + path.segments[0].ident, + ScopeSet::Macro(MacroKind::Bang), + &ParentScope { macro_rules: no_macro_rules, ..*parent_scope }, + None, + false, + None, + ); + if fallback_binding.ok().and_then(|b| b.res().opt_def_id()) != Some(def_id) { + self.tcx.sess.psess.buffer_lint( + OUT_OF_SCOPE_MACRO_CALLS, + path.span, + node_id, + BuiltinLintDiag::OutOfScopeMacroCalls { path: pprust::path_to_string(path) }, + ); + } + } + } + pub(crate) fn check_reserved_macro_name(&mut self, ident: Ident, res: Res) { // Reserve some names that are not quite covered by the general check // performed on `Resolver::builtin_attrs`. diff --git a/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs b/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs index 44b31f2659c..f0f2d1fefd2 100644 --- a/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs +++ b/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs @@ -232,7 +232,8 @@ fn trait_object_ty<'tcx>(tcx: TyCtxt<'tcx>, poly_trait_ref: ty::PolyTraitRef<'tc .filter(|item| item.kind == ty::AssocKind::Type) .map(move |assoc_ty| { super_poly_trait_ref.map_bound(|super_trait_ref| { - let alias_ty = ty::AliasTy::new(tcx, assoc_ty.def_id, super_trait_ref.args); + let alias_ty = + ty::AliasTy::new_from_args(tcx, assoc_ty.def_id, super_trait_ref.args); let resolved = tcx.normalize_erasing_regions( ty::ParamEnv::reveal_all(), alias_ty.to_ty(tcx), @@ -351,7 +352,7 @@ pub fn transform_instance<'tcx>( // Adjust the type ids of VTableShims to the type id expected in the call sites for the // entry in the vtable (i.e., by using the signature of the closure passed as an argument // to the shim, or by just removing self). - let trait_ref = ty::TraitRef::new(tcx, trait_id, instance.args); + let trait_ref = ty::TraitRef::new_from_args(tcx, trait_id, instance.args); let invoke_ty = trait_object_ty(tcx, ty::Binder::dummy(trait_ref)); instance.args = tcx.mk_args_trait(invoke_ty, trait_ref.args.into_iter().skip(1)); } @@ -432,7 +433,7 @@ pub fn transform_instance<'tcx>( x => bug!("Unexpected type kind for closure-like: {x:?}"), }; let concrete_args = tcx.mk_args_trait(closure_ty, inputs.map(Into::into)); - let trait_ref = ty::TraitRef::new(tcx, trait_id, concrete_args); + let trait_ref = ty::TraitRef::new_from_args(tcx, trait_id, concrete_args); let invoke_ty = trait_object_ty(tcx, ty::Binder::dummy(trait_ref)); let abstract_args = tcx.mk_args_trait(invoke_ty, trait_ref.args.into_iter().skip(1)); // There should be exactly one method on this trait, and it should be the one we're diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 839cc51efce..2d38ad37133 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -498,9 +498,11 @@ pub enum OutputType { DepInfo, } -// Safety: Trivial C-Style enums have a stable sort order across compilation sessions. -unsafe impl StableOrd for OutputType { +impl StableOrd for OutputType { const CAN_USE_UNSTABLE_SORT: bool = true; + + // Trivial C-Style enums have a stable sort order across compilation sessions. + const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } impl<HCX: HashStableContext> ToStableHashKey<HCX> for OutputType { diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index f068d093889..9a10adeb6d1 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1499,7 +1499,8 @@ options! { incremental: Option<String> = (None, parse_opt_string, [UNTRACKED], "enable incremental compilation"), inline_threshold: Option<u32> = (None, parse_opt_number, [TRACKED], - "set the threshold for inlining a function"), + "this option is deprecated and does nothing \ + (consider using `-Cllvm-args=--inline-threshold=...`)"), #[rustc_lint_opt_deny_field_access("use `Session::instrument_coverage` instead of this field")] instrument_coverage: InstrumentCoverage = (InstrumentCoverage::No, parse_instrument_coverage, [TRACKED], "instrument the generated code to support LLVM source-based code coverage reports \ diff --git a/compiler/rustc_smir/src/rustc_internal/internal.rs b/compiler/rustc_smir/src/rustc_internal/internal.rs index c33a52f4a7a..c9c1570a29a 100644 --- a/compiler/rustc_smir/src/rustc_internal/internal.rs +++ b/compiler/rustc_smir/src/rustc_internal/internal.rs @@ -408,7 +408,7 @@ impl RustcInternal for TraitRef { type T<'tcx> = rustc_ty::TraitRef<'tcx>; fn internal<'tcx>(&self, tables: &mut Tables<'_>, tcx: TyCtxt<'tcx>) -> Self::T<'tcx> { - rustc_ty::TraitRef::new( + rustc_ty::TraitRef::new_from_args( tcx, self.def_id.0.internal(tables, tcx), self.args().internal(tables, tcx), diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs index 1ac3a817bba..5456303b36f 100644 --- a/compiler/rustc_span/src/def_id.rs +++ b/compiler/rustc_span/src/def_id.rs @@ -120,9 +120,11 @@ impl Default for DefPathHash { } } -// Safety: `DefPathHash` sort order is not affected (de)serialization. -unsafe impl StableOrd for DefPathHash { +impl StableOrd for DefPathHash { const CAN_USE_UNSTABLE_SORT: bool = true; + + // `DefPathHash` sort order is not affected by (de)serialization. + const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } /// A [`StableCrateId`] is a 64-bit hash of a crate name, together with all diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 8d8f4927e99..6d4a8c29bc9 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -174,6 +174,7 @@ symbols! { Center, Cleanup, Clone, + CoerceUnsized, Command, ConstParamTy, Context, @@ -189,6 +190,7 @@ symbols! { DiagMessage, Diagnostic, DirBuilder, + DispatchFromDyn, Display, DoubleEndedIterator, Duration, @@ -299,8 +301,10 @@ symbols! { Saturating, Send, SeqCst, + Sized, SliceIndex, SliceIter, + SmartPointer, Some, SpanCtxt, String, @@ -323,6 +327,7 @@ symbols! { TyCtxt, TyKind, Unknown, + Unsize, Upvars, Vec, VecDeque, @@ -707,6 +712,7 @@ symbols! { derive, derive_const, derive_default_enum, + derive_smart_pointer, destruct, destructuring_assignment, diagnostic, @@ -1315,6 +1321,7 @@ symbols! { on, on_unimplemented, opaque, + ops, opt_out_copy, optimize, optimize_attribute, @@ -1389,6 +1396,7 @@ symbols! { plugin, plugin_registrar, plugins, + pointee, pointee_trait, pointer, pointer_like, @@ -1559,6 +1567,7 @@ symbols! { rust_2018_preview, rust_2021, rust_2024, + rust_analyzer, rust_begin_unwind, rust_cold_cc, rust_eh_catch_typeinfo, diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index b2fa3489dda..f4a026c0367 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -630,7 +630,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let trait_pred_and_ty = trait_pred.map_bound(|inner| { ( ty::TraitPredicate { - trait_ref: ty::TraitRef::new( + trait_ref: ty::TraitRef::new_from_args( self.tcx, inner.trait_ref.def_id, self.tcx.mk_args( @@ -2915,38 +2915,21 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } ObligationCauseCode::RepeatElementCopy { is_constable, - elt_type, + elt_type: _, elt_span, - elt_stmt_span, + elt_stmt_span: _, } => { err.note( "the `Copy` trait is required because this value will be copied for each element of the array", ); - let value_kind = match is_constable { - IsConstable::Fn => Some("the result of the function call"), - IsConstable::Ctor => Some("the result of the constructor"), - _ => None, - }; let sm = tcx.sess.source_map(); - if let Some(value_kind) = value_kind + if matches!(is_constable, IsConstable::Fn | IsConstable::Ctor) && let Ok(snip) = sm.span_to_snippet(elt_span) { - let help_msg = format!( - "consider creating a new `const` item and initializing it with {value_kind} \ - to be used in the repeat position" - ); - let indentation = sm.indentation_before(elt_stmt_span).unwrap_or_default(); - err.multipart_suggestion( - help_msg, - vec![ - ( - elt_stmt_span.shrink_to_lo(), - format!( - "const ARRAY_REPEAT_VALUE: {elt_type} = {snip};\n{indentation}" - ), - ), - (elt_span, "ARRAY_REPEAT_VALUE".to_string()), - ], + err.span_suggestion( + elt_span, + "create an inline `const` block", + format!("const {{ {snip} }}"), Applicability::MachineApplicable, ); } else { @@ -2954,15 +2937,6 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { err.help("consider using `core::array::from_fn` to initialize the array"); err.help("see https://doc.rust-lang.org/stable/std/array/fn.from_fn.html for more information"); } - - if tcx.sess.is_nightly_build() - && matches!(is_constable, IsConstable::Fn | IsConstable::Ctor) - { - err.help( - "create an inline `const` block, see RFC #2920 \ - <https://github.com/rust-lang/rfcs/pull/2920> for more information", - ); - } } ObligationCauseCode::VariableType(hir_id) => { if let Some(typeck_results) = &self.typeck_results @@ -3955,7 +3929,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { // Extract `<U as Deref>::Target` assoc type and check that it is `T` && let Some(deref_target_did) = tcx.lang_items().deref_target() - && let projection = Ty::new_projection(tcx,deref_target_did, tcx.mk_args(&[ty::GenericArg::from(found_ty)])) + && let projection = Ty::new_projection_from_args(tcx,deref_target_did, tcx.mk_args(&[ty::GenericArg::from(found_ty)])) && let InferOk { value: deref_target, obligations } = infcx.at(&ObligationCause::dummy(), param_env).normalize(projection) && obligations.iter().all(|obligation| infcx.predicate_must_hold_modulo_regions(obligation)) && infcx.can_eq(param_env, deref_target, target_ty) @@ -4290,7 +4264,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { // This corresponds to `<ExprTy as Iterator>::Item = _`. let projection = ty::Binder::dummy(ty::PredicateKind::Clause( ty::ClauseKind::Projection(ty::ProjectionPredicate { - projection_term: ty::AliasTerm::new(self.tcx, proj.def_id, args), + projection_term: ty::AliasTerm::new_from_args(self.tcx, proj.def_id, args), term: ty.into(), }), )); diff --git a/compiler/rustc_trait_selection/src/traits/object_safety.rs b/compiler/rustc_trait_selection/src/traits/object_safety.rs index fc5a2875b67..4d10d33fa6e 100644 --- a/compiler/rustc_trait_selection/src/traits/object_safety.rs +++ b/compiler/rustc_trait_selection/src/traits/object_safety.rs @@ -689,7 +689,7 @@ fn receiver_is_dispatchable<'tcx>( if param.index == 0 { unsized_self_ty.into() } else { tcx.mk_param_from_def(param) } }); - ty::TraitRef::new(tcx, trait_def_id, args).upcast(tcx) + ty::TraitRef::new_from_args(tcx, trait_def_id, args).upcast(tcx) }; let caller_bounds = diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index 8ab324e6601..1d7a0515044 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -727,10 +727,12 @@ fn project<'cx, 'tcx>( ProjectionCandidateSet::None => { let tcx = selcx.tcx(); let term = match tcx.def_kind(obligation.predicate.def_id) { - DefKind::AssocTy => { - Ty::new_projection(tcx, obligation.predicate.def_id, obligation.predicate.args) - .into() - } + DefKind::AssocTy => Ty::new_projection_from_args( + tcx, + obligation.predicate.def_id, + obligation.predicate.args, + ) + .into(), DefKind::AssocConst => ty::Const::new_unevaluated( tcx, ty::UnevaluatedConst::new( @@ -1387,7 +1389,11 @@ fn confirm_coroutine_candidate<'cx, 'tcx>( }; let predicate = ty::ProjectionPredicate { - projection_term: ty::AliasTerm::new(tcx, obligation.predicate.def_id, trait_ref.args), + projection_term: ty::AliasTerm::new_from_args( + tcx, + obligation.predicate.def_id, + trait_ref.args, + ), term: ty.into(), }; @@ -1431,7 +1437,11 @@ fn confirm_future_candidate<'cx, 'tcx>( debug_assert_eq!(tcx.associated_item(obligation.predicate.def_id).name, sym::Output); let predicate = ty::ProjectionPredicate { - projection_term: ty::AliasTerm::new(tcx, obligation.predicate.def_id, trait_ref.args), + projection_term: ty::AliasTerm::new_from_args( + tcx, + obligation.predicate.def_id, + trait_ref.args, + ), term: return_ty.into(), }; @@ -1473,7 +1483,11 @@ fn confirm_iterator_candidate<'cx, 'tcx>( debug_assert_eq!(tcx.associated_item(obligation.predicate.def_id).name, sym::Item); let predicate = ty::ProjectionPredicate { - projection_term: ty::AliasTerm::new(tcx, obligation.predicate.def_id, trait_ref.args), + projection_term: ty::AliasTerm::new_from_args( + tcx, + obligation.predicate.def_id, + trait_ref.args, + ), term: yield_ty.into(), }; @@ -1523,7 +1537,11 @@ fn confirm_async_iterator_candidate<'cx, 'tcx>( let item_ty = args.type_at(0); let predicate = ty::ProjectionPredicate { - projection_term: ty::AliasTerm::new(tcx, obligation.predicate.def_id, trait_ref.args), + projection_term: ty::AliasTerm::new_from_args( + tcx, + obligation.predicate.def_id, + trait_ref.args, + ), term: item_ty.into(), }; @@ -1592,7 +1610,7 @@ fn confirm_builtin_candidate<'cx, 'tcx>( }; let predicate = ty::ProjectionPredicate { - projection_term: ty::AliasTerm::new(tcx, item_def_id, args), + projection_term: ty::AliasTerm::new_from_args(tcx, item_def_id, args), term, }; @@ -1753,7 +1771,7 @@ fn confirm_callable_candidate<'cx, 'tcx>( fn_host_effect, ) .map_bound(|(trait_ref, ret_type)| ty::ProjectionPredicate { - projection_term: ty::AliasTerm::new(tcx, fn_once_output_def_id, trait_ref.args), + projection_term: ty::AliasTerm::new_from_args(tcx, fn_once_output_def_id, trait_ref.args), term: ret_type.into(), }); @@ -1937,7 +1955,7 @@ fn confirm_async_fn_kind_helper_candidate<'cx, 'tcx>( }; let predicate = ty::ProjectionPredicate { - projection_term: ty::AliasTerm::new( + projection_term: ty::AliasTerm::new_from_args( selcx.tcx(), obligation.predicate.def_id, obligation.predicate.args, diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs index c53939bfe60..e36a9ca8bd1 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -940,7 +940,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let ty = traits::normalize_projection_ty( self, param_env, - ty::AliasTy::new(tcx, tcx.lang_items().deref_target()?, trait_ref.args), + ty::AliasTy::new_from_args(tcx, tcx.lang_items().deref_target()?, trait_ref.args), cause.clone(), 0, // We're *intentionally* throwing these away, diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index b50f6260ab3..8c5dc88184c 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -1162,7 +1162,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let InferOk { mut obligations, .. } = self .infcx .at(&obligation.cause, obligation.param_env) - .sup(DefineOpaqueTypes::No, target, source_trait) + .sup(DefineOpaqueTypes::Yes, target, source_trait) .map_err(|_| Unimplemented)?; // Register one obligation for 'a: 'b. @@ -1229,7 +1229,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let InferOk { obligations, .. } = self .infcx .at(&obligation.cause, obligation.param_env) - .eq(DefineOpaqueTypes::No, b, a) + .eq(DefineOpaqueTypes::Yes, b, a) .map_err(|_| Unimplemented)?; ImplSource::Builtin(BuiltinImplSource::Misc, obligations) @@ -1277,7 +1277,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let InferOk { obligations, .. } = self .infcx .at(&obligation.cause, obligation.param_env) - .eq(DefineOpaqueTypes::No, target, new_struct) + .eq(DefineOpaqueTypes::Yes, target, new_struct) .map_err(|_| Unimplemented)?; nested.extend(obligations); @@ -1310,7 +1310,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let InferOk { mut obligations, .. } = self .infcx .at(&obligation.cause, obligation.param_env) - .eq(DefineOpaqueTypes::No, target, new_tuple) + .eq(DefineOpaqueTypes::Yes, target, new_tuple) .map_err(|_| Unimplemented)?; // Add a nested `T: Unsize<U>` predicate. diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index fe047f9966f..68cc04bc8e6 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -2487,7 +2487,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> { trait_def_id, &[normalized_ty.into()], ); - ty::TraitRef::new(tcx, trait_def_id, err_args) + ty::TraitRef::new_from_args(tcx, trait_def_id, err_args) }; let obligation = Obligation::new(self.tcx(), cause.clone(), param_env, trait_ref); diff --git a/compiler/rustc_type_ir/src/binder.rs b/compiler/rustc_type_ir/src/binder.rs index 18b34f8d99b..491ef34430c 100644 --- a/compiler/rustc_type_ir/src/binder.rs +++ b/compiler/rustc_type_ir/src/binder.rs @@ -320,7 +320,7 @@ impl<I: Interner> TypeVisitor<I> for ValidateBoundVars<I> { if self.bound_vars.len() <= idx { panic!("Not enough bound vars: {:?} not found in {:?}", t, self.bound_vars); } - bound_ty.assert_eq(self.bound_vars[idx]); + bound_ty.assert_eq(self.bound_vars.get(idx).unwrap()); } _ => {} }; @@ -335,7 +335,7 @@ impl<I: Interner> TypeVisitor<I> for ValidateBoundVars<I> { if self.bound_vars.len() <= idx { panic!("Not enough bound vars: {:?} not found in {:?}", r, self.bound_vars); } - br.assert_eq(self.bound_vars[idx]); + br.assert_eq(self.bound_vars.get(idx).unwrap()); } _ => (), @@ -435,15 +435,14 @@ impl<I: Interner, T> EarlyBinder<I, Option<T>> { } } -impl<'s, I: Interner, Iter: IntoIterator> EarlyBinder<I, Iter> +impl<I: Interner, Iter: IntoIterator> EarlyBinder<I, Iter> where Iter::Item: TypeFoldable<I>, { - pub fn iter_instantiated( - self, - tcx: I, - args: &'s [I::GenericArg], - ) -> IterInstantiated<'s, I, Iter> { + pub fn iter_instantiated<A>(self, tcx: I, args: A) -> IterInstantiated<I, Iter, A> + where + A: SliceLike<Item = I::GenericArg>, + { IterInstantiated { it: self.value.into_iter(), tcx, args } } @@ -454,15 +453,16 @@ where } } -pub struct IterInstantiated<'s, I: Interner, Iter: IntoIterator> { +pub struct IterInstantiated<I: Interner, Iter: IntoIterator, A> { it: Iter::IntoIter, tcx: I, - args: &'s [I::GenericArg], + args: A, } -impl<I: Interner, Iter: IntoIterator> Iterator for IterInstantiated<'_, I, Iter> +impl<I: Interner, Iter: IntoIterator, A> Iterator for IterInstantiated<I, Iter, A> where Iter::Item: TypeFoldable<I>, + A: SliceLike<Item = I::GenericArg>, { type Item = Iter::Item; @@ -478,10 +478,11 @@ where } } -impl<I: Interner, Iter: IntoIterator> DoubleEndedIterator for IterInstantiated<'_, I, Iter> +impl<I: Interner, Iter: IntoIterator, A> DoubleEndedIterator for IterInstantiated<I, Iter, A> where Iter::IntoIter: DoubleEndedIterator, Iter::Item: TypeFoldable<I>, + A: SliceLike<Item = I::GenericArg>, { fn next_back(&mut self) -> Option<Self::Item> { Some( @@ -491,10 +492,11 @@ where } } -impl<I: Interner, Iter: IntoIterator> ExactSizeIterator for IterInstantiated<'_, I, Iter> +impl<I: Interner, Iter: IntoIterator, A> ExactSizeIterator for IterInstantiated<I, Iter, A> where Iter::IntoIter: ExactSizeIterator, Iter::Item: TypeFoldable<I>, + A: SliceLike<Item = I::GenericArg>, { } @@ -589,8 +591,11 @@ impl<I: Interner, T: Iterator> Iterator for EarlyBinderIter<I, T> { } impl<I: Interner, T: TypeFoldable<I>> ty::EarlyBinder<I, T> { - pub fn instantiate(self, tcx: I, args: &[I::GenericArg]) -> T { - let mut folder = ArgFolder { tcx, args, binders_passed: 0 }; + pub fn instantiate<A>(self, tcx: I, args: A) -> T + where + A: SliceLike<Item = I::GenericArg>, + { + let mut folder = ArgFolder { tcx, args: args.as_slice(), binders_passed: 0 }; self.value.fold_with(&mut folder) } diff --git a/compiler/rustc_type_ir/src/canonical.rs b/compiler/rustc_type_ir/src/canonical.rs index 61ae36265ec..7b114f565f2 100644 --- a/compiler/rustc_type_ir/src/canonical.rs +++ b/compiler/rustc_type_ir/src/canonical.rs @@ -283,7 +283,7 @@ pub struct CanonicalVarValues<I: Interner> { impl<I: Interner> CanonicalVarValues<I> { pub fn is_identity(&self) -> bool { - self.var_values.into_iter().enumerate().all(|(bv, arg)| match arg.kind() { + self.var_values.iter().enumerate().all(|(bv, arg)| match arg.kind() { ty::GenericArgKind::Lifetime(r) => { matches!(r.kind(), ty::ReBound(ty::INNERMOST, br) if br.var().as_usize() == bv) } @@ -298,7 +298,7 @@ impl<I: Interner> CanonicalVarValues<I> { pub fn is_identity_modulo_regions(&self) -> bool { let mut var = ty::BoundVar::ZERO; - for arg in self.var_values { + for arg in self.var_values.iter() { match arg.kind() { ty::GenericArgKind::Lifetime(r) => { if matches!(r.kind(), ty::ReBound(ty::INNERMOST, br) if var == br.var()) { @@ -332,7 +332,7 @@ impl<I: Interner> CanonicalVarValues<I> { // the identity response. pub fn make_identity(tcx: I, infos: I::CanonicalVars) -> CanonicalVarValues<I> { CanonicalVarValues { - var_values: tcx.mk_args_from_iter(infos.into_iter().enumerate().map( + var_values: tcx.mk_args_from_iter(infos.iter().enumerate().map( |(i, info)| -> I::GenericArg { match info.kind { CanonicalVarKind::Ty(_) | CanonicalVarKind::PlaceholderTy(_) => { @@ -371,10 +371,10 @@ impl<I: Interner> CanonicalVarValues<I> { impl<'a, I: Interner> IntoIterator for &'a CanonicalVarValues<I> { type Item = I::GenericArg; - type IntoIter = <I::GenericArgs as IntoIterator>::IntoIter; + type IntoIter = <I::GenericArgs as SliceLike>::IntoIter; fn into_iter(self) -> Self::IntoIter { - self.var_values.into_iter() + self.var_values.iter() } } @@ -382,6 +382,6 @@ impl<I: Interner> Index<ty::BoundVar> for CanonicalVarValues<I> { type Output = I::GenericArg; fn index(&self, value: ty::BoundVar) -> &I::GenericArg { - &self.var_values[value.as_usize()] + &self.var_values.as_slice()[value.as_usize()] } } diff --git a/compiler/rustc_type_ir/src/fold.rs b/compiler/rustc_type_ir/src/fold.rs index 953a438cb14..09ee12d1cc3 100644 --- a/compiler/rustc_type_ir/src/fold.rs +++ b/compiler/rustc_type_ir/src/fold.rs @@ -323,6 +323,12 @@ impl<I: Interner, T: TypeFoldable<I>> TypeFoldable<I> for Vec<T> { } } +impl<I: Interner, T: TypeFoldable<I>> TypeFoldable<I> for Box<[T]> { + fn try_fold_with<F: FallibleTypeFolder<I>>(self, folder: &mut F) -> Result<Self, F::Error> { + Vec::from(self).try_fold_with(folder).map(Vec::into_boxed_slice) + } +} + impl<I: Interner, T: TypeFoldable<I>, Ix: Idx> TypeFoldable<I> for IndexVec<Ix, T> { fn try_fold_with<F: FallibleTypeFolder<I>>(self, folder: &mut F) -> Result<Self, F::Error> { self.raw.try_fold_with(folder).map(IndexVec::from_raw) diff --git a/compiler/rustc_type_ir/src/inherent.rs b/compiler/rustc_type_ir/src/inherent.rs index be6deee011b..a4e1a97d505 100644 --- a/compiler/rustc_type_ir/src/inherent.rs +++ b/compiler/rustc_type_ir/src/inherent.rs @@ -5,7 +5,6 @@ use std::fmt::Debug; use std::hash::Hash; -use std::ops::Deref; use rustc_ast_ir::Mutability; @@ -47,6 +46,14 @@ pub trait Ty<I: Interner<Ty = Self>>: fn new_alias(interner: I, kind: ty::AliasTyKind, alias_ty: ty::AliasTy<I>) -> Self; + fn new_projection_from_args(interner: I, def_id: I::DefId, args: I::GenericArgs) -> Self { + Ty::new_alias( + interner, + ty::AliasTyKind::Projection, + ty::AliasTy::new_from_args(interner, def_id, args), + ) + } + fn new_projection( interner: I, def_id: I::DefId, @@ -120,7 +127,7 @@ pub trait Ty<I: Interner<Ty = Self>>: fn fn_sig(self, interner: I) -> ty::Binder<I, ty::FnSig<I>> { match self.kind() { ty::FnPtr(sig) => sig, - ty::FnDef(def_id, args) => interner.fn_sig(def_id).instantiate(interner, &args), + ty::FnDef(def_id, args) => interner.fn_sig(def_id).instantiate(interner, args), ty::Error(_) => { // ignore errors (#54954) ty::Binder::dummy(ty::FnSig { @@ -182,14 +189,7 @@ pub trait Ty<I: Interner<Ty = Self>>: } pub trait Tys<I: Interner<Tys = Self>>: - Copy - + Debug - + Hash - + Eq - + IntoIterator<Item = I::Ty> - + Deref<Target: Deref<Target = [I::Ty]>> - + TypeFoldable<I> - + Default + Copy + Debug + Hash + Eq + SliceLike<Item = I::Ty> + TypeFoldable<I> + Default { fn split_inputs_and_output(self) -> (I::FnInputTys, I::Ty); } @@ -354,14 +354,7 @@ pub trait Term<I: Interner<Term = Self>>: } pub trait GenericArgs<I: Interner<GenericArgs = Self>>: - Copy - + Debug - + Hash - + Eq - + IntoIterator<Item = I::GenericArg> - + Deref<Target: Deref<Target = [I::GenericArg]>> - + Default - + Relate<I> + Copy + Debug + Hash + Eq + SliceLike<Item = I::GenericArg> + Default + Relate<I> { fn rebase_onto( self, @@ -553,12 +546,7 @@ pub trait DefId<I: Interner>: Copy + Debug + Hash + Eq + TypeFoldable<I> { } pub trait BoundExistentialPredicates<I: Interner>: - Copy - + Debug - + Hash - + Eq - + Relate<I> - + IntoIterator<Item = ty::Binder<I, ty::ExistentialPredicate<I>>> + Copy + Debug + Hash + Eq + Relate<I> + SliceLike<Item = ty::Binder<I, ty::ExistentialPredicate<I>>> { fn principal_def_id(self) -> Option<I::DefId>; @@ -570,3 +558,82 @@ pub trait BoundExistentialPredicates<I: Interner>: self, ) -> impl IntoIterator<Item = ty::Binder<I, ty::ExistentialProjection<I>>>; } + +pub trait SliceLike: Sized + Copy { + type Item: Copy; + type IntoIter: Iterator<Item = Self::Item>; + + fn iter(self) -> Self::IntoIter; + + fn as_slice(&self) -> &[Self::Item]; + + fn get(self, idx: usize) -> Option<Self::Item> { + self.as_slice().get(idx).copied() + } + + fn len(self) -> usize { + self.as_slice().len() + } + + fn is_empty(self) -> bool { + self.len() == 0 + } + + fn contains(self, t: &Self::Item) -> bool + where + Self::Item: PartialEq, + { + self.as_slice().contains(t) + } + + fn to_vec(self) -> Vec<Self::Item> { + self.as_slice().to_vec() + } + + fn last(self) -> Option<Self::Item> { + self.as_slice().last().copied() + } + + fn split_last(&self) -> Option<(&Self::Item, &[Self::Item])> { + self.as_slice().split_last() + } +} + +impl<'a, T: Copy> SliceLike for &'a [T] { + type Item = T; + type IntoIter = std::iter::Copied<std::slice::Iter<'a, T>>; + + fn iter(self) -> Self::IntoIter { + self.iter().copied() + } + + fn as_slice(&self) -> &[Self::Item] { + *self + } +} + +impl<'a, T: Copy, const N: usize> SliceLike for &'a [T; N] { + type Item = T; + type IntoIter = std::iter::Copied<std::slice::Iter<'a, T>>; + + fn iter(self) -> Self::IntoIter { + self.into_iter().copied() + } + + fn as_slice(&self) -> &[Self::Item] { + *self + } +} + +impl<'a, S: SliceLike> SliceLike for &'a S { + type Item = S::Item; + type IntoIter = S::IntoIter; + + fn iter(self) -> Self::IntoIter { + (*self).iter() + } + + fn as_slice(&self) -> &[Self::Item] { + (*self).as_slice() + } +} diff --git a/compiler/rustc_type_ir/src/interner.rs b/compiler/rustc_type_ir/src/interner.rs index 59ca95c09cd..b89ea30fc34 100644 --- a/compiler/rustc_type_ir/src/interner.rs +++ b/compiler/rustc_type_ir/src/interner.rs @@ -34,16 +34,11 @@ pub trait Interner: type LocalDefId: Copy + Debug + Hash + Eq + Into<Self::DefId> + TypeFoldable<Self>; type GenericArgs: GenericArgs<Self>; - type GenericArgsSlice: Copy + Debug + Hash + Eq + Deref<Target = [Self::GenericArg]>; + type GenericArgsSlice: Copy + Debug + Hash + Eq + SliceLike<Item = Self::GenericArg>; type GenericArg: GenericArg<Self>; type Term: Term<Self>; - type BoundVarKinds: Copy - + Debug - + Hash - + Eq - + Deref<Target: Deref<Target = [Self::BoundVarKind]>> - + Default; + type BoundVarKinds: Copy + Debug + Hash + Eq + SliceLike<Item = Self::BoundVarKind> + Default; type BoundVarKind: Copy + Debug + Hash + Eq; type PredefinedOpaques: Copy @@ -63,7 +58,7 @@ pub trait Interner: + Default + Eq + TypeVisitable<Self> - + Deref<Target: Deref<Target = [Self::LocalDefId]>>; + + SliceLike<Item = Self::LocalDefId>; type CanonicalGoalEvaluationStepRef: Copy + Debug + Hash @@ -74,8 +69,7 @@ pub trait Interner: + Debug + Hash + Eq - + IntoIterator<Item = ty::CanonicalVarInfo<Self>> - + Deref<Target: Deref<Target = [ty::CanonicalVarInfo<Self>]>> + + SliceLike<Item = ty::CanonicalVarInfo<Self>> + Default; fn mk_canonical_var_infos(self, infos: &[ty::CanonicalVarInfo<Self>]) -> Self::CanonicalVars; @@ -96,7 +90,7 @@ pub trait Interner: // Kinds of tys type Ty: Ty<Self>; type Tys: Tys<Self>; - type FnInputTys: Copy + Debug + Hash + Eq + Deref<Target = [Self::Ty]> + TypeVisitable<Self>; + type FnInputTys: Copy + Debug + Hash + Eq + SliceLike<Item = Self::Ty> + TypeVisitable<Self>; type ParamTy: Copy + Debug + Hash + Eq + ParamLike; type BoundTy: Copy + Debug + Hash + Eq + BoundVarLike<Self>; type PlaceholderTy: PlaceholderLike; @@ -138,11 +132,7 @@ pub trait Interner: type GenericsOf: GenericsOf<Self>; fn generics_of(self, def_id: Self::DefId) -> Self::GenericsOf; - type VariancesOf: Copy - + Debug - + Deref<Target = [ty::Variance]> - // FIXME: This is terrible! - + IntoIterator<Item: Deref<Target = ty::Variance>>; + type VariancesOf: Copy + Debug + SliceLike<Item = ty::Variance>; fn variances_of(self, def_id: Self::DefId) -> Self::VariancesOf; fn type_of(self, def_id: Self::DefId) -> ty::EarlyBinder<Self, Self::Ty>; @@ -169,11 +159,7 @@ pub trait Interner: fn check_args_compatible(self, def_id: Self::DefId, args: Self::GenericArgs) -> bool; - fn check_and_mk_args( - self, - def_id: Self::DefId, - args: impl IntoIterator<Item: Into<Self::GenericArg>>, - ) -> Self::GenericArgs; + fn debug_assert_args_compatible(self, def_id: Self::DefId, args: Self::GenericArgs); fn intern_canonical_goal_evaluation_step( self, diff --git a/compiler/rustc_type_ir/src/opaque_ty.rs b/compiler/rustc_type_ir/src/opaque_ty.rs index 738350f1b34..d8ed4770e2d 100644 --- a/compiler/rustc_type_ir/src/opaque_ty.rs +++ b/compiler/rustc_type_ir/src/opaque_ty.rs @@ -24,13 +24,13 @@ pub struct OpaqueTypeKey<I: Interner> { impl<I: Interner> OpaqueTypeKey<I> { pub fn iter_captured_args(self, tcx: I) -> impl Iterator<Item = (usize, I::GenericArg)> { let variances = tcx.variances_of(self.def_id.into()); - std::iter::zip(self.args, variances.into_iter()).enumerate().filter_map(|(i, (arg, v))| { - match (arg.kind(), *v) { + std::iter::zip(self.args.iter(), variances.iter()).enumerate().filter_map( + |(i, (arg, v))| match (arg.kind(), v) { (_, ty::Invariant) => Some((i, arg)), (ty::GenericArgKind::Lifetime(_), ty::Bivariant) => None, _ => panic!("unexpected opaque type arg variance"), - } - }) + }, + ) } pub fn fold_captured_lifetime_args( @@ -41,7 +41,7 @@ impl<I: Interner> OpaqueTypeKey<I> { let Self { def_id, args } = self; let variances = tcx.variances_of(def_id.into()); let args = - std::iter::zip(args, variances.into_iter()).map(|(arg, v)| match (arg.kind(), *v) { + std::iter::zip(args.iter(), variances.iter()).map(|(arg, v)| match (arg.kind(), v) { (ty::GenericArgKind::Lifetime(_), ty::Bivariant) => arg, (ty::GenericArgKind::Lifetime(lt), _) => f(lt).into(), _ => arg, diff --git a/compiler/rustc_type_ir/src/predicate.rs b/compiler/rustc_type_ir/src/predicate.rs index 7a3376c7218..e5bcbc67f94 100644 --- a/compiler/rustc_type_ir/src/predicate.rs +++ b/compiler/rustc_type_ir/src/predicate.rs @@ -64,36 +64,45 @@ pub struct TraitRef<I: Interner> { pub def_id: I::DefId, pub args: I::GenericArgs, /// This field exists to prevent the creation of `TraitRef` without - /// calling [`TraitRef::new`]. + /// calling [`TraitRef::new_from_args`]. _use_trait_ref_new_instead: (), } impl<I: Interner> TraitRef<I> { + pub fn new_from_args(interner: I, trait_def_id: I::DefId, args: I::GenericArgs) -> Self { + interner.debug_assert_args_compatible(trait_def_id, args); + Self { def_id: trait_def_id, args, _use_trait_ref_new_instead: () } + } + pub fn new( interner: I, trait_def_id: I::DefId, args: impl IntoIterator<Item: Into<I::GenericArg>>, ) -> Self { - let args = interner.check_and_mk_args(trait_def_id, args); - Self { def_id: trait_def_id, args, _use_trait_ref_new_instead: () } + let args = interner.mk_args_from_iter(args.into_iter().map(Into::into)); + Self::new_from_args(interner, trait_def_id, args) } pub fn from_method(interner: I, trait_id: I::DefId, args: I::GenericArgs) -> TraitRef<I> { let generics = interner.generics_of(trait_id); - TraitRef::new(interner, trait_id, args.into_iter().take(generics.count())) + TraitRef::new(interner, trait_id, args.iter().take(generics.count())) } /// Returns a `TraitRef` of the form `P0: Foo<P1..Pn>` where `Pi` /// are the parameters defined on trait. pub fn identity(interner: I, def_id: I::DefId) -> TraitRef<I> { - TraitRef::new(interner, def_id, I::GenericArgs::identity_for_item(interner, def_id)) + TraitRef::new_from_args( + interner, + def_id, + I::GenericArgs::identity_for_item(interner, def_id), + ) } pub fn with_self_ty(self, interner: I, self_ty: I::Ty) -> Self { TraitRef::new( interner, self.def_id, - [self_ty.into()].into_iter().chain(self.args.into_iter().skip(1)), + [self_ty.into()].into_iter().chain(self.args.iter().skip(1)), ) } @@ -274,7 +283,7 @@ impl<I: Interner> ty::Binder<I, ExistentialPredicate<I>> { // If this is an ill-formed auto trait, then synthesize // new error args for the missing generics. let err_args = GenericArgs::extend_with_error(tcx, did, &[self_ty.into()]); - ty::TraitRef::new(tcx, did, err_args) + ty::TraitRef::new_from_args(tcx, did, err_args) }; self.rebind(trait_ref).upcast(tcx) } @@ -311,7 +320,7 @@ impl<I: Interner> ExistentialTraitRef<I> { ExistentialTraitRef { def_id: trait_ref.def_id, - args: interner.mk_args(&trait_ref.args[1..]), + args: interner.mk_args(&trait_ref.args.as_slice()[1..]), } } @@ -323,11 +332,7 @@ impl<I: Interner> ExistentialTraitRef<I> { // otherwise the escaping vars would be captured by the binder // debug_assert!(!self_ty.has_escaping_bound_vars()); - TraitRef::new( - interner, - self.def_id, - [self_ty.into()].into_iter().chain(self.args.into_iter()), - ) + TraitRef::new(interner, self.def_id, [self_ty.into()].into_iter().chain(self.args.iter())) } } @@ -370,7 +375,7 @@ impl<I: Interner> ExistentialProjection<I> { pub fn trait_ref(&self, interner: I) -> ExistentialTraitRef<I> { let def_id = interner.parent(self.def_id); let args_count = interner.generics_of(def_id).count() - 1; - let args = interner.mk_args(&self.args[..args_count]); + let args = interner.mk_args(&self.args.as_slice()[..args_count]); ExistentialTraitRef { def_id, args } } @@ -382,7 +387,7 @@ impl<I: Interner> ExistentialProjection<I> { projection_term: AliasTerm::new( interner, self.def_id, - [self_ty.into()].into_iter().chain(self.args), + [self_ty.into()].iter().chain(self.args.iter()), ), term: self.term, } @@ -394,7 +399,7 @@ impl<I: Interner> ExistentialProjection<I> { Self { def_id: projection_predicate.projection_term.def_id, - args: interner.mk_args(&projection_predicate.projection_term.args[1..]), + args: interner.mk_args(&projection_predicate.projection_term.args.as_slice()[1..]), term: projection_predicate.term, } } @@ -485,19 +490,24 @@ pub struct AliasTerm<I: Interner> { /// aka. `interner.parent(def_id)`. pub def_id: I::DefId, - /// This field exists to prevent the creation of `AliasTerm` without using [`AliasTerm::new`]. + /// This field exists to prevent the creation of `AliasTerm` without using [`AliasTerm::new_from_args`]. #[derivative(Debug = "ignore")] _use_alias_term_new_instead: (), } impl<I: Interner> AliasTerm<I> { + pub fn new_from_args(interner: I, def_id: I::DefId, args: I::GenericArgs) -> AliasTerm<I> { + interner.debug_assert_args_compatible(def_id, args); + AliasTerm { def_id, args, _use_alias_term_new_instead: () } + } + pub fn new( interner: I, def_id: I::DefId, args: impl IntoIterator<Item: Into<I::GenericArg>>, ) -> AliasTerm<I> { - let args = interner.check_and_mk_args(def_id, args); - AliasTerm { def_id, args, _use_alias_term_new_instead: () } + let args = interner.mk_args_from_iter(args.into_iter().map(Into::into)); + Self::new_from_args(interner, def_id, args) } pub fn expect_ty(self, interner: I) -> ty::AliasTy<I> { @@ -564,7 +574,7 @@ impl<I: Interner> AliasTerm<I> { AliasTerm::new( interner, self.def_id, - [self_ty.into()].into_iter().chain(self.args.into_iter().skip(1)), + [self_ty.into()].into_iter().chain(self.args.iter().skip(1)), ) } diff --git a/compiler/rustc_type_ir/src/predicate_kind.rs b/compiler/rustc_type_ir/src/predicate_kind.rs index efe270ed608..b1d0f8d19b3 100644 --- a/compiler/rustc_type_ir/src/predicate_kind.rs +++ b/compiler/rustc_type_ir/src/predicate_kind.rs @@ -127,7 +127,6 @@ impl std::fmt::Display for AliasRelationDirection { } } -// FIXME: Convert to DebugWithInfcx impl impl<I: Interner> fmt::Debug for ClauseKind<I> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { @@ -144,7 +143,6 @@ impl<I: Interner> fmt::Debug for ClauseKind<I> { } } -// FIXME: Convert to DebugWithInfcx impl impl<I: Interner> fmt::Debug for PredicateKind<I> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { diff --git a/compiler/rustc_type_ir/src/relate.rs b/compiler/rustc_type_ir/src/relate.rs index 429bc3197d4..0439e7f857f 100644 --- a/compiler/rustc_type_ir/src/relate.rs +++ b/compiler/rustc_type_ir/src/relate.rs @@ -82,7 +82,7 @@ pub trait TypeRelation<I: Interner>: Sized { let tcx = self.tcx(); let opt_variances = tcx.variances_of(item_def_id); - relate_args_with_variances(self, item_def_id, &opt_variances, a_arg, b_arg, true) + relate_args_with_variances(self, item_def_id, opt_variances, a_arg, b_arg, true) } /// Switch variance for the purpose of relating `a` and `b`. @@ -128,7 +128,7 @@ pub fn relate_args_invariantly<I: Interner, R: TypeRelation<I>>( a_arg: I::GenericArgs, b_arg: I::GenericArgs, ) -> RelateResult<I, I::GenericArgs> { - relation.tcx().mk_args_from_iter(iter::zip(a_arg, b_arg).map(|(a, b)| { + relation.tcx().mk_args_from_iter(iter::zip(a_arg.iter(), b_arg.iter()).map(|(a, b)| { relation.relate_with_variance(ty::Invariant, VarianceDiagInfo::default(), a, b) })) } @@ -136,7 +136,7 @@ pub fn relate_args_invariantly<I: Interner, R: TypeRelation<I>>( pub fn relate_args_with_variances<I: Interner, R: TypeRelation<I>>( relation: &mut R, ty_def_id: I::DefId, - variances: &[ty::Variance], + variances: I::VariancesOf, a_arg: I::GenericArgs, b_arg: I::GenericArgs, fetch_ty_for_diag: bool, @@ -144,11 +144,11 @@ pub fn relate_args_with_variances<I: Interner, R: TypeRelation<I>>( let tcx = relation.tcx(); let mut cached_ty = None; - let params = iter::zip(a_arg, b_arg).enumerate().map(|(i, (a, b))| { - let variance = variances[i]; + let params = iter::zip(a_arg.iter(), b_arg.iter()).enumerate().map(|(i, (a, b))| { + let variance = variances.get(i).unwrap(); let variance_info = if variance == ty::Invariant && fetch_ty_for_diag { let ty = - *cached_ty.get_or_insert_with(|| tcx.type_of(ty_def_id).instantiate(tcx, &a_arg)); + *cached_ty.get_or_insert_with(|| tcx.type_of(ty_def_id).instantiate(tcx, a_arg)); VarianceDiagInfo::Invariant { ty, param_index: i.try_into().unwrap() } } else { VarianceDiagInfo::default() @@ -185,7 +185,7 @@ impl<I: Interner> Relate<I> for ty::FnSig<I> { } let inputs_and_output = iter::zip(a_inputs.iter(), b_inputs.iter()) - .map(|(&a, &b)| ((a, b), false)) + .map(|(a, b)| ((a, b), false)) .chain(iter::once(((a.output(), b.output()), true))) .map(|((a, b), is_output)| { if is_output { @@ -249,7 +249,7 @@ impl<I: Interner> Relate<I> for ty::AliasTy<I> { ty::Opaque => relate_args_with_variances( relation, a.def_id, - &relation.tcx().variances_of(a.def_id), + relation.tcx().variances_of(a.def_id), a.args, b.args, false, // do not fetch `type_of(a_def_id)`, as it will cause a cycle @@ -258,7 +258,7 @@ impl<I: Interner> Relate<I> for ty::AliasTy<I> { relate_args_invariantly(relation, a.args, b.args)? } }; - Ok(ty::AliasTy::new(relation.tcx(), a.def_id, args)) + Ok(ty::AliasTy::new_from_args(relation.tcx(), a.def_id, args)) } } } @@ -280,7 +280,7 @@ impl<I: Interner> Relate<I> for ty::AliasTerm<I> { ty::AliasTermKind::OpaqueTy => relate_args_with_variances( relation, a.def_id, - &relation.tcx().variances_of(a.def_id), + relation.tcx().variances_of(a.def_id), a.args, b.args, false, // do not fetch `type_of(a_def_id)`, as it will cause a cycle @@ -293,7 +293,7 @@ impl<I: Interner> Relate<I> for ty::AliasTerm<I> { relate_args_invariantly(relation, a.args, b.args)? } }; - Ok(ty::AliasTerm::new(relation.tcx(), a.def_id, args)) + Ok(ty::AliasTerm::new_from_args(relation.tcx(), a.def_id, args)) } } } @@ -343,7 +343,7 @@ impl<I: Interner> Relate<I> for ty::TraitRef<I> { })) } else { let args = relate_args_invariantly(relation, a.args, b.args)?; - Ok(ty::TraitRef::new(relation.tcx(), a.def_id, args)) + Ok(ty::TraitRef::new_from_args(relation.tcx(), a.def_id, args)) } } } @@ -525,7 +525,7 @@ pub fn structurally_relate_tys<I: Interner, R: TypeRelation<I>>( if as_.len() == bs.len() { Ok(Ty::new_tup_from_iter( tcx, - iter::zip(as_, bs).map(|(a, b)| relation.relate(a, b)), + iter::zip(as_.iter(), bs.iter()).map(|(a, b)| relation.relate(a, b)), )?) } else if !(as_.is_empty() || bs.is_empty()) { Err(TypeError::TupleSize(ExpectedFound::new(true, as_.len(), bs.len()))) @@ -607,8 +607,8 @@ pub fn structurally_relate_consts<I: Interner, R: TypeRelation<I>>( // be stabilized. (ty::ConstKind::Unevaluated(au), ty::ConstKind::Unevaluated(bu)) if au.def == bu.def => { if cfg!(debug_assertions) { - let a_ty = tcx.type_of(au.def).instantiate(tcx, &au.args); - let b_ty = tcx.type_of(bu.def).instantiate(tcx, &bu.args); + let a_ty = tcx.type_of(au.def).instantiate(tcx, au.args); + let b_ty = tcx.type_of(bu.def).instantiate(tcx, bu.args); assert_eq!(a_ty, b_ty); } diff --git a/compiler/rustc_type_ir/src/ty_kind.rs b/compiler/rustc_type_ir/src/ty_kind.rs index 915888ab59b..4ffebef9f1f 100644 --- a/compiler/rustc_type_ir/src/ty_kind.rs +++ b/compiler/rustc_type_ir/src/ty_kind.rs @@ -352,7 +352,7 @@ impl<I: Interner> fmt::Debug for TyKind<I> { Float(float) => write!(f, "{float:?}"), Adt(d, s) => { write!(f, "{d:?}")?; - let mut s = s.into_iter(); + let mut s = s.iter(); let first = s.next(); match first { Some(first) => write!(f, "<{:?}", first)?, @@ -388,7 +388,7 @@ impl<I: Interner> fmt::Debug for TyKind<I> { Tuple(t) => { write!(f, "(")?; let mut count = 0; - for ty in *t { + for ty in t.iter() { if count > 0 { write!(f, ", ")?; } @@ -452,19 +452,24 @@ pub struct AliasTy<I: Interner> { /// aka. `interner.parent(def_id)`. pub def_id: I::DefId, - /// This field exists to prevent the creation of `AliasTy` without using [`AliasTy::new`]. + /// This field exists to prevent the creation of `AliasTy` without using [`AliasTy::new_from_args`]. #[derivative(Debug = "ignore")] pub(crate) _use_alias_ty_new_instead: (), } impl<I: Interner> AliasTy<I> { + pub fn new_from_args(interner: I, def_id: I::DefId, args: I::GenericArgs) -> AliasTy<I> { + interner.debug_assert_args_compatible(def_id, args); + AliasTy { def_id, args, _use_alias_ty_new_instead: () } + } + pub fn new( interner: I, def_id: I::DefId, args: impl IntoIterator<Item: Into<I::GenericArg>>, ) -> AliasTy<I> { - let args = interner.check_and_mk_args(def_id, args); - AliasTy { def_id, args, _use_alias_ty_new_instead: () } + let args = interner.mk_args_from_iter(args.into_iter().map(Into::into)); + Self::new_from_args(interner, def_id, args) } pub fn kind(self, interner: I) -> AliasTyKind { @@ -491,7 +496,7 @@ impl<I: Interner> AliasTy<I> { AliasTy::new( interner, self.def_id, - [self_ty.into()].into_iter().chain(self.args.into_iter().skip(1)), + [self_ty.into()].into_iter().chain(self.args.iter().skip(1)), ) } @@ -539,7 +544,7 @@ impl<I: Interner> AliasTy<I> { interner: I, ) -> I::GenericArgs { debug_assert_eq!(self.kind(interner), AliasTyKind::Inherent); - interner.mk_args_from_iter(impl_args.into_iter().chain(self.args.into_iter().skip(1))) + interner.mk_args_from_iter(impl_args.iter().chain(self.args.iter().skip(1))) } } @@ -1000,7 +1005,7 @@ impl<I: Interner> ty::Binder<I, FnSig<I>> { #[inline] #[track_caller] pub fn input(self, index: usize) -> ty::Binder<I, I::Ty> { - self.map_bound(|fn_sig| fn_sig.inputs()[index]) + self.map_bound(|fn_sig| fn_sig.inputs().get(index).unwrap()) } pub fn inputs_and_output(self) -> ty::Binder<I, I::Tys> { diff --git a/compiler/rustc_type_ir/src/ty_kind/closure.rs b/compiler/rustc_type_ir/src/ty_kind/closure.rs index 3a17a27bd03..24a7c0c67e9 100644 --- a/compiler/rustc_type_ir/src/ty_kind/closure.rs +++ b/compiler/rustc_type_ir/src/ty_kind/closure.rs @@ -138,7 +138,7 @@ impl<I: Interner> ClosureArgs<I> { /// for the closure parent, alongside additional closure-specific components. pub fn new(tcx: I, parts: ClosureArgsParts<I>) -> ClosureArgs<I> { ClosureArgs { - args: tcx.mk_args_from_iter(parts.parent_args.iter().copied().chain([ + args: tcx.mk_args_from_iter(parts.parent_args.iter().chain([ parts.closure_kind_ty.into(), parts.closure_sig_as_fn_ptr_ty.into(), parts.tupled_upvars_ty.into(), @@ -260,7 +260,7 @@ pub struct CoroutineClosureArgsParts<I: Interner> { impl<I: Interner> CoroutineClosureArgs<I> { pub fn new(tcx: I, parts: CoroutineClosureArgsParts<I>) -> CoroutineClosureArgs<I> { CoroutineClosureArgs { - args: tcx.mk_args_from_iter(parts.parent_args.iter().copied().chain([ + args: tcx.mk_args_from_iter(parts.parent_args.iter().chain([ parts.closure_kind_ty.into(), parts.signature_parts_ty.into(), parts.tupled_upvars_ty.into(), @@ -309,10 +309,10 @@ impl<I: Interner> CoroutineClosureArgs<I> { let interior = self.coroutine_witness_ty(); let ty::FnPtr(sig) = self.signature_parts_ty().kind() else { panic!() }; sig.map_bound(|sig| { - let [resume_ty, tupled_inputs_ty] = *sig.inputs() else { + let [resume_ty, tupled_inputs_ty] = *sig.inputs().as_slice() else { panic!(); }; - let [yield_ty, return_ty] = **sig.output().tuple_fields() else { panic!() }; + let [yield_ty, return_ty] = *sig.output().tuple_fields().as_slice() else { panic!() }; CoroutineClosureSignature { interior, tupled_inputs_ty, @@ -496,16 +496,16 @@ impl<I: Interner> CoroutineClosureSignature<I> { tcx, tupled_inputs_ty .tuple_fields() - .into_iter() - .chain(coroutine_captures_by_ref_ty.tuple_fields()), + .iter() + .chain(coroutine_captures_by_ref_ty.tuple_fields().iter()), ) } ty::ClosureKind::FnOnce => Ty::new_tup_from_iter( tcx, tupled_inputs_ty .tuple_fields() - .into_iter() - .chain(closure_tupled_upvars_ty.tuple_fields()), + .iter() + .chain(closure_tupled_upvars_ty.tuple_fields().iter()), ), } } @@ -617,7 +617,7 @@ impl<I: Interner> CoroutineArgs<I> { /// for the coroutine parent, alongside additional coroutine-specific components. pub fn new(tcx: I, parts: CoroutineArgsParts<I>) -> CoroutineArgs<I> { CoroutineArgs { - args: tcx.mk_args_from_iter(parts.parent_args.iter().copied().chain([ + args: tcx.mk_args_from_iter(parts.parent_args.iter().chain([ parts.kind_ty.into(), parts.resume_ty.into(), parts.yield_ty.into(), diff --git a/library/alloc/src/collections/vec_deque/into_iter.rs b/library/alloc/src/collections/vec_deque/into_iter.rs index 692af7c197a..4747517393c 100644 --- a/library/alloc/src/collections/vec_deque/into_iter.rs +++ b/library/alloc/src/collections/vec_deque/into_iter.rs @@ -132,7 +132,7 @@ impl<T, A: Allocator> Iterator for IntoIter<T, A> { fn next_chunk<const N: usize>( &mut self, ) -> Result<[Self::Item; N], array::IntoIter<Self::Item, N>> { - let mut raw_arr = MaybeUninit::uninit_array(); + let mut raw_arr = [const { MaybeUninit::uninit() }; N]; let raw_arr_ptr = raw_arr.as_mut_ptr().cast(); let (head, tail) = self.inner.as_slices(); diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index ecb019b49c6..a1a2404a2ee 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -135,7 +135,6 @@ #![feature(layout_for_ptr)] #![feature(local_waker)] #![feature(maybe_uninit_slice)] -#![feature(maybe_uninit_uninit_array)] #![feature(maybe_uninit_uninit_array_transpose)] #![feature(panic_internals)] #![feature(pattern)] diff --git a/library/alloc/src/str.rs b/library/alloc/src/str.rs index 3e23612d0c1..3bb808a6c73 100644 --- a/library/alloc/src/str.rs +++ b/library/alloc/src/str.rs @@ -206,15 +206,16 @@ impl BorrowMut<str> for String { #[stable(feature = "rust1", since = "1.0.0")] impl ToOwned for str { type Owned = String; + #[inline] fn to_owned(&self) -> String { unsafe { String::from_utf8_unchecked(self.as_bytes().to_owned()) } } + #[inline] fn clone_into(&self, target: &mut String) { - let mut b = mem::take(target).into_bytes(); - self.as_bytes().clone_into(&mut b); - *target = unsafe { String::from_utf8_unchecked(b) } + target.clear(); + target.push_str(self); } } diff --git a/library/alloc/src/vec/into_iter.rs b/library/alloc/src/vec/into_iter.rs index c4798933770..3bd89eaa6cb 100644 --- a/library/alloc/src/vec/into_iter.rs +++ b/library/alloc/src/vec/into_iter.rs @@ -254,7 +254,7 @@ impl<T, A: Allocator> Iterator for IntoIter<T, A> { #[inline] fn next_chunk<const N: usize>(&mut self) -> Result<[T; N], core::array::IntoIter<T, N>> { - let mut raw_ary = MaybeUninit::uninit_array(); + let mut raw_ary = [const { MaybeUninit::uninit() }; N]; let len = self.len(); diff --git a/library/core/src/array/iter.rs b/library/core/src/array/iter.rs index b314d0536a3..3585bf07b59 100644 --- a/library/core/src/array/iter.rs +++ b/library/core/src/array/iter.rs @@ -101,7 +101,6 @@ impl<T, const N: usize> IntoIter<T, N> { /// ``` /// #![feature(array_into_iter_constructors)] /// #![feature(maybe_uninit_uninit_array_transpose)] - /// #![feature(maybe_uninit_uninit_array)] /// use std::array::IntoIter; /// use std::mem::MaybeUninit; /// @@ -111,7 +110,7 @@ impl<T, const N: usize> IntoIter<T, N> { /// fn next_chunk<T: Copy, const N: usize>( /// it: &mut impl Iterator<Item = T>, /// ) -> Result<[T; N], IntoIter<T, N>> { - /// let mut buffer = MaybeUninit::uninit_array(); + /// let mut buffer = [const { MaybeUninit::uninit() }; N]; /// let mut i = 0; /// while i < N { /// match it.next() { @@ -203,7 +202,7 @@ impl<T, const N: usize> IntoIter<T, N> { #[unstable(feature = "array_into_iter_constructors", issue = "91583")] #[rustc_const_unstable(feature = "const_array_into_iter_constructors", issue = "91583")] pub const fn empty() -> Self { - let buffer = MaybeUninit::uninit_array(); + let buffer = [const { MaybeUninit::uninit() }; N]; let initialized = 0..0; // SAFETY: We're telling it that none of the elements are initialized, @@ -405,7 +404,8 @@ impl<T: Clone, const N: usize> Clone for IntoIter<T, N> { fn clone(&self) -> Self { // Note, we don't really need to match the exact same alive range, so // we can just clone into offset 0 regardless of where `self` is. - let mut new = Self { data: MaybeUninit::uninit_array(), alive: IndexRange::zero_to(0) }; + let mut new = + Self { data: [const { MaybeUninit::uninit() }; N], alive: IndexRange::zero_to(0) }; // Clone all alive elements. for (src, dst) in iter::zip(self.as_slice(), &mut new.data) { diff --git a/library/core/src/array/mod.rs b/library/core/src/array/mod.rs index 3e4eadbb7c9..8285c64ed29 100644 --- a/library/core/src/array/mod.rs +++ b/library/core/src/array/mod.rs @@ -127,7 +127,7 @@ where R: Try, R::Residual: Residual<[R::Output; N]>, { - let mut array = MaybeUninit::uninit_array::<N>(); + let mut array = [const { MaybeUninit::uninit() }; N]; match try_from_fn_erased(&mut array, cb) { ControlFlow::Break(r) => FromResidual::from_residual(r), ControlFlow::Continue(()) => { @@ -918,7 +918,7 @@ impl<T> Drop for Guard<'_, T> { pub(crate) fn iter_next_chunk<T, const N: usize>( iter: &mut impl Iterator<Item = T>, ) -> Result<[T; N], IntoIter<T, N>> { - let mut array = MaybeUninit::uninit_array::<N>(); + let mut array = [const { MaybeUninit::uninit() }; N]; let r = iter_next_chunk_erased(&mut array, iter); match r { Ok(()) => { diff --git a/library/core/src/fmt/float.rs b/library/core/src/fmt/float.rs index 7f23d3c0956..80c45fce2f0 100644 --- a/library/core/src/fmt/float.rs +++ b/library/core/src/fmt/float.rs @@ -35,8 +35,8 @@ fn float_to_decimal_common_exact<T>( where T: flt2dec::DecodableFloat, { - let mut buf: [MaybeUninit<u8>; 1024] = MaybeUninit::uninit_array(); // enough for f32 and f64 - let mut parts: [MaybeUninit<numfmt::Part<'_>>; 4] = MaybeUninit::uninit_array(); + let mut buf: [MaybeUninit<u8>; 1024] = [MaybeUninit::uninit(); 1024]; // enough for f32 and f64 + let mut parts: [MaybeUninit<numfmt::Part<'_>>; 4] = [MaybeUninit::uninit(); 4]; let formatted = flt2dec::to_exact_fixed_str( flt2dec::strategy::grisu::format_exact, *num, @@ -62,8 +62,9 @@ where T: flt2dec::DecodableFloat, { // enough for f32 and f64 - let mut buf: [MaybeUninit<u8>; flt2dec::MAX_SIG_DIGITS] = MaybeUninit::uninit_array(); - let mut parts: [MaybeUninit<numfmt::Part<'_>>; 4] = MaybeUninit::uninit_array(); + let mut buf: [MaybeUninit<u8>; flt2dec::MAX_SIG_DIGITS] = + [MaybeUninit::uninit(); flt2dec::MAX_SIG_DIGITS]; + let mut parts: [MaybeUninit<numfmt::Part<'_>>; 4] = [MaybeUninit::uninit(); 4]; let formatted = flt2dec::to_shortest_str( flt2dec::strategy::grisu::format_shortest, *num, @@ -107,8 +108,8 @@ fn float_to_exponential_common_exact<T>( where T: flt2dec::DecodableFloat, { - let mut buf: [MaybeUninit<u8>; 1024] = MaybeUninit::uninit_array(); // enough for f32 and f64 - let mut parts: [MaybeUninit<numfmt::Part<'_>>; 6] = MaybeUninit::uninit_array(); + let mut buf: [MaybeUninit<u8>; 1024] = [MaybeUninit::uninit(); 1024]; // enough for f32 and f64 + let mut parts: [MaybeUninit<numfmt::Part<'_>>; 6] = [MaybeUninit::uninit(); 6]; let formatted = flt2dec::to_exact_exp_str( flt2dec::strategy::grisu::format_exact, *num, @@ -135,8 +136,9 @@ where T: flt2dec::DecodableFloat, { // enough for f32 and f64 - let mut buf: [MaybeUninit<u8>; flt2dec::MAX_SIG_DIGITS] = MaybeUninit::uninit_array(); - let mut parts: [MaybeUninit<numfmt::Part<'_>>; 6] = MaybeUninit::uninit_array(); + let mut buf: [MaybeUninit<u8>; flt2dec::MAX_SIG_DIGITS] = + [MaybeUninit::uninit(); flt2dec::MAX_SIG_DIGITS]; + let mut parts: [MaybeUninit<numfmt::Part<'_>>; 6] = [MaybeUninit::uninit(); 6]; let formatted = flt2dec::to_shortest_exp_str( flt2dec::strategy::grisu::format_shortest, *num, diff --git a/library/core/src/iter/adapters/copied.rs b/library/core/src/iter/adapters/copied.rs index 6d82d1581f7..d772e7b36e0 100644 --- a/library/core/src/iter/adapters/copied.rs +++ b/library/core/src/iter/adapters/copied.rs @@ -202,7 +202,7 @@ where T: Copy, { fn spec_next_chunk(&mut self) -> Result<[T; N], array::IntoIter<T, N>> { - let mut raw_array = MaybeUninit::uninit_array(); + let mut raw_array = [const { MaybeUninit::uninit() }; N]; let len = self.len(); diff --git a/library/core/src/iter/adapters/filter.rs b/library/core/src/iter/adapters/filter.rs index a7f1fde6975..ca23d1b13a8 100644 --- a/library/core/src/iter/adapters/filter.rs +++ b/library/core/src/iter/adapters/filter.rs @@ -64,7 +64,7 @@ where fn next_chunk<const N: usize>( &mut self, ) -> Result<[Self::Item; N], array::IntoIter<Self::Item, N>> { - let mut array: [MaybeUninit<Self::Item>; N] = MaybeUninit::uninit_array(); + let mut array: [MaybeUninit<Self::Item>; N] = [const { MaybeUninit::uninit() }; N]; struct Guard<'a, T> { array: &'a mut [MaybeUninit<T>], diff --git a/library/core/src/iter/adapters/filter_map.rs b/library/core/src/iter/adapters/filter_map.rs index 1a5f9e62654..2126619a58a 100644 --- a/library/core/src/iter/adapters/filter_map.rs +++ b/library/core/src/iter/adapters/filter_map.rs @@ -68,7 +68,7 @@ where fn next_chunk<const N: usize>( &mut self, ) -> Result<[Self::Item; N], array::IntoIter<Self::Item, N>> { - let mut array: [MaybeUninit<Self::Item>; N] = MaybeUninit::uninit_array(); + let mut array: [MaybeUninit<Self::Item>; N] = [const { MaybeUninit::uninit() }; N]; struct Guard<'a, T> { array: &'a mut [MaybeUninit<T>], diff --git a/library/core/src/iter/adapters/map_windows.rs b/library/core/src/iter/adapters/map_windows.rs index 5f39b245834..18277512136 100644 --- a/library/core/src/iter/adapters/map_windows.rs +++ b/library/core/src/iter/adapters/map_windows.rs @@ -110,7 +110,8 @@ impl<I: Iterator, const N: usize> MapWindowsInner<I, N> { impl<T, const N: usize> Buffer<T, N> { fn try_from_iter(iter: &mut impl Iterator<Item = T>) -> Option<Self> { let first_half = crate::array::iter_next_chunk(iter).ok()?; - let buffer = [MaybeUninit::new(first_half).transpose(), MaybeUninit::uninit_array()]; + let buffer = + [MaybeUninit::new(first_half).transpose(), [const { MaybeUninit::uninit() }; N]]; Some(Self { buffer, start: 0 }) } @@ -204,7 +205,7 @@ impl<T, const N: usize> Buffer<T, N> { impl<T: Clone, const N: usize> Clone for Buffer<T, N> { fn clone(&self) -> Self { let mut buffer = Buffer { - buffer: [MaybeUninit::uninit_array(), MaybeUninit::uninit_array()], + buffer: [[const { MaybeUninit::uninit() }; N], [const { MaybeUninit::uninit() }; N]], start: self.start, }; buffer.as_uninit_array_mut().write(self.as_array_ref().clone()); diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 2d0b8825f43..d1692729a31 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -140,7 +140,6 @@ #![feature(const_likely)] #![feature(const_maybe_uninit_as_mut_ptr)] #![feature(const_maybe_uninit_assume_init)] -#![feature(const_maybe_uninit_uninit_array)] #![feature(const_nonnull_new)] #![feature(const_num_midpoint)] #![feature(const_option)] @@ -177,7 +176,6 @@ #![feature(is_ascii_octdigit)] #![feature(isqrt)] #![feature(link_cfg)] -#![feature(maybe_uninit_uninit_array)] #![feature(offset_of_enum)] #![feature(offset_of_nested)] #![feature(panic_internals)] diff --git a/library/core/src/marker.rs b/library/core/src/marker.rs index 2e8be7bde4b..0fedb8835d1 100644 --- a/library/core/src/marker.rs +++ b/library/core/src/marker.rs @@ -1018,3 +1018,12 @@ pub trait FnPtr: Copy + Clone { #[lang = "fn_ptr_addr"] fn addr(self) -> *const (); } + +/// Derive macro generating impls of traits related to smart pointers. +#[cfg(not(bootstrap))] +#[rustc_builtin_macro] +#[allow_internal_unstable(dispatch_from_dyn, coerce_unsized, unsize)] +#[unstable(feature = "derive_smart_pointer", issue = "123430")] +pub macro SmartPointer($item:item) { + /* compiler built-in */ +} diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs index 4175d4a3329..24ebe33bb2c 100644 --- a/library/core/src/mem/maybe_uninit.rs +++ b/library/core/src/mem/maybe_uninit.rs @@ -917,11 +917,10 @@ impl<T> MaybeUninit<T> { /// # Examples /// /// ``` - /// #![feature(maybe_uninit_uninit_array)] /// #![feature(maybe_uninit_array_assume_init)] /// use std::mem::MaybeUninit; /// - /// let mut array: [MaybeUninit<i32>; 3] = MaybeUninit::uninit_array(); + /// let mut array: [MaybeUninit<i32>; 3] = [MaybeUninit::uninit(); 3]; /// array[0].write(0); /// array[1].write(1); /// array[2].write(2); diff --git a/library/core/src/net/display_buffer.rs b/library/core/src/net/display_buffer.rs index b7e778605fc..6619c85f483 100644 --- a/library/core/src/net/display_buffer.rs +++ b/library/core/src/net/display_buffer.rs @@ -11,7 +11,7 @@ pub struct DisplayBuffer<const SIZE: usize> { impl<const SIZE: usize> DisplayBuffer<SIZE> { #[inline] pub const fn new() -> Self { - Self { buf: MaybeUninit::uninit_array(), len: 0 } + Self { buf: [MaybeUninit::uninit(); SIZE], len: 0 } } #[inline] diff --git a/library/core/src/num/mod.rs b/library/core/src/num/mod.rs index ab1ede38979..034af6a0d57 100644 --- a/library/core/src/num/mod.rs +++ b/library/core/src/num/mod.rs @@ -483,7 +483,6 @@ impl u8 { Self = u8, ActualT = u8, SignedT = i8, - NonZeroT = NonZero<u8>, BITS = 8, MAX = 255, rot = 2, @@ -1098,7 +1097,6 @@ impl u16 { Self = u16, ActualT = u16, SignedT = i16, - NonZeroT = NonZero<u16>, BITS = 16, MAX = 65535, rot = 4, @@ -1147,7 +1145,6 @@ impl u32 { Self = u32, ActualT = u32, SignedT = i32, - NonZeroT = NonZero<u32>, BITS = 32, MAX = 4294967295, rot = 8, @@ -1171,7 +1168,6 @@ impl u64 { Self = u64, ActualT = u64, SignedT = i64, - NonZeroT = NonZero<u64>, BITS = 64, MAX = 18446744073709551615, rot = 12, @@ -1195,7 +1191,6 @@ impl u128 { Self = u128, ActualT = u128, SignedT = i128, - NonZeroT = NonZero<u128>, BITS = 128, MAX = 340282366920938463463374607431768211455, rot = 16, @@ -1221,7 +1216,6 @@ impl usize { Self = usize, ActualT = u16, SignedT = isize, - NonZeroT = NonZero<usize>, BITS = 16, MAX = 65535, rot = 4, @@ -1246,7 +1240,6 @@ impl usize { Self = usize, ActualT = u32, SignedT = isize, - NonZeroT = NonZero<usize>, BITS = 32, MAX = 4294967295, rot = 8, @@ -1271,7 +1264,6 @@ impl usize { Self = usize, ActualT = u64, SignedT = isize, - NonZeroT = NonZero<usize>, BITS = 64, MAX = 18446744073709551615, rot = 12, diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs index 00450c2cda3..cd74cece0d1 100644 --- a/library/core/src/num/uint_macros.rs +++ b/library/core/src/num/uint_macros.rs @@ -3,7 +3,6 @@ macro_rules! uint_impl { Self = $SelfT:ty, ActualT = $ActualT:ident, SignedT = $SignedT:ident, - NonZeroT = $NonZeroT:ty, // There are all for use *only* in doc comments. // As such, they're all passed as literals -- passing them as a string @@ -455,8 +454,19 @@ macro_rules! uint_impl { without modifying the original"] #[inline] pub const fn checked_add(self, rhs: Self) -> Option<Self> { - let (a, b) = self.overflowing_add(rhs); - if unlikely!(b) { None } else { Some(a) } + // This used to use `overflowing_add`, but that means it ends up being + // a `wrapping_add`, losing some optimization opportunities. Notably, + // phrasing it this way helps `.checked_add(1)` optimize to a check + // against `MAX` and a `add nuw`. + // Per <https://github.com/rust-lang/rust/pull/124114#issuecomment-2066173305>, + // LLVM is happy to re-form the intrinsic later if useful. + + if unlikely!(intrinsics::add_with_overflow(self, rhs).1) { + None + } else { + // SAFETY: Just checked it doesn't overflow + Some(unsafe { intrinsics::unchecked_add(self, rhs) }) + } } /// Strict integer addition. Computes `self + rhs`, panicking @@ -1216,8 +1226,7 @@ macro_rules! uint_impl { without modifying the original"] #[inline] pub const fn checked_ilog2(self) -> Option<u32> { - // FIXME: Simply use `NonZero::new` once it is actually generic. - if let Some(x) = <$NonZeroT>::new(self) { + if let Some(x) = NonZero::new(self) { Some(x.ilog2()) } else { None @@ -1239,8 +1248,7 @@ macro_rules! uint_impl { without modifying the original"] #[inline] pub const fn checked_ilog10(self) -> Option<u32> { - // FIXME: Simply use `NonZero::new` once it is actually generic. - if let Some(x) = <$NonZeroT>::new(self) { + if let Some(x) = NonZero::new(self) { Some(x.ilog10()) } else { None diff --git a/library/core/src/slice/sort/stable/mod.rs b/library/core/src/slice/sort/stable/mod.rs index 3d3fe2e70b7..18f7b2ac54a 100644 --- a/library/core/src/slice/sort/stable/mod.rs +++ b/library/core/src/slice/sort/stable/mod.rs @@ -104,7 +104,7 @@ struct AlignedStorage<T, const N: usize> { impl<T, const N: usize> AlignedStorage<T, N> { fn new() -> Self { - Self { _align: [], storage: MaybeUninit::uninit_array() } + Self { _align: [], storage: [const { MaybeUninit::uninit() }; N] } } fn as_uninit_slice_mut(&mut self) -> &mut [MaybeUninit<T>] { diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index c709ea2a15d..1d19c985f23 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -443,8 +443,8 @@ impl AtomicBool { /// /// # Safety /// - /// * `ptr` must be aligned to `align_of::<AtomicBool>()` (note that on some platforms this can - /// be bigger than `align_of::<bool>()`). + /// * `ptr` must be aligned to `align_of::<AtomicBool>()` (note that this is always true, since + /// `align_of::<AtomicBool>() == 1`). /// * `ptr` must be [valid] for both reads and writes for the whole lifetime `'a`. /// * You must adhere to the [Memory model for atomic accesses]. In particular, it is not /// allowed to mix atomic and non-atomic accesses, or atomic accesses of different sizes, @@ -2091,10 +2091,10 @@ impl<T> From<*mut T> for AtomicPtr<T> { } #[allow(unused_macros)] // This macro ends up being unused on some architectures. -macro_rules! if_not_8_bit { - (u8, $($tt:tt)*) => { "" }; - (i8, $($tt:tt)*) => { "" }; - ($_:ident, $($tt:tt)*) => { $($tt)* }; +macro_rules! if_8_bit { + (u8, $( yes = [$($yes:tt)*], )? $( no = [$($no:tt)*], )? ) => { concat!("", $($($yes)*)?) }; + (i8, $( yes = [$($yes:tt)*], )? $( no = [$($no:tt)*], )? ) => { concat!("", $($($yes)*)?) }; + ($_:ident, $( yes = [$($yes:tt)*], )? $( no = [$($no:tt)*], )? ) => { concat!("", $($($no)*)?) }; } #[cfg(target_has_atomic_load_store)] @@ -2116,18 +2116,24 @@ macro_rules! atomic_int { $int_type:ident $atomic_type:ident) => { /// An integer type which can be safely shared between threads. /// - /// This type has the same size and bit validity as the underlying - /// integer type, [` + /// This type has the same + #[doc = if_8_bit!( + $int_type, + yes = ["size, alignment, and bit validity"], + no = ["size and bit validity"], + )] + /// as the underlying integer type, [` #[doc = $s_int_type] /// `]. - #[doc = if_not_8_bit! { + #[doc = if_8_bit! { $int_type, - concat!( + no = [ "However, the alignment of this type is always equal to its ", "size, even on targets where [`", $s_int_type, "`] has a ", "lesser alignment." - ) + ], }] + /// /// For more about the differences between atomic types and /// non-atomic types as well as information about the portability of /// this type, please see the [module-level documentation]. @@ -2220,9 +2226,19 @@ macro_rules! atomic_int { /// /// # Safety /// - #[doc = concat!(" * `ptr` must be aligned to \ - `align_of::<", stringify!($atomic_type), ">()` (note that on some platforms this \ - can be bigger than `align_of::<", stringify!($int_type), ">()`).")] + /// * `ptr` must be aligned to + #[doc = concat!(" `align_of::<", stringify!($atomic_type), ">()`")] + #[doc = if_8_bit!{ + $int_type, + yes = [ + " (note that this is always true, since `align_of::<", + stringify!($atomic_type), ">() == 1`)." + ], + no = [ + " (note that on some platforms this can be bigger than `align_of::<", + stringify!($int_type), ">()`)." + ], + }] /// * `ptr` must be [valid] for both reads and writes for the whole lifetime `'a`. /// * You must adhere to the [Memory model for atomic accesses]. In particular, it is not /// allowed to mix atomic and non-atomic accesses, or atomic accesses of different sizes, @@ -2261,12 +2277,12 @@ macro_rules! atomic_int { #[doc = concat!("Get atomic access to a `&mut ", stringify!($int_type), "`.")] /// - #[doc = if_not_8_bit! { + #[doc = if_8_bit! { $int_type, - concat!( + no = [ "**Note:** This function is only available on targets where `", stringify!($int_type), "` has an alignment of ", $align, " bytes." - ) + ], }] /// /// # Examples diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index 3a2c98db0d5..57127df51eb 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -54,8 +54,6 @@ #![feature(slice_split_once)] #![feature(split_as_slice)] #![feature(maybe_uninit_fill)] -#![feature(maybe_uninit_slice)] -#![feature(maybe_uninit_uninit_array)] #![feature(maybe_uninit_write_slice)] #![feature(maybe_uninit_uninit_array_transpose)] #![feature(min_specialization)] diff --git a/library/std/src/fs/tests.rs b/library/std/src/fs/tests.rs index 62a268facb6..b75579d6d5e 100644 --- a/library/std/src/fs/tests.rs +++ b/library/std/src/fs/tests.rs @@ -406,7 +406,7 @@ fn file_test_read_buf() { let filename = &tmpdir.join("test"); check!(fs::write(filename, &[1, 2, 3, 4])); - let mut buf: [MaybeUninit<u8>; 128] = MaybeUninit::uninit_array(); + let mut buf: [MaybeUninit<u8>; 128] = [MaybeUninit::uninit(); 128]; let mut buf = BorrowedBuf::from(buf.as_mut_slice()); let mut file = check!(File::open(filename)); check!(file.read_buf(buf.unfilled())); diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index caa8c7375ec..27ed2e4137c 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -337,7 +337,6 @@ #![feature(hint_assert_unchecked)] #![feature(ip)] #![feature(maybe_uninit_slice)] -#![feature(maybe_uninit_uninit_array)] #![feature(maybe_uninit_write_slice)] #![feature(panic_can_unwind)] #![feature(panic_info_message)] @@ -407,7 +406,6 @@ #![feature(const_ip)] #![feature(const_ipv4)] #![feature(const_ipv6)] -#![feature(const_maybe_uninit_uninit_array)] #![feature(const_waker)] #![feature(thread_local_internals)] // tidy-alphabetical-end diff --git a/library/std/src/net/tcp/tests.rs b/library/std/src/net/tcp/tests.rs index ec8b62f9687..3ad046733a6 100644 --- a/library/std/src/net/tcp/tests.rs +++ b/library/std/src/net/tcp/tests.rs @@ -301,7 +301,7 @@ fn read_buf() { }); let mut s = t!(srv.accept()).0; - let mut buf: [MaybeUninit<u8>; 128] = MaybeUninit::uninit_array(); + let mut buf: [MaybeUninit<u8>; 128] = [MaybeUninit::uninit(); 128]; let mut buf = BorrowedBuf::from(buf.as_mut_slice()); t!(s.read_buf(buf.unfilled())); assert_eq!(buf.filled(), &[1, 2, 3, 4]); diff --git a/library/std/src/process/tests.rs b/library/std/src/process/tests.rs index 07d4de5c1a2..63455a274fa 100644 --- a/library/std/src/process/tests.rs +++ b/library/std/src/process/tests.rs @@ -137,7 +137,7 @@ fn child_stdout_read_buf() { let child = cmd.spawn().unwrap(); let mut stdout = child.stdout.unwrap(); - let mut buf: [MaybeUninit<u8>; 128] = MaybeUninit::uninit_array(); + let mut buf: [MaybeUninit<u8>; 128] = [MaybeUninit::uninit(); 128]; let mut buf = BorrowedBuf::from(buf.as_mut_slice()); stdout.read_buf(buf.unfilled()).unwrap(); diff --git a/library/std/src/sys/pal/hermit/mod.rs b/library/std/src/sys/pal/hermit/mod.rs index eca7351d54c..55583b89d67 100644 --- a/library/std/src/sys/pal/hermit/mod.rs +++ b/library/std/src/sys/pal/hermit/mod.rs @@ -32,9 +32,6 @@ pub mod pipe; pub mod process; pub mod stdio; pub mod thread; -pub mod thread_local_dtor; -#[path = "../unsupported/thread_local_key.rs"] -pub mod thread_local_key; pub mod time; use crate::io::ErrorKind; @@ -97,7 +94,6 @@ pub unsafe extern "C" fn runtime_entry( argv: *const *const c_char, env: *const *const c_char, ) -> ! { - use thread_local_dtor::run_dtors; extern "C" { fn main(argc: isize, argv: *const *const c_char) -> i32; } @@ -107,7 +103,7 @@ pub unsafe extern "C" fn runtime_entry( let result = main(argc as isize, argv); - run_dtors(); + crate::sys::thread_local::destructors::run(); hermit_abi::exit(result); } diff --git a/library/std/src/sys/pal/hermit/thread.rs b/library/std/src/sys/pal/hermit/thread.rs index 07a843a597e..a244b953d2a 100644 --- a/library/std/src/sys/pal/hermit/thread.rs +++ b/library/std/src/sys/pal/hermit/thread.rs @@ -1,7 +1,6 @@ #![allow(dead_code)] use super::hermit_abi; -use super::thread_local_dtor::run_dtors; use crate::ffi::CStr; use crate::io; use crate::mem; @@ -50,7 +49,7 @@ impl Thread { Box::from_raw(ptr::with_exposed_provenance::<Box<dyn FnOnce()>>(main).cast_mut())(); // run all destructors - run_dtors(); + crate::sys::thread_local::destructors::run(); } } } diff --git a/library/std/src/sys/pal/hermit/thread_local_dtor.rs b/library/std/src/sys/pal/hermit/thread_local_dtor.rs deleted file mode 100644 index 98adaf4bff1..00000000000 --- a/library/std/src/sys/pal/hermit/thread_local_dtor.rs +++ /dev/null @@ -1,29 +0,0 @@ -#![cfg(target_thread_local)] -#![unstable(feature = "thread_local_internals", issue = "none")] - -// Simplify dtor registration by using a list of destructors. -// The this solution works like the implementation of macOS and -// doesn't additional OS support - -use crate::cell::RefCell; - -#[thread_local] -static DTORS: RefCell<Vec<(*mut u8, unsafe extern "C" fn(*mut u8))>> = RefCell::new(Vec::new()); - -pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { - match DTORS.try_borrow_mut() { - Ok(mut dtors) => dtors.push((t, dtor)), - Err(_) => rtabort!("global allocator may not use TLS"), - } -} - -// every thread call this function to run through all possible destructors -pub unsafe fn run_dtors() { - let mut list = DTORS.take(); - while !list.is_empty() { - for (ptr, dtor) in list { - dtor(ptr); - } - list = DTORS.take(); - } -} diff --git a/library/std/src/sys/pal/itron/thread.rs b/library/std/src/sys/pal/itron/thread.rs index a0c8217128f..fd7b5558f75 100644 --- a/library/std/src/sys/pal/itron/thread.rs +++ b/library/std/src/sys/pal/itron/thread.rs @@ -15,7 +15,6 @@ use crate::{ num::NonZero, ptr::NonNull, sync::atomic::{AtomicUsize, Ordering}, - sys::thread_local_dtor::run_dtors, time::Duration, }; @@ -117,7 +116,7 @@ impl Thread { // Run TLS destructors now because they are not // called automatically for terminated tasks. - unsafe { run_dtors() }; + unsafe { crate::sys::thread_local::destructors::run() }; let old_lifecycle = inner .lifecycle diff --git a/library/std/src/sys/pal/sgx/mod.rs b/library/std/src/sys/pal/sgx/mod.rs index d30976ec151..851ab9b9f97 100644 --- a/library/std/src/sys/pal/sgx/mod.rs +++ b/library/std/src/sys/pal/sgx/mod.rs @@ -26,7 +26,6 @@ pub mod pipe; pub mod process; pub mod stdio; pub mod thread; -pub mod thread_local_key; pub mod thread_parking; pub mod time; pub mod waitqueue; diff --git a/library/std/src/sys/pal/solid/mod.rs b/library/std/src/sys/pal/solid/mod.rs index 3f6ff37903a..9a7741ddda7 100644 --- a/library/std/src/sys/pal/solid/mod.rs +++ b/library/std/src/sys/pal/solid/mod.rs @@ -33,8 +33,6 @@ pub mod pipe; pub mod process; pub mod stdio; pub use self::itron::thread; -pub mod thread_local_dtor; -pub mod thread_local_key; pub use self::itron::thread_parking; pub mod time; diff --git a/library/std/src/sys/pal/solid/thread_local_dtor.rs b/library/std/src/sys/pal/solid/thread_local_dtor.rs deleted file mode 100644 index 26918a4fcb0..00000000000 --- a/library/std/src/sys/pal/solid/thread_local_dtor.rs +++ /dev/null @@ -1,43 +0,0 @@ -#![cfg(target_thread_local)] -#![unstable(feature = "thread_local_internals", issue = "none")] - -// Simplify dtor registration by using a list of destructors. - -use super::{abi, itron::task}; -use crate::cell::{Cell, RefCell}; - -#[thread_local] -static REGISTERED: Cell<bool> = Cell::new(false); - -#[thread_local] -static DTORS: RefCell<Vec<(*mut u8, unsafe extern "C" fn(*mut u8))>> = RefCell::new(Vec::new()); - -pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { - if !REGISTERED.get() { - let tid = task::current_task_id_aborting(); - // Register `tls_dtor` to make sure the TLS destructors are called - // for tasks created by other means than `std::thread` - unsafe { abi::SOLID_TLS_AddDestructor(tid as i32, tls_dtor) }; - REGISTERED.set(true); - } - - match DTORS.try_borrow_mut() { - Ok(mut dtors) => dtors.push((t, dtor)), - Err(_) => rtabort!("global allocator may not use TLS"), - } -} - -pub unsafe fn run_dtors() { - let mut list = DTORS.take(); - while !list.is_empty() { - for (ptr, dtor) in list { - unsafe { dtor(ptr) }; - } - - list = DTORS.take(); - } -} - -unsafe extern "C" fn tls_dtor(_unused: *mut u8) { - unsafe { run_dtors() }; -} diff --git a/library/std/src/sys/pal/solid/thread_local_key.rs b/library/std/src/sys/pal/solid/thread_local_key.rs deleted file mode 100644 index b37bf999698..00000000000 --- a/library/std/src/sys/pal/solid/thread_local_key.rs +++ /dev/null @@ -1,21 +0,0 @@ -pub type Key = usize; - -#[inline] -pub unsafe fn create(_dtor: Option<unsafe extern "C" fn(*mut u8)>) -> Key { - panic!("should not be used on the solid target"); -} - -#[inline] -pub unsafe fn set(_key: Key, _value: *mut u8) { - panic!("should not be used on the solid target"); -} - -#[inline] -pub unsafe fn get(_key: Key) -> *mut u8 { - panic!("should not be used on the solid target"); -} - -#[inline] -pub unsafe fn destroy(_key: Key) { - panic!("should not be used on the solid target"); -} diff --git a/library/std/src/sys/pal/teeos/mod.rs b/library/std/src/sys/pal/teeos/mod.rs index 6dd465a12ed..2a789e72722 100644 --- a/library/std/src/sys/pal/teeos/mod.rs +++ b/library/std/src/sys/pal/teeos/mod.rs @@ -27,9 +27,6 @@ pub mod process; mod rand; pub mod stdio; pub mod thread; -pub mod thread_local_dtor; -#[path = "../unix/thread_local_key.rs"] -pub mod thread_local_key; #[allow(non_upper_case_globals)] #[path = "../unix/time.rs"] pub mod time; diff --git a/library/std/src/sys/pal/teeos/thread_local_dtor.rs b/library/std/src/sys/pal/teeos/thread_local_dtor.rs deleted file mode 100644 index 5c6bc4d6750..00000000000 --- a/library/std/src/sys/pal/teeos/thread_local_dtor.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { - use crate::sys_common::thread_local_dtor::register_dtor_fallback; - register_dtor_fallback(t, dtor); -} diff --git a/library/std/src/sys/pal/uefi/mod.rs b/library/std/src/sys/pal/uefi/mod.rs index 48b74df1384..408031a4616 100644 --- a/library/std/src/sys/pal/uefi/mod.rs +++ b/library/std/src/sys/pal/uefi/mod.rs @@ -28,8 +28,6 @@ pub mod pipe; pub mod process; pub mod stdio; pub mod thread; -#[path = "../unsupported/thread_local_key.rs"] -pub mod thread_local_key; pub mod time; mod helpers; diff --git a/library/std/src/sys/pal/unix/mod.rs b/library/std/src/sys/pal/unix/mod.rs index b370f06e92b..16fc2011d70 100644 --- a/library/std/src/sys/pal/unix/mod.rs +++ b/library/std/src/sys/pal/unix/mod.rs @@ -33,8 +33,6 @@ pub mod rand; pub mod stack_overflow; pub mod stdio; pub mod thread; -pub mod thread_local_dtor; -pub mod thread_local_key; pub mod thread_parking; pub mod time; diff --git a/library/std/src/sys/pal/unix/thread_local_dtor.rs b/library/std/src/sys/pal/unix/thread_local_dtor.rs deleted file mode 100644 index 75db6e112ed..00000000000 --- a/library/std/src/sys/pal/unix/thread_local_dtor.rs +++ /dev/null @@ -1,126 +0,0 @@ -#![cfg(target_thread_local)] -#![unstable(feature = "thread_local_internals", issue = "none")] - -//! Provides thread-local destructors without an associated "key", which -//! can be more efficient. - -// Since what appears to be glibc 2.18 this symbol has been shipped which -// GCC and clang both use to invoke destructors in thread_local globals, so -// let's do the same! -// -// Note, however, that we run on lots older linuxes, as well as cross -// compiling from a newer linux to an older linux, so we also have a -// fallback implementation to use as well. -#[cfg(any( - target_os = "linux", - target_os = "android", - target_os = "fuchsia", - target_os = "redox", - target_os = "hurd", - target_os = "netbsd", - target_os = "dragonfly" -))] -// FIXME: The Rust compiler currently omits weakly function definitions (i.e., -// __cxa_thread_atexit_impl) and its metadata from LLVM IR. -#[no_sanitize(cfi, kcfi)] -pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { - use crate::mem; - use crate::sys_common::thread_local_dtor::register_dtor_fallback; - - /// This is necessary because the __cxa_thread_atexit_impl implementation - /// std links to by default may be a C or C++ implementation that was not - /// compiled using the Clang integer normalization option. - #[cfg(sanitizer_cfi_normalize_integers)] - use core::ffi::c_int; - #[cfg(not(sanitizer_cfi_normalize_integers))] - #[cfi_encoding = "i"] - #[repr(transparent)] - pub struct c_int(#[allow(dead_code)] pub libc::c_int); - - extern "C" { - #[linkage = "extern_weak"] - static __dso_handle: *mut u8; - #[linkage = "extern_weak"] - static __cxa_thread_atexit_impl: Option< - extern "C" fn( - unsafe extern "C" fn(*mut libc::c_void), - *mut libc::c_void, - *mut libc::c_void, - ) -> c_int, - >; - } - - if let Some(f) = __cxa_thread_atexit_impl { - unsafe { - f( - mem::transmute::< - unsafe extern "C" fn(*mut u8), - unsafe extern "C" fn(*mut libc::c_void), - >(dtor), - t.cast(), - core::ptr::addr_of!(__dso_handle) as *mut _, - ); - } - return; - } - register_dtor_fallback(t, dtor); -} - -// This implementation is very similar to register_dtor_fallback in -// sys_common/thread_local.rs. The main difference is that we want to hook into -// macOS's analog of the above linux function, _tlv_atexit. OSX will run the -// registered dtors before any TLS slots get freed, and when the main thread -// exits. -// -// Unfortunately, calling _tlv_atexit while tls dtors are running is UB. The -// workaround below is to register, via _tlv_atexit, a custom DTOR list once per -// thread. thread_local dtors are pushed to the DTOR list without calling -// _tlv_atexit. -#[cfg(target_vendor = "apple")] -pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { - use crate::cell::{Cell, RefCell}; - use crate::ptr; - - #[thread_local] - static REGISTERED: Cell<bool> = Cell::new(false); - - #[thread_local] - static DTORS: RefCell<Vec<(*mut u8, unsafe extern "C" fn(*mut u8))>> = RefCell::new(Vec::new()); - - if !REGISTERED.get() { - _tlv_atexit(run_dtors, ptr::null_mut()); - REGISTERED.set(true); - } - - extern "C" { - fn _tlv_atexit(dtor: unsafe extern "C" fn(*mut u8), arg: *mut u8); - } - - match DTORS.try_borrow_mut() { - Ok(mut dtors) => dtors.push((t, dtor)), - Err(_) => rtabort!("global allocator may not use TLS"), - } - - unsafe extern "C" fn run_dtors(_: *mut u8) { - let mut list = DTORS.take(); - while !list.is_empty() { - for (ptr, dtor) in list { - dtor(ptr); - } - list = DTORS.take(); - } - } -} - -#[cfg(any( - target_os = "vxworks", - target_os = "horizon", - target_os = "emscripten", - target_os = "aix", - target_os = "freebsd", -))] -#[cfg_attr(target_family = "wasm", allow(unused))] // might remain unused depending on target details (e.g. wasm32-unknown-emscripten) -pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { - use crate::sys_common::thread_local_dtor::register_dtor_fallback; - register_dtor_fallback(t, dtor); -} diff --git a/library/std/src/sys/pal/unix/thread_local_key.rs b/library/std/src/sys/pal/unix/thread_local_key.rs deleted file mode 100644 index 2b2d079ee4d..00000000000 --- a/library/std/src/sys/pal/unix/thread_local_key.rs +++ /dev/null @@ -1,29 +0,0 @@ -#![allow(dead_code)] // not used on all platforms - -use crate::mem; - -pub type Key = libc::pthread_key_t; - -#[inline] -pub unsafe fn create(dtor: Option<unsafe extern "C" fn(*mut u8)>) -> Key { - let mut key = 0; - assert_eq!(libc::pthread_key_create(&mut key, mem::transmute(dtor)), 0); - key -} - -#[inline] -pub unsafe fn set(key: Key, value: *mut u8) { - let r = libc::pthread_setspecific(key, value as *mut _); - debug_assert_eq!(r, 0); -} - -#[inline] -pub unsafe fn get(key: Key) -> *mut u8 { - libc::pthread_getspecific(key) as *mut u8 -} - -#[inline] -pub unsafe fn destroy(key: Key) { - let r = libc::pthread_key_delete(key); - debug_assert_eq!(r, 0); -} diff --git a/library/std/src/sys/pal/unsupported/mod.rs b/library/std/src/sys/pal/unsupported/mod.rs index 01f5cfd4297..442e6042ad5 100644 --- a/library/std/src/sys/pal/unsupported/mod.rs +++ b/library/std/src/sys/pal/unsupported/mod.rs @@ -11,9 +11,6 @@ pub mod pipe; pub mod process; pub mod stdio; pub mod thread; -#[cfg(target_thread_local)] -pub mod thread_local_dtor; -pub mod thread_local_key; pub mod time; mod common; diff --git a/library/std/src/sys/pal/unsupported/thread_local_dtor.rs b/library/std/src/sys/pal/unsupported/thread_local_dtor.rs deleted file mode 100644 index 84660ea5881..00000000000 --- a/library/std/src/sys/pal/unsupported/thread_local_dtor.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![unstable(feature = "thread_local_internals", issue = "none")] - -#[cfg_attr(target_family = "wasm", allow(unused))] // unused on wasm32-unknown-unknown -pub unsafe fn register_dtor(_t: *mut u8, _dtor: unsafe extern "C" fn(*mut u8)) { - // FIXME: right now there is no concept of "thread exit", but this is likely - // going to show up at some point in the form of an exported symbol that the - // wasm runtime is going to be expected to call. For now we basically just - // ignore the arguments, but if such a function starts to exist it will - // likely look like the OSX implementation in `unix/fast_thread_local.rs` -} diff --git a/library/std/src/sys/pal/unsupported/thread_local_key.rs b/library/std/src/sys/pal/unsupported/thread_local_key.rs deleted file mode 100644 index b6e5e4cd2e1..00000000000 --- a/library/std/src/sys/pal/unsupported/thread_local_key.rs +++ /dev/null @@ -1,21 +0,0 @@ -pub type Key = usize; - -#[inline] -pub unsafe fn create(_dtor: Option<unsafe extern "C" fn(*mut u8)>) -> Key { - panic!("should not be used on this target"); -} - -#[inline] -pub unsafe fn set(_key: Key, _value: *mut u8) { - panic!("should not be used on this target"); -} - -#[inline] -pub unsafe fn get(_key: Key) -> *mut u8 { - panic!("should not be used on this target"); -} - -#[inline] -pub unsafe fn destroy(_key: Key) { - panic!("should not be used on this target"); -} diff --git a/library/std/src/sys/pal/wasi/mod.rs b/library/std/src/sys/pal/wasi/mod.rs index c1266619b36..8dfb733043e 100644 --- a/library/std/src/sys/pal/wasi/mod.rs +++ b/library/std/src/sys/pal/wasi/mod.rs @@ -33,10 +33,6 @@ pub mod pipe; pub mod process; pub mod stdio; pub mod thread; -#[path = "../unsupported/thread_local_dtor.rs"] -pub mod thread_local_dtor; -#[path = "../unsupported/thread_local_key.rs"] -pub mod thread_local_key; pub mod time; #[path = "../unsupported/common.rs"] diff --git a/library/std/src/sys/pal/wasip2/mod.rs b/library/std/src/sys/pal/wasip2/mod.rs index 6787ffb4bed..7af0917b8ed 100644 --- a/library/std/src/sys/pal/wasip2/mod.rs +++ b/library/std/src/sys/pal/wasip2/mod.rs @@ -34,10 +34,6 @@ pub mod process; pub mod stdio; #[path = "../wasi/thread.rs"] pub mod thread; -#[path = "../unsupported/thread_local_dtor.rs"] -pub mod thread_local_dtor; -#[path = "../unsupported/thread_local_key.rs"] -pub mod thread_local_key; #[path = "../wasi/time.rs"] pub mod time; diff --git a/library/std/src/sys/pal/wasm/mod.rs b/library/std/src/sys/pal/wasm/mod.rs index 75dd10826cc..4c34859e918 100644 --- a/library/std/src/sys/pal/wasm/mod.rs +++ b/library/std/src/sys/pal/wasm/mod.rs @@ -34,10 +34,6 @@ pub mod pipe; pub mod process; #[path = "../unsupported/stdio.rs"] pub mod stdio; -#[path = "../unsupported/thread_local_dtor.rs"] -pub mod thread_local_dtor; -#[path = "../unsupported/thread_local_key.rs"] -pub mod thread_local_key; #[path = "../unsupported/time.rs"] pub mod time; diff --git a/library/std/src/sys/pal/windows/c.rs b/library/std/src/sys/pal/windows/c.rs index 9d58ce05f01..6ec82693077 100644 --- a/library/std/src/sys/pal/windows/c.rs +++ b/library/std/src/sys/pal/windows/c.rs @@ -54,6 +54,7 @@ pub const EXIT_FAILURE: u32 = 1; pub const CONDITION_VARIABLE_INIT: CONDITION_VARIABLE = CONDITION_VARIABLE { Ptr: ptr::null_mut() }; #[cfg(target_vendor = "win7")] pub const SRWLOCK_INIT: SRWLOCK = SRWLOCK { Ptr: ptr::null_mut() }; +#[cfg(not(target_thread_local))] pub const INIT_ONCE_STATIC_INIT: INIT_ONCE = INIT_ONCE { Ptr: ptr::null_mut() }; // Some windows_sys types have different signs than the types we use. diff --git a/library/std/src/sys/pal/windows/mod.rs b/library/std/src/sys/pal/windows/mod.rs index 402a205977b..6406cec9c27 100644 --- a/library/std/src/sys/pal/windows/mod.rs +++ b/library/std/src/sys/pal/windows/mod.rs @@ -31,8 +31,6 @@ pub mod process; pub mod rand; pub mod stdio; pub mod thread; -pub mod thread_local_dtor; -pub mod thread_local_key; pub mod time; cfg_if::cfg_if! { if #[cfg(not(target_vendor = "uwp"))] { @@ -227,7 +225,7 @@ where // This initial size also works around `GetFullPathNameW` returning // incorrect size hints for some short paths: // https://github.com/dylni/normpath/issues/5 - let mut stack_buf: [MaybeUninit<u16>; 512] = MaybeUninit::uninit_array(); + let mut stack_buf: [MaybeUninit<u16>; 512] = [MaybeUninit::uninit(); 512]; let mut heap_buf: Vec<MaybeUninit<u16>> = Vec::new(); unsafe { let mut n = stack_buf.len(); diff --git a/library/std/src/sys/pal/windows/thread_local_dtor.rs b/library/std/src/sys/pal/windows/thread_local_dtor.rs deleted file mode 100644 index cf542d2bfb8..00000000000 --- a/library/std/src/sys/pal/windows/thread_local_dtor.rs +++ /dev/null @@ -1,7 +0,0 @@ -//! Implements thread-local destructors that are not associated with any -//! particular data. - -#![unstable(feature = "thread_local_internals", issue = "none")] -#![cfg(target_thread_local)] - -pub use super::thread_local_key::register_keyless_dtor as register_dtor; diff --git a/library/std/src/sys/pal/windows/thread_local_key.rs b/library/std/src/sys/pal/windows/thread_local_key.rs deleted file mode 100644 index e5ba619fc6b..00000000000 --- a/library/std/src/sys/pal/windows/thread_local_key.rs +++ /dev/null @@ -1,351 +0,0 @@ -use crate::cell::UnsafeCell; -use crate::ptr; -use crate::sync::atomic::{ - AtomicPtr, AtomicU32, - Ordering::{AcqRel, Acquire, Relaxed, Release}, -}; -use crate::sys::c; - -#[cfg(test)] -mod tests; - -// Using a per-thread list avoids the problems in synchronizing global state. -#[thread_local] -#[cfg(target_thread_local)] -static DESTRUCTORS: crate::cell::RefCell<Vec<(*mut u8, unsafe extern "C" fn(*mut u8))>> = - crate::cell::RefCell::new(Vec::new()); - -// Ensure this can never be inlined because otherwise this may break in dylibs. -// See #44391. -#[inline(never)] -#[cfg(target_thread_local)] -pub unsafe fn register_keyless_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { - dtors_used(); - match DESTRUCTORS.try_borrow_mut() { - Ok(mut dtors) => dtors.push((t, dtor)), - Err(_) => rtabort!("global allocator may not use TLS"), - } -} - -#[inline(never)] // See comment above -#[cfg(target_thread_local)] -/// Runs destructors. This should not be called until thread exit. -unsafe fn run_keyless_dtors() { - // Drop all the destructors. - // - // Note: While this is potentially an infinite loop, it *should* be - // the case that this loop always terminates because we provide the - // guarantee that a TLS key cannot be set after it is flagged for - // destruction. - loop { - // Use a let-else binding to ensure the `RefCell` guard is dropped - // immediately. Otherwise, a panic would occur if a TLS destructor - // tries to access the list. - let Some((ptr, dtor)) = DESTRUCTORS.borrow_mut().pop() else { - break; - }; - (dtor)(ptr); - } - // We're done so free the memory. - DESTRUCTORS.replace(Vec::new()); -} - -type Key = c::DWORD; -type Dtor = unsafe extern "C" fn(*mut u8); - -// Turns out, like pretty much everything, Windows is pretty close the -// functionality that Unix provides, but slightly different! In the case of -// TLS, Windows does not provide an API to provide a destructor for a TLS -// variable. This ends up being pretty crucial to this implementation, so we -// need a way around this. -// -// The solution here ended up being a little obscure, but fear not, the -// internet has informed me [1][2] that this solution is not unique (no way -// I could have thought of it as well!). The key idea is to insert some hook -// somewhere to run arbitrary code on thread termination. With this in place -// we'll be able to run anything we like, including all TLS destructors! -// -// To accomplish this feat, we perform a number of threads, all contained -// within this module: -// -// * All TLS destructors are tracked by *us*, not the Windows runtime. This -// means that we have a global list of destructors for each TLS key that -// we know about. -// * When a thread exits, we run over the entire list and run dtors for all -// non-null keys. This attempts to match Unix semantics in this regard. -// -// For more details and nitty-gritty, see the code sections below! -// -// [1]: https://www.codeproject.com/Articles/8113/Thread-Local-Storage-The-C-Way -// [2]: https://github.com/ChromiumWebApps/chromium/blob/master/base/threading/thread_local_storage_win.cc#L42 - -pub struct StaticKey { - /// The key value shifted up by one. Since TLS_OUT_OF_INDEXES == DWORD::MAX - /// is not a valid key value, this allows us to use zero as sentinel value - /// without risking overflow. - key: AtomicU32, - dtor: Option<Dtor>, - next: AtomicPtr<StaticKey>, - /// Currently, destructors cannot be unregistered, so we cannot use racy - /// initialization for keys. Instead, we need synchronize initialization. - /// Use the Windows-provided `Once` since it does not require TLS. - once: UnsafeCell<c::INIT_ONCE>, -} - -impl StaticKey { - #[inline] - pub const fn new(dtor: Option<Dtor>) -> StaticKey { - StaticKey { - key: AtomicU32::new(0), - dtor, - next: AtomicPtr::new(ptr::null_mut()), - once: UnsafeCell::new(c::INIT_ONCE_STATIC_INIT), - } - } - - #[inline] - pub unsafe fn set(&'static self, val: *mut u8) { - let r = c::TlsSetValue(self.key(), val.cast()); - debug_assert_eq!(r, c::TRUE); - } - - #[inline] - pub unsafe fn get(&'static self) -> *mut u8 { - c::TlsGetValue(self.key()).cast() - } - - #[inline] - unsafe fn key(&'static self) -> Key { - match self.key.load(Acquire) { - 0 => self.init(), - key => key - 1, - } - } - - #[cold] - unsafe fn init(&'static self) -> Key { - if self.dtor.is_some() { - dtors_used(); - let mut pending = c::FALSE; - let r = c::InitOnceBeginInitialize(self.once.get(), 0, &mut pending, ptr::null_mut()); - assert_eq!(r, c::TRUE); - - if pending == c::FALSE { - // Some other thread initialized the key, load it. - self.key.load(Relaxed) - 1 - } else { - let key = c::TlsAlloc(); - if key == c::TLS_OUT_OF_INDEXES { - // Wakeup the waiting threads before panicking to avoid deadlock. - c::InitOnceComplete(self.once.get(), c::INIT_ONCE_INIT_FAILED, ptr::null_mut()); - panic!("out of TLS indexes"); - } - - register_dtor(self); - - // Release-storing the key needs to be the last thing we do. - // This is because in `fn key()`, other threads will do an acquire load of the key, - // and if that sees this write then it will entirely bypass the `InitOnce`. We thus - // need to establish synchronization through `key`. In particular that acquire load - // must happen-after the register_dtor above, to ensure the dtor actually runs! - self.key.store(key + 1, Release); - - let r = c::InitOnceComplete(self.once.get(), 0, ptr::null_mut()); - debug_assert_eq!(r, c::TRUE); - - key - } - } else { - // If there is no destructor to clean up, we can use racy initialization. - - let key = c::TlsAlloc(); - assert_ne!(key, c::TLS_OUT_OF_INDEXES, "out of TLS indexes"); - - match self.key.compare_exchange(0, key + 1, AcqRel, Acquire) { - Ok(_) => key, - Err(new) => { - // Some other thread completed initialization first, so destroy - // our key and use theirs. - let r = c::TlsFree(key); - debug_assert_eq!(r, c::TRUE); - new - 1 - } - } - } - } -} - -unsafe impl Send for StaticKey {} -unsafe impl Sync for StaticKey {} - -// ------------------------------------------------------------------------- -// Dtor registration -// -// Windows has no native support for running destructors so we manage our own -// list of destructors to keep track of how to destroy keys. We then install a -// callback later to get invoked whenever a thread exits, running all -// appropriate destructors. -// -// Currently unregistration from this list is not supported. A destructor can be -// registered but cannot be unregistered. There's various simplifying reasons -// for doing this, the big ones being: -// -// 1. Currently we don't even support deallocating TLS keys, so normal operation -// doesn't need to deallocate a destructor. -// 2. There is no point in time where we know we can unregister a destructor -// because it could always be getting run by some remote thread. -// -// Typically processes have a statically known set of TLS keys which is pretty -// small, and we'd want to keep this memory alive for the whole process anyway -// really. - -static DTORS: AtomicPtr<StaticKey> = AtomicPtr::new(ptr::null_mut()); - -/// Should only be called once per key, otherwise loops or breaks may occur in -/// the linked list. -unsafe fn register_dtor(key: &'static StaticKey) { - // Ensure this is never run when native thread locals are available. - assert_eq!(false, cfg!(target_thread_local)); - let this = <*const StaticKey>::cast_mut(key); - // Use acquire ordering to pass along the changes done by the previously - // registered keys when we store the new head with release ordering. - let mut head = DTORS.load(Acquire); - loop { - key.next.store(head, Relaxed); - match DTORS.compare_exchange_weak(head, this, Release, Acquire) { - Ok(_) => break, - Err(new) => head = new, - } - } -} - -// ------------------------------------------------------------------------- -// Where the Magic (TM) Happens -// -// If you're looking at this code, and wondering "what is this doing?", -// you're not alone! I'll try to break this down step by step: -// -// # What's up with CRT$XLB? -// -// For anything about TLS destructors to work on Windows, we have to be able -// to run *something* when a thread exits. To do so, we place a very special -// static in a very special location. If this is encoded in just the right -// way, the kernel's loader is apparently nice enough to run some function -// of ours whenever a thread exits! How nice of the kernel! -// -// Lots of detailed information can be found in source [1] above, but the -// gist of it is that this is leveraging a feature of Microsoft's PE format -// (executable format) which is not actually used by any compilers today. -// This apparently translates to any callbacks in the ".CRT$XLB" section -// being run on certain events. -// -// So after all that, we use the compiler's #[link_section] feature to place -// a callback pointer into the magic section so it ends up being called. -// -// # What's up with this callback? -// -// The callback specified receives a number of parameters from... someone! -// (the kernel? the runtime? I'm not quite sure!) There are a few events that -// this gets invoked for, but we're currently only interested on when a -// thread or a process "detaches" (exits). The process part happens for the -// last thread and the thread part happens for any normal thread. -// -// # Ok, what's up with running all these destructors? -// -// This will likely need to be improved over time, but this function -// attempts a "poor man's" destructor callback system. Once we've got a list -// of what to run, we iterate over all keys, check their values, and then run -// destructors if the values turn out to be non null (setting them to null just -// beforehand). We do this a few times in a loop to basically match Unix -// semantics. If we don't reach a fixed point after a short while then we just -// inevitably leak something most likely. -// -// # The article mentions weird stuff about "/INCLUDE"? -// -// It sure does! Specifically we're talking about this quote: -// -// The Microsoft run-time library facilitates this process by defining a -// memory image of the TLS Directory and giving it the special name -// “__tls_used” (Intel x86 platforms) or “_tls_used” (other platforms). The -// linker looks for this memory image and uses the data there to create the -// TLS Directory. Other compilers that support TLS and work with the -// Microsoft linker must use this same technique. -// -// Basically what this means is that if we want support for our TLS -// destructors/our hook being called then we need to make sure the linker does -// not omit this symbol. Otherwise it will omit it and our callback won't be -// wired up. -// -// We don't actually use the `/INCLUDE` linker flag here like the article -// mentions because the Rust compiler doesn't propagate linker flags, but -// instead we use a shim function which performs a volatile 1-byte load from -// the address of the symbol to ensure it sticks around. - -#[link_section = ".CRT$XLB"] -#[cfg_attr(miri, used)] // Miri only considers explicitly `#[used]` statics for `lookup_link_section` -pub static p_thread_callback: unsafe extern "system" fn(c::LPVOID, c::DWORD, c::LPVOID) = - on_tls_callback; - -fn dtors_used() { - // we don't want LLVM eliminating p_thread_callback when destructors are used. - // when the symbol makes it to the linker the linker will take over - unsafe { crate::intrinsics::volatile_load(&p_thread_callback) }; -} - -unsafe extern "system" fn on_tls_callback(_h: c::LPVOID, dwReason: c::DWORD, _pv: c::LPVOID) { - if dwReason == c::DLL_THREAD_DETACH || dwReason == c::DLL_PROCESS_DETACH { - #[cfg(not(target_thread_local))] - run_dtors(); - #[cfg(target_thread_local)] - run_keyless_dtors(); - } - - // See comments above for what this is doing. Note that we don't need this - // trickery on GNU windows, just on MSVC. - #[cfg(all(target_env = "msvc", not(target_thread_local)))] - { - extern "C" { - static _tls_used: u8; - } - crate::intrinsics::volatile_load(&_tls_used); - } -} - -#[cfg(not(target_thread_local))] -unsafe fn run_dtors() { - for _ in 0..5 { - let mut any_run = false; - - // Use acquire ordering to observe key initialization. - let mut cur = DTORS.load(Acquire); - while !cur.is_null() { - let pre_key = (*cur).key.load(Acquire); - let dtor = (*cur).dtor.unwrap(); - cur = (*cur).next.load(Relaxed); - - // In StaticKey::init, we register the dtor before setting `key`. - // So if one thread's `run_dtors` races with another thread executing `init` on the same - // `StaticKey`, we can encounter a key of 0 here. That means this key was never - // initialized in this thread so we can safely skip it. - if pre_key == 0 { - continue; - } - // If this is non-zero, then via the `Acquire` load above we synchronized with - // everything relevant for this key. (It's not clear that this is needed, since the - // release-acquire pair on DTORS also establishes synchronization, but better safe than - // sorry.) - let key = pre_key - 1; - - let ptr = c::TlsGetValue(key); - if !ptr.is_null() { - c::TlsSetValue(key, ptr::null_mut()); - dtor(ptr as *mut _); - any_run = true; - } - } - - if !any_run { - break; - } - } -} diff --git a/library/std/src/sys/pal/xous/mod.rs b/library/std/src/sys/pal/xous/mod.rs index 68189bcc2e3..a28a52e305e 100644 --- a/library/std/src/sys/pal/xous/mod.rs +++ b/library/std/src/sys/pal/xous/mod.rs @@ -17,7 +17,6 @@ pub mod pipe; pub mod process; pub mod stdio; pub mod thread; -pub mod thread_local_key; pub mod time; #[path = "../unsupported/common.rs"] diff --git a/library/std/src/sys/pal/xous/thread.rs b/library/std/src/sys/pal/xous/thread.rs index da7d722cc70..279f24f9ee8 100644 --- a/library/std/src/sys/pal/xous/thread.rs +++ b/library/std/src/sys/pal/xous/thread.rs @@ -81,7 +81,7 @@ impl Thread { // Destroy TLS, which will free the TLS page and call the destructor for // any thread local storage (if any). unsafe { - crate::sys::thread_local_key::destroy_tls(); + crate::sys::thread_local::key::destroy_tls(); } // Deallocate the stack memory, along with the guard pages. Afterwards, diff --git a/library/std/src/sys/pal/zkvm/mod.rs b/library/std/src/sys/pal/zkvm/mod.rs index 0b22eabca6d..bacde9d880c 100644 --- a/library/std/src/sys/pal/zkvm/mod.rs +++ b/library/std/src/sys/pal/zkvm/mod.rs @@ -25,7 +25,6 @@ pub mod pipe; #[path = "../unsupported/process.rs"] pub mod process; pub mod stdio; -pub mod thread_local_key; #[path = "../unsupported/time.rs"] pub mod time; diff --git a/library/std/src/sys/pal/zkvm/thread_local_key.rs b/library/std/src/sys/pal/zkvm/thread_local_key.rs deleted file mode 100644 index 2f67924c618..00000000000 --- a/library/std/src/sys/pal/zkvm/thread_local_key.rs +++ /dev/null @@ -1,23 +0,0 @@ -use crate::alloc::{alloc, Layout}; - -pub type Key = usize; - -#[inline] -pub unsafe fn create(_dtor: Option<unsafe extern "C" fn(*mut u8)>) -> Key { - alloc(Layout::new::<*mut u8>()) as _ -} - -#[inline] -pub unsafe fn set(key: Key, value: *mut u8) { - let key: *mut *mut u8 = core::ptr::with_exposed_provenance_mut(key); - *key = value; -} - -#[inline] -pub unsafe fn get(key: Key) -> *mut u8 { - let key: *mut *mut u8 = core::ptr::with_exposed_provenance_mut(key); - *key -} - -#[inline] -pub unsafe fn destroy(_key: Key) {} diff --git a/library/std/src/sys/thread_local/destructors/linux_like.rs b/library/std/src/sys/thread_local/destructors/linux_like.rs new file mode 100644 index 00000000000..c381be0bf8c --- /dev/null +++ b/library/std/src/sys/thread_local/destructors/linux_like.rs @@ -0,0 +1,58 @@ +//! Destructor registration for Linux-like systems. +//! +//! Since what appears to be version 2.18, glibc has shipped the +//! `__cxa_thread_atexit_impl` symbol which GCC and clang both use to invoke +//! destructors in C++ thread_local globals. This function does exactly what +//! we want: it schedules a callback which will be run at thread exit with the +//! provided argument. +//! +//! Unfortunately, our minimum supported glibc version (at the time of writing) +//! is 2.17, so we can only link this symbol weakly and need to use the +//! [`list`](super::list) destructor implementation as fallback. + +use crate::mem::transmute; + +// FIXME: The Rust compiler currently omits weakly function definitions (i.e., +// __cxa_thread_atexit_impl) and its metadata from LLVM IR. +#[no_sanitize(cfi, kcfi)] +pub unsafe fn register(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { + /// This is necessary because the __cxa_thread_atexit_impl implementation + /// std links to by default may be a C or C++ implementation that was not + /// compiled using the Clang integer normalization option. + #[cfg(sanitizer_cfi_normalize_integers)] + use core::ffi::c_int; + #[cfg(not(sanitizer_cfi_normalize_integers))] + #[cfi_encoding = "i"] + #[repr(transparent)] + #[allow(non_camel_case_types)] + pub struct c_int(#[allow(dead_code)] pub core::ffi::c_int); + + extern "C" { + #[linkage = "extern_weak"] + static __dso_handle: *mut u8; + #[linkage = "extern_weak"] + static __cxa_thread_atexit_impl: Option< + extern "C" fn( + unsafe extern "C" fn(*mut libc::c_void), + *mut libc::c_void, + *mut libc::c_void, + ) -> c_int, + >; + } + + if let Some(f) = unsafe { __cxa_thread_atexit_impl } { + unsafe { + f( + transmute::<unsafe extern "C" fn(*mut u8), unsafe extern "C" fn(*mut libc::c_void)>( + dtor, + ), + t.cast(), + core::ptr::addr_of!(__dso_handle) as *mut _, + ); + } + } else { + unsafe { + super::list::register(t, dtor); + } + } +} diff --git a/library/std/src/sys/thread_local/destructors/list.rs b/library/std/src/sys/thread_local/destructors/list.rs new file mode 100644 index 00000000000..b9d5214c438 --- /dev/null +++ b/library/std/src/sys/thread_local/destructors/list.rs @@ -0,0 +1,44 @@ +use crate::cell::RefCell; +use crate::sys::thread_local::guard; + +#[thread_local] +static DTORS: RefCell<Vec<(*mut u8, unsafe extern "C" fn(*mut u8))>> = RefCell::new(Vec::new()); + +pub unsafe fn register(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { + let Ok(mut dtors) = DTORS.try_borrow_mut() else { + // This point can only be reached if the global allocator calls this + // function again. + // FIXME: maybe use the system allocator instead? + rtabort!("the global allocator may not use TLS with destructors"); + }; + + guard::enable(); + + dtors.push((t, dtor)); +} + +/// The [`guard`] module contains platform-specific functions which will run this +/// function on thread exit if [`guard::enable`] has been called. +/// +/// # Safety +/// +/// May only be run on thread exit to guarantee that there are no live references +/// to TLS variables while they are destroyed. +pub unsafe fn run() { + loop { + let mut dtors = DTORS.borrow_mut(); + match dtors.pop() { + Some((t, dtor)) => { + drop(dtors); + unsafe { + dtor(t); + } + } + None => { + // Free the list memory. + *dtors = Vec::new(); + break; + } + } + } +} diff --git a/library/std/src/sys/thread_local/guard/apple.rs b/library/std/src/sys/thread_local/guard/apple.rs new file mode 100644 index 00000000000..6c27f7ae35c --- /dev/null +++ b/library/std/src/sys/thread_local/guard/apple.rs @@ -0,0 +1,31 @@ +//! macOS allows registering destructors through _tlv_atexit. But since calling +//! it while TLS destructors are running is UB, we still need to keep our own +//! list of destructors. + +use crate::cell::Cell; +use crate::ptr; +use crate::sys::thread_local::destructors; + +pub fn enable() { + #[thread_local] + static REGISTERED: Cell<bool> = Cell::new(false); + + extern "C" { + fn _tlv_atexit(dtor: unsafe extern "C" fn(*mut u8), arg: *mut u8); + } + + if !REGISTERED.replace(true) { + // SAFETY: Calling _tlv_atexit while TLS destructors are running is UB. + // But as run_dtors is only called after being registered, this point + // cannot be reached from it. + unsafe { + _tlv_atexit(run_dtors, ptr::null_mut()); + } + } + + unsafe extern "C" fn run_dtors(_: *mut u8) { + unsafe { + destructors::run(); + } + } +} diff --git a/library/std/src/sys/thread_local/guard/key.rs b/library/std/src/sys/thread_local/guard/key.rs new file mode 100644 index 00000000000..ee9d55ddd5e --- /dev/null +++ b/library/std/src/sys/thread_local/guard/key.rs @@ -0,0 +1,23 @@ +//! A lot of UNIX platforms don't have a specialized way to register TLS +//! destructors for native TLS. Instead, we use one TLS key with a destructor +//! that will run all native TLS destructors in the destructor list. + +use crate::ptr; +use crate::sys::thread_local::destructors; +use crate::sys::thread_local::key::StaticKey; + +pub fn enable() { + static DTORS: StaticKey = StaticKey::new(Some(run)); + + // Setting the key value to something other than NULL will result in the + // destructor being run at thread exit. + unsafe { + DTORS.set(ptr::without_provenance_mut(1)); + } + + unsafe extern "C" fn run(_: *mut u8) { + unsafe { + destructors::run(); + } + } +} diff --git a/library/std/src/sys/thread_local/guard/solid.rs b/library/std/src/sys/thread_local/guard/solid.rs new file mode 100644 index 00000000000..b65d00c5b5f --- /dev/null +++ b/library/std/src/sys/thread_local/guard/solid.rs @@ -0,0 +1,23 @@ +//! SOLID, just like macOS, has an API to register TLS destructors. But since +//! it does not allow specifying an argument to that function, and will not run +//! destructors for terminated tasks, we still keep our own list. + +use crate::cell::Cell; +use crate::sys::pal::{abi, itron::task}; +use crate::sys::thread_local::destructors; + +pub fn enable() { + #[thread_local] + static REGISTERED: Cell<bool> = Cell::new(false); + + if !REGISTERED.replace(true) { + let tid = task::current_task_id_aborting(); + // Register `tls_dtor` to make sure the TLS destructors are called + // for tasks created by other means than `std::thread` + unsafe { abi::SOLID_TLS_AddDestructor(tid as i32, tls_dtor) }; + } + + unsafe extern "C" fn tls_dtor(_unused: *mut u8) { + unsafe { destructors::run() }; + } +} diff --git a/library/std/src/sys/thread_local/guard/windows.rs b/library/std/src/sys/thread_local/guard/windows.rs new file mode 100644 index 00000000000..81797f55170 --- /dev/null +++ b/library/std/src/sys/thread_local/guard/windows.rs @@ -0,0 +1,103 @@ +//! Support for Windows TLS destructors. +//! +//! Unfortunately, Windows does not provide a nice API to provide a destructor +//! for a TLS variable. Thus, the solution here ended up being a little more +//! obscure, but fear not, the internet has informed me [1][2] that this solution +//! is not unique (no way I could have thought of it as well!). The key idea is +//! to insert some hook somewhere to run arbitrary code on thread termination. +//! With this in place we'll be able to run anything we like, including all +//! TLS destructors! +//! +//! In order to realize this, all TLS destructors are tracked by *us*, not the +//! Windows runtime. This means that we have a global list of destructors for +//! each TLS key or variable that we know about. +//! +//! # What's up with CRT$XLB? +//! +//! For anything about TLS destructors to work on Windows, we have to be able +//! to run *something* when a thread exits. To do so, we place a very special +//! static in a very special location. If this is encoded in just the right +//! way, the kernel's loader is apparently nice enough to run some function +//! of ours whenever a thread exits! How nice of the kernel! +//! +//! Lots of detailed information can be found in source [1] above, but the +//! gist of it is that this is leveraging a feature of Microsoft's PE format +//! (executable format) which is not actually used by any compilers today. +//! This apparently translates to any callbacks in the ".CRT$XLB" section +//! being run on certain events. +//! +//! So after all that, we use the compiler's #[link_section] feature to place +//! a callback pointer into the magic section so it ends up being called. +//! +//! # What's up with this callback? +//! +//! The callback specified receives a number of parameters from... someone! +//! (the kernel? the runtime? I'm not quite sure!) There are a few events that +//! this gets invoked for, but we're currently only interested on when a +//! thread or a process "detaches" (exits). The process part happens for the +//! last thread and the thread part happens for any normal thread. +//! +//! # The article mentions weird stuff about "/INCLUDE"? +//! +//! It sure does! Specifically we're talking about this quote: +//! +//! ```quote +//! The Microsoft run-time library facilitates this process by defining a +//! memory image of the TLS Directory and giving it the special name +//! “__tls_used” (Intel x86 platforms) or “_tls_used” (other platforms). The +//! linker looks for this memory image and uses the data there to create the +//! TLS Directory. Other compilers that support TLS and work with the +//! Microsoft linker must use this same technique. +//! ``` +//! +//! Basically what this means is that if we want support for our TLS +//! destructors/our hook being called then we need to make sure the linker does +//! not omit this symbol. Otherwise it will omit it and our callback won't be +//! wired up. +//! +//! We don't actually use the `/INCLUDE` linker flag here like the article +//! mentions because the Rust compiler doesn't propagate linker flags, but +//! instead we use a shim function which performs a volatile 1-byte load from +//! the address of the symbol to ensure it sticks around. +//! +//! [1]: https://www.codeproject.com/Articles/8113/Thread-Local-Storage-The-C-Way +//! [2]: https://github.com/ChromiumWebApps/chromium/blob/master/base/threading/thread_local_storage_win.cc#L42 + +use crate::ptr; +use crate::sys::c; + +pub fn enable() { + // When destructors are used, we don't want LLVM eliminating CALLBACK for any + // reason. Once the symbol makes it to the linker, it will do the rest. + unsafe { ptr::from_ref(&CALLBACK).read_volatile() }; +} + +#[link_section = ".CRT$XLB"] +#[cfg_attr(miri, used)] // Miri only considers explicitly `#[used]` statics for `lookup_link_section` +pub static CALLBACK: unsafe extern "system" fn(c::LPVOID, c::DWORD, c::LPVOID) = tls_callback; + +unsafe extern "system" fn tls_callback(_h: c::LPVOID, dw_reason: c::DWORD, _pv: c::LPVOID) { + // See comments above for what this is doing. Note that we don't need this + // trickery on GNU windows, just on MSVC. + #[cfg(all(target_env = "msvc", not(target_thread_local)))] + { + extern "C" { + static _tls_used: u8; + } + + unsafe { + ptr::from_ref(&_tls_used).read_volatile(); + } + } + + if dw_reason == c::DLL_THREAD_DETACH || dw_reason == c::DLL_PROCESS_DETACH { + #[cfg(target_thread_local)] + unsafe { + super::super::destructors::run(); + } + #[cfg(not(target_thread_local))] + unsafe { + super::super::key::run_dtors(); + } + } +} diff --git a/library/std/src/sys_common/thread_local_key.rs b/library/std/src/sys/thread_local/key/racy.rs index a9cd26389cd..eda8b83bc7f 100644 --- a/library/std/src/sys_common/thread_local_key.rs +++ b/library/std/src/sys/thread_local/key/racy.rs @@ -1,61 +1,12 @@ -//! OS-based thread local storage for non-Windows systems +//! A `StaticKey` implementation using racy initialization. //! -//! This module provides an implementation of OS-based thread local storage, -//! using the native OS-provided facilities (think `TlsAlloc` or -//! `pthread_setspecific`). The interface of this differs from the other types -//! of thread-local-storage provided in this crate in that OS-based TLS can only -//! get/set pointer-sized data, possibly with an associated destructor. -//! -//! This module also provides two flavors of TLS. One is intended for static -//! initialization, and does not contain a `Drop` implementation to deallocate -//! the OS-TLS key. The other is a type which does implement `Drop` and hence -//! has a safe interface. -//! -//! Windows doesn't use this module at all; `sys::pal::windows::thread_local_key` -//! gets imported in its stead. -//! -//! # Usage -//! -//! This module should likely not be used directly unless other primitives are -//! being built on. Types such as `thread_local::spawn::Key` are likely much -//! more useful in practice than this OS-based version which likely requires -//! unsafe code to interoperate with. -//! -//! # Examples -//! -//! Using a dynamically allocated TLS key. Note that this key can be shared -//! among many threads via an `Arc`. -//! -//! ```ignore (cannot-doctest-private-modules) -//! let key = Key::new(None); -//! assert!(key.get().is_null()); -//! key.set(1 as *mut u8); -//! assert!(!key.get().is_null()); -//! -//! drop(key); // deallocate this TLS slot. -//! ``` -//! -//! Sometimes a statically allocated key is either required or easier to work -//! with, however. -//! -//! ```ignore (cannot-doctest-private-modules) -//! static KEY: StaticKey = INIT; -//! -//! unsafe { -//! assert!(KEY.get().is_null()); -//! KEY.set(1 as *mut u8); -//! } -//! ``` - -#![allow(non_camel_case_types)] -#![unstable(feature = "thread_local_internals", issue = "none")] -#![allow(dead_code)] - -#[cfg(test)] -mod tests; +//! Unfortunately, none of the platforms currently supported by `std` allows +//! creating TLS keys at compile-time. Thus we need a way to lazily create keys. +//! Instead of blocking API like `OnceLock`, we use racy initialization, which +//! should be more lightweight and avoids circular dependencies with the rest of +//! `std`. use crate::sync::atomic::{self, AtomicUsize, Ordering}; -use crate::sys::thread_local_key as imp; /// A type for TLS keys that are statically allocated. /// @@ -90,11 +41,6 @@ pub struct StaticKey { dtor: Option<unsafe extern "C" fn(*mut u8)>, } -/// Constant initialization value for static TLS keys. -/// -/// This value specifies no destructor by default. -pub const INIT: StaticKey = StaticKey::new(None); - // Define a sentinel value that is likely not to be returned // as a TLS key. #[cfg(not(target_os = "nto"))] @@ -117,7 +63,7 @@ impl StaticKey { /// been allocated. #[inline] pub unsafe fn get(&self) -> *mut u8 { - imp::get(self.key()) + unsafe { super::get(self.key()) } } /// Sets this TLS key to a new value. @@ -126,18 +72,18 @@ impl StaticKey { /// been allocated. #[inline] pub unsafe fn set(&self, val: *mut u8) { - imp::set(self.key(), val) + unsafe { super::set(self.key(), val) } } #[inline] - unsafe fn key(&self) -> imp::Key { + fn key(&self) -> super::Key { match self.key.load(Ordering::Acquire) { - KEY_SENTVAL => self.lazy_init() as imp::Key, - n => n as imp::Key, + KEY_SENTVAL => self.lazy_init() as super::Key, + n => n as super::Key, } } - unsafe fn lazy_init(&self) -> usize { + fn lazy_init(&self) -> usize { // POSIX allows the key created here to be KEY_SENTVAL, but the compare_exchange // below relies on using KEY_SENTVAL as a sentinel value to check who won the // race to set the shared TLS key. As far as I know, there is no @@ -147,12 +93,14 @@ impl StaticKey { // value of KEY_SENTVAL, but with some gyrations to make sure we have a non-KEY_SENTVAL // value returned from the creation routine. // FIXME: this is clearly a hack, and should be cleaned up. - let key1 = imp::create(self.dtor); + let key1 = super::create(self.dtor); let key = if key1 as usize != KEY_SENTVAL { key1 } else { - let key2 = imp::create(self.dtor); - imp::destroy(key1); + let key2 = super::create(self.dtor); + unsafe { + super::destroy(key1); + } key2 }; rtassert!(key as usize != KEY_SENTVAL); @@ -165,10 +113,10 @@ impl StaticKey { // The CAS succeeded, so we've created the actual key Ok(_) => key as usize, // If someone beat us to the punch, use their key instead - Err(n) => { - imp::destroy(key); + Err(n) => unsafe { + super::destroy(key); n - } + }, } } } diff --git a/library/std/src/sys/pal/sgx/thread_local_key.rs b/library/std/src/sys/thread_local/key/sgx.rs index c7a57d3a3d4..4aa2e5afa72 100644 --- a/library/std/src/sys/pal/sgx/thread_local_key.rs +++ b/library/std/src/sys/thread_local/key/sgx.rs @@ -1,9 +1,9 @@ -use super::abi::tls::{Key as AbiKey, Tls}; +use crate::sys::pal::abi::tls::{Key as AbiKey, Tls}; pub type Key = usize; #[inline] -pub unsafe fn create(dtor: Option<unsafe extern "C" fn(*mut u8)>) -> Key { +pub fn create(dtor: Option<unsafe extern "C" fn(*mut u8)>) -> Key { Tls::create(dtor).as_usize() } diff --git a/library/std/src/sys/pal/windows/thread_local_key/tests.rs b/library/std/src/sys/thread_local/key/tests.rs index 4119f990968..24cad396da2 100644 --- a/library/std/src/sys/pal/windows/thread_local_key/tests.rs +++ b/library/std/src/sys/thread_local/key/tests.rs @@ -1,7 +1,3 @@ -// This file only tests the thread local key fallback. -// Windows targets with native thread local support do not use this. -#![cfg(not(target_thread_local))] - use super::StaticKey; use crate::ptr; @@ -27,7 +23,7 @@ fn destructors() { use crate::thread; unsafe extern "C" fn destruct(ptr: *mut u8) { - drop(Arc::from_raw(ptr as *const ())); + drop(unsafe { Arc::from_raw(ptr as *const ()) }); } static KEY: StaticKey = StaticKey::new(Some(destruct)); diff --git a/library/std/src/sys/thread_local/key/unix.rs b/library/std/src/sys/thread_local/key/unix.rs new file mode 100644 index 00000000000..13522d44b35 --- /dev/null +++ b/library/std/src/sys/thread_local/key/unix.rs @@ -0,0 +1,27 @@ +use crate::mem; + +pub type Key = libc::pthread_key_t; + +#[inline] +pub fn create(dtor: Option<unsafe extern "C" fn(*mut u8)>) -> Key { + let mut key = 0; + assert_eq!(unsafe { libc::pthread_key_create(&mut key, mem::transmute(dtor)) }, 0); + key +} + +#[inline] +pub unsafe fn set(key: Key, value: *mut u8) { + let r = unsafe { libc::pthread_setspecific(key, value as *mut _) }; + debug_assert_eq!(r, 0); +} + +#[inline] +pub unsafe fn get(key: Key) -> *mut u8 { + unsafe { libc::pthread_getspecific(key) as *mut u8 } +} + +#[inline] +pub unsafe fn destroy(key: Key) { + let r = unsafe { libc::pthread_key_delete(key) }; + debug_assert_eq!(r, 0); +} diff --git a/library/std/src/sys/thread_local/key/windows.rs b/library/std/src/sys/thread_local/key/windows.rs new file mode 100644 index 00000000000..ad0e72c29ed --- /dev/null +++ b/library/std/src/sys/thread_local/key/windows.rs @@ -0,0 +1,206 @@ +//! Implementation of `StaticKey` for Windows. +//! +//! Windows has no native support for running destructors so we manage our own +//! list of destructors to keep track of how to destroy keys. We then install a +//! callback later to get invoked whenever a thread exits, running all +//! appropriate destructors (see the [`guard`](guard) module documentation). +//! +//! This will likely need to be improved over time, but this module attempts a +//! "poor man's" destructor callback system. Once we've got a list of what to +//! run, we iterate over all keys, check their values, and then run destructors +//! if the values turn out to be non null (setting them to null just beforehand). +//! We do this a few times in a loop to basically match Unix semantics. If we +//! don't reach a fixed point after a short while then we just inevitably leak +//! something. +//! +//! The list is implemented as an atomic single-linked list of `StaticKey`s and +//! does not support unregistration. Unfortunately, this means that we cannot +//! use racy initialization for creating the keys in `StaticKey`, as that could +//! result in destructors being missed. Hence, we synchronize the creation of +//! keys with destructors through [`INIT_ONCE`](c::INIT_ONCE) (`std`'s +//! [`Once`](crate::sync::Once) cannot be used since it might use TLS itself). +//! For keys without destructors, racy initialization suffices. + +// FIXME: investigate using a fixed-size array instead, as the maximum number +// of keys is [limited to 1088](https://learn.microsoft.com/en-us/windows/win32/ProcThread/thread-local-storage). + +use crate::cell::UnsafeCell; +use crate::ptr; +use crate::sync::atomic::{ + AtomicPtr, AtomicU32, + Ordering::{AcqRel, Acquire, Relaxed, Release}, +}; +use crate::sys::c; +use crate::sys::thread_local::guard; + +type Key = c::DWORD; +type Dtor = unsafe extern "C" fn(*mut u8); + +pub struct StaticKey { + /// The key value shifted up by one. Since TLS_OUT_OF_INDEXES == DWORD::MAX + /// is not a valid key value, this allows us to use zero as sentinel value + /// without risking overflow. + key: AtomicU32, + dtor: Option<Dtor>, + next: AtomicPtr<StaticKey>, + /// Currently, destructors cannot be unregistered, so we cannot use racy + /// initialization for keys. Instead, we need synchronize initialization. + /// Use the Windows-provided `Once` since it does not require TLS. + once: UnsafeCell<c::INIT_ONCE>, +} + +impl StaticKey { + #[inline] + pub const fn new(dtor: Option<Dtor>) -> StaticKey { + StaticKey { + key: AtomicU32::new(0), + dtor, + next: AtomicPtr::new(ptr::null_mut()), + once: UnsafeCell::new(c::INIT_ONCE_STATIC_INIT), + } + } + + #[inline] + pub unsafe fn set(&'static self, val: *mut u8) { + let r = unsafe { c::TlsSetValue(self.key(), val.cast()) }; + debug_assert_eq!(r, c::TRUE); + } + + #[inline] + pub unsafe fn get(&'static self) -> *mut u8 { + unsafe { c::TlsGetValue(self.key()).cast() } + } + + #[inline] + fn key(&'static self) -> Key { + match self.key.load(Acquire) { + 0 => unsafe { self.init() }, + key => key - 1, + } + } + + #[cold] + unsafe fn init(&'static self) -> Key { + if self.dtor.is_some() { + let mut pending = c::FALSE; + let r = unsafe { + c::InitOnceBeginInitialize(self.once.get(), 0, &mut pending, ptr::null_mut()) + }; + assert_eq!(r, c::TRUE); + + if pending == c::FALSE { + // Some other thread initialized the key, load it. + self.key.load(Relaxed) - 1 + } else { + let key = unsafe { c::TlsAlloc() }; + if key == c::TLS_OUT_OF_INDEXES { + // Wakeup the waiting threads before panicking to avoid deadlock. + unsafe { + c::InitOnceComplete( + self.once.get(), + c::INIT_ONCE_INIT_FAILED, + ptr::null_mut(), + ); + } + panic!("out of TLS indexes"); + } + + unsafe { + register_dtor(self); + } + + // Release-storing the key needs to be the last thing we do. + // This is because in `fn key()`, other threads will do an acquire load of the key, + // and if that sees this write then it will entirely bypass the `InitOnce`. We thus + // need to establish synchronization through `key`. In particular that acquire load + // must happen-after the register_dtor above, to ensure the dtor actually runs! + self.key.store(key + 1, Release); + + let r = unsafe { c::InitOnceComplete(self.once.get(), 0, ptr::null_mut()) }; + debug_assert_eq!(r, c::TRUE); + + key + } + } else { + // If there is no destructor to clean up, we can use racy initialization. + + let key = unsafe { c::TlsAlloc() }; + assert_ne!(key, c::TLS_OUT_OF_INDEXES, "out of TLS indexes"); + + match self.key.compare_exchange(0, key + 1, AcqRel, Acquire) { + Ok(_) => key, + Err(new) => unsafe { + // Some other thread completed initialization first, so destroy + // our key and use theirs. + let r = c::TlsFree(key); + debug_assert_eq!(r, c::TRUE); + new - 1 + }, + } + } + } +} + +unsafe impl Send for StaticKey {} +unsafe impl Sync for StaticKey {} + +static DTORS: AtomicPtr<StaticKey> = AtomicPtr::new(ptr::null_mut()); + +/// Should only be called once per key, otherwise loops or breaks may occur in +/// the linked list. +unsafe fn register_dtor(key: &'static StaticKey) { + guard::enable(); + + let this = <*const StaticKey>::cast_mut(key); + // Use acquire ordering to pass along the changes done by the previously + // registered keys when we store the new head with release ordering. + let mut head = DTORS.load(Acquire); + loop { + key.next.store(head, Relaxed); + match DTORS.compare_exchange_weak(head, this, Release, Acquire) { + Ok(_) => break, + Err(new) => head = new, + } + } +} + +/// This will and must only be run by the destructor callback in [`guard`]. +pub unsafe fn run_dtors() { + for _ in 0..5 { + let mut any_run = false; + + // Use acquire ordering to observe key initialization. + let mut cur = DTORS.load(Acquire); + while !cur.is_null() { + let pre_key = unsafe { (*cur).key.load(Acquire) }; + let dtor = unsafe { (*cur).dtor.unwrap() }; + cur = unsafe { (*cur).next.load(Relaxed) }; + + // In StaticKey::init, we register the dtor before setting `key`. + // So if one thread's `run_dtors` races with another thread executing `init` on the same + // `StaticKey`, we can encounter a key of 0 here. That means this key was never + // initialized in this thread so we can safely skip it. + if pre_key == 0 { + continue; + } + // If this is non-zero, then via the `Acquire` load above we synchronized with + // everything relevant for this key. (It's not clear that this is needed, since the + // release-acquire pair on DTORS also establishes synchronization, but better safe than + // sorry.) + let key = pre_key - 1; + + let ptr = unsafe { c::TlsGetValue(key) }; + if !ptr.is_null() { + unsafe { + c::TlsSetValue(key, ptr::null_mut()); + dtor(ptr as *mut _); + any_run = true; + } + } + } + + if !any_run { + break; + } + } +} diff --git a/library/std/src/sys/pal/xous/thread_local_key.rs b/library/std/src/sys/thread_local/key/xous.rs index 6c29813c79d..a23f6de95f7 100644 --- a/library/std/src/sys/pal/xous/thread_local_key.rs +++ b/library/std/src/sys/thread_local/key/xous.rs @@ -1,3 +1,41 @@ +//! Thread Local Storage +//! +//! Currently, we are limited to 1023 TLS entries. The entries +//! live in a page of memory that's unique per-process, and is +//! stored in the `$tp` register. If this register is 0, then +//! TLS has not been initialized and thread cleanup can be skipped. +//! +//! The index into this register is the `key`. This key is identical +//! between all threads, but indexes a different offset within this +//! pointer. +//! +//! # Dtor registration (stolen from Windows) +//! +//! Xous has no native support for running destructors so we manage our own +//! list of destructors to keep track of how to destroy keys. When a thread +//! or the process exits, `run_dtors` is called, which will iterate through +//! the list and run the destructors. +//! +//! Currently unregistration from this list is not supported. A destructor can be +//! registered but cannot be unregistered. There's various simplifying reasons +//! for doing this, the big ones being: +//! +//! 1. Currently we don't even support deallocating TLS keys, so normal operation +//! doesn't need to deallocate a destructor. +//! 2. There is no point in time where we know we can unregister a destructor +//! because it could always be getting run by some remote thread. +//! +//! Typically processes have a statically known set of TLS keys which is pretty +//! small, and we'd want to keep this memory alive for the whole process anyway +//! really. +//! +//! Perhaps one day we can fold the `Box` here into a static allocation, +//! expanding the `StaticKey` structure to contain not only a slot for the TLS +//! key but also a slot for the destructor queue on windows. An optimization for +//! another day! + +// FIXME(joboet): implement support for native TLS instead. + use crate::mem::ManuallyDrop; use crate::ptr; use crate::sync::atomic::AtomicPtr; @@ -7,18 +45,7 @@ use core::arch::asm; use crate::os::xous::ffi::{map_memory, unmap_memory, MemoryFlags}; -/// Thread Local Storage -/// -/// Currently, we are limited to 1023 TLS entries. The entries -/// live in a page of memory that's unique per-process, and is -/// stored in the `$tp` register. If this register is 0, then -/// TLS has not been initialized and thread cleanup can be skipped. -/// -/// The index into this register is the `key`. This key is identical -/// between all threads, but indexes a different offset within this -/// pointer. pub type Key = usize; - pub type Dtor = unsafe extern "C" fn(*mut u8); const TLS_MEMORY_SIZE: usize = 4096; @@ -89,7 +116,7 @@ fn tls_table() -> &'static mut [*mut u8] { } #[inline] -pub unsafe fn create(dtor: Option<Dtor>) -> Key { +pub fn create(dtor: Option<Dtor>) -> Key { // Allocate a new TLS key. These keys are shared among all threads. #[allow(unused_unsafe)] let key = unsafe { TLS_KEY_INDEX.fetch_add(1, Relaxed) }; @@ -118,32 +145,6 @@ pub unsafe fn destroy(_key: Key) { // lots of TLS variables, but in practice that's not an issue. } -// ------------------------------------------------------------------------- -// Dtor registration (stolen from Windows) -// -// Xous has no native support for running destructors so we manage our own -// list of destructors to keep track of how to destroy keys. We then install a -// callback later to get invoked whenever a thread exits, running all -// appropriate destructors. -// -// Currently unregistration from this list is not supported. A destructor can be -// registered but cannot be unregistered. There's various simplifying reasons -// for doing this, the big ones being: -// -// 1. Currently we don't even support deallocating TLS keys, so normal operation -// doesn't need to deallocate a destructor. -// 2. There is no point in time where we know we can unregister a destructor -// because it could always be getting run by some remote thread. -// -// Typically processes have a statically known set of TLS keys which is pretty -// small, and we'd want to keep this memory alive for the whole process anyway -// really. -// -// Perhaps one day we can fold the `Box` here into a static allocation, -// expanding the `StaticKey` structure to contain not only a slot for the TLS -// key but also a slot for the destructor queue on windows. An optimization for -// another day! - struct Node { dtor: Dtor, key: Key, diff --git a/library/std/src/sys/thread_local/mod.rs b/library/std/src/sys/thread_local/mod.rs index 0a78a1a1cf0..f74fd828cbe 100644 --- a/library/std/src/sys/thread_local/mod.rs +++ b/library/std/src/sys/thread_local/mod.rs @@ -1,27 +1,154 @@ -#![unstable(feature = "thread_local_internals", reason = "should not be necessary", issue = "none")] -#![cfg_attr(test, allow(unused))] +//! Implementation of the `thread_local` macro. +//! +//! There are three different thread-local implementations: +//! * Some targets lack threading support, and hence have only one thread, so +//! the TLS data is stored in a normal `static`. +//! * Some targets support TLS natively via the dynamic linker and C runtime. +//! * On some targets, the OS provides a library-based TLS implementation. The +//! TLS data is heap-allocated and referenced using a TLS key. +//! +//! Each implementation provides a macro which generates the `LocalKey` `const` +//! used to reference the TLS variable, along with the necessary helper structs +//! to track the initialization/destruction state of the variable. +//! +//! Additionally, this module contains abstractions for the OS interfaces used +//! for these implementations. -// There are three thread-local implementations: "static", "fast", "OS". -// The "OS" thread local key type is accessed via platform-specific API calls and is slow, while the -// "fast" key type is accessed via code generated via LLVM, where TLS keys are set up by the linker. -// "static" is for single-threaded platforms where a global static is sufficient. +#![cfg_attr(test, allow(unused))] +#![doc(hidden)] +#![forbid(unsafe_op_in_unsafe_fn)] +#![unstable( + feature = "thread_local_internals", + reason = "internal details of the thread_local macro", + issue = "none" +)] cfg_if::cfg_if! { - if #[cfg(any(all(target_family = "wasm", not(target_feature = "atomics")), target_os = "uefi"))] { - #[doc(hidden)] - mod static_local; - #[doc(hidden)] - pub use static_local::{EagerStorage, LazyStorage, thread_local_inner}; + if #[cfg(any( + all(target_family = "wasm", not(target_feature = "atomics")), + target_os = "uefi", + target_os = "zkvm", + ))] { + mod statik; + pub use statik::{EagerStorage, LazyStorage, thread_local_inner}; } else if #[cfg(target_thread_local)] { - #[doc(hidden)] - mod fast_local; - #[doc(hidden)] - pub use fast_local::{EagerStorage, LazyStorage, thread_local_inner}; + mod native; + pub use native::{EagerStorage, LazyStorage, thread_local_inner}; } else { - #[doc(hidden)] - mod os_local; - #[doc(hidden)] - pub use os_local::{Key, thread_local_inner}; + mod os; + pub use os::{Key, thread_local_inner}; + } +} + +/// The native TLS implementation needs a way to register destructors for its data. +/// This module contains platform-specific implementations of that register. +/// +/// It turns out however that most platforms don't have a way to register a +/// destructor for each variable. On these platforms, we keep track of the +/// destructors ourselves and register (through the [`guard`] module) only a +/// single callback that runs all of the destructors in the list. +#[cfg(all(target_thread_local, not(all(target_family = "wasm", not(target_feature = "atomics")))))] +pub(crate) mod destructors { + cfg_if::cfg_if! { + if #[cfg(any( + target_os = "linux", + target_os = "android", + target_os = "fuchsia", + target_os = "redox", + target_os = "hurd", + target_os = "netbsd", + target_os = "dragonfly" + ))] { + mod linux_like; + mod list; + pub(super) use linux_like::register; + pub(super) use list::run; + } else { + mod list; + pub(super) use list::register; + pub(crate) use list::run; + } + } +} + +/// This module provides a way to schedule the execution of the destructor list +/// on systems without a per-variable destructor system. +mod guard { + cfg_if::cfg_if! { + if #[cfg(all(target_thread_local, target_vendor = "apple"))] { + mod apple; + pub(super) use apple::enable; + } else if #[cfg(target_os = "windows")] { + mod windows; + pub(super) use windows::enable; + } else if #[cfg(any( + all(target_family = "wasm", target_feature = "atomics"), + ))] { + pub(super) fn enable() { + // FIXME: Right now there is no concept of "thread exit", but + // this is likely going to show up at some point in the form of + // an exported symbol that the wasm runtime is going to be + // expected to call. For now we just leak everything, but if + // such a function starts to exist it will probably need to + // iterate the destructor list with this function: + #[allow(unused)] + use super::destructors::run; + } + } else if #[cfg(target_os = "hermit")] { + pub(super) fn enable() {} + } else if #[cfg(target_os = "solid_asp3")] { + mod solid; + pub(super) use solid::enable; + } else if #[cfg(all(target_thread_local, not(target_family = "wasm")))] { + mod key; + pub(super) use key::enable; + } + } +} + +/// `const`-creatable TLS keys. +/// +/// Most OSs without native TLS will provide a library-based way to create TLS +/// storage. For each TLS variable, we create a key, which can then be used to +/// reference an entry in a thread-local table. This then associates each key +/// with a pointer which we can get and set to store our data. +pub(crate) mod key { + cfg_if::cfg_if! { + if #[cfg(any( + all( + not(target_vendor = "apple"), + not(target_family = "wasm"), + target_family = "unix", + ), + target_os = "teeos", + ))] { + mod racy; + mod unix; + #[cfg(test)] + mod tests; + pub(super) use racy::StaticKey; + use unix::{Key, create, destroy, get, set}; + } else if #[cfg(all(not(target_thread_local), target_os = "windows"))] { + #[cfg(test)] + mod tests; + mod windows; + pub(super) use windows::{StaticKey, run_dtors}; + } else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] { + mod racy; + mod sgx; + #[cfg(test)] + mod tests; + pub(super) use racy::StaticKey; + use sgx::{Key, create, destroy, get, set}; + } else if #[cfg(target_os = "xous")] { + mod racy; + #[cfg(test)] + mod tests; + mod xous; + pub(super) use racy::StaticKey; + pub(crate) use xous::destroy_tls; + use xous::{Key, create, destroy, get, set}; + } } } diff --git a/library/std/src/sys/thread_local/fast_local/eager.rs b/library/std/src/sys/thread_local/native/eager.rs index b97bd9cc88c..99e5ae7fb96 100644 --- a/library/std/src/sys/thread_local/fast_local/eager.rs +++ b/library/std/src/sys/thread_local/native/eager.rs @@ -1,7 +1,7 @@ use crate::cell::{Cell, UnsafeCell}; use crate::ptr::{self, drop_in_place}; use crate::sys::thread_local::abort_on_dtor_unwind; -use crate::sys::thread_local_dtor::register_dtor; +use crate::sys::thread_local::destructors; #[derive(Clone, Copy)] enum State { @@ -45,7 +45,7 @@ impl<T> Storage<T> { // SAFETY: // The caller guarantees that `self` will be valid until thread destruction. unsafe { - register_dtor(ptr::from_ref(self).cast_mut().cast(), destroy::<T>); + destructors::register(ptr::from_ref(self).cast_mut().cast(), destroy::<T>); } self.state.set(State::Alive); diff --git a/library/std/src/sys/thread_local/fast_local/lazy.rs b/library/std/src/sys/thread_local/native/lazy.rs index c1ada35d484..9d47e8ef689 100644 --- a/library/std/src/sys/thread_local/fast_local/lazy.rs +++ b/library/std/src/sys/thread_local/native/lazy.rs @@ -2,7 +2,7 @@ use crate::cell::UnsafeCell; use crate::hint::unreachable_unchecked; use crate::ptr; use crate::sys::thread_local::abort_on_dtor_unwind; -use crate::sys::thread_local_dtor::register_dtor; +use crate::sys::thread_local::destructors; pub unsafe trait DestroyedState: Sized { fn register_dtor<T>(s: &Storage<T, Self>); @@ -15,7 +15,7 @@ unsafe impl DestroyedState for ! { unsafe impl DestroyedState for () { fn register_dtor<T>(s: &Storage<T, ()>) { unsafe { - register_dtor(ptr::from_ref(s).cast_mut().cast(), destroy::<T>); + destructors::register(ptr::from_ref(s).cast_mut().cast(), destroy::<T>); } } } diff --git a/library/std/src/sys/thread_local/fast_local/mod.rs b/library/std/src/sys/thread_local/native/mod.rs index 575d60de4ee..1cc45fe892d 100644 --- a/library/std/src/sys/thread_local/fast_local/mod.rs +++ b/library/std/src/sys/thread_local/native/mod.rs @@ -29,8 +29,6 @@ //! eliminates the `Destroyed` state for these values, which can allow more niche //! optimizations to occur for the `State` enum. For `Drop` types, `()` is used. -#![deny(unsafe_op_in_unsafe_fn)] - mod eager; mod lazy; diff --git a/library/std/src/sys/thread_local/os_local.rs b/library/std/src/sys/thread_local/os.rs index ee5adef66ea..6980c897fdb 100644 --- a/library/std/src/sys/thread_local/os_local.rs +++ b/library/std/src/sys/thread_local/os.rs @@ -2,7 +2,7 @@ use super::abort_on_dtor_unwind; use crate::cell::Cell; use crate::marker::PhantomData; use crate::ptr; -use crate::sys_common::thread_local_key::StaticKey as OsKey; +use crate::sys::thread_local::key::StaticKey as OsKey; #[doc(hidden)] #[allow_internal_unstable(thread_local_internals)] diff --git a/library/std/src/sys/thread_local/static_local.rs b/library/std/src/sys/thread_local/statik.rs index 0f08cab1ae4..0f08cab1ae4 100644 --- a/library/std/src/sys/thread_local/static_local.rs +++ b/library/std/src/sys/thread_local/statik.rs diff --git a/library/std/src/sys_common/mod.rs b/library/std/src/sys_common/mod.rs index 200ea028a08..60ee405ecaa 100644 --- a/library/std/src/sys_common/mod.rs +++ b/library/std/src/sys_common/mod.rs @@ -24,19 +24,10 @@ pub mod fs; pub mod io; pub mod lazy_box; pub mod process; -pub mod thread_local_dtor; pub mod wstr; pub mod wtf8; cfg_if::cfg_if! { - if #[cfg(target_os = "windows")] { - pub use crate::sys::thread_local_key; - } else { - pub mod thread_local_key; - } -} - -cfg_if::cfg_if! { if #[cfg(any( all(unix, not(target_os = "l4re")), windows, diff --git a/library/std/src/sys_common/thread_local_dtor.rs b/library/std/src/sys_common/thread_local_dtor.rs deleted file mode 100644 index 98382fc6acc..00000000000 --- a/library/std/src/sys_common/thread_local_dtor.rs +++ /dev/null @@ -1,56 +0,0 @@ -//! Thread-local destructor -//! -//! Besides thread-local "keys" (pointer-sized non-addressable thread-local store -//! with an associated destructor), many platforms also provide thread-local -//! destructors that are not associated with any particular data. These are -//! often more efficient. -//! -//! This module provides a fallback implementation for that interface, based -//! on the less efficient thread-local "keys". Each platform provides -//! a `thread_local_dtor` module which will either re-export the fallback, -//! or implement something more efficient. - -#![unstable(feature = "thread_local_internals", issue = "none")] -#![allow(dead_code)] - -use crate::cell::RefCell; -use crate::ptr; -use crate::sys_common::thread_local_key::StaticKey; - -pub unsafe fn register_dtor_fallback(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { - // The fallback implementation uses a vanilla OS-based TLS key to track - // the list of destructors that need to be run for this thread. The key - // then has its own destructor which runs all the other destructors. - // - // The destructor for DTORS is a little special in that it has a `while` - // loop to continuously drain the list of registered destructors. It - // *should* be the case that this loop always terminates because we - // provide the guarantee that a TLS key cannot be set after it is - // flagged for destruction. - - static DTORS: StaticKey = StaticKey::new(Some(run_dtors)); - // FIXME(joboet): integrate RefCell into pointer to avoid infinite recursion - // when the global allocator tries to register a destructor and just panic - // instead. - type List = RefCell<Vec<(*mut u8, unsafe extern "C" fn(*mut u8))>>; - if DTORS.get().is_null() { - let v: Box<List> = Box::new(RefCell::new(Vec::new())); - DTORS.set(Box::into_raw(v) as *mut u8); - } - let list = &*(DTORS.get() as *const List); - match list.try_borrow_mut() { - Ok(mut dtors) => dtors.push((t, dtor)), - Err(_) => rtabort!("global allocator may not use TLS"), - } - - unsafe extern "C" fn run_dtors(mut ptr: *mut u8) { - while !ptr.is_null() { - let list = Box::from_raw(ptr as *mut List).into_inner(); - for (ptr, dtor) in list.into_iter() { - dtor(ptr); - } - ptr = DTORS.get(); - DTORS.set(ptr::null_mut()); - } - } -} diff --git a/library/std/src/sys_common/thread_local_key/tests.rs b/library/std/src/sys_common/thread_local_key/tests.rs deleted file mode 100644 index 48bed31af51..00000000000 --- a/library/std/src/sys_common/thread_local_key/tests.rs +++ /dev/null @@ -1,17 +0,0 @@ -use super::StaticKey; -use core::ptr; - -#[test] -fn statik() { - static K1: StaticKey = StaticKey::new(None); - static K2: StaticKey = StaticKey::new(None); - - unsafe { - assert!(K1.get().is_null()); - assert!(K2.get().is_null()); - K1.set(ptr::without_provenance_mut(1)); - K2.set(ptr::without_provenance_mut(2)); - assert_eq!(K1.get() as usize, 1); - assert_eq!(K2.get() as usize, 2); - } -} diff --git a/src/doc/rustc/src/codegen-options/index.md b/src/doc/rustc/src/codegen-options/index.md index babe2bc342b..cd10168bc1c 100644 --- a/src/doc/rustc/src/codegen-options/index.md +++ b/src/doc/rustc/src/codegen-options/index.md @@ -184,20 +184,9 @@ incremental files will be stored. ## inline-threshold -This option lets you set the default threshold for inlining a function. It -takes an unsigned integer as a value. Inlining is based on a cost model, where -a higher threshold will allow more inlining. - -The default depends on the [opt-level](#opt-level): - -| opt-level | Threshold | -|-----------|-----------| -| 0 | N/A, only inlines always-inline functions | -| 1 | N/A, only inlines always-inline functions and LLVM lifetime intrinsics | -| 2 | 225 | -| 3 | 275 | -| s | 75 | -| z | 25 | +This option is deprecated and does nothing. + +Consider using `-Cllvm-args=--inline-threshold=...`. ## instrument-coverage diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 39659473f22..71dc8c4ca0f 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -119,7 +119,7 @@ The `std` column in the table below has the following meanings: * ✓ indicates the full standard library is available. * \* indicates the target only supports [`no_std`] development. -* ? indicates the standard library support is unknown or a work-in-progress. +* ? indicates the standard library support is a work-in-progress. [`no_std`]: https://rust-embedded.github.io/book/intro/no-std.html diff --git a/src/etc/htmldocck.py b/src/etc/htmldocck.py index 2e0f832192f..3d7ead99282 100755 --- a/src/etc/htmldocck.py +++ b/src/etc/htmldocck.py @@ -240,9 +240,37 @@ def concat_multi_lines(f): print_err(lineno, line, 'Trailing backslash at the end of the file') +def get_known_directive_names(): + def filter_line(line): + line = line.strip() + return line.startswith('"') and (line.endswith('",') or line.endswith('"')) + + # Equivalent to `src/tools/compiletest/src/header.rs` constant of the same name. + with open( + os.path.join( + # We go back to `src`. + os.path.dirname(os.path.dirname(__file__)), + "tools/compiletest/src/command-list.rs", + ), + "r", + encoding="utf8" + ) as fd: + content = fd.read() + return [ + line.strip().replace('",', '').replace('"', '') + for line in content.split('\n') + if filter_line(line) + ] + + +# To prevent duplicating the list of commmands between `compiletest` and `htmldocck`, we put +# it into a common file which is included in rust code and parsed here. +# FIXME: This setup is temporary until we figure out how to improve this situation. +KNOWN_DIRECTIVE_NAMES = get_known_directive_names() + LINE_PATTERN = re.compile(r''' - (?<=(?<!\S))(?P<invalid>!?)@(?P<negated>!?) - (?P<cmd>[A-Za-z]+(?:-[A-Za-z]+)*) + //@\s+ + (?P<negated>!?)(?P<cmd>[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*) (?P<args>.*)$ ''', re.X | re.UNICODE) @@ -254,17 +282,9 @@ def get_commands(template): if not m: continue - negated = (m.group('negated') == '!') cmd = m.group('cmd') - if m.group('invalid') == '!': - print_err( - lineno, - line, - 'Invalid command: `!@{0}{1}`, (help: try with `@!{1}`)'.format( - '!' if negated else '', - cmd, - ), - ) + negated = (m.group('negated') == '!') + if not negated and cmd in KNOWN_DIRECTIVE_NAMES: continue args = m.group('args') if args and not args[:1].isspace(): @@ -549,7 +569,7 @@ def get_nb_matching_elements(cache, c, regexp, stop_at_first): def check_files_in_folder(c, cache, folder, files): files = files.strip() if not files.startswith('[') or not files.endswith(']'): - raise InvalidCheck("Expected list as second argument of @{} (ie '[]')".format(c.cmd)) + raise InvalidCheck("Expected list as second argument of {} (ie '[]')".format(c.cmd)) folder = cache.get_absolute_path(folder) @@ -558,7 +578,7 @@ def check_files_in_folder(c, cache, folder, files): files_set = set() for file in files: if file in files_set: - raise InvalidCheck("Duplicated file `{}` in @{}".format(file, c.cmd)) + raise InvalidCheck("Duplicated file `{}` in {}".format(file, c.cmd)) files_set.add(file) folder_set = set([f for f in os.listdir(folder) if f != "." and f != ".."]) @@ -590,7 +610,7 @@ def check_command(c, cache): if c.cmd in ['has', 'hasraw', 'matches', 'matchesraw']: # string test regexp = c.cmd.startswith('matches') - # @has <path> = file existence + # has <path> = file existence if len(c.args) == 1 and not regexp and 'raw' not in c.cmd: try: cache.get_file(c.args[0]) @@ -598,40 +618,40 @@ def check_command(c, cache): except FailedCheck as err: cerr = str(err) ret = False - # @hasraw/matchesraw <path> <pat> = string test + # hasraw/matchesraw <path> <pat> = string test elif len(c.args) == 2 and 'raw' in c.cmd: cerr = "`PATTERN` did not match" ret = check_string(cache.get_file(c.args[0]), c.args[1], regexp) - # @has/matches <path> <pat> <match> = XML tree test + # has/matches <path> <pat> <match> = XML tree test elif len(c.args) == 3 and 'raw' not in c.cmd: cerr = "`XPATH PATTERN` did not match" ret = get_nb_matching_elements(cache, c, regexp, True) != 0 else: - raise InvalidCheck('Invalid number of @{} arguments'.format(c.cmd)) + raise InvalidCheck('Invalid number of {} arguments'.format(c.cmd)) elif c.cmd == 'files': # check files in given folder - if len(c.args) != 2: # @files <folder path> <file list> - raise InvalidCheck("Invalid number of @{} arguments".format(c.cmd)) + if len(c.args) != 2: # files <folder path> <file list> + raise InvalidCheck("Invalid number of {} arguments".format(c.cmd)) elif c.negated: - raise InvalidCheck("@{} doesn't support negative check".format(c.cmd)) + raise InvalidCheck("{} doesn't support negative check".format(c.cmd)) ret = check_files_in_folder(c, cache, c.args[0], c.args[1]) elif c.cmd == 'count': # count test - if len(c.args) == 3: # @count <path> <pat> <count> = count test + if len(c.args) == 3: # count <path> <pat> <count> = count test expected = int(c.args[2]) found = get_tree_count(cache.get_tree(c.args[0]), c.args[1]) cerr = "Expected {} occurrences but found {}".format(expected, found) ret = expected == found - elif len(c.args) == 4: # @count <path> <pat> <text> <count> = count test + elif len(c.args) == 4: # count <path> <pat> <text> <count> = count test expected = int(c.args[3]) found = get_nb_matching_elements(cache, c, False, False) cerr = "Expected {} occurrences but found {}".format(expected, found) ret = found == expected else: - raise InvalidCheck('Invalid number of @{} arguments'.format(c.cmd)) + raise InvalidCheck('Invalid number of {} arguments'.format(c.cmd)) elif c.cmd == 'snapshot': # snapshot test - if len(c.args) == 3: # @snapshot <snapshot-name> <html-path> <xpath> + if len(c.args) == 3: # snapshot <snapshot-name> <html-path> <xpath> [snapshot_name, html_path, pattern] = c.args tree = cache.get_tree(html_path) xpath = normalize_xpath(pattern) @@ -654,10 +674,10 @@ def check_command(c, cache): else: raise FailedCheck('Expected 1 match, but found {}'.format(len(subtrees))) else: - raise InvalidCheck('Invalid number of @{} arguments'.format(c.cmd)) + raise InvalidCheck('Invalid number of {} arguments'.format(c.cmd)) elif c.cmd == 'has-dir': # has-dir test - if len(c.args) == 1: # @has-dir <path> = has-dir test + if len(c.args) == 1: # has-dir <path> = has-dir test try: cache.get_dir(c.args[0]) ret = True @@ -665,22 +685,22 @@ def check_command(c, cache): cerr = str(err) ret = False else: - raise InvalidCheck('Invalid number of @{} arguments'.format(c.cmd)) + raise InvalidCheck('Invalid number of {} arguments'.format(c.cmd)) elif c.cmd == 'valid-html': - raise InvalidCheck('Unimplemented @valid-html') + raise InvalidCheck('Unimplemented valid-html') elif c.cmd == 'valid-links': - raise InvalidCheck('Unimplemented @valid-links') + raise InvalidCheck('Unimplemented valid-links') else: - raise InvalidCheck('Unrecognized @{}'.format(c.cmd)) + raise InvalidCheck('Unrecognized {}'.format(c.cmd)) if ret == c.negated: raise FailedCheck(cerr) except FailedCheck as err: - message = '@{}{} check failed'.format('!' if c.negated else '', c.cmd) + message = '{}{} check failed'.format('!' if c.negated else '', c.cmd) print_err(c.lineno, c.context, str(err), message) except InvalidCheck as err: print_err(c.lineno, c.context, str(err)) diff --git a/src/tools/clippy/clippy_lints/src/bool_assert_comparison.rs b/src/tools/clippy/clippy_lints/src/bool_assert_comparison.rs index 58c1a2f2706..db5792188dd 100644 --- a/src/tools/clippy/clippy_lints/src/bool_assert_comparison.rs +++ b/src/tools/clippy/clippy_lints/src/bool_assert_comparison.rs @@ -61,7 +61,7 @@ fn is_impl_not_trait_with_bool_out<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) - ) }) .map_or(false, |assoc_item| { - let proj = Ty::new_projection(cx.tcx, assoc_item.def_id, cx.tcx.mk_args_trait(ty, [])); + let proj = Ty::new_projection_from_args(cx.tcx, assoc_item.def_id, cx.tcx.mk_args_trait(ty, [])); let nty = cx.tcx.normalize_erasing_regions(cx.param_env, proj); nty.is_bool() diff --git a/src/tools/clippy/clippy_lints/src/methods/needless_collect.rs b/src/tools/clippy/clippy_lints/src/methods/needless_collect.rs index f26f164fa54..46b457daf70 100644 --- a/src/tools/clippy/clippy_lints/src/methods/needless_collect.rs +++ b/src/tools/clippy/clippy_lints/src/methods/needless_collect.rs @@ -206,7 +206,7 @@ fn iterates_same_ty<'tcx>(cx: &LateContext<'tcx>, iter_ty: Ty<'tcx>, collect_ty: && let Some(into_iter_item_proj) = make_projection(cx.tcx, into_iter_trait, sym::Item, [collect_ty]) && let Ok(into_iter_item_ty) = cx.tcx.try_normalize_erasing_regions( cx.param_env, - Ty::new_projection(cx.tcx, into_iter_item_proj.def_id, into_iter_item_proj.args), + Ty::new_projection_from_args(cx.tcx, into_iter_item_proj.def_id, into_iter_item_proj.args), ) { iter_item_ty == into_iter_item_ty @@ -235,7 +235,7 @@ fn is_contains_sig(cx: &LateContext<'_>, call_id: HirId, iter_expr: &Expr<'_>) - iter_trait, ) && let args = cx.tcx.mk_args(&[GenericArg::from(typeck.expr_ty_adjusted(iter_expr))]) - && let proj_ty = Ty::new_projection(cx.tcx, iter_item.def_id, args) + && let proj_ty = Ty::new_projection_from_args(cx.tcx, iter_item.def_id, args) && let Ok(item_ty) = cx.tcx.try_normalize_erasing_regions(cx.param_env, proj_ty) { item_ty == EarlyBinder::bind(search_ty).instantiate(cx.tcx, cx.typeck_results().node_args(call_id)) diff --git a/src/tools/clippy/clippy_lints/src/needless_borrows_for_generic_args.rs b/src/tools/clippy/clippy_lints/src/needless_borrows_for_generic_args.rs index 4f99eaa40c2..f4846a1753f 100644 --- a/src/tools/clippy/clippy_lints/src/needless_borrows_for_generic_args.rs +++ b/src/tools/clippy/clippy_lints/src/needless_borrows_for_generic_args.rs @@ -267,7 +267,7 @@ fn needless_borrow_count<'tcx>( return false; } - let predicate = EarlyBinder::bind(predicate).instantiate(cx.tcx, &args_with_referent_ty); + let predicate = EarlyBinder::bind(predicate).instantiate(cx.tcx, &args_with_referent_ty[..]); let obligation = Obligation::new(cx.tcx, ObligationCause::dummy(), cx.param_env, predicate); let infcx = cx.tcx.infer_ctxt().build(); infcx.predicate_must_hold_modulo_regions(&obligation) diff --git a/src/tools/clippy/clippy_lints/src/redundant_slicing.rs b/src/tools/clippy/clippy_lints/src/redundant_slicing.rs index 7f87d18e502..82f22ad693d 100644 --- a/src/tools/clippy/clippy_lints/src/redundant_slicing.rs +++ b/src/tools/clippy/clippy_lints/src/redundant_slicing.rs @@ -133,7 +133,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantSlicing { } else if let Some(target_id) = cx.tcx.lang_items().deref_target() { if let Ok(deref_ty) = cx.tcx.try_normalize_erasing_regions( cx.param_env, - Ty::new_projection(cx.tcx, target_id, cx.tcx.mk_args(&[GenericArg::from(indexed_ty)])), + Ty::new_projection_from_args(cx.tcx, target_id, cx.tcx.mk_args(&[GenericArg::from(indexed_ty)])), ) { if deref_ty == expr_ty { let snip = snippet_with_context(cx, indexed.span, ctxt, "..", &mut app).0; diff --git a/src/tools/clippy/clippy_utils/src/ty.rs b/src/tools/clippy/clippy_utils/src/ty.rs index 7d4332a3d9d..3790a852f7e 100644 --- a/src/tools/clippy/clippy_utils/src/ty.rs +++ b/src/tools/clippy/clippy_utils/src/ty.rs @@ -292,7 +292,7 @@ pub fn implements_trait_with_env_from_iter<'tcx>( let trait_ref = TraitRef::new( tcx, trait_id, - Some(GenericArg::from(ty)).into_iter().chain(args).chain(effect_arg), + [GenericArg::from(ty)].into_iter().chain(args).chain(effect_arg), ); debug_assert_matches!( @@ -1126,7 +1126,7 @@ pub fn make_projection<'tcx>( #[cfg(debug_assertions)] assert_generic_args_match(tcx, assoc_item.def_id, args); - Some(AliasTy::new(tcx, assoc_item.def_id, args)) + Some(AliasTy::new_from_args(tcx, assoc_item.def_id, args)) } helper( tcx, @@ -1165,7 +1165,7 @@ pub fn make_normalized_projection<'tcx>( ); return None; } - match tcx.try_normalize_erasing_regions(param_env, Ty::new_projection(tcx, ty.def_id, ty.args)) { + match tcx.try_normalize_erasing_regions(param_env, Ty::new_projection_from_args(tcx, ty.def_id, ty.args)) { Ok(ty) => Some(ty), Err(e) => { debug_assert!(false, "failed to normalize type `{ty}`: {e:#?}"); @@ -1289,7 +1289,7 @@ pub fn make_normalized_projection_with_regions<'tcx>( .infer_ctxt() .build() .at(&cause, param_env) - .query_normalize(Ty::new_projection(tcx, ty.def_id, ty.args)) + .query_normalize(Ty::new_projection_from_args(tcx, ty.def_id, ty.args)) { Ok(ty) => Some(ty.value), Err(e) => { diff --git a/src/tools/clippy/tests/ui/cfg_attr_cargo_clippy.stderr b/src/tools/clippy/tests/ui/cfg_attr_cargo_clippy.stderr index ddec0e648d1..0a358f1a684 100644 --- a/src/tools/clippy/tests/ui/cfg_attr_cargo_clippy.stderr +++ b/src/tools/clippy/tests/ui/cfg_attr_cargo_clippy.stderr @@ -1,13 +1,19 @@ error: `feature = "cargo-clippy"` was replaced by `clippy` - --> tests/ui/cfg_attr_cargo_clippy.rs:5:12 + --> tests/ui/cfg_attr_cargo_clippy.rs:3:13 | -LL | #[cfg_attr(feature = "cargo-clippy", derive(Debug))] - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` +LL | #![cfg_attr(feature = "cargo-clippy", doc = "a")] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` | = note: `-D clippy::deprecated-clippy-cfg-attr` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::deprecated_clippy_cfg_attr)]` error: `feature = "cargo-clippy"` was replaced by `clippy` + --> tests/ui/cfg_attr_cargo_clippy.rs:5:12 + | +LL | #[cfg_attr(feature = "cargo-clippy", derive(Debug))] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` + +error: `feature = "cargo-clippy"` was replaced by `clippy` --> tests/ui/cfg_attr_cargo_clippy.rs:6:16 | LL | #[cfg_attr(not(feature = "cargo-clippy"), derive(Debug))] @@ -37,11 +43,5 @@ error: `feature = "cargo-clippy"` was replaced by `clippy` LL | #[cfg(all(feature = "cargo-clippy"))] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` -error: `feature = "cargo-clippy"` was replaced by `clippy` - --> tests/ui/cfg_attr_cargo_clippy.rs:3:13 - | -LL | #![cfg_attr(feature = "cargo-clippy", doc = "a")] - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `clippy` - error: aborting due to 7 previous errors diff --git a/src/tools/clippy/tests/ui/tabs_in_doc_comments.stderr b/src/tools/clippy/tests/ui/tabs_in_doc_comments.stderr index 23d5dcd3a8d..aef6c391452 100644 --- a/src/tools/clippy/tests/ui/tabs_in_doc_comments.stderr +++ b/src/tools/clippy/tests/ui/tabs_in_doc_comments.stderr @@ -1,53 +1,53 @@ error: using tabs in doc comments is not recommended - --> tests/ui/tabs_in_doc_comments.rs:10:9 + --> tests/ui/tabs_in_doc_comments.rs:6:5 | -LL | /// - First String: - | ^^^^ help: consider using four spaces per tab +LL | /// - first one + | ^^^^ help: consider using four spaces per tab | = note: `-D clippy::tabs-in-doc-comments` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::tabs_in_doc_comments)]` error: using tabs in doc comments is not recommended - --> tests/ui/tabs_in_doc_comments.rs:11:9 + --> tests/ui/tabs_in_doc_comments.rs:6:13 | -LL | /// - needs to be inside here - | ^^^^^^^^ help: consider using four spaces per tab +LL | /// - first one + | ^^^^^^^^ help: consider using four spaces per tab error: using tabs in doc comments is not recommended - --> tests/ui/tabs_in_doc_comments.rs:14:9 + --> tests/ui/tabs_in_doc_comments.rs:7:5 | -LL | /// - Second String: - | ^^^^ help: consider using four spaces per tab +LL | /// - second one + | ^^^^ help: consider using four spaces per tab error: using tabs in doc comments is not recommended - --> tests/ui/tabs_in_doc_comments.rs:15:9 + --> tests/ui/tabs_in_doc_comments.rs:7:14 | -LL | /// - needs to be inside here - | ^^^^^^^^ help: consider using four spaces per tab +LL | /// - second one + | ^^^^ help: consider using four spaces per tab error: using tabs in doc comments is not recommended - --> tests/ui/tabs_in_doc_comments.rs:6:5 + --> tests/ui/tabs_in_doc_comments.rs:10:9 | -LL | /// - first one - | ^^^^ help: consider using four spaces per tab +LL | /// - First String: + | ^^^^ help: consider using four spaces per tab error: using tabs in doc comments is not recommended - --> tests/ui/tabs_in_doc_comments.rs:6:13 + --> tests/ui/tabs_in_doc_comments.rs:11:9 | -LL | /// - first one - | ^^^^^^^^ help: consider using four spaces per tab +LL | /// - needs to be inside here + | ^^^^^^^^ help: consider using four spaces per tab error: using tabs in doc comments is not recommended - --> tests/ui/tabs_in_doc_comments.rs:7:5 + --> tests/ui/tabs_in_doc_comments.rs:14:9 | -LL | /// - second one - | ^^^^ help: consider using four spaces per tab +LL | /// - Second String: + | ^^^^ help: consider using four spaces per tab error: using tabs in doc comments is not recommended - --> tests/ui/tabs_in_doc_comments.rs:7:14 + --> tests/ui/tabs_in_doc_comments.rs:15:9 | -LL | /// - second one - | ^^^^ help: consider using four spaces per tab +LL | /// - needs to be inside here + | ^^^^^^^^ help: consider using four spaces per tab error: aborting due to 8 previous errors diff --git a/src/tools/clippy/tests/ui/unnecessary_clippy_cfg.stderr b/src/tools/clippy/tests/ui/unnecessary_clippy_cfg.stderr index 16a86165295..01f842a657d 100644 --- a/src/tools/clippy/tests/ui/unnecessary_clippy_cfg.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_clippy_cfg.stderr @@ -1,61 +1,61 @@ error: no need to put clippy lints behind a `clippy` cfg - --> tests/ui/unnecessary_clippy_cfg.rs:13:1 + --> tests/ui/unnecessary_clippy_cfg.rs:4:1 | -LL | #[cfg_attr(clippy, deny(clippy::non_minimal_cfg))] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#[deny(clippy::non_minimal_cfg)]` +LL | #![cfg_attr(clippy, deny(clippy::non_minimal_cfg))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#![deny(clippy::non_minimal_cfg)]` | = note: `-D clippy::unnecessary-clippy-cfg` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::unnecessary_clippy_cfg)]` error: no need to put clippy lints behind a `clippy` cfg - --> tests/ui/unnecessary_clippy_cfg.rs:15:36 + --> tests/ui/unnecessary_clippy_cfg.rs:6:37 | -LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] + | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: write instead: `#[deny(clippy::non_minimal_cfg)]` + = note: write instead: `#![deny(clippy::non_minimal_cfg)]` error: no need to put clippy lints behind a `clippy` cfg - --> tests/ui/unnecessary_clippy_cfg.rs:17:36 + --> tests/ui/unnecessary_clippy_cfg.rs:8:37 | -LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] + | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: write instead: `#[deny(clippy::non_minimal_cfg)]` + = note: write instead: `#![deny(clippy::non_minimal_cfg)]` error: no need to put clippy lints behind a `clippy` cfg - --> tests/ui/unnecessary_clippy_cfg.rs:19:1 + --> tests/ui/unnecessary_clippy_cfg.rs:10:1 | -LL | #[cfg_attr(clippy, deny(clippy::non_minimal_cfg))] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#[deny(clippy::non_minimal_cfg)]` +LL | #![cfg_attr(clippy, deny(clippy::non_minimal_cfg))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#![deny(clippy::non_minimal_cfg)]` error: no need to put clippy lints behind a `clippy` cfg - --> tests/ui/unnecessary_clippy_cfg.rs:4:1 + --> tests/ui/unnecessary_clippy_cfg.rs:13:1 | -LL | #![cfg_attr(clippy, deny(clippy::non_minimal_cfg))] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#![deny(clippy::non_minimal_cfg)]` +LL | #[cfg_attr(clippy, deny(clippy::non_minimal_cfg))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#[deny(clippy::non_minimal_cfg)]` error: no need to put clippy lints behind a `clippy` cfg - --> tests/ui/unnecessary_clippy_cfg.rs:6:37 + --> tests/ui/unnecessary_clippy_cfg.rs:15:36 | -LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] + | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: write instead: `#![deny(clippy::non_minimal_cfg)]` + = note: write instead: `#[deny(clippy::non_minimal_cfg)]` error: no need to put clippy lints behind a `clippy` cfg - --> tests/ui/unnecessary_clippy_cfg.rs:8:37 + --> tests/ui/unnecessary_clippy_cfg.rs:17:36 | -LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] + | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: write instead: `#![deny(clippy::non_minimal_cfg)]` + = note: write instead: `#[deny(clippy::non_minimal_cfg)]` error: no need to put clippy lints behind a `clippy` cfg - --> tests/ui/unnecessary_clippy_cfg.rs:10:1 + --> tests/ui/unnecessary_clippy_cfg.rs:19:1 | -LL | #![cfg_attr(clippy, deny(clippy::non_minimal_cfg))] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#![deny(clippy::non_minimal_cfg)]` +LL | #[cfg_attr(clippy, deny(clippy::non_minimal_cfg))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#[deny(clippy::non_minimal_cfg)]` error: duplicated attribute --> tests/ui/unnecessary_clippy_cfg.rs:8:26 diff --git a/src/tools/compiletest/src/command-list.rs b/src/tools/compiletest/src/command-list.rs new file mode 100644 index 00000000000..6e1685a8a94 --- /dev/null +++ b/src/tools/compiletest/src/command-list.rs @@ -0,0 +1,230 @@ +/// This was originally generated by collecting directives from ui tests and then extracting their +/// directive names. This is **not** an exhaustive list of all possible directives. Instead, this is +/// a best-effort approximation for diagnostics. Add new headers to this list when needed. +const KNOWN_DIRECTIVE_NAMES: &[&str] = &[ + // tidy-alphabetical-start + "assembly-output", + "aux-bin", + "aux-build", + "aux-codegen-backend", + "aux-crate", + "build-aux-docs", + "build-fail", + "build-pass", + "check-fail", + "check-pass", + "check-run-results", + "check-stdout", + "check-test-line-numbers-match", + "compare-output-lines-by-subset", + "compile-flags", + "dont-check-compiler-stderr", + "dont-check-compiler-stdout", + "dont-check-failure-status", + "edition", + "error-pattern", + "exec-env", + "failure-status", + "filecheck-flags", + "forbid-output", + "force-host", + "ignore-16bit", + "ignore-32bit", + "ignore-64bit", + "ignore-aarch64", + "ignore-aarch64-unknown-linux-gnu", + "ignore-android", + "ignore-apple", + "ignore-arm", + "ignore-avr", + "ignore-beta", + "ignore-cdb", + "ignore-compare-mode-next-solver", + "ignore-compare-mode-polonius", + "ignore-cross-compile", + "ignore-debug", + "ignore-eabi", + "ignore-emscripten", + "ignore-endian-big", + "ignore-freebsd", + "ignore-fuchsia", + "ignore-gdb", + "ignore-gdb-version", + "ignore-gnu", + "ignore-haiku", + "ignore-horizon", + "ignore-i686-pc-windows-msvc", + "ignore-illumos", + "ignore-ios", + "ignore-linux", + "ignore-lldb", + "ignore-llvm-version", + "ignore-loongarch64", + "ignore-macabi", + "ignore-macos", + "ignore-mode-assembly", + "ignore-mode-codegen", + "ignore-mode-codegen-units", + "ignore-mode-coverage-map", + "ignore-mode-coverage-run", + "ignore-mode-crashes", + "ignore-mode-debuginfo", + "ignore-mode-incremental", + "ignore-mode-js-doc-test", + "ignore-mode-mir-opt", + "ignore-mode-pretty", + "ignore-mode-run-make", + "ignore-mode-run-pass-valgrind", + "ignore-mode-rustdoc", + "ignore-mode-rustdoc-json", + "ignore-mode-ui", + "ignore-mode-ui-fulldeps", + "ignore-msp430", + "ignore-msvc", + "ignore-musl", + "ignore-netbsd", + "ignore-nightly", + "ignore-none", + "ignore-nto", + "ignore-nvptx64", + "ignore-nvptx64-nvidia-cuda", + "ignore-openbsd", + "ignore-pass", + "ignore-remote", + "ignore-riscv64", + "ignore-s390x", + "ignore-sgx", + "ignore-spirv", + "ignore-stable", + "ignore-stage1", + "ignore-stage2", + "ignore-test", + "ignore-thumb", + "ignore-thumbv8m.base-none-eabi", + "ignore-thumbv8m.main-none-eabi", + "ignore-tvos", + "ignore-unix", + "ignore-unknown", + "ignore-uwp", + "ignore-visionos", + "ignore-vxworks", + "ignore-wasi", + "ignore-wasm", + "ignore-wasm32", + "ignore-wasm32-bare", + "ignore-wasm64", + "ignore-watchos", + "ignore-windows", + "ignore-windows-gnu", + "ignore-x32", + "ignore-x86", + "ignore-x86_64", + "ignore-x86_64-apple-darwin", + "ignore-x86_64-unknown-linux-gnu", + "incremental", + "known-bug", + "llvm-cov-flags", + "min-cdb-version", + "min-gdb-version", + "min-lldb-version", + "min-llvm-version", + "min-system-llvm-version", + "needs-asm-support", + "needs-dlltool", + "needs-dynamic-linking", + "needs-force-clang-based-tests", + "needs-git-hash", + "needs-llvm-components", + "needs-profiler-support", + "needs-relocation-model-pic", + "needs-run-enabled", + "needs-rust-lld", + "needs-rust-lldb", + "needs-sanitizer-address", + "needs-sanitizer-cfi", + "needs-sanitizer-dataflow", + "needs-sanitizer-hwaddress", + "needs-sanitizer-kcfi", + "needs-sanitizer-leak", + "needs-sanitizer-memory", + "needs-sanitizer-memtag", + "needs-sanitizer-safestack", + "needs-sanitizer-shadow-call-stack", + "needs-sanitizer-support", + "needs-sanitizer-thread", + "needs-symlink", + "needs-threads", + "needs-unwind", + "needs-wasmtime", + "needs-xray", + "no-auto-check-cfg", + "no-prefer-dynamic", + "normalize-stderr-32bit", + "normalize-stderr-64bit", + "normalize-stderr-test", + "normalize-stdout-test", + "only-16bit", + "only-32bit", + "only-64bit", + "only-aarch64", + "only-apple", + "only-arm", + "only-avr", + "only-beta", + "only-bpf", + "only-cdb", + "only-gnu", + "only-i686-pc-windows-msvc", + "only-ios", + "only-linux", + "only-loongarch64", + "only-loongarch64-unknown-linux-gnu", + "only-macos", + "only-mips", + "only-mips64", + "only-msp430", + "only-msvc", + "only-nightly", + "only-nvptx64", + "only-riscv64", + "only-sparc", + "only-sparc64", + "only-stable", + "only-thumb", + "only-tvos", + "only-unix", + "only-visionos", + "only-wasm32", + "only-wasm32-bare", + "only-wasm32-wasip1", + "only-watchos", + "only-windows", + "only-x86", + "only-x86_64", + "only-x86_64-fortanix-unknown-sgx", + "only-x86_64-pc-windows-gnu", + "only-x86_64-pc-windows-msvc", + "only-x86_64-unknown-linux-gnu", + "pp-exact", + "pretty-compare-only", + "pretty-expanded", + "pretty-mode", + "regex-error-pattern", + "remap-src-base", + "revisions", + "run-fail", + "run-flags", + "run-pass", + "run-rustfix", + "rustc-env", + "rustfix-only-machine-applicable", + "should-fail", + "should-ice", + "stderr-per-bitwidth", + "test-mir-pass", + "unset-exec-env", + "unset-rustc-env", + // Used by the tidy check `unknown_revision`. + "unused-revision-names", + // tidy-alphabetical-end +]; diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 31ae0deb7ec..63d1efd42fa 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -723,235 +723,28 @@ pub fn line_directive<'line>( } } -/// This was originally generated by collecting directives from ui tests and then extracting their -/// directive names. This is **not** an exhaustive list of all possible directives. Instead, this is -/// a best-effort approximation for diagnostics. Add new headers to this list when needed. -const KNOWN_DIRECTIVE_NAMES: &[&str] = &[ - // tidy-alphabetical-start - "assembly-output", - "aux-bin", - "aux-build", - "aux-codegen-backend", - "aux-crate", - "build-aux-docs", - "build-fail", - "build-pass", - "check-fail", - "check-pass", - "check-run-results", - "check-stdout", - "check-test-line-numbers-match", - "compare-output-lines-by-subset", - "compile-flags", - "dont-check-compiler-stderr", - "dont-check-compiler-stdout", - "dont-check-failure-status", - "edition", - "error-pattern", - "exec-env", - "failure-status", - "filecheck-flags", - "forbid-output", - "force-host", - "ignore-16bit", - "ignore-32bit", - "ignore-64bit", - "ignore-aarch64", - "ignore-aarch64-unknown-linux-gnu", - "ignore-android", - "ignore-apple", - "ignore-arm", - "ignore-avr", - "ignore-beta", - "ignore-cdb", - "ignore-compare-mode-next-solver", - "ignore-compare-mode-polonius", - "ignore-cross-compile", - "ignore-debug", - "ignore-eabi", - "ignore-emscripten", - "ignore-endian-big", - "ignore-freebsd", - "ignore-fuchsia", - "ignore-gdb", - "ignore-gdb-version", - "ignore-gnu", - "ignore-haiku", - "ignore-horizon", - "ignore-i686-pc-windows-msvc", - "ignore-illumos", - "ignore-ios", - "ignore-linux", - "ignore-lldb", - "ignore-llvm-version", - "ignore-loongarch64", - "ignore-macabi", - "ignore-macos", - "ignore-mode-assembly", - "ignore-mode-codegen", - "ignore-mode-codegen-units", - "ignore-mode-coverage-map", - "ignore-mode-coverage-run", - "ignore-mode-crashes", - "ignore-mode-debuginfo", - "ignore-mode-incremental", - "ignore-mode-js-doc-test", - "ignore-mode-mir-opt", - "ignore-mode-pretty", - "ignore-mode-run-make", - "ignore-mode-run-pass-valgrind", - "ignore-mode-rustdoc", - "ignore-mode-rustdoc-json", - "ignore-mode-ui", - "ignore-mode-ui-fulldeps", - "ignore-msp430", - "ignore-msvc", - "ignore-musl", - "ignore-netbsd", - "ignore-nightly", - "ignore-none", - "ignore-nto", - "ignore-nvptx64", - "ignore-nvptx64-nvidia-cuda", - "ignore-openbsd", - "ignore-pass", - "ignore-remote", - "ignore-riscv64", - "ignore-s390x", - "ignore-sgx", - "ignore-spirv", - "ignore-stable", - "ignore-stage1", - "ignore-stage2", - "ignore-test", - "ignore-thumb", - "ignore-thumbv8m.base-none-eabi", - "ignore-thumbv8m.main-none-eabi", - "ignore-tvos", - "ignore-unix", - "ignore-unknown", - "ignore-uwp", - "ignore-visionos", - "ignore-vxworks", - "ignore-wasi", - "ignore-wasm", - "ignore-wasm32", - "ignore-wasm32-bare", - "ignore-wasm64", - "ignore-watchos", - "ignore-windows", - "ignore-windows-gnu", - "ignore-x32", - "ignore-x86", - "ignore-x86_64", - "ignore-x86_64-apple-darwin", - "ignore-x86_64-unknown-linux-gnu", - "incremental", - "known-bug", - "llvm-cov-flags", - "min-cdb-version", - "min-gdb-version", - "min-lldb-version", - "min-llvm-version", - "min-system-llvm-version", - "needs-asm-support", - "needs-dlltool", - "needs-dynamic-linking", - "needs-force-clang-based-tests", - "needs-git-hash", - "needs-llvm-components", - "needs-profiler-support", - "needs-relocation-model-pic", - "needs-run-enabled", - "needs-rust-lld", - "needs-rust-lldb", - "needs-sanitizer-address", - "needs-sanitizer-cfi", - "needs-sanitizer-dataflow", - "needs-sanitizer-hwaddress", - "needs-sanitizer-kcfi", - "needs-sanitizer-leak", - "needs-sanitizer-memory", - "needs-sanitizer-memtag", - "needs-sanitizer-safestack", - "needs-sanitizer-shadow-call-stack", - "needs-sanitizer-support", - "needs-sanitizer-thread", - "needs-symlink", - "needs-threads", - "needs-unwind", - "needs-wasmtime", - "needs-xray", - "no-auto-check-cfg", - "no-prefer-dynamic", - "normalize-stderr-32bit", - "normalize-stderr-64bit", - "normalize-stderr-test", - "normalize-stdout-test", - "only-16bit", - "only-32bit", - "only-64bit", - "only-aarch64", - "only-apple", - "only-arm", - "only-avr", - "only-beta", - "only-bpf", - "only-cdb", - "only-gnu", - "only-i686-pc-windows-msvc", - "only-ios", - "only-linux", - "only-loongarch64", - "only-loongarch64-unknown-linux-gnu", - "only-macos", - "only-mips", - "only-mips64", - "only-msp430", - "only-msvc", - "only-nightly", - "only-nvptx64", - "only-riscv64", - "only-sparc", - "only-sparc64", - "only-stable", - "only-thumb", - "only-tvos", - "only-unix", - "only-visionos", - "only-wasm32", - "only-wasm32-bare", - "only-wasm32-wasip1", - "only-watchos", - "only-windows", - "only-x86", - "only-x86_64", - "only-x86_64-fortanix-unknown-sgx", - "only-x86_64-pc-windows-gnu", - "only-x86_64-pc-windows-msvc", - "only-x86_64-unknown-linux-gnu", - "pp-exact", - "pretty-compare-only", - "pretty-expanded", - "pretty-mode", - "regex-error-pattern", - "remap-src-base", - "revisions", - "run-fail", - "run-flags", - "run-pass", - "run-rustfix", - "rustc-env", - "rustfix-only-machine-applicable", - "should-fail", - "should-ice", - "stderr-per-bitwidth", - "test-mir-pass", - "unset-exec-env", - "unset-rustc-env", - // Used by the tidy check `unknown_revision`. - "unused-revision-names", - // tidy-alphabetical-end +// To prevent duplicating the list of commmands between `compiletest` and `htmldocck`, we put +// it into a common file which is included in rust code and parsed here. +// FIXME: This setup is temporary until we figure out how to improve this situation. +include!("command-list.rs"); + +const KNOWN_RUSTDOC_DIRECTIVE_NAMES: &[&str] = &[ + "count", + "!count", + "files", + "!files", + "has", + "!has", + "has-dir", + "!has-dir", + "hasraw", + "!hasraw", + "matches", + "!matches", + "matchesraw", + "!matchesraw", + "snapshot", + "!snapshot", ]; /// The broken-down contents of a line containing a test header directive, @@ -988,20 +781,30 @@ pub(crate) struct CheckDirectiveResult<'ln> { trailing_directive: Option<&'ln str>, } -pub(crate) fn check_directive(directive_ln: &str) -> CheckDirectiveResult<'_> { +pub(crate) fn check_directive<'a>( + directive_ln: &'a str, + is_rustdoc: bool, + original_line: &str, +) -> CheckDirectiveResult<'a> { let (directive_name, post) = directive_ln.split_once([':', ' ']).unwrap_or((directive_ln, "")); let trailing = post.trim().split_once(' ').map(|(pre, _)| pre).unwrap_or(post); + let is_known = |s: &str| { + KNOWN_DIRECTIVE_NAMES.contains(&s) + || (is_rustdoc + && original_line.starts_with("//@") + && KNOWN_RUSTDOC_DIRECTIVE_NAMES.contains(&s)) + }; let trailing_directive = { // 1. is the directive name followed by a space? (to exclude `:`) matches!(directive_ln.get(directive_name.len()..), Some(s) if s.starts_with(' ')) // 2. is what is after that directive also a directive (ex: "only-x86 only-arm") - && KNOWN_DIRECTIVE_NAMES.contains(&trailing) + && is_known(trailing) } .then_some(trailing); CheckDirectiveResult { - is_known_directive: KNOWN_DIRECTIVE_NAMES.contains(&directive_name), + is_known_directive: is_known(&directive_name), directive_name: directive_ln, trailing_directive, } @@ -1072,7 +875,7 @@ fn iter_header( let directive_ln = non_revisioned_directive_line.trim(); let CheckDirectiveResult { is_known_directive, trailing_directive, .. } = - check_directive(directive_ln); + check_directive(directive_ln, mode == Mode::Rustdoc, ln); if !is_known_directive { *poisoned = true; @@ -1125,7 +928,7 @@ fn iter_header( let rest = rest.trim_start(); let CheckDirectiveResult { is_known_directive, directive_name, .. } = - check_directive(rest); + check_directive(rest, mode == Mode::Rustdoc, ln); if is_known_directive { *poisoned = true; diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 72b57d91c23..1a4101e4de8 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -374,11 +374,12 @@ impl<'test> TestCx<'test> { // if a test does not crash, consider it an error if proc_res.status.success() || matches!(proc_res.status.code(), Some(1 | 0)) { - self.fatal( - "test no longer crashes/triggers ICE! Please give it a mearningful name, \ + self.fatal(&format!( + "crashtest no longer crashes/triggers ICE, horray! Please give it a meaningful name, \ add a doc-comment to the start of the test explaining why it exists and \ - move it to tests/ui or wherever you see fit.", - ); + move it to tests/ui or wherever you see fit. Adding 'Fixes #<issueNr>' to your PR description \ + ensures that the corresponding ticket is auto-closed upon merge." + )); } } diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index 11a1c43bae9..e5e9f0bbdaf 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -d49994b060684af423339b55769439b2f444a7b9 +c290e9de32e8ba6a673ef125fde40eadd395d170 diff --git a/src/tools/miri/tests/pass-dep/concurrency/tls_pthread_drop_order.rs b/src/tools/miri/tests/pass-dep/concurrency/tls_pthread_drop_order.rs index 0eaab967642..52348aad33d 100644 --- a/src/tools/miri/tests/pass-dep/concurrency/tls_pthread_drop_order.rs +++ b/src/tools/miri/tests/pass-dep/concurrency/tls_pthread_drop_order.rs @@ -1,9 +1,9 @@ //@ignore-target-windows: No pthreads on Windows //! Test that pthread_key destructors are run in the right order. //! Note that these are *not* used by actual `thread_local!` on Linux! Those use -//! `thread_local_dtor::register_dtor` from the stdlib instead. In Miri this hits the fallback path -//! in `register_dtor_fallback`, which uses a *single* pthread_key to manage a thread-local list of -//! dtors to call. +//! `destructors::register` from the stdlib instead. In Miri this ends up hitting +//! the fallback path in `guard::key::enable`, which uses a *single* pthread_key +//! to manage a thread-local list of dtors to call. use std::mem; use std::ptr; diff --git a/src/tools/tidy/src/style.rs b/src/tools/tidy/src/style.rs index 7bcb85335e0..e4d54d2a2b5 100644 --- a/src/tools/tidy/src/style.rs +++ b/src/tools/tidy/src/style.rs @@ -186,6 +186,11 @@ fn should_ignore(line: &str) -> bool { // - `//@[rev] normalize-stderr-test` || static_regex!("\\s*//@(\\[.*\\]) (compile-flags|normalize-stderr-test|error-pattern).*") .is_match(line) + // Matching for rustdoc tests commands. + // It allows to prevent them emitting warnings like `line longer than 100 chars`. + || static_regex!( + "\\s*//@ \\!?(count|files|has|has-dir|hasraw|matches|matchesraw|snapshot)\\s.*" + ).is_match(line) } /// Returns `true` if `line` is allowed to be longer than the normal limit. diff --git a/tests/codegen/checked_math.rs b/tests/codegen/checked_math.rs index 41016e3b7be..75df5866d6e 100644 --- a/tests/codegen/checked_math.rs +++ b/tests/codegen/checked_math.rs @@ -84,3 +84,17 @@ pub fn checked_shr_signed(a: i32, b: u32) -> Option<i32> { // CHECK: ret { i32, i32 } %[[R1]] a.checked_shr(b) } + +// CHECK-LABEL: @checked_add_one_unwrap_unsigned +// CHECK-SAME: (i32 noundef %x) +#[no_mangle] +pub fn checked_add_one_unwrap_unsigned(x: u32) -> u32 { + // CHECK: %[[IS_MAX:.+]] = icmp eq i32 %x, -1 + // CHECK: br i1 %[[IS_MAX]], label %[[NONE_BB:.+]], label %[[SOME_BB:.+]] + // CHECK: [[SOME_BB]]: + // CHECK: %[[R:.+]] = add nuw i32 %x, 1 + // CHECK: ret i32 %[[R]] + // CHECK: [[NONE_BB]]: + // CHECK: call {{.+}}unwrap_failed + x.checked_add(1).unwrap() +} diff --git a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir index e31a8cb6937..69c11ebcacc 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir @@ -11,15 +11,9 @@ fn step_forward(_1: u16, _2: usize) -> u16 { scope 3 (inlined <u16 as Step>::forward_checked) { scope 4 { scope 6 (inlined core::num::<impl u16>::checked_add) { + let mut _5: (u16, bool); + let mut _6: bool; let mut _7: bool; - scope 7 { - } - scope 8 (inlined core::num::<impl u16>::overflowing_add) { - let mut _5: (u16, bool); - let _6: bool; - scope 9 { - } - } } } scope 5 (inlined convert::num::ptr_try_from_impls::<impl TryFrom<usize> for u16>::try_from) { @@ -27,11 +21,11 @@ fn step_forward(_1: u16, _2: usize) -> u16 { let mut _4: u16; } } - scope 10 (inlined Option::<u16>::is_none) { - scope 11 (inlined Option::<u16>::is_some) { + scope 7 (inlined Option::<u16>::is_none) { + scope 8 (inlined Option::<u16>::is_some) { } } - scope 12 (inlined core::num::<impl u16>::wrapping_add) { + scope 9 (inlined core::num::<impl u16>::wrapping_add) { } } @@ -45,12 +39,11 @@ fn step_forward(_1: u16, _2: usize) -> u16 { bb1: { _4 = _2 as u16 (IntToInt); StorageDead(_3); + StorageLive(_7); StorageLive(_6); StorageLive(_5); _5 = AddWithOverflow(_1, _4); _6 = (_5.1: bool); - StorageDead(_5); - StorageLive(_7); _7 = unlikely(move _6) -> [return: bb2, unwind unreachable]; } @@ -59,14 +52,16 @@ fn step_forward(_1: u16, _2: usize) -> u16 { } bb3: { - StorageDead(_7); + StorageDead(_5); StorageDead(_6); + StorageDead(_7); goto -> bb7; } bb4: { - StorageDead(_7); + StorageDead(_5); StorageDead(_6); + StorageDead(_7); goto -> bb6; } diff --git a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir index 8cc9be27e21..e6ea6c51001 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir @@ -11,15 +11,9 @@ fn step_forward(_1: u16, _2: usize) -> u16 { scope 3 (inlined <u16 as Step>::forward_checked) { scope 4 { scope 6 (inlined core::num::<impl u16>::checked_add) { + let mut _5: (u16, bool); + let mut _6: bool; let mut _7: bool; - scope 7 { - } - scope 8 (inlined core::num::<impl u16>::overflowing_add) { - let mut _5: (u16, bool); - let _6: bool; - scope 9 { - } - } } } scope 5 (inlined convert::num::ptr_try_from_impls::<impl TryFrom<usize> for u16>::try_from) { @@ -27,11 +21,11 @@ fn step_forward(_1: u16, _2: usize) -> u16 { let mut _4: u16; } } - scope 10 (inlined Option::<u16>::is_none) { - scope 11 (inlined Option::<u16>::is_some) { + scope 7 (inlined Option::<u16>::is_none) { + scope 8 (inlined Option::<u16>::is_some) { } } - scope 12 (inlined core::num::<impl u16>::wrapping_add) { + scope 9 (inlined core::num::<impl u16>::wrapping_add) { } } @@ -45,12 +39,11 @@ fn step_forward(_1: u16, _2: usize) -> u16 { bb1: { _4 = _2 as u16 (IntToInt); StorageDead(_3); + StorageLive(_7); StorageLive(_6); StorageLive(_5); _5 = AddWithOverflow(_1, _4); _6 = (_5.1: bool); - StorageDead(_5); - StorageLive(_7); _7 = unlikely(move _6) -> [return: bb2, unwind unreachable]; } @@ -59,14 +52,16 @@ fn step_forward(_1: u16, _2: usize) -> u16 { } bb3: { - StorageDead(_7); + StorageDead(_5); StorageDead(_6); + StorageDead(_7); goto -> bb7; } bb4: { - StorageDead(_7); + StorageDead(_5); StorageDead(_6); + StorageDead(_7); goto -> bb6; } diff --git a/tests/run-make/jobserver-error/cannot_open_fd.stderr b/tests/run-make/jobserver-error/cannot_open_fd.stderr index 7c421846535..9ac4c1c58f7 100644 --- a/tests/run-make/jobserver-error/cannot_open_fd.stderr +++ b/tests/run-make/jobserver-error/cannot_open_fd.stderr @@ -4,3 +4,5 @@ warning: failed to connect to jobserver from environment variable `MAKEFLAGS="-- error: no input filename given +error: aborting due to 1 previous error + diff --git a/tests/run-make/no-input-file/rmake.rs b/tests/run-make/no-input-file/rmake.rs index fc558b22fb4..d76a8f9e7c1 100644 --- a/tests/run-make/no-input-file/rmake.rs +++ b/tests/run-make/no-input-file/rmake.rs @@ -1,9 +1,9 @@ use run_make_support::rustc; fn main() { - rustc() - .print("crate-name") - .run_fail() - .assert_exit_code(1) - .assert_stderr_equals("error: no input filename given"); + rustc().print("crate-name").run_fail().assert_exit_code(1).assert_stderr_equals( + "error: no input filename given + +error: aborting due to 1 previous error", + ); } diff --git a/tests/rustdoc/alias-reexport.rs b/tests/rustdoc/alias-reexport.rs index 0f77d8b3f96..41f1f8df0f6 100644 --- a/tests/rustdoc/alias-reexport.rs +++ b/tests/rustdoc/alias-reexport.rs @@ -7,11 +7,11 @@ extern crate alias_reexport2; -// @has 'foo/reexport/fn.foo.html' -// @has - '//*[@class="rust item-decl"]' 'pub fn foo() -> Reexported' -// @has 'foo/reexport/fn.foo2.html' -// @has - '//*[@class="rust item-decl"]' 'pub fn foo2() -> Result<Reexported, ()>' -// @has 'foo/reexport/type.Reexported.html' -// @has - '//*[@class="rust item-decl"]' 'pub type Reexported = u8;' +//@ has 'foo/reexport/fn.foo.html' +//@ has - '//*[@class="rust item-decl"]' 'pub fn foo() -> Reexported' +//@ has 'foo/reexport/fn.foo2.html' +//@ has - '//*[@class="rust item-decl"]' 'pub fn foo2() -> Result<Reexported, ()>' +//@ has 'foo/reexport/type.Reexported.html' +//@ has - '//*[@class="rust item-decl"]' 'pub type Reexported = u8;' #[doc(inline)] pub use alias_reexport2 as reexport; diff --git a/tests/rustdoc/alias-reexport2.rs b/tests/rustdoc/alias-reexport2.rs index 60b7a5f9b83..2fb69b922c8 100644 --- a/tests/rustdoc/alias-reexport2.rs +++ b/tests/rustdoc/alias-reexport2.rs @@ -9,9 +9,9 @@ extern crate alias_reexport; use alias_reexport::Reexported; -// @has 'foo/fn.foo.html' -// @has - '//*[@class="rust item-decl"]' 'pub fn foo() -> Reexported' +//@ has 'foo/fn.foo.html' +//@ has - '//*[@class="rust item-decl"]' 'pub fn foo() -> Reexported' pub fn foo() -> Reexported { 0 } -// @has 'foo/fn.foo2.html' -// @has - '//*[@class="rust item-decl"]' 'pub fn foo2() -> Result<Reexported, ()>' +//@ has 'foo/fn.foo2.html' +//@ has - '//*[@class="rust item-decl"]' 'pub fn foo2() -> Result<Reexported, ()>' pub fn foo2() -> Result<Reexported, ()> { Ok(0) } diff --git a/tests/rustdoc/all.rs b/tests/rustdoc/all.rs index 4c8d0231095..7056af8e343 100644 --- a/tests/rustdoc/all.rs +++ b/tests/rustdoc/all.rs @@ -1,11 +1,11 @@ #![crate_name = "foo"] -// @has foo/all.html '//a[@href="struct.Struct.html"]' 'Struct' -// @has foo/all.html '//a[@href="enum.Enum.html"]' 'Enum' -// @has foo/all.html '//a[@href="union.Union.html"]' 'Union' -// @has foo/all.html '//a[@href="constant.CONST.html"]' 'CONST' -// @has foo/all.html '//a[@href="static.STATIC.html"]' 'STATIC' -// @has foo/all.html '//a[@href="fn.function.html"]' 'function' +//@ has foo/all.html '//a[@href="struct.Struct.html"]' 'Struct' +//@ has foo/all.html '//a[@href="enum.Enum.html"]' 'Enum' +//@ has foo/all.html '//a[@href="union.Union.html"]' 'Union' +//@ has foo/all.html '//a[@href="constant.CONST.html"]' 'CONST' +//@ has foo/all.html '//a[@href="static.STATIC.html"]' 'STATIC' +//@ has foo/all.html '//a[@href="fn.function.html"]' 'function' pub struct Struct; pub enum Enum { @@ -23,6 +23,6 @@ mod private_module { pub struct ReexportedStruct; } -// @has foo/all.html '//a[@href="struct.ReexportedStruct.html"]' 'ReexportedStruct' -// @!hasraw foo/all.html 'private_module' +//@ has foo/all.html '//a[@href="struct.ReexportedStruct.html"]' 'ReexportedStruct' +//@ !hasraw foo/all.html 'private_module' pub use private_module::ReexportedStruct; diff --git a/tests/rustdoc/anchor-id-duplicate-method-name-25001.rs b/tests/rustdoc/anchor-id-duplicate-method-name-25001.rs index ffb0765d3c3..5fa6891b23d 100644 --- a/tests/rustdoc/anchor-id-duplicate-method-name-25001.rs +++ b/tests/rustdoc/anchor-id-duplicate-method-name-25001.rs @@ -1,7 +1,7 @@ // https://github.com/rust-lang/rust/issues/25001 #![crate_name="issue_25001"] -// @has issue_25001/struct.Foo.html +//@ has issue_25001/struct.Foo.html pub struct Foo<T>(T); pub trait Bar { @@ -11,36 +11,36 @@ pub trait Bar { } impl Foo<u8> { - // @has - '//*[@id="method.pass"]//h4[@class="code-header"]' 'fn pass()' + //@ has - '//*[@id="method.pass"]//h4[@class="code-header"]' 'fn pass()' pub fn pass() {} } impl Foo<u16> { - // @has - '//*[@id="method.pass-1"]//h4[@class="code-header"]' 'fn pass() -> usize' + //@ has - '//*[@id="method.pass-1"]//h4[@class="code-header"]' 'fn pass() -> usize' pub fn pass() -> usize { 42 } } impl Foo<u32> { - // @has - '//*[@id="method.pass-2"]//h4[@class="code-header"]' 'fn pass() -> isize' + //@ has - '//*[@id="method.pass-2"]//h4[@class="code-header"]' 'fn pass() -> isize' pub fn pass() -> isize { 42 } } impl<T> Bar for Foo<T> { - // @has - '//*[@id="associatedtype.Item-1"]//h4[@class="code-header"]' 'type Item = T' + //@ has - '//*[@id="associatedtype.Item-1"]//h4[@class="code-header"]' 'type Item = T' type Item=T; - // @has - '//*[@id="method.quux"]//h4[@class="code-header"]' 'fn quux(self)' + //@ has - '//*[@id="method.quux"]//h4[@class="code-header"]' 'fn quux(self)' fn quux(self) {} } impl<'a, T> Bar for &'a Foo<T> { - // @has - '//*[@id="associatedtype.Item"]//h4[@class="code-header"]' "type Item = &'a T" + //@ has - '//*[@id="associatedtype.Item"]//h4[@class="code-header"]' "type Item = &'a T" type Item=&'a T; - // @has - '//*[@id="method.quux-1"]//h4[@class="code-header"]' 'fn quux(self)' + //@ has - '//*[@id="method.quux-1"]//h4[@class="code-header"]' 'fn quux(self)' fn quux(self) {} } impl<'a, T> Bar for &'a mut Foo<T> { - // @has - '//*[@id="associatedtype.Item-2"]//h4[@class="code-header"]' "type Item = &'a mut T" + //@ has - '//*[@id="associatedtype.Item-2"]//h4[@class="code-header"]' "type Item = &'a mut T" type Item=&'a mut T; - // @has - '//*[@id="method.quux-2"]//h4[@class="code-header"]' 'fn quux(self)' + //@ has - '//*[@id="method.quux-2"]//h4[@class="code-header"]' 'fn quux(self)' fn quux(self) {} } diff --git a/tests/rustdoc/anchor-id-trait-method-15169.rs b/tests/rustdoc/anchor-id-trait-method-15169.rs index 26bb59c1875..19eeeaee9d1 100644 --- a/tests/rustdoc/anchor-id-trait-method-15169.rs +++ b/tests/rustdoc/anchor-id-trait-method-15169.rs @@ -1,4 +1,4 @@ -// @has issue_15169/struct.Foo.html '//*[@id="method.eq"]' 'fn eq' +//@ has issue_15169/struct.Foo.html '//*[@id="method.eq"]' 'fn eq' // https://github.com/rust-lang/rust/issues/15169 #![crate_name="issue_15169"] diff --git a/tests/rustdoc/anchor-id-trait-tymethod-28478.rs b/tests/rustdoc/anchor-id-trait-tymethod-28478.rs index 5685040dc1e..e7adba7d06e 100644 --- a/tests/rustdoc/anchor-id-trait-tymethod-28478.rs +++ b/tests/rustdoc/anchor-id-trait-tymethod-28478.rs @@ -3,32 +3,32 @@ #![feature(associated_type_defaults)] -// @has issue_28478/trait.Bar.html +//@ has issue_28478/trait.Bar.html pub trait Bar { - // @has - '//*[@id="associatedtype.Bar"]' 'type Bar = ()' - // @has - '//*[@href="#associatedtype.Bar"]' 'Bar' + //@ has - '//*[@id="associatedtype.Bar"]' 'type Bar = ()' + //@ has - '//*[@href="#associatedtype.Bar"]' 'Bar' type Bar = (); - // @has - '//*[@id="associatedconstant.Baz"]' 'const Baz: usize' - // @has - '//*[@href="#associatedconstant.Baz"]' 'Baz' + //@ has - '//*[@id="associatedconstant.Baz"]' 'const Baz: usize' + //@ has - '//*[@href="#associatedconstant.Baz"]' 'Baz' const Baz: usize = 7; - // @has - '//*[@id="tymethod.bar"]' 'fn bar' + //@ has - '//*[@id="tymethod.bar"]' 'fn bar' fn bar(); - // @has - '//*[@id="method.baz"]' 'fn baz' + //@ has - '//*[@id="method.baz"]' 'fn baz' fn baz() { } } -// @has issue_28478/struct.Foo.html +//@ has issue_28478/struct.Foo.html pub struct Foo; impl Foo { - // @has - '//*[@href="#method.foo"]' 'foo' + //@ has - '//*[@href="#method.foo"]' 'foo' pub fn foo() {} } impl Bar for Foo { - // @has - '//*[@href="trait.Bar.html#associatedtype.Bar"]' 'Bar' - // @has - '//*[@href="trait.Bar.html#associatedconstant.Baz"]' 'Baz' - // @has - '//*[@href="trait.Bar.html#tymethod.bar"]' 'bar' + //@ has - '//*[@href="trait.Bar.html#associatedtype.Bar"]' 'Bar' + //@ has - '//*[@href="trait.Bar.html#associatedconstant.Baz"]' 'Baz' + //@ has - '//*[@href="trait.Bar.html#tymethod.bar"]' 'bar' fn bar() {} - // @has - '//*[@href="trait.Bar.html#method.baz"]' 'baz' + //@ has - '//*[@href="trait.Bar.html#method.baz"]' 'baz' } diff --git a/tests/rustdoc/anchors.rs b/tests/rustdoc/anchors.rs index 034cf8eaf4f..255ef87351c 100644 --- a/tests/rustdoc/anchors.rs +++ b/tests/rustdoc/anchors.rs @@ -6,44 +6,44 @@ pub struct Foo; -// @has 'foo/trait.Bar.html' +//@ has 'foo/trait.Bar.html' pub trait Bar { // There should be no anchors here. - // @snapshot no_type_anchor - '//*[@id="associatedtype.T"]' + //@ snapshot no_type_anchor - '//*[@id="associatedtype.T"]' type T; // There should be no anchors here. - // @snapshot no_const_anchor - '//*[@id="associatedconstant.YOLO"]' + //@ snapshot no_const_anchor - '//*[@id="associatedconstant.YOLO"]' const YOLO: u32; // There should be no anchors here. - // @snapshot no_tymethod_anchor - '//*[@id="tymethod.foo"]' + //@ snapshot no_tymethod_anchor - '//*[@id="tymethod.foo"]' fn foo(); // There should be no anchors here. - // @snapshot no_trait_method_anchor - '//*[@id="method.bar"]' + //@ snapshot no_trait_method_anchor - '//*[@id="method.bar"]' fn bar() {} } -// @has 'foo/struct.Foo.html' +//@ has 'foo/struct.Foo.html' impl Bar for Foo { - // @has - '//*[@id="associatedtype.T"]/a[@class="anchor"]' '' + //@ has - '//*[@id="associatedtype.T"]/a[@class="anchor"]' '' type T = u32; - // @has - '//*[@id="associatedconstant.YOLO"]/a[@class="anchor"]' '' + //@ has - '//*[@id="associatedconstant.YOLO"]/a[@class="anchor"]' '' const YOLO: u32 = 0; - // @has - '//*[@id="method.foo"]/a[@class="anchor"]' '' + //@ has - '//*[@id="method.foo"]/a[@class="anchor"]' '' fn foo() {} // Same check for provided "bar" method. - // @has - '//*[@id="method.bar"]/a[@class="anchor"]' '' + //@ has - '//*[@id="method.bar"]/a[@class="anchor"]' '' } impl Foo { - // @snapshot no_const_anchor2 - '//*[@id="associatedconstant.X"]' + //@ snapshot no_const_anchor2 - '//*[@id="associatedconstant.X"]' // There should be no anchors here. pub const X: i32 = 0; - // @snapshot no_type_anchor2 - '//*[@id="associatedtype.Y"]' + //@ snapshot no_type_anchor2 - '//*[@id="associatedtype.Y"]' // There should be no anchors here. pub type Y = u32; - // @snapshot no_method_anchor - '//*[@id="method.new"]' + //@ snapshot no_method_anchor - '//*[@id="method.new"]' // There should be no anchors here. pub fn new() -> Self { Self } } diff --git a/tests/rustdoc/anonymous-lifetime.rs b/tests/rustdoc/anonymous-lifetime.rs index 390ed5a1f93..872f31a3602 100644 --- a/tests/rustdoc/anonymous-lifetime.rs +++ b/tests/rustdoc/anonymous-lifetime.rs @@ -11,8 +11,8 @@ pub trait Stream { fn size_hint(&self) -> (usize, Option<usize>); } -// @has 'foo/trait.Stream.html' -// @has - '//*[@class="code-header"]' 'impl<S: ?Sized + Stream + Unpin> Stream for &mut S' +//@ has 'foo/trait.Stream.html' +//@ has - '//*[@class="code-header"]' 'impl<S: ?Sized + Stream + Unpin> Stream for &mut S' impl<S: ?Sized + Stream + Unpin> Stream for &mut S { type Item = S::Item; diff --git a/tests/rustdoc/anonymous-reexport.rs b/tests/rustdoc/anonymous-reexport.rs index 839c1a30346..8021008dc66 100644 --- a/tests/rustdoc/anonymous-reexport.rs +++ b/tests/rustdoc/anonymous-reexport.rs @@ -2,16 +2,16 @@ // This test ensures we don't display anonymous (non-inline) re-exports of public items. -// @has 'foo/index.html' -// @has - '//*[@id="main-content"]' '' +//@ has 'foo/index.html' +//@ has - '//*[@id="main-content"]' '' // We check that the only "h2" present are "Structs" (for "Bla") and "Re-exports". -// @count - '//*[@id="main-content"]/h2' 2 -// @has - '//*[@id="main-content"]/h2' 'Structs' -// @has - '//*[@id="main-content"]/h2' 'Re-exports' +//@ count - '//*[@id="main-content"]/h2' 2 +//@ has - '//*[@id="main-content"]/h2' 'Structs' +//@ has - '//*[@id="main-content"]/h2' 'Re-exports' // The 3 re-exports. -// @count - '//*[@id="main-content"]//*[@class="item-table"]//li//code' 3 +//@ count - '//*[@id="main-content"]//*[@class="item-table"]//li//code' 3 // The public struct. -// @count - '//*[@id="main-content"]//a[@class="struct"]' 1 +//@ count - '//*[@id="main-content"]//a[@class="struct"]' 1 mod ext { pub trait Foo {} diff --git a/tests/rustdoc/array-links.rs b/tests/rustdoc/array-links.rs index 8ee294daa96..d185233c728 100644 --- a/tests/rustdoc/array-links.rs +++ b/tests/rustdoc/array-links.rs @@ -3,26 +3,26 @@ pub struct MyBox<T: ?Sized>(*const T); -// @has 'foo/fn.alpha.html' -// @snapshot link_slice_u32 - '//pre[@class="rust item-decl"]/code' +//@ has 'foo/fn.alpha.html' +//@ snapshot link_slice_u32 - '//pre[@class="rust item-decl"]/code' pub fn alpha() -> &'static [u32; 1] { loop {} } -// @has 'foo/fn.beta.html' -// @snapshot link_slice_generic - '//pre[@class="rust item-decl"]/code' +//@ has 'foo/fn.beta.html' +//@ snapshot link_slice_generic - '//pre[@class="rust item-decl"]/code' pub fn beta<T>() -> &'static [T; 1] { loop {} } -// @has 'foo/fn.gamma.html' -// @snapshot link_box_u32 - '//pre[@class="rust item-decl"]/code' +//@ has 'foo/fn.gamma.html' +//@ snapshot link_box_u32 - '//pre[@class="rust item-decl"]/code' pub fn gamma() -> MyBox<[u32; 1]> { loop {} } -// @has 'foo/fn.delta.html' -// @snapshot link_box_generic - '//pre[@class="rust item-decl"]/code' +//@ has 'foo/fn.delta.html' +//@ snapshot link_box_generic - '//pre[@class="rust item-decl"]/code' pub fn delta<T>() -> MyBox<[T; 1]> { loop {} } diff --git a/tests/rustdoc/asm-foreign.rs b/tests/rustdoc/asm-foreign.rs index d7550ca5aca..ebae53ea19c 100644 --- a/tests/rustdoc/asm-foreign.rs +++ b/tests/rustdoc/asm-foreign.rs @@ -2,7 +2,7 @@ use std::arch::asm; -// @has asm_foreign/fn.aarch64.html +//@ has asm_foreign/fn.aarch64.html pub unsafe fn aarch64(a: f64, b: f64) -> f64 { let c; asm!("add {:d}, {:d}, d0", out(vreg) c, in(vreg) a, in("d0") { @@ -12,7 +12,7 @@ pub unsafe fn aarch64(a: f64, b: f64) -> f64 { c } -// @has asm_foreign/fn.x86.html +//@ has asm_foreign/fn.x86.html pub unsafe fn x86(a: f64, b: f64) -> f64 { let c; asm!("addsd {}, {}, xmm0", out(xmm_reg) c, in(xmm_reg) a, in("xmm0") b); diff --git a/tests/rustdoc/asm-foreign2.rs b/tests/rustdoc/asm-foreign2.rs index c3b194b1660..c0f3224a90f 100644 --- a/tests/rustdoc/asm-foreign2.rs +++ b/tests/rustdoc/asm-foreign2.rs @@ -3,7 +3,7 @@ use std::arch::asm; -// @has asm_foreign2/fn.x86.html +//@ has asm_foreign2/fn.x86.html pub unsafe fn x86(x: i64) -> i64 { let y; asm!("movq {}, {}", in(reg) x, out(reg) y, options(att_syntax)); diff --git a/tests/rustdoc/asref-for-and-of-local-82465.rs b/tests/rustdoc/asref-for-and-of-local-82465.rs index e6204688904..9c96b72ee27 100644 --- a/tests/rustdoc/asref-for-and-of-local-82465.rs +++ b/tests/rustdoc/asref-for-and-of-local-82465.rs @@ -4,14 +4,14 @@ use std::convert::AsRef; pub struct Local; -// @has foo/struct.Local.html '//h3[@class="code-header"]' 'impl AsRef<str> for Local' +//@ has foo/struct.Local.html '//h3[@class="code-header"]' 'impl AsRef<str> for Local' impl AsRef<str> for Local { fn as_ref(&self) -> &str { todo!() } } -// @has - '//h3[@class="code-header"]' 'impl AsRef<Local> for str' +//@ has - '//h3[@class="code-header"]' 'impl AsRef<Local> for str' impl AsRef<Local> for str { fn as_ref(&self) -> &Local { todo!() diff --git a/tests/rustdoc/assoc-consts-version.rs b/tests/rustdoc/assoc-consts-version.rs index 6060bc0a6fd..db4d759acab 100644 --- a/tests/rustdoc/assoc-consts-version.rs +++ b/tests/rustdoc/assoc-consts-version.rs @@ -8,7 +8,7 @@ pub struct SomeStruct; impl SomeStruct { - // @has 'foo/struct.SomeStruct.html' \ + //@ has 'foo/struct.SomeStruct.html' \ // '//*[@id="associatedconstant.SOME_CONST"]//span[@class="since"]' '1.1.2' #[stable(since="1.1.2", feature="rust2")] pub const SOME_CONST: usize = 0; diff --git a/tests/rustdoc/assoc-consts.rs b/tests/rustdoc/assoc-consts.rs index 08dfa879d43..cb8e839541c 100644 --- a/tests/rustdoc/assoc-consts.rs +++ b/tests/rustdoc/assoc-consts.rs @@ -1,11 +1,11 @@ pub trait Foo { - // @has assoc_consts/trait.Foo.html '//pre[@class="rust item-decl"]' \ + //@ has assoc_consts/trait.Foo.html '//pre[@class="rust item-decl"]' \ // 'const FOO: usize = 13usize;' - // @has - '//*[@id="associatedconstant.FOO"]' 'const FOO: usize' + //@ has - '//*[@id="associatedconstant.FOO"]' 'const FOO: usize' const FOO: usize = 12 + 1; - // @has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool' + //@ has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool' const FOO_NO_DEFAULT: bool; - // @!hasraw - FOO_HIDDEN + //@ !hasraw - FOO_HIDDEN #[doc(hidden)] const FOO_HIDDEN: u8 = 0; } @@ -13,22 +13,22 @@ pub trait Foo { pub struct Bar; impl Foo for Bar { - // @has assoc_consts/struct.Bar.html '//h3[@class="code-header"]' 'impl Foo for Bar' - // @has - '//*[@id="associatedconstant.FOO"]' 'const FOO: usize' + //@ has assoc_consts/struct.Bar.html '//h3[@class="code-header"]' 'impl Foo for Bar' + //@ has - '//*[@id="associatedconstant.FOO"]' 'const FOO: usize' const FOO: usize = 12; - // @has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool' + //@ has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool' const FOO_NO_DEFAULT: bool = false; - // @!hasraw - FOO_HIDDEN + //@ !hasraw - FOO_HIDDEN #[doc(hidden)] const FOO_HIDDEN: u8 = 0; } impl Bar { - // @has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.BAR"]' \ + //@ has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.BAR"]' \ // 'const BAR: usize' pub const BAR: usize = 3; - // @has - '//*[@id="associatedconstant.BAR_ESCAPED"]' \ + //@ has - '//*[@id="associatedconstant.BAR_ESCAPED"]' \ // "const BAR_ESCAPED: &'static str = \"<em>markup</em>\"" pub const BAR_ESCAPED: &'static str = "<em>markup</em>"; } @@ -36,7 +36,7 @@ impl Bar { pub struct Baz<'a, U: 'a, T>(T, &'a [U]); impl Bar { - // @has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.BAZ"]' \ + //@ has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.BAZ"]' \ // "const BAZ: Baz<'static, u8, u32>" pub const BAZ: Baz<'static, u8, u32> = Baz(321, &[1, 2, 3]); } @@ -44,60 +44,60 @@ impl Bar { pub fn f(_: &(ToString + 'static)) {} impl Bar { - // @has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.F"]' \ + //@ has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.F"]' \ // "const F: fn(_: &(dyn ToString + 'static))" pub const F: fn(_: &(ToString + 'static)) = f; } impl Bar { - // @!hasraw assoc_consts/struct.Bar.html 'BAR_PRIVATE' + //@ !hasraw assoc_consts/struct.Bar.html 'BAR_PRIVATE' const BAR_PRIVATE: char = 'a'; - // @!hasraw assoc_consts/struct.Bar.html 'BAR_HIDDEN' + //@ !hasraw assoc_consts/struct.Bar.html 'BAR_HIDDEN' #[doc(hidden)] pub const BAR_HIDDEN: &'static str = "a"; } -// @has assoc_consts/trait.Qux.html +//@ has assoc_consts/trait.Qux.html pub trait Qux { - // @has - '//*[@id="associatedconstant.QUX0"]' 'const QUX0: u8' - // @has - '//*[@class="docblock"]' "Docs for QUX0 in trait." + //@ has - '//*[@id="associatedconstant.QUX0"]' 'const QUX0: u8' + //@ has - '//*[@class="docblock"]' "Docs for QUX0 in trait." /// Docs for QUX0 in trait. const QUX0: u8; - // @has - '//*[@id="associatedconstant.QUX1"]' 'const QUX1: i8' - // @has - '//*[@class="docblock"]' "Docs for QUX1 in trait." + //@ has - '//*[@id="associatedconstant.QUX1"]' 'const QUX1: i8' + //@ has - '//*[@class="docblock"]' "Docs for QUX1 in trait." /// Docs for QUX1 in trait. const QUX1: i8; - // @has - '//*[@id="associatedconstant.QUX_DEFAULT0"]' 'const QUX_DEFAULT0: u16' - // @has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT12 in trait." + //@ has - '//*[@id="associatedconstant.QUX_DEFAULT0"]' 'const QUX_DEFAULT0: u16' + //@ has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT12 in trait." /// Docs for QUX_DEFAULT12 in trait. const QUX_DEFAULT0: u16 = 1; - // @has - '//*[@id="associatedconstant.QUX_DEFAULT1"]' 'const QUX_DEFAULT1: i16' - // @has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT1 in trait." + //@ has - '//*[@id="associatedconstant.QUX_DEFAULT1"]' 'const QUX_DEFAULT1: i16' + //@ has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT1 in trait." /// Docs for QUX_DEFAULT1 in trait. const QUX_DEFAULT1: i16 = 2; - // @has - '//*[@id="associatedconstant.QUX_DEFAULT2"]' 'const QUX_DEFAULT2: u32' - // @has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT2 in trait." + //@ has - '//*[@id="associatedconstant.QUX_DEFAULT2"]' 'const QUX_DEFAULT2: u32' + //@ has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT2 in trait." /// Docs for QUX_DEFAULT2 in trait. const QUX_DEFAULT2: u32 = 3; } -// @has assoc_consts/struct.Bar.html '//h3[@class="code-header"]' 'impl Qux for Bar' +//@ has assoc_consts/struct.Bar.html '//h3[@class="code-header"]' 'impl Qux for Bar' impl Qux for Bar { - // @has - '//*[@id="associatedconstant.QUX0"]' 'const QUX0: u8' - // @has - '//*[@class="docblock"]' "Docs for QUX0 in trait." + //@ has - '//*[@id="associatedconstant.QUX0"]' 'const QUX0: u8' + //@ has - '//*[@class="docblock"]' "Docs for QUX0 in trait." /// Docs for QUX0 in trait. const QUX0: u8 = 4; - // @has - '//*[@id="associatedconstant.QUX1"]' 'const QUX1: i8' - // @has - '//*[@class="docblock"]' "Docs for QUX1 in impl." + //@ has - '//*[@id="associatedconstant.QUX1"]' 'const QUX1: i8' + //@ has - '//*[@class="docblock"]' "Docs for QUX1 in impl." /// Docs for QUX1 in impl. const QUX1: i8 = 5; - // @has - '//*[@id="associatedconstant.QUX_DEFAULT0"]' 'const QUX_DEFAULT0: u16' - // @has - '//div[@class="impl-items"]//*[@class="docblock"]' "Docs for QUX_DEFAULT12 in trait." + //@ has - '//*[@id="associatedconstant.QUX_DEFAULT0"]' 'const QUX_DEFAULT0: u16' + //@ has - '//div[@class="impl-items"]//*[@class="docblock"]' "Docs for QUX_DEFAULT12 in trait." const QUX_DEFAULT0: u16 = 6; - // @has - '//*[@id="associatedconstant.QUX_DEFAULT1"]' 'const QUX_DEFAULT1: i16' - // @has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT1 in impl." + //@ has - '//*[@id="associatedconstant.QUX_DEFAULT1"]' 'const QUX_DEFAULT1: i16' + //@ has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT1 in impl." /// Docs for QUX_DEFAULT1 in impl. const QUX_DEFAULT1: i16 = 7; - // @has - '//*[@id="associatedconstant.QUX_DEFAULT2"]' 'const QUX_DEFAULT2: u32' - // @has - '//div[@class="impl-items"]//*[@class="docblock"]' "Docs for QUX_DEFAULT2 in trait." + //@ has - '//*[@id="associatedconstant.QUX_DEFAULT2"]' 'const QUX_DEFAULT2: u32' + //@ has - '//div[@class="impl-items"]//*[@class="docblock"]' "Docs for QUX_DEFAULT2 in trait." } diff --git a/tests/rustdoc/assoc-item-cast.rs b/tests/rustdoc/assoc-item-cast.rs index ad8235985bc..17b7cf6f0da 100644 --- a/tests/rustdoc/assoc-item-cast.rs +++ b/tests/rustdoc/assoc-item-cast.rs @@ -9,6 +9,6 @@ pub trait AsExpression<T> { fn as_expression(self) -> Self::Expression; } -// @has foo/type.AsExprOf.html -// @has - '//pre[@class="rust item-decl"]' 'type AsExprOf<Item, Type> = <Item as AsExpression<Type>>::Expression;' +//@ has foo/type.AsExprOf.html +//@ has - '//pre[@class="rust item-decl"]' 'type AsExprOf<Item, Type> = <Item as AsExpression<Type>>::Expression;' pub type AsExprOf<Item, Type> = <Item as AsExpression<Type>>::Expression; diff --git a/tests/rustdoc/assoc-type-bindings-20646.rs b/tests/rustdoc/assoc-type-bindings-20646.rs index 3d752551d1b..c79d07ff5bd 100644 --- a/tests/rustdoc/assoc-type-bindings-20646.rs +++ b/tests/rustdoc/assoc-type-bindings-20646.rs @@ -7,22 +7,22 @@ extern crate issue_20646; -// @has issue_20646/trait.Trait.html \ +//@ has issue_20646/trait.Trait.html \ // '//*[@id="associatedtype.Output"]' \ // 'type Output' pub trait Trait { type Output; } -// @has issue_20646/fn.fun.html \ +//@ has issue_20646/fn.fun.html \ // '//pre[@class="rust item-decl"]' 'where T: Trait<Output = i32>' pub fn fun<T>(_: T) where T: Trait<Output=i32> {} pub mod reexport { - // @has issue_20646/reexport/trait.Trait.html \ + //@ has issue_20646/reexport/trait.Trait.html \ // '//*[@id="associatedtype.Output"]' \ // 'type Output' - // @has issue_20646/reexport/fn.fun.html \ + //@ has issue_20646/reexport/fn.fun.html \ // '//pre[@class="rust item-decl"]' 'where T: Trait<Output = i32>' pub use issue_20646::{Trait, fun}; } diff --git a/tests/rustdoc/assoc-types.rs b/tests/rustdoc/assoc-types.rs index e74db7578d1..8247d8b91e8 100644 --- a/tests/rustdoc/assoc-types.rs +++ b/tests/rustdoc/assoc-types.rs @@ -1,19 +1,19 @@ #![crate_type="lib"] -// @has assoc_types/trait.Index.html +//@ has assoc_types/trait.Index.html pub trait Index<I: ?Sized> { - // @has - '//*[@id="associatedtype.Output"]//h4[@class="code-header"]' 'type Output: ?Sized' + //@ has - '//*[@id="associatedtype.Output"]//h4[@class="code-header"]' 'type Output: ?Sized' type Output: ?Sized; - // @has - '//*[@id="tymethod.index"]//h4[@class="code-header"]' \ + //@ has - '//*[@id="tymethod.index"]//h4[@class="code-header"]' \ // "fn index<'a>(&'a self, index: I) -> &'a Self::Output" - // @has - '//*[@id="tymethod.index"]//h4[@class="code-header"]//a[@href="trait.Index.html#associatedtype.Output"]' \ + //@ has - '//*[@id="tymethod.index"]//h4[@class="code-header"]//a[@href="trait.Index.html#associatedtype.Output"]' \ // "Output" fn index<'a>(&'a self, index: I) -> &'a Self::Output; } -// @has assoc_types/fn.use_output.html -// @has - '//pre[@class="rust item-decl"]' '-> &T::Output' -// @has - '//pre[@class="rust item-decl"]//a[@href="trait.Index.html#associatedtype.Output"]' 'Output' +//@ has assoc_types/fn.use_output.html +//@ has - '//pre[@class="rust item-decl"]' '-> &T::Output' +//@ has - '//pre[@class="rust item-decl"]//a[@href="trait.Index.html#associatedtype.Output"]' 'Output' pub fn use_output<T: Index<usize>>(obj: &T, index: usize) -> &T::Output { obj.index(index) } @@ -22,14 +22,14 @@ pub trait Feed { type Input; } -// @has assoc_types/fn.use_input.html -// @has - '//pre[@class="rust item-decl"]' 'T::Input' -// @has - '//pre[@class="rust item-decl"]//a[@href="trait.Feed.html#associatedtype.Input"]' 'Input' +//@ has assoc_types/fn.use_input.html +//@ has - '//pre[@class="rust item-decl"]' 'T::Input' +//@ has - '//pre[@class="rust item-decl"]//a[@href="trait.Feed.html#associatedtype.Input"]' 'Input' pub fn use_input<T: Feed>(_feed: &T, _element: T::Input) { } -// @has assoc_types/fn.cmp_input.html -// @has - '//pre[@class="rust item-decl"]' 'where T::Input: PartialEq<U::Input>' -// @has - '//pre[@class="rust item-decl"]//a[@href="trait.Feed.html#associatedtype.Input"]' 'Input' +//@ has assoc_types/fn.cmp_input.html +//@ has - '//pre[@class="rust item-decl"]' 'where T::Input: PartialEq<U::Input>' +//@ has - '//pre[@class="rust item-decl"]//a[@href="trait.Feed.html#associatedtype.Input"]' 'Input' pub fn cmp_input<T: Feed, U: Feed>(a: &T::Input, b: &U::Input) -> bool where T::Input: PartialEq<U::Input> { diff --git a/tests/rustdoc/associated-consts.rs b/tests/rustdoc/associated-consts.rs index adb155bb525..2a7269a89be 100644 --- a/tests/rustdoc/associated-consts.rs +++ b/tests/rustdoc/associated-consts.rs @@ -8,9 +8,9 @@ pub trait Trait { pub struct Bar; -// @has 'foo/struct.Bar.html' -// @!has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' -// @!has - '//div[@class="sidebar-elems"]//a' 'FOO' +//@ has 'foo/struct.Bar.html' +//@ !has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' +//@ !has - '//div[@class="sidebar-elems"]//a' 'FOO' impl Trait for Bar { const FOO: u32 = 1; @@ -21,9 +21,9 @@ pub enum Foo { A, } -// @has 'foo/enum.Foo.html' -// @!has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' -// @!has - '//div[@class="sidebar-elems"]//a' 'FOO' +//@ has 'foo/enum.Foo.html' +//@ !has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' +//@ !has - '//div[@class="sidebar-elems"]//a' 'FOO' impl Trait for Foo { const FOO: u32 = 1; @@ -32,9 +32,9 @@ impl Trait for Foo { pub struct Baz; -// @has 'foo/struct.Baz.html' -// @has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' -// @has - '//div[@class="sidebar-elems"]//a' 'FOO' +//@ has 'foo/struct.Baz.html' +//@ has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' +//@ has - '//div[@class="sidebar-elems"]//a' 'FOO' impl Baz { pub const FOO: u32 = 42; } @@ -43,9 +43,9 @@ pub enum Quux { B, } -// @has 'foo/enum.Quux.html' -// @has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' -// @has - '//div[@class="sidebar-elems"]//a' 'FOO' +//@ has 'foo/enum.Quux.html' +//@ has - '//div[@class="sidebar-elems"]//h3' 'Associated Constants' +//@ has - '//div[@class="sidebar-elems"]//a' 'FOO' impl Quux { pub const FOO: u32 = 42; } diff --git a/tests/rustdoc/async-fn-opaque-item.rs b/tests/rustdoc/async-fn-opaque-item.rs index 566c1c233ce..d45183f96dd 100644 --- a/tests/rustdoc/async-fn-opaque-item.rs +++ b/tests/rustdoc/async-fn-opaque-item.rs @@ -5,11 +5,11 @@ // that comes from an async fn desugaring. // Check that we don't document an unnamed opaque type -// @!has async_fn_opaque_item/opaque..html +//@ !has async_fn_opaque_item/opaque..html // Checking there is only a "Functions" header and no "Opaque types". -// @has async_fn_opaque_item/index.html -// @count - '//*[@class="section-header"]' 1 -// @has - '//*[@class="section-header"]' 'Functions' +//@ has async_fn_opaque_item/index.html +//@ count - '//*[@class="section-header"]' 1 +//@ has - '//*[@class="section-header"]' 'Functions' pub async fn test() {} diff --git a/tests/rustdoc/async-fn.rs b/tests/rustdoc/async-fn.rs index 4de5d8575b0..3d49766c55e 100644 --- a/tests/rustdoc/async-fn.rs +++ b/tests/rustdoc/async-fn.rs @@ -1,43 +1,43 @@ //@ edition:2018 -// @has async_fn/fn.foo.html '//pre[@class="rust item-decl"]' 'pub async fn foo() -> Option<Foo>' +//@ has async_fn/fn.foo.html '//pre[@class="rust item-decl"]' 'pub async fn foo() -> Option<Foo>' pub async fn foo() -> Option<Foo> { None } -// @has async_fn/fn.bar.html '//pre[@class="rust item-decl"]' 'pub async fn bar(a: i32, b: i32) -> i32' +//@ has async_fn/fn.bar.html '//pre[@class="rust item-decl"]' 'pub async fn bar(a: i32, b: i32) -> i32' pub async fn bar(a: i32, b: i32) -> i32 { 0 } -// @has async_fn/fn.baz.html '//pre[@class="rust item-decl"]' 'pub async fn baz<T>(a: T) -> T' +//@ has async_fn/fn.baz.html '//pre[@class="rust item-decl"]' 'pub async fn baz<T>(a: T) -> T' pub async fn baz<T>(a: T) -> T { a } -// @has async_fn/fn.qux.html '//pre[@class="rust item-decl"]' 'pub async unsafe fn qux() -> char' +//@ has async_fn/fn.qux.html '//pre[@class="rust item-decl"]' 'pub async unsafe fn qux() -> char' pub async unsafe fn qux() -> char { '⚠' } -// @has async_fn/fn.mut_args.html '//pre[@class="rust item-decl"]' 'pub async fn mut_args(a: usize)' +//@ has async_fn/fn.mut_args.html '//pre[@class="rust item-decl"]' 'pub async fn mut_args(a: usize)' pub async fn mut_args(mut a: usize) {} -// @has async_fn/fn.mut_ref.html '//pre[@class="rust item-decl"]' 'pub async fn mut_ref(x: i32)' +//@ has async_fn/fn.mut_ref.html '//pre[@class="rust item-decl"]' 'pub async fn mut_ref(x: i32)' pub async fn mut_ref(ref mut x: i32) {} trait Bar {} impl Bar for () {} -// @has async_fn/fn.quux.html '//pre[@class="rust item-decl"]' 'pub async fn quux() -> impl Bar' +//@ has async_fn/fn.quux.html '//pre[@class="rust item-decl"]' 'pub async fn quux() -> impl Bar' pub async fn quux() -> impl Bar { () } -// @has async_fn/struct.Foo.html -// @matches - '//h4[@class="code-header"]' 'pub async fn f\(\)$' -// @matches - '//h4[@class="code-header"]' 'pub async unsafe fn g\(\)$' -// @matches - '//h4[@class="code-header"]' 'pub async fn mut_self\(self, first: usize\)$' +//@ has async_fn/struct.Foo.html +//@ matches - '//h4[@class="code-header"]' 'pub async fn f\(\)$' +//@ matches - '//h4[@class="code-header"]' 'pub async unsafe fn g\(\)$' +//@ matches - '//h4[@class="code-header"]' 'pub async fn mut_self\(self, first: usize\)$' pub struct Foo; impl Foo { @@ -51,49 +51,49 @@ pub trait Pattern<'a> {} impl Pattern<'_> for () {} pub trait Trait<const N: usize> {} -// @has async_fn/fn.const_generics.html -// @has - '//pre[@class="rust item-decl"]' 'pub async fn const_generics<const N: usize>(_: impl Trait<N>)' +//@ has async_fn/fn.const_generics.html +//@ has - '//pre[@class="rust item-decl"]' 'pub async fn const_generics<const N: usize>(_: impl Trait<N>)' pub async fn const_generics<const N: usize>(_: impl Trait<N>) {} // test that elided lifetimes are properly elided and not displayed as `'_` // regression test for #63037 -// @has async_fn/fn.elided.html -// @has - '//pre[@class="rust item-decl"]' 'pub async fn elided(foo: &str) -> &str' +//@ has async_fn/fn.elided.html +//@ has - '//pre[@class="rust item-decl"]' 'pub async fn elided(foo: &str) -> &str' pub async fn elided(foo: &str) -> &str { "" } // This should really be shown as written, but for implementation reasons it's difficult. // See `impl Clean for TyKind::Ref`. -// @has async_fn/fn.user_elided.html -// @has - '//pre[@class="rust item-decl"]' 'pub async fn user_elided(foo: &str) -> &str' +//@ has async_fn/fn.user_elided.html +//@ has - '//pre[@class="rust item-decl"]' 'pub async fn user_elided(foo: &str) -> &str' pub async fn user_elided(foo: &'_ str) -> &str { "" } -// @has async_fn/fn.static_trait.html -// @has - '//pre[@class="rust item-decl"]' 'pub async fn static_trait(foo: &str) -> Box<dyn Bar>' +//@ has async_fn/fn.static_trait.html +//@ has - '//pre[@class="rust item-decl"]' 'pub async fn static_trait(foo: &str) -> Box<dyn Bar>' pub async fn static_trait(foo: &str) -> Box<dyn Bar> { Box::new(()) } -// @has async_fn/fn.lifetime_for_trait.html -// @has - '//pre[@class="rust item-decl"]' "pub async fn lifetime_for_trait(foo: &str) -> Box<dyn Bar + '_>" +//@ has async_fn/fn.lifetime_for_trait.html +//@ has - '//pre[@class="rust item-decl"]' "pub async fn lifetime_for_trait(foo: &str) -> Box<dyn Bar + '_>" pub async fn lifetime_for_trait(foo: &str) -> Box<dyn Bar + '_> { Box::new(()) } -// @has async_fn/fn.elided_in_input_trait.html -// @has - '//pre[@class="rust item-decl"]' "pub async fn elided_in_input_trait(t: impl Pattern<'_>)" +//@ has async_fn/fn.elided_in_input_trait.html +//@ has - '//pre[@class="rust item-decl"]' "pub async fn elided_in_input_trait(t: impl Pattern<'_>)" pub async fn elided_in_input_trait(t: impl Pattern<'_>) {} struct AsyncFdReadyGuard<'a, T> { x: &'a T } impl Foo { - // @has async_fn/struct.Foo.html - // @has - '//*[@class="method"]' 'pub async fn complicated_lifetimes( &self, context: &impl Bar, ) -> impl Iterator<Item = &usize>' + //@ has async_fn/struct.Foo.html + //@ has - '//*[@class="method"]' 'pub async fn complicated_lifetimes( &self, context: &impl Bar, ) -> impl Iterator<Item = &usize>' pub async fn complicated_lifetimes(&self, context: &impl Bar) -> impl Iterator<Item = &usize> { [0].iter() } // taken from `tokio` as an example of a method that was particularly bad before - // @has - '//*[@class="method"]' "pub async fn readable<T>(&self) -> Result<AsyncFdReadyGuard<'_, T>, ()>" + //@ has - '//*[@class="method"]' "pub async fn readable<T>(&self) -> Result<AsyncFdReadyGuard<'_, T>, ()>" pub async fn readable<T>(&self) -> Result<AsyncFdReadyGuard<'_, T>, ()> { Err(()) } - // @has - '//*[@class="method"]' "pub async fn mut_self(&mut self)" + //@ has - '//*[@class="method"]' "pub async fn mut_self(&mut self)" pub async fn mut_self(&mut self) {} } // test named lifetimes, just in case -// @has async_fn/fn.named.html -// @has - '//pre[@class="rust item-decl"]' "pub async fn named<'a, 'b>(foo: &'a str) -> &'b str" +//@ has async_fn/fn.named.html +//@ has - '//pre[@class="rust item-decl"]' "pub async fn named<'a, 'b>(foo: &'a str) -> &'b str" pub async fn named<'a, 'b>(foo: &'a str) -> &'b str { "" } -// @has async_fn/fn.named_trait.html -// @has - '//pre[@class="rust item-decl"]' "pub async fn named_trait<'a, 'b>(foo: impl Pattern<'a>) -> impl Pattern<'b>" +//@ has async_fn/fn.named_trait.html +//@ has - '//pre[@class="rust item-decl"]' "pub async fn named_trait<'a, 'b>(foo: impl Pattern<'a>) -> impl Pattern<'b>" pub async fn named_trait<'a, 'b>(foo: impl Pattern<'a>) -> impl Pattern<'b> {} diff --git a/tests/rustdoc/async-trait-sig.rs b/tests/rustdoc/async-trait-sig.rs index 40e68ce9b3c..be790f6ed7f 100644 --- a/tests/rustdoc/async-trait-sig.rs +++ b/tests/rustdoc/async-trait-sig.rs @@ -3,10 +3,10 @@ #![allow(incomplete_features)] pub trait Foo { - // @has async_trait_sig/trait.Foo.html '//h4[@class="code-header"]' "async fn bar() -> i32" + //@ has async_trait_sig/trait.Foo.html '//h4[@class="code-header"]' "async fn bar() -> i32" async fn bar() -> i32; - // @has async_trait_sig/trait.Foo.html '//h4[@class="code-header"]' "async fn baz() -> i32" + //@ has async_trait_sig/trait.Foo.html '//h4[@class="code-header"]' "async fn baz() -> i32" async fn baz() -> i32 { 1 } diff --git a/tests/rustdoc/async-trait.rs b/tests/rustdoc/async-trait.rs index 980a812815b..a6ee340e2dd 100644 --- a/tests/rustdoc/async-trait.rs +++ b/tests/rustdoc/async-trait.rs @@ -7,7 +7,7 @@ extern crate async_trait_dep; pub struct Oink {} -// @has 'async_trait/struct.Oink.html' '//h4[@class="code-header"]' "async fn woof()" +//@ has 'async_trait/struct.Oink.html' '//h4[@class="code-header"]' "async fn woof()" impl async_trait_dep::Meow for Oink { async fn woof() { todo!() diff --git a/tests/rustdoc/attribute-rendering.rs b/tests/rustdoc/attribute-rendering.rs index a652fda1604..841533814c3 100644 --- a/tests/rustdoc/attribute-rendering.rs +++ b/tests/rustdoc/attribute-rendering.rs @@ -1,7 +1,7 @@ #![crate_name = "foo"] -// @has 'foo/fn.f.html' -// @has - //*[@'class="rust item-decl"]' '#[export_name = "f"] pub fn f()' +//@ has 'foo/fn.f.html' +//@ has - //*[@'class="rust item-decl"]' '#[export_name = "f"] pub fn f()' #[export_name = "\ f"] pub fn f() {} diff --git a/tests/rustdoc/attributes.rs b/tests/rustdoc/attributes.rs index 86333c7534a..e34468a88b1 100644 --- a/tests/rustdoc/attributes.rs +++ b/tests/rustdoc/attributes.rs @@ -1,13 +1,13 @@ #![crate_name = "foo"] -// @has foo/fn.f.html '//pre[@class="rust item-decl"]' '#[no_mangle]' +//@ has foo/fn.f.html '//pre[@class="rust item-decl"]' '#[no_mangle]' #[no_mangle] pub extern "C" fn f() {} -// @has foo/fn.g.html '//pre[@class="rust item-decl"]' '#[export_name = "bar"]' +//@ has foo/fn.g.html '//pre[@class="rust item-decl"]' '#[export_name = "bar"]' #[export_name = "bar"] pub extern "C" fn g() {} -// @has foo/struct.Repr.html '//pre[@class="rust item-decl"]' '#[repr(C, align(8))]' +//@ has foo/struct.Repr.html '//pre[@class="rust item-decl"]' '#[repr(C, align(8))]' #[repr(C, align(8))] pub struct Repr; diff --git a/tests/rustdoc/auto-impl-primitive.rs b/tests/rustdoc/auto-impl-primitive.rs index a6db93dbc33..3dab02506ca 100644 --- a/tests/rustdoc/auto-impl-primitive.rs +++ b/tests/rustdoc/auto-impl-primitive.rs @@ -4,7 +4,7 @@ pub use std::fs::File; -// @has 'foo/primitive.i16.html' '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementation' +//@ has 'foo/primitive.i16.html' '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementation' #[rustc_doc_primitive = "i16"] /// I love poneys! mod prim {} diff --git a/tests/rustdoc/auto-trait-bounds-by-associated-type-50159.rs b/tests/rustdoc/auto-trait-bounds-by-associated-type-50159.rs index 7d9133b85a6..2803c4da437 100644 --- a/tests/rustdoc/auto-trait-bounds-by-associated-type-50159.rs +++ b/tests/rustdoc/auto-trait-bounds-by-associated-type-50159.rs @@ -16,11 +16,11 @@ where type Item2 = C; } -// @has foo/struct.Switch.html -// @has - '//h3[@class="code-header"]' 'impl<B> Send for Switch<B>where <B as Signal>::Item: Send' -// @has - '//h3[@class="code-header"]' 'impl<B> Sync for Switch<B>where <B as Signal>::Item: Sync' -// @count - '//*[@id="implementations-list"]//*[@class="impl"]' 0 -// @count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 6 +//@ has foo/struct.Switch.html +//@ has - '//h3[@class="code-header"]' 'impl<B> Send for Switch<B>where <B as Signal>::Item: Send' +//@ has - '//h3[@class="code-header"]' 'impl<B> Sync for Switch<B>where <B as Signal>::Item: Sync' +//@ count - '//*[@id="implementations-list"]//*[@class="impl"]' 0 +//@ count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 6 pub struct Switch<B: Signal> { pub inner: <B as Signal2>::Item2, } diff --git a/tests/rustdoc/auto-trait-bounds-inference-variables-54705.rs b/tests/rustdoc/auto-trait-bounds-inference-variables-54705.rs index 00be0042fb0..ef159fca872 100644 --- a/tests/rustdoc/auto-trait-bounds-inference-variables-54705.rs +++ b/tests/rustdoc/auto-trait-bounds-inference-variables-54705.rs @@ -3,11 +3,11 @@ pub trait ScopeHandle<'scope> {} -// @has foo/struct.ScopeFutureContents.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has foo/struct.ScopeFutureContents.html +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<'scope, S> Send for ScopeFutureContents<'scope, S>where S: Sync" // -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<'scope, S> Sync for ScopeFutureContents<'scope, S>where S: Sync" pub struct ScopeFutureContents<'scope, S> where S: ScopeHandle<'scope>, diff --git a/tests/rustdoc/auto-trait-bounds-where-51236.rs b/tests/rustdoc/auto-trait-bounds-where-51236.rs index 30c81e79601..c892b6d0abf 100644 --- a/tests/rustdoc/auto-trait-bounds-where-51236.rs +++ b/tests/rustdoc/auto-trait-bounds-where-51236.rs @@ -9,8 +9,8 @@ pub mod traits { } } -// @has foo/struct.Owned.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has foo/struct.Owned.html +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<T> Send for Owned<T>where <T as Owned<'static>>::Reader: Send" pub struct Owned<T> where T: for<'a> ::traits::Owned<'a> { marker: PhantomData<<T as ::traits::Owned<'static>>::Reader>, diff --git a/tests/rustdoc/auto-trait-negative-impl-55321.rs b/tests/rustdoc/auto-trait-negative-impl-55321.rs index e9be1ff854e..147f44da117 100644 --- a/tests/rustdoc/auto-trait-negative-impl-55321.rs +++ b/tests/rustdoc/auto-trait-negative-impl-55321.rs @@ -3,19 +3,19 @@ #![feature(negative_impls)] -// @has foo/struct.A.html -// @has - '//*[@id="trait-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has foo/struct.A.html +//@ has - '//*[@id="trait-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // "impl !Send for A" -// @has - '//*[@id="trait-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has - '//*[@id="trait-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // "impl !Sync for A" pub struct A(); impl !Send for A {} impl !Sync for A {} -// @has foo/struct.B.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has foo/struct.B.html +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<T> !Send for B<T>" -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<T> !Sync for B<T>" pub struct B<T: ?Sized>(A, Box<T>); diff --git a/tests/rustdoc/auto-trait-not-send.rs b/tests/rustdoc/auto-trait-not-send.rs index 661d905ab63..0a31952f5e1 100644 --- a/tests/rustdoc/auto-trait-not-send.rs +++ b/tests/rustdoc/auto-trait-not-send.rs @@ -1,8 +1,8 @@ #![crate_name = "foo"] -// @has 'foo/struct.Foo.html' -// @has - '//*[@id="impl-Send-for-Foo"]' 'impl !Send for Foo' -// @has - '//*[@id="impl-Sync-for-Foo"]' 'impl !Sync for Foo' +//@ has 'foo/struct.Foo.html' +//@ has - '//*[@id="impl-Send-for-Foo"]' 'impl !Send for Foo' +//@ has - '//*[@id="impl-Sync-for-Foo"]' 'impl !Sync for Foo' pub struct Foo(*const i8); pub trait Whatever: Send {} impl<T: Send + ?Sized> Whatever for T {} diff --git a/tests/rustdoc/auto-traits.rs b/tests/rustdoc/auto-traits.rs index 01439c8601b..dce406ed3e3 100644 --- a/tests/rustdoc/auto-traits.rs +++ b/tests/rustdoc/auto-traits.rs @@ -6,8 +6,8 @@ extern crate auto_traits; -// @has 'foo/trait.Foo.html' '//pre' 'pub unsafe auto trait Foo' +//@ has 'foo/trait.Foo.html' '//pre' 'pub unsafe auto trait Foo' pub unsafe auto trait Foo {} -// @has 'foo/trait.Bar.html' '//pre' 'pub unsafe auto trait Bar' +//@ has 'foo/trait.Bar.html' '//pre' 'pub unsafe auto trait Bar' pub use auto_traits::Bar; diff --git a/tests/rustdoc/auto_aliases.rs b/tests/rustdoc/auto_aliases.rs index a047c76b637..920aba805cd 100644 --- a/tests/rustdoc/auto_aliases.rs +++ b/tests/rustdoc/auto_aliases.rs @@ -1,6 +1,6 @@ #![feature(auto_traits)] -// @has auto_aliases/trait.Bar.html '//*[@data-aliases="auto_aliases::Foo"]' 'impl Bar for Foo' +//@ has auto_aliases/trait.Bar.html '//*[@data-aliases="auto_aliases::Foo"]' 'impl Bar for Foo' pub struct Foo; pub auto trait Bar {} diff --git a/tests/rustdoc/auxiliary/alias-reexport2.rs b/tests/rustdoc/auxiliary/alias-reexport2.rs index 9f6910572ad..ee1f242c1d4 100644 --- a/tests/rustdoc/auxiliary/alias-reexport2.rs +++ b/tests/rustdoc/auxiliary/alias-reexport2.rs @@ -4,9 +4,9 @@ extern crate alias_reexport; pub use alias_reexport::Reexported; -// @has 'foo/fn.foo.html' -// @has - '//*[@class="docblock item-decl"]' 'pub fn foo() -> Reexported' +//@ has 'foo/fn.foo.html' +//@ has - '//*[@class="docblock item-decl"]' 'pub fn foo() -> Reexported' pub fn foo() -> Reexported { 0 } -// @has 'foo/fn.foo2.html' -// @has - '//*[@class="docblock item-decl"]' 'pub fn foo2() -> Result<Reexported, ()>' +//@ has 'foo/fn.foo2.html' +//@ has - '//*[@class="docblock item-decl"]' 'pub fn foo2() -> Result<Reexported, ()>' pub fn foo2() -> Result<Reexported, ()> { Ok(0) } diff --git a/tests/rustdoc/auxiliary/rustdoc-ffi.rs b/tests/rustdoc/auxiliary/rustdoc-ffi.rs index b74d190b526..98e2b55699a 100644 --- a/tests/rustdoc/auxiliary/rustdoc-ffi.rs +++ b/tests/rustdoc/auxiliary/rustdoc-ffi.rs @@ -1,6 +1,6 @@ #![crate_type="lib"] extern "C" { - // @has lib/fn.foreigner.html //pre 'pub unsafe fn foreigner(cold_as_ice: u32)' + //@ has lib/fn.foreigner.html //pre 'pub unsafe fn foreigner(cold_as_ice: u32)' pub fn foreigner(cold_as_ice: u32); } diff --git a/tests/rustdoc/bad-codeblock-syntax.rs b/tests/rustdoc/bad-codeblock-syntax.rs index 9ec089fd7ad..b14aca20679 100644 --- a/tests/rustdoc/bad-codeblock-syntax.rs +++ b/tests/rustdoc/bad-codeblock-syntax.rs @@ -1,43 +1,43 @@ #![allow(rustdoc::invalid_rust_codeblocks)] -// @has bad_codeblock_syntax/fn.foo.html -// @has - '//*[@class="docblock"]' '\_' +//@ has bad_codeblock_syntax/fn.foo.html +//@ has - '//*[@class="docblock"]' '\_' /// ``` /// \_ /// ``` pub fn foo() {} -// @has bad_codeblock_syntax/fn.bar.html -// @has - '//*[@class="docblock"]' '`baz::foobar`' +//@ has bad_codeblock_syntax/fn.bar.html +//@ has - '//*[@class="docblock"]' '`baz::foobar`' /// ``` /// `baz::foobar` /// ``` pub fn bar() {} -// @has bad_codeblock_syntax/fn.quux.html -// @has - '//*[@class="docblock"]' '\_' +//@ has bad_codeblock_syntax/fn.quux.html +//@ has - '//*[@class="docblock"]' '\_' /// ```rust /// \_ /// ``` pub fn quux() {} -// @has bad_codeblock_syntax/fn.ok.html -// @has - '//*[@class="docblock"]' '\_' +//@ has bad_codeblock_syntax/fn.ok.html +//@ has - '//*[@class="docblock"]' '\_' /// ```text /// \_ /// ``` pub fn ok() {} -// @has bad_codeblock_syntax/fn.escape.html -// @has - '//*[@class="docblock"]' '\_ <script>alert("not valid Rust");</script>' +//@ has bad_codeblock_syntax/fn.escape.html +//@ has - '//*[@class="docblock"]' '\_ <script>alert("not valid Rust");</script>' /// ``` /// \_ /// <script>alert("not valid Rust");</script> /// ``` pub fn escape() {} -// @has bad_codeblock_syntax/fn.unterminated.html -// @has - '//*[@class="docblock"]' '"unterminated' +//@ has bad_codeblock_syntax/fn.unterminated.html +//@ has - '//*[@class="docblock"]' '"unterminated' /// ``` /// "unterminated /// ``` diff --git a/tests/rustdoc/blank-line-in-doc-block-47197.rs b/tests/rustdoc/blank-line-in-doc-block-47197.rs index 79492b4fa76..c35e6d2fe5c 100644 --- a/tests/rustdoc/blank-line-in-doc-block-47197.rs +++ b/tests/rustdoc/blank-line-in-doc-block-47197.rs @@ -1,7 +1,7 @@ // https://github.com/rust-lang/rust/issues/47197 #![crate_name="foo"] -// @has foo/fn.whose_woods_these_are_i_think_i_know.html +//@ has foo/fn.whose_woods_these_are_i_think_i_know.html /** * snow diff --git a/tests/rustdoc/blanket-impl-29503.rs b/tests/rustdoc/blanket-impl-29503.rs index d6a132e1c26..f43fe79ca58 100644 --- a/tests/rustdoc/blanket-impl-29503.rs +++ b/tests/rustdoc/blanket-impl-29503.rs @@ -3,12 +3,12 @@ use std::fmt; -// @has issue_29503/trait.MyTrait.html +//@ has issue_29503/trait.MyTrait.html pub trait MyTrait { fn my_string(&self) -> String; } -// @has - "//div[@id='implementors-list']//*[@id='impl-MyTrait-for-T']//h3[@class='code-header']" "impl<T> MyTrait for Twhere T: Debug" +//@ has - "//div[@id='implementors-list']//*[@id='impl-MyTrait-for-T']//h3[@class='code-header']" "impl<T> MyTrait for Twhere T: Debug" impl<T> MyTrait for T where T: fmt::Debug, diff --git a/tests/rustdoc/blanket-impl-78673.rs b/tests/rustdoc/blanket-impl-78673.rs index d7ceef2c057..412d4057406 100644 --- a/tests/rustdoc/blanket-impl-78673.rs +++ b/tests/rustdoc/blanket-impl-78673.rs @@ -7,18 +7,18 @@ pub trait AnAmazingTrait {} impl<T: Something> AnAmazingTrait for T {} -// @has 'issue_78673/struct.MyStruct.html' -// @has - '//*[@class="impl"]' 'AnAmazingTrait for MyStruct' -// @!has - '//*[@class="impl"]' 'AnAmazingTrait for T' +//@ has 'issue_78673/struct.MyStruct.html' +//@ has - '//*[@class="impl"]' 'AnAmazingTrait for MyStruct' +//@ !has - '//*[@class="impl"]' 'AnAmazingTrait for T' pub struct MyStruct; impl AnAmazingTrait for MyStruct {} // generic structs may have _both_ specific and blanket impls that apply -// @has 'issue_78673/struct.AnotherStruct.html' -// @has - '//*[@class="impl"]' 'AnAmazingTrait for AnotherStruct<()>' -// @has - '//*[@class="impl"]' 'AnAmazingTrait for T' +//@ has 'issue_78673/struct.AnotherStruct.html' +//@ has - '//*[@class="impl"]' 'AnAmazingTrait for AnotherStruct<()>' +//@ has - '//*[@class="impl"]' 'AnAmazingTrait for T' pub struct AnotherStruct<T>(T); impl<T: Something> Something for AnotherStruct<T> {} diff --git a/tests/rustdoc/blanket-reexport-item.rs b/tests/rustdoc/blanket-reexport-item.rs index 315a38c30c5..199a47019a2 100644 --- a/tests/rustdoc/blanket-reexport-item.rs +++ b/tests/rustdoc/blanket-reexport-item.rs @@ -1,6 +1,6 @@ #![crate_name = "foo"] -// @has foo/struct.S.html '//*[@id="impl-Into%3CU%3E-for-T"]//h3[@class="code-header"]' 'impl<T, U> Into<U> for T' +//@ has foo/struct.S.html '//*[@id="impl-Into%3CU%3E-for-T"]//h3[@class="code-header"]' 'impl<T, U> Into<U> for T' pub struct S2 {} mod m { pub struct S {} diff --git a/tests/rustdoc/bounds.rs b/tests/rustdoc/bounds.rs index da09e3f2a52..8213ab96241 100644 --- a/tests/rustdoc/bounds.rs +++ b/tests/rustdoc/bounds.rs @@ -4,16 +4,16 @@ pub trait Eq {} pub trait Eq2 {} // Checking that "where predicates" and "generics params" are merged. -// @has 'foo/trait.T.html' -// @has - "//*[@id='tymethod.f']/h4" "fn f<'a, 'b, 'c, T>()where Self: Eq, T: Eq + 'a, 'c: 'b + 'a," +//@ has 'foo/trait.T.html' +//@ has - "//*[@id='tymethod.f']/h4" "fn f<'a, 'b, 'c, T>()where Self: Eq, T: Eq + 'a, 'c: 'b + 'a," pub trait T { fn f<'a, 'b, 'c: 'a, T: Eq + 'a>() where Self: Eq, Self: Eq, T: Eq, 'c: 'b; } // Checking that a duplicated "where predicate" is removed. -// @has 'foo/trait.T2.html' -// @has - "//*[@id='tymethod.f']/h4" "fn f<T>()where Self: Eq + Eq2, T: Eq2 + Eq," +//@ has 'foo/trait.T2.html' +//@ has - "//*[@id='tymethod.f']/h4" "fn f<T>()where Self: Eq + Eq2, T: Eq2 + Eq," pub trait T2 { fn f<T: Eq>() where Self: Eq, Self: Eq2, T: Eq2; @@ -23,8 +23,8 @@ pub trait T2 { // Note that we don't want to hide them since they have a semantic effect. // For outlives-bounds, they force the lifetime param to be early-bound instead of late-bound. // For trait bounds, it can affect well-formedness (see `ClauseKind::WellFormed`). -// @has 'foo/fn.empty.html' -// @has - '//pre[@class="rust item-decl"]' "empty<'a, T>()where T:, 'a:," +//@ has 'foo/fn.empty.html' +//@ has - '//pre[@class="rust item-decl"]' "empty<'a, T>()where T:, 'a:," pub fn empty<'a, T>() where T:, diff --git a/tests/rustdoc/cap-lints.rs b/tests/rustdoc/cap-lints.rs index 08a35339680..30f9be0424c 100644 --- a/tests/rustdoc/cap-lints.rs +++ b/tests/rustdoc/cap-lints.rs @@ -3,7 +3,7 @@ // therefore should not concern itself with the lints. #[deny(warnings)] -// @has cap_lints/struct.Foo.html //* 'Foo' +//@ has cap_lints/struct.Foo.html //* 'Foo' pub struct Foo { field: i32, } diff --git a/tests/rustdoc/cfg-doctest.rs b/tests/rustdoc/cfg-doctest.rs index 6a9d26a4bb7..a2272e6ca00 100644 --- a/tests/rustdoc/cfg-doctest.rs +++ b/tests/rustdoc/cfg-doctest.rs @@ -1,5 +1,5 @@ -// @!has cfg_doctest/struct.SomeStruct.html -// @!has cfg_doctest/index.html '//a/@href' 'struct.SomeStruct.html' +//@ !has cfg_doctest/struct.SomeStruct.html +//@ !has cfg_doctest/index.html '//a/@href' 'struct.SomeStruct.html' /// Sneaky, this isn't actually part of docs. #[cfg(doctest)] diff --git a/tests/rustdoc/cfg_doc_reexport.rs b/tests/rustdoc/cfg_doc_reexport.rs index a10c84f2cac..a07e4fe2f02 100644 --- a/tests/rustdoc/cfg_doc_reexport.rs +++ b/tests/rustdoc/cfg_doc_reexport.rs @@ -4,14 +4,14 @@ #![crate_name = "foo"] #![no_core] -// @has 'foo/index.html' -// @has - '//*[@class="item-name"]/*[@class="stab portability"]' 'foobar' -// @has - '//*[@class="item-name"]/*[@class="stab portability"]' 'bar' +//@ has 'foo/index.html' +//@ has - '//*[@class="item-name"]/*[@class="stab portability"]' 'foobar' +//@ has - '//*[@class="item-name"]/*[@class="stab portability"]' 'bar' #[doc(cfg(feature = "foobar"))] mod imp_priv { - // @has 'foo/struct.BarPriv.html' - // @has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ + //@ has 'foo/struct.BarPriv.html' + //@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ // 'Available on crate feature foobar only.' pub struct BarPriv {} impl BarPriv { @@ -22,8 +22,8 @@ mod imp_priv { pub use crate::imp_priv::*; pub mod bar { - // @has 'foo/bar/struct.Bar.html' - // @has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ + //@ has 'foo/bar/struct.Bar.html' + //@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ // 'Available on crate feature bar only.' #[doc(cfg(feature = "bar"))] pub struct Bar; diff --git a/tests/rustdoc/check-source-code-urls-to-def-std.rs b/tests/rustdoc/check-source-code-urls-to-def-std.rs index fac2a94b815..42468f7dde6 100644 --- a/tests/rustdoc/check-source-code-urls-to-def-std.rs +++ b/tests/rustdoc/check-source-code-urls-to-def-std.rs @@ -2,14 +2,14 @@ #![crate_name = "foo"] -// @has 'src/foo/check-source-code-urls-to-def-std.rs.html' +//@ has 'src/foo/check-source-code-urls-to-def-std.rs.html' fn babar() {} -// @has - '//a[@href="{{channel}}/std/primitive.u32.html"]' 'u32' -// @has - '//a[@href="{{channel}}/std/primitive.str.html"]' 'str' -// @has - '//a[@href="{{channel}}/std/primitive.bool.html"]' 'bool' -// @has - '//a[@href="#7"]' 'babar' +//@ has - '//a[@href="{{channel}}/std/primitive.u32.html"]' 'u32' +//@ has - '//a[@href="{{channel}}/std/primitive.str.html"]' 'str' +//@ has - '//a[@href="{{channel}}/std/primitive.bool.html"]' 'bool' +//@ has - '//a[@href="#7"]' 'babar' pub fn foo(a: u32, b: &str, c: String) { let x = 12; let y: bool = true; @@ -31,12 +31,12 @@ macro_rules! data { pub fn another_foo() { // This is known limitation: if the macro doesn't generate anything, the visitor // can't find any item or anything that could tell us that it comes from expansion. - // @!has - '//a[@href="#19"]' 'yolo!' + //@ !has - '//a[@href="#19"]' 'yolo!' yolo!(); - // @has - '//a[@href="{{channel}}/std/macro.eprintln.html"]' 'eprintln!' + //@ has - '//a[@href="{{channel}}/std/macro.eprintln.html"]' 'eprintln!' eprintln!(); - // @has - '//a[@href="#27-29"]' 'data!' + //@ has - '//a[@href="#27-29"]' 'data!' let x = data!(4); - // @has - '//a[@href="#23-25"]' 'bar!' + //@ has - '//a[@href="#23-25"]' 'bar!' bar!(x); } diff --git a/tests/rustdoc/check-source-code-urls-to-def.rs b/tests/rustdoc/check-source-code-urls-to-def.rs index 30638992ac7..8703287abc5 100644 --- a/tests/rustdoc/check-source-code-urls-to-def.rs +++ b/tests/rustdoc/check-source-code-urls-to-def.rs @@ -8,16 +8,16 @@ extern crate source_code; -// @has 'src/foo/check-source-code-urls-to-def.rs.html' +//@ has 'src/foo/check-source-code-urls-to-def.rs.html' -// @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#1-17"]' 'bar' +//@ has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#1-17"]' 'bar' #[path = "auxiliary/source-code-bar.rs"] pub mod bar; -// @count - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#5-7"]' 4 +//@ count - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#5-7"]' 4 use bar::Bar; -// @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#13-17"]' 'self' -// @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14-16"]' 'Trait' +//@ has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#13-17"]' 'self' +//@ has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14-16"]' 'Trait' use bar::sub::{self, Trait}; pub struct Foo; @@ -28,30 +28,30 @@ impl Foo { fn babar() {} -// @has - '//pre[@class="rust"]//a/@href' '/struct.String.html' -// @has - '//pre[@class="rust"]//a/@href' '/primitive.u32.html' -// @has - '//pre[@class="rust"]//a/@href' '/primitive.str.html' -// @count - '//pre[@class="rust"]//a[@href="#23"]' 5 -// @has - '//pre[@class="rust"]//a[@href="../../source_code/struct.SourceCode.html"]' \ +//@ has - '//pre[@class="rust"]//a/@href' '/struct.String.html' +//@ has - '//pre[@class="rust"]//a/@href' '/primitive.u32.html' +//@ has - '//pre[@class="rust"]//a/@href' '/primitive.str.html' +//@ count - '//pre[@class="rust"]//a[@href="#23"]' 5 +//@ has - '//pre[@class="rust"]//a[@href="../../source_code/struct.SourceCode.html"]' \ // 'source_code::SourceCode' pub fn foo(a: u32, b: &str, c: String, d: Foo, e: bar::Bar, f: source_code::SourceCode) { let x = 12; let y: Foo = Foo; let z: Bar = bar::Bar { field: Foo }; babar(); - // @has - '//pre[@class="rust"]//a[@href="#26"]' 'hello' + //@ has - '//pre[@class="rust"]//a[@href="#26"]' 'hello' y.hello(); } -// @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14-16"]' 'bar::sub::Trait' -// @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14-16"]' 'Trait' +//@ has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14-16"]' 'bar::sub::Trait' +//@ has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14-16"]' 'Trait' pub fn foo2<T: bar::sub::Trait, V: Trait>(t: &T, v: &V, b: bool) {} pub trait AnotherTrait {} pub trait WhyNot {} -// @has - '//pre[@class="rust"]//a[@href="#50"]' 'AnotherTrait' -// @has - '//pre[@class="rust"]//a[@href="#51"]' 'WhyNot' +//@ has - '//pre[@class="rust"]//a[@href="#50"]' 'AnotherTrait' +//@ has - '//pre[@class="rust"]//a[@href="#51"]' 'WhyNot' pub fn foo3<T, V>(t: &T, v: &V) where T: AnotherTrait, @@ -60,11 +60,11 @@ where pub trait AnotherTrait2 {} -// @has - '//pre[@class="rust"]//a[@href="#61"]' 'AnotherTrait2' +//@ has - '//pre[@class="rust"]//a[@href="#61"]' 'AnotherTrait2' pub fn foo4() { let x: Vec<&dyn AnotherTrait2> = Vec::new(); } -// @has - '//pre[@class="rust"]//a[@href="../../foo/primitive.bool.html"]' 'bool' +//@ has - '//pre[@class="rust"]//a[@href="../../foo/primitive.bool.html"]' 'bool' #[rustc_doc_primitive = "bool"] mod whatever {} diff --git a/tests/rustdoc/check-styled-link.rs b/tests/rustdoc/check-styled-link.rs index ed4a5ea2137..a74a3c9466f 100644 --- a/tests/rustdoc/check-styled-link.rs +++ b/tests/rustdoc/check-styled-link.rs @@ -2,7 +2,7 @@ pub struct Foo; -// @has foo/struct.Bar.html '//a[@href="struct.Foo.html"]' 'Foo' +//@ has foo/struct.Bar.html '//a[@href="struct.Foo.html"]' 'Foo' /// Code-styled reference to [`Foo`]. pub struct Bar; diff --git a/tests/rustdoc/check.rs b/tests/rustdoc/check.rs index 9ca85a123f7..c083e10f657 100644 --- a/tests/rustdoc/check.rs +++ b/tests/rustdoc/check.rs @@ -1,5 +1,5 @@ //@ compile-flags: -Z unstable-options --check -// @!has check/fn.foo.html -// @!has check/index.html +//@ !has check/fn.foo.html +//@ !has check/index.html pub fn foo() {} diff --git a/tests/rustdoc/codeblock-title.rs b/tests/rustdoc/codeblock-title.rs index 761afb8bd08..22124869d6e 100644 --- a/tests/rustdoc/codeblock-title.rs +++ b/tests/rustdoc/codeblock-title.rs @@ -1,9 +1,9 @@ #![crate_name = "foo"] -// @has foo/fn.bar.html '//*[@class="example-wrap compile_fail"]/*[@class="tooltip"]' "ⓘ" -// @has foo/fn.bar.html '//*[@class="example-wrap ignore"]/*[@class="tooltip"]' "ⓘ" -// @has foo/fn.bar.html '//*[@class="example-wrap should_panic"]/*[@class="tooltip"]' "ⓘ" -// @has foo/fn.bar.html '//*[@title="This example runs with edition 2018"]' "ⓘ" +//@ has foo/fn.bar.html '//*[@class="example-wrap compile_fail"]/*[@class="tooltip"]' "ⓘ" +//@ has foo/fn.bar.html '//*[@class="example-wrap ignore"]/*[@class="tooltip"]' "ⓘ" +//@ has foo/fn.bar.html '//*[@class="example-wrap should_panic"]/*[@class="tooltip"]' "ⓘ" +//@ has foo/fn.bar.html '//*[@title="This example runs with edition 2018"]' "ⓘ" /// foo /// diff --git a/tests/rustdoc/compiler-derive-proc-macro.rs b/tests/rustdoc/compiler-derive-proc-macro.rs index 1c3867ced9b..e8dc5d7c6b7 100644 --- a/tests/rustdoc/compiler-derive-proc-macro.rs +++ b/tests/rustdoc/compiler-derive-proc-macro.rs @@ -2,14 +2,14 @@ #![crate_name = "foo"] -// @has 'foo/index.html' +//@ has 'foo/index.html' // Each compiler builtin proc-macro has a trait equivalent so we should have // a trait section as well. -// @count - '//*[@id="main-content"]//*[@class="section-header"]' 2 -// @has - '//*[@id="main-content"]//*[@class="section-header"]' 'Traits' -// @has - '//*[@id="main-content"]//*[@class="section-header"]' 'Derive Macros' +//@ count - '//*[@id="main-content"]//*[@class="section-header"]' 2 +//@ has - '//*[@id="main-content"]//*[@class="section-header"]' 'Traits' +//@ has - '//*[@id="main-content"]//*[@class="section-header"]' 'Derive Macros' // Now checking the correct file is generated as well. -// @has 'foo/derive.Clone.html' -// @!has 'foo/macro.Clone.html' +//@ has 'foo/derive.Clone.html' +//@ !has 'foo/macro.Clone.html' pub use std::clone::Clone; diff --git a/tests/rustdoc/const-display.rs b/tests/rustdoc/const-display.rs index 959a00102b7..ac55a6302f7 100644 --- a/tests/rustdoc/const-display.rs +++ b/tests/rustdoc/const-display.rs @@ -7,68 +7,68 @@ #![feature(foo, foo2)] #![feature(staged_api)] -// @has 'foo/fn.foo.html' '//pre' 'pub fn foo() -> u32' -// @has - '//span[@class="since"]' '1.0.0 (const: unstable)' +//@ has 'foo/fn.foo.html' '//pre' 'pub fn foo() -> u32' +//@ has - '//span[@class="since"]' '1.0.0 (const: unstable)' #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature="foo", issue = "none")] pub const fn foo() -> u32 { 42 } -// @has 'foo/fn.foo_unsafe.html' '//pre' 'pub unsafe fn foo_unsafe() -> u32' -// @has - '//span[@class="since"]' '1.0.0 (const: unstable)' +//@ has 'foo/fn.foo_unsafe.html' '//pre' 'pub unsafe fn foo_unsafe() -> u32' +//@ has - '//span[@class="since"]' '1.0.0 (const: unstable)' #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature="foo", issue = "none")] pub const unsafe fn foo_unsafe() -> u32 { 42 } -// @has 'foo/fn.foo2.html' '//pre' 'pub const fn foo2() -> u32' -// @!hasraw - '//span[@class="since"]' +//@ has 'foo/fn.foo2.html' '//pre' 'pub const fn foo2() -> u32' +//@ !hasraw - '//span[@class="since"]' #[unstable(feature = "humans", issue = "none")] pub const fn foo2() -> u32 { 42 } -// @has 'foo/fn.foo3.html' '//pre' 'pub const fn foo3() -> u32' -// @!hasraw - '//span[@class="since"]' +//@ has 'foo/fn.foo3.html' '//pre' 'pub const fn foo3() -> u32' +//@ !hasraw - '//span[@class="since"]' #[unstable(feature = "humans", issue = "none")] #[rustc_const_unstable(feature = "humans", issue = "none")] pub const fn foo3() -> u32 { 42 } -// @has 'foo/fn.bar2.html' '//pre' 'pub const fn bar2() -> u32' -// @has - //span '1.0.0 (const: 1.0.0)' +//@ has 'foo/fn.bar2.html' '//pre' 'pub const fn bar2() -> u32' +//@ has - //span '1.0.0 (const: 1.0.0)' #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "rust1", since = "1.0.0")] pub const fn bar2() -> u32 { 42 } -// @has 'foo/fn.foo2_gated.html' '//pre' 'pub const unsafe fn foo2_gated() -> u32' -// @!hasraw - '//span[@class="since"]' +//@ has 'foo/fn.foo2_gated.html' '//pre' 'pub const unsafe fn foo2_gated() -> u32' +//@ !hasraw - '//span[@class="since"]' #[unstable(feature = "foo2", issue = "none")] pub const unsafe fn foo2_gated() -> u32 { 42 } -// @has 'foo/fn.bar2_gated.html' '//pre' 'pub const unsafe fn bar2_gated() -> u32' -// @has - '//span[@class="since"]' '1.0.0 (const: 1.0.0)' +//@ has 'foo/fn.bar2_gated.html' '//pre' 'pub const unsafe fn bar2_gated() -> u32' +//@ has - '//span[@class="since"]' '1.0.0 (const: 1.0.0)' #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "rust1", since = "1.0.0")] pub const unsafe fn bar2_gated() -> u32 { 42 } -// @has 'foo/fn.bar_not_gated.html' '//pre' 'pub const unsafe fn bar_not_gated() -> u32' -// @!hasraw - '//span[@class="since"]' +//@ has 'foo/fn.bar_not_gated.html' '//pre' 'pub const unsafe fn bar_not_gated() -> u32' +//@ !hasraw - '//span[@class="since"]' pub const unsafe fn bar_not_gated() -> u32 { 42 } pub struct Foo; impl Foo { - // @has 'foo/struct.Foo.html' '//*[@id="method.gated"]/h4[@class="code-header"]' 'pub fn gated() -> u32' - // @has - '//span[@class="since"]' '1.0.0 (const: unstable)' + //@ has 'foo/struct.Foo.html' '//*[@id="method.gated"]/h4[@class="code-header"]' 'pub fn gated() -> u32' + //@ has - '//span[@class="since"]' '1.0.0 (const: unstable)' #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature="foo", issue = "none")] pub const fn gated() -> u32 { 42 } - // @has 'foo/struct.Foo.html' '//*[@id="method.gated_unsafe"]/h4[@class="code-header"]' 'pub unsafe fn gated_unsafe() -> u32' - // @has - '//span[@class="since"]' '1.0.0 (const: unstable)' + //@ has 'foo/struct.Foo.html' '//*[@id="method.gated_unsafe"]/h4[@class="code-header"]' 'pub unsafe fn gated_unsafe() -> u32' + //@ has - '//span[@class="since"]' '1.0.0 (const: unstable)' #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature="foo", issue = "none")] pub const unsafe fn gated_unsafe() -> u32 { 42 } - // @has 'foo/struct.Foo.html' '//*[@id="method.stable_impl"]/h4[@class="code-header"]' 'pub const fn stable_impl() -> u32' - // @has - '//span[@class="since"]' '1.0.0 (const: 1.2.0)' + //@ has 'foo/struct.Foo.html' '//*[@id="method.stable_impl"]/h4[@class="code-header"]' 'pub const fn stable_impl() -> u32' + //@ has - '//span[@class="since"]' '1.0.0 (const: 1.2.0)' #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const2", since = "1.2.0")] pub const fn stable_impl() -> u32 { 42 } @@ -79,13 +79,13 @@ pub struct Bar; impl Bar { // Show non-const stabilities that are the same as the enclosing item. - // @has 'foo/struct.Bar.html' '//span[@class="since"]' '1.0.0 (const: 1.2.0)' + //@ has 'foo/struct.Bar.html' '//span[@class="since"]' '1.0.0 (const: 1.2.0)' #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const2", since = "1.2.0")] pub const fn stable_impl() -> u32 { 42 } // Show const-stability even for unstable functions. - // @matches 'foo/struct.Bar.html' '//span[@class="since"]' '^const: 1.3.0$' + //@ matches 'foo/struct.Bar.html' '//span[@class="since"]' '^const: 1.3.0$' #[unstable(feature = "foo2", issue = "none")] #[rustc_const_stable(feature = "const3", since = "1.3.0")] pub const fn const_stable_unstable() -> u32 { 42 } diff --git a/tests/rustdoc/const-doc.rs b/tests/rustdoc/const-doc.rs index 74ab4af61ac..f33083a267c 100644 --- a/tests/rustdoc/const-doc.rs +++ b/tests/rustdoc/const-doc.rs @@ -11,8 +11,8 @@ pub struct ContentType { } impl ContentType { - // @has const_doc/struct.ContentType.html - // @has - '//*[@id="associatedconstant.Any"]' 'const Any: ContentType' + //@ has const_doc/struct.ContentType.html + //@ has - '//*[@id="associatedconstant.Any"]' 'const Any: ContentType' pub const Any: ContentType = ContentType { ttype: Foo { f: PhantomData, }, subtype: Foo { f: PhantomData, }, params: None, }; diff --git a/tests/rustdoc/const-effect-param.rs b/tests/rustdoc/const-effect-param.rs index f3f1fcfda65..3c81700ba83 100644 --- a/tests/rustdoc/const-effect-param.rs +++ b/tests/rustdoc/const-effect-param.rs @@ -9,7 +9,7 @@ pub trait Tr { fn f(); } -// @has foo/fn.g.html -// @has - '//pre[@class="rust item-decl"]' 'pub const fn g<T: Tr>()' +//@ has foo/fn.g.html +//@ has - '//pre[@class="rust item-decl"]' 'pub const fn g<T: Tr>()' /// foo pub const fn g<T: ~const Tr>() {} diff --git a/tests/rustdoc/const-fn-76501.rs b/tests/rustdoc/const-fn-76501.rs index 4a7284f9851..fac49b0fd20 100644 --- a/tests/rustdoc/const-fn-76501.rs +++ b/tests/rustdoc/const-fn-76501.rs @@ -1,7 +1,7 @@ // https://github.com/rust-lang/rust/issues/76501 #![crate_name="foo"] -// @has 'foo/fn.bloop.html' '//pre' 'pub const fn bloop() -> i32' +//@ has 'foo/fn.bloop.html' '//pre' 'pub const fn bloop() -> i32' /// A useless function that always returns 1. pub const fn bloop() -> i32 { 1 @@ -11,7 +11,7 @@ pub const fn bloop() -> i32 { pub struct Struct {} impl Struct { - // @has 'foo/struct.Struct.html' '//*[@class="method"]' \ + //@ has 'foo/struct.Struct.html' '//*[@class="method"]' \ // 'pub const fn blurp() -> i32' /// A useless function that always returns 1. pub const fn blurp() -> i32 { diff --git a/tests/rustdoc/const-fn-effects.rs b/tests/rustdoc/const-fn-effects.rs index c495a4faa87..4523870c8a5 100644 --- a/tests/rustdoc/const-fn-effects.rs +++ b/tests/rustdoc/const-fn-effects.rs @@ -2,15 +2,15 @@ #![feature(effects)] #![allow(incomplete_features)] -// @has foo/fn.bar.html -// @has - '//pre[@class="rust item-decl"]' 'pub const fn bar() -> ' +//@ has foo/fn.bar.html +//@ has - '//pre[@class="rust item-decl"]' 'pub const fn bar() -> ' /// foo pub const fn bar() -> usize { 2 } -// @has foo/struct.Foo.html -// @has - '//*[@class="method"]' 'const fn new()' +//@ has foo/struct.Foo.html +//@ has - '//*[@class="method"]' 'const fn new()' pub struct Foo(usize); impl Foo { diff --git a/tests/rustdoc/const-fn.rs b/tests/rustdoc/const-fn.rs index f6616185681..8cb0cb6bf1d 100644 --- a/tests/rustdoc/const-fn.rs +++ b/tests/rustdoc/const-fn.rs @@ -1,14 +1,14 @@ #![crate_name = "foo"] -// @has foo/fn.bar.html -// @has - '//pre[@class="rust item-decl"]' 'pub const fn bar() -> ' +//@ has foo/fn.bar.html +//@ has - '//pre[@class="rust item-decl"]' 'pub const fn bar() -> ' /// foo pub const fn bar() -> usize { 2 } -// @has foo/struct.Foo.html -// @has - '//*[@class="method"]' 'const fn new()' +//@ has foo/struct.Foo.html +//@ has - '//*[@class="method"]' 'const fn new()' pub struct Foo(usize); impl Foo { diff --git a/tests/rustdoc/const-generics/add-impl.rs b/tests/rustdoc/const-generics/add-impl.rs index df490d2c636..1fea0f847b2 100644 --- a/tests/rustdoc/const-generics/add-impl.rs +++ b/tests/rustdoc/const-generics/add-impl.rs @@ -2,12 +2,12 @@ use std::ops::Add; -// @has foo/struct.Simd.html '//pre[@class="rust item-decl"]' 'pub struct Simd<T, const WIDTH: usize>' +//@ has foo/struct.Simd.html '//pre[@class="rust item-decl"]' 'pub struct Simd<T, const WIDTH: usize>' pub struct Simd<T, const WIDTH: usize> { inner: T, } -// @has foo/struct.Simd.html '//div[@id="trait-implementations-list"]//h3[@class="code-header"]' 'impl Add for Simd<u8, 16>' +//@ has foo/struct.Simd.html '//div[@id="trait-implementations-list"]//h3[@class="code-header"]' 'impl Add for Simd<u8, 16>' impl Add for Simd<u8, 16> { type Output = Self; diff --git a/tests/rustdoc/const-generics/const-generic-defaults.rs b/tests/rustdoc/const-generics/const-generic-defaults.rs index 7a0a794112d..090f17cc988 100644 --- a/tests/rustdoc/const-generics/const-generic-defaults.rs +++ b/tests/rustdoc/const-generics/const-generic-defaults.rs @@ -1,5 +1,5 @@ #![crate_name = "foo"] -// @has foo/struct.Foo.html '//pre[@class="rust item-decl"]' \ +//@ has foo/struct.Foo.html '//pre[@class="rust item-decl"]' \ // 'pub struct Foo<const M: usize = 10, const N: usize = M, T = i32>(' pub struct Foo<const M: usize = 10, const N: usize = M, T = i32>(T); diff --git a/tests/rustdoc/const-generics/const-generic-slice.rs b/tests/rustdoc/const-generics/const-generic-slice.rs index 80a9ab3f12e..6517caf4f2f 100644 --- a/tests/rustdoc/const-generics/const-generic-slice.rs +++ b/tests/rustdoc/const-generics/const-generic-slice.rs @@ -4,8 +4,8 @@ pub trait Array { type Item; } -// @has foo/trait.Array.html -// @has - '//*[@class="impl"]' 'impl<T, const N: usize> Array for [T; N]' +//@ has foo/trait.Array.html +//@ has - '//*[@class="impl"]' 'impl<T, const N: usize> Array for [T; N]' impl<T, const N: usize> Array for [T; N] { type Item = T; } diff --git a/tests/rustdoc/const-generics/const-generics-docs.rs b/tests/rustdoc/const-generics/const-generics-docs.rs index 4ef1acf45f5..e261585263b 100644 --- a/tests/rustdoc/const-generics/const-generics-docs.rs +++ b/tests/rustdoc/const-generics/const-generics-docs.rs @@ -3,26 +3,26 @@ #![crate_name = "foo"] extern crate extern_crate; -// @has foo/fn.extern_fn.html '//pre[@class="rust item-decl"]' \ +//@ has foo/fn.extern_fn.html '//pre[@class="rust item-decl"]' \ // 'pub fn extern_fn<const N: usize>() -> impl Iterator<Item = [u8; N]>' pub use extern_crate::extern_fn; -// @has foo/struct.ExternTy.html '//pre[@class="rust item-decl"]' \ +//@ has foo/struct.ExternTy.html '//pre[@class="rust item-decl"]' \ // 'pub struct ExternTy<const N: usize> {' pub use extern_crate::ExternTy; -// @has foo/type.TyAlias.html '//pre[@class="rust item-decl"]' \ +//@ has foo/type.TyAlias.html '//pre[@class="rust item-decl"]' \ // 'type TyAlias<const N: usize> = ExternTy<N>;' pub use extern_crate::TyAlias; -// @has foo/trait.WTrait.html '//pre[@class="rust item-decl"]' \ +//@ has foo/trait.WTrait.html '//pre[@class="rust item-decl"]' \ // 'pub trait WTrait<const N: usize, const M: usize>' -// @has - '//pre[@class="rust item-decl"]' 'fn hey<const P: usize>() -> usize' +//@ has - '//pre[@class="rust item-decl"]' 'fn hey<const P: usize>() -> usize' pub use extern_crate::WTrait; -// @has foo/trait.Trait.html '//pre[@class="rust item-decl"]' \ +//@ has foo/trait.Trait.html '//pre[@class="rust item-decl"]' \ // 'pub trait Trait<const N: usize>' -// @has - '//*[@id="impl-Trait%3C1%3E-for-u8"]//h3[@class="code-header"]' 'impl Trait<1> for u8' -// @has - '//*[@id="impl-Trait%3C2%3E-for-u8"]//h3[@class="code-header"]' 'impl Trait<2> for u8' -// @has - '//*[@id="impl-Trait%3C%7B1+%2B+2%7D%3E-for-u8"]//h3[@class="code-header"]' 'impl Trait<{1 + 2}> for u8' -// @has - '//*[@id="impl-Trait%3CN%3E-for-%5Bu8;+N%5D"]//h3[@class="code-header"]' \ +//@ has - '//*[@id="impl-Trait%3C1%3E-for-u8"]//h3[@class="code-header"]' 'impl Trait<1> for u8' +//@ has - '//*[@id="impl-Trait%3C2%3E-for-u8"]//h3[@class="code-header"]' 'impl Trait<2> for u8' +//@ has - '//*[@id="impl-Trait%3C%7B1+%2B+2%7D%3E-for-u8"]//h3[@class="code-header"]' 'impl Trait<{1 + 2}> for u8' +//@ has - '//*[@id="impl-Trait%3CN%3E-for-%5Bu8;+N%5D"]//h3[@class="code-header"]' \ // 'impl<const N: usize> Trait<N> for [u8; N]' pub trait Trait<const N: usize> {} impl Trait<1> for u8 {} @@ -30,58 +30,58 @@ impl Trait<2> for u8 {} impl Trait<{1 + 2}> for u8 {} impl<const N: usize> Trait<N> for [u8; N] {} -// @has foo/struct.Foo.html '//pre[@class="rust item-decl"]' \ +//@ has foo/struct.Foo.html '//pre[@class="rust item-decl"]' \ // 'pub struct Foo<const N: usize> where u8: Trait<N>' pub struct Foo<const N: usize> where u8: Trait<N>; -// @has foo/struct.Bar.html '//pre[@class="rust item-decl"]' 'pub struct Bar<T, const N: usize>(' +//@ has foo/struct.Bar.html '//pre[@class="rust item-decl"]' 'pub struct Bar<T, const N: usize>(' pub struct Bar<T, const N: usize>([T; N]); -// @has foo/struct.Foo.html '//*[@id="impl-Foo%3CM%3E"]/h3[@class="code-header"]' 'impl<const M: usize> Foo<M>where u8: Trait<M>' +//@ has foo/struct.Foo.html '//*[@id="impl-Foo%3CM%3E"]/h3[@class="code-header"]' 'impl<const M: usize> Foo<M>where u8: Trait<M>' impl<const M: usize> Foo<M> where u8: Trait<M> { - // @has - '//*[@id="associatedconstant.FOO_ASSOC"]' 'pub const FOO_ASSOC: usize' + //@ has - '//*[@id="associatedconstant.FOO_ASSOC"]' 'pub const FOO_ASSOC: usize' pub const FOO_ASSOC: usize = M + 13; - // @has - '//*[@id="method.hey"]' 'pub fn hey<const N: usize>(&self) -> Bar<u8, N>' + //@ has - '//*[@id="method.hey"]' 'pub fn hey<const N: usize>(&self) -> Bar<u8, N>' pub fn hey<const N: usize>(&self) -> Bar<u8, N> { Bar([0; N]) } } -// @has foo/struct.Bar.html '//*[@id="impl-Bar%3Cu8,+M%3E"]/h3[@class="code-header"]' 'impl<const M: usize> Bar<u8, M>' +//@ has foo/struct.Bar.html '//*[@id="impl-Bar%3Cu8,+M%3E"]/h3[@class="code-header"]' 'impl<const M: usize> Bar<u8, M>' impl<const M: usize> Bar<u8, M> { - // @has - '//*[@id="method.hey"]' \ + //@ has - '//*[@id="method.hey"]' \ // 'pub fn hey<const N: usize>(&self) -> Foo<N>where u8: Trait<N>' pub fn hey<const N: usize>(&self) -> Foo<N> where u8: Trait<N> { Foo } } -// @has foo/fn.test.html '//pre[@class="rust item-decl"]' \ +//@ has foo/fn.test.html '//pre[@class="rust item-decl"]' \ // 'pub fn test<const N: usize>() -> impl Trait<N>where u8: Trait<N>' pub fn test<const N: usize>() -> impl Trait<N> where u8: Trait<N> { 2u8 } -// @has foo/fn.a_sink.html '//pre[@class="rust item-decl"]' \ +//@ has foo/fn.a_sink.html '//pre[@class="rust item-decl"]' \ // 'pub async fn a_sink<const N: usize>(v: [u8; N]) -> impl Trait<N>' pub async fn a_sink<const N: usize>(v: [u8; N]) -> impl Trait<N> { v } -// @has foo/fn.b_sink.html '//pre[@class="rust item-decl"]' \ +//@ has foo/fn.b_sink.html '//pre[@class="rust item-decl"]' \ // 'pub async fn b_sink<const N: usize>(_: impl Trait<N>)' pub async fn b_sink<const N: usize>(_: impl Trait<N>) {} -// @has foo/fn.concrete.html '//pre[@class="rust item-decl"]' \ +//@ has foo/fn.concrete.html '//pre[@class="rust item-decl"]' \ // 'pub fn concrete() -> [u8; 22]' pub fn concrete() -> [u8; 3 + std::mem::size_of::<u64>() << 1] { Default::default() } -// @has foo/type.Faz.html '//pre[@class="rust item-decl"]' \ +//@ has foo/type.Faz.html '//pre[@class="rust item-decl"]' \ // 'type Faz<const N: usize> = [u8; N];' pub type Faz<const N: usize> = [u8; N]; -// @has foo/type.Fiz.html '//pre[@class="rust item-decl"]' \ +//@ has foo/type.Fiz.html '//pre[@class="rust item-decl"]' \ // 'type Fiz<const N: usize> = [[u8; N]; 48];' pub type Fiz<const N: usize> = [[u8; N]; 3 << 4]; @@ -91,7 +91,7 @@ macro_rules! define_me { } } -// @has foo/struct.Foz.html '//pre[@class="rust item-decl"]' \ +//@ has foo/struct.Foz.html '//pre[@class="rust item-decl"]' \ // 'pub struct Foz<const N: usize>(/* private fields */);' define_me!(Foz<N>); @@ -103,26 +103,26 @@ impl<const N: usize> Q for [u8; N] { const ASSOC: usize = N; } -// @has foo/fn.q_user.html '//pre[@class="rust item-decl"]' \ +//@ has foo/fn.q_user.html '//pre[@class="rust item-decl"]' \ // 'pub fn q_user() -> [u8; 13]' pub fn q_user() -> [u8; <[u8; 13] as Q>::ASSOC] { [0; <[u8; 13] as Q>::ASSOC] } -// @has foo/union.Union.html '//pre[@class="rust item-decl"]' \ +//@ has foo/union.Union.html '//pre[@class="rust item-decl"]' \ // 'pub union Union<const N: usize>' pub union Union<const N: usize> { - // @has - //pre "pub arr: [u8; N]" + //@ has - //pre "pub arr: [u8; N]" pub arr: [u8; N], - // @has - //pre "pub another_arr: [(); N]" + //@ has - //pre "pub another_arr: [(); N]" pub another_arr: [(); N], } -// @has foo/enum.Enum.html '//pre[@class="rust item-decl"]' \ +//@ has foo/enum.Enum.html '//pre[@class="rust item-decl"]' \ // 'pub enum Enum<const N: usize>' pub enum Enum<const N: usize> { - // @has - //pre "Variant([u8; N])" + //@ has - //pre "Variant([u8; N])" Variant([u8; N]), - // @has - //pre "EmptyVariant" + //@ has - //pre "EmptyVariant" EmptyVariant, } diff --git a/tests/rustdoc/const-generics/const-impl.rs b/tests/rustdoc/const-generics/const-impl.rs index f4eefcc1c33..ce536291290 100644 --- a/tests/rustdoc/const-generics/const-impl.rs +++ b/tests/rustdoc/const-generics/const-impl.rs @@ -10,21 +10,21 @@ pub enum Order { Unsorted, } -// @has foo/struct.VSet.html '//pre[@class="rust item-decl"]' 'pub struct VSet<T, const ORDER: Order>' -// @has foo/struct.VSet.html '//*[@id="impl-Send-for-VSet%3CT,+ORDER%3E"]/h3[@class="code-header"]' 'impl<T, const ORDER: Order> Send for VSet<T, ORDER>' -// @has foo/struct.VSet.html '//*[@id="impl-Sync-for-VSet%3CT,+ORDER%3E"]/h3[@class="code-header"]' 'impl<T, const ORDER: Order> Sync for VSet<T, ORDER>' +//@ has foo/struct.VSet.html '//pre[@class="rust item-decl"]' 'pub struct VSet<T, const ORDER: Order>' +//@ has foo/struct.VSet.html '//*[@id="impl-Send-for-VSet%3CT,+ORDER%3E"]/h3[@class="code-header"]' 'impl<T, const ORDER: Order> Send for VSet<T, ORDER>' +//@ has foo/struct.VSet.html '//*[@id="impl-Sync-for-VSet%3CT,+ORDER%3E"]/h3[@class="code-header"]' 'impl<T, const ORDER: Order> Sync for VSet<T, ORDER>' pub struct VSet<T, const ORDER: Order> { inner: Vec<T>, } -// @has foo/struct.VSet.html '//*[@id="impl-VSet%3CT,+%7B+Order::Sorted+%7D%3E"]/h3[@class="code-header"]' 'impl<T> VSet<T, { Order::Sorted }>' +//@ has foo/struct.VSet.html '//*[@id="impl-VSet%3CT,+%7B+Order::Sorted+%7D%3E"]/h3[@class="code-header"]' 'impl<T> VSet<T, { Order::Sorted }>' impl<T> VSet<T, { Order::Sorted }> { pub fn new() -> Self { Self { inner: Vec::new() } } } -// @has foo/struct.VSet.html '//*[@id="impl-VSet%3CT,+%7B+Order::Unsorted+%7D%3E"]/h3[@class="code-header"]' 'impl<T> VSet<T, { Order::Unsorted }>' +//@ has foo/struct.VSet.html '//*[@id="impl-VSet%3CT,+%7B+Order::Unsorted+%7D%3E"]/h3[@class="code-header"]' 'impl<T> VSet<T, { Order::Unsorted }>' impl<T> VSet<T, { Order::Unsorted }> { pub fn new() -> Self { Self { inner: Vec::new() } @@ -33,7 +33,7 @@ impl<T> VSet<T, { Order::Unsorted }> { pub struct Escape<const S: &'static str>; -// @has foo/struct.Escape.html '//*[@id="impl-Escape%3C%22%3Cscript%3Ealert(%5C%22Escape%5C%22);%3C/script%3E%22%3E"]/h3[@class="code-header"]' 'impl Escape<r#"<script>alert("Escape");</script>"#>' +//@ has foo/struct.Escape.html '//*[@id="impl-Escape%3C%22%3Cscript%3Ealert(%5C%22Escape%5C%22);%3C/script%3E%22%3E"]/h3[@class="code-header"]' 'impl Escape<r#"<script>alert("Escape");</script>"#>' impl Escape<r#"<script>alert("Escape");</script>"#> { pub fn f() {} } diff --git a/tests/rustdoc/const-generics/generic_const_exprs.rs b/tests/rustdoc/const-generics/generic_const_exprs.rs index 2d2d31d7231..c406fa5d034 100644 --- a/tests/rustdoc/const-generics/generic_const_exprs.rs +++ b/tests/rustdoc/const-generics/generic_const_exprs.rs @@ -2,6 +2,6 @@ #![feature(generic_const_exprs)] #![allow(incomplete_features)] // make sure that `ConstEvaluatable` predicates dont cause rustdoc to ICE #77647 -// @has foo/struct.Ice.html '//pre[@class="rust item-decl"]' \ +//@ has foo/struct.Ice.html '//pre[@class="rust item-decl"]' \ // 'pub struct Ice<const N: usize> where [(); { _ }]:;' pub struct Ice<const N: usize> where [(); N + 1]:; diff --git a/tests/rustdoc/const-generics/lazy_normalization_consts/const-equate-pred.rs b/tests/rustdoc/const-generics/lazy_normalization_consts/const-equate-pred.rs index 310e89a35c4..c9d80d68aa1 100644 --- a/tests/rustdoc/const-generics/lazy_normalization_consts/const-equate-pred.rs +++ b/tests/rustdoc/const-generics/lazy_normalization_consts/const-equate-pred.rs @@ -11,8 +11,8 @@ pub struct Hasher<T> { unsafe impl<T: Default> Send for Hasher<T> {} -// @has foo/struct.Foo.html -// @has - '//h3[@class="code-header"]' 'impl Send for Foo' +//@ has foo/struct.Foo.html +//@ has - '//h3[@class="code-header"]' 'impl Send for Foo' pub struct Foo { hasher: Hasher<[u8; 3]>, } diff --git a/tests/rustdoc/const-generics/type-alias.rs b/tests/rustdoc/const-generics/type-alias.rs index 4b93e72d273..6d98648fe62 100644 --- a/tests/rustdoc/const-generics/type-alias.rs +++ b/tests/rustdoc/const-generics/type-alias.rs @@ -1,4 +1,4 @@ #![crate_name = "foo"] -// @has foo/type.CellIndex.html '//pre[@class="rust item-decl"]' 'type CellIndex<const D: usize> = [i64; D];' +//@ has foo/type.CellIndex.html '//pre[@class="rust item-decl"]' 'type CellIndex<const D: usize> = [i64; D];' pub type CellIndex<const D: usize> = [i64; D]; diff --git a/tests/rustdoc/const-intrinsic.rs b/tests/rustdoc/const-intrinsic.rs index 6d2c6cce29c..520e253469c 100644 --- a/tests/rustdoc/const-intrinsic.rs +++ b/tests/rustdoc/const-intrinsic.rs @@ -5,21 +5,21 @@ #![stable(since="1.0.0", feature="rust1")] extern "rust-intrinsic" { - // @has 'foo/fn.transmute.html' - // @has - '//pre[@class="rust item-decl"]' 'pub const unsafe extern "rust-intrinsic" fn transmute<T, U>(_: T) -> U' + //@ has 'foo/fn.transmute.html' + //@ has - '//pre[@class="rust item-decl"]' 'pub const unsafe extern "rust-intrinsic" fn transmute<T, U>(_: T) -> U' #[stable(since="1.0.0", feature="rust1")] #[rustc_const_stable(feature = "const_transmute", since = "1.56.0")] pub fn transmute<T, U>(_: T) -> U; - // @has 'foo/fn.unreachable.html' - // @has - '//pre[@class="rust item-decl"]' 'pub unsafe extern "rust-intrinsic" fn unreachable() -> !' + //@ has 'foo/fn.unreachable.html' + //@ has - '//pre[@class="rust item-decl"]' 'pub unsafe extern "rust-intrinsic" fn unreachable() -> !' #[stable(since="1.0.0", feature="rust1")] pub fn unreachable() -> !; } extern "C" { - // @has 'foo/fn.needs_drop.html' - // @has - '//pre[@class="rust item-decl"]' 'pub unsafe extern "C" fn needs_drop() -> !' + //@ has 'foo/fn.needs_drop.html' + //@ has - '//pre[@class="rust item-decl"]' 'pub unsafe extern "C" fn needs_drop() -> !' #[stable(since="1.0.0", feature="rust1")] pub fn needs_drop() -> !; } diff --git a/tests/rustdoc/const-rendering-macros-33302.rs b/tests/rustdoc/const-rendering-macros-33302.rs index 0f5cb921411..9fd45df08be 100644 --- a/tests/rustdoc/const-rendering-macros-33302.rs +++ b/tests/rustdoc/const-rendering-macros-33302.rs @@ -8,42 +8,42 @@ macro_rules! make { ($n:expr) => { pub struct S; - // @has issue_33302/constant.CST.html \ + //@ has issue_33302/constant.CST.html \ // '//pre[@class="rust item-decl"]' 'pub const CST: i32' pub const CST: i32 = ($n * $n); - // @has issue_33302/static.ST.html \ + //@ has issue_33302/static.ST.html \ // '//pre[@class="rust item-decl"]' 'pub static ST: i32' pub static ST: i32 = ($n * $n); pub trait T<X> { fn ignore(_: &X) {} const C: X; - // @has issue_33302/trait.T.html \ + //@ has issue_33302/trait.T.html \ // '//pre[@class="rust item-decl"]' 'const D: i32' - // @has - '//*[@id="associatedconstant.D"]' 'const D: i32' + //@ has - '//*[@id="associatedconstant.D"]' 'const D: i32' const D: i32 = ($n * $n); } - // @has issue_33302/struct.S.html \ + //@ has issue_33302/struct.S.html \ // '//*[@class="impl"]' 'impl T<[i32; 16]> for S' - // @has - '//*[@id="associatedconstant.C"]' 'const C: [i32; 16]' - // @has - '//*[@id="associatedconstant.D"]' 'const D: i32' + //@ has - '//*[@id="associatedconstant.C"]' 'const C: [i32; 16]' + //@ has - '//*[@id="associatedconstant.D"]' 'const D: i32' impl T<[i32; ($n * $n)]> for S { const C: [i32; ($n * $n)] = [0; ($n * $n)]; } - // @has issue_33302/struct.S.html \ + //@ has issue_33302/struct.S.html \ // '//*[@class="impl"]' 'impl T<[i32; 16]> for S' - // @has - '//*[@id="associatedconstant.C-1"]' 'const C: (i32,)' - // @has - '//*[@id="associatedconstant.D-1"]' 'const D: i32' + //@ has - '//*[@id="associatedconstant.C-1"]' 'const C: (i32,)' + //@ has - '//*[@id="associatedconstant.D-1"]' 'const D: i32' impl T<(i32,)> for S { const C: (i32,) = ($n,); } - // @has issue_33302/struct.S.html \ + //@ has issue_33302/struct.S.html \ // '//*[@class="impl"]' 'impl T<(i32, i32)> for S' - // @has - '//*[@id="associatedconstant.C-2"]' 'const C: (i32, i32)' - // @has - '//*[@id="associatedconstant.D-2"]' 'const D: i32' + //@ has - '//*[@id="associatedconstant.C-2"]' 'const C: (i32, i32)' + //@ has - '//*[@id="associatedconstant.D-2"]' 'const D: i32' impl T<(i32, i32)> for S { const C: (i32, i32) = ($n, $n); const D: i32 = ($n / $n); diff --git a/tests/rustdoc/const-underscore.rs b/tests/rustdoc/const-underscore.rs index f7f15e54831..fafc4b4e25c 100644 --- a/tests/rustdoc/const-underscore.rs +++ b/tests/rustdoc/const-underscore.rs @@ -1,6 +1,6 @@ //@ compile-flags: --document-private-items -// @!has const_underscore/constant._.html +//@ !has const_underscore/constant._.html const _: () = { #[no_mangle] extern "C" fn implementation_detail() {} diff --git a/tests/rustdoc/const-value-display.rs b/tests/rustdoc/const-value-display.rs index a7548ad2cc4..658978a3490 100644 --- a/tests/rustdoc/const-value-display.rs +++ b/tests/rustdoc/const-value-display.rs @@ -1,9 +1,9 @@ #![crate_name = "foo"] -// @has 'foo/constant.HOUR_IN_SECONDS.html' -// @has - '//*[@class="rust item-decl"]//code' 'pub const HOUR_IN_SECONDS: u64 = _; // 3_600u64' +//@ has 'foo/constant.HOUR_IN_SECONDS.html' +//@ has - '//*[@class="rust item-decl"]//code' 'pub const HOUR_IN_SECONDS: u64 = _; // 3_600u64' pub const HOUR_IN_SECONDS: u64 = 60 * 60; -// @has 'foo/constant.NEGATIVE.html' -// @has - '//*[@class="rust item-decl"]//code' 'pub const NEGATIVE: i64 = _; // -3_600i64' +//@ has 'foo/constant.NEGATIVE.html' +//@ has - '//*[@class="rust item-decl"]//code' 'pub const NEGATIVE: i64 = _; // -3_600i64' pub const NEGATIVE: i64 = -60 * 60; diff --git a/tests/rustdoc/const.rs b/tests/rustdoc/const.rs index 587ad4db478..fe6a828505a 100644 --- a/tests/rustdoc/const.rs +++ b/tests/rustdoc/const.rs @@ -3,7 +3,7 @@ pub struct Foo; impl Foo { - // @has const/struct.Foo.html '//*[@id="method.new"]//h4[@class="code-header"]' 'const unsafe fn new' + //@ has const/struct.Foo.html '//*[@id="method.new"]//h4[@class="code-header"]' 'const unsafe fn new' pub const unsafe fn new() -> Foo { Foo } diff --git a/tests/rustdoc/constructor-imports.rs b/tests/rustdoc/constructor-imports.rs index 26795c27444..e5f280476b6 100644 --- a/tests/rustdoc/constructor-imports.rs +++ b/tests/rustdoc/constructor-imports.rs @@ -7,9 +7,9 @@ pub mod a { } } -// @count 'foo/index.html' '//*[code="pub use a::Foo;"]' 1 +//@ count 'foo/index.html' '//*[code="pub use a::Foo;"]' 1 #[doc(no_inline)] pub use a::Foo; -// @count 'foo/index.html' '//*[code="pub use a::Bar::Baz;"]' 1 +//@ count 'foo/index.html' '//*[code="pub use a::Bar::Baz;"]' 1 #[doc(no_inline)] pub use a::Bar::Baz; diff --git a/tests/rustdoc/crate-version-escape.rs b/tests/rustdoc/crate-version-escape.rs index a8f9e7eee7b..3a08d52361c 100644 --- a/tests/rustdoc/crate-version-escape.rs +++ b/tests/rustdoc/crate-version-escape.rs @@ -2,4 +2,4 @@ #![crate_name = "foo"] -// @has 'foo/index.html' '//*[@class="version"]' '<script>alert("hi")</script>' +//@ has 'foo/index.html' '//*[@class="version"]' '<script>alert("hi")</script>' diff --git a/tests/rustdoc/crate-version-extra.rs b/tests/rustdoc/crate-version-extra.rs index 4e215b86dee..b3cd54da764 100644 --- a/tests/rustdoc/crate-version-extra.rs +++ b/tests/rustdoc/crate-version-extra.rs @@ -3,5 +3,5 @@ #![crate_name="foo"] // main version next to logo, extra version data below it -// @has 'foo/index.html' '//h2/span[@class="version"]' '1.3.37-nightly' -// @has 'foo/index.html' '//nav[@class="sidebar"]/div[@class="version"]' '(203c57dbe 2023-09-17)' +//@ has 'foo/index.html' '//h2/span[@class="version"]' '1.3.37-nightly' +//@ has 'foo/index.html' '//nav[@class="sidebar"]/div[@class="version"]' '(203c57dbe 2023-09-17)' diff --git a/tests/rustdoc/crate-version.rs b/tests/rustdoc/crate-version.rs index 7095bf54c13..05ce0aeb5ca 100644 --- a/tests/rustdoc/crate-version.rs +++ b/tests/rustdoc/crate-version.rs @@ -1,3 +1,3 @@ //@ compile-flags: --crate-version=1.3.37 -// @has 'crate_version/index.html' '//*[@class="version"]' '1.3.37' +//@ has 'crate_version/index.html' '//*[@class="version"]' '1.3.37' diff --git a/tests/rustdoc/cross-crate-hidden-assoc-trait-items.rs b/tests/rustdoc/cross-crate-hidden-assoc-trait-items.rs index 22630705e1e..d3771c2e7a2 100644 --- a/tests/rustdoc/cross-crate-hidden-assoc-trait-items.rs +++ b/tests/rustdoc/cross-crate-hidden-assoc-trait-items.rs @@ -10,14 +10,14 @@ // visible items instead and assert that there are *exactly two* associated items // (by counting the number of `section`s). This is more robust and future-proof. -// @has dependent/struct.Ty.html -// @has - '//*[@id="associatedtype.VisibleAssoc"]' 'type VisibleAssoc = ()' -// @has - '//*[@id="associatedconstant.VISIBLE_ASSOC"]' 'const VISIBLE_ASSOC: ()' -// @count - '//*[@class="impl-items"]/section' 2 +//@ has dependent/struct.Ty.html +//@ has - '//*[@id="associatedtype.VisibleAssoc"]' 'type VisibleAssoc = ()' +//@ has - '//*[@id="associatedconstant.VISIBLE_ASSOC"]' 'const VISIBLE_ASSOC: ()' +//@ count - '//*[@class="impl-items"]/section' 2 -// @has dependent/trait.Tr.html -// @has - '//*[@id="associatedtype.VisibleAssoc-1"]' 'type VisibleAssoc = ()' -// @has - '//*[@id="associatedconstant.VISIBLE_ASSOC-1"]' 'const VISIBLE_ASSOC: ()' -// @count - '//*[@class="impl-items"]/section' 2 +//@ has dependent/trait.Tr.html +//@ has - '//*[@id="associatedtype.VisibleAssoc-1"]' 'type VisibleAssoc = ()' +//@ has - '//*[@id="associatedconstant.VISIBLE_ASSOC-1"]' 'const VISIBLE_ASSOC: ()' +//@ count - '//*[@class="impl-items"]/section' 2 pub use dependency::{Tr, Ty}; diff --git a/tests/rustdoc/cross-crate-hidden-impl-parameter.rs b/tests/rustdoc/cross-crate-hidden-impl-parameter.rs index 69f9ca132fd..ebfe251134a 100644 --- a/tests/rustdoc/cross-crate-hidden-impl-parameter.rs +++ b/tests/rustdoc/cross-crate-hidden-impl-parameter.rs @@ -8,7 +8,7 @@ pub use ::cross_crate_hidden_impl_parameter::{HiddenType, HiddenTrait}; // OK, n pub enum MyLibType {} -// @!has foo/enum.MyLibType.html '//*[@id="impl-From%3CHiddenType%3E"]' 'impl From<HiddenType> for MyLibType' +//@ !has foo/enum.MyLibType.html '//*[@id="impl-From%3CHiddenType%3E"]' 'impl From<HiddenType> for MyLibType' impl From<HiddenType> for MyLibType { fn from(it: HiddenType) -> MyLibType { match it {} @@ -17,17 +17,17 @@ impl From<HiddenType> for MyLibType { pub struct T<T>(T); -// @!has foo/enum.MyLibType.html '//*[@id="impl-From%3CT%3CT%3CT%3CT%3CHiddenType%3E%3E%3E%3E%3E"]' 'impl From<T<T<T<T<HiddenType>>>>> for MyLibType' +//@ !has foo/enum.MyLibType.html '//*[@id="impl-From%3CT%3CT%3CT%3CT%3CHiddenType%3E%3E%3E%3E%3E"]' 'impl From<T<T<T<T<HiddenType>>>>> for MyLibType' impl From<T<T<T<T<HiddenType>>>>> for MyLibType { fn from(it: T<T<T<T<HiddenType>>>>) -> MyLibType { todo!() } } -// @!has foo/enum.MyLibType.html '//*[@id="impl-HiddenTrait"]' 'impl HiddenTrait for MyLibType' +//@ !has foo/enum.MyLibType.html '//*[@id="impl-HiddenTrait"]' 'impl HiddenTrait for MyLibType' impl HiddenTrait for MyLibType {} -// @!has foo/struct.T.html '//*[@id="impl-From%3CMyLibType%3E"]' 'impl From<MyLibType> for T<T<T<T<HiddenType>>>>' +//@ !has foo/struct.T.html '//*[@id="impl-From%3CMyLibType%3E"]' 'impl From<MyLibType> for T<T<T<T<HiddenType>>>>' impl From<MyLibType> for T<T<T<T<HiddenType>>>> { fn from(it: MyLibType) -> T<T<T<T<HiddenType>>>> { match it {} diff --git a/tests/rustdoc/cross-crate-links.rs b/tests/rustdoc/cross-crate-links.rs index 36e8f31dfc6..b051d41cad4 100644 --- a/tests/rustdoc/cross-crate-links.rs +++ b/tests/rustdoc/cross-crate-links.rs @@ -6,54 +6,54 @@ #[macro_use] extern crate all_item_types; -// @has 'foo/index.html' '//a[@href="../all_item_types/foo_mod/index.html"]' 'foo_mod' +//@ has 'foo/index.html' '//a[@href="../all_item_types/foo_mod/index.html"]' 'foo_mod' #[doc(no_inline)] pub use all_item_types::foo_mod; -// @has 'foo/index.html' '//a[@href="../all_item_types/fn.foo_ffn.html"]' 'foo_ffn' +//@ has 'foo/index.html' '//a[@href="../all_item_types/fn.foo_ffn.html"]' 'foo_ffn' #[doc(no_inline)] pub use all_item_types::foo_ffn; -// @has 'foo/index.html' '//a[@href="../all_item_types/static.FOO_FSTATIC.html"]' 'FOO_FSTATIC' +//@ has 'foo/index.html' '//a[@href="../all_item_types/static.FOO_FSTATIC.html"]' 'FOO_FSTATIC' #[doc(no_inline)] pub use all_item_types::FOO_FSTATIC; -// @has 'foo/index.html' '//a[@href="../all_item_types/foreigntype.FooFType.html"]' 'FooFType' +//@ has 'foo/index.html' '//a[@href="../all_item_types/foreigntype.FooFType.html"]' 'FooFType' #[doc(no_inline)] pub use all_item_types::FooFType; -// @has 'foo/index.html' '//a[@href="../all_item_types/fn.foo_fn.html"]' 'foo_fn' +//@ has 'foo/index.html' '//a[@href="../all_item_types/fn.foo_fn.html"]' 'foo_fn' #[doc(no_inline)] pub use all_item_types::foo_fn; -// @has 'foo/index.html' '//a[@href="../all_item_types/trait.FooTrait.html"]' 'FooTrait' +//@ has 'foo/index.html' '//a[@href="../all_item_types/trait.FooTrait.html"]' 'FooTrait' #[doc(no_inline)] pub use all_item_types::FooTrait; -// @has 'foo/index.html' '//a[@href="../all_item_types/struct.FooStruct.html"]' 'FooStruct' +//@ has 'foo/index.html' '//a[@href="../all_item_types/struct.FooStruct.html"]' 'FooStruct' #[doc(no_inline)] pub use all_item_types::FooStruct; -// @has 'foo/index.html' '//a[@href="../all_item_types/enum.FooEnum.html"]' 'FooEnum' +//@ has 'foo/index.html' '//a[@href="../all_item_types/enum.FooEnum.html"]' 'FooEnum' #[doc(no_inline)] pub use all_item_types::FooEnum; -// @has 'foo/index.html' '//a[@href="../all_item_types/union.FooUnion.html"]' 'FooUnion' +//@ has 'foo/index.html' '//a[@href="../all_item_types/union.FooUnion.html"]' 'FooUnion' #[doc(no_inline)] pub use all_item_types::FooUnion; -// @has 'foo/index.html' '//a[@href="../all_item_types/type.FooType.html"]' 'FooType' +//@ has 'foo/index.html' '//a[@href="../all_item_types/type.FooType.html"]' 'FooType' #[doc(no_inline)] pub use all_item_types::FooType; -// @has 'foo/index.html' '//a[@href="../all_item_types/static.FOO_STATIC.html"]' 'FOO_STATIC' +//@ has 'foo/index.html' '//a[@href="../all_item_types/static.FOO_STATIC.html"]' 'FOO_STATIC' #[doc(no_inline)] pub use all_item_types::FOO_STATIC; -// @has 'foo/index.html' '//a[@href="../all_item_types/constant.FOO_CONSTANT.html"]' 'FOO_CONSTANT' +//@ has 'foo/index.html' '//a[@href="../all_item_types/constant.FOO_CONSTANT.html"]' 'FOO_CONSTANT' #[doc(no_inline)] pub use all_item_types::FOO_CONSTANT; -// @has 'foo/index.html' '//a[@href="../all_item_types/macro.foo_macro.html"]' 'foo_macro' +//@ has 'foo/index.html' '//a[@href="../all_item_types/macro.foo_macro.html"]' 'foo_macro' #[doc(no_inline)] pub use all_item_types::foo_macro; diff --git a/tests/rustdoc/cross-crate-primitive-doc.rs b/tests/rustdoc/cross-crate-primitive-doc.rs index 01a4c4ef8e4..ca33dedcbae 100644 --- a/tests/rustdoc/cross-crate-primitive-doc.rs +++ b/tests/rustdoc/cross-crate-primitive-doc.rs @@ -7,7 +7,7 @@ extern crate primitive_doc; -// @has 'cross_crate_primitive_doc/fn.foo.html' '//a[@href="../primitive_doc/primitive.usize.html"]' 'usize' -// @has 'cross_crate_primitive_doc/fn.foo.html' '//a[@href="../primitive_doc/primitive.usize.html"]' 'link' +//@ has 'cross_crate_primitive_doc/fn.foo.html' '//a[@href="../primitive_doc/primitive.usize.html"]' 'usize' +//@ has 'cross_crate_primitive_doc/fn.foo.html' '//a[@href="../primitive_doc/primitive.usize.html"]' 'link' /// [link](usize) pub fn foo() -> usize { 0 } diff --git a/tests/rustdoc/custom_code_classes.rs b/tests/rustdoc/custom_code_classes.rs index 569857a09cb..1e89b0761a6 100644 --- a/tests/rustdoc/custom_code_classes.rs +++ b/tests/rustdoc/custom_code_classes.rs @@ -4,10 +4,10 @@ #![feature(no_core)] #![no_core] -// @has 'foo/struct.Bar.html' -// @has - '//*[@id="main-content"]//pre[@class="language-whatever hoho-c"]' 'main;' -// @has - '//*[@id="main-content"]//pre[@class="language-whatever2 haha-c"]' 'main;' -// @has - '//*[@id="main-content"]//pre[@class="language-whatever4 huhu-c"]' 'main;' +//@ has 'foo/struct.Bar.html' +//@ has - '//*[@id="main-content"]//pre[@class="language-whatever hoho-c"]' 'main;' +//@ has - '//*[@id="main-content"]//pre[@class="language-whatever2 haha-c"]' 'main;' +//@ has - '//*[@id="main-content"]//pre[@class="language-whatever4 huhu-c"]' 'main;' /// ```{class=hoho-c},whatever /// main; diff --git a/tests/rustdoc/decl-line-wrapping-empty-arg-list.rs b/tests/rustdoc/decl-line-wrapping-empty-arg-list.rs index 4cfb87496b4..635c7762a53 100644 --- a/tests/rustdoc/decl-line-wrapping-empty-arg-list.rs +++ b/tests/rustdoc/decl-line-wrapping-empty-arg-list.rs @@ -5,8 +5,8 @@ pub struct Padding00000000000000000000000000000000000000000000000000000000000000000000000000000000; -// @has 'decl_line_wrapping_empty_arg_list/fn.create.html' -// @snapshot decl - '//pre[@class="rust item-decl"]' +//@ has 'decl_line_wrapping_empty_arg_list/fn.create.html' +//@ snapshot decl - '//pre[@class="rust item-decl"]' pub fn create() -> Padding00000000000000000000000000000000000000000000000000000000000000000000000000000000 { loop {} } diff --git a/tests/rustdoc/decl-trailing-whitespace.rs b/tests/rustdoc/decl-trailing-whitespace.rs index 66783774308..9fa01f3216c 100644 --- a/tests/rustdoc/decl-trailing-whitespace.rs +++ b/tests/rustdoc/decl-trailing-whitespace.rs @@ -4,10 +4,10 @@ pub struct Error; -// @has 'foo/trait.Write.html' +//@ has 'foo/trait.Write.html' pub trait Write { - // @snapshot 'declaration' - '//*[@class="rust item-decl"]//code' + //@ snapshot 'declaration' - '//*[@class="rust item-decl"]//code' fn poll_write( self, cx: &mut Option<String>, diff --git a/tests/rustdoc/decl_macro.rs b/tests/rustdoc/decl_macro.rs index 116fa15d749..da471e7c224 100644 --- a/tests/rustdoc/decl_macro.rs +++ b/tests/rustdoc/decl_macro.rs @@ -2,25 +2,25 @@ #![feature(decl_macro)] -// @has decl_macro/macro.my_macro.html //pre 'pub macro my_macro() {' -// @has - //pre '...' -// @has - //pre '}' +//@ has decl_macro/macro.my_macro.html //pre 'pub macro my_macro() {' +//@ has - //pre '...' +//@ has - //pre '}' pub macro my_macro() { } -// @has decl_macro/macro.my_macro_2.html //pre 'pub macro my_macro_2($($tok:tt)*) {' -// @has - //pre '...' -// @has - //pre '}' +//@ has decl_macro/macro.my_macro_2.html //pre 'pub macro my_macro_2($($tok:tt)*) {' +//@ has - //pre '...' +//@ has - //pre '}' pub macro my_macro_2($($tok:tt)*) { } -// @has decl_macro/macro.my_macro_multi.html //pre 'pub macro my_macro_multi {' -// @has - //pre '(_) => { ... },' -// @has - //pre '($foo:ident . $bar:expr) => { ... },' -// @has - //pre '($($foo:literal),+) => { ... },' -// @has - //pre '}' +//@ has decl_macro/macro.my_macro_multi.html //pre 'pub macro my_macro_multi {' +//@ has - //pre '(_) => { ... },' +//@ has - //pre '($foo:ident . $bar:expr) => { ... },' +//@ has - //pre '($($foo:literal),+) => { ... },' +//@ has - //pre '}' pub macro my_macro_multi { (_) => { @@ -33,21 +33,21 @@ pub macro my_macro_multi { } } -// @has decl_macro/macro.by_example_single.html //pre 'pub macro by_example_single($foo:expr) {' -// @has - //pre '...' -// @has - //pre '}' +//@ has decl_macro/macro.by_example_single.html //pre 'pub macro by_example_single($foo:expr) {' +//@ has - //pre '...' +//@ has - //pre '}' pub macro by_example_single { ($foo:expr) => {} } mod a { mod b { - // @has decl_macro/a/b/macro.by_example_vis.html //pre 'pub(super) macro by_example_vis($foo:expr) {' + //@ has decl_macro/a/b/macro.by_example_vis.html //pre 'pub(super) macro by_example_vis($foo:expr) {' pub(in super) macro by_example_vis { ($foo:expr) => {} } mod c { - // @has decl_macro/a/b/c/macro.by_example_vis_named.html //pre 'pub(in a) macro by_example_vis_named($foo:expr) {' + //@ has decl_macro/a/b/c/macro.by_example_vis_named.html //pre 'pub(in a) macro by_example_vis_named($foo:expr) {' pub(in a) macro by_example_vis_named { ($foo:expr) => {} } diff --git a/tests/rustdoc/decl_macro_priv.rs b/tests/rustdoc/decl_macro_priv.rs index 2a890e739f2..d87c8d22f2d 100644 --- a/tests/rustdoc/decl_macro_priv.rs +++ b/tests/rustdoc/decl_macro_priv.rs @@ -2,13 +2,13 @@ #![feature(decl_macro)] -// @has decl_macro_priv/macro.crate_macro.html //pre 'pub(crate) macro crate_macro() {' -// @has - //pre '...' -// @has - //pre '}' +//@ has decl_macro_priv/macro.crate_macro.html //pre 'pub(crate) macro crate_macro() {' +//@ has - //pre '...' +//@ has - //pre '}' pub(crate) macro crate_macro() {} -// @has decl_macro_priv/macro.priv_macro.html //pre 'macro priv_macro() {' -// @!has - //pre 'pub macro priv_macro() {' -// @has - //pre '...' -// @has - //pre '}' +//@ has decl_macro_priv/macro.priv_macro.html //pre 'macro priv_macro() {' +//@ !has - //pre 'pub macro priv_macro() {' +//@ has - //pre '...' +//@ has - //pre '}' macro priv_macro() {} diff --git a/tests/rustdoc/deduplicate-glob-import-impl-21474.rs b/tests/rustdoc/deduplicate-glob-import-impl-21474.rs index 2a675b4b6ef..5812d414997 100644 --- a/tests/rustdoc/deduplicate-glob-import-impl-21474.rs +++ b/tests/rustdoc/deduplicate-glob-import-impl-21474.rs @@ -9,6 +9,6 @@ mod inner { pub trait Blah { } -// @count issue_21474/struct.What.html \ +//@ count issue_21474/struct.What.html \ // '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1 pub struct What; diff --git a/tests/rustdoc/default-theme.rs b/tests/rustdoc/default-theme.rs index 4167086807c..529b994c3c2 100644 --- a/tests/rustdoc/default-theme.rs +++ b/tests/rustdoc/default-theme.rs @@ -1,7 +1,7 @@ //@ compile-flags: --default-theme ayu -// @has default_theme/index.html -// @has - '//script[@id="default-settings"]/@data-theme' 'ayu' -// @has - '//script[@id="default-settings"]/@data-use_system_theme' 'false' +//@ has default_theme/index.html +//@ has - '//script[@id="default-settings"]/@data-theme' 'ayu' +//@ has - '//script[@id="default-settings"]/@data-use_system_theme' 'false' pub fn whatever() {} diff --git a/tests/rustdoc/default-trait-method-link.rs b/tests/rustdoc/default-trait-method-link.rs index 7bcd2a3c149..3e03ecece97 100644 --- a/tests/rustdoc/default-trait-method-link.rs +++ b/tests/rustdoc/default-trait-method-link.rs @@ -1,7 +1,7 @@ #![crate_name = "foo"] -// @has foo/trait.Foo.html '//a[@href="trait.Foo.html#tymethod.req"]' 'req' -// @has foo/trait.Foo.html '//a[@href="trait.Foo.html#method.prov"]' 'prov' +//@ has foo/trait.Foo.html '//a[@href="trait.Foo.html#tymethod.req"]' 'req' +//@ has foo/trait.Foo.html '//a[@href="trait.Foo.html#method.prov"]' 'prov' /// Always make sure to implement [`req`], but you don't have to implement [`prov`]. /// diff --git a/tests/rustdoc/default-trait-method.rs b/tests/rustdoc/default-trait-method.rs index c8950678164..5a1d256e906 100644 --- a/tests/rustdoc/default-trait-method.rs +++ b/tests/rustdoc/default-trait-method.rs @@ -1,45 +1,45 @@ #![feature(min_specialization)] -// @has default_trait_method/trait.Item.html +//@ has default_trait_method/trait.Item.html pub trait Item { - // @has - '//*[@id="tymethod.foo"]' 'fn foo()' - // @!has - '//*[@id="tymethod.foo"]' 'default fn foo()' + //@ has - '//*[@id="tymethod.foo"]' 'fn foo()' + //@ !has - '//*[@id="tymethod.foo"]' 'default fn foo()' fn foo(); - // @has - '//*[@id="tymethod.bar"]' 'fn bar()' - // @!has - '//*[@id="tymethod.bar"]' 'default fn bar()' + //@ has - '//*[@id="tymethod.bar"]' 'fn bar()' + //@ !has - '//*[@id="tymethod.bar"]' 'default fn bar()' fn bar(); - // @has - '//*[@id="tymethod.baz"]' 'unsafe fn baz()' - // @!has - '//*[@id="tymethod.baz"]' 'default unsafe fn baz()' + //@ has - '//*[@id="tymethod.baz"]' 'unsafe fn baz()' + //@ !has - '//*[@id="tymethod.baz"]' 'default unsafe fn baz()' unsafe fn baz(); - // @has - '//*[@id="tymethod.quux"]' 'unsafe fn quux()' - // @!has - '//*[@id="tymethod.quux"]' 'default unsafe fn quux()' + //@ has - '//*[@id="tymethod.quux"]' 'unsafe fn quux()' + //@ !has - '//*[@id="tymethod.quux"]' 'default unsafe fn quux()' unsafe fn quux(); - // @has - '//*[@id="method.xyzzy"]' 'fn xyzzy()' - // @!has - '//*[@id="method.xyzzy"]' 'default fn xyzzy()' + //@ has - '//*[@id="method.xyzzy"]' 'fn xyzzy()' + //@ !has - '//*[@id="method.xyzzy"]' 'default fn xyzzy()' fn xyzzy() {} } -// @has default_trait_method/struct.Foo.html +//@ has default_trait_method/struct.Foo.html pub struct Foo; impl Item for Foo { - // @has - '//*[@id="method.foo"]' 'default fn foo()' + //@ has - '//*[@id="method.foo"]' 'default fn foo()' default fn foo() {} - // @has - '//*[@id="method.bar"]' 'fn bar()' - // @!has - '//*[@id="method.bar"]' 'default fn bar()' + //@ has - '//*[@id="method.bar"]' 'fn bar()' + //@ !has - '//*[@id="method.bar"]' 'default fn bar()' fn bar() {} - // @has - '//*[@id="method.baz"]' 'default unsafe fn baz()' + //@ has - '//*[@id="method.baz"]' 'default unsafe fn baz()' default unsafe fn baz() {} - // @has - '//*[@id="method.quux"]' 'unsafe fn quux()' - // @!has - '//*[@id="method.quux"]' 'default unsafe fn quux()' + //@ has - '//*[@id="method.quux"]' 'unsafe fn quux()' + //@ !has - '//*[@id="method.quux"]' 'default unsafe fn quux()' unsafe fn quux() {} - // @has - '//*[@id="method.xyzzy"]' 'fn xyzzy()' - // @!has - '//*[@id="method.xyzzy"]' 'default fn xyzzy()' + //@ has - '//*[@id="method.xyzzy"]' 'fn xyzzy()' + //@ !has - '//*[@id="method.xyzzy"]' 'default fn xyzzy()' } diff --git a/tests/rustdoc/deprecated-future-staged-api.rs b/tests/rustdoc/deprecated-future-staged-api.rs index 64dfd893050..1bb44e2a520 100644 --- a/tests/rustdoc/deprecated-future-staged-api.rs +++ b/tests/rustdoc/deprecated-future-staged-api.rs @@ -1,17 +1,17 @@ #![feature(staged_api)] #![stable(feature = "deprecated_future_staged_api", since = "1.0.0")] -// @has deprecated_future_staged_api/index.html '//*[@class="stab deprecated"]' \ +//@ has deprecated_future_staged_api/index.html '//*[@class="stab deprecated"]' \ // 'Deprecation planned' -// @has deprecated_future_staged_api/struct.S1.html '//*[@class="stab deprecated"]' \ +//@ has deprecated_future_staged_api/struct.S1.html '//*[@class="stab deprecated"]' \ // 'Deprecating in 99.99.99: effectively never' #[deprecated(since = "99.99.99", note = "effectively never")] #[stable(feature = "deprecated_future_staged_api", since = "1.0.0")] pub struct S1; -// @has deprecated_future_staged_api/index.html '//*[@class="stab deprecated"]' \ +//@ has deprecated_future_staged_api/index.html '//*[@class="stab deprecated"]' \ // 'Deprecation planned' -// @has deprecated_future_staged_api/struct.S2.html '//*[@class="stab deprecated"]' \ +//@ has deprecated_future_staged_api/struct.S2.html '//*[@class="stab deprecated"]' \ // 'Deprecating in a future version: literally never' #[deprecated(since = "TBD", note = "literally never")] #[stable(feature = "deprecated_future_staged_api", since = "1.0.0")] diff --git a/tests/rustdoc/deprecated-future.rs b/tests/rustdoc/deprecated-future.rs index 7db8cc60281..8e669e43bf7 100644 --- a/tests/rustdoc/deprecated-future.rs +++ b/tests/rustdoc/deprecated-future.rs @@ -1,6 +1,6 @@ -// @has deprecated_future/index.html '//*[@class="stab deprecated"]' \ +//@ has deprecated_future/index.html '//*[@class="stab deprecated"]' \ // 'Deprecated' -// @has deprecated_future/struct.S.html '//*[@class="stab deprecated"]' \ +//@ has deprecated_future/struct.S.html '//*[@class="stab deprecated"]' \ // 'Deprecated since 99.99.99: effectively never' #[deprecated(since = "99.99.99", note = "effectively never")] pub struct S; diff --git a/tests/rustdoc/deprecated-impls.rs b/tests/rustdoc/deprecated-impls.rs index e419d2631f6..a57f26ec7fd 100644 --- a/tests/rustdoc/deprecated-impls.rs +++ b/tests/rustdoc/deprecated-impls.rs @@ -1,19 +1,19 @@ #![crate_name = "foo"] -// @has foo/struct.Foo0.html +//@ has foo/struct.Foo0.html pub struct Foo0; impl Foo0 { - // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.1: fn_with_doc' - // @hasraw - 'fn_with_doc short' - // @hasraw - 'fn_with_doc full' + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.1: fn_with_doc' + //@ hasraw - 'fn_with_doc short' + //@ hasraw - 'fn_with_doc full' /// fn_with_doc short /// /// fn_with_doc full #[deprecated(since = "1.0.1", note = "fn_with_doc")] pub fn fn_with_doc() {} - // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.2: fn_without_doc' + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.2: fn_without_doc' #[deprecated(since = "1.0.2", note = "fn_without_doc")] pub fn fn_without_doc() {} } @@ -47,72 +47,72 @@ pub trait Bar { fn fn_def_def_without_doc() {} } -// @has foo/struct.Foo1.html +//@ has foo/struct.Foo1.html pub struct Foo1; impl Bar for Foo1 { - // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.3: fn_empty_with_doc' - // @hasraw - 'fn_empty_with_doc_impl short' - // @hasraw - 'fn_empty_with_doc_impl full' + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.3: fn_empty_with_doc' + //@ hasraw - 'fn_empty_with_doc_impl short' + //@ hasraw - 'fn_empty_with_doc_impl full' /// fn_empty_with_doc_impl short /// /// fn_empty_with_doc_impl full fn fn_empty_with_doc() {} - // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.4: fn_empty_without_doc' + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.4: fn_empty_without_doc' fn fn_empty_without_doc() {} - // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.5: fn_def_with_doc' - // @hasraw - 'fn_def_with_doc_impl short' - // @hasraw - 'fn_def_with_doc_impl full' + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.5: fn_def_with_doc' + //@ hasraw - 'fn_def_with_doc_impl short' + //@ hasraw - 'fn_def_with_doc_impl full' /// fn_def_with_doc_impl short /// /// fn_def_with_doc_impl full fn fn_def_with_doc() {} - // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.6: fn_def_without_doc' + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.6: fn_def_without_doc' fn fn_def_without_doc() {} - // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.7: fn_def_def_with_doc' - // @hasraw - 'fn_def_def_with_doc short' - // @!hasraw - 'fn_def_def_with_doc full' + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.7: fn_def_def_with_doc' + //@ hasraw - 'fn_def_def_with_doc short' + //@ !hasraw - 'fn_def_def_with_doc full' - // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.8: fn_def_def_without_doc' + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.8: fn_def_def_without_doc' } -// @has foo/struct.Foo2.html +//@ has foo/struct.Foo2.html pub struct Foo2; impl Bar for Foo2 { - // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.3: fn_empty_with_doc' - // @hasraw - 'fn_empty_with_doc short' - // @!hasraw - 'fn_empty_with_doc full' + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.3: fn_empty_with_doc' + //@ hasraw - 'fn_empty_with_doc short' + //@ !hasraw - 'fn_empty_with_doc full' fn fn_empty_with_doc() {} - // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.4: fn_empty_without_doc' - // @hasraw - 'fn_empty_without_doc_impl short' - // @hasraw - 'fn_empty_without_doc_impl full' + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.4: fn_empty_without_doc' + //@ hasraw - 'fn_empty_without_doc_impl short' + //@ hasraw - 'fn_empty_without_doc_impl full' /// fn_empty_without_doc_impl short /// /// fn_empty_without_doc_impl full fn fn_empty_without_doc() {} - // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.5: fn_def_with_doc' - // @hasraw - 'fn_def_with_doc short' - // @!hasraw - 'fn_def_with_doc full' + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.5: fn_def_with_doc' + //@ hasraw - 'fn_def_with_doc short' + //@ !hasraw - 'fn_def_with_doc full' fn fn_def_with_doc() {} - // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.6: fn_def_without_doc' - // @hasraw - 'fn_def_without_doc_impl short' - // @hasraw - 'fn_def_without_doc_impl full' + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.6: fn_def_without_doc' + //@ hasraw - 'fn_def_without_doc_impl short' + //@ hasraw - 'fn_def_without_doc_impl full' /// fn_def_without_doc_impl short /// /// fn_def_without_doc_impl full fn fn_def_without_doc() {} - // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.7: fn_def_def_with_doc' - // @hasraw - 'fn_def_def_with_doc short' - // @!hasraw - 'fn_def_def_with_doc full' + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.7: fn_def_def_with_doc' + //@ hasraw - 'fn_def_def_with_doc short' + //@ !hasraw - 'fn_def_def_with_doc full' - // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.8: fn_def_def_without_doc' + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.8: fn_def_def_without_doc' } diff --git a/tests/rustdoc/deprecated.rs b/tests/rustdoc/deprecated.rs index 9c9c0945b8f..b39da9b440a 100644 --- a/tests/rustdoc/deprecated.rs +++ b/tests/rustdoc/deprecated.rs @@ -1,33 +1,33 @@ -// @has deprecated/index.html '//*[@class="item-name"]/span[@class="stab deprecated"]' \ +//@ has deprecated/index.html '//*[@class="item-name"]/span[@class="stab deprecated"]' \ // 'Deprecated' -// @has - '//*[@class="desc docblock-short"]' 'Deprecated docs' +//@ has - '//*[@class="desc docblock-short"]' 'Deprecated docs' -// @has deprecated/struct.S.html '//*[@class="stab deprecated"]' \ +//@ has deprecated/struct.S.html '//*[@class="stab deprecated"]' \ // 'Deprecated since 1.0.0: text' /// Deprecated docs #[deprecated(since = "1.0.0", note = "text")] pub struct S; -// @matches deprecated/index.html '//*[@class="desc docblock-short"]' '^Docs' +//@ matches deprecated/index.html '//*[@class="desc docblock-short"]' '^Docs' /// Docs pub struct T; -// @matches deprecated/struct.U.html '//*[@class="stab deprecated"]' \ +//@ matches deprecated/struct.U.html '//*[@class="stab deprecated"]' \ // 'Deprecated since 1.0.0$' #[deprecated(since = "1.0.0")] pub struct U; -// @matches deprecated/struct.V.html '//*[@class="stab deprecated"]' \ +//@ matches deprecated/struct.V.html '//*[@class="stab deprecated"]' \ // 'Deprecated: text$' #[deprecated(note = "text")] pub struct V; -// @matches deprecated/struct.W.html '//*[@class="stab deprecated"]' \ +//@ matches deprecated/struct.W.html '//*[@class="stab deprecated"]' \ // 'Deprecated$' #[deprecated] pub struct W; -// @matches deprecated/struct.X.html '//*[@class="stab deprecated"]' \ +//@ matches deprecated/struct.X.html '//*[@class="stab deprecated"]' \ // 'Deprecated: shorthand reason: code$' #[deprecated = "shorthand reason: `code`"] pub struct X; diff --git a/tests/rustdoc/deref-methods-19190-foreign-type.rs b/tests/rustdoc/deref-methods-19190-foreign-type.rs index c8326992115..7ac0521eb29 100644 --- a/tests/rustdoc/deref-methods-19190-foreign-type.rs +++ b/tests/rustdoc/deref-methods-19190-foreign-type.rs @@ -11,6 +11,6 @@ impl Deref for Bar { fn deref(&self) -> &String { loop {} } } -// @has issue_19190_2/struct.Bar.html -// @!has - '//*[@id="method.new"]' 'fn new() -> String' -// @has - '//*[@id="method.as_str"]' 'fn as_str(&self) -> &str' +//@ has issue_19190_2/struct.Bar.html +//@ !has - '//*[@id="method.new"]' 'fn new() -> String' +//@ has - '//*[@id="method.as_str"]' 'fn as_str(&self) -> &str' diff --git a/tests/rustdoc/deref-methods-19190-inline.rs b/tests/rustdoc/deref-methods-19190-inline.rs index ef31cc70d93..942edbd5aaf 100644 --- a/tests/rustdoc/deref-methods-19190-inline.rs +++ b/tests/rustdoc/deref-methods-19190-inline.rs @@ -9,19 +9,19 @@ extern crate issue_19190_3; use std::ops::Deref; use issue_19190_3::Baz; -// @has issue_19190_3/struct.Foo.html -// @has - '//*[@id="method.as_str"]' 'fn as_str(&self) -> &str' -// @!has - '//*[@id="method.new"]' 'fn new() -> String' +//@ has issue_19190_3/struct.Foo.html +//@ has - '//*[@id="method.as_str"]' 'fn as_str(&self) -> &str' +//@ !has - '//*[@id="method.new"]' 'fn new() -> String' pub use issue_19190_3::Foo; -// @has issue_19190_3/struct.Bar.html -// @has - '//*[@id="method.baz"]' 'fn baz(&self)' -// @!has - '//*[@id="method.static_baz"]' 'fn static_baz()' +//@ has issue_19190_3/struct.Bar.html +//@ has - '//*[@id="method.baz"]' 'fn baz(&self)' +//@ !has - '//*[@id="method.static_baz"]' 'fn static_baz()' pub use issue_19190_3::Bar; -// @has issue_19190_3/struct.MyBar.html -// @has - '//*[@id="method.baz"]' 'fn baz(&self)' -// @!has - '//*[@id="method.static_baz"]' 'fn static_baz()' +//@ has issue_19190_3/struct.MyBar.html +//@ has - '//*[@id="method.baz"]' 'fn baz(&self)' +//@ !has - '//*[@id="method.static_baz"]' 'fn static_baz()' pub struct MyBar; impl Deref for MyBar { diff --git a/tests/rustdoc/deref-methods-19190.rs b/tests/rustdoc/deref-methods-19190.rs index 4c274d82ff7..ea10ac3b678 100644 --- a/tests/rustdoc/deref-methods-19190.rs +++ b/tests/rustdoc/deref-methods-19190.rs @@ -16,8 +16,8 @@ impl Deref for Bar { fn deref(&self) -> &Foo { loop {} } } -// @has issue_19190/struct.Bar.html -// @has - '//*[@id="method.foo"]//h4[@class="code-header"]' 'fn foo(&self)' -// @has - '//*[@id="method.foo"]' 'fn foo(&self)' -// @!has - '//*[@id="method.static_foo"]//h4[@class="code-header"]' 'fn static_foo()' -// @!has - '//*[@id="method.static_foo"]' 'fn static_foo()' +//@ has issue_19190/struct.Bar.html +//@ has - '//*[@id="method.foo"]//h4[@class="code-header"]' 'fn foo(&self)' +//@ has - '//*[@id="method.foo"]' 'fn foo(&self)' +//@ !has - '//*[@id="method.static_foo"]//h4[@class="code-header"]' 'fn static_foo()' +//@ !has - '//*[@id="method.static_foo"]' 'fn static_foo()' diff --git a/tests/rustdoc/deref-mut-35169-2.rs b/tests/rustdoc/deref-mut-35169-2.rs index c82323ddc6a..37462790f2e 100644 --- a/tests/rustdoc/deref-mut-35169-2.rs +++ b/tests/rustdoc/deref-mut-35169-2.rs @@ -26,18 +26,18 @@ impl DerefMut for Bar { fn deref_mut(&mut self) -> &mut Foo { loop {} } } -// @has foo/struct.Bar.html -// @has - '//*[@id="method.by_ref"]//h4[@class="code-header"]' 'fn by_ref(&self)' -// @has - '//*[@id="method.by_ref"]' 'fn by_ref(&self)' -// @has - '//*[@id="method.by_explicit_ref"]//h4[@class="code-header"]' 'fn by_explicit_ref(self: &Foo)' -// @has - '//*[@id="method.by_explicit_ref"]' 'fn by_explicit_ref(self: &Foo)' -// @has - '//*[@id="method.by_mut_ref"]//h4[@class="code-header"]' 'fn by_mut_ref(&mut self)' -// @has - '//*[@id="method.by_mut_ref"]' 'fn by_mut_ref(&mut self)' -// @has - '//*[@id="method.by_explicit_mut_ref"]//h4[@class="code-header"]' 'fn by_explicit_mut_ref(self: &mut Foo)' -// @has - '//*[@id="method.by_explicit_mut_ref"]' 'fn by_explicit_mut_ref(self: &mut Foo)' -// @!has - '//*[@id="method.by_explicit_box"]//h4[@class="code-header"]' 'fn by_explicit_box(self: Box<Foo>)' -// @!has - '//*[@id="method.by_explicit_box"]' 'fn by_explicit_box(self: Box<Foo>)' -// @!has - '//*[@id="method.by_explicit_self_box"]//h4[@class="code-header"]' 'fn by_explicit_self_box(self: Box<Self>)' -// @!has - '//*[@id="method.by_explicit_self_box"]' 'fn by_explicit_self_box(self: Box<Self>)' -// @!has - '//*[@id="method.static_foo"]//h4[@class="code-header"]' 'fn static_foo()' -// @!has - '//*[@id="method.static_foo"]' 'fn static_foo()' +//@ has foo/struct.Bar.html +//@ has - '//*[@id="method.by_ref"]//h4[@class="code-header"]' 'fn by_ref(&self)' +//@ has - '//*[@id="method.by_ref"]' 'fn by_ref(&self)' +//@ has - '//*[@id="method.by_explicit_ref"]//h4[@class="code-header"]' 'fn by_explicit_ref(self: &Foo)' +//@ has - '//*[@id="method.by_explicit_ref"]' 'fn by_explicit_ref(self: &Foo)' +//@ has - '//*[@id="method.by_mut_ref"]//h4[@class="code-header"]' 'fn by_mut_ref(&mut self)' +//@ has - '//*[@id="method.by_mut_ref"]' 'fn by_mut_ref(&mut self)' +//@ has - '//*[@id="method.by_explicit_mut_ref"]//h4[@class="code-header"]' 'fn by_explicit_mut_ref(self: &mut Foo)' +//@ has - '//*[@id="method.by_explicit_mut_ref"]' 'fn by_explicit_mut_ref(self: &mut Foo)' +//@ !has - '//*[@id="method.by_explicit_box"]//h4[@class="code-header"]' 'fn by_explicit_box(self: Box<Foo>)' +//@ !has - '//*[@id="method.by_explicit_box"]' 'fn by_explicit_box(self: Box<Foo>)' +//@ !has - '//*[@id="method.by_explicit_self_box"]//h4[@class="code-header"]' 'fn by_explicit_self_box(self: Box<Self>)' +//@ !has - '//*[@id="method.by_explicit_self_box"]' 'fn by_explicit_self_box(self: Box<Self>)' +//@ !has - '//*[@id="method.static_foo"]//h4[@class="code-header"]' 'fn static_foo()' +//@ !has - '//*[@id="method.static_foo"]' 'fn static_foo()' diff --git a/tests/rustdoc/deref-mut-35169.rs b/tests/rustdoc/deref-mut-35169.rs index 44afaf2e903..07a3754f795 100644 --- a/tests/rustdoc/deref-mut-35169.rs +++ b/tests/rustdoc/deref-mut-35169.rs @@ -21,18 +21,18 @@ impl Deref for Bar { fn deref(&self) -> &Foo { loop {} } } -// @has foo/struct.Bar.html -// @has - '//*[@id="method.by_ref"]//h4[@class="code-header"]' 'fn by_ref(&self)' -// @has - '//*[@id="method.by_ref"]' 'fn by_ref(&self)' -// @has - '//*[@id="method.by_explicit_ref"]//h4[@class="code-header"]' 'fn by_explicit_ref(self: &Foo)' -// @has - '//*[@id="method.by_explicit_ref"]' 'fn by_explicit_ref(self: &Foo)' -// @!has - '//*[@id="method.by_mut_ref"]//h4[@class="code-header"]' 'fn by_mut_ref(&mut self)' -// @!has - '//*[@id="method.by_mut_ref"]' 'fn by_mut_ref(&mut self)' -// @!has - '//*[@id="method.by_explicit_mut_ref"]//h4[@class="code-header"]' 'fn by_explicit_mut_ref(self: &mut Foo)' -// @!has - '//*[@id="method.by_explicit_mut_ref"]' 'fn by_explicit_mut_ref(self: &mut Foo)' -// @!has - '//*[@id="method.by_explicit_box"]//h4[@class="code-header"]' 'fn by_explicit_box(self: Box<Foo>)' -// @!has - '//*[@id="method.by_explicit_box"]' 'fn by_explicit_box(self: Box<Foo>)' -// @!has - '//*[@id="method.by_explicit_self_box"]//h4[@class="code-header"]' 'fn by_explicit_self_box(self: Box<Self>)' -// @!has - '//*[@id="method.by_explicit_self_box"]' 'fn by_explicit_self_box(self: Box<Self>)' -// @!has - '//*[@id="method.static_foo"]//h4[@class="code-header"]' 'fn static_foo()' -// @!has - '//*[@id="method.static_foo"]' 'fn static_foo()' +//@ has foo/struct.Bar.html +//@ has - '//*[@id="method.by_ref"]//h4[@class="code-header"]' 'fn by_ref(&self)' +//@ has - '//*[@id="method.by_ref"]' 'fn by_ref(&self)' +//@ has - '//*[@id="method.by_explicit_ref"]//h4[@class="code-header"]' 'fn by_explicit_ref(self: &Foo)' +//@ has - '//*[@id="method.by_explicit_ref"]' 'fn by_explicit_ref(self: &Foo)' +//@ !has - '//*[@id="method.by_mut_ref"]//h4[@class="code-header"]' 'fn by_mut_ref(&mut self)' +//@ !has - '//*[@id="method.by_mut_ref"]' 'fn by_mut_ref(&mut self)' +//@ !has - '//*[@id="method.by_explicit_mut_ref"]//h4[@class="code-header"]' 'fn by_explicit_mut_ref(self: &mut Foo)' +//@ !has - '//*[@id="method.by_explicit_mut_ref"]' 'fn by_explicit_mut_ref(self: &mut Foo)' +//@ !has - '//*[@id="method.by_explicit_box"]//h4[@class="code-header"]' 'fn by_explicit_box(self: Box<Foo>)' +//@ !has - '//*[@id="method.by_explicit_box"]' 'fn by_explicit_box(self: Box<Foo>)' +//@ !has - '//*[@id="method.by_explicit_self_box"]//h4[@class="code-header"]' 'fn by_explicit_self_box(self: Box<Self>)' +//@ !has - '//*[@id="method.by_explicit_self_box"]' 'fn by_explicit_self_box(self: Box<Self>)' +//@ !has - '//*[@id="method.static_foo"]//h4[@class="code-header"]' 'fn static_foo()' +//@ !has - '//*[@id="method.static_foo"]' 'fn static_foo()' diff --git a/tests/rustdoc/deref/deref-const-fn.rs b/tests/rustdoc/deref/deref-const-fn.rs index 85c2f2934e0..fa1e4730071 100644 --- a/tests/rustdoc/deref/deref-const-fn.rs +++ b/tests/rustdoc/deref/deref-const-fn.rs @@ -7,13 +7,13 @@ #![stable(feature = "rust1", since = "1.0.0")] -// @has 'foo/struct.Bar.html' +//@ has 'foo/struct.Bar.html' #[stable(feature = "rust1", since = "1.0.0")] pub struct Bar; impl Bar { - // @has - '//*[@id="method.len"]' 'pub const fn len(&self) -> usize' - // @has - '//*[@id="method.len"]//span[@class="since"]' 'const: 1.0.0' + //@ has - '//*[@id="method.len"]' 'pub const fn len(&self) -> usize' + //@ has - '//*[@id="method.len"]//span[@class="since"]' 'const: 1.0.0' #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "rust1", since = "1.0.0")] pub const fn len(&self) -> usize { 0 } @@ -24,10 +24,10 @@ pub struct Foo { value: Bar, } -// @has 'foo/struct.Foo.html' -// @has - '//*[@id="method.len"]' 'pub fn len(&self) -> usize' -// @has - '//*[@id="method.len"]//span[@class="since"]' '1.0.0' -// @!has - '//*[@id="method.len"]//span[@class="since"]' '(const: 1.0.0)' +//@ has 'foo/struct.Foo.html' +//@ has - '//*[@id="method.len"]' 'pub fn len(&self) -> usize' +//@ has - '//*[@id="method.len"]//span[@class="since"]' '1.0.0' +//@ !has - '//*[@id="method.len"]//span[@class="since"]' '(const: 1.0.0)' #[stable(feature = "rust1", since = "1.0.0")] impl std::ops::Deref for Foo { type Target = Bar; diff --git a/tests/rustdoc/deref/deref-multiple-impl-blocks.rs b/tests/rustdoc/deref/deref-multiple-impl-blocks.rs index fa3607c5fc1..2ce35627546 100644 --- a/tests/rustdoc/deref/deref-multiple-impl-blocks.rs +++ b/tests/rustdoc/deref/deref-multiple-impl-blocks.rs @@ -2,11 +2,11 @@ use std::ops::{Deref, DerefMut}; -// @has foo/struct.Vec.html -// @count - '//h2[@id="deref-methods-Slice"]' 1 -// @count - '//div[@id="deref-methods-Slice-1"]' 1 -// @count - '//div[@id="deref-methods-Slice-1"][@class="impl-items"]' 1 -// @count - '//div[@id="deref-methods-Slice-1"]/div[@class="impl-items"]' 0 +//@ has foo/struct.Vec.html +//@ count - '//h2[@id="deref-methods-Slice"]' 1 +//@ count - '//div[@id="deref-methods-Slice-1"]' 1 +//@ count - '//div[@id="deref-methods-Slice-1"][@class="impl-items"]' 1 +//@ count - '//div[@id="deref-methods-Slice-1"]/div[@class="impl-items"]' 0 pub struct Vec; pub struct Slice; diff --git a/tests/rustdoc/deref/deref-mut-methods.rs b/tests/rustdoc/deref/deref-mut-methods.rs index 65681f81245..83214ca3b8a 100644 --- a/tests/rustdoc/deref/deref-mut-methods.rs +++ b/tests/rustdoc/deref/deref-mut-methods.rs @@ -8,8 +8,8 @@ impl Foo { pub fn foo(&mut self) {} } -// @has foo/struct.Bar.html -// @has - '//*[@class="sidebar-elems"]//*[@class="block deref-methods"]//a[@href="#method.foo"]' 'foo' +//@ has foo/struct.Bar.html +//@ has - '//*[@class="sidebar-elems"]//*[@class="block deref-methods"]//a[@href="#method.foo"]' 'foo' pub struct Bar { foo: Foo, } diff --git a/tests/rustdoc/deref/deref-recursive-pathbuf.rs b/tests/rustdoc/deref/deref-recursive-pathbuf.rs index 7aee3147ba8..be6b1811503 100644 --- a/tests/rustdoc/deref/deref-recursive-pathbuf.rs +++ b/tests/rustdoc/deref/deref-recursive-pathbuf.rs @@ -2,15 +2,15 @@ // levels and across multiple crates. // For `Deref` on non-foreign types, look at `deref-recursive.rs`. -// @has 'foo/struct.Foo.html' -// @has '-' '//*[@id="deref-methods-PathBuf"]' 'Methods from Deref<Target = PathBuf>' -// @has '-' '//*[@class="impl-items"]//*[@id="method.as_path"]' 'pub fn as_path(&self)' -// @has '-' '//*[@id="deref-methods-Path"]' 'Methods from Deref<Target = Path>' -// @has '-' '//*[@class="impl-items"]//*[@id="method.exists"]' 'pub fn exists(&self)' -// @has '-' '//div[@class="sidebar-elems"]//h3/a[@href="#deref-methods-PathBuf"]' 'Methods from Deref<Target=PathBuf>' -// @has '-' '//*[@class="sidebar-elems"]//*[@class="block deref-methods"]//a[@href="#method.as_path"]' 'as_path' -// @has '-' '//div[@class="sidebar-elems"]//h3/a[@href="#deref-methods-Path"]' 'Methods from Deref<Target=Path>' -// @has '-' '//*[@class="sidebar-elems"]//*[@class="block deref-methods"]//a[@href="#method.exists"]' 'exists' +//@ has 'foo/struct.Foo.html' +//@ has '-' '//*[@id="deref-methods-PathBuf"]' 'Methods from Deref<Target = PathBuf>' +//@ has '-' '//*[@class="impl-items"]//*[@id="method.as_path"]' 'pub fn as_path(&self)' +//@ has '-' '//*[@id="deref-methods-Path"]' 'Methods from Deref<Target = Path>' +//@ has '-' '//*[@class="impl-items"]//*[@id="method.exists"]' 'pub fn exists(&self)' +//@ has '-' '//div[@class="sidebar-elems"]//h3/a[@href="#deref-methods-PathBuf"]' 'Methods from Deref<Target=PathBuf>' +//@ has '-' '//*[@class="sidebar-elems"]//*[@class="block deref-methods"]//a[@href="#method.as_path"]' 'as_path' +//@ has '-' '//div[@class="sidebar-elems"]//h3/a[@href="#deref-methods-Path"]' 'Methods from Deref<Target=Path>' +//@ has '-' '//*[@class="sidebar-elems"]//*[@class="block deref-methods"]//a[@href="#method.exists"]' 'exists' #![crate_name = "foo"] diff --git a/tests/rustdoc/deref/deref-recursive.rs b/tests/rustdoc/deref/deref-recursive.rs index 0436f2f86f5..604ce7a40c0 100644 --- a/tests/rustdoc/deref/deref-recursive.rs +++ b/tests/rustdoc/deref/deref-recursive.rs @@ -2,15 +2,15 @@ // levels if needed. // For `Deref` on foreign types, look at `deref-recursive-pathbuf.rs`. -// @has 'foo/struct.Foo.html' -// @has '-' '//*[@id="deref-methods-Bar"]' 'Methods from Deref<Target = Bar>' -// @has '-' '//*[@class="impl-items"]//*[@id="method.bar"]' 'pub fn bar(&self)' -// @has '-' '//*[@id="deref-methods-Baz"]' 'Methods from Deref<Target = Baz>' -// @has '-' '//*[@class="impl-items"]//*[@id="method.baz"]' 'pub fn baz(&self)' -// @has '-' '//div[@class="sidebar-elems"]//h3/a[@href="#deref-methods-Bar"]' 'Methods from Deref<Target=Bar>' -// @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.bar"]' 'bar' -// @has '-' '//div[@class="sidebar-elems"]//h3/a[@href="#deref-methods-Baz"]' 'Methods from Deref<Target=Baz>' -// @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.baz"]' 'baz' +//@ has 'foo/struct.Foo.html' +//@ has '-' '//*[@id="deref-methods-Bar"]' 'Methods from Deref<Target = Bar>' +//@ has '-' '//*[@class="impl-items"]//*[@id="method.bar"]' 'pub fn bar(&self)' +//@ has '-' '//*[@id="deref-methods-Baz"]' 'Methods from Deref<Target = Baz>' +//@ has '-' '//*[@class="impl-items"]//*[@id="method.baz"]' 'pub fn baz(&self)' +//@ has '-' '//div[@class="sidebar-elems"]//h3/a[@href="#deref-methods-Bar"]' 'Methods from Deref<Target=Bar>' +//@ has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.bar"]' 'bar' +//@ has '-' '//div[@class="sidebar-elems"]//h3/a[@href="#deref-methods-Baz"]' 'Methods from Deref<Target=Baz>' +//@ has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.baz"]' 'baz' #![crate_name = "foo"] diff --git a/tests/rustdoc/deref/deref-slice-core.rs b/tests/rustdoc/deref/deref-slice-core.rs index cccf273a820..3a21c19ddd1 100644 --- a/tests/rustdoc/deref/deref-slice-core.rs +++ b/tests/rustdoc/deref/deref-slice-core.rs @@ -5,9 +5,9 @@ use core::ops::Deref; -// @has 'deref_slice_core/struct.MyArray.html' -// @has '-' '//*[@id="deref-methods-%5BT%5D"]' 'Methods from Deref<Target = [T]>' -// @has '-' '//*[@class="impl-items"]//*[@id="method.len"]' 'pub fn len(&self)' +//@ has 'deref_slice_core/struct.MyArray.html' +//@ has '-' '//*[@id="deref-methods-%5BT%5D"]' 'Methods from Deref<Target = [T]>' +//@ has '-' '//*[@class="impl-items"]//*[@id="method.len"]' 'pub fn len(&self)' pub struct MyArray<T> { array: [T; 10], diff --git a/tests/rustdoc/deref/deref-to-primitive.rs b/tests/rustdoc/deref/deref-to-primitive.rs index 527de780d48..7a5a3cd8fd6 100644 --- a/tests/rustdoc/deref/deref-to-primitive.rs +++ b/tests/rustdoc/deref/deref-to-primitive.rs @@ -1,8 +1,8 @@ #![crate_name = "foo"] -// @has 'foo/struct.Foo.html' -// @has - '//*[@id="deref-methods-i32"]' 'Methods from Deref<Target = i32>' -// @has - '//*[@id="deref-methods-i32-1"]//*[@id="associatedconstant.BITS"]/h4' \ +//@ has 'foo/struct.Foo.html' +//@ has - '//*[@id="deref-methods-i32"]' 'Methods from Deref<Target = i32>' +//@ has - '//*[@id="deref-methods-i32-1"]//*[@id="associatedconstant.BITS"]/h4' \ // 'pub const BITS: u32 = 32u32' pub struct Foo(i32); diff --git a/tests/rustdoc/deref/deref-typedef.rs b/tests/rustdoc/deref/deref-typedef.rs index 32424d13eb8..44324cc6f41 100644 --- a/tests/rustdoc/deref/deref-typedef.rs +++ b/tests/rustdoc/deref/deref-typedef.rs @@ -1,16 +1,16 @@ #![crate_name = "foo"] -// @has 'foo/struct.Bar.html' -// @has '-' '//*[@id="deref-methods-FooJ"]' 'Methods from Deref<Target = FooJ>' -// @has '-' '//*[@class="impl-items"]//*[@id="method.foo_a"]' 'pub fn foo_a(&self)' -// @has '-' '//*[@class="impl-items"]//*[@id="method.foo_b"]' 'pub fn foo_b(&self)' -// @has '-' '//*[@class="impl-items"]//*[@id="method.foo_c"]' 'pub fn foo_c(&self)' -// @has '-' '//*[@class="impl-items"]//*[@id="method.foo_j"]' 'pub fn foo_j(&self)' -// @has '-' '//div[@class="sidebar-elems"]//h3/a[@href="#deref-methods-FooJ"]' 'Methods from Deref<Target=FooJ>' -// @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.foo_a"]' 'foo_a' -// @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.foo_b"]' 'foo_b' -// @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.foo_c"]' 'foo_c' -// @has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.foo_j"]' 'foo_j' +//@ has 'foo/struct.Bar.html' +//@ has '-' '//*[@id="deref-methods-FooJ"]' 'Methods from Deref<Target = FooJ>' +//@ has '-' '//*[@class="impl-items"]//*[@id="method.foo_a"]' 'pub fn foo_a(&self)' +//@ has '-' '//*[@class="impl-items"]//*[@id="method.foo_b"]' 'pub fn foo_b(&self)' +//@ has '-' '//*[@class="impl-items"]//*[@id="method.foo_c"]' 'pub fn foo_c(&self)' +//@ has '-' '//*[@class="impl-items"]//*[@id="method.foo_j"]' 'pub fn foo_j(&self)' +//@ has '-' '//div[@class="sidebar-elems"]//h3/a[@href="#deref-methods-FooJ"]' 'Methods from Deref<Target=FooJ>' +//@ has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.foo_a"]' 'foo_a' +//@ has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.foo_b"]' 'foo_b' +//@ has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.foo_c"]' 'foo_c' +//@ has '-' '//*[@class="sidebar-elems"]//section//a[@href="#method.foo_j"]' 'foo_j' pub struct FooA; pub type FooB = FooA; diff --git a/tests/rustdoc/deref/escape-deref-methods.rs b/tests/rustdoc/deref/escape-deref-methods.rs index 66919d73eeb..2e423640f67 100644 --- a/tests/rustdoc/deref/escape-deref-methods.rs +++ b/tests/rustdoc/deref/escape-deref-methods.rs @@ -26,8 +26,8 @@ impl Deref for TitleList { } } -// @has foo/struct.TitleList.html -// @has - '//div[@class="sidebar-elems"]//h3' 'Methods from Deref<Target=Vec<Title>>' +//@ has foo/struct.TitleList.html +//@ has - '//div[@class="sidebar-elems"]//h3' 'Methods from Deref<Target=Vec<Title>>' impl DerefMut for TitleList { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.members diff --git a/tests/rustdoc/deref/issue-100679-sidebar-links-deref.rs b/tests/rustdoc/deref/issue-100679-sidebar-links-deref.rs index f09d2320609..44ac08de0b8 100644 --- a/tests/rustdoc/deref/issue-100679-sidebar-links-deref.rs +++ b/tests/rustdoc/deref/issue-100679-sidebar-links-deref.rs @@ -11,7 +11,7 @@ impl std::ops::Deref for Vec { } } -// @has foo/struct.Vec.html '//*[@class="sidebar-elems"]//section//li/a[@href="#method.is_empty"]' \ +//@ has foo/struct.Vec.html '//*[@class="sidebar-elems"]//section//li/a[@href="#method.is_empty"]' \ // "is_empty" impl Vec { pub fn is_empty(&self) -> bool { @@ -19,9 +19,9 @@ impl Vec { } } -// @has foo/struct.Vec.html '//*[@class="sidebar-elems"]//section//li/a[@href="#method.is_empty-1"]' \ +//@ has foo/struct.Vec.html '//*[@class="sidebar-elems"]//section//li/a[@href="#method.is_empty-1"]' \ // "is_empty" -// @has foo/struct.Slice.html '//*[@class="sidebar-elems"]//section//li/a[@href="#method.is_empty"]' \ +//@ has foo/struct.Slice.html '//*[@class="sidebar-elems"]//section//li/a[@href="#method.is_empty"]' \ // "is_empty" impl Slice { pub fn is_empty(&self) -> bool { diff --git a/tests/rustdoc/deref/recursive-deref-sidebar.rs b/tests/rustdoc/deref/recursive-deref-sidebar.rs index 619f40eff89..0af5326f3dc 100644 --- a/tests/rustdoc/deref/recursive-deref-sidebar.rs +++ b/tests/rustdoc/deref/recursive-deref-sidebar.rs @@ -9,13 +9,13 @@ impl B { pub fn foo_b(&self) {} } pub struct C {} impl C { pub fn foo_c(&self) {} } -// @has recursive_deref_sidebar/struct.A.html '//*[@class="sidebar-elems"]//section' 'foo_b' +//@ has recursive_deref_sidebar/struct.A.html '//*[@class="sidebar-elems"]//section' 'foo_b' impl Deref for A { type Target = B; fn deref(&self) -> &B { todo!() } } -// @has recursive_deref_sidebar/struct.A.html '//*[@class="sidebar-elems"]//section' 'foo_c' +//@ has recursive_deref_sidebar/struct.A.html '//*[@class="sidebar-elems"]//section' 'foo_c' impl Deref for B { type Target = C; fn deref(&self) -> &C { todo!() } diff --git a/tests/rustdoc/deref/recursive-deref.rs b/tests/rustdoc/deref/recursive-deref.rs index aa38485c445..286abef382c 100644 --- a/tests/rustdoc/deref/recursive-deref.rs +++ b/tests/rustdoc/deref/recursive-deref.rs @@ -9,8 +9,8 @@ impl C { pub fn c(&self) {} } -// @has recursive_deref/struct.A.html '//h3[@class="code-header"]' 'impl Deref for A' -// @has '-' '//*[@class="impl-items"]//*[@id="method.c"]' 'pub fn c(&self)' +//@ has recursive_deref/struct.A.html '//h3[@class="code-header"]' 'impl Deref for A' +//@ has '-' '//*[@class="impl-items"]//*[@id="method.c"]' 'pub fn c(&self)' impl Deref for A { type Target = B; @@ -19,8 +19,8 @@ impl Deref for A { } } -// @has recursive_deref/struct.B.html '//h3[@class="code-header"]' 'impl Deref for B' -// @has '-' '//*[@class="impl-items"]//*[@id="method.c"]' 'pub fn c(&self)' +//@ has recursive_deref/struct.B.html '//h3[@class="code-header"]' 'impl Deref for B' +//@ has '-' '//*[@class="impl-items"]//*[@id="method.c"]' 'pub fn c(&self)' impl Deref for B { type Target = C; @@ -29,7 +29,7 @@ impl Deref for B { } } -// @has recursive_deref/struct.C.html '//h3[@class="code-header"]' 'impl Deref for C' +//@ has recursive_deref/struct.C.html '//h3[@class="code-header"]' 'impl Deref for C' impl Deref for C { type Target = B; @@ -49,9 +49,9 @@ impl G { pub fn g() {} } -// @has recursive_deref/struct.D.html '//h3[@class="code-header"]' 'impl Deref for D' +//@ has recursive_deref/struct.D.html '//h3[@class="code-header"]' 'impl Deref for D' // We also check that `G::g` method isn't rendered because there is no `self` argument. -// @!has '-' '//*[@id="deref-methods-G"]' '' +//@ !has '-' '//*[@id="deref-methods-G"]' '' impl Deref for D { type Target = E; @@ -60,9 +60,9 @@ impl Deref for D { } } -// @has recursive_deref/struct.E.html '//h3[@class="code-header"]' 'impl Deref for E' +//@ has recursive_deref/struct.E.html '//h3[@class="code-header"]' 'impl Deref for E' // We also check that `G::g` method isn't rendered because there is no `self` argument. -// @!has '-' '//*[@id="deref-methods-G"]' '' +//@ !has '-' '//*[@id="deref-methods-G"]' '' impl Deref for E { type Target = F; @@ -71,9 +71,9 @@ impl Deref for E { } } -// @has recursive_deref/struct.F.html '//h3[@class="code-header"]' 'impl Deref for F' +//@ has recursive_deref/struct.F.html '//h3[@class="code-header"]' 'impl Deref for F' // We also check that `G::g` method isn't rendered because there is no `self` argument. -// @!has '-' '//*[@id="deref-methods-G"]' '' +//@ !has '-' '//*[@id="deref-methods-G"]' '' impl Deref for F { type Target = G; @@ -82,7 +82,7 @@ impl Deref for F { } } -// @has recursive_deref/struct.G.html '//h3[@class="code-header"]' 'impl Deref for G' +//@ has recursive_deref/struct.G.html '//h3[@class="code-header"]' 'impl Deref for G' impl Deref for G { type Target = E; @@ -100,8 +100,8 @@ impl I { pub fn i() {} } -// @has recursive_deref/struct.H.html '//h3[@class="code-header"]' 'impl Deref for H' -// @!has '-' '//*[@id="deref-methods-I"]' '' +//@ has recursive_deref/struct.H.html '//h3[@class="code-header"]' 'impl Deref for H' +//@ !has '-' '//*[@id="deref-methods-I"]' '' impl Deref for H { type Target = I; @@ -110,7 +110,7 @@ impl Deref for H { } } -// @has recursive_deref/struct.I.html '//h3[@class="code-header"]' 'impl Deref for I' +//@ has recursive_deref/struct.I.html '//h3[@class="code-header"]' 'impl Deref for I' impl Deref for I { type Target = H; diff --git a/tests/rustdoc/description.rs b/tests/rustdoc/description.rs index aabbb4c4c8f..be6ef1dc756 100644 --- a/tests/rustdoc/description.rs +++ b/tests/rustdoc/description.rs @@ -5,13 +5,13 @@ //! This is the contents of the test crate docstring. //! It should not show up in the description. -// @has 'foo/index.html' '//meta[@name="description"]/@content' \ +//@ has 'foo/index.html' '//meta[@name="description"]/@content' \ // 'Description test crate' -// @!has - '//meta[@name="description"]/@content' 'should not show up' +//@ !has - '//meta[@name="description"]/@content' 'should not show up' -// @has 'foo/foo_mod/index.html' '//meta[@name="description"]/@content' \ +//@ has 'foo/foo_mod/index.html' '//meta[@name="description"]/@content' \ // 'First paragraph description.' -// @!has - '//meta[@name="description"]/@content' 'Second paragraph' +//@ !has - '//meta[@name="description"]/@content' 'Second paragraph' /// First paragraph description. /// /// Second paragraph should not show up. @@ -19,12 +19,12 @@ pub mod foo_mod { pub struct __Thing {} } -// @has 'foo/fn.foo_fn.html' '//meta[@name="description"]/@content' \ +//@ has 'foo/fn.foo_fn.html' '//meta[@name="description"]/@content' \ // 'Only paragraph.' /// Only paragraph. pub fn foo_fn() {} -// @has 'foo/fn.bar_fn.html' '//meta[@name="description"]/@content' \ +//@ has 'foo/fn.bar_fn.html' '//meta[@name="description"]/@content' \ // 'Description with intra-doc link to foo_fn and [nonexistent_item] and foo_fn.' #[allow(rustdoc::broken_intra_doc_links)] /// Description with intra-doc link to [foo_fn] and [nonexistent_item] and [foo_fn](self::foo_fn). diff --git a/tests/rustdoc/description_default.rs b/tests/rustdoc/description_default.rs index 21d8e04d3f9..6a673870bec 100644 --- a/tests/rustdoc/description_default.rs +++ b/tests/rustdoc/description_default.rs @@ -1,14 +1,14 @@ #![crate_name = "foo"] -// @has 'foo/index.html' '//meta[@name="description"]/@content' \ +//@ has 'foo/index.html' '//meta[@name="description"]/@content' \ // 'API documentation for the Rust `foo` crate.' -// @has 'foo/foo_mod/index.html' '//meta[@name="description"]/@content' \ +//@ has 'foo/foo_mod/index.html' '//meta[@name="description"]/@content' \ // 'API documentation for the Rust `foo_mod` mod in crate `foo`.' pub mod foo_mod { pub struct __Thing {} } -// @has 'foo/fn.foo_fn.html' '//meta[@name="description"]/@content' \ +//@ has 'foo/fn.foo_fn.html' '//meta[@name="description"]/@content' \ // 'API documentation for the Rust `foo_fn` fn in crate `foo`.' pub fn foo_fn() {} diff --git a/tests/rustdoc/disambiguate-anchors-32890.rs b/tests/rustdoc/disambiguate-anchors-32890.rs index d88601d65d3..0b726d5fba4 100644 --- a/tests/rustdoc/disambiguate-anchors-32890.rs +++ b/tests/rustdoc/disambiguate-anchors-32890.rs @@ -1,20 +1,20 @@ // https://github.com/rust-lang/rust/issues/32890 #![crate_name="issue_32890"] -// @has issue_32890/struct.Foo.html +//@ has issue_32890/struct.Foo.html pub struct Foo<T>(T); impl Foo<u8> { - // @has - '//a[@href="#method.pass"]' 'pass' + //@ has - '//a[@href="#method.pass"]' 'pass' pub fn pass() {} } impl Foo<u16> { - // @has - '//a[@href="#method.pass-1"]' 'pass' + //@ has - '//a[@href="#method.pass-1"]' 'pass' pub fn pass() {} } impl Foo<u32> { - // @has - '//a[@href="#method.pass-2"]' 'pass' + //@ has - '//a[@href="#method.pass-2"]' 'pass' pub fn pass() {} } diff --git a/tests/rustdoc/disambiguate-anchors-header-29449.rs b/tests/rustdoc/disambiguate-anchors-header-29449.rs index 1388af7df4b..feb0632775e 100644 --- a/tests/rustdoc/disambiguate-anchors-header-29449.rs +++ b/tests/rustdoc/disambiguate-anchors-header-29449.rs @@ -1,27 +1,27 @@ // https://github.com/rust-lang/rust/issues/29449 #![crate_name="issue_29449"] -// @has issue_29449/struct.Foo.html +//@ has issue_29449/struct.Foo.html pub struct Foo; impl Foo { - // @has - '//*[@id="examples"]' 'Examples' - // @has - '//*[@id="examples"]/a[@href="#examples"]' '§' - // @has - '//*[@id="panics"]' 'Panics' - // @has - '//*[@id="panics"]/a[@href="#panics"]' '§' + //@ has - '//*[@id="examples"]' 'Examples' + //@ has - '//*[@id="examples"]/a[@href="#examples"]' '§' + //@ has - '//*[@id="panics"]' 'Panics' + //@ has - '//*[@id="panics"]/a[@href="#panics"]' '§' /// # Examples /// # Panics pub fn bar() {} - // @has - '//*[@id="examples-1"]' 'Examples' - // @has - '//*[@id="examples-1"]/a[@href="#examples-1"]' '§' + //@ has - '//*[@id="examples-1"]' 'Examples' + //@ has - '//*[@id="examples-1"]/a[@href="#examples-1"]' '§' /// # Examples pub fn bar_1() {} - // @has - '//*[@id="examples-2"]' 'Examples' - // @has - '//*[@id="examples-2"]/a[@href="#examples-2"]' '§' - // @has - '//*[@id="panics-1"]' 'Panics' - // @has - '//*[@id="panics-1"]/a[@href="#panics-1"]' '§' + //@ has - '//*[@id="examples-2"]' 'Examples' + //@ has - '//*[@id="examples-2"]/a[@href="#examples-2"]' '§' + //@ has - '//*[@id="panics-1"]' 'Panics' + //@ has - '//*[@id="panics-1"]/a[@href="#panics-1"]' '§' /// # Examples /// # Panics pub fn bar_2() {} diff --git a/tests/rustdoc/display-hidden-items.rs b/tests/rustdoc/display-hidden-items.rs index 901ca17d4d2..d9f53435e46 100644 --- a/tests/rustdoc/display-hidden-items.rs +++ b/tests/rustdoc/display-hidden-items.rs @@ -4,72 +4,72 @@ #![crate_name = "foo"] -// @has 'foo/index.html' -// @has - '//*[@class="item-name"]/span[@title="Hidden item"]' '👻' +//@ has 'foo/index.html' +//@ has - '//*[@class="item-name"]/span[@title="Hidden item"]' '👻' -// @has - '//*[@id="reexport.hidden_reexport"]/code' '#[doc(hidden)] pub use hidden::inside_hidden as hidden_reexport;' +//@ has - '//*[@id="reexport.hidden_reexport"]/code' '#[doc(hidden)] pub use hidden::inside_hidden as hidden_reexport;' #[doc(hidden)] pub use hidden::inside_hidden as hidden_reexport; -// @has - '//*[@class="item-name"]/a[@class="trait"]' 'TraitHidden' -// @has 'foo/trait.TraitHidden.html' -// @has - '//code' '#[doc(hidden)] pub trait TraitHidden' +//@ has - '//*[@class="item-name"]/a[@class="trait"]' 'TraitHidden' +//@ has 'foo/trait.TraitHidden.html' +//@ has - '//code' '#[doc(hidden)] pub trait TraitHidden' #[doc(hidden)] pub trait TraitHidden {} -// @has 'foo/index.html' '//*[@class="item-name"]/a[@class="trait"]' 'Trait' +//@ has 'foo/index.html' '//*[@class="item-name"]/a[@class="trait"]' 'Trait' pub trait Trait { - // @has 'foo/trait.Trait.html' - // @has - '//*[@id="associatedconstant.BAR"]/*[@class="code-header"]' '#[doc(hidden)] const BAR: u32 = 0u32' + //@ has 'foo/trait.Trait.html' + //@ has - '//*[@id="associatedconstant.BAR"]/*[@class="code-header"]' '#[doc(hidden)] const BAR: u32 = 0u32' #[doc(hidden)] const BAR: u32 = 0; - // @has - '//*[@id="method.foo"]/*[@class="code-header"]' 'fn foo()' + //@ has - '//*[@id="method.foo"]/*[@class="code-header"]' 'fn foo()' #[doc(hidden)] fn foo() {} } -// @has 'foo/index.html' '//*[@class="item-name"]/a[@class="struct"]' 'Struct' -// @has 'foo/struct.Struct.html' +//@ has 'foo/index.html' '//*[@class="item-name"]/a[@class="struct"]' 'Struct' +//@ has 'foo/struct.Struct.html' pub struct Struct { - // @has - '//*[@id="structfield.a"]/code' 'a: u32' + //@ has - '//*[@id="structfield.a"]/code' 'a: u32' #[doc(hidden)] pub a: u32, } impl Struct { - // @has - '//*[@id="method.new"]/*[@class="code-header"]' 'pub fn new() -> Self' + //@ has - '//*[@id="method.new"]/*[@class="code-header"]' 'pub fn new() -> Self' #[doc(hidden)] pub fn new() -> Self { Self { a: 0 } } } impl Trait for Struct { - // @has - '//*[@id="associatedconstant.BAR"]/*[@class="code-header"]' '#[doc(hidden)] const BAR: u32 = 0u32' - // @has - '//*[@id="method.foo"]/*[@class="code-header"]' '#[doc(hidden)] fn foo()' + //@ has - '//*[@id="associatedconstant.BAR"]/*[@class="code-header"]' '#[doc(hidden)] const BAR: u32 = 0u32' + //@ has - '//*[@id="method.foo"]/*[@class="code-header"]' '#[doc(hidden)] fn foo()' } -// @has - '//*[@id="impl-TraitHidden-for-Struct"]/*[@class="code-header"]' 'impl TraitHidden for Struct' +//@ has - '//*[@id="impl-TraitHidden-for-Struct"]/*[@class="code-header"]' 'impl TraitHidden for Struct' impl TraitHidden for Struct {} -// @has 'foo/index.html' '//*[@class="item-name"]/a[@class="enum"]' 'HiddenEnum' -// @has 'foo/enum.HiddenEnum.html' -// @has - '//code' '#[doc(hidden)] pub enum HiddenEnum' +//@ has 'foo/index.html' '//*[@class="item-name"]/a[@class="enum"]' 'HiddenEnum' +//@ has 'foo/enum.HiddenEnum.html' +//@ has - '//code' '#[doc(hidden)] pub enum HiddenEnum' #[doc(hidden)] pub enum HiddenEnum { A, } -// @has 'foo/index.html' '//*[@class="item-name"]/a[@class="enum"]' 'Enum' +//@ has 'foo/index.html' '//*[@class="item-name"]/a[@class="enum"]' 'Enum' pub enum Enum { - // @has 'foo/enum.Enum.html' '//*[@id="variant.A"]/*[@class="code-header"]' 'A' + //@ has 'foo/enum.Enum.html' '//*[@id="variant.A"]/*[@class="code-header"]' 'A' #[doc(hidden)] A, } -// @has 'foo/index.html' '//*[@class="item-name"]/a[@class="mod"]' 'hidden' +//@ has 'foo/index.html' '//*[@class="item-name"]/a[@class="mod"]' 'hidden' #[doc(hidden)] pub mod hidden { - // @has 'foo/hidden/index.html' - // @has - '//*[@class="item-name"]/a[@class="fn"]' 'inside_hidden' - // @has 'foo/hidden/fn.inside_hidden.html' + //@ has 'foo/hidden/index.html' + //@ has - '//*[@class="item-name"]/a[@class="fn"]' 'inside_hidden' + //@ has 'foo/hidden/fn.inside_hidden.html' pub fn inside_hidden() {} } diff --git a/tests/rustdoc/doc-assoc-item.rs b/tests/rustdoc/doc-assoc-item.rs index 4d5c9f83e1e..2eb82abfc0b 100644 --- a/tests/rustdoc/doc-assoc-item.rs +++ b/tests/rustdoc/doc-assoc-item.rs @@ -8,7 +8,7 @@ pub trait Bar { fn foo(foo: Self::Fuu); } -// @has doc_assoc_item/struct.Foo.html '//*[@class="impl"]' 'impl<T: Bar<Fuu = u32>> Foo<T>' +//@ has doc_assoc_item/struct.Foo.html '//*[@class="impl"]' 'impl<T: Bar<Fuu = u32>> Foo<T>' impl<T: Bar<Fuu = u32>> Foo<T> { pub fn new(t: T) -> Foo<T> { Foo { diff --git a/tests/rustdoc/doc-attr-comment-mix-42760.rs b/tests/rustdoc/doc-attr-comment-mix-42760.rs index 16c1705eb00..c457ac74d8d 100644 --- a/tests/rustdoc/doc-attr-comment-mix-42760.rs +++ b/tests/rustdoc/doc-attr-comment-mix-42760.rs @@ -3,8 +3,8 @@ #![allow(rustdoc::invalid_rust_codeblocks)] -// @has foo/struct.NonGen.html -// @has - '//h2' 'Example' +//@ has foo/struct.NonGen.html +//@ has - '//h2' 'Example' /// Item docs. /// diff --git a/tests/rustdoc/doc-auto-cfg.rs b/tests/rustdoc/doc-auto-cfg.rs index 7842ee69c9f..b3fe8922fd7 100644 --- a/tests/rustdoc/doc-auto-cfg.rs +++ b/tests/rustdoc/doc-auto-cfg.rs @@ -1,35 +1,35 @@ #![feature(doc_auto_cfg)] #![crate_name = "foo"] -// @has foo/fn.foo.html -// @has - '//*[@class="item-info"]/*[@class="stab portability"]' 'non-meowmeow' +//@ has foo/fn.foo.html +//@ has - '//*[@class="item-info"]/*[@class="stab portability"]' 'non-meowmeow' #[cfg(not(meowmeow))] pub fn foo() {} -// @has foo/fn.bar.html -// @has - '//*[@class="item-info"]/*[@class="stab portability"]' 'meowmeow' -// @!has - '//*[@class="item-info"]/*[@class="stab portability"]' 'test' -// @!has - '//*[@class="item-info"]/*[@class="stab portability"]' 'doc' -// @!has - '//*[@class="item-info"]/*[@class="stab portability"]' 'doctest' +//@ has foo/fn.bar.html +//@ has - '//*[@class="item-info"]/*[@class="stab portability"]' 'meowmeow' +//@ !has - '//*[@class="item-info"]/*[@class="stab portability"]' 'test' +//@ !has - '//*[@class="item-info"]/*[@class="stab portability"]' 'doc' +//@ !has - '//*[@class="item-info"]/*[@class="stab portability"]' 'doctest' #[cfg(any(meowmeow, test, doc, doctest))] pub fn bar() {} -// @has foo/fn.appear_1.html -// @has - '//*[@class="item-info"]/*[@class="stab portability"]' 'meowmeow' -// @!has - '//*[@class="item-info"]/*[@class="stab portability"]' 'doc' -// @!has - '//*[@class="item-info"]/*[@class="stab portability"]' 'non-test' +//@ has foo/fn.appear_1.html +//@ has - '//*[@class="item-info"]/*[@class="stab portability"]' 'meowmeow' +//@ !has - '//*[@class="item-info"]/*[@class="stab portability"]' 'doc' +//@ !has - '//*[@class="item-info"]/*[@class="stab portability"]' 'non-test' #[cfg(any(meowmeow, doc, not(test)))] pub fn appear_1() {} // issue #98065 -// @has foo/fn.appear_2.html -// @has - '//*[@class="item-info"]/*[@class="stab portability"]' 'meowmeow' -// @!has - '//*[@class="item-info"]/*[@class="stab portability"]' 'doc' -// @!has - '//*[@class="item-info"]/*[@class="stab portability"]' 'test' +//@ has foo/fn.appear_2.html +//@ has - '//*[@class="item-info"]/*[@class="stab portability"]' 'meowmeow' +//@ !has - '//*[@class="item-info"]/*[@class="stab portability"]' 'doc' +//@ !has - '//*[@class="item-info"]/*[@class="stab portability"]' 'test' #[cfg(any(meowmeow, doc, all(test)))] pub fn appear_2() {} // issue #98065 -// @has foo/fn.appear_3.html -// @has - '//*[@class="item-info"]/*[@class="stab portability"]' 'meowmeow' -// @!has - '//*[@class="item-info"]/*[@class="stab portability"]' 'doc' +//@ has foo/fn.appear_3.html +//@ has - '//*[@class="item-info"]/*[@class="stab portability"]' 'meowmeow' +//@ !has - '//*[@class="item-info"]/*[@class="stab portability"]' 'doc' #[cfg(any(meowmeow, doc, all()))] pub fn appear_3() {} // issue #98065 diff --git a/tests/rustdoc/doc-cfg-hide.rs b/tests/rustdoc/doc-cfg-hide.rs index f80453d50ed..ceb1f99fae0 100644 --- a/tests/rustdoc/doc-cfg-hide.rs +++ b/tests/rustdoc/doc-cfg-hide.rs @@ -3,30 +3,30 @@ #![doc(cfg_hide(feature = "solecism"))] -// @has 'oud/struct.Solecism.html' -// @count - '//*[@class="stab portability"]' 0 +//@ has 'oud/struct.Solecism.html' +//@ count - '//*[@class="stab portability"]' 0 //@ compile-flags:--cfg feature="solecism" #[cfg(feature = "solecism")] pub struct Solecism; -// @has 'oud/struct.Scribacious.html' -// @count - '//*[@class="stab portability"]' 1 -// @matches - '//*[@class="stab portability"]' 'crate feature solecism' +//@ has 'oud/struct.Scribacious.html' +//@ count - '//*[@class="stab portability"]' 1 +//@ matches - '//*[@class="stab portability"]' 'crate feature solecism' #[cfg(feature = "solecism")] #[doc(cfg(feature = "solecism"))] pub struct Scribacious; -// @has 'oud/struct.Hyperdulia.html' -// @count - '//*[@class="stab portability"]' 1 -// @matches - '//*[@class="stab portability"]' 'crate feature hyperdulia' +//@ has 'oud/struct.Hyperdulia.html' +//@ count - '//*[@class="stab portability"]' 1 +//@ matches - '//*[@class="stab portability"]' 'crate feature hyperdulia' //@ compile-flags:--cfg feature="hyperdulia" #[cfg(feature = "solecism")] #[cfg(feature = "hyperdulia")] pub struct Hyperdulia; -// @has 'oud/struct.Oystercatcher.html' -// @count - '//*[@class="stab portability"]' 1 -// @matches - '//*[@class="stab portability"]' 'crate feature oystercatcher only' +//@ has 'oud/struct.Oystercatcher.html' +//@ count - '//*[@class="stab portability"]' 1 +//@ matches - '//*[@class="stab portability"]' 'crate feature oystercatcher only' //@ compile-flags:--cfg feature="oystercatcher" #[cfg(all(feature = "solecism", feature = "oystercatcher"))] pub struct Oystercatcher; diff --git a/tests/rustdoc/doc-cfg-implicit-gate.rs b/tests/rustdoc/doc-cfg-implicit-gate.rs index 15de15c0ce2..b5b8d0f427b 100644 --- a/tests/rustdoc/doc-cfg-implicit-gate.rs +++ b/tests/rustdoc/doc-cfg-implicit-gate.rs @@ -1,7 +1,7 @@ //@ compile-flags:--cfg feature="worricow" #![crate_name = "xenogenous"] -// @has 'xenogenous/struct.Worricow.html' -// @count - '//*[@class="stab portability"]' 0 +//@ has 'xenogenous/struct.Worricow.html' +//@ count - '//*[@class="stab portability"]' 0 #[cfg(feature = "worricow")] pub struct Worricow; diff --git a/tests/rustdoc/doc-cfg-implicit.rs b/tests/rustdoc/doc-cfg-implicit.rs index a6c0896db31..69b10867ee3 100644 --- a/tests/rustdoc/doc-cfg-implicit.rs +++ b/tests/rustdoc/doc-cfg-implicit.rs @@ -1,30 +1,30 @@ #![crate_name = "funambulism"] #![feature(doc_auto_cfg, doc_cfg)] -// @has 'funambulism/struct.Disorbed.html' -// @count - '//*[@class="stab portability"]' 1 -// @matches - '//*[@class="stab portability"]' 'crate feature disorbed' +//@ has 'funambulism/struct.Disorbed.html' +//@ count - '//*[@class="stab portability"]' 1 +//@ matches - '//*[@class="stab portability"]' 'crate feature disorbed' //@ compile-flags:--cfg feature="disorbed" #[cfg(feature = "disorbed")] pub struct Disorbed; -// @has 'funambulism/struct.Aesthesia.html' -// @count - '//*[@class="stab portability"]' 1 -// @matches - '//*[@class="stab portability"]' 'crate feature aesthesia' +//@ has 'funambulism/struct.Aesthesia.html' +//@ count - '//*[@class="stab portability"]' 1 +//@ matches - '//*[@class="stab portability"]' 'crate feature aesthesia' //@ compile-flags:--cfg feature="aesthesia" #[doc(cfg(feature = "aesthesia"))] pub struct Aesthesia; -// @has 'funambulism/struct.Pliothermic.html' -// @count - '//*[@class="stab portability"]' 1 -// @matches - '//*[@class="stab portability"]' 'crate feature pliothermic' +//@ has 'funambulism/struct.Pliothermic.html' +//@ count - '//*[@class="stab portability"]' 1 +//@ matches - '//*[@class="stab portability"]' 'crate feature pliothermic' //@ compile-flags:--cfg feature="epopoeist" #[cfg(feature = "epopoeist")] #[doc(cfg(feature = "pliothermic"))] pub struct Pliothermic; -// @has 'funambulism/struct.Simillimum.html' -// @count - '//*[@class="stab portability"]' 0 +//@ has 'funambulism/struct.Simillimum.html' +//@ count - '//*[@class="stab portability"]' 0 //@ compile-flags:--cfg feature="simillimum" #[cfg(feature = "simillimum")] #[doc(cfg(all()))] diff --git a/tests/rustdoc/doc-cfg-inherit-from-module-79201.rs b/tests/rustdoc/doc-cfg-inherit-from-module-79201.rs index 76260c4a502..256e3b0015c 100644 --- a/tests/rustdoc/doc-cfg-inherit-from-module-79201.rs +++ b/tests/rustdoc/doc-cfg-inherit-from-module-79201.rs @@ -3,13 +3,13 @@ #![feature(doc_cfg)] -// @has 'foo/trait.Foo.html' -// @count - '//*[@class="stab portability"]' 6 -// @matches - '//*[@class="stab portability"]' 'crate feature foo-root' -// @matches - '//*[@class="stab portability"]' 'crate feature foo-public-mod' -// @matches - '//*[@class="stab portability"]' 'crate feature foo-private-mod' -// @matches - '//*[@class="stab portability"]' 'crate feature foo-fn' -// @matches - '//*[@class="stab portability"]' 'crate feature foo-method' +//@ has 'foo/trait.Foo.html' +//@ count - '//*[@class="stab portability"]' 6 +//@ matches - '//*[@class="stab portability"]' 'crate feature foo-root' +//@ matches - '//*[@class="stab portability"]' 'crate feature foo-public-mod' +//@ matches - '//*[@class="stab portability"]' 'crate feature foo-private-mod' +//@ matches - '//*[@class="stab portability"]' 'crate feature foo-fn' +//@ matches - '//*[@class="stab portability"]' 'crate feature foo-method' pub trait Foo {} diff --git a/tests/rustdoc/doc-cfg-simplification.rs b/tests/rustdoc/doc-cfg-simplification.rs index 633df661be0..ce70de289c6 100644 --- a/tests/rustdoc/doc-cfg-simplification.rs +++ b/tests/rustdoc/doc-cfg-simplification.rs @@ -1,75 +1,75 @@ #![crate_name = "globuliferous"] #![feature(doc_cfg)] -// @has 'globuliferous/index.html' -// @count - '//*[@class="stab portability"]' 1 -// @matches - '//*[@class="stab portability"]' '^ratel$' - -// @has 'globuliferous/ratel/index.html' -// @count - '//*[@class="stab portability"]' 8 -// @matches - '//*[@class="stab portability"]' 'crate feature ratel' -// @matches - '//*[@class="stab portability"]' '^zoonosology$' -// @matches - '//*[@class="stab portability"]' '^yusho$' -// @matches - '//*[@class="stab portability"]' '^nunciative$' -// @matches - '//*[@class="stab portability"]' '^thionic$' -// @matches - '//*[@class="stab portability"]' '^zincic$' -// @matches - '//*[@class="stab portability"]' '^cosmotellurian$' -// @matches - '//*[@class="stab portability"]' '^aposiopesis$' +//@ has 'globuliferous/index.html' +//@ count - '//*[@class="stab portability"]' 1 +//@ matches - '//*[@class="stab portability"]' '^ratel$' + +//@ has 'globuliferous/ratel/index.html' +//@ count - '//*[@class="stab portability"]' 8 +//@ matches - '//*[@class="stab portability"]' 'crate feature ratel' +//@ matches - '//*[@class="stab portability"]' '^zoonosology$' +//@ matches - '//*[@class="stab portability"]' '^yusho$' +//@ matches - '//*[@class="stab portability"]' '^nunciative$' +//@ matches - '//*[@class="stab portability"]' '^thionic$' +//@ matches - '//*[@class="stab portability"]' '^zincic$' +//@ matches - '//*[@class="stab portability"]' '^cosmotellurian$' +//@ matches - '//*[@class="stab portability"]' '^aposiopesis$' #[doc(cfg(feature = "ratel"))] pub mod ratel { - // @has 'globuliferous/ratel/fn.ovicide.html' - // @count - '//*[@class="stab portability"]' 1 - // @matches - '//*[@class="stab portability"]' 'crate feature ratel' + //@ has 'globuliferous/ratel/fn.ovicide.html' + //@ count - '//*[@class="stab portability"]' 1 + //@ matches - '//*[@class="stab portability"]' 'crate feature ratel' pub fn ovicide() {} - // @has 'globuliferous/ratel/fn.zoonosology.html' - // @count - '//*[@class="stab portability"]' 1 - // @matches - '//*[@class="stab portability"]' 'crate features ratel and zoonosology' + //@ has 'globuliferous/ratel/fn.zoonosology.html' + //@ count - '//*[@class="stab portability"]' 1 + //@ matches - '//*[@class="stab portability"]' 'crate features ratel and zoonosology' #[doc(cfg(feature = "zoonosology"))] pub fn zoonosology() {} - // @has 'globuliferous/ratel/constant.DIAGRAPHICS.html' - // @count - '//*[@class="stab portability"]' 1 - // @matches - '//*[@class="stab portability"]' 'crate feature ratel' + //@ has 'globuliferous/ratel/constant.DIAGRAPHICS.html' + //@ count - '//*[@class="stab portability"]' 1 + //@ matches - '//*[@class="stab portability"]' 'crate feature ratel' pub const DIAGRAPHICS: () = (); - // @has 'globuliferous/ratel/constant.YUSHO.html' - // @count - '//*[@class="stab portability"]' 1 - // @matches - '//*[@class="stab portability"]' 'crate features ratel and yusho' + //@ has 'globuliferous/ratel/constant.YUSHO.html' + //@ count - '//*[@class="stab portability"]' 1 + //@ matches - '//*[@class="stab portability"]' 'crate features ratel and yusho' #[doc(cfg(feature = "yusho"))] pub const YUSHO: () = (); - // @has 'globuliferous/ratel/static.KEYBUGLE.html' - // @count - '//*[@class="stab portability"]' 1 - // @matches - '//*[@class="stab portability"]' 'crate feature ratel' + //@ has 'globuliferous/ratel/static.KEYBUGLE.html' + //@ count - '//*[@class="stab portability"]' 1 + //@ matches - '//*[@class="stab portability"]' 'crate feature ratel' pub static KEYBUGLE: () = (); - // @has 'globuliferous/ratel/static.NUNCIATIVE.html' - // @count - '//*[@class="stab portability"]' 1 - // @matches - '//*[@class="stab portability"]' 'crate features ratel and nunciative' + //@ has 'globuliferous/ratel/static.NUNCIATIVE.html' + //@ count - '//*[@class="stab portability"]' 1 + //@ matches - '//*[@class="stab portability"]' 'crate features ratel and nunciative' #[doc(cfg(feature = "nunciative"))] pub static NUNCIATIVE: () = (); - // @has 'globuliferous/ratel/type.Wrick.html' - // @count - '//*[@class="stab portability"]' 1 - // @matches - '//*[@class="stab portability"]' 'crate feature ratel' + //@ has 'globuliferous/ratel/type.Wrick.html' + //@ count - '//*[@class="stab portability"]' 1 + //@ matches - '//*[@class="stab portability"]' 'crate feature ratel' pub type Wrick = (); - // @has 'globuliferous/ratel/type.Thionic.html' - // @count - '//*[@class="stab portability"]' 1 - // @matches - '//*[@class="stab portability"]' 'crate features ratel and thionic' + //@ has 'globuliferous/ratel/type.Thionic.html' + //@ count - '//*[@class="stab portability"]' 1 + //@ matches - '//*[@class="stab portability"]' 'crate features ratel and thionic' #[doc(cfg(feature = "thionic"))] pub type Thionic = (); - // @has 'globuliferous/ratel/struct.Eventration.html' - // @count - '//*[@class="stab portability"]' 1 - // @matches - '//*[@class="stab portability"]' 'crate feature ratel' + //@ has 'globuliferous/ratel/struct.Eventration.html' + //@ count - '//*[@class="stab portability"]' 1 + //@ matches - '//*[@class="stab portability"]' 'crate feature ratel' pub struct Eventration; - // @has 'globuliferous/ratel/struct.Zincic.html' - // @count - '//*[@class="stab portability"]' 2 - // @matches - '//*[@class="stab portability"]' 'crate features ratel and zincic' - // @matches - '//*[@class="stab portability"]' 'crate feature rutherford' + //@ has 'globuliferous/ratel/struct.Zincic.html' + //@ count - '//*[@class="stab portability"]' 2 + //@ matches - '//*[@class="stab portability"]' 'crate features ratel and zincic' + //@ matches - '//*[@class="stab portability"]' 'crate feature rutherford' #[doc(cfg(feature = "zincic"))] pub struct Zincic { pub rectigrade: (), @@ -78,18 +78,18 @@ pub mod ratel { pub rutherford: (), } - // @has 'globuliferous/ratel/enum.Cosmotellurian.html' - // @count - '//*[@class="stab portability"]' 10 - // @matches - '//*[@class="stab portability"]' 'crate features ratel and cosmotellurian' - // @matches - '//*[@class="stab portability"]' 'crate feature biotaxy' - // @matches - '//*[@class="stab portability"]' 'crate feature xiphopagus' - // @matches - '//*[@class="stab portability"]' 'crate feature juxtapositive' - // @matches - '//*[@class="stab portability"]' 'crate feature fuero' - // @matches - '//*[@class="stab portability"]' 'crate feature palaeophile' - // @matches - '//*[@class="stab portability"]' 'crate feature broadcloth' - // @matches - '//*[@class="stab portability"]' 'crate features broadcloth and xanthocomic' - // @matches - '//*[@class="stab portability"]' 'crate feature broadcloth' - // @matches - '//*[@class="stab portability"]' 'crate features broadcloth and whosoever' + //@ has 'globuliferous/ratel/enum.Cosmotellurian.html' + //@ count - '//*[@class="stab portability"]' 10 + //@ matches - '//*[@class="stab portability"]' 'crate features ratel and cosmotellurian' + //@ matches - '//*[@class="stab portability"]' 'crate feature biotaxy' + //@ matches - '//*[@class="stab portability"]' 'crate feature xiphopagus' + //@ matches - '//*[@class="stab portability"]' 'crate feature juxtapositive' + //@ matches - '//*[@class="stab portability"]' 'crate feature fuero' + //@ matches - '//*[@class="stab portability"]' 'crate feature palaeophile' + //@ matches - '//*[@class="stab portability"]' 'crate feature broadcloth' + //@ matches - '//*[@class="stab portability"]' 'crate features broadcloth and xanthocomic' + //@ matches - '//*[@class="stab portability"]' 'crate feature broadcloth' + //@ matches - '//*[@class="stab portability"]' 'crate features broadcloth and whosoever' #[doc(cfg(feature = "cosmotellurian"))] pub enum Cosmotellurian { Groundsel { @@ -133,12 +133,12 @@ pub mod ratel { pub const WHOSOEVER: () = (); } - // @has 'globuliferous/ratel/trait.Gnotobiology.html' - // @count - '//*[@class="stab portability"]' 4 - // @matches - '//*[@class="stab portability"]' 'crate feature ratel' - // @matches - '//*[@class="stab portability"]' 'crate feature unzymotic' - // @matches - '//*[@class="stab portability"]' 'crate feature summate' - // @matches - '//*[@class="stab portability"]' 'crate feature unctuous' + //@ has 'globuliferous/ratel/trait.Gnotobiology.html' + //@ count - '//*[@class="stab portability"]' 4 + //@ matches - '//*[@class="stab portability"]' 'crate feature ratel' + //@ matches - '//*[@class="stab portability"]' 'crate feature unzymotic' + //@ matches - '//*[@class="stab portability"]' 'crate feature summate' + //@ matches - '//*[@class="stab portability"]' 'crate feature unctuous' pub trait Gnotobiology { const XYLOTHERAPY: (); @@ -156,12 +156,12 @@ pub mod ratel { fn unctuous(); } - // @has 'globuliferous/ratel/trait.Aposiopesis.html' - // @count - '//*[@class="stab portability"]' 4 - // @matches - '//*[@class="stab portability"]' 'crate features ratel and aposiopesis' - // @matches - '//*[@class="stab portability"]' 'crate feature umbracious' - // @matches - '//*[@class="stab portability"]' 'crate feature uakari' - // @matches - '//*[@class="stab portability"]' 'crate feature rotograph' + //@ has 'globuliferous/ratel/trait.Aposiopesis.html' + //@ count - '//*[@class="stab portability"]' 4 + //@ matches - '//*[@class="stab portability"]' 'crate features ratel and aposiopesis' + //@ matches - '//*[@class="stab portability"]' 'crate feature umbracious' + //@ matches - '//*[@class="stab portability"]' 'crate feature uakari' + //@ matches - '//*[@class="stab portability"]' 'crate feature rotograph' #[doc(cfg(feature = "aposiopesis"))] pub trait Aposiopesis { const REDHIBITION: (); diff --git a/tests/rustdoc/doc-cfg-traits.rs b/tests/rustdoc/doc-cfg-traits.rs index 13407b2c791..1256a7ae2c1 100644 --- a/tests/rustdoc/doc-cfg-traits.rs +++ b/tests/rustdoc/doc-cfg-traits.rs @@ -1,21 +1,21 @@ #![crate_name = "myrmecophagous"] #![feature(doc_cfg, associated_type_defaults)] -// @has 'myrmecophagous/index.html' -// @count - '//*[@class="stab portability"]' 2 -// @matches - '//*[@class="stab portability"]' '^jurisconsult$' -// @matches - '//*[@class="stab portability"]' '^quarter$' +//@ has 'myrmecophagous/index.html' +//@ count - '//*[@class="stab portability"]' 2 +//@ matches - '//*[@class="stab portability"]' '^jurisconsult$' +//@ matches - '//*[@class="stab portability"]' '^quarter$' pub trait Lea {} -// @has 'myrmecophagous/trait.Vortoscope.html' -// @count - '//*[@class="stab portability"]' 6 -// @matches - '//*[@class="stab portability"]' 'crate feature zibib' -// @matches - '//*[@class="stab portability"]' 'crate feature poriform' -// @matches - '//*[@class="stab portability"]' 'crate feature ethopoeia' -// @matches - '//*[@class="stab portability"]' 'crate feature lea' -// @matches - '//*[@class="stab portability"]' 'crate feature unit' -// @matches - '//*[@class="stab portability"]' 'crate feature quarter' +//@ has 'myrmecophagous/trait.Vortoscope.html' +//@ count - '//*[@class="stab portability"]' 6 +//@ matches - '//*[@class="stab portability"]' 'crate feature zibib' +//@ matches - '//*[@class="stab portability"]' 'crate feature poriform' +//@ matches - '//*[@class="stab portability"]' 'crate feature ethopoeia' +//@ matches - '//*[@class="stab portability"]' 'crate feature lea' +//@ matches - '//*[@class="stab portability"]' 'crate feature unit' +//@ matches - '//*[@class="stab portability"]' 'crate feature quarter' pub trait Vortoscope { type Batology = (); @@ -39,15 +39,15 @@ impl<T: Lea> Vortoscope for T {} #[doc(cfg(feature = "unit"))] impl Vortoscope for () {} -// @has 'myrmecophagous/trait.Jurisconsult.html' -// @count - '//*[@class="stab portability"]' 7 -// @matches - '//*[@class="stab portability"]' 'crate feature jurisconsult' -// @matches - '//*[@class="stab portability"]' 'crate feature lithomancy' -// @matches - '//*[@class="stab portability"]' 'crate feature boodle' -// @matches - '//*[@class="stab portability"]' 'crate feature mistetch' -// @matches - '//*[@class="stab portability"]' 'crate feature lea' -// @matches - '//*[@class="stab portability"]' 'crate feature unit' -// @matches - '//*[@class="stab portability"]' 'crate feature quarter' +//@ has 'myrmecophagous/trait.Jurisconsult.html' +//@ count - '//*[@class="stab portability"]' 7 +//@ matches - '//*[@class="stab portability"]' 'crate feature jurisconsult' +//@ matches - '//*[@class="stab portability"]' 'crate feature lithomancy' +//@ matches - '//*[@class="stab portability"]' 'crate feature boodle' +//@ matches - '//*[@class="stab portability"]' 'crate feature mistetch' +//@ matches - '//*[@class="stab portability"]' 'crate feature lea' +//@ matches - '//*[@class="stab portability"]' 'crate feature unit' +//@ matches - '//*[@class="stab portability"]' 'crate feature quarter' #[doc(cfg(feature = "jurisconsult"))] pub trait Jurisconsult { type Urbanist = (); @@ -72,19 +72,19 @@ impl<T: Lea> Jurisconsult for T {} #[doc(cfg(feature = "unit"))] impl Jurisconsult for () {} -// @has 'myrmecophagous/struct.Ultimogeniture.html' -// @count - '//*[@class="stab portability"]' 8 +//@ has 'myrmecophagous/struct.Ultimogeniture.html' +//@ count - '//*[@class="stab portability"]' 8 // -// @matches - '//*[@class="stab portability"]' 'crate feature zibib' -// @matches - '//*[@class="stab portability"]' 'crate feature poriform' -// @matches - '//*[@class="stab portability"]' 'crate feature ethopoeia' +//@ matches - '//*[@class="stab portability"]' 'crate feature zibib' +//@ matches - '//*[@class="stab portability"]' 'crate feature poriform' +//@ matches - '//*[@class="stab portability"]' 'crate feature ethopoeia' // -// @matches - '//*[@class="stab portability"]' 'crate feature jurisconsult' -// @matches - '//*[@class="stab portability"]' 'crate feature lithomancy' -// @matches - '//*[@class="stab portability"]' 'crate feature boodle' -// @matches - '//*[@class="stab portability"]' 'crate feature mistetch' +//@ matches - '//*[@class="stab portability"]' 'crate feature jurisconsult' +//@ matches - '//*[@class="stab portability"]' 'crate feature lithomancy' +//@ matches - '//*[@class="stab portability"]' 'crate feature boodle' +//@ matches - '//*[@class="stab portability"]' 'crate feature mistetch' // -// @matches - '//*[@class="stab portability"]' 'crate feature copy' +//@ matches - '//*[@class="stab portability"]' 'crate feature copy' #[derive(Clone)] pub struct Ultimogeniture; @@ -96,20 +96,20 @@ impl Jurisconsult for Ultimogeniture {} #[doc(cfg(feature = "copy"))] impl Copy for Ultimogeniture {} -// @has 'myrmecophagous/struct.Quarter.html' -// @count - '//*[@class="stab portability"]' 9 -// @matches - '//*[@class="stab portability"]' 'crate feature quarter' +//@ has 'myrmecophagous/struct.Quarter.html' +//@ count - '//*[@class="stab portability"]' 9 +//@ matches - '//*[@class="stab portability"]' 'crate feature quarter' // -// @matches - '//*[@class="stab portability"]' 'crate feature zibib' -// @matches - '//*[@class="stab portability"]' 'crate feature poriform' -// @matches - '//*[@class="stab portability"]' 'crate feature ethopoeia' +//@ matches - '//*[@class="stab portability"]' 'crate feature zibib' +//@ matches - '//*[@class="stab portability"]' 'crate feature poriform' +//@ matches - '//*[@class="stab portability"]' 'crate feature ethopoeia' // -// @matches - '//*[@class="stab portability"]' 'crate feature jurisconsult' -// @matches - '//*[@class="stab portability"]' 'crate feature lithomancy' -// @matches - '//*[@class="stab portability"]' 'crate feature boodle' -// @matches - '//*[@class="stab portability"]' 'crate feature mistetch' +//@ matches - '//*[@class="stab portability"]' 'crate feature jurisconsult' +//@ matches - '//*[@class="stab portability"]' 'crate feature lithomancy' +//@ matches - '//*[@class="stab portability"]' 'crate feature boodle' +//@ matches - '//*[@class="stab portability"]' 'crate feature mistetch' // -// @matches - '//*[@class="stab portability"]' 'crate feature copy' +//@ matches - '//*[@class="stab portability"]' 'crate feature copy' #[doc(cfg(feature = "quarter"))] #[derive(Clone)] pub struct Quarter; diff --git a/tests/rustdoc/doc-cfg.rs b/tests/rustdoc/doc-cfg.rs index c4702d4109e..6c973b5666b 100644 --- a/tests/rustdoc/doc-cfg.rs +++ b/tests/rustdoc/doc-cfg.rs @@ -1,33 +1,33 @@ #![feature(doc_cfg)] #![feature(target_feature, cfg_target_feature)] -// @has doc_cfg/struct.Portable.html -// @!has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' '' -// @has - '//*[@id="method.unix_and_arm_only_function"]' 'fn unix_and_arm_only_function()' -// @has - '//*[@class="stab portability"]' 'Available on Unix and ARM only.' -// @has - '//*[@id="method.wasi_and_wasm32_only_function"]' 'fn wasi_and_wasm32_only_function()' -// @has - '//*[@class="stab portability"]' 'Available on WASI and WebAssembly only.' +//@ has doc_cfg/struct.Portable.html +//@ !has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' '' +//@ has - '//*[@id="method.unix_and_arm_only_function"]' 'fn unix_and_arm_only_function()' +//@ has - '//*[@class="stab portability"]' 'Available on Unix and ARM only.' +//@ has - '//*[@id="method.wasi_and_wasm32_only_function"]' 'fn wasi_and_wasm32_only_function()' +//@ has - '//*[@class="stab portability"]' 'Available on WASI and WebAssembly only.' pub struct Portable; -// @has doc_cfg/unix_only/index.html \ +//@ has doc_cfg/unix_only/index.html \ // '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ // 'Available on Unix only.' -// @matches - '//*[@class="item-name"]//*[@class="stab portability"]' '\AARM\Z' -// @count - '//*[@class="stab portability"]' 2 +//@ matches - '//*[@class="item-name"]//*[@class="stab portability"]' '\AARM\Z' +//@ count - '//*[@class="stab portability"]' 2 #[doc(cfg(unix))] pub mod unix_only { - // @has doc_cfg/unix_only/fn.unix_only_function.html \ + //@ has doc_cfg/unix_only/fn.unix_only_function.html \ // '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ // 'Available on Unix only.' - // @count - '//*[@class="stab portability"]' 1 + //@ count - '//*[@class="stab portability"]' 1 pub fn unix_only_function() { content::should::be::irrelevant(); } - // @has doc_cfg/unix_only/trait.ArmOnly.html \ + //@ has doc_cfg/unix_only/trait.ArmOnly.html \ // '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ // 'Available on Unix and ARM only.' - // @count - '//*[@class="stab portability"]' 1 + //@ count - '//*[@class="stab portability"]' 1 #[doc(cfg(target_arch = "arm"))] pub trait ArmOnly { fn unix_and_arm_only_function(); @@ -39,25 +39,25 @@ pub mod unix_only { } } -// @has doc_cfg/wasi_only/index.html \ +//@ has doc_cfg/wasi_only/index.html \ // '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ // 'Available on WASI only.' -// @matches - '//*[@class="item-name"]//*[@class="stab portability"]' '\AWebAssembly\Z' -// @count - '//*[@class="stab portability"]' 2 +//@ matches - '//*[@class="item-name"]//*[@class="stab portability"]' '\AWebAssembly\Z' +//@ count - '//*[@class="stab portability"]' 2 #[doc(cfg(target_os = "wasi"))] pub mod wasi_only { - // @has doc_cfg/wasi_only/fn.wasi_only_function.html \ + //@ has doc_cfg/wasi_only/fn.wasi_only_function.html \ // '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ // 'Available on WASI only.' - // @count - '//*[@class="stab portability"]' 1 + //@ count - '//*[@class="stab portability"]' 1 pub fn wasi_only_function() { content::should::be::irrelevant(); } - // @has doc_cfg/wasi_only/trait.Wasm32Only.html \ + //@ has doc_cfg/wasi_only/trait.Wasm32Only.html \ // '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ // 'Available on WASI and WebAssembly only.' - // @count - '//*[@class="stab portability"]' 1 + //@ count - '//*[@class="stab portability"]' 1 #[doc(cfg(target_arch = "wasm32"))] pub trait Wasm32Only { fn wasi_and_wasm32_only_function(); @@ -73,19 +73,19 @@ pub mod wasi_only { // item as well // the portability header is different on the module view versus the full view -// @has doc_cfg/index.html -// @matches - '//*[@class="item-name"]//*[@class="stab portability"]' '\Aavx\Z' +//@ has doc_cfg/index.html +//@ matches - '//*[@class="item-name"]//*[@class="stab portability"]' '\Aavx\Z' -// @has doc_cfg/fn.uses_target_feature.html -// @has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ +//@ has doc_cfg/fn.uses_target_feature.html +//@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ // 'Available with target feature avx only.' #[target_feature(enable = "avx")] pub unsafe fn uses_target_feature() { content::should::be::irrelevant(); } -// @has doc_cfg/fn.uses_cfg_target_feature.html -// @has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ +//@ has doc_cfg/fn.uses_cfg_target_feature.html +//@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ // 'Available with target feature avx only.' #[doc(cfg(target_feature = "avx"))] pub fn uses_cfg_target_feature() { @@ -93,7 +93,7 @@ pub fn uses_cfg_target_feature() { } // multiple attributes should be allowed -// @has doc_cfg/fn.multiple_attrs.html \ +//@ has doc_cfg/fn.multiple_attrs.html \ // '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ // 'Available on x and y and z only.' #[doc(cfg(x))] diff --git a/tests/rustdoc/doc-hidden-method-13698.rs b/tests/rustdoc/doc-hidden-method-13698.rs index 44bf8bfd8d2..5c0ad18ee29 100644 --- a/tests/rustdoc/doc-hidden-method-13698.rs +++ b/tests/rustdoc/doc-hidden-method-13698.rs @@ -7,7 +7,7 @@ extern crate issue_13698; pub struct Foo; -// @!has issue_13698/struct.Foo.html '//*[@id="method.foo"]' 'fn foo' +//@ !has issue_13698/struct.Foo.html '//*[@id="method.foo"]' 'fn foo' impl issue_13698::Foo for Foo {} pub trait Bar { @@ -15,5 +15,5 @@ pub trait Bar { fn bar(&self) {} } -// @!has issue_13698/struct.Foo.html '//*[@id="method.bar"]' 'fn bar' +//@ !has issue_13698/struct.Foo.html '//*[@id="method.bar"]' 'fn bar' impl Bar for Foo {} diff --git a/tests/rustdoc/doc-hidden-private-67851-both.rs b/tests/rustdoc/doc-hidden-private-67851-both.rs index e6eb6a68ffd..2e2190d8755 100644 --- a/tests/rustdoc/doc-hidden-private-67851-both.rs +++ b/tests/rustdoc/doc-hidden-private-67851-both.rs @@ -2,9 +2,9 @@ // https://github.com/rust-lang/rust/issues/67851 #![crate_name="foo"] -// @has foo/struct.Hidden.html +//@ has foo/struct.Hidden.html #[doc(hidden)] pub struct Hidden; -// @has foo/struct.Private.html +//@ has foo/struct.Private.html struct Private; diff --git a/tests/rustdoc/doc-hidden-private-67851-hidden.rs b/tests/rustdoc/doc-hidden-private-67851-hidden.rs index 9767f9c84f9..a811a04a668 100644 --- a/tests/rustdoc/doc-hidden-private-67851-hidden.rs +++ b/tests/rustdoc/doc-hidden-private-67851-hidden.rs @@ -2,9 +2,9 @@ // https://github.com/rust-lang/rust/issues/67851 #![crate_name="foo"] -// @has foo/struct.Hidden.html +//@ has foo/struct.Hidden.html #[doc(hidden)] pub struct Hidden; -// @!has foo/struct.Private.html +//@ !has foo/struct.Private.html struct Private; diff --git a/tests/rustdoc/doc-hidden-private-67851-neither.rs b/tests/rustdoc/doc-hidden-private-67851-neither.rs index 6c6e84da43d..1f70ceefe44 100644 --- a/tests/rustdoc/doc-hidden-private-67851-neither.rs +++ b/tests/rustdoc/doc-hidden-private-67851-neither.rs @@ -1,9 +1,9 @@ // https://github.com/rust-lang/rust/issues/67851 #![crate_name="foo"] -// @!has foo/struct.Hidden.html +//@ !has foo/struct.Hidden.html #[doc(hidden)] pub struct Hidden; -// @!has foo/struct.Private.html +//@ !has foo/struct.Private.html struct Private; diff --git a/tests/rustdoc/doc-hidden-private-67851-private.rs b/tests/rustdoc/doc-hidden-private-67851-private.rs index 4aa39f5b789..f6f546ad5ea 100644 --- a/tests/rustdoc/doc-hidden-private-67851-private.rs +++ b/tests/rustdoc/doc-hidden-private-67851-private.rs @@ -2,9 +2,9 @@ // https://github.com/rust-lang/rust/issues/67851 #![crate_name="foo"] -// @!has foo/struct.Hidden.html +//@ !has foo/struct.Hidden.html #[doc(hidden)] pub struct Hidden; -// @has foo/struct.Private.html +//@ has foo/struct.Private.html struct Private; diff --git a/tests/rustdoc/doc-hidden-trait-implementors-33069.rs b/tests/rustdoc/doc-hidden-trait-implementors-33069.rs index 35570668ea1..d5ee3d09276 100644 --- a/tests/rustdoc/doc-hidden-trait-implementors-33069.rs +++ b/tests/rustdoc/doc-hidden-trait-implementors-33069.rs @@ -8,6 +8,6 @@ pub mod hidden { pub struct Foo; } -// @has issue_33069/trait.Bar.html -// @!has - '//code' 'impl Bar for Foo' +//@ has issue_33069/trait.Bar.html +//@ !has - '//code' 'impl Bar for Foo' impl Bar for hidden::Foo {} diff --git a/tests/rustdoc/doc_auto_cfg_nested_impl.rs b/tests/rustdoc/doc_auto_cfg_nested_impl.rs index 4d73e0d829a..f85d7b23637 100644 --- a/tests/rustdoc/doc_auto_cfg_nested_impl.rs +++ b/tests/rustdoc/doc_auto_cfg_nested_impl.rs @@ -8,8 +8,8 @@ pub struct S; pub trait MyTrait1 {} pub trait MyTrait2 {} -// @has foo/struct.S.html -// @has - '//*[@id="impl-MyTrait1-for-S"]//*[@class="stab portability"]' \ +//@ has foo/struct.S.html +//@ has - '//*[@id="impl-MyTrait1-for-S"]//*[@class="stab portability"]' \ // 'Available on non-crate feature coolstuff only.' #[cfg(not(feature = "coolstuff"))] impl MyTrait1 for S {} @@ -18,7 +18,7 @@ impl MyTrait1 for S {} mod submod { use crate::{S, MyTrait2}; // This impl should also have the `not(feature = "coolstuff")`. - // @has - '//*[@id="impl-MyTrait2-for-S"]//*[@class="stab portability"]' \ + //@ has - '//*[@id="impl-MyTrait2-for-S"]//*[@class="stab portability"]' \ // 'Available on non-crate feature coolstuff only.' impl MyTrait2 for S {} } diff --git a/tests/rustdoc/doctest/doctest-escape-boring-41783.rs b/tests/rustdoc/doctest/doctest-escape-boring-41783.rs index 7782e148fd9..2d614f63da6 100644 --- a/tests/rustdoc/doctest/doctest-escape-boring-41783.rs +++ b/tests/rustdoc/doctest/doctest-escape-boring-41783.rs @@ -1,14 +1,14 @@ // https://github.com/rust-lang/rust/issues/41783 #![crate_name="foo"] -// @has foo/struct.Foo.html -// @!hasraw - 'space' -// @!hasraw - 'comment' -// @hasraw - '<span class="attr">#[outer]' -// @!hasraw - '<span class="attr">#[outer]</span>' -// @hasraw - '#![inner]</span>' -// @!hasraw - '<span class="attr">#![inner]</span>' -// @snapshot 'codeblock' - '//*[@class="toggle top-doc"]/*[@class="docblock"]//pre/code' +//@ has foo/struct.Foo.html +//@ !hasraw - 'space' +//@ !hasraw - 'comment' +//@ hasraw - '<span class="attr">#[outer]' +//@ !hasraw - '<span class="attr">#[outer]</span>' +//@ hasraw - '#![inner]</span>' +//@ !hasraw - '<span class="attr">#![inner]</span>' +//@ snapshot 'codeblock' - '//*[@class="toggle top-doc"]/*[@class="docblock"]//pre/code' /// ```no_run /// # # space diff --git a/tests/rustdoc/document-hidden-items-15347.rs b/tests/rustdoc/document-hidden-items-15347.rs index bf3c73f0ba1..ee19e793020 100644 --- a/tests/rustdoc/document-hidden-items-15347.rs +++ b/tests/rustdoc/document-hidden-items-15347.rs @@ -3,6 +3,6 @@ #![crate_name="issue_15347"] -// @has issue_15347/fn.foo.html +//@ has issue_15347/fn.foo.html #[doc(hidden)] pub fn foo() {} diff --git a/tests/rustdoc/double-hyphen-to-dash.rs b/tests/rustdoc/double-hyphen-to-dash.rs index 66905f90cfc..009de4faf41 100644 --- a/tests/rustdoc/double-hyphen-to-dash.rs +++ b/tests/rustdoc/double-hyphen-to-dash.rs @@ -2,8 +2,8 @@ #![crate_name = "foo"] -// @has 'foo/index.html' '//*[@class="desc docblock-short"]' '–' -// @has 'foo/struct.Bar.html' '//*[@class="docblock"]' '–' +//@ has 'foo/index.html' '//*[@class="desc docblock-short"]' '–' +//@ has 'foo/struct.Bar.html' '//*[@class="docblock"]' '–' /// -- pub struct Bar; diff --git a/tests/rustdoc/double-quote-escape.rs b/tests/rustdoc/double-quote-escape.rs index 4f4436377a0..9c8fb8fc6da 100644 --- a/tests/rustdoc/double-quote-escape.rs +++ b/tests/rustdoc/double-quote-escape.rs @@ -6,6 +6,6 @@ pub trait Foo<T> { pub struct Bar; -// @has foo/struct.Bar.html -// @has - '//*[@class="sidebar-elems"]//section//a[@href="#impl-Foo%3Cunsafe+extern+%22C%22+fn()%3E-for-Bar"]' 'Foo<unsafe extern "C" fn()>' +//@ has foo/struct.Bar.html +//@ has - '//*[@class="sidebar-elems"]//section//a[@href="#impl-Foo%3Cunsafe+extern+%22C%22+fn()%3E-for-Bar"]' 'Foo<unsafe extern "C" fn()>' impl Foo<unsafe extern "C" fn()> for Bar {} diff --git a/tests/rustdoc/duplicate-cfg.rs b/tests/rustdoc/duplicate-cfg.rs index 12846c5c17a..87c089e9735 100644 --- a/tests/rustdoc/duplicate-cfg.rs +++ b/tests/rustdoc/duplicate-cfg.rs @@ -1,53 +1,53 @@ #![crate_name = "foo"] #![feature(doc_cfg)] -// @has 'foo/index.html' -// @matches '-' '//*[@class="item-name"]//*[@class="stab portability"]' '^sync$' -// @has '-' '//*[@class="item-name"]//*[@class="stab portability"]/@title' 'Available on crate feature `sync` only' +//@ has 'foo/index.html' +//@ matches '-' '//*[@class="item-name"]//*[@class="stab portability"]' '^sync$' +//@ has '-' '//*[@class="item-name"]//*[@class="stab portability"]/@title' 'Available on crate feature `sync` only' -// @has 'foo/struct.Foo.html' -// @has '-' '//*[@class="stab portability"]' 'sync' +//@ has 'foo/struct.Foo.html' +//@ has '-' '//*[@class="stab portability"]' 'sync' #[doc(cfg(feature = "sync"))] #[doc(cfg(feature = "sync"))] /// my feature sync struct pub struct Foo; -// @has 'foo/bar/index.html' -// @has '-' '//*[@class="stab portability"]' 'Available on crate feature sync only.' +//@ has 'foo/bar/index.html' +//@ has '-' '//*[@class="stab portability"]' 'Available on crate feature sync only.' #[doc(cfg(feature = "sync"))] pub mod bar { - // @has 'foo/bar/struct.Bar.html' - // @has '-' '//*[@class="stab portability"]' 'Available on crate feature sync only.' + //@ has 'foo/bar/struct.Bar.html' + //@ has '-' '//*[@class="stab portability"]' 'Available on crate feature sync only.' #[doc(cfg(feature = "sync"))] pub struct Bar; } -// @has 'foo/baz/index.html' -// @has '-' '//*[@class="stab portability"]' 'Available on crate features sync and send only.' +//@ has 'foo/baz/index.html' +//@ has '-' '//*[@class="stab portability"]' 'Available on crate features sync and send only.' #[doc(cfg(all(feature = "sync", feature = "send")))] pub mod baz { - // @has 'foo/baz/struct.Baz.html' - // @has '-' '//*[@class="stab portability"]' 'Available on crate features sync and send only.' + //@ has 'foo/baz/struct.Baz.html' + //@ has '-' '//*[@class="stab portability"]' 'Available on crate features sync and send only.' #[doc(cfg(feature = "sync"))] pub struct Baz; } -// @has 'foo/qux/index.html' -// @has '-' '//*[@class="stab portability"]' 'Available on crate feature sync only.' +//@ has 'foo/qux/index.html' +//@ has '-' '//*[@class="stab portability"]' 'Available on crate feature sync only.' #[doc(cfg(feature = "sync"))] pub mod qux { - // @has 'foo/qux/struct.Qux.html' - // @has '-' '//*[@class="stab portability"]' 'Available on crate features sync and send only.' + //@ has 'foo/qux/struct.Qux.html' + //@ has '-' '//*[@class="stab portability"]' 'Available on crate features sync and send only.' #[doc(cfg(all(feature = "sync", feature = "send")))] pub struct Qux; } -// @has 'foo/quux/index.html' -// @has '-' '//*[@class="stab portability"]' 'Available on crate feature sync and crate feature send and foo only.' +//@ has 'foo/quux/index.html' +//@ has '-' '//*[@class="stab portability"]' 'Available on crate feature sync and crate feature send and foo only.' #[doc(cfg(all(feature = "sync", feature = "send", foo)))] pub mod quux { - // @has 'foo/quux/struct.Quux.html' - // @has '-' '//*[@class="stab portability"]' 'Available on crate feature sync and crate feature send and foo and bar only.' + //@ has 'foo/quux/struct.Quux.html' + //@ has '-' '//*[@class="stab portability"]' 'Available on crate feature sync and crate feature send and foo and bar only.' #[doc(cfg(all(feature = "send", feature = "sync", bar)))] pub struct Quux; } diff --git a/tests/rustdoc/duplicate-flags.rs b/tests/rustdoc/duplicate-flags.rs index c0df181397b..230eedfba62 100644 --- a/tests/rustdoc/duplicate-flags.rs +++ b/tests/rustdoc/duplicate-flags.rs @@ -1,4 +1,4 @@ //@ compile-flags: --document-private-items --document-private-items -// @has duplicate_flags/struct.Private.html +//@ has duplicate_flags/struct.Private.html struct Private; diff --git a/tests/rustdoc/duplicate_impls/issue-33054.rs b/tests/rustdoc/duplicate_impls/issue-33054.rs index 4c2071b8322..24ff30668cf 100644 --- a/tests/rustdoc/duplicate_impls/issue-33054.rs +++ b/tests/rustdoc/duplicate_impls/issue-33054.rs @@ -1,13 +1,13 @@ // ignore-tidy-linelength -// @has issue_33054/impls/struct.Foo.html -// @has - '//h3[@class="code-header"]' 'impl Foo' -// @has - '//h3[@class="code-header"]' 'impl Bar for Foo' -// @count - '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1 -// @count - '//*[@id="main-content"]/div[@id="implementations-list"]/details/summary/*[@class="impl"]' 1 -// @has issue_33054/impls/bar/trait.Bar.html -// @has - '//h3[@class="code-header"]' 'impl Bar for Foo' -// @count - '//*[@class="struct"]' 1 +//@ has issue_33054/impls/struct.Foo.html +//@ has - '//h3[@class="code-header"]' 'impl Foo' +//@ has - '//h3[@class="code-header"]' 'impl Bar for Foo' +//@ count - '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1 +//@ count - '//*[@id="main-content"]/div[@id="implementations-list"]/details/summary/*[@class="impl"]' 1 +//@ has issue_33054/impls/bar/trait.Bar.html +//@ has - '//h3[@class="code-header"]' 'impl Bar for Foo' +//@ count - '//*[@class="struct"]' 1 pub mod impls; #[doc(inline)] diff --git a/tests/rustdoc/duplicated-glob-reexport-60522.rs b/tests/rustdoc/duplicated-glob-reexport-60522.rs index 50def2c3cd9..a75a21c2dac 100644 --- a/tests/rustdoc/duplicated-glob-reexport-60522.rs +++ b/tests/rustdoc/duplicated-glob-reexport-60522.rs @@ -4,14 +4,14 @@ #![crate_name = "foo"] -// @has 'foo/index.html' -// @count - '//*[@id="main-content"]/*[@class="section-header"]' 1 -// @has - '//*[@id="main-content"]/*[@class="section-header"]' 'Modules' -// @count - '//*[@id="main-content"]/*[@class="item-table"]//*[@class="mod"]' 2 -// @has - '//*[@id="main-content"]//*[@class="mod"]' 'banana' -// @has - '//*[@id="main-content"]//*[@href="banana/index.html"]' 'banana' -// @has - '//*[@id="main-content"]//*[@class="mod"]' 'peach' -// @has - '//*[@id="main-content"]//*[@href="peach/index.html"]' 'peach' +//@ has 'foo/index.html' +//@ count - '//*[@id="main-content"]/*[@class="section-header"]' 1 +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Modules' +//@ count - '//*[@id="main-content"]/*[@class="item-table"]//*[@class="mod"]' 2 +//@ has - '//*[@id="main-content"]//*[@class="mod"]' 'banana' +//@ has - '//*[@id="main-content"]//*[@href="banana/index.html"]' 'banana' +//@ has - '//*[@id="main-content"]//*[@class="mod"]' 'peach' +//@ has - '//*[@id="main-content"]//*[@href="peach/index.html"]' 'peach' pub use crate::my_crate::*; @@ -24,16 +24,16 @@ mod my_crate { } } -// @has 'foo/banana/index.html' -// @count - '//*[@id="main-content"]//*[@class="struct"]' 1 -// @has - '//*[@id="main-content"]//*[@class="struct"]' 'Brown' +//@ has 'foo/banana/index.html' +//@ count - '//*[@id="main-content"]//*[@class="struct"]' 1 +//@ has - '//*[@id="main-content"]//*[@class="struct"]' 'Brown' pub mod banana { pub struct Brown; } -// @has 'foo/peach/index.html' -// @count - '//*[@id="main-content"]//*[@class="struct"]' 1 -// @has - '//*[@id="main-content"]//*[@class="struct"]' 'Pungent' +//@ has 'foo/peach/index.html' +//@ count - '//*[@id="main-content"]//*[@class="struct"]' 1 +//@ has - '//*[@id="main-content"]//*[@class="struct"]' 'Pungent' pub mod peach { pub struct Pungent; } diff --git a/tests/rustdoc/duplicated_impl.rs b/tests/rustdoc/duplicated_impl.rs index f32cf310055..e7828885cc1 100644 --- a/tests/rustdoc/duplicated_impl.rs +++ b/tests/rustdoc/duplicated_impl.rs @@ -6,8 +6,8 @@ // We check that there is only one "impl<T> Something<Whatever> for T" listed in the // blanket implementations. -// @has 'foo/struct.Whatever.html' -// @count - '//*[@id="blanket-implementations-list"]/section[@class="impl"]' 1 +//@ has 'foo/struct.Whatever.html' +//@ count - '//*[@id="blanket-implementations-list"]/section[@class="impl"]' 1 pub trait Something<T> { } pub struct Whatever; diff --git a/tests/rustdoc/early-unindent.rs b/tests/rustdoc/early-unindent.rs index 791a452c957..33342aaee0e 100644 --- a/tests/rustdoc/early-unindent.rs +++ b/tests/rustdoc/early-unindent.rs @@ -6,8 +6,8 @@ pub mod app { pub struct S; impl S { - // @has 'foo/app/struct.S.html' - // @has - '//a[@href="../enums/enum.Foo.html#method.by_name"]' 'Foo::by_name' + //@ has 'foo/app/struct.S.html' + //@ has - '//a[@href="../enums/enum.Foo.html#method.by_name"]' 'Foo::by_name' /** Doc comment hello! [`Foo::by_name`](`crate::enums::Foo::by_name`). */ diff --git a/tests/rustdoc/elided-lifetime.rs b/tests/rustdoc/elided-lifetime.rs index 4df381a6f68..259325762c6 100644 --- a/tests/rustdoc/elided-lifetime.rs +++ b/tests/rustdoc/elided-lifetime.rs @@ -10,34 +10,34 @@ pub struct Ref<'a>(&'a u32); type ARef<'a> = Ref<'a>; -// @has foo/fn.test1.html -// @matchesraw - "Ref</a><'_>" +//@ has foo/fn.test1.html +//@ matchesraw - "Ref</a><'_>" pub fn test1(a: &u32) -> Ref { Ref(a) } -// @has foo/fn.test2.html -// @matchesraw - "Ref</a><'_>" +//@ has foo/fn.test2.html +//@ matchesraw - "Ref</a><'_>" pub fn test2(a: &u32) -> Ref<'_> { Ref(a) } -// @has foo/fn.test3.html -// @matchesraw - "Ref</a><'_>" +//@ has foo/fn.test3.html +//@ matchesraw - "Ref</a><'_>" pub fn test3(a: &u32) -> ARef { Ref(a) } -// @has foo/fn.test4.html -// @matchesraw - "Ref</a><'_>" +//@ has foo/fn.test4.html +//@ matchesraw - "Ref</a><'_>" pub fn test4(a: &u32) -> ARef<'_> { Ref(a) } // Ensure external paths in inlined docs also display elided lifetime -// @has foo/bar/fn.test5.html -// @matchesraw - "Ref</a><'_>" -// @has foo/bar/fn.test6.html -// @matchesraw - "Ref</a><'_>" +//@ has foo/bar/fn.test5.html +//@ matchesraw - "Ref</a><'_>" +//@ has foo/bar/fn.test6.html +//@ matchesraw - "Ref</a><'_>" #[doc(inline)] pub extern crate bar; diff --git a/tests/rustdoc/empty-impl-block-private-with-doc.rs b/tests/rustdoc/empty-impl-block-private-with-doc.rs index 21c860c0923..5dc7e1aed7a 100644 --- a/tests/rustdoc/empty-impl-block-private-with-doc.rs +++ b/tests/rustdoc/empty-impl-block-private-with-doc.rs @@ -4,13 +4,13 @@ #![allow(incomplete_features)] #![crate_name = "foo"] -// @has 'foo/struct.Foo.html' +//@ has 'foo/struct.Foo.html' pub struct Foo; // There are 3 impl blocks with public item and one that should not be displayed // by default because it only contains private items (but not in this case because // we used `--document-private-items`). -// @count - '//*[@class="impl"]' 'impl Foo' 4 +//@ count - '//*[@class="impl"]' 'impl Foo' 4 // Impl block only containing private items should not be displayed unless the // `--document-private-items` flag is used. diff --git a/tests/rustdoc/empty-impl-block-private.rs b/tests/rustdoc/empty-impl-block-private.rs index d44b4a47cee..2ee65d1a969 100644 --- a/tests/rustdoc/empty-impl-block-private.rs +++ b/tests/rustdoc/empty-impl-block-private.rs @@ -2,12 +2,12 @@ #![allow(incomplete_features)] #![crate_name = "foo"] -// @has 'foo/struct.Foo.html' +//@ has 'foo/struct.Foo.html' pub struct Foo; // There are 3 impl blocks with public item and one that should not be displayed // because it only contains private items. -// @count - '//*[@class="impl"]' 'impl Foo' 3 +//@ count - '//*[@class="impl"]' 'impl Foo' 3 // Impl block only containing private items should not be displayed. /// Private diff --git a/tests/rustdoc/empty-impl-block.rs b/tests/rustdoc/empty-impl-block.rs index da780580bd0..91fd4a64ef9 100644 --- a/tests/rustdoc/empty-impl-block.rs +++ b/tests/rustdoc/empty-impl-block.rs @@ -1,20 +1,20 @@ #![crate_name = "foo"] -// @has 'foo/struct.Foo.html' +//@ has 'foo/struct.Foo.html' pub struct Foo; -// @has - '//*[@class="docblock"]' 'Hello empty impl block!' -// @has - '//*[@class="item-info"]' 'This impl block contains no items.' +//@ has - '//*[@class="docblock"]' 'Hello empty impl block!' +//@ has - '//*[@class="item-info"]' 'This impl block contains no items.' /// Hello empty impl block! impl Foo {} // We ensure that this empty impl block without doc isn't rendered. -// @count - '//*[@class="impl"]' 'impl Foo' 1 +//@ count - '//*[@class="impl"]' 'impl Foo' 1 impl Foo {} // Just to ensure that empty trait impl blocks are rendered. pub struct Another; pub trait Bar {} -// @has 'foo/struct.Another.html' -// @has - '//h3[@class="code-header"]' 'impl Bar for Another' +//@ has 'foo/struct.Another.html' +//@ has - '//h3[@class="code-header"]' 'impl Bar for Another' impl Bar for Another {} diff --git a/tests/rustdoc/empty-impls.rs b/tests/rustdoc/empty-impls.rs index 83902d6f7ab..912a8d3d913 100644 --- a/tests/rustdoc/empty-impls.rs +++ b/tests/rustdoc/empty-impls.rs @@ -1,19 +1,19 @@ #![crate_name = "foo"] -// @has foo/struct.Foo.html -// @has - '//div[@id="synthetic-implementations-list"]/*[@id="impl-Send-for-Foo"]' 'impl Send for Foo' +//@ has foo/struct.Foo.html +//@ has - '//div[@id="synthetic-implementations-list"]/*[@id="impl-Send-for-Foo"]' 'impl Send for Foo' pub struct Foo; pub trait EmptyTrait {} -// @has - '//div[@id="trait-implementations-list"]/*[@id="impl-EmptyTrait-for-Foo"]' 'impl EmptyTrait for Foo' +//@ has - '//div[@id="trait-implementations-list"]/*[@id="impl-EmptyTrait-for-Foo"]' 'impl EmptyTrait for Foo' impl EmptyTrait for Foo {} pub trait NotEmpty { fn foo(&self); } -// @has - '//div[@id="trait-implementations-list"]/details/summary/*[@id="impl-NotEmpty-for-Foo"]' 'impl NotEmpty for Foo' +//@ has - '//div[@id="trait-implementations-list"]/details/summary/*[@id="impl-NotEmpty-for-Foo"]' 'impl NotEmpty for Foo' impl NotEmpty for Foo { fn foo(&self) {} } diff --git a/tests/rustdoc/empty-mod-private.rs b/tests/rustdoc/empty-mod-private.rs index 7e78aac1764..4e408e3d424 100644 --- a/tests/rustdoc/empty-mod-private.rs +++ b/tests/rustdoc/empty-mod-private.rs @@ -1,16 +1,16 @@ //@ compile-flags: --document-private-items -// @has 'empty_mod_private/index.html' '//a[@href="foo/index.html"]' 'foo' -// @hasraw 'empty_mod_private/sidebar-items.js' 'foo' -// @matches 'empty_mod_private/foo/index.html' '//h1' 'Module empty_mod_private::foo' +//@ has 'empty_mod_private/index.html' '//a[@href="foo/index.html"]' 'foo' +//@ hasraw 'empty_mod_private/sidebar-items.js' 'foo' +//@ matches 'empty_mod_private/foo/index.html' '//h1' 'Module empty_mod_private::foo' mod foo {} -// @has 'empty_mod_private/index.html' '//a[@href="bar/index.html"]' 'bar' -// @hasraw 'empty_mod_private/sidebar-items.js' 'bar' -// @matches 'empty_mod_private/bar/index.html' '//h1' 'Module empty_mod_private::bar' +//@ has 'empty_mod_private/index.html' '//a[@href="bar/index.html"]' 'bar' +//@ hasraw 'empty_mod_private/sidebar-items.js' 'bar' +//@ matches 'empty_mod_private/bar/index.html' '//h1' 'Module empty_mod_private::bar' mod bar { - // @has 'empty_mod_private/bar/index.html' '//a[@href="baz/index.html"]' 'baz' - // @hasraw 'empty_mod_private/bar/sidebar-items.js' 'baz' - // @matches 'empty_mod_private/bar/baz/index.html' '//h1' 'Module empty_mod_private::bar::baz' + //@ has 'empty_mod_private/bar/index.html' '//a[@href="baz/index.html"]' 'baz' + //@ hasraw 'empty_mod_private/bar/sidebar-items.js' 'baz' + //@ matches 'empty_mod_private/bar/baz/index.html' '//h1' 'Module empty_mod_private::bar::baz' mod baz {} } diff --git a/tests/rustdoc/empty-mod-public.rs b/tests/rustdoc/empty-mod-public.rs index c0bac40212c..b5a63525524 100644 --- a/tests/rustdoc/empty-mod-public.rs +++ b/tests/rustdoc/empty-mod-public.rs @@ -1,14 +1,14 @@ -// @has 'empty_mod_public/index.html' '//a[@href="foo/index.html"]' 'foo' -// @hasraw 'empty_mod_public/sidebar-items.js' 'foo' -// @matches 'empty_mod_public/foo/index.html' '//h1' 'Module empty_mod_public::foo' +//@ has 'empty_mod_public/index.html' '//a[@href="foo/index.html"]' 'foo' +//@ hasraw 'empty_mod_public/sidebar-items.js' 'foo' +//@ matches 'empty_mod_public/foo/index.html' '//h1' 'Module empty_mod_public::foo' pub mod foo {} -// @has 'empty_mod_public/index.html' '//a[@href="bar/index.html"]' 'bar' -// @hasraw 'empty_mod_public/sidebar-items.js' 'bar' -// @matches 'empty_mod_public/bar/index.html' '//h1' 'Module empty_mod_public::bar' +//@ has 'empty_mod_public/index.html' '//a[@href="bar/index.html"]' 'bar' +//@ hasraw 'empty_mod_public/sidebar-items.js' 'bar' +//@ matches 'empty_mod_public/bar/index.html' '//h1' 'Module empty_mod_public::bar' pub mod bar { - // @has 'empty_mod_public/bar/index.html' '//a[@href="baz/index.html"]' 'baz' - // @hasraw 'empty_mod_public/bar/sidebar-items.js' 'baz' - // @matches 'empty_mod_public/bar/baz/index.html' '//h1' 'Module empty_mod_public::bar::baz' + //@ has 'empty_mod_public/bar/index.html' '//a[@href="baz/index.html"]' 'baz' + //@ hasraw 'empty_mod_public/bar/sidebar-items.js' 'baz' + //@ matches 'empty_mod_public/bar/baz/index.html' '//h1' 'Module empty_mod_public::bar::baz' pub mod baz {} } diff --git a/tests/rustdoc/empty-section.rs b/tests/rustdoc/empty-section.rs index 0d6afb0e444..71ebc66d695 100644 --- a/tests/rustdoc/empty-section.rs +++ b/tests/rustdoc/empty-section.rs @@ -3,8 +3,8 @@ pub struct Foo; -// @has foo/struct.Foo.html -// @!hasraw - 'Auto Trait Implementations' +//@ has foo/struct.Foo.html +//@ !hasraw - 'Auto Trait Implementations' impl !Send for Foo {} impl !Sync for Foo {} impl !std::marker::Freeze for Foo {} diff --git a/tests/rustdoc/ensure-src-link.rs b/tests/rustdoc/ensure-src-link.rs index f95b5f2d424..4156fdcba59 100644 --- a/tests/rustdoc/ensure-src-link.rs +++ b/tests/rustdoc/ensure-src-link.rs @@ -2,5 +2,5 @@ // This test ensures that the [src] link is present on traits items. -// @has foo/trait.Iterator.html '//*[@id="method.zip"]//a[@class="src"]' "source" +//@ has foo/trait.Iterator.html '//*[@id="method.zip"]//a[@class="src"]' "source" pub use std::iter::Iterator; diff --git a/tests/rustdoc/enum-headings.rs b/tests/rustdoc/enum-headings.rs index 2e5c34391c4..6deabf1cd9a 100644 --- a/tests/rustdoc/enum-headings.rs +++ b/tests/rustdoc/enum-headings.rs @@ -1,25 +1,25 @@ #![crate_name = "foo"] -// @has foo/enum.Token.html +//@ has foo/enum.Token.html /// A token! /// # First /// Some following text... -// @has - '//h2[@id="first"]' "First" +//@ has - '//h2[@id="first"]' "First" pub enum Token { /// A declaration! /// # Variant-First /// Some following text... - // @has - '//h4[@id="variant-first"]' "Variant-First" + //@ has - '//h4[@id="variant-first"]' "Variant-First" Declaration { /// A version! /// # Variant-Field-First /// Some following text... - // @has - '//h5[@id="variant-field-first"]' "Variant-Field-First" + //@ has - '//h5[@id="variant-field-first"]' "Variant-Field-First" version: String, }, /// A Zoople! /// # Variant-First Zoople( - // @has - '//h5[@id="variant-tuple-field-first"]' "Variant-Tuple-Field-First" + //@ has - '//h5[@id="variant-tuple-field-first"]' "Variant-Tuple-Field-First" /// Zoople's first variant! /// # Variant-Tuple-Field-First /// Some following text... @@ -28,13 +28,13 @@ pub enum Token { /// Unfinished business! /// # Non-Exhaustive-First /// Some following text... - // @has - '//h4[@id="non-exhaustive-first"]' "Non-Exhaustive-First" + //@ has - '//h4[@id="non-exhaustive-first"]' "Non-Exhaustive-First" #[non_exhaustive] Unfinished { /// This is x. /// # X-First /// Some following text... - // @has - '//h5[@id="x-first"]' "X-First" + //@ has - '//h5[@id="x-first"]' "X-First" x: usize, }, } diff --git a/tests/rustdoc/enum-variant-doc-hidden-field-88600.rs b/tests/rustdoc/enum-variant-doc-hidden-field-88600.rs index 31d96e9db75..f1d461c66c3 100644 --- a/tests/rustdoc/enum-variant-doc-hidden-field-88600.rs +++ b/tests/rustdoc/enum-variant-doc-hidden-field-88600.rs @@ -8,26 +8,26 @@ pub struct H; // Denotes a field which should not be hidden (shown). pub struct S; -// @has foo/enum.FooEnum.html +//@ has foo/enum.FooEnum.html pub enum FooEnum { - // @has - '//*[@id="variant.HiddenTupleItem"]//h3' 'HiddenTupleItem(/* private fields */)' - // @count - '//*[@id="variant.HiddenTupleItem.field.0"]' 0 + //@ has - '//*[@id="variant.HiddenTupleItem"]//h3' 'HiddenTupleItem(/* private fields */)' + //@ count - '//*[@id="variant.HiddenTupleItem.field.0"]' 0 HiddenTupleItem(#[doc(hidden)] H), - // @has - '//*[@id="variant.MultipleHidden"]//h3' 'MultipleHidden(/* private fields */)' - // @count - '//*[@id="variant.MultipleHidden.field.0"]' 0 - // @count - '//*[@id="variant.MultipleHidden.field.1"]' 0 + //@ has - '//*[@id="variant.MultipleHidden"]//h3' 'MultipleHidden(/* private fields */)' + //@ count - '//*[@id="variant.MultipleHidden.field.0"]' 0 + //@ count - '//*[@id="variant.MultipleHidden.field.1"]' 0 MultipleHidden(#[doc(hidden)] H, #[doc(hidden)] H), - // @has - '//*[@id="variant.MixedHiddenFirst"]//h3' 'MixedHiddenFirst(_, S)' - // @count - '//*[@id="variant.MixedHiddenFirst.field.0"]' 0 - // @has - '//*[@id="variant.MixedHiddenFirst.field.1"]' '1: S' + //@ has - '//*[@id="variant.MixedHiddenFirst"]//h3' 'MixedHiddenFirst(_, S)' + //@ count - '//*[@id="variant.MixedHiddenFirst.field.0"]' 0 + //@ has - '//*[@id="variant.MixedHiddenFirst.field.1"]' '1: S' MixedHiddenFirst(#[doc(hidden)] H, /** dox */ S), - // @has - '//*[@id="variant.MixedHiddenLast"]//h3' 'MixedHiddenLast(S, _)' - // @has - '//*[@id="variant.MixedHiddenLast.field.0"]' '0: S' - // @count - '//*[@id="variant.MixedHiddenLast.field.1"]' 0 + //@ has - '//*[@id="variant.MixedHiddenLast"]//h3' 'MixedHiddenLast(S, _)' + //@ has - '//*[@id="variant.MixedHiddenLast.field.0"]' '0: S' + //@ count - '//*[@id="variant.MixedHiddenLast.field.1"]' 0 MixedHiddenLast(/** dox */ S, #[doc(hidden)] H), - // @has - '//*[@id="variant.HiddenStruct"]//h3' 'HiddenStruct' - // @count - '//*[@id="variant.HiddenStruct.field.h"]' 0 - // @has - '//*[@id="variant.HiddenStruct.field.s"]' 's: S' + //@ has - '//*[@id="variant.HiddenStruct"]//h3' 'HiddenStruct' + //@ count - '//*[@id="variant.HiddenStruct.field.h"]' 0 + //@ has - '//*[@id="variant.HiddenStruct.field.s"]' 's: S' HiddenStruct { #[doc(hidden)] h: H, diff --git a/tests/rustdoc/enum-variant-fields-heading.rs b/tests/rustdoc/enum-variant-fields-heading.rs index 8a7c99a8735..e210667d3c0 100644 --- a/tests/rustdoc/enum-variant-fields-heading.rs +++ b/tests/rustdoc/enum-variant-fields-heading.rs @@ -3,12 +3,12 @@ #![crate_name = "foo"] -// @has 'foo/enum.Foo.html' -// @has - '//*[@id="variant.A"]' 'A' -// @count - '//*[@id="variant.A.fields"]' 0 -// @has - '//*[@id="variant.B"]' 'B' -// @count - '//*[@id="variant.B.fields"]' 0 -// @snapshot variants - '//*[@id="main-content"]/*[@class="variants"]' +//@ has 'foo/enum.Foo.html' +//@ has - '//*[@id="variant.A"]' 'A' +//@ count - '//*[@id="variant.A.fields"]' 0 +//@ has - '//*[@id="variant.B"]' 'B' +//@ count - '//*[@id="variant.B.fields"]' 0 +//@ snapshot variants - '//*[@id="main-content"]/*[@class="variants"]' pub enum Foo { /// A variant with no fields diff --git a/tests/rustdoc/enum-variant-private-46767.rs b/tests/rustdoc/enum-variant-private-46767.rs index 6386aa75a95..cc93684e723 100644 --- a/tests/rustdoc/enum-variant-private-46767.rs +++ b/tests/rustdoc/enum-variant-private-46767.rs @@ -6,5 +6,5 @@ mod private { } pub use self::private::Enum::*; -// @!has-dir foo/private -// @!has foo/index.html '//a/@href' 'private/index.html' +//@ !has-dir foo/private +//@ !has foo/index.html '//a/@href' 'private/index.html' diff --git a/tests/rustdoc/enum-variant-reexport-35488.rs b/tests/rustdoc/enum-variant-reexport-35488.rs index ed955dcd770..b8e42ef7a89 100644 --- a/tests/rustdoc/enum-variant-reexport-35488.rs +++ b/tests/rustdoc/enum-variant-reexport-35488.rs @@ -8,9 +8,9 @@ mod foo { pub use self::Foo::*; } -// @has 'foo/index.html' '//code' 'pub use self::Foo::*;' -// @has 'foo/enum.Foo.html' +//@ has 'foo/index.html' '//code' 'pub use self::Foo::*;' +//@ has 'foo/enum.Foo.html' pub use self::foo::*; -// @has 'foo/index.html' '//code' 'pub use std::option::Option::None;' +//@ has 'foo/index.html' '//code' 'pub use std::option::Option::None;' pub use std::option::Option::None; diff --git a/tests/rustdoc/enum-variant-value.rs b/tests/rustdoc/enum-variant-value.rs index 5767d9e5423..1670de8a24f 100644 --- a/tests/rustdoc/enum-variant-value.rs +++ b/tests/rustdoc/enum-variant-value.rs @@ -10,13 +10,13 @@ extern crate bar; // In this case, since all variants are C-like variants and at least one of them // has its value set, we display values for all of them. -// @has 'foo/enum.A.html' -// @has - '//*[@class="rust item-decl"]/code' 'A = 12,' -// @has - '//*[@class="rust item-decl"]/code' 'B = 13,' -// @has - '//*[@class="rust item-decl"]/code' 'C = 1_245,' -// @matches - '//*[@id="variant.A"]/h3' '^A = 12$' -// @matches - '//*[@id="variant.B"]/h3' '^B = 13$' -// @matches - '//*[@id="variant.C"]/h3' '^C = 1_245$' +//@ has 'foo/enum.A.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A = 12,' +//@ has - '//*[@class="rust item-decl"]/code' 'B = 13,' +//@ has - '//*[@class="rust item-decl"]/code' 'C = 1_245,' +//@ matches - '//*[@id="variant.A"]/h3' '^A = 12$' +//@ matches - '//*[@id="variant.B"]/h3' '^B = 13$' +//@ matches - '//*[@id="variant.C"]/h3' '^C = 1_245$' pub enum A { A = 12, B, @@ -26,11 +26,11 @@ pub enum A { // In this case, all variants are C-like variants but none of them has its value set. // Therefore we don't display values. -// @has 'foo/enum.B.html' -// @has - '//*[@class="rust item-decl"]/code' 'A,' -// @has - '//*[@class="rust item-decl"]/code' 'B,' -// @matches - '//*[@id="variant.A"]/h3' '^A$' -// @matches - '//*[@id="variant.B"]/h3' '^B$' +//@ has 'foo/enum.B.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A,' +//@ has - '//*[@class="rust item-decl"]/code' 'B,' +//@ matches - '//*[@id="variant.A"]/h3' '^A$' +//@ matches - '//*[@id="variant.B"]/h3' '^B$' pub enum B { A, B, @@ -38,13 +38,13 @@ pub enum B { // In this case, not all variants are C-like variants so we don't display values. -// @has 'foo/enum.C.html' -// @has - '//*[@class="rust item-decl"]/code' 'A = 12,' -// @has - '//*[@class="rust item-decl"]/code' 'B,' -// @has - '//*[@class="rust item-decl"]/code' 'C(u32),' -// @matches - '//*[@id="variant.A"]/h3' '^A = 12$' -// @matches - '//*[@id="variant.B"]/h3' '^B$' -// @has - '//*[@id="variant.C"]/h3' 'C(u32)' +//@ has 'foo/enum.C.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A = 12,' +//@ has - '//*[@class="rust item-decl"]/code' 'B,' +//@ has - '//*[@class="rust item-decl"]/code' 'C(u32),' +//@ matches - '//*[@id="variant.A"]/h3' '^A = 12$' +//@ matches - '//*[@id="variant.B"]/h3' '^B$' +//@ has - '//*[@id="variant.C"]/h3' 'C(u32)' #[repr(u32)] pub enum C { A = 12, @@ -55,59 +55,59 @@ pub enum C { // In this case, not all variants are C-like variants and no C-like variant has its // value set, so we don't display values. -// @has 'foo/enum.D.html' -// @has - '//*[@class="rust item-decl"]/code' 'A,' -// @has - '//*[@class="rust item-decl"]/code' 'C(u32),' -// @matches - '//*[@id="variant.A"]/h3' '^A$' -// @has - '//*[@id="variant.C"]/h3' 'C(u32)' +//@ has 'foo/enum.D.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A,' +//@ has - '//*[@class="rust item-decl"]/code' 'C(u32),' +//@ matches - '//*[@id="variant.A"]/h3' '^A$' +//@ has - '//*[@id="variant.C"]/h3' 'C(u32)' pub enum D { A, C(u32), } -// @has 'foo/enum.E.html' -// @has - '//*[@class="rust item-decl"]/code' 'A = 12,' -// @has - '//*[@class="rust item-decl"]/code' 'B = 13,' -// @has - '//*[@class="rust item-decl"]/code' 'C = 1_245,' -// @matches - '//*[@id="variant.A"]/h3' '^A = 12$' -// @matches - '//*[@id="variant.B"]/h3' '^B = 13$' -// @matches - '//*[@id="variant.C"]/h3' '^C = 1_245$' +//@ has 'foo/enum.E.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A = 12,' +//@ has - '//*[@class="rust item-decl"]/code' 'B = 13,' +//@ has - '//*[@class="rust item-decl"]/code' 'C = 1_245,' +//@ matches - '//*[@id="variant.A"]/h3' '^A = 12$' +//@ matches - '//*[@id="variant.B"]/h3' '^B = 13$' +//@ matches - '//*[@id="variant.C"]/h3' '^C = 1_245$' pub use bar::E; -// @has 'foo/enum.F.html' -// @has - '//*[@class="rust item-decl"]/code' 'A,' -// @has - '//*[@class="rust item-decl"]/code' 'B,' -// @matches - '//*[@id="variant.A"]/h3' '^A$' -// @matches - '//*[@id="variant.B"]/h3' '^B$' +//@ has 'foo/enum.F.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A,' +//@ has - '//*[@class="rust item-decl"]/code' 'B,' +//@ matches - '//*[@id="variant.A"]/h3' '^A$' +//@ matches - '//*[@id="variant.B"]/h3' '^B$' pub use bar::F; -// @has 'foo/enum.G.html' -// @has - '//*[@class="rust item-decl"]/code' 'A = 12,' -// @has - '//*[@class="rust item-decl"]/code' 'B,' -// @has - '//*[@class="rust item-decl"]/code' 'C(u32),' -// @matches - '//*[@id="variant.A"]/h3' '^A = 12$' -// @matches - '//*[@id="variant.B"]/h3' '^B$' -// @has - '//*[@id="variant.C"]/h3' 'C(u32)' +//@ has 'foo/enum.G.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A = 12,' +//@ has - '//*[@class="rust item-decl"]/code' 'B,' +//@ has - '//*[@class="rust item-decl"]/code' 'C(u32),' +//@ matches - '//*[@id="variant.A"]/h3' '^A = 12$' +//@ matches - '//*[@id="variant.B"]/h3' '^B$' +//@ has - '//*[@id="variant.C"]/h3' 'C(u32)' pub use bar::G; -// @has 'foo/enum.H.html' -// @has - '//*[@class="rust item-decl"]/code' 'A,' -// @has - '//*[@class="rust item-decl"]/code' 'C(u32),' -// @matches - '//*[@id="variant.A"]/h3' '^A$' -// @has - '//*[@id="variant.C"]/h3' 'C(u32)' +//@ has 'foo/enum.H.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A,' +//@ has - '//*[@class="rust item-decl"]/code' 'C(u32),' +//@ matches - '//*[@id="variant.A"]/h3' '^A$' +//@ has - '//*[@id="variant.C"]/h3' 'C(u32)' pub use bar::H; // Testing more complex cases. pub const X: isize = 2; -// @has 'foo/enum.I.html' -// @has - '//*[@class="rust item-decl"]/code' 'A = 2,' -// @has - '//*[@class="rust item-decl"]/code' 'B = 4,' -// @has - '//*[@class="rust item-decl"]/code' 'C = 9,' -// @has - '//*[@class="rust item-decl"]/code' 'D = -1,' -// @matches - '//*[@id="variant.A"]/h3' '^A = 2$' -// @matches - '//*[@id="variant.B"]/h3' '^B = 4$' -// @matches - '//*[@id="variant.C"]/h3' '^C = 9$' -// @matches - '//*[@id="variant.D"]/h3' '^D = -1$' +//@ has 'foo/enum.I.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A = 2,' +//@ has - '//*[@class="rust item-decl"]/code' 'B = 4,' +//@ has - '//*[@class="rust item-decl"]/code' 'C = 9,' +//@ has - '//*[@class="rust item-decl"]/code' 'D = -1,' +//@ matches - '//*[@id="variant.A"]/h3' '^A = 2$' +//@ matches - '//*[@id="variant.B"]/h3' '^B = 4$' +//@ matches - '//*[@id="variant.C"]/h3' '^C = 9$' +//@ matches - '//*[@id="variant.D"]/h3' '^D = -1$' #[repr(isize)] pub enum I { A = X, @@ -118,74 +118,74 @@ pub enum I { // Testing `repr`. -// @has 'foo/enum.J.html' -// @has - '//*[@class="rust item-decl"]/code' 'A = 0,' -// @has - '//*[@class="rust item-decl"]/code' 'B = 1,' -// @matches - '//*[@id="variant.A"]/h3' '^A = 0$' -// @matches - '//*[@id="variant.B"]/h3' '^B = 1$' +//@ has 'foo/enum.J.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A = 0,' +//@ has - '//*[@class="rust item-decl"]/code' 'B = 1,' +//@ matches - '//*[@id="variant.A"]/h3' '^A = 0$' +//@ matches - '//*[@id="variant.B"]/h3' '^B = 1$' #[repr(C)] pub enum J { A, B, } -// @has 'foo/enum.K.html' -// @has - '//*[@class="rust item-decl"]/code' 'A(u32),' -// @has - '//*[@class="rust item-decl"]/code' 'B,' -// @has - '//*[@id="variant.A"]/h3' 'A(u32)' -// @matches - '//*[@id="variant.B"]/h3' '^B$' +//@ has 'foo/enum.K.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A(u32),' +//@ has - '//*[@class="rust item-decl"]/code' 'B,' +//@ has - '//*[@id="variant.A"]/h3' 'A(u32)' +//@ matches - '//*[@id="variant.B"]/h3' '^B$' #[repr(C)] pub enum K { A(u32), B, } -// @has 'foo/enum.L.html' -// @has - '//*[@class="rust item-decl"]/code' 'A = 0,' -// @has - '//*[@class="rust item-decl"]/code' 'B = 1,' -// @matches - '//*[@id="variant.A"]/h3' '^A = 0$' -// @matches - '//*[@id="variant.B"]/h3' '^B = 1$' +//@ has 'foo/enum.L.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A = 0,' +//@ has - '//*[@class="rust item-decl"]/code' 'B = 1,' +//@ matches - '//*[@id="variant.A"]/h3' '^A = 0$' +//@ matches - '//*[@id="variant.B"]/h3' '^B = 1$' #[repr(u32)] pub enum L { A, B, } -// @has 'foo/enum.M.html' -// @has - '//*[@class="rust item-decl"]/code' 'A(u32),' -// @has - '//*[@class="rust item-decl"]/code' 'B,' -// @has - '//*[@id="variant.A"]/h3' 'A(u32)' -// @matches - '//*[@id="variant.B"]/h3' '^B$' +//@ has 'foo/enum.M.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A(u32),' +//@ has - '//*[@class="rust item-decl"]/code' 'B,' +//@ has - '//*[@id="variant.A"]/h3' 'A(u32)' +//@ matches - '//*[@id="variant.B"]/h3' '^B$' #[repr(u32)] pub enum M { A(u32), B, } -// @has 'foo/enum.N.html' -// @has - '//*[@class="rust item-decl"]/code' 'A = 0,' -// @has - '//*[@class="rust item-decl"]/code' 'B = 1,' -// @matches - '//*[@id="variant.A"]/h3' '^A = 0$' -// @matches - '//*[@id="variant.B"]/h3' '^B = 1$' +//@ has 'foo/enum.N.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A = 0,' +//@ has - '//*[@class="rust item-decl"]/code' 'B = 1,' +//@ matches - '//*[@id="variant.A"]/h3' '^A = 0$' +//@ matches - '//*[@id="variant.B"]/h3' '^B = 1$' pub use bar::N; -// @has 'foo/enum.O.html' -// @has - '//*[@class="rust item-decl"]/code' 'A(u32),' -// @has - '//*[@class="rust item-decl"]/code' 'B,' -// @has - '//*[@id="variant.A"]/h3' 'A(u32)' -// @matches - '//*[@id="variant.B"]/h3' '^B$' +//@ has 'foo/enum.O.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A(u32),' +//@ has - '//*[@class="rust item-decl"]/code' 'B,' +//@ has - '//*[@id="variant.A"]/h3' 'A(u32)' +//@ matches - '//*[@id="variant.B"]/h3' '^B$' pub use bar::O; -// @has 'foo/enum.P.html' -// @has - '//*[@class="rust item-decl"]/code' 'A = 0,' -// @has - '//*[@class="rust item-decl"]/code' 'B = 1,' -// @matches - '//*[@id="variant.A"]/h3' '^A = 0$' -// @matches - '//*[@id="variant.B"]/h3' '^B = 1$' +//@ has 'foo/enum.P.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A = 0,' +//@ has - '//*[@class="rust item-decl"]/code' 'B = 1,' +//@ matches - '//*[@id="variant.A"]/h3' '^A = 0$' +//@ matches - '//*[@id="variant.B"]/h3' '^B = 1$' pub use bar::P; -// @has 'foo/enum.Q.html' -// @has - '//*[@class="rust item-decl"]/code' 'A(u32),' -// @has - '//*[@class="rust item-decl"]/code' 'B,' -// @has - '//*[@id="variant.A"]/h3' 'A(u32)' -// @matches - '//*[@id="variant.B"]/h3' '^B$' +//@ has 'foo/enum.Q.html' +//@ has - '//*[@class="rust item-decl"]/code' 'A(u32),' +//@ has - '//*[@class="rust item-decl"]/code' 'B,' +//@ has - '//*[@id="variant.A"]/h3' 'A(u32)' +//@ matches - '//*[@id="variant.B"]/h3' '^B$' pub use bar::Q; diff --git a/tests/rustdoc/extern-default-method.rs b/tests/rustdoc/extern-default-method.rs index 058c2200d94..1af9fab152e 100644 --- a/tests/rustdoc/extern-default-method.rs +++ b/tests/rustdoc/extern-default-method.rs @@ -16,8 +16,8 @@ extern crate rustdoc_extern_default_method as ext; // general: If the type `Struct` also had an inherent method called `provided`, the impl item // would link to that one even though those two methods are distinct items! -// @count extern_default_method/struct.Struct.html '//*[@id="method.provided"]' 1 -// @count extern_default_method/struct.Struct.html '//*[@id="method.provided"]//a[@class="fn"]' 1 -// @snapshot no_href_on_anchor - '//*[@id="method.provided"]//a[@class="fn"]' -// @has extern_default_method/struct.Struct.html '//*[@id="method.provided"]//a[@class="anchor"]/@href' #method.provided +//@ count extern_default_method/struct.Struct.html '//*[@id="method.provided"]' 1 +//@ count extern_default_method/struct.Struct.html '//*[@id="method.provided"]//a[@class="fn"]' 1 +//@ snapshot no_href_on_anchor - '//*[@id="method.provided"]//a[@class="fn"]' +//@ has extern_default_method/struct.Struct.html '//*[@id="method.provided"]//a[@class="anchor"]/@href' #method.provided pub use ext::Struct; diff --git a/tests/rustdoc/extern-fn-22038.rs b/tests/rustdoc/extern-fn-22038.rs index 72d39c32a1c..206c6e181d1 100644 --- a/tests/rustdoc/extern-fn-22038.rs +++ b/tests/rustdoc/extern-fn-22038.rs @@ -2,21 +2,21 @@ #![crate_name="issue_22038"] extern "C" { - // @has issue_22038/fn.foo1.html \ + //@ has issue_22038/fn.foo1.html \ // '//pre[@class="rust item-decl"]' 'pub unsafe extern "C" fn foo1()' pub fn foo1(); } extern "system" { - // @has issue_22038/fn.foo2.html \ + //@ has issue_22038/fn.foo2.html \ // '//pre[@class="rust item-decl"]' 'pub unsafe extern "system" fn foo2()' pub fn foo2(); } -// @has issue_22038/fn.bar.html \ +//@ has issue_22038/fn.bar.html \ // '//pre[@class="rust item-decl"]' 'pub extern "C" fn bar()' pub extern "C" fn bar() {} -// @has issue_22038/fn.baz.html \ +//@ has issue_22038/fn.baz.html \ // '//pre[@class="rust item-decl"]' 'pub extern "system" fn baz()' pub extern "system" fn baz() {} diff --git a/tests/rustdoc/extern-html-root-url-precedence.rs b/tests/rustdoc/extern-html-root-url-precedence.rs index 68af5ea5e04..93775087997 100644 --- a/tests/rustdoc/extern-html-root-url-precedence.rs +++ b/tests/rustdoc/extern-html-root-url-precedence.rs @@ -1,7 +1,7 @@ //@ compile-flags:-Z unstable-options --extern-html-root-url core=https://example.com/core/0.1.0 --extern-html-root-takes-precedence -// @has extern_html_root_url_precedence/index.html +//@ has extern_html_root_url_precedence/index.html // --extern-html-root should take precedence if `--takes-precedence` is passed -// @has - '//a/@href' 'https://example.com/core/0.1.0/core/iter/index.html' +//@ has - '//a/@href' 'https://example.com/core/0.1.0/core/iter/index.html' #[doc(no_inline)] pub use std::iter; diff --git a/tests/rustdoc/extern-html-root-url.rs b/tests/rustdoc/extern-html-root-url.rs index 672c460c20b..a503e829de4 100644 --- a/tests/rustdoc/extern-html-root-url.rs +++ b/tests/rustdoc/extern-html-root-url.rs @@ -6,13 +6,13 @@ extern crate html_root; extern crate no_html_root; -// @has extern_html_root_url/index.html +//@ has extern_html_root_url/index.html // `html_root_url` should override `--extern-html-root-url` -// @has - '//a/@href' 'https://example.com/html_root/html_root/fn.foo.html' +//@ has - '//a/@href' 'https://example.com/html_root/html_root/fn.foo.html' #[doc(no_inline)] pub use html_root::foo; #[doc(no_inline)] // `--extern-html-root-url` should apply if no `html_root_url` is given -// @has - '//a/@href' 'https://example.com/override/no_html_root/fn.bar.html' +//@ has - '//a/@href' 'https://example.com/override/no_html_root/fn.bar.html' pub use no_html_root::bar; diff --git a/tests/rustdoc/extern-impl-trait.rs b/tests/rustdoc/extern-impl-trait.rs index 9cc235504e7..65b7a8cef49 100644 --- a/tests/rustdoc/extern-impl-trait.rs +++ b/tests/rustdoc/extern-impl-trait.rs @@ -4,8 +4,8 @@ extern crate extern_impl_trait; -// @has 'foo/struct.X.html' '//h4[@class="code-header"]' "impl Foo<Associated = ()> + 'a" +//@ has 'foo/struct.X.html' '//h4[@class="code-header"]' "impl Foo<Associated = ()> + 'a" pub use extern_impl_trait::X; -// @has 'foo/struct.Y.html' '//h4[@class="code-header"]' "impl Foo<Associated = ()> + ?Sized + 'a" +//@ has 'foo/struct.Y.html' '//h4[@class="code-header"]' "impl Foo<Associated = ()> + ?Sized + 'a" pub use extern_impl_trait::Y; diff --git a/tests/rustdoc/extern-impl.rs b/tests/rustdoc/extern-impl.rs index fd1bc214008..4fc31393988 100644 --- a/tests/rustdoc/extern-impl.rs +++ b/tests/rustdoc/extern-impl.rs @@ -1,27 +1,27 @@ #![crate_name = "foo"] -// @has foo/struct.Foo.html +//@ has foo/struct.Foo.html pub struct Foo; impl Foo { - // @has - '//h4[@class="code-header"]' 'fn rust0()' + //@ has - '//h4[@class="code-header"]' 'fn rust0()' pub fn rust0() {} - // @has - '//h4[@class="code-header"]' 'fn rust1()' + //@ has - '//h4[@class="code-header"]' 'fn rust1()' pub extern "Rust" fn rust1() {} - // @has - '//h4[@class="code-header"]' 'extern "C" fn c0()' + //@ has - '//h4[@class="code-header"]' 'extern "C" fn c0()' pub extern fn c0() {} - // @has - '//h4[@class="code-header"]' 'extern "C" fn c1()' + //@ has - '//h4[@class="code-header"]' 'extern "C" fn c1()' pub extern "C" fn c1() {} - // @has - '//h4[@class="code-header"]' 'extern "system" fn system0()' + //@ has - '//h4[@class="code-header"]' 'extern "system" fn system0()' pub extern "system" fn system0() {} } -// @has foo/trait.Bar.html +//@ has foo/trait.Bar.html pub trait Bar {} -// @has - '//h3[@class="code-header"]' 'impl Bar for fn()' +//@ has - '//h3[@class="code-header"]' 'impl Bar for fn()' impl Bar for fn() {} -// @has - '//h3[@class="code-header"]' 'impl Bar for extern "C" fn()' +//@ has - '//h3[@class="code-header"]' 'impl Bar for extern "C" fn()' impl Bar for extern fn() {} -// @has - '//h3[@class="code-header"]' 'impl Bar for extern "system" fn()' +//@ has - '//h3[@class="code-header"]' 'impl Bar for extern "system" fn()' impl Bar for extern "system" fn() {} diff --git a/tests/rustdoc/extern-links.rs b/tests/rustdoc/extern-links.rs index a8c6eb76390..d1fee224755 100644 --- a/tests/rustdoc/extern-links.rs +++ b/tests/rustdoc/extern-links.rs @@ -5,17 +5,17 @@ pub extern crate extern_links; -// @!has foo/index.html '//a' 'extern_links' +//@ !has foo/index.html '//a' 'extern_links' #[doc(no_inline)] pub use extern_links as extern_links2; -// @!has foo/index.html '//a' 'Foo' +//@ !has foo/index.html '//a' 'Foo' #[doc(no_inline)] pub use extern_links::Foo; #[doc(hidden)] pub mod hidden { - // @!has foo/hidden/extern_links/index.html - // @!has foo/hidden/extern_links/struct.Foo.html + //@ !has foo/hidden/extern_links/index.html + //@ !has foo/hidden/extern_links/struct.Foo.html pub use extern_links; } diff --git a/tests/rustdoc/extern-method.rs b/tests/rustdoc/extern-method.rs index 3a86ad4feb0..c3e042f2da8 100644 --- a/tests/rustdoc/extern-method.rs +++ b/tests/rustdoc/extern-method.rs @@ -5,15 +5,15 @@ extern crate rustdoc_extern_method as foo; -// @has extern_method/trait.Foo.html //pre "pub trait Foo" -// @has - '//*[@id="tymethod.foo"]//h4[@class="code-header"]' 'extern "rust-call" fn foo' -// @has - '//*[@id="method.foo_"]//h4[@class="code-header"]' 'extern "rust-call" fn foo_' +//@ has extern_method/trait.Foo.html //pre "pub trait Foo" +//@ has - '//*[@id="tymethod.foo"]//h4[@class="code-header"]' 'extern "rust-call" fn foo' +//@ has - '//*[@id="method.foo_"]//h4[@class="code-header"]' 'extern "rust-call" fn foo_' pub use foo::Foo; -// @has extern_method/trait.Bar.html //pre "pub trait Bar" +//@ has extern_method/trait.Bar.html //pre "pub trait Bar" pub trait Bar { - // @has - '//*[@id="tymethod.bar"]//h4[@class="code-header"]' 'extern "rust-call" fn bar' + //@ has - '//*[@id="tymethod.bar"]//h4[@class="code-header"]' 'extern "rust-call" fn bar' extern "rust-call" fn bar(&self, _: ()); - // @has - '//*[@id="method.bar_"]//h4[@class="code-header"]' 'extern "rust-call" fn bar_' + //@ has - '//*[@id="method.bar_"]//h4[@class="code-header"]' 'extern "rust-call" fn bar_' extern "rust-call" fn bar_(&self, _: ()) { } } diff --git a/tests/rustdoc/external-cross.rs b/tests/rustdoc/external-cross.rs index 527c81839b5..13646ec38cf 100644 --- a/tests/rustdoc/external-cross.rs +++ b/tests/rustdoc/external-cross.rs @@ -5,6 +5,6 @@ extern crate external_cross; -// @has host/struct.NeedMoreDocs.html -// @has - '//h2' 'Cross-crate imported docs' +//@ has host/struct.NeedMoreDocs.html +//@ has - '//h2' 'Cross-crate imported docs' pub use external_cross::NeedMoreDocs; diff --git a/tests/rustdoc/external-doc.rs b/tests/rustdoc/external-doc.rs index bd322d67a37..c81aa17ed5a 100644 --- a/tests/rustdoc/external-doc.rs +++ b/tests/rustdoc/external-doc.rs @@ -1,14 +1,14 @@ -// @has external_doc/struct.IncludeStrDocs.html -// @has - '//h2' 'External Docs' -// @has - '//h3' 'Inline Docs' +//@ has external_doc/struct.IncludeStrDocs.html +//@ has - '//h2' 'External Docs' +//@ has - '//h3' 'Inline Docs' #[doc = include_str!("auxiliary/external-doc.md")] /// ## Inline Docs pub struct IncludeStrDocs; macro_rules! dir { () => { "auxiliary" } } -// @has external_doc/struct.EagerExpansion.html -// @has - '//h2' 'External Docs' +//@ has external_doc/struct.EagerExpansion.html +//@ has - '//h2' 'External Docs' #[doc = include_str!(concat!(dir!(), "/external-doc.md"))] /// ## Inline Docs pub struct EagerExpansion; diff --git a/tests/rustdoc/external-macro-src.rs b/tests/rustdoc/external-macro-src.rs index 1813ecb423f..f723af57fad 100644 --- a/tests/rustdoc/external-macro-src.rs +++ b/tests/rustdoc/external-macro-src.rs @@ -5,8 +5,8 @@ #[macro_use] extern crate external_macro_src; -// @has foo/index.html '//a[@href="../src/foo/external-macro-src.rs.html#3-12"]' 'source' +//@ has foo/index.html '//a[@href="../src/foo/external-macro-src.rs.html#3-12"]' 'source' -// @has foo/struct.Foo.html -// @has - '//a[@href="../src/foo/external-macro-src.rs.html#12"]' 'source' +//@ has foo/struct.Foo.html +//@ has - '//a[@href="../src/foo/external-macro-src.rs.html#12"]' 'source' make_foo!(); diff --git a/tests/rustdoc/feature-gate-doc_auto_cfg.rs b/tests/rustdoc/feature-gate-doc_auto_cfg.rs index da76381e480..75a488bc8ab 100644 --- a/tests/rustdoc/feature-gate-doc_auto_cfg.rs +++ b/tests/rustdoc/feature-gate-doc_auto_cfg.rs @@ -2,7 +2,7 @@ #![crate_name = "foo"] -// @has foo/fn.foo.html -// @count - '//*[@class="item-info"]/*[@class="stab portability"]' 0 +//@ has foo/fn.foo.html +//@ count - '//*[@class="item-info"]/*[@class="stab portability"]' 0 #[cfg(not(test))] pub fn foo() {} diff --git a/tests/rustdoc/ffi.rs b/tests/rustdoc/ffi.rs index c9dbdbf42a5..5ba7cdba910 100644 --- a/tests/rustdoc/ffi.rs +++ b/tests/rustdoc/ffi.rs @@ -3,10 +3,10 @@ extern crate rustdoc_ffi as lib; -// @has ffi/fn.foreigner.html //pre 'pub unsafe extern "C" fn foreigner(cold_as_ice: u32)' +//@ has ffi/fn.foreigner.html //pre 'pub unsafe extern "C" fn foreigner(cold_as_ice: u32)' pub use lib::foreigner; extern "C" { - // @has ffi/fn.another.html //pre 'pub unsafe extern "C" fn another(cold_as_ice: u32)' + //@ has ffi/fn.another.html //pre 'pub unsafe extern "C" fn another(cold_as_ice: u32)' pub fn another(cold_as_ice: u32); } diff --git a/tests/rustdoc/files-creation-hidden.rs b/tests/rustdoc/files-creation-hidden.rs index 498d9cdaef1..8adf84d6640 100644 --- a/tests/rustdoc/files-creation-hidden.rs +++ b/tests/rustdoc/files-creation-hidden.rs @@ -1,24 +1,24 @@ #![crate_name="foo"] -// @files foo '["index.html", "all.html", "sidebar-items.js"]' -// @!has "foo/struct.Foo.html" +//@ files foo '["index.html", "all.html", "sidebar-items.js"]' +//@ !has "foo/struct.Foo.html" #[doc(hidden)] pub struct Foo; -// @!has "foo/struct.Bar.html" +//@ !has "foo/struct.Bar.html" pub use crate::Foo as Bar; -// @!has "foo/struct.Baz.html" +//@ !has "foo/struct.Baz.html" #[doc(hidden)] pub use crate::Foo as Baz; -// @!has "foo/foo/index.html" +//@ !has "foo/foo/index.html" #[doc(hidden)] pub mod foo {} -// @!has "foo/bar/index.html" +//@ !has "foo/bar/index.html" pub use crate::foo as bar; -// @!has "foo/baz/index.html" +//@ !has "foo/baz/index.html" #[doc(hidden)] pub use crate::foo as baz; diff --git a/tests/rustdoc/files-creation-private.rs b/tests/rustdoc/files-creation-private.rs index e2fdbc068f8..54579380f0b 100644 --- a/tests/rustdoc/files-creation-private.rs +++ b/tests/rustdoc/files-creation-private.rs @@ -1,22 +1,22 @@ #![crate_name="foo"] -// @files "foo" \ +//@ files "foo" \ // '["index.html", "all.html", "sidebar-items.js", "foo", "bar", "private", "struct.Bar.html"]' -// @files "foo/bar" '["index.html", "sidebar-items.js"]' +//@ files "foo/bar" '["index.html", "sidebar-items.js"]' -// @!has "foo/priv/index.html" -// @!has "foo/priv/struct.Foo.html" +//@ !has "foo/priv/index.html" +//@ !has "foo/priv/struct.Foo.html" mod private { pub struct Foo; } -// @has "foo/struct.Bar.html" +//@ has "foo/struct.Bar.html" pub use crate::private::Foo as Bar; -// @!has "foo/foo/index.html" +//@ !has "foo/foo/index.html" mod foo { pub mod subfoo {} } -// @has "foo/bar/index.html" +//@ has "foo/bar/index.html" pub use crate::foo::subfoo as bar; diff --git a/tests/rustdoc/fn-bound.rs b/tests/rustdoc/fn-bound.rs index 9e060ff2026..460b6b14e79 100644 --- a/tests/rustdoc/fn-bound.rs +++ b/tests/rustdoc/fn-bound.rs @@ -11,7 +11,7 @@ pub struct ConditionalIterator<F> { } -// @has 'fn_bound/struct.ConditionalIterator.html' '//h3[@class="code-header"]' 'impl<F: Fn(&i32)> Iterator for ConditionalIterator<F>' +//@ has 'fn_bound/struct.ConditionalIterator.html' '//h3[@class="code-header"]' 'impl<F: Fn(&i32)> Iterator for ConditionalIterator<F>' impl<F: Fn(&i32)> Iterator for ConditionalIterator<F> { type Item = (); diff --git a/tests/rustdoc/fn-pointer-arg-name.rs b/tests/rustdoc/fn-pointer-arg-name.rs index 359ca64ee8d..3bde6e9ecfa 100644 --- a/tests/rustdoc/fn-pointer-arg-name.rs +++ b/tests/rustdoc/fn-pointer-arg-name.rs @@ -1,5 +1,5 @@ #![crate_name = "foo"] -// @has foo/fn.f.html -// @has - '//pre[@class="rust item-decl"]' 'pub fn f(callback: fn(len: usize, foo: u32))' +//@ has foo/fn.f.html +//@ has - '//pre[@class="rust item-decl"]' 'pub fn f(callback: fn(len: usize, foo: u32))' pub fn f(callback: fn(len: usize, foo: u32)) {} diff --git a/tests/rustdoc/fn-sidebar.rs b/tests/rustdoc/fn-sidebar.rs index 2fe8ebec1c5..dfe756739a6 100644 --- a/tests/rustdoc/fn-sidebar.rs +++ b/tests/rustdoc/fn-sidebar.rs @@ -1,9 +1,9 @@ #![crate_name = "foo"] -// @has foo/fn.bar.html -// @has - '//*[@class="sidebar-elems"]' '' +//@ has foo/fn.bar.html +//@ has - '//*[@class="sidebar-elems"]' '' pub fn bar() {} -// @has foo/constant.BAR.html -// @has - '//*[@class="sidebar-elems"]' '' +//@ has foo/constant.BAR.html +//@ has - '//*[@class="sidebar-elems"]' '' pub const BAR: u32 = 0; diff --git a/tests/rustdoc/fn-type.rs b/tests/rustdoc/fn-type.rs index 3959aeb6cfb..6d63e5cea4a 100644 --- a/tests/rustdoc/fn-type.rs +++ b/tests/rustdoc/fn-type.rs @@ -8,6 +8,6 @@ pub struct Foo<'a, T> { pub hrtb_lifetime: for<'b, 'c> fn(one: &'b i32, two: &'c &'b i32) -> (&'b i32, &'c i32), } -// @has 'foo/struct.Foo.html' '//span[@id="structfield.generic"]' "generic: fn(val: &T) -> T" -// @has 'foo/struct.Foo.html' '//span[@id="structfield.lifetime"]' "lifetime: fn(val: &'a i32) -> i32" -// @has 'foo/struct.Foo.html' '//span[@id="structfield.hrtb_lifetime"]' "hrtb_lifetime: for<'b, 'c> fn(one: &'b i32, two: &'c &'b i32) -> (&'b i32, &'c i32)" +//@ has 'foo/struct.Foo.html' '//span[@id="structfield.generic"]' "generic: fn(val: &T) -> T" +//@ has 'foo/struct.Foo.html' '//span[@id="structfield.lifetime"]' "lifetime: fn(val: &'a i32) -> i32" +//@ has 'foo/struct.Foo.html' '//span[@id="structfield.hrtb_lifetime"]' "hrtb_lifetime: for<'b, 'c> fn(one: &'b i32, two: &'c &'b i32) -> (&'b i32, &'c i32)" diff --git a/tests/rustdoc/footnote-definition-without-blank-line-100638.rs b/tests/rustdoc/footnote-definition-without-blank-line-100638.rs index b6f62c3bcba..a8aab1ac38e 100644 --- a/tests/rustdoc/footnote-definition-without-blank-line-100638.rs +++ b/tests/rustdoc/footnote-definition-without-blank-line-100638.rs @@ -6,10 +6,10 @@ //! [^2]: Footnote B. //! [^3]: Footnote C. -// @has 'foo/index.html' -// @has - '//*[@class="docblock"]/*[@class="footnotes"]/ol/li[@id="fn1"]/p' 'Footnote A' -// @has - '//li[@id="fn1"]/p/a/@href' '#fnref1' -// @has - '//*[@class="docblock"]/*[@class="footnotes"]/ol/li[@id="fn2"]/p' 'Footnote B' -// @has - '//li[@id="fn2"]/p/a/@href' '#fnref2' -// @has - '//*[@class="docblock"]/*[@class="footnotes"]/ol/li[@id="fn3"]/p' 'Footnote C' -// @has - '//li[@id="fn3"]/p/a/@href' '#fnref3' +//@ has 'foo/index.html' +//@ has - '//*[@class="docblock"]/*[@class="footnotes"]/ol/li[@id="fn1"]/p' 'Footnote A' +//@ has - '//li[@id="fn1"]/p/a/@href' '#fnref1' +//@ has - '//*[@class="docblock"]/*[@class="footnotes"]/ol/li[@id="fn2"]/p' 'Footnote B' +//@ has - '//li[@id="fn2"]/p/a/@href' '#fnref2' +//@ has - '//*[@class="docblock"]/*[@class="footnotes"]/ol/li[@id="fn3"]/p' 'Footnote C' +//@ has - '//li[@id="fn3"]/p/a/@href' '#fnref3' diff --git a/tests/rustdoc/footnote-in-summary.rs b/tests/rustdoc/footnote-in-summary.rs index e6ff5a7fd51..d69282f1041 100644 --- a/tests/rustdoc/footnote-in-summary.rs +++ b/tests/rustdoc/footnote-in-summary.rs @@ -3,13 +3,13 @@ #![crate_name = "foo"] -// @has 'foo/index.html' -// @has - '//*[@class="desc docblock-short"]' 'hello bla' -// @!has - '//*[@class="desc docblock-short"]/sup' '1' +//@ has 'foo/index.html' +//@ has - '//*[@class="desc docblock-short"]' 'hello bla' +//@ !has - '//*[@class="desc docblock-short"]/sup' '1' -// @has 'foo/struct.S.html' -// @has - '//*[@class="docblock"]//sup' '1' -// @has - '//*[@class="docblock"]' 'hello 1 bla' +//@ has 'foo/struct.S.html' +//@ has - '//*[@class="docblock"]//sup' '1' +//@ has - '//*[@class="docblock"]' 'hello 1 bla' /// hello [^foot] bla /// diff --git a/tests/rustdoc/foreign-implementors-js-43701.rs b/tests/rustdoc/foreign-implementors-js-43701.rs index 3b16ad2045a..03147da02c2 100644 --- a/tests/rustdoc/foreign-implementors-js-43701.rs +++ b/tests/rustdoc/foreign-implementors-js-43701.rs @@ -3,4 +3,4 @@ pub use std::vec::Vec; -// @!has trait.impl/core/clone/trait.Clone.js +//@ !has trait.impl/core/clone/trait.Clone.js diff --git a/tests/rustdoc/foreigntype-reexport.rs b/tests/rustdoc/foreigntype-reexport.rs index 1dec0ef3e0f..22c1852adf5 100644 --- a/tests/rustdoc/foreigntype-reexport.rs +++ b/tests/rustdoc/foreigntype-reexport.rs @@ -11,11 +11,11 @@ mod sub { pub mod sub2 { extern "C" { - // @has foreigntype_reexport/sub2/foreigntype.C.html + //@ has foreigntype_reexport/sub2/foreigntype.C.html pub type C; - // @has foreigntype_reexport/sub2/fn.f.html + //@ has foreigntype_reexport/sub2/fn.f.html pub fn f(); - // @has foreigntype_reexport/sub2/static.K3.html + //@ has foreigntype_reexport/sub2/static.K3.html pub static K3: usize; } } @@ -29,28 +29,28 @@ mod sub3 { } } -// @has foreigntype_reexport/foreigntype.C2.html -// @has foreigntype_reexport/fn.f2.html -// @has foreigntype_reexport/static.K2.html -// @has foreigntype_reexport/index.html '//a[@class="foreigntype"]' 'C2' -// @has foreigntype_reexport/index.html '//a[@class="fn"]' 'f2' -// @has foreigntype_reexport/index.html '//a[@class="static"]' 'K2' +//@ has foreigntype_reexport/foreigntype.C2.html +//@ has foreigntype_reexport/fn.f2.html +//@ has foreigntype_reexport/static.K2.html +//@ has foreigntype_reexport/index.html '//a[@class="foreigntype"]' 'C2' +//@ has foreigntype_reexport/index.html '//a[@class="fn"]' 'f2' +//@ has foreigntype_reexport/index.html '//a[@class="static"]' 'K2' pub use self::sub::{f2, C2, K as K2}; -// @has foreigntype_reexport/index.html '//a[@class="foreigntype"]' 'C' -// @has foreigntype_reexport/index.html '//a[@class="fn"]' 'f' -// @has foreigntype_reexport/index.html '//a[@class="static"]' 'K3' -// @has foreigntype_reexport/index.html '//code' 'pub use self::sub2::C as C3;' -// @has foreigntype_reexport/index.html '//code' 'pub use self::sub2::f as f3;' -// @has foreigntype_reexport/index.html '//code' 'pub use self::sub2::K3;' +//@ has foreigntype_reexport/index.html '//a[@class="foreigntype"]' 'C' +//@ has foreigntype_reexport/index.html '//a[@class="fn"]' 'f' +//@ has foreigntype_reexport/index.html '//a[@class="static"]' 'K3' +//@ has foreigntype_reexport/index.html '//code' 'pub use self::sub2::C as C3;' +//@ has foreigntype_reexport/index.html '//code' 'pub use self::sub2::f as f3;' +//@ has foreigntype_reexport/index.html '//code' 'pub use self::sub2::K3;' pub use self::sub2::{f as f3, C as C3, K3}; -// @has foreigntype_reexport/foreigntype.C4.html -// @has foreigntype_reexport/fn.f4.html -// @has foreigntype_reexport/static.K4.html -// @!has foreigntype_reexport/foreigntype.X4.html -// @has foreigntype_reexport/index.html '//a[@class="foreigntype"]' 'C4' -// @has foreigntype_reexport/index.html '//a[@class="fn"]' 'f4' -// @has foreigntype_reexport/index.html '//a[@class="static"]' 'K4' -// @!has foreigntype_reexport/index.html '//a[@class="foreigntype"]' 'X4' +//@ has foreigntype_reexport/foreigntype.C4.html +//@ has foreigntype_reexport/fn.f4.html +//@ has foreigntype_reexport/static.K4.html +//@ !has foreigntype_reexport/foreigntype.X4.html +//@ has foreigntype_reexport/index.html '//a[@class="foreigntype"]' 'C4' +//@ has foreigntype_reexport/index.html '//a[@class="fn"]' 'f4' +//@ has foreigntype_reexport/index.html '//a[@class="static"]' 'K4' +//@ !has foreigntype_reexport/index.html '//a[@class="foreigntype"]' 'X4' pub use self::sub3::*; diff --git a/tests/rustdoc/foreigntype.rs b/tests/rustdoc/foreigntype.rs index 29f9c2926e9..bee3d8e6509 100644 --- a/tests/rustdoc/foreigntype.rs +++ b/tests/rustdoc/foreigntype.rs @@ -1,18 +1,18 @@ #![feature(extern_types)] extern "C" { - // @has foreigntype/foreigntype.ExtType.html + //@ has foreigntype/foreigntype.ExtType.html pub type ExtType; } impl ExtType { - // @has - '//a[@class="fn"]' 'do_something' + //@ has - '//a[@class="fn"]' 'do_something' pub fn do_something(&self) {} } pub trait Trait {} -// @has foreigntype/trait.Trait.html '//a[@class="foreigntype"]' 'ExtType' +//@ has foreigntype/trait.Trait.html '//a[@class="foreigntype"]' 'ExtType' impl Trait for ExtType {} -// @has foreigntype/index.html '//a[@class="foreigntype"]' 'ExtType' +//@ has foreigntype/index.html '//a[@class="foreigntype"]' 'ExtType' diff --git a/tests/rustdoc/generic-associated-types/gats.rs b/tests/rustdoc/generic-associated-types/gats.rs index 605176e5fea..ecfa1796e72 100644 --- a/tests/rustdoc/generic-associated-types/gats.rs +++ b/tests/rustdoc/generic-associated-types/gats.rs @@ -1,19 +1,19 @@ #![crate_name = "foo"] -// @has foo/trait.LendingIterator.html +//@ has foo/trait.LendingIterator.html pub trait LendingIterator { - // @has - '//*[@id="associatedtype.Item"]//h4[@class="code-header"]' "type Item<'a> where Self: 'a" + //@ has - '//*[@id="associatedtype.Item"]//h4[@class="code-header"]' "type Item<'a> where Self: 'a" type Item<'a> where Self: 'a; - // @has - '//*[@id="tymethod.next"]//h4[@class="code-header"]' \ + //@ has - '//*[@id="tymethod.next"]//h4[@class="code-header"]' \ // "fn next<'a>(&'a self) -> Self::Item<'a>" - // @has - '//*[@id="tymethod.next"]//h4[@class="code-header"]//a[@href="trait.LendingIterator.html#associatedtype.Item"]' \ + //@ has - '//*[@id="tymethod.next"]//h4[@class="code-header"]//a[@href="trait.LendingIterator.html#associatedtype.Item"]' \ // "Item" fn next<'a>(&'a self) -> Self::Item<'a>; } -// @has foo/trait.LendingIterator.html -// @has - '//*[@id="associatedtype.Item-1"]//h4[@class="code-header"]' "type Item<'a> = ()" +//@ has foo/trait.LendingIterator.html +//@ has - '//*[@id="associatedtype.Item-1"]//h4[@class="code-header"]' "type Item<'a> = ()" impl LendingIterator for () { type Item<'a> = (); @@ -22,8 +22,8 @@ impl LendingIterator for () { pub struct Infinite<T>(T); -// @has foo/trait.LendingIterator.html -// @has - '//*[@id="associatedtype.Item-2"]//h4[@class="code-header"]' "type Item<'a> = &'a T where Self: 'a" +//@ has foo/trait.LendingIterator.html +//@ has - '//*[@id="associatedtype.Item-2"]//h4[@class="code-header"]' "type Item<'a> = &'a T where Self: 'a" impl<T> LendingIterator for Infinite<T> { type Item<'a> = &'a T where Self: 'a; diff --git a/tests/rustdoc/generic-associated-types/issue-109488.rs b/tests/rustdoc/generic-associated-types/issue-109488.rs index 99ae8a6c36c..12f8988f520 100644 --- a/tests/rustdoc/generic-associated-types/issue-109488.rs +++ b/tests/rustdoc/generic-associated-types/issue-109488.rs @@ -2,9 +2,9 @@ // the href of the corresponding trait (in this case it is private). // Further, test that we also linkify the GAT arguments. -// @has 'issue_109488/type.A.html' -// @has - '//pre[@class="rust item-decl"]' '<S as Tr>::P<Option<i32>>' -// @has - '//pre[@class="rust item-decl"]//a[@class="enum"]/@href' '{{channel}}/core/option/enum.Option.html' +//@ has 'issue_109488/type.A.html' +//@ has - '//pre[@class="rust item-decl"]' '<S as Tr>::P<Option<i32>>' +//@ has - '//pre[@class="rust item-decl"]//a[@class="enum"]/@href' '{{channel}}/core/option/enum.Option.html' pub type A = <S as Tr>::P<Option<i32>>; /*private*/ trait Tr { diff --git a/tests/rustdoc/generic-associated-types/issue-94683.rs b/tests/rustdoc/generic-associated-types/issue-94683.rs index 985c7e983aa..19a1e9d448e 100644 --- a/tests/rustdoc/generic-associated-types/issue-94683.rs +++ b/tests/rustdoc/generic-associated-types/issue-94683.rs @@ -6,7 +6,7 @@ pub trait Trait { // Make sure that the elided lifetime shows up -// @has foo/type.T.html -// @hasraw - "pub type T = " -// @hasraw - "<'_>" +//@ has foo/type.T.html +//@ hasraw - "pub type T = " +//@ hasraw - "<'_>" pub type T = fn(&<() as Trait>::Gat<'_>); diff --git a/tests/rustdoc/generic-const-items.rs b/tests/rustdoc/generic-const-items.rs index e2c6a027afa..31c300f2ff1 100644 --- a/tests/rustdoc/generic-const-items.rs +++ b/tests/rustdoc/generic-const-items.rs @@ -1,8 +1,8 @@ #![feature(generic_const_items)] #![allow(incomplete_features)] -// @has 'generic_const_items/constant.K.html' -// @has - '//*[@class="rust item-decl"]//code' \ +//@ has 'generic_const_items/constant.K.html' +//@ has - '//*[@class="rust item-decl"]//code' \ // "pub const K<'a, T: 'a + Copy, const N: usize>: Option<[T; N]> \ // where \ // String: From<T>;" @@ -10,9 +10,9 @@ pub const K<'a, T: 'a + Copy, const N: usize>: Option<[T; N]> = None where String: From<T>; -// @has generic_const_items/trait.Trait.html +//@ has generic_const_items/trait.Trait.html pub trait Trait<T: ?Sized> { - // @has - '//*[@id="associatedconstant.C"]' \ + //@ has - '//*[@id="associatedconstant.C"]' \ // "const C<'a>: &'a T \ // where \ // T: 'a + Eq" @@ -23,10 +23,10 @@ pub trait Trait<T: ?Sized> { pub struct Implementor; -// @has generic_const_items/struct.Implementor.html -// @has - '//h3[@class="code-header"]' 'impl Trait<str> for Implementor' +//@ has generic_const_items/struct.Implementor.html +//@ has - '//h3[@class="code-header"]' 'impl Trait<str> for Implementor' impl Trait<str> for Implementor { - // @has - '//*[@id="associatedconstant.C"]' \ + //@ has - '//*[@id="associatedconstant.C"]' \ // "const C<'a>: &'a str = \"C\" \ // where \ // str: 'a" diff --git a/tests/rustdoc/generic-impl.rs b/tests/rustdoc/generic-impl.rs index f62540c6bf9..9d15d0fff77 100644 --- a/tests/rustdoc/generic-impl.rs +++ b/tests/rustdoc/generic-impl.rs @@ -2,12 +2,12 @@ use std::fmt; -// @!has foo/struct.Bar.html '//*[@id="impl-ToString-for-Bar"]' '' +//@ !has foo/struct.Bar.html '//*[@id="impl-ToString-for-Bar"]' '' pub struct Bar; -// @has foo/struct.Foo.html '//*[@id="impl-ToString-for-T"]//h3[@class="code-header"]' 'impl<T> ToString for T' +//@ has foo/struct.Foo.html '//*[@id="impl-ToString-for-T"]//h3[@class="code-header"]' 'impl<T> ToString for T' pub struct Foo; -// @has foo/struct.Foo.html '//*[@class="sidebar-elems"]//section//a[@href="#impl-ToString-for-T"]' 'ToString' +//@ has foo/struct.Foo.html '//*[@class="sidebar-elems"]//section//a[@href="#impl-ToString-for-T"]' 'ToString' impl fmt::Display for Foo { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/tests/rustdoc/generic_const_exprs.rs b/tests/rustdoc/generic_const_exprs.rs index 6ff59163975..44f7bf5b24c 100644 --- a/tests/rustdoc/generic_const_exprs.rs +++ b/tests/rustdoc/generic_const_exprs.rs @@ -5,7 +5,7 @@ #![crate_name = "foo"] -// @has 'foo/trait.Foo.html' +//@ has 'foo/trait.Foo.html' pub trait Foo: Sized { const WIDTH: usize; @@ -16,7 +16,7 @@ pub trait Foo: Sized { impl<T: Sized> Foo for T { const WIDTH: usize = 1; - // @has - '//*[@id="tymethod.arrayify"]/*[@class="code-header"]' \ + //@ has - '//*[@id="tymethod.arrayify"]/*[@class="code-header"]' \ // 'fn arrayify(self) -> [Self; Self::WIDTH]' fn arrayify(self) -> [Self; Self::WIDTH] { [self] diff --git a/tests/rustdoc/glob-reexport-attribute-merge-120487.rs b/tests/rustdoc/glob-reexport-attribute-merge-120487.rs index 98cdec107ae..2fa10f546d5 100644 --- a/tests/rustdoc/glob-reexport-attribute-merge-120487.rs +++ b/tests/rustdoc/glob-reexport-attribute-merge-120487.rs @@ -5,11 +5,11 @@ #![crate_name = "foo"] #![feature(doc_cfg)] -// @has 'foo/index.html' +//@ has 'foo/index.html' // There are two items. -// @count - '//*[@class="item-table"]//div[@class="item-name"]' 2 +//@ count - '//*[@class="item-table"]//div[@class="item-name"]' 2 // Only one of them should have an attribute. -// @count - '//*[@class="item-table"]//div[@class="item-name"]/*[@class="stab portability"]' 1 +//@ count - '//*[@class="item-table"]//div[@class="item-name"]/*[@class="stab portability"]' 1 mod a { #[doc(cfg(not(feature = "a")))] @@ -23,10 +23,10 @@ mod b { pub struct Test2; } -// @has 'foo/struct.Test1.html' -// @count - '//*[@id="main-content"]/*[@class="item-info"]' 1 -// @has - '//*[@id="main-content"]/*[@class="item-info"]' 'Available on non-crate feature a only.' +//@ has 'foo/struct.Test1.html' +//@ count - '//*[@id="main-content"]/*[@class="item-info"]' 1 +//@ has - '//*[@id="main-content"]/*[@class="item-info"]' 'Available on non-crate feature a only.' pub use a::*; -// @has 'foo/struct.Test2.html' -// @count - '//*[@id="main-content"]/*[@class="item-info"]' 0 +//@ has 'foo/struct.Test2.html' +//@ count - '//*[@id="main-content"]/*[@class="item-info"]' 0 pub use b::Test2; diff --git a/tests/rustdoc/glob-reexport-attribute-merge-doc-auto-cfg.rs b/tests/rustdoc/glob-reexport-attribute-merge-doc-auto-cfg.rs index 3e3e602eb1b..314b457c2ad 100644 --- a/tests/rustdoc/glob-reexport-attribute-merge-doc-auto-cfg.rs +++ b/tests/rustdoc/glob-reexport-attribute-merge-doc-auto-cfg.rs @@ -4,11 +4,11 @@ #![crate_name = "foo"] #![feature(doc_auto_cfg)] -// @has 'foo/index.html' +//@ has 'foo/index.html' // There are two items. -// @count - '//*[@class="item-table"]//div[@class="item-name"]' 2 +//@ count - '//*[@class="item-table"]//div[@class="item-name"]' 2 // Only one of them should have an attribute. -// @count - '//*[@class="item-table"]//div[@class="item-name"]/*[@class="stab portability"]' 1 +//@ count - '//*[@class="item-table"]//div[@class="item-name"]/*[@class="stab portability"]' 1 mod a { #[cfg(not(feature = "a"))] @@ -20,10 +20,10 @@ mod b { pub struct Test2; } -// @has 'foo/struct.Test1.html' -// @count - '//*[@id="main-content"]/*[@class="item-info"]' 1 -// @has - '//*[@id="main-content"]/*[@class="item-info"]' 'Available on non-crate feature a only.' +//@ has 'foo/struct.Test1.html' +//@ count - '//*[@id="main-content"]/*[@class="item-info"]' 1 +//@ has - '//*[@id="main-content"]/*[@class="item-info"]' 'Available on non-crate feature a only.' pub use a::*; -// @has 'foo/struct.Test2.html' -// @count - '//*[@id="main-content"]/*[@class="item-info"]' 0 +//@ has 'foo/struct.Test2.html' +//@ count - '//*[@id="main-content"]/*[@class="item-info"]' 0 pub use b::Test2; diff --git a/tests/rustdoc/glob-shadowing-const.rs b/tests/rustdoc/glob-shadowing-const.rs index 58fe8173e03..1eb5596cd9c 100644 --- a/tests/rustdoc/glob-shadowing-const.rs +++ b/tests/rustdoc/glob-shadowing-const.rs @@ -14,7 +14,7 @@ mod sub4 { #[doc(inline)] pub use sub4::inner::*; -// @has 'foo/index.html' -// @has - '//div[@class="desc docblock-short"]' '1' -// @!has - '//div[@class="desc docblock-short"]' '0' +//@ has 'foo/index.html' +//@ has - '//div[@class="desc docblock-short"]' '1' +//@ !has - '//div[@class="desc docblock-short"]' '0' fn main() { assert_eq!(X, 1); } diff --git a/tests/rustdoc/glob-shadowing.rs b/tests/rustdoc/glob-shadowing.rs index c117b9d6489..a051bd407d5 100644 --- a/tests/rustdoc/glob-shadowing.rs +++ b/tests/rustdoc/glob-shadowing.rs @@ -1,20 +1,20 @@ -// @has 'glob_shadowing/index.html' -// @count - '//div[@class="item-name"]' 6 -// @!has - '//div[@class="desc docblock-short"]' 'sub1::describe' -// @has - '//div[@class="desc docblock-short"]' 'sub2::describe' +//@ has 'glob_shadowing/index.html' +//@ count - '//div[@class="item-name"]' 6 +//@ !has - '//div[@class="desc docblock-short"]' 'sub1::describe' +//@ has - '//div[@class="desc docblock-short"]' 'sub2::describe' -// @!has - '//div[@class="desc docblock-short"]' 'sub1::describe2' +//@ !has - '//div[@class="desc docblock-short"]' 'sub1::describe2' -// @!has - '//div[@class="desc docblock-short"]' 'sub1::prelude' -// @has - '//div[@class="desc docblock-short"]' 'mod::prelude' +//@ !has - '//div[@class="desc docblock-short"]' 'sub1::prelude' +//@ has - '//div[@class="desc docblock-short"]' 'mod::prelude' -// @has - '//div[@class="desc docblock-short"]' 'sub1::Foo (struct)' -// @has - '//div[@class="desc docblock-short"]' 'mod::Foo (function)' +//@ has - '//div[@class="desc docblock-short"]' 'sub1::Foo (struct)' +//@ has - '//div[@class="desc docblock-short"]' 'mod::Foo (function)' -// @has - '//div[@class="desc docblock-short"]' 'sub4::inner::X' +//@ has - '//div[@class="desc docblock-short"]' 'sub4::inner::X' -// @has 'glob_shadowing/fn.describe.html' -// @has - '//div[@class="docblock"]' 'sub2::describe' +//@ has 'glob_shadowing/fn.describe.html' +//@ has - '//div[@class="docblock"]' 'sub2::describe' mod sub1 { // this should be shadowed by sub2::describe diff --git a/tests/rustdoc/heading-levels-89309.rs b/tests/rustdoc/heading-levels-89309.rs index caa99428525..772217c1594 100644 --- a/tests/rustdoc/heading-levels-89309.rs +++ b/tests/rustdoc/heading-levels-89309.rs @@ -1,20 +1,20 @@ // https://github.com/rust-lang/rust/issues/89309 #![crate_name = "foo"] -// @has foo/trait.Read.html -// @has - '//h2' 'Trait examples' +//@ has foo/trait.Read.html +//@ has - '//h2' 'Trait examples' /// # Trait examples pub trait Read { - // @has - '//h5' 'Function examples' + //@ has - '//h5' 'Function examples' /// # Function examples fn read(&mut self, buf: &mut [u8]) -> Result<usize, ()>; } pub struct Foo; -// @has foo/struct.Foo.html +//@ has foo/struct.Foo.html impl Foo { - // @has - '//h5' 'Implementation header' + //@ has - '//h5' 'Implementation header' /// # Implementation header pub fn bar(&self) -> usize { 1 @@ -22,7 +22,7 @@ impl Foo { } impl Read for Foo { - // @has - '//h5' 'Trait implementation header' + //@ has - '//h5' 'Trait implementation header' /// # Trait implementation header fn read(&mut self, buf: &mut [u8]) -> Result<usize, ()> { Ok(1) diff --git a/tests/rustdoc/hidden-extern-34025.rs b/tests/rustdoc/hidden-extern-34025.rs index 81ccf2a0e5c..2a7b21a874d 100644 --- a/tests/rustdoc/hidden-extern-34025.rs +++ b/tests/rustdoc/hidden-extern-34025.rs @@ -1,12 +1,12 @@ // https://github.com/rust-lang/rust/issues/34025 #![crate_name = "foo"] -// @!has 'foo/sys/index.html' -// @!has 'foo/sys/sidebar-items.js' +//@ !has 'foo/sys/index.html' +//@ !has 'foo/sys/sidebar-items.js' #[doc(hidden)] pub mod sys { extern "C" { - // @!has 'foo/sys/fn.foo.html' + //@ !has 'foo/sys/fn.foo.html' #[doc(hidden)] pub fn foo(); } diff --git a/tests/rustdoc/hidden-impls.rs b/tests/rustdoc/hidden-impls.rs index 3283fbfecce..73deeed9e90 100644 --- a/tests/rustdoc/hidden-impls.rs +++ b/tests/rustdoc/hidden-impls.rs @@ -10,8 +10,8 @@ pub mod __hidden { pub use hidden::Foo; } -// @has foo/trait.Clone.html -// @!hasraw - 'Foo' -// @has trait.impl/core/clone/trait.Clone.js -// @!hasraw - 'Foo' +//@ has foo/trait.Clone.html +//@ !hasraw - 'Foo' +//@ has trait.impl/core/clone/trait.Clone.js +//@ !hasraw - 'Foo' pub use std::clone::Clone; diff --git a/tests/rustdoc/hidden-line.rs b/tests/rustdoc/hidden-line.rs index 00a05a7c26f..0162b27d8be 100644 --- a/tests/rustdoc/hidden-line.rs +++ b/tests/rustdoc/hidden-line.rs @@ -15,5 +15,5 @@ /// ``` pub fn foo() {} -// @!hasraw hidden_line/fn.foo.html invisible -// @matches - //pre "#\[derive\(PartialEq\)\] // Bar" +//@ !hasraw hidden_line/fn.foo.html invisible +//@ matches - //pre "#\[derive\(PartialEq\)\] // Bar" diff --git a/tests/rustdoc/hidden-methods.rs b/tests/rustdoc/hidden-methods.rs index 543d8f768a6..ed9c1ee1aac 100644 --- a/tests/rustdoc/hidden-methods.rs +++ b/tests/rustdoc/hidden-methods.rs @@ -16,14 +16,14 @@ pub mod hidden { } } -// @has foo/struct.Foo.html -// @!hasraw - 'Methods' -// @!has - '//code' 'impl Foo' -// @!hasraw - 'this_should_be_hidden' +//@ has foo/struct.Foo.html +//@ !hasraw - 'Methods' +//@ !has - '//code' 'impl Foo' +//@ !hasraw - 'this_should_be_hidden' pub use hidden::Foo; -// @has foo/struct.Bar.html -// @!hasraw - 'Methods' -// @!has - '//code' 'impl Bar' -// @!hasraw - 'this_should_be_hidden' +//@ has foo/struct.Bar.html +//@ !hasraw - 'Methods' +//@ !has - '//code' 'impl Bar' +//@ !hasraw - 'this_should_be_hidden' pub use hidden::Bar; diff --git a/tests/rustdoc/hidden-private.rs b/tests/rustdoc/hidden-private.rs index 5e3c7f3a3e4..658e093cc23 100644 --- a/tests/rustdoc/hidden-private.rs +++ b/tests/rustdoc/hidden-private.rs @@ -6,10 +6,10 @@ #![crate_name = "foo"] -// @has 'foo/index.html' -// @count - '//*[@class="item-table"]//a[@class="struct"]' 2 -// @count - '//*[@class="item-table"]//a[@class="trait"]' 1 -// @count - '//*[@class="item-table"]//a[@class="macro"]' 0 +//@ has 'foo/index.html' +//@ count - '//*[@class="item-table"]//a[@class="struct"]' 2 +//@ count - '//*[@class="item-table"]//a[@class="trait"]' 1 +//@ count - '//*[@class="item-table"]//a[@class="macro"]' 0 #[doc(hidden)] const _: () = { macro_rules! stry { @@ -18,8 +18,8 @@ const _: () = { struct ShouldBeHidden; - // @has 'foo/struct.Foo.html' - // @!has - '//*[@class="code-header"]' 'impl Bar for Foo' + //@ has 'foo/struct.Foo.html' + //@ !has - '//*[@class="code-header"]' 'impl Bar for Foo' #[doc(hidden)] impl Bar for Foo { fn bar(&self) { @@ -27,15 +27,15 @@ const _: () = { } } - // @has 'foo/struct.Private.html' - // @has - '//*[@id="impl-Bar-for-Private"]/*[@class="code-header"]' 'impl Bar for Private' - // @has - '//*[@id="method.bar"]/*[@class="code-header"]' 'fn bar(&self)' + //@ has 'foo/struct.Private.html' + //@ has - '//*[@id="impl-Bar-for-Private"]/*[@class="code-header"]' 'impl Bar for Private' + //@ has - '//*[@id="method.bar"]/*[@class="code-header"]' 'fn bar(&self)' impl Bar for Private { fn bar(&self) {} } - // @has - '//*[@id="impl-Private"]/*[@class="code-header"]' 'impl Private' - // @has - '//*[@id="method.tralala"]/*[@class="code-header"]' 'fn tralala()' + //@ has - '//*[@id="impl-Private"]/*[@class="code-header"]' 'impl Private' + //@ has - '//*[@id="method.tralala"]/*[@class="code-header"]' 'fn tralala()' impl Private { fn tralala() {} } diff --git a/tests/rustdoc/hidden-trait-methods-with-document-hidden-items.rs b/tests/rustdoc/hidden-trait-methods-with-document-hidden-items.rs index d2269e3b021..a290992e5fe 100644 --- a/tests/rustdoc/hidden-trait-methods-with-document-hidden-items.rs +++ b/tests/rustdoc/hidden-trait-methods-with-document-hidden-items.rs @@ -3,11 +3,11 @@ // test for trait methods with `doc(hidden)` with `--document-hidden-items` passed. #![crate_name = "foo"] -// @has foo/trait.Trait.html -// @has - '//*[@id="associatedtype.Foo"]' 'type Foo' -// @has - '//*[@id="associatedtype.Bar"]' 'type Bar' -// @has - '//*[@id="tymethod.f"]' 'fn f()' -// @has - '//*[@id="tymethod.g"]' 'fn g()' +//@ has foo/trait.Trait.html +//@ has - '//*[@id="associatedtype.Foo"]' 'type Foo' +//@ has - '//*[@id="associatedtype.Bar"]' 'type Bar' +//@ has - '//*[@id="tymethod.f"]' 'fn f()' +//@ has - '//*[@id="tymethod.g"]' 'fn g()' pub trait Trait { #[doc(hidden)] type Foo; @@ -17,11 +17,11 @@ pub trait Trait { fn g(); } -// @has foo/struct.S.html -// @has - '//*[@id="associatedtype.Foo"]' 'type Foo' -// @has - '//*[@id="associatedtype.Bar"]' 'type Bar' -// @has - '//*[@id="method.f"]' 'fn f()' -// @has - '//*[@id="method.g"]' 'fn g()' +//@ has foo/struct.S.html +//@ has - '//*[@id="associatedtype.Foo"]' 'type Foo' +//@ has - '//*[@id="associatedtype.Bar"]' 'type Bar' +//@ has - '//*[@id="method.f"]' 'fn f()' +//@ has - '//*[@id="method.g"]' 'fn g()' pub struct S; impl Trait for S { type Foo = (); diff --git a/tests/rustdoc/hidden-trait-methods.rs b/tests/rustdoc/hidden-trait-methods.rs index e924ba7d0ac..2c342ff28b3 100644 --- a/tests/rustdoc/hidden-trait-methods.rs +++ b/tests/rustdoc/hidden-trait-methods.rs @@ -1,11 +1,11 @@ // test for trait methods with `doc(hidden)`. #![crate_name = "foo"] -// @has foo/trait.Trait.html -// @!has - '//*[@id="associatedtype.Foo"]' 'type Foo' -// @has - '//*[@id="associatedtype.Bar"]' 'type Bar' -// @!has - '//*[@id="tymethod.f"]' 'fn f()' -// @has - '//*[@id="tymethod.g"]' 'fn g()' +//@ has foo/trait.Trait.html +//@ !has - '//*[@id="associatedtype.Foo"]' 'type Foo' +//@ has - '//*[@id="associatedtype.Bar"]' 'type Bar' +//@ !has - '//*[@id="tymethod.f"]' 'fn f()' +//@ has - '//*[@id="tymethod.g"]' 'fn g()' pub trait Trait { #[doc(hidden)] type Foo; @@ -15,11 +15,11 @@ pub trait Trait { fn g(); } -// @has foo/struct.S.html -// @!has - '//*[@id="associatedtype.Foo"]' 'type Foo' -// @has - '//*[@id="associatedtype.Bar"]' 'type Bar' -// @!has - '//*[@id="method.f"]' 'fn f()' -// @has - '//*[@id="method.g"]' 'fn g()' +//@ has foo/struct.S.html +//@ !has - '//*[@id="associatedtype.Foo"]' 'type Foo' +//@ has - '//*[@id="associatedtype.Bar"]' 'type Bar' +//@ !has - '//*[@id="method.f"]' 'fn f()' +//@ has - '//*[@id="method.g"]' 'fn g()' pub struct S; impl Trait for S { type Foo = (); diff --git a/tests/rustdoc/hidden-trait-struct-impls.rs b/tests/rustdoc/hidden-trait-struct-impls.rs index cc3f6337719..1010cb45960 100644 --- a/tests/rustdoc/hidden-trait-struct-impls.rs +++ b/tests/rustdoc/hidden-trait-struct-impls.rs @@ -11,12 +11,12 @@ pub struct Bar; struct Hidden; -// @!has foo/struct.Bar.html '//*[@id="impl-Foo-for-Bar"]' 'impl Foo for Bar' +//@ !has foo/struct.Bar.html '//*[@id="impl-Foo-for-Bar"]' 'impl Foo for Bar' impl Foo for Bar {} -// @!has foo/struct.Bar.html '//*[@id="impl-Dark-for-Bar"]' 'impl Dark for Bar' +//@ !has foo/struct.Bar.html '//*[@id="impl-Dark-for-Bar"]' 'impl Dark for Bar' impl Dark for Bar {} -// @has foo/struct.Bar.html '//*[@id="impl-Bam-for-Bar"]' 'impl Bam for Bar' -// @has foo/trait.Bam.html '//*[@id="implementors-list"]' 'impl Bam for Bar' +//@ has foo/struct.Bar.html '//*[@id="impl-Bam-for-Bar"]' 'impl Bam for Bar' +//@ has foo/trait.Bam.html '//*[@id="implementors-list"]' 'impl Bam for Bar' impl Bam for Bar {} -// @!has foo/trait.Bam.html '//*[@id="implementors-list"]' 'impl Bam for Hidden' +//@ !has foo/trait.Bam.html '//*[@id="implementors-list"]' 'impl Bam for Hidden' impl Bam for Hidden {} diff --git a/tests/rustdoc/hide-complex-unevaluated-const-arguments.rs b/tests/rustdoc/hide-complex-unevaluated-const-arguments.rs index d728f772a69..e94c1ea5c61 100644 --- a/tests/rustdoc/hide-complex-unevaluated-const-arguments.rs +++ b/tests/rustdoc/hide-complex-unevaluated-const-arguments.rs @@ -9,7 +9,7 @@ use std::marker::ConstParamTy; -// @has hide_complex_unevaluated_const_arguments/trait.Stage.html +//@ has hide_complex_unevaluated_const_arguments/trait.Stage.html pub trait Stage { // A helper constant that prevents const expressions containing it // from getting fully evaluated since it doesn't have a body and @@ -29,12 +29,12 @@ pub trait Stage { // This assoc. const could leak the private assoc. function `Struct::new`. // Ensure that this does not happen. // - // @has - '//*[@id="associatedconstant.ARRAY1"]' \ + //@ has - '//*[@id="associatedconstant.ARRAY1"]' \ // 'const ARRAY1: [u8; { _ }]' const ARRAY1: [u8; Struct::new(/* ... */).do_something(Self::ABSTRACT * 1_000)] where [(); Struct::new(/* ... */).do_something(Self::ABSTRACT * 1_000)]:; - // @has - '//*[@id="associatedconstant.VERBOSE"]' \ + //@ has - '//*[@id="associatedconstant.VERBOSE"]' \ // 'const VERBOSE: [u16; { _ }]' const VERBOSE: [u16; compute("thing", 9 + 9) * Self::ABSTRACT] where [(); compute("thing", 9 + 9) * Self::ABSTRACT]:; @@ -44,7 +44,7 @@ pub trait Stage { // (e.g. printing sth. akin to `<Self as Helper<{ _ }>>::OUT`) but // right now “safe is safe”. // - // @has - '//*[@id="associatedconstant.PATH"]' \ + //@ has - '//*[@id="associatedconstant.PATH"]' \ // 'const PATH: usize = _' const PATH: usize = <Self as Helper<{ Struct { private: () } }>>::OUT; } @@ -66,7 +66,7 @@ impl<const S: Struct, St: Stage + ?Sized> Helper<S> for St { // If rustdoc gets patched to evaluate const arguments, it is fine to replace // this test as long as one can ensure that private fields are not leaked! // -// @has hide_complex_unevaluated_const_arguments/trait.Sub.html \ +//@ has hide_complex_unevaluated_const_arguments/trait.Sub.html \ // '//pre[@class="rust item-decl"]' \ // 'pub trait Sub: Sup<{ _ }, { _ }> { }' pub trait Sub: Sup<{ 90 * 20 * 4 }, { Struct { private: () } }> {} diff --git a/tests/rustdoc/hide-complex-unevaluated-consts.rs b/tests/rustdoc/hide-complex-unevaluated-consts.rs index ba623246a01..61ae8c801dd 100644 --- a/tests/rustdoc/hide-complex-unevaluated-consts.rs +++ b/tests/rustdoc/hide-complex-unevaluated-consts.rs @@ -7,7 +7,7 @@ // Read the documentation of `rustdoc::clean::utils::print_const_expr` // for further details. -// @has hide_complex_unevaluated_consts/trait.Container.html +//@ has hide_complex_unevaluated_consts/trait.Container.html pub trait Container { // A helper constant that prevents const expressions containing it // from getting fully evaluated since it doesn't have a body and @@ -17,11 +17,11 @@ pub trait Container { // Ensure that the private field does not get leaked: // - // @has - '//*[@id="associatedconstant.STRUCT0"]' \ + //@ has - '//*[@id="associatedconstant.STRUCT0"]' \ // 'const STRUCT0: Struct = _' const STRUCT0: Struct = Struct { private: () }; - // @has - '//*[@id="associatedconstant.STRUCT1"]' \ + //@ has - '//*[@id="associatedconstant.STRUCT1"]' \ // 'const STRUCT1: (Struct,) = _' const STRUCT1: (Struct,) = (Struct{private: /**/()},); @@ -30,20 +30,20 @@ pub trait Container { // show it. However for the time being, the printing logic is a bit // conservative. // - // @has - '//*[@id="associatedconstant.STRUCT2"]' \ + //@ has - '//*[@id="associatedconstant.STRUCT2"]' \ // 'const STRUCT2: Record = _' const STRUCT2: Record = Record { public: 5 }; // Test that we do not show the incredibly verbose match expr: // - // @has - '//*[@id="associatedconstant.MATCH0"]' \ + //@ has - '//*[@id="associatedconstant.MATCH0"]' \ // 'const MATCH0: i32 = _' const MATCH0: i32 = match 234 { 0 => 1, _ => Self::ABSTRACT, }; - // @has - '//*[@id="associatedconstant.MATCH1"]' \ + //@ has - '//*[@id="associatedconstant.MATCH1"]' \ // 'const MATCH1: bool = _' const MATCH1: bool = match Self::ABSTRACT { _ => true, @@ -61,7 +61,7 @@ pub trait Container { // For now, the implementation is quite simple and the choices // rather conservative. // - // @has - '//*[@id="associatedconstant.ARITH_OPS"]' \ + //@ has - '//*[@id="associatedconstant.ARITH_OPS"]' \ // 'const ARITH_OPS: i32 = _' const ARITH_OPS: i32 = Self::ABSTRACT * 2 + 1; } diff --git a/tests/rustdoc/hide-mut-methods-if-no-derefmut-impl-74083.rs b/tests/rustdoc/hide-mut-methods-if-no-derefmut-impl-74083.rs index 0bed7e2fb62..995121a8455 100644 --- a/tests/rustdoc/hide-mut-methods-if-no-derefmut-impl-74083.rs +++ b/tests/rustdoc/hide-mut-methods-if-no-derefmut-impl-74083.rs @@ -9,8 +9,8 @@ impl Foo { pub fn foo(&mut self) {} } -// @has foo/struct.Bar.html -// @!has - '//div[@class="sidebar-links"]/a[@href="#method.foo"]' 'foo' +//@ has foo/struct.Bar.html +//@ !has - '//div[@class="sidebar-links"]/a[@href="#method.foo"]' 'foo' pub struct Bar { foo: Foo, } diff --git a/tests/rustdoc/hide-unstable-trait.rs b/tests/rustdoc/hide-unstable-trait.rs index ebf9efb368b..33c514c77a7 100644 --- a/tests/rustdoc/hide-unstable-trait.rs +++ b/tests/rustdoc/hide-unstable-trait.rs @@ -5,7 +5,7 @@ extern crate unstable_trait; -// @hasraw foo/struct.Foo.html 'bar' -// @hasraw foo/struct.Foo.html 'bar2' +//@ hasraw foo/struct.Foo.html 'bar' +//@ hasraw foo/struct.Foo.html 'bar2' #[doc(inline)] pub use unstable_trait::Foo; diff --git a/tests/rustdoc/higher-ranked-trait-bounds.rs b/tests/rustdoc/higher-ranked-trait-bounds.rs index 3493ae6d2bb..cda2ddc9166 100644 --- a/tests/rustdoc/higher-ranked-trait-bounds.rs +++ b/tests/rustdoc/higher-ranked-trait-bounds.rs @@ -1,44 +1,44 @@ #![crate_name = "foo"] -// @has foo/trait.Trait.html +//@ has foo/trait.Trait.html pub trait Trait<'x> {} -// @has foo/fn.test1.html -// @has - '//pre' "pub fn test1<T>()where for<'a> &'a T: Iterator," +//@ has foo/fn.test1.html +//@ has - '//pre' "pub fn test1<T>()where for<'a> &'a T: Iterator," pub fn test1<T>() where for<'a> &'a T: Iterator, { } -// @has foo/fn.test2.html -// @has - '//pre' "pub fn test2<T>()where for<'a, 'b> &'a T: Trait<'b>," +//@ has foo/fn.test2.html +//@ has - '//pre' "pub fn test2<T>()where for<'a, 'b> &'a T: Trait<'b>," pub fn test2<T>() where for<'a, 'b> &'a T: Trait<'b>, { } -// @has foo/fn.test3.html -// @has - '//pre' "pub fn test3<F>()where F: for<'a, 'b> Fn(&'a u8, &'b u8)," +//@ has foo/fn.test3.html +//@ has - '//pre' "pub fn test3<F>()where F: for<'a, 'b> Fn(&'a u8, &'b u8)," pub fn test3<F>() where F: for<'a, 'b> Fn(&'a u8, &'b u8), { } -// @has foo/struct.Foo.html +//@ has foo/struct.Foo.html pub struct Foo<'a> { _x: &'a u8, pub some_trait: &'a dyn for<'b> Trait<'b>, pub some_func: for<'c> fn(val: &'c i32) -> i32, } -// @has - '//span[@id="structfield.some_func"]' "some_func: for<'c> fn(val: &'c i32) -> i32" -// @has - '//span[@id="structfield.some_trait"]' "some_trait: &'a dyn for<'b> Trait<'b>" +//@ has - '//span[@id="structfield.some_func"]' "some_func: for<'c> fn(val: &'c i32) -> i32" +//@ has - '//span[@id="structfield.some_trait"]' "some_trait: &'a dyn for<'b> Trait<'b>" impl<'a> Foo<'a> { - // @has - '//h4[@class="code-header"]' "pub fn bar<T>()where T: Trait<'a>," + //@ has - '//h4[@class="code-header"]' "pub fn bar<T>()where T: Trait<'a>," pub fn bar<T>() where T: Trait<'a>, @@ -46,15 +46,15 @@ impl<'a> Foo<'a> { } } -// @has foo/trait.B.html +//@ has foo/trait.B.html pub trait B<'x> {} -// @has - '//h3[@class="code-header"]' "impl<'a> B<'a> for dyn for<'b> Trait<'b>" +//@ has - '//h3[@class="code-header"]' "impl<'a> B<'a> for dyn for<'b> Trait<'b>" impl<'a> B<'a> for dyn for<'b> Trait<'b> {} -// @has foo/struct.Bar.html -// @has - '//span[@id="structfield.bar"]' "bar: &'a (dyn for<'b> Trait<'b> + Unpin)" -// @has - '//span[@id="structfield.baz"]' "baz: &'a (dyn Unpin + for<'b> Trait<'b>)" +//@ has foo/struct.Bar.html +//@ has - '//span[@id="structfield.bar"]' "bar: &'a (dyn for<'b> Trait<'b> + Unpin)" +//@ has - '//span[@id="structfield.baz"]' "baz: &'a (dyn Unpin + for<'b> Trait<'b>)" pub struct Bar<'a> { pub bar: &'a (dyn for<'b> Trait<'b> + Unpin), pub baz: &'a (dyn Unpin + for<'b> Trait<'b>), diff --git a/tests/rustdoc/highlight-invalid-rust-12834.rs b/tests/rustdoc/highlight-invalid-rust-12834.rs index f8acc500264..f4a015ded29 100644 --- a/tests/rustdoc/highlight-invalid-rust-12834.rs +++ b/tests/rustdoc/highlight-invalid-rust-12834.rs @@ -5,8 +5,8 @@ #![crate_name="issue_12834"] #![allow(rustdoc::invalid_rust_codeblocks)] -// @has issue_12834/fn.foo.html -// @has - //pre 'a + b ' +//@ has issue_12834/fn.foo.html +//@ has - //pre 'a + b ' /// ``` /// a + b ∈ Self ∀ a, b ∈ Self diff --git a/tests/rustdoc/html-no-source.rs b/tests/rustdoc/html-no-source.rs index b52792837e5..100ab0031f7 100644 --- a/tests/rustdoc/html-no-source.rs +++ b/tests/rustdoc/html-no-source.rs @@ -8,23 +8,23 @@ #![crate_name = "foo"] // Ensures that there is no items in the corresponding "src" folder. -// @files 'src/foo' '[]' +//@ files 'src/foo' '[]' -// @has foo/fn.foo.html -// @has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.0 · ' -// @!has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.0 · source · ' +//@ has foo/fn.foo.html +//@ has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.0 · ' +//@ !has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.0 · source · ' #[stable(feature = "bar", since = "1.0")] pub fn foo() {} -// @has foo/struct.Bar.html -// @has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.0 · ' -// @!has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.0 · source · ' +//@ has foo/struct.Bar.html +//@ has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.0 · ' +//@ !has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.0 · source · ' #[stable(feature = "bar", since = "1.0")] pub struct Bar; impl Bar { - // @has - '//*[@id="method.bar"]/*[@class="since rightside"]' '2.0.0' - // @!has - '//*[@id="method.bar"]/*[@class="rightside"]' '2.0.0 ·' + //@ has - '//*[@id="method.bar"]/*[@class="since rightside"]' '2.0.0' + //@ !has - '//*[@id="method.bar"]/*[@class="rightside"]' '2.0.0 ·' #[stable(feature = "foobar", since = "2.0")] pub fn bar() {} } diff --git a/tests/rustdoc/impl-alias-substituted.rs b/tests/rustdoc/impl-alias-substituted.rs index 82dfffe5f1c..02efcd88df8 100644 --- a/tests/rustdoc/impl-alias-substituted.rs +++ b/tests/rustdoc/impl-alias-substituted.rs @@ -2,7 +2,7 @@ pub struct Matrix<T, const N: usize, const M: usize>([[T; N]; M]); pub type Vector<T, const N: usize> = Matrix<T, N, 1>; -// @has "impl_alias_substituted/struct.Matrix.html" '//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has "impl_alias_substituted/struct.Matrix.html" '//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<T: Copy> Matrix<T, 3, 1>" impl<T: Copy> Vector<T, 3> { pub fn test() {} diff --git a/tests/rustdoc/impl-assoc-type-21092.rs b/tests/rustdoc/impl-assoc-type-21092.rs index 2354fb986e7..c350456195d 100644 --- a/tests/rustdoc/impl-assoc-type-21092.rs +++ b/tests/rustdoc/impl-assoc-type-21092.rs @@ -6,6 +6,6 @@ extern crate issue_21092; -// @has issue_21092/struct.Bar.html -// @has - '//*[@id="associatedtype.Bar"]' 'type Bar = i32' +//@ has issue_21092/struct.Bar.html +//@ has - '//*[@id="associatedtype.Bar"]' 'type Bar = i32' pub use issue_21092::{Foo, Bar}; diff --git a/tests/rustdoc/impl-blanket-53689.rs b/tests/rustdoc/impl-blanket-53689.rs index 63bce550b9b..4b1697349f2 100644 --- a/tests/rustdoc/impl-blanket-53689.rs +++ b/tests/rustdoc/impl-blanket-53689.rs @@ -5,9 +5,9 @@ extern crate issue_53689; -// @has foo/trait.MyTrait.html -// @!hasraw - 'MyStruct' -// @count - '//*[h3="impl<T> MyTrait for T"]' 1 +//@ has foo/trait.MyTrait.html +//@ !hasraw - 'MyStruct' +//@ count - '//*[h3="impl<T> MyTrait for T"]' 1 pub trait MyTrait {} impl<T> MyTrait for T {} diff --git a/tests/rustdoc/impl-box.rs b/tests/rustdoc/impl-box.rs index 592b6c98587..1fb63e21685 100644 --- a/tests/rustdoc/impl-box.rs +++ b/tests/rustdoc/impl-box.rs @@ -4,8 +4,8 @@ pub struct MyType; -// @has 'impl_box/struct.MyType.html' -// @has '-' '//*[@id="impl-Iterator-for-Box%3CMyType%3E"]' 'impl Iterator for Box<MyType>' +//@ has 'impl_box/struct.MyType.html' +//@ has '-' '//*[@id="impl-Iterator-for-Box%3CMyType%3E"]' 'impl Iterator for Box<MyType>' impl Iterator for Box<MyType> { type Item = (); diff --git a/tests/rustdoc/impl-disambiguation.rs b/tests/rustdoc/impl-disambiguation.rs index 9e74ede8ff7..cfd5013964b 100644 --- a/tests/rustdoc/impl-disambiguation.rs +++ b/tests/rustdoc/impl-disambiguation.rs @@ -4,13 +4,13 @@ pub trait Foo {} pub struct Bar<T> { field: T } -// @has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ +//@ has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ // "impl Foo for Bar<u8>" impl Foo for Bar<u8> {} -// @has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ +//@ has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ // "impl Foo for Bar<u16>" impl Foo for Bar<u16> {} -// @has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ +//@ has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ // "impl<'a> Foo for &'a Bar<u8>" impl<'a> Foo for &'a Bar<u8> {} @@ -22,9 +22,9 @@ pub mod mod2 { pub enum Baz {} } -// @has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ +//@ has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ // "impl Foo for foo::mod1::Baz" impl Foo for mod1::Baz {} -// @has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ +//@ has foo/trait.Foo.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ // "impl<'a> Foo for &'a foo::mod2::Baz" impl<'a> Foo for &'a mod2::Baz {} diff --git a/tests/rustdoc/impl-everywhere.rs b/tests/rustdoc/impl-everywhere.rs index 2311c806c18..d1a4e901bad 100644 --- a/tests/rustdoc/impl-everywhere.rs +++ b/tests/rustdoc/impl-everywhere.rs @@ -8,23 +8,23 @@ pub struct Bar; impl Foo for Bar {} impl Foo2 for Bar {} -// @has foo/fn.foo.html '//section[@id="main-content"]//pre' "x: &'x impl Foo" -// @has foo/fn.foo.html '//section[@id="main-content"]//pre' "-> &'x impl Foo" +//@ has foo/fn.foo.html '//section[@id="main-content"]//pre' "x: &'x impl Foo" +//@ has foo/fn.foo.html '//section[@id="main-content"]//pre' "-> &'x impl Foo" pub fn foo<'x>(x: &'x impl Foo) -> &'x impl Foo { x } -// @has foo/fn.foo2.html '//section[@id="main-content"]//pre' "x: &'x impl Foo" -// @has foo/fn.foo2.html '//section[@id="main-content"]//pre' '-> impl Foo2' +//@ has foo/fn.foo2.html '//section[@id="main-content"]//pre' "x: &'x impl Foo" +//@ has foo/fn.foo2.html '//section[@id="main-content"]//pre' '-> impl Foo2' pub fn foo2<'x>(_x: &'x impl Foo) -> impl Foo2 { Bar } -// @has foo/fn.foo_foo.html '//section[@id="main-content"]//pre' '-> impl Foo + Foo2' +//@ has foo/fn.foo_foo.html '//section[@id="main-content"]//pre' '-> impl Foo + Foo2' pub fn foo_foo() -> impl Foo + Foo2 { Bar } -// @has foo/fn.foo_foo_foo.html '//section[@id="main-content"]//pre' "x: &'x (impl Foo + Foo2)" +//@ has foo/fn.foo_foo_foo.html '//section[@id="main-content"]//pre' "x: &'x (impl Foo + Foo2)" pub fn foo_foo_foo<'x>(_x: &'x (impl Foo + Foo2)) { } diff --git a/tests/rustdoc/impl-in-const-block.rs b/tests/rustdoc/impl-in-const-block.rs index b44e7135246..3f757fa9566 100644 --- a/tests/rustdoc/impl-in-const-block.rs +++ b/tests/rustdoc/impl-in-const-block.rs @@ -4,12 +4,12 @@ #![crate_name = "foo"] -// @has 'foo/struct.A.html' -// @has - '//*[@id="method.new"]/*[@class="code-header"]' 'pub fn new() -> A' -// @has - '//*[@id="method.bar"]/*[@class="code-header"]' 'pub fn bar(&self)' -// @has - '//*[@id="method.woo"]/*[@class="code-header"]' 'pub fn woo(&self)' -// @has - '//*[@id="method.yoo"]/*[@class="code-header"]' 'pub fn yoo()' -// @has - '//*[@id="method.yuu"]/*[@class="code-header"]' 'pub fn yuu()' +//@ has 'foo/struct.A.html' +//@ has - '//*[@id="method.new"]/*[@class="code-header"]' 'pub fn new() -> A' +//@ has - '//*[@id="method.bar"]/*[@class="code-header"]' 'pub fn bar(&self)' +//@ has - '//*[@id="method.woo"]/*[@class="code-header"]' 'pub fn woo(&self)' +//@ has - '//*[@id="method.yoo"]/*[@class="code-header"]' 'pub fn yoo()' +//@ has - '//*[@id="method.yuu"]/*[@class="code-header"]' 'pub fn yuu()' pub struct A; const _: () = { diff --git a/tests/rustdoc/impl-on-ty-alias-issue-119015.rs b/tests/rustdoc/impl-on-ty-alias-issue-119015.rs index 68996deae6f..cea0f5565a2 100644 --- a/tests/rustdoc/impl-on-ty-alias-issue-119015.rs +++ b/tests/rustdoc/impl-on-ty-alias-issue-119015.rs @@ -1,9 +1,9 @@ #![crate_name = "foo"] -// @has 'foo/index.html' +//@ has 'foo/index.html' // There should be only `type A`. -// @count - '//*[@class="item-table"]//*[@class="item-name"]' 1 -// @has - '//*[@class="item-name"]/a[@href="type.A.html"]' 'A' +//@ count - '//*[@class="item-table"]//*[@class="item-name"]' 1 +//@ has - '//*[@class="item-name"]/a[@href="type.A.html"]' 'A' mod foo { pub struct S; @@ -13,15 +13,15 @@ use foo::S; pub type A = S; -// @has 'foo/type.A.html' -// @has - '//*[@id="method.default"]/h4' 'fn default() -> Self' +//@ has 'foo/type.A.html' +//@ has - '//*[@id="method.default"]/h4' 'fn default() -> Self' impl Default for A { fn default() -> Self { S } } -// @has - '//*[@id="method.a"]/h4' 'pub fn a(&self)' +//@ has - '//*[@id="method.a"]/h4' 'pub fn a(&self)' impl A { pub fn a(&self) {} } diff --git a/tests/rustdoc/impl-parts-crosscrate.rs b/tests/rustdoc/impl-parts-crosscrate.rs index 2cca3a5c37c..49752ab75d5 100644 --- a/tests/rustdoc/impl-parts-crosscrate.rs +++ b/tests/rustdoc/impl-parts-crosscrate.rs @@ -12,9 +12,9 @@ pub struct Bar<T> { t: T } // full impl string. Instead, just make sure something from each part // is mentioned. -// @hasraw trait.impl/rustdoc_impl_parts_crosscrate/trait.AnAutoTrait.js Bar -// @hasraw - Send -// @hasraw - !AnAutoTrait -// @hasraw - Copy +//@ hasraw trait.impl/rustdoc_impl_parts_crosscrate/trait.AnAutoTrait.js Bar +//@ hasraw - Send +//@ hasraw - !AnAutoTrait +//@ hasraw - Copy impl<T: Send> !rustdoc_impl_parts_crosscrate::AnAutoTrait for Bar<T> where T: Copy {} diff --git a/tests/rustdoc/impl-parts.rs b/tests/rustdoc/impl-parts.rs index f7738060e99..820f51008a4 100644 --- a/tests/rustdoc/impl-parts.rs +++ b/tests/rustdoc/impl-parts.rs @@ -5,8 +5,8 @@ pub auto trait AnAutoTrait {} pub struct Foo<T> { field: T } -// @has impl_parts/struct.Foo.html '//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has impl_parts/struct.Foo.html '//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<T> !AnAutoTrait for Foo<T>where T: Sync + Clone," -// @has impl_parts/trait.AnAutoTrait.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ +//@ has impl_parts/trait.AnAutoTrait.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ // "impl<T> !AnAutoTrait for Foo<T>where T: Sync + Clone," impl<T: Clone> !AnAutoTrait for Foo<T> where T: Sync {} diff --git a/tests/rustdoc/impl-ref-20175.rs b/tests/rustdoc/impl-ref-20175.rs index a92db2d0a66..b1a9286fd41 100644 --- a/tests/rustdoc/impl-ref-20175.rs +++ b/tests/rustdoc/impl-ref-20175.rs @@ -8,7 +8,7 @@ pub trait Foo { pub struct Bar; -// @has issue_20175/struct.Bar.html \ +//@ has issue_20175/struct.Bar.html \ // '//*[@id="method.foo"]' \ // 'fn foo' impl<'a> Foo for &'a Bar {} diff --git a/tests/rustdoc/impl-trait-43869.rs b/tests/rustdoc/impl-trait-43869.rs index 9c4ed841f79..89176f59ca1 100644 --- a/tests/rustdoc/impl-trait-43869.rs +++ b/tests/rustdoc/impl-trait-43869.rs @@ -61,15 +61,15 @@ pub fn test_44731_4() -> Box<Iterator<Item=impl Clone>> { Box::new(g()) } -// @has foo/fn.g.html -// @has foo/fn.h.html -// @has foo/fn.i.html -// @has foo/fn.j.html -// @has foo/fn.k.html -// @has foo/fn.l.html -// @has foo/fn.m.html -// @has foo/fn.n.html -// @has foo/fn.o.html -// @has foo/fn.test_44731_0.html -// @has foo/fn.test_44731_1.html -// @has foo/fn.test_44731_4.html +//@ has foo/fn.g.html +//@ has foo/fn.h.html +//@ has foo/fn.i.html +//@ has foo/fn.j.html +//@ has foo/fn.k.html +//@ has foo/fn.l.html +//@ has foo/fn.m.html +//@ has foo/fn.n.html +//@ has foo/fn.o.html +//@ has foo/fn.test_44731_0.html +//@ has foo/fn.test_44731_1.html +//@ has foo/fn.test_44731_4.html diff --git a/tests/rustdoc/impl-trait-alias.rs b/tests/rustdoc/impl-trait-alias.rs index 4f681c78ee1..f7ecfffbf46 100644 --- a/tests/rustdoc/impl-trait-alias.rs +++ b/tests/rustdoc/impl-trait-alias.rs @@ -3,11 +3,11 @@ trait MyTrait {} impl MyTrait for i32 {} -// @hasraw impl_trait_alias/type.Foo.html 'Foo' +//@ hasraw impl_trait_alias/type.Foo.html 'Foo' /// debug type pub type Foo = impl MyTrait; -// @hasraw impl_trait_alias/fn.foo.html 'foo' +//@ hasraw impl_trait_alias/fn.foo.html 'foo' /// debug function pub fn foo() -> Foo { 1 diff --git a/tests/rustdoc/impl-type-parameter-33592.rs b/tests/rustdoc/impl-type-parameter-33592.rs index 77f53710e5e..ac5df460925 100644 --- a/tests/rustdoc/impl-type-parameter-33592.rs +++ b/tests/rustdoc/impl-type-parameter-33592.rs @@ -7,8 +7,8 @@ pub struct Bar; pub struct Baz; -// @has foo/trait.Foo.html '//h3[@class="code-header"]' 'impl Foo<i32> for Bar' +//@ has foo/trait.Foo.html '//h3[@class="code-header"]' 'impl Foo<i32> for Bar' impl Foo<i32> for Bar {} -// @has foo/trait.Foo.html '//h3[@class="code-header"]' 'impl<T> Foo<T> for Baz' +//@ has foo/trait.Foo.html '//h3[@class="code-header"]' 'impl<T> Foo<T> for Baz' impl<T> Foo<T> for Baz {} diff --git a/tests/rustdoc/implementor-stable-version.rs b/tests/rustdoc/implementor-stable-version.rs index 3674b9f2e48..cd4fa93f803 100644 --- a/tests/rustdoc/implementor-stable-version.rs +++ b/tests/rustdoc/implementor-stable-version.rs @@ -12,10 +12,10 @@ pub trait Baz {} #[stable(feature = "baz", since = "3.3.3")] pub struct Foo; -// @has foo/trait.Bar.html '//div[@id="implementors-list"]//span[@class="since"]' '4.4.4' +//@ has foo/trait.Bar.html '//div[@id="implementors-list"]//span[@class="since"]' '4.4.4' #[stable(feature = "foobar", since = "4.4.4")] impl Bar for Foo {} -// @has foo/trait.Baz.html '//div[@id="implementors-list"]//span[@class="since"]' '3.3.3' +//@ has foo/trait.Baz.html '//div[@id="implementors-list"]//span[@class="since"]' '3.3.3' #[stable(feature = "foobaz", since = "3.3.3")] impl Baz for Foo {} diff --git a/tests/rustdoc/implementors-unstable-75588.rs b/tests/rustdoc/implementors-unstable-75588.rs index befddf6b788..44a785c4ad9 100644 --- a/tests/rustdoc/implementors-unstable-75588.rs +++ b/tests/rustdoc/implementors-unstable-75588.rs @@ -11,8 +11,8 @@ extern crate realcore; extern crate real_gimli; // issue #74672 -// @!has foo/trait.Deref.html '//*[@id="impl-Deref-for-EndianSlice"]//h3[@class="code-header"]' 'impl Deref for EndianSlice' +//@ !has foo/trait.Deref.html '//*[@id="impl-Deref-for-EndianSlice"]//h3[@class="code-header"]' 'impl Deref for EndianSlice' pub use realcore::Deref; -// @has foo/trait.Join.html '//*[@id="impl-Join-for-Foo"]//h3[@class="code-header"]' 'impl Join for Foo' +//@ has foo/trait.Join.html '//*[@id="impl-Join-for-Foo"]//h3[@class="code-header"]' 'impl Join for Foo' pub use realcore::Join; diff --git a/tests/rustdoc/impossible-default.rs b/tests/rustdoc/impossible-default.rs index 24d6e3bdac1..fad64068010 100644 --- a/tests/rustdoc/impossible-default.rs +++ b/tests/rustdoc/impossible-default.rs @@ -11,9 +11,9 @@ pub trait Foo { fn no_needs_sized(&self) {} } -// @!has foo/struct.Bar.html '//*[@id="method.needs_sized"]//h4[@class="code-header"]' \ +//@ !has foo/struct.Bar.html '//*[@id="method.needs_sized"]//h4[@class="code-header"]' \ // "fn needs_sized" -// @has foo/struct.Bar.html '//*[@id="method.no_needs_sized"]//h4[@class="code-header"]' \ +//@ has foo/struct.Bar.html '//*[@id="method.no_needs_sized"]//h4[@class="code-header"]' \ // "fn no_needs_sized" pub struct Bar([u8]); diff --git a/tests/rustdoc/include_str_cut.rs b/tests/rustdoc/include_str_cut.rs index cbc1ba8db75..27336c95a69 100644 --- a/tests/rustdoc/include_str_cut.rs +++ b/tests/rustdoc/include_str_cut.rs @@ -1,7 +1,7 @@ #![crate_name = "foo"] #![no_std] -// @has 'foo/fn.foo.html' -// @has - '//*[@class="docblock"]' 'inc2 x' +//@ has 'foo/fn.foo.html' +//@ has - '//*[@class="docblock"]' 'inc2 x' #[doc = include_str!("short-line.md")] pub fn foo() {} diff --git a/tests/rustdoc/index-page.rs b/tests/rustdoc/index-page.rs index 51354c8b25b..ea8a0ee17e7 100644 --- a/tests/rustdoc/index-page.rs +++ b/tests/rustdoc/index-page.rs @@ -4,8 +4,8 @@ #![crate_name = "foo"] -// @has foo/../index.html -// @has - '//h1' 'List of all crates' -// @has - '//ul[@class="all-items"]//a[@href="foo/index.html"]' 'foo' -// @has - '//ul[@class="all-items"]//a[@href="all_item_types/index.html"]' 'all_item_types' +//@ has foo/../index.html +//@ has - '//h1' 'List of all crates' +//@ has - '//ul[@class="all-items"]//a[@href="foo/index.html"]' 'foo' +//@ has - '//ul[@class="all-items"]//a[@href="all_item_types/index.html"]' 'all_item_types' pub struct Foo; diff --git a/tests/rustdoc/infinite-redirection-16265-1.rs b/tests/rustdoc/infinite-redirection-16265-1.rs index 7d72469bd72..5eefde7b919 100644 --- a/tests/rustdoc/infinite-redirection-16265-1.rs +++ b/tests/rustdoc/infinite-redirection-16265-1.rs @@ -3,7 +3,7 @@ pub struct Foo; -// @hasraw issue_16265_1/traits/index.html 'source' +//@ hasraw issue_16265_1/traits/index.html 'source' pub mod traits { impl PartialEq for super::Foo { fn eq(&self, _: &super::Foo) -> bool { diff --git a/tests/rustdoc/infinite-redirection-16265-2.rs b/tests/rustdoc/infinite-redirection-16265-2.rs index 7a4791c5fd4..9c680e29f83 100644 --- a/tests/rustdoc/infinite-redirection-16265-2.rs +++ b/tests/rustdoc/infinite-redirection-16265-2.rs @@ -1,7 +1,7 @@ // https://github.com/rust-lang/rust/issues/16265 #![crate_name="issue_16265_2"] -// @hasraw issue_16265_2/index.html 'source' +//@ hasraw issue_16265_2/index.html 'source' trait Y {} impl Y for Option<u32> {} diff --git a/tests/rustdoc/infinite-redirection.rs b/tests/rustdoc/infinite-redirection.rs index f037a8e1a83..9ac559fbecf 100644 --- a/tests/rustdoc/infinite-redirection.rs +++ b/tests/rustdoc/infinite-redirection.rs @@ -4,12 +4,12 @@ // file which redirects to itself). // We check it's not a redirection file. -// @has 'foo/builders/struct.ActionRowBuilder.html' -// @has - '//*[@id="synthetic-implementations"]' 'Auto Trait Implementations' +//@ has 'foo/builders/struct.ActionRowBuilder.html' +//@ has - '//*[@id="synthetic-implementations"]' 'Auto Trait Implementations' // And that the link in the module is targeting it. -// @has 'foo/builders/index.html' -// @has - '//a[@href="struct.ActionRowBuilder.html"]' 'ActionRowBuilder' +//@ has 'foo/builders/index.html' +//@ has - '//a[@href="struct.ActionRowBuilder.html"]' 'ActionRowBuilder' mod auto { mod action_row { diff --git a/tests/rustdoc/inherent-projections.rs b/tests/rustdoc/inherent-projections.rs index 25f51282617..4fc769f70f5 100644 --- a/tests/rustdoc/inherent-projections.rs +++ b/tests/rustdoc/inherent-projections.rs @@ -1,9 +1,9 @@ #![feature(inherent_associated_types)] #![allow(incomplete_features)] -// @has 'inherent_projections/fn.create.html' -// @has - '//pre[@class="rust item-decl"]' "create() -> Owner::Metadata" -// @has - '//pre[@class="rust item-decl"]//a[@class="associatedtype"]/@href' 'struct.Owner.html#associatedtype.Metadata' +//@ has 'inherent_projections/fn.create.html' +//@ has - '//pre[@class="rust item-decl"]' "create() -> Owner::Metadata" +//@ has - '//pre[@class="rust item-decl"]//a[@class="associatedtype"]/@href' 'struct.Owner.html#associatedtype.Metadata' pub fn create() -> Owner::Metadata {} pub struct Owner; @@ -13,7 +13,7 @@ impl Owner { } // Make sure we handle bound vars correctly. -// @has 'inherent_projections/fn.user.html' '//pre[@class="rust item-decl"]' "user(_: for<'a> fn(_: Carrier<'a>::Focus))" +//@ has 'inherent_projections/fn.user.html' '//pre[@class="rust item-decl"]' "user(_: for<'a> fn(_: Carrier<'a>::Focus))" pub fn user(_: for<'a> fn(Carrier<'a>::Focus)) {} pub struct Carrier<'a>(&'a ()); @@ -27,10 +27,10 @@ impl<'a> Carrier<'a> { // FIXME(inherent_associated_types): Below we link to `Proj` but we should link to `Proj-1`. // The current test checks for the buggy behavior for demonstration purposes. -// @has 'inherent_projections/fn.test.html' -// @has - '//pre[@class="rust item-decl"]' "test(_: Parametrized<i32>::Proj)" -// @has - '//pre[@class="rust item-decl"]//a[@class="associatedtype"]/@href' 'struct.Parametrized.html#associatedtype.Proj' -// @!has - '//pre[@class="rust item-decl"]//a[@class="associatedtype"]/@href' 'struct.Parametrized.html#associatedtype.Proj-1' +//@ has 'inherent_projections/fn.test.html' +//@ has - '//pre[@class="rust item-decl"]' "test(_: Parametrized<i32>::Proj)" +//@ has - '//pre[@class="rust item-decl"]//a[@class="associatedtype"]/@href' 'struct.Parametrized.html#associatedtype.Proj' +//@ !has - '//pre[@class="rust item-decl"]//a[@class="associatedtype"]/@href' 'struct.Parametrized.html#associatedtype.Proj-1' pub fn test(_: Parametrized<i32>::Proj) {} pub struct Parametrized<T>(T); diff --git a/tests/rustdoc/inline-assoc-type-20727-bindings.rs b/tests/rustdoc/inline-assoc-type-20727-bindings.rs index d270ccfc375..b3447a759df 100644 --- a/tests/rustdoc/inline-assoc-type-20727-bindings.rs +++ b/tests/rustdoc/inline-assoc-type-20727-bindings.rs @@ -6,20 +6,20 @@ extern crate issue_20727; -// @has issue_20727_2/trait.Add.html +//@ has issue_20727_2/trait.Add.html pub trait Add<RHS = Self> { - // @has - '//pre[@class="rust item-decl"]' 'trait Add<RHS = Self> {' - // @has - '//pre[@class="rust item-decl"]' 'type Output;' + //@ has - '//pre[@class="rust item-decl"]' 'trait Add<RHS = Self> {' + //@ has - '//pre[@class="rust item-decl"]' 'type Output;' type Output; - // @has - '//pre[@class="rust item-decl"]' 'fn add(self, rhs: RHS) -> Self::Output;' + //@ has - '//pre[@class="rust item-decl"]' 'fn add(self, rhs: RHS) -> Self::Output;' fn add(self, rhs: RHS) -> Self::Output; } -// @has issue_20727_2/reexport/trait.Add.html +//@ has issue_20727_2/reexport/trait.Add.html pub mod reexport { - // @has - '//pre[@class="rust item-decl"]' 'trait Add<RHS = Self> {' - // @has - '//pre[@class="rust item-decl"]' 'type Output;' - // @has - '//pre[@class="rust item-decl"]' 'fn add(self, rhs: RHS) -> Self::Output;' + //@ has - '//pre[@class="rust item-decl"]' 'trait Add<RHS = Self> {' + //@ has - '//pre[@class="rust item-decl"]' 'type Output;' + //@ has - '//pre[@class="rust item-decl"]' 'fn add(self, rhs: RHS) -> Self::Output;' pub use issue_20727::Add; } diff --git a/tests/rustdoc/inline-assoc-type-20727-bounds-deref.rs b/tests/rustdoc/inline-assoc-type-20727-bounds-deref.rs index b8449860531..afb9087cc7a 100644 --- a/tests/rustdoc/inline-assoc-type-20727-bounds-deref.rs +++ b/tests/rustdoc/inline-assoc-type-20727-bounds-deref.rs @@ -8,20 +8,20 @@ extern crate issue_20727; pub trait Bar {} -// @has issue_20727_3/trait.Deref2.html +//@ has issue_20727_3/trait.Deref2.html pub trait Deref2 { - // @has - '//pre[@class="rust item-decl"]' 'trait Deref2 {' - // @has - '//pre[@class="rust item-decl"]' 'type Target: Bar;' + //@ has - '//pre[@class="rust item-decl"]' 'trait Deref2 {' + //@ has - '//pre[@class="rust item-decl"]' 'type Target: Bar;' type Target: Bar; - // @has - '//pre[@class="rust item-decl"]' 'fn deref(&self) -> Self::Target;' + //@ has - '//pre[@class="rust item-decl"]' 'fn deref(&self) -> Self::Target;' fn deref(&self) -> Self::Target; } -// @has issue_20727_3/reexport/trait.Deref2.html +//@ has issue_20727_3/reexport/trait.Deref2.html pub mod reexport { - // @has - '//pre[@class="rust item-decl"]' 'trait Deref2 {' - // @has - '//pre[@class="rust item-decl"]' 'type Target: Bar;' - // @has - '//pre[@class="rust item-decl"]' 'fn deref(&self) -> Self::Target;' + //@ has - '//pre[@class="rust item-decl"]' 'trait Deref2 {' + //@ has - '//pre[@class="rust item-decl"]' 'type Target: Bar;' + //@ has - '//pre[@class="rust item-decl"]' 'fn deref(&self) -> Self::Target;' pub use issue_20727::Deref2; } diff --git a/tests/rustdoc/inline-assoc-type-20727-bounds-index.rs b/tests/rustdoc/inline-assoc-type-20727-bounds-index.rs index 4905d0dc4c5..9dd234e8202 100644 --- a/tests/rustdoc/inline-assoc-type-20727-bounds-index.rs +++ b/tests/rustdoc/inline-assoc-type-20727-bounds-index.rs @@ -6,38 +6,38 @@ extern crate issue_20727; -// @has issue_20727_4/trait.Index.html +//@ has issue_20727_4/trait.Index.html pub trait Index<Idx: ?Sized> { - // @has - '//pre[@class="rust item-decl"]' 'trait Index<Idx: ?Sized> {' - // @has - '//pre[@class="rust item-decl"]' 'type Output: ?Sized' + //@ has - '//pre[@class="rust item-decl"]' 'trait Index<Idx: ?Sized> {' + //@ has - '//pre[@class="rust item-decl"]' 'type Output: ?Sized' type Output: ?Sized; - // @has - '//pre[@class="rust item-decl"]' \ + //@ has - '//pre[@class="rust item-decl"]' \ // 'fn index(&self, index: Idx) -> &Self::Output' fn index(&self, index: Idx) -> &Self::Output; } -// @has issue_20727_4/trait.IndexMut.html +//@ has issue_20727_4/trait.IndexMut.html pub trait IndexMut<Idx: ?Sized>: Index<Idx> { - // @has - '//pre[@class="rust item-decl"]' \ + //@ has - '//pre[@class="rust item-decl"]' \ // 'trait IndexMut<Idx: ?Sized>: Index<Idx> {' - // @has - '//pre[@class="rust item-decl"]' \ + //@ has - '//pre[@class="rust item-decl"]' \ // 'fn index_mut(&mut self, index: Idx) -> &mut Self::Output;' fn index_mut(&mut self, index: Idx) -> &mut Self::Output; } pub mod reexport { - // @has issue_20727_4/reexport/trait.Index.html - // @has - '//pre[@class="rust item-decl"]' 'trait Index<Idx>where Idx: ?Sized,{' - // @has - '//pre[@class="rust item-decl"]' 'type Output: ?Sized' - // @has - '//pre[@class="rust item-decl"]' \ + //@ has issue_20727_4/reexport/trait.Index.html + //@ has - '//pre[@class="rust item-decl"]' 'trait Index<Idx>where Idx: ?Sized,{' + //@ has - '//pre[@class="rust item-decl"]' 'type Output: ?Sized' + //@ has - '//pre[@class="rust item-decl"]' \ // 'fn index(&self, index: Idx) -> &Self::Output' pub use issue_20727::Index; - // @has issue_20727_4/reexport/trait.IndexMut.html - // @has - '//pre[@class="rust item-decl"]' \ + //@ has issue_20727_4/reexport/trait.IndexMut.html + //@ has - '//pre[@class="rust item-decl"]' \ // 'trait IndexMut<Idx>: Index<Idx>where Idx: ?Sized,{' - // @has - '//pre[@class="rust item-decl"]' \ + //@ has - '//pre[@class="rust item-decl"]' \ // 'fn index_mut(&mut self, index: Idx) -> &mut Self::Output;' pub use issue_20727::IndexMut; } diff --git a/tests/rustdoc/inline-assoc-type-20727-bounds.rs b/tests/rustdoc/inline-assoc-type-20727-bounds.rs index e6e0490cdd8..bd8d46f4a56 100644 --- a/tests/rustdoc/inline-assoc-type-20727-bounds.rs +++ b/tests/rustdoc/inline-assoc-type-20727-bounds.rs @@ -6,22 +6,22 @@ extern crate issue_20727; -// @has issue_20727/trait.Deref.html +//@ has issue_20727/trait.Deref.html pub trait Deref { - // @has - '//pre[@class="rust item-decl"]' 'trait Deref {' - // @has - '//pre[@class="rust item-decl"]' 'type Target: ?Sized;' + //@ has - '//pre[@class="rust item-decl"]' 'trait Deref {' + //@ has - '//pre[@class="rust item-decl"]' 'type Target: ?Sized;' type Target: ?Sized; - // @has - '//pre[@class="rust item-decl"]' \ + //@ has - '//pre[@class="rust item-decl"]' \ // "fn deref<'a>(&'a self) -> &'a Self::Target;" fn deref<'a>(&'a self) -> &'a Self::Target; } -// @has issue_20727/reexport/trait.Deref.html +//@ has issue_20727/reexport/trait.Deref.html pub mod reexport { - // @has - '//pre[@class="rust item-decl"]' 'trait Deref {' - // @has - '//pre[@class="rust item-decl"]' 'type Target: ?Sized;' - // @has - '//pre[@class="rust item-decl"]' \ + //@ has - '//pre[@class="rust item-decl"]' 'trait Deref {' + //@ has - '//pre[@class="rust item-decl"]' 'type Target: ?Sized;' + //@ has - '//pre[@class="rust item-decl"]' \ // "fn deref<'a>(&'a self) -> &'a Self::Target;" pub use issue_20727::Deref; } diff --git a/tests/rustdoc/inline-default-methods.rs b/tests/rustdoc/inline-default-methods.rs index a3779567376..2f4c0548c7e 100644 --- a/tests/rustdoc/inline-default-methods.rs +++ b/tests/rustdoc/inline-default-methods.rs @@ -3,19 +3,19 @@ extern crate inline_default_methods; -// @has inline_default_methods/trait.Foo.html -// @has - '//pre[@class="rust item-decl"]' '// Required method fn bar(&self);' -// @has - '//pre[@class="rust item-decl"]' '// Provided method fn foo(&mut self)' +//@ has inline_default_methods/trait.Foo.html +//@ has - '//pre[@class="rust item-decl"]' '// Required method fn bar(&self);' +//@ has - '//pre[@class="rust item-decl"]' '// Provided method fn foo(&mut self)' pub use inline_default_methods::Foo; -// @has inline_default_methods/trait.Bar.html -// @has - '//pre[@class="rust item-decl"]' '// Required method fn bar(&self);' -// @has - '//pre[@class="rust item-decl"]' '// Provided methods fn foo1(&mut self)' -// @has - '//pre[@class="rust item-decl"]' 'fn foo2(&mut self)' +//@ has inline_default_methods/trait.Bar.html +//@ has - '//pre[@class="rust item-decl"]' '// Required method fn bar(&self);' +//@ has - '//pre[@class="rust item-decl"]' '// Provided methods fn foo1(&mut self)' +//@ has - '//pre[@class="rust item-decl"]' 'fn foo2(&mut self)' pub use inline_default_methods::Bar; -// @has inline_default_methods/trait.Baz.html -// @has - '//pre[@class="rust item-decl"]' '// Required methods fn bar1(&self);' -// @has - '//pre[@class="rust item-decl"]' 'fn bar2(&self);' -// @has - '//pre[@class="rust item-decl"]' '// Provided method fn foo(&mut self)' +//@ has inline_default_methods/trait.Baz.html +//@ has - '//pre[@class="rust item-decl"]' '// Required methods fn bar1(&self);' +//@ has - '//pre[@class="rust item-decl"]' 'fn bar2(&self);' +//@ has - '//pre[@class="rust item-decl"]' '// Provided method fn foo(&mut self)' pub use inline_default_methods::Baz; diff --git a/tests/rustdoc/inline-private-with-intermediate-doc-hidden.rs b/tests/rustdoc/inline-private-with-intermediate-doc-hidden.rs index ae830c03ea3..752f3843eea 100644 --- a/tests/rustdoc/inline-private-with-intermediate-doc-hidden.rs +++ b/tests/rustdoc/inline-private-with-intermediate-doc-hidden.rs @@ -4,12 +4,12 @@ #![crate_name = "foo"] -// @has 'foo/index.html' +//@ has 'foo/index.html' // There should only be one struct displayed. -// @count - '//*[@id="main-content"]/*[@class="section-header"]' 1 -// @has - '//*[@id="main-content"]/*[@class="section-header"]' 'Structs' -// @has - '//*[@id="main-content"]//a[@href="struct.Reexport.html"]' 'Reexport' -// @has - '//*[@id="main-content"]//*[@class="desc docblock-short"]' 'Visible. Original.' +//@ count - '//*[@id="main-content"]/*[@class="section-header"]' 1 +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Structs' +//@ has - '//*[@id="main-content"]//a[@href="struct.Reexport.html"]' 'Reexport' +//@ has - '//*[@id="main-content"]//*[@class="desc docblock-short"]' 'Visible. Original.' mod private { /// Original. diff --git a/tests/rustdoc/inline-rename-34473.rs b/tests/rustdoc/inline-rename-34473.rs index 7bc92cca1af..7a065adb0db 100644 --- a/tests/rustdoc/inline-rename-34473.rs +++ b/tests/rustdoc/inline-rename-34473.rs @@ -6,8 +6,8 @@ mod second { pub struct SomeTypeWithLongName; } -// @has foo/index.html -// @!hasraw - SomeTypeWithLongName -// @has foo/struct.SomeType.html -// @!has foo/struct.SomeTypeWithLongName.html +//@ has foo/index.html +//@ !hasraw - SomeTypeWithLongName +//@ has foo/struct.SomeType.html +//@ !has foo/struct.SomeTypeWithLongName.html pub use second::{SomeTypeWithLongName as SomeType}; diff --git a/tests/rustdoc/inline_cross/add-docs.rs b/tests/rustdoc/inline_cross/add-docs.rs index a7fbe3c6d0e..d4e0c539070 100644 --- a/tests/rustdoc/inline_cross/add-docs.rs +++ b/tests/rustdoc/inline_cross/add-docs.rs @@ -3,7 +3,7 @@ extern crate inner; -// @has add_docs/struct.MyStruct.html -// @hasraw add_docs/struct.MyStruct.html "Doc comment from ‘pub use’, Doc comment from definition" +//@ has add_docs/struct.MyStruct.html +//@ hasraw add_docs/struct.MyStruct.html "Doc comment from ‘pub use’, Doc comment from definition" /// Doc comment from 'pub use', pub use inner::MyStruct; diff --git a/tests/rustdoc/inline_cross/assoc-const-equality.rs b/tests/rustdoc/inline_cross/assoc-const-equality.rs index cdf74389e76..ec5c2f748ef 100644 --- a/tests/rustdoc/inline_cross/assoc-const-equality.rs +++ b/tests/rustdoc/inline_cross/assoc-const-equality.rs @@ -4,6 +4,6 @@ #![crate_name = "user"] -// @has user/fn.accept.html -// @has - '//pre[@class="rust item-decl"]' 'fn accept(_: impl Trait<K = 0>)' +//@ has user/fn.accept.html +//@ has - '//pre[@class="rust item-decl"]' 'fn accept(_: impl Trait<K = 0>)' pub use assoc_const_equality::accept; diff --git a/tests/rustdoc/inline_cross/assoc-items.rs b/tests/rustdoc/inline_cross/assoc-items.rs index 6b126964a78..94bd8950e75 100644 --- a/tests/rustdoc/inline_cross/assoc-items.rs +++ b/tests/rustdoc/inline_cross/assoc-items.rs @@ -6,37 +6,37 @@ extern crate assoc_items; -// @has foo/struct.MyStruct.html -// @!hasraw - 'PrivateConst' -// @has - '//*[@id="associatedconstant.PublicConst"]' 'pub const PublicConst: u8' -// @has - '//*[@class="docblock"]' 'docs for PublicConst' -// @!hasraw - 'private_method' -// @has - '//*[@id="method.public_method"]' 'pub fn public_method()' -// @has - '//*[@class="docblock"]' 'docs for public_method' -// @has - '//*[@id="associatedconstant.ConstNoDefault"]' 'const ConstNoDefault: i16' -// @has - '//*[@class="docblock"]' 'dox for ConstNoDefault' -// @has - '//*[@id="associatedconstant.ConstWithDefault"]' 'const ConstWithDefault: u16' -// @has - '//div[@class="docblock"]' 'docs for ConstWithDefault' -// @has - '//*[@id="associatedtype.TypeNoDefault"]' 'type TypeNoDefault = i32' -// @has - '//*[@class="docblock"]' 'dox for TypeNoDefault' -// @has - '//*[@id="associatedtype.TypeWithDefault"]' 'type TypeWithDefault = u32' -// @has - '//div[@class="docblock"]' 'docs for TypeWithDefault' -// @has - '//*[@id="method.method_no_default"]' 'fn method_no_default()' -// @has - '//*[@class="docblock"]' 'dox for method_no_default' -// @has - '//*[@id="method.method_with_default"]' 'fn method_with_default()' -// @has - '//div[@class="docblock"]' 'docs for method_with_default' +//@ has foo/struct.MyStruct.html +//@ !hasraw - 'PrivateConst' +//@ has - '//*[@id="associatedconstant.PublicConst"]' 'pub const PublicConst: u8' +//@ has - '//*[@class="docblock"]' 'docs for PublicConst' +//@ !hasraw - 'private_method' +//@ has - '//*[@id="method.public_method"]' 'pub fn public_method()' +//@ has - '//*[@class="docblock"]' 'docs for public_method' +//@ has - '//*[@id="associatedconstant.ConstNoDefault"]' 'const ConstNoDefault: i16' +//@ has - '//*[@class="docblock"]' 'dox for ConstNoDefault' +//@ has - '//*[@id="associatedconstant.ConstWithDefault"]' 'const ConstWithDefault: u16' +//@ has - '//div[@class="docblock"]' 'docs for ConstWithDefault' +//@ has - '//*[@id="associatedtype.TypeNoDefault"]' 'type TypeNoDefault = i32' +//@ has - '//*[@class="docblock"]' 'dox for TypeNoDefault' +//@ has - '//*[@id="associatedtype.TypeWithDefault"]' 'type TypeWithDefault = u32' +//@ has - '//div[@class="docblock"]' 'docs for TypeWithDefault' +//@ has - '//*[@id="method.method_no_default"]' 'fn method_no_default()' +//@ has - '//*[@class="docblock"]' 'dox for method_no_default' +//@ has - '//*[@id="method.method_with_default"]' 'fn method_with_default()' +//@ has - '//div[@class="docblock"]' 'docs for method_with_default' pub use assoc_items::MyStruct; -// @has foo/trait.MyTrait.html -// @has - '//*[@id="associatedconstant.ConstNoDefault"]' 'const ConstNoDefault: i16' -// @has - '//*[@class="docblock"]' 'docs for ConstNoDefault' -// @has - '//*[@id="associatedconstant.ConstWithDefault"]' 'const ConstWithDefault: u16' -// @has - '//*[@class="docblock"]' 'docs for ConstWithDefault' -// @has - '//*[@id="associatedtype.TypeNoDefault"]' 'type TypeNoDefault' -// @has - '//*[@class="docblock"]' 'docs for TypeNoDefault' -// @has - '//*[@class="docblock"]' 'docs for TypeWithDefault' -// @has - '//*[@id="tymethod.method_no_default"]' 'fn method_no_default()' -// @has - '//*[@class="docblock"]' 'docs for method_no_default' -// @has - '//*[@id="method.method_with_default"]' 'fn method_with_default()' -// @has - '//*[@class="docblock"]' 'docs for method_with_default' +//@ has foo/trait.MyTrait.html +//@ has - '//*[@id="associatedconstant.ConstNoDefault"]' 'const ConstNoDefault: i16' +//@ has - '//*[@class="docblock"]' 'docs for ConstNoDefault' +//@ has - '//*[@id="associatedconstant.ConstWithDefault"]' 'const ConstWithDefault: u16' +//@ has - '//*[@class="docblock"]' 'docs for ConstWithDefault' +//@ has - '//*[@id="associatedtype.TypeNoDefault"]' 'type TypeNoDefault' +//@ has - '//*[@class="docblock"]' 'docs for TypeNoDefault' +//@ has - '//*[@class="docblock"]' 'docs for TypeWithDefault' +//@ has - '//*[@id="tymethod.method_no_default"]' 'fn method_no_default()' +//@ has - '//*[@class="docblock"]' 'docs for method_no_default' +//@ has - '//*[@id="method.method_with_default"]' 'fn method_with_default()' +//@ has - '//*[@class="docblock"]' 'docs for method_with_default' pub use assoc_items::MyTrait; diff --git a/tests/rustdoc/inline_cross/assoc_item_trait_bounds.rs b/tests/rustdoc/inline_cross/assoc_item_trait_bounds.rs index c030e344997..346f7120b5b 100644 --- a/tests/rustdoc/inline_cross/assoc_item_trait_bounds.rs +++ b/tests/rustdoc/inline_cross/assoc_item_trait_bounds.rs @@ -6,49 +6,49 @@ //@ ignore-cross-compile extern crate assoc_item_trait_bounds as aux; -// @has main/trait.Main.html -// @has - '//*[@id="associatedtype.Out0"]' 'type Out0: Support<Item = ()>' -// @has - '//*[@id="associatedtype.Out1"]' 'type Out1: Support<Item = Self::Item>' -// @has - '//*[@id="associatedtype.Out2"]' 'type Out2<T>: Support<Item = T>' -// @has - '//*[@id="associatedtype.Out3"]' 'type Out3: Support<Produce<()> = bool>' -// @has - '//*[@id="associatedtype.Out4"]' 'type Out4<T>: Support<Produce<T> = T>' -// @has - '//*[@id="associatedtype.Out5"]' "type Out5: Support<Output<'static> = &'static ()>" -// @has - '//*[@id="associatedtype.Out6"]' "type Out6: for<'a> Support<Output<'a> = &'a ()>" -// @has - '//*[@id="associatedtype.Out7"]' "type Out7: Support<Item = String, Produce<i32> = u32> + Unrelated" -// @has - '//*[@id="associatedtype.Out8"]' "type Out8: Unrelated + Protocol<i16, Q1 = u128, Q0 = ()>" -// @has - '//*[@id="associatedtype.Out9"]' "type Out9: FnMut(i32) -> bool + Clone" -// @has - '//*[@id="associatedtype.Out10"]' "type Out10<'q>: Support<Output<'q> = ()>" -// @has - '//*[@id="associatedtype.Out11"]' "type Out11: for<'r, 's> Helper<A<'s> = &'s (), B<'r> = ()>" -// @has - '//*[@id="associatedtype.Out12"]' "type Out12: for<'w> Helper<B<'w> = Cow<'w, str>, A<'w> = bool>" -// @has - '//*[@id="associatedtype.Out13"]' "type Out13: for<'fst, 'snd> Aid<'snd, Result<'fst> = &'fst mut str>" -// @has - '//*[@id="associatedtype.Out14"]' "type Out14<P: Copy + Eq, Q: ?Sized>" +//@ has main/trait.Main.html +//@ has - '//*[@id="associatedtype.Out0"]' 'type Out0: Support<Item = ()>' +//@ has - '//*[@id="associatedtype.Out1"]' 'type Out1: Support<Item = Self::Item>' +//@ has - '//*[@id="associatedtype.Out2"]' 'type Out2<T>: Support<Item = T>' +//@ has - '//*[@id="associatedtype.Out3"]' 'type Out3: Support<Produce<()> = bool>' +//@ has - '//*[@id="associatedtype.Out4"]' 'type Out4<T>: Support<Produce<T> = T>' +//@ has - '//*[@id="associatedtype.Out5"]' "type Out5: Support<Output<'static> = &'static ()>" +//@ has - '//*[@id="associatedtype.Out6"]' "type Out6: for<'a> Support<Output<'a> = &'a ()>" +//@ has - '//*[@id="associatedtype.Out7"]' "type Out7: Support<Item = String, Produce<i32> = u32> + Unrelated" +//@ has - '//*[@id="associatedtype.Out8"]' "type Out8: Unrelated + Protocol<i16, Q1 = u128, Q0 = ()>" +//@ has - '//*[@id="associatedtype.Out9"]' "type Out9: FnMut(i32) -> bool + Clone" +//@ has - '//*[@id="associatedtype.Out10"]' "type Out10<'q>: Support<Output<'q> = ()>" +//@ has - '//*[@id="associatedtype.Out11"]' "type Out11: for<'r, 's> Helper<A<'s> = &'s (), B<'r> = ()>" +//@ has - '//*[@id="associatedtype.Out12"]' "type Out12: for<'w> Helper<B<'w> = Cow<'w, str>, A<'w> = bool>" +//@ has - '//*[@id="associatedtype.Out13"]' "type Out13: for<'fst, 'snd> Aid<'snd, Result<'fst> = &'fst mut str>" +//@ has - '//*[@id="associatedtype.Out14"]' "type Out14<P: Copy + Eq, Q: ?Sized>" // // Snapshots: // Check that we don't render any where-clauses for the following associated types since // all corresponding projection equality predicates should have already been re-sugared // to associated type bindings: // -// @snapshot out0 - '//*[@id="associatedtype.Out0"]/*[@class="code-header"]' -// @snapshot out2 - '//*[@id="associatedtype.Out2"]/*[@class="code-header"]' -// @snapshot out9 - '//*[@id="associatedtype.Out9"]/*[@class="code-header"]' +//@ snapshot out0 - '//*[@id="associatedtype.Out0"]/*[@class="code-header"]' +//@ snapshot out2 - '//*[@id="associatedtype.Out2"]/*[@class="code-header"]' +//@ snapshot out9 - '//*[@id="associatedtype.Out9"]/*[@class="code-header"]' // -// @has - '//*[@id="tymethod.make"]' \ +//@ has - '//*[@id="tymethod.make"]' \ // "fn make<F>(_: F, _: impl FnMut(&str) -> bool)\ // where \ // F: FnOnce(u32) -> String, \ // Self::Out2<()>: Protocol<u8, Q0 = Self::Item, Q1 = ()>" pub use aux::Main; -// @has main/trait.Aid.html -// @has - '//*[@id="associatedtype.Result"]' "type Result<'inter: 'src>" +//@ has main/trait.Aid.html +//@ has - '//*[@id="associatedtype.Result"]' "type Result<'inter: 'src>" pub use aux::Aid; // Below, ensure that we correctly display generic parameters and where-clauses on // associated types inside trait *impls*. More particularly, check that we don't render // any bounds (here `Self::Alias<T>: ...`) as item bounds unlike all the trait test cases above. -// @has main/struct.Implementor.html -// @has - '//*[@id="associatedtype.Alias"]' \ +//@ has main/struct.Implementor.html +//@ has - '//*[@id="associatedtype.Alias"]' \ // "type Alias<T: Eq> = T \ // where \ // String: From<T>, \ diff --git a/tests/rustdoc/inline_cross/async-fn.rs b/tests/rustdoc/inline_cross/async-fn.rs index 20fa409a8dd..fb81c61be60 100644 --- a/tests/rustdoc/inline_cross/async-fn.rs +++ b/tests/rustdoc/inline_cross/async-fn.rs @@ -6,14 +6,14 @@ //@ edition: 2021 #![crate_name = "user"] -// @has user/fn.load.html -// @has - '//pre[@class="rust item-decl"]' "pub async fn load() -> i32" +//@ has user/fn.load.html +//@ has - '//pre[@class="rust item-decl"]' "pub async fn load() -> i32" pub use async_fn::load; -// @has user/trait.Load.html -// @has - '//*[@id="tymethod.run"]' 'async fn run(&self) -> i32' +//@ has user/trait.Load.html +//@ has - '//*[@id="tymethod.run"]' 'async fn run(&self) -> i32' pub use async_fn::Load; -// @has user/struct.Loader.html -// @has - '//*[@id="method.run"]' 'async fn run(&self) -> i32' +//@ has user/struct.Loader.html +//@ has - '//*[@id="method.run"]' 'async fn run(&self) -> i32' pub use async_fn::Loader; diff --git a/tests/rustdoc/inline_cross/attributes.rs b/tests/rustdoc/inline_cross/attributes.rs index ac9e6174dc1..4747f8ad67c 100644 --- a/tests/rustdoc/inline_cross/attributes.rs +++ b/tests/rustdoc/inline_cross/attributes.rs @@ -2,6 +2,6 @@ //@ edition:2021 #![crate_name = "user"] -// @has 'user/struct.NonExhaustive.html' -// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[non_exhaustive]' +//@ has 'user/struct.NonExhaustive.html' +//@ has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[non_exhaustive]' pub use attributes::NonExhaustive; diff --git a/tests/rustdoc/inline_cross/auxiliary/issue-85454.rs b/tests/rustdoc/inline_cross/auxiliary/issue-85454.rs index 5db4fe053af..be1ec49fdcc 100644 --- a/tests/rustdoc/inline_cross/auxiliary/issue-85454.rs +++ b/tests/rustdoc/inline_cross/auxiliary/issue-85454.rs @@ -1,5 +1,5 @@ -// @has issue_85454/trait.FromResidual.html -// @has - '//pre[@class="rust item-decl"]' 'pub trait FromResidual<R = <Self as Try>::Residual> { fn from_residual(residual: R) -> Self; }' +//@ has issue_85454/trait.FromResidual.html +//@ has - '//pre[@class="rust item-decl"]' 'pub trait FromResidual<R = <Self as Try>::Residual> { fn from_residual(residual: R) -> Self; }' pub trait FromResidual<R = <Self as Try>::Residual> { fn from_residual(residual: R) -> Self; } diff --git a/tests/rustdoc/inline_cross/const-effect-param.rs b/tests/rustdoc/inline_cross/const-effect-param.rs index 72c90ab6968..a3dcbb3ff0f 100644 --- a/tests/rustdoc/inline_cross/const-effect-param.rs +++ b/tests/rustdoc/inline_cross/const-effect-param.rs @@ -6,23 +6,23 @@ #![crate_name = "user"] // Don't render the host param on `load` and the host arg `host` passed to `Resource`. -// @has user/fn.load.html -// @has - '//pre[@class="rust item-decl"]' "pub const fn load<R>() -> i32\ +//@ has user/fn.load.html +//@ has - '//pre[@class="rust item-decl"]' "pub const fn load<R>() -> i32\ // where \ // R: Resource" pub use const_effect_param::load; // Don't render the host arg `true` passed to `Resource`. -// @has user/fn.lock.html -// @has - '//pre[@class="rust item-decl"]' "pub const fn lock<R>()\ +//@ has user/fn.lock.html +//@ has - '//pre[@class="rust item-decl"]' "pub const fn lock<R>()\ // where \ // R: Resource" pub use const_effect_param::lock; // Regression test for an issue introduced in PR #116670. // Don't hide the const param `host` since it actually isn't the host effect param. -// @has user/fn.clash.html -// @has - '//pre[@class="rust item-decl"]' \ +//@ has user/fn.clash.html +//@ has - '//pre[@class="rust item-decl"]' \ // "pub const fn clash<T, const host: u64>()\ // where \ // T: Clash<host>" diff --git a/tests/rustdoc/inline_cross/const-eval-46727.rs b/tests/rustdoc/inline_cross/const-eval-46727.rs index 213664a90b9..e68bf6a9d27 100644 --- a/tests/rustdoc/inline_cross/const-eval-46727.rs +++ b/tests/rustdoc/inline_cross/const-eval-46727.rs @@ -5,6 +5,6 @@ extern crate issue_46727; -// @has foo/trait.Foo.html -// @has - '//h3[@class="code-header"]' 'impl<T> Foo for Bar<[T; 3]>' +//@ has foo/trait.Foo.html +//@ has - '//h3[@class="code-header"]' 'impl<T> Foo for Bar<[T; 3]>' pub use issue_46727::{Foo, Bar}; diff --git a/tests/rustdoc/inline_cross/const-fn-27362.rs b/tests/rustdoc/inline_cross/const-fn-27362.rs index 22b2fa30fec..bc2587b7f00 100644 --- a/tests/rustdoc/inline_cross/const-fn-27362.rs +++ b/tests/rustdoc/inline_cross/const-fn-27362.rs @@ -8,6 +8,6 @@ extern crate issue_27362_aux; pub use issue_27362_aux::*; -// @matches issue_27362/fn.foo.html '//pre' "pub const fn foo()" -// @matches issue_27362/fn.bar.html '//pre' "pub const unsafe fn bar()" -// @matches issue_27362/struct.Foo.html '//h4[@class="code-header"]' "const unsafe fn baz()" +//@ matches issue_27362/fn.foo.html '//pre' "pub const fn foo()" +//@ matches issue_27362/fn.bar.html '//pre' "pub const unsafe fn bar()" +//@ matches issue_27362/struct.Foo.html '//h4[@class="code-header"]' "const unsafe fn baz()" diff --git a/tests/rustdoc/inline_cross/cross-glob.rs b/tests/rustdoc/inline_cross/cross-glob.rs index ae36655936c..d22e48a5d76 100644 --- a/tests/rustdoc/inline_cross/cross-glob.rs +++ b/tests/rustdoc/inline_cross/cross-glob.rs @@ -4,13 +4,13 @@ extern crate inner; -// @has cross_glob/struct.SomeStruct.html -// @has cross_glob/fn.some_fn.html -// @!has cross_glob/enum.Shadowed.html -// @!has cross_glob/index.html '//code' 'pub use inner::*;' +//@ has cross_glob/struct.SomeStruct.html +//@ has cross_glob/fn.some_fn.html +//@ !has cross_glob/enum.Shadowed.html +//@ !has cross_glob/index.html '//code' 'pub use inner::*;' #[doc(inline)] pub use inner::*; // This type shadows the glob-imported enum `Shadowed`. -// @has cross_glob/type.Shadowed.html +//@ has cross_glob/type.Shadowed.html pub type Shadowed = u8; diff --git a/tests/rustdoc/inline_cross/deduplicate-inlined-items-23207.rs b/tests/rustdoc/inline_cross/deduplicate-inlined-items-23207.rs index 374b4d28545..60c2e0f06d3 100644 --- a/tests/rustdoc/inline_cross/deduplicate-inlined-items-23207.rs +++ b/tests/rustdoc/inline_cross/deduplicate-inlined-items-23207.rs @@ -7,6 +7,6 @@ extern crate issue_23207_2; -// @has issue_23207/fmt/index.html -// @count - '//*[@class="struct"]' 1 +//@ has issue_23207/fmt/index.html +//@ count - '//*[@class="struct"]' 1 pub use issue_23207_2::fmt; diff --git a/tests/rustdoc/inline_cross/default-generic-args.rs b/tests/rustdoc/inline_cross/default-generic-args.rs index f006915f153..0469221b3d8 100644 --- a/tests/rustdoc/inline_cross/default-generic-args.rs +++ b/tests/rustdoc/inline_cross/default-generic-args.rs @@ -2,113 +2,113 @@ //@ aux-crate:default_generic_args=default-generic-args.rs //@ edition:2021 -// @has user/type.BoxedStr.html -// @has - '//*[@class="rust item-decl"]//code' "Box<str>" +//@ has user/type.BoxedStr.html +//@ has - '//*[@class="rust item-decl"]//code' "Box<str>" pub use default_generic_args::BoxedStr; -// @has user/type.IntMap.html -// @has - '//*[@class="rust item-decl"]//code' "HashMap<i64, u64>" +//@ has user/type.IntMap.html +//@ has - '//*[@class="rust item-decl"]//code' "HashMap<i64, u64>" pub use default_generic_args::IntMap; -// @has user/type.T0.html -// @has - '//*[@class="rust item-decl"]//code' "TyPair<i32>" +//@ has user/type.T0.html +//@ has - '//*[@class="rust item-decl"]//code' "TyPair<i32>" pub use default_generic_args::T0; -// @has user/type.T1.html -// @has - '//*[@class="rust item-decl"]//code' "TyPair<i32, u32>" +//@ has user/type.T1.html +//@ has - '//*[@class="rust item-decl"]//code' "TyPair<i32, u32>" pub use default_generic_args::T1; -// @has user/type.T2.html -// @has - '//*[@class="rust item-decl"]//code' "TyPair<i32, K>" +//@ has user/type.T2.html +//@ has - '//*[@class="rust item-decl"]//code' "TyPair<i32, K>" pub use default_generic_args::T2; -// @has user/type.T3.html -// @has - '//*[@class="rust item-decl"]//code' "TyPair<Q>" +//@ has user/type.T3.html +//@ has - '//*[@class="rust item-decl"]//code' "TyPair<Q>" pub use default_generic_args::T3; -// @has user/type.C0.html -// @has - '//*[@class="rust item-decl"]//code' "CtPair<43>" +//@ has user/type.C0.html +//@ has - '//*[@class="rust item-decl"]//code' "CtPair<43>" pub use default_generic_args::C0; -// @has user/type.C1.html -// @has - '//*[@class="rust item-decl"]//code' "CtPair<0, 1>" +//@ has user/type.C1.html +//@ has - '//*[@class="rust item-decl"]//code' "CtPair<0, 1>" pub use default_generic_args::C1; -// @has user/type.C2.html -// @has - '//*[@class="rust item-decl"]//code' "CtPair<default_generic_args::::C2::{constant#0}, 3>" +//@ has user/type.C2.html +//@ has - '//*[@class="rust item-decl"]//code' "CtPair<default_generic_args::::C2::{constant#0}, 3>" pub use default_generic_args::C2; -// @has user/type.R0.html -// @has - '//*[@class="rust item-decl"]//code' "Re<'q>" +//@ has user/type.R0.html +//@ has - '//*[@class="rust item-decl"]//code' "Re<'q>" pub use default_generic_args::R0; -// @has user/type.R1.html -// @has - '//*[@class="rust item-decl"]//code' "Re<'q>" +//@ has user/type.R1.html +//@ has - '//*[@class="rust item-decl"]//code' "Re<'q>" pub use default_generic_args::R1; -// @has user/type.R2.html +//@ has user/type.R2.html // Check that we consider regions: -// @has - '//*[@class="rust item-decl"]//code' "Re<'q, &'static ()>" +//@ has - '//*[@class="rust item-decl"]//code' "Re<'q, &'static ()>" pub use default_generic_args::R2; -// @has user/type.H0.html +//@ has user/type.H0.html // Check that we handle higher-ranked regions correctly: -// @has - '//*[@class="rust item-decl"]//code' "fn(_: for<'a> fn(_: Re<'a>))" +//@ has - '//*[@class="rust item-decl"]//code' "fn(_: for<'a> fn(_: Re<'a>))" pub use default_generic_args::H0; -// @has user/type.H1.html +//@ has user/type.H1.html // Check that we don't conflate distinct universially quantified regions (#1): -// @has - '//*[@class="rust item-decl"]//code' "for<'b> fn(_: for<'a> fn(_: Re<'a, &'b ()>))" +//@ has - '//*[@class="rust item-decl"]//code' "for<'b> fn(_: for<'a> fn(_: Re<'a, &'b ()>))" pub use default_generic_args::H1; -// @has user/type.H2.html +//@ has user/type.H2.html // Check that we don't conflate distinct universially quantified regions (#2): -// @has - '//*[@class="rust item-decl"]//code' "for<'a> fn(_: for<'b> fn(_: Re<'a, &'b ()>))" +//@ has - '//*[@class="rust item-decl"]//code' "for<'a> fn(_: for<'b> fn(_: Re<'a, &'b ()>))" pub use default_generic_args::H2; -// @has user/type.P0.html -// @has - '//*[@class="rust item-decl"]//code' "Proj<()>" +//@ has user/type.P0.html +//@ has - '//*[@class="rust item-decl"]//code' "Proj<()>" pub use default_generic_args::P0; -// @has user/type.P1.html -// @has - '//*[@class="rust item-decl"]//code' "Proj<(), bool>" +//@ has user/type.P1.html +//@ has - '//*[@class="rust item-decl"]//code' "Proj<(), bool>" pub use default_generic_args::P1; -// @has user/type.P2.html -// @has - '//*[@class="rust item-decl"]//code' "Proj<(), ()>" +//@ has user/type.P2.html +//@ has - '//*[@class="rust item-decl"]//code' "Proj<(), ()>" pub use default_generic_args::P2; -// @has user/type.A0.html -// @has - '//*[@class="rust item-decl"]//code' "Alpha;" +//@ has user/type.A0.html +//@ has - '//*[@class="rust item-decl"]//code' "Alpha;" pub use default_generic_args::A0; -// @has user/type.A1.html +//@ has user/type.A1.html // Demonstrates that we currently don't elide generic arguments that are alpha-equivalent to their // respective generic parameter (after instantiation) for perf reasons (it would require us to // create an inference context). -// @has - '//*[@class="rust item-decl"]//code' "Alpha<for<'arbitrary> fn(_: &'arbitrary ())>" +//@ has - '//*[@class="rust item-decl"]//code' "Alpha<for<'arbitrary> fn(_: &'arbitrary ())>" pub use default_generic_args::A1; -// @has user/type.M0.html +//@ has user/type.M0.html // Test that we don't elide `u64` even if it coincides with `A`'s default precisely because // `()` is not the default of `B`. Mindlessly eliding `u64` would lead to `M<()>` which is a // different type (`M<(), u64>` versus `M<u64, ()>`). -// @has - '//*[@class="rust item-decl"]//code' "Multi<u64, ()>" +//@ has - '//*[@class="rust item-decl"]//code' "Multi<u64, ()>" pub use default_generic_args::M0; -// @has user/type.D0.html -// @has - '//*[@class="rust item-decl"]//code' "dyn for<'a> Trait0<'a>" +//@ has user/type.D0.html +//@ has - '//*[@class="rust item-decl"]//code' "dyn for<'a> Trait0<'a>" pub use default_generic_args::D0; // Regression test for issue #119529. // Check that we correctly elide def ty&const args inside trait object types. -// @has user/type.D1.html -// @has - '//*[@class="rust item-decl"]//code' "dyn Trait1<T>" +//@ has user/type.D1.html +//@ has - '//*[@class="rust item-decl"]//code' "dyn Trait1<T>" pub use default_generic_args::D1; -// @has user/type.D2.html -// @has - '//*[@class="rust item-decl"]//code' "dyn Trait1<(), K>" +//@ has user/type.D2.html +//@ has - '//*[@class="rust item-decl"]//code' "dyn Trait1<(), K>" pub use default_generic_args::D2; -// @has user/type.D3.html -// @has - '//*[@class="rust item-decl"]//code' "dyn Trait1;" +//@ has user/type.D3.html +//@ has - '//*[@class="rust item-decl"]//code' "dyn Trait1;" pub use default_generic_args::D3; diff --git a/tests/rustdoc/inline_cross/default-trait-method.rs b/tests/rustdoc/inline_cross/default-trait-method.rs index 3d943735031..e589fc6cb85 100644 --- a/tests/rustdoc/inline_cross/default-trait-method.rs +++ b/tests/rustdoc/inline_cross/default-trait-method.rs @@ -2,19 +2,19 @@ extern crate foo; -// @has default_trait_method/trait.Item.html -// @has - '//*[@id="tymethod.foo"]' 'fn foo()' -// @!has - '//*[@id="tymethod.foo"]' 'default fn foo()' -// @has - '//*[@id="tymethod.bar"]' 'fn bar()' -// @!has - '//*[@id="tymethod.bar"]' 'default fn bar()' -// @has - '//*[@id="method.baz"]' 'fn baz()' -// @!has - '//*[@id="method.baz"]' 'default fn baz()' +//@ has default_trait_method/trait.Item.html +//@ has - '//*[@id="tymethod.foo"]' 'fn foo()' +//@ !has - '//*[@id="tymethod.foo"]' 'default fn foo()' +//@ has - '//*[@id="tymethod.bar"]' 'fn bar()' +//@ !has - '//*[@id="tymethod.bar"]' 'default fn bar()' +//@ has - '//*[@id="method.baz"]' 'fn baz()' +//@ !has - '//*[@id="method.baz"]' 'default fn baz()' pub use foo::Item; -// @has default_trait_method/struct.Foo.html -// @has - '//*[@id="method.foo"]' 'default fn foo()' -// @has - '//*[@id="method.bar"]' 'fn bar()' -// @!has - '//*[@id="method.bar"]' 'default fn bar()' -// @has - '//*[@id="method.baz"]' 'fn baz()' -// @!has - '//*[@id="method.baz"]' 'default fn baz()' +//@ has default_trait_method/struct.Foo.html +//@ has - '//*[@id="method.foo"]' 'default fn foo()' +//@ has - '//*[@id="method.bar"]' 'fn bar()' +//@ !has - '//*[@id="method.bar"]' 'default fn bar()' +//@ has - '//*[@id="method.baz"]' 'fn baz()' +//@ !has - '//*[@id="method.baz"]' 'default fn baz()' pub use foo::Foo; diff --git a/tests/rustdoc/inline_cross/doc-hidden-extern-trait-impl-29584.rs b/tests/rustdoc/inline_cross/doc-hidden-extern-trait-impl-29584.rs index 4643e8f4750..2459dbdaeed 100644 --- a/tests/rustdoc/inline_cross/doc-hidden-extern-trait-impl-29584.rs +++ b/tests/rustdoc/inline_cross/doc-hidden-extern-trait-impl-29584.rs @@ -6,6 +6,6 @@ extern crate issue_29584; -// @has issue_29584/struct.Foo.html -// @!hasraw - 'impl Bar for' +//@ has issue_29584/struct.Foo.html +//@ !hasraw - 'impl Bar for' pub use issue_29584::Foo; diff --git a/tests/rustdoc/inline_cross/dyn_trait.rs b/tests/rustdoc/inline_cross/dyn_trait.rs index 18404556984..b93dc921212 100644 --- a/tests/rustdoc/inline_cross/dyn_trait.rs +++ b/tests/rustdoc/inline_cross/dyn_trait.rs @@ -6,140 +6,140 @@ //@ aux-crate:dyn_trait=dyn_trait.rs //@ edition:2021 -// @has user/type.Ty0.html -// @has - '//*[@class="rust item-decl"]//code' "dyn for<'any> FnOnce(&'any str) -> bool;" +//@ has user/type.Ty0.html +//@ has - '//*[@class="rust item-decl"]//code' "dyn for<'any> FnOnce(&'any str) -> bool;" pub use dyn_trait::Ty0; -// @has user/type.Ty1.html -// @has - '//*[@class="rust item-decl"]//code' "dyn Display + 'obj;" +//@ has user/type.Ty1.html +//@ has - '//*[@class="rust item-decl"]//code' "dyn Display + 'obj;" pub use dyn_trait::Ty1; -// @has user/type.Ty2.html -// @has - '//*[@class="rust item-decl"]//code' "dyn for<'a, 'r> Container<'r, Item<'a, 'static> = ()>;" +//@ has user/type.Ty2.html +//@ has - '//*[@class="rust item-decl"]//code' "dyn for<'a, 'r> Container<'r, Item<'a, 'static> = ()>;" pub use dyn_trait::Ty2; -// @has user/type.Ty3.html -// @has - '//*[@class="rust item-decl"]//code' "&'s dyn ToString;" +//@ has user/type.Ty3.html +//@ has - '//*[@class="rust item-decl"]//code' "&'s dyn ToString;" pub use dyn_trait::Ty3; // Below we check if we correctly elide trait-object lifetime bounds if they coincide with their // default (known as "object lifetime default" or "default trait object lifetime"). -// @has user/fn.lbwel.html -// @has - '//pre[@class="rust item-decl"]' "lbwel(_: &dyn Fn())" +//@ has user/fn.lbwel.html +//@ has - '//pre[@class="rust item-decl"]' "lbwel(_: &dyn Fn())" pub use dyn_trait::late_bound_wrapped_elided as lbwel; -// @has user/fn.lbwl0.html -// has - '//pre[@class="rust item-decl"]' "lbwl0<'f>(_: &mut (dyn Fn() + 'f))" +//@ has user/fn.lbwl0.html +//@ has - '//pre[@class="rust item-decl"]' "lbwl0<'f>(_: &mut (dyn Fn() + 'f))" pub use dyn_trait::late_bound_wrapped_late0 as lbwl0; -// @has user/fn.lbwd0.html -// has - '//pre[@class="rust item-decl"]' "lbwd0<'f>(_: &'f mut dyn Fn())" +//@ has user/fn.lbwd0.html +//@ has - '//pre[@class="rust item-decl"]' "lbwd0<'f>(_: &'f mut dyn Fn())" pub use dyn_trait::late_bound_wrapped_defaulted0 as lbwd0; -// @has user/type.EarlyBoundWrappedDefaulted0.html -// @has - '//*[@class="rust item-decl"]//code' "Ref<'x, dyn Trait>;" +//@ has user/type.EarlyBoundWrappedDefaulted0.html +//@ has - '//*[@class="rust item-decl"]//code' "Ref<'x, dyn Trait>;" pub use dyn_trait::EarlyBoundWrappedDefaulted0; -// @has user/type.EarlyBoundWrappedDefaulted1.html -// @has - '//*[@class="rust item-decl"]//code' "&'x dyn Trait;" +//@ has user/type.EarlyBoundWrappedDefaulted1.html +//@ has - '//*[@class="rust item-decl"]//code' "&'x dyn Trait;" pub use dyn_trait::EarlyBoundWrappedDefaulted1; -// @has user/type.EarlyBoundWrappedEarly.html -// @has - '//*[@class="rust item-decl"]//code' "Ref<'x, dyn Trait + 'y>" +//@ has user/type.EarlyBoundWrappedEarly.html +//@ has - '//*[@class="rust item-decl"]//code' "Ref<'x, dyn Trait + 'y>" pub use dyn_trait::EarlyBoundWrappedEarly; -// @has user/type.EarlyBoundWrappedStatic.html -// @has - '//*[@class="rust item-decl"]//code' "Ref<'x, dyn Trait + 'static>" +//@ has user/type.EarlyBoundWrappedStatic.html +//@ has - '//*[@class="rust item-decl"]//code' "Ref<'x, dyn Trait + 'static>" pub use dyn_trait::EarlyBoundWrappedStatic; -// @has user/fn.lbwd1.html -// @has - '//pre[@class="rust item-decl"]' "lbwd1<'l>(_: Ref<'l, dyn Trait>)" +//@ has user/fn.lbwd1.html +//@ has - '//pre[@class="rust item-decl"]' "lbwd1<'l>(_: Ref<'l, dyn Trait>)" pub use dyn_trait::late_bound_wrapped_defaulted1 as lbwd1; -// @has user/fn.lbwl1.html -// @has - '//pre[@class="rust item-decl"]' "lbwl1<'l, 'm>(_: Ref<'l, dyn Trait + 'm>)" +//@ has user/fn.lbwl1.html +//@ has - '//pre[@class="rust item-decl"]' "lbwl1<'l, 'm>(_: Ref<'l, dyn Trait + 'm>)" pub use dyn_trait::late_bound_wrapped_late1 as lbwl1; -// @has user/fn.lbwe.html -// @has - '//pre[@class="rust item-decl"]' "lbwe<'e, 'l>(_: Ref<'l, dyn Trait + 'e>)" +//@ has user/fn.lbwe.html +//@ has - '//pre[@class="rust item-decl"]' "lbwe<'e, 'l>(_: Ref<'l, dyn Trait + 'e>)" pub use dyn_trait::late_bound_wrapped_early as lbwe; -// @has user/fn.ebwd.html -// @has - '//pre[@class="rust item-decl"]' "ebwd(_: Ref<'_, dyn Trait>)" +//@ has user/fn.ebwd.html +//@ has - '//pre[@class="rust item-decl"]' "ebwd(_: Ref<'_, dyn Trait>)" pub use dyn_trait::elided_bound_wrapped_defaulted as ebwd; -// @has user/type.StaticBoundWrappedDefaulted0.html -// @has - '//*[@class="rust item-decl"]//code' "Ref<'static, dyn Trait>;" +//@ has user/type.StaticBoundWrappedDefaulted0.html +//@ has - '//*[@class="rust item-decl"]//code' "Ref<'static, dyn Trait>;" pub use dyn_trait::StaticBoundWrappedDefaulted0; -// @has user/type.StaticBoundWrappedDefaulted1.html -// @has - '//*[@class="rust item-decl"]//code' "&'static dyn Trait;" +//@ has user/type.StaticBoundWrappedDefaulted1.html +//@ has - '//*[@class="rust item-decl"]//code' "&'static dyn Trait;" pub use dyn_trait::StaticBoundWrappedDefaulted1; -// @has user/type.AmbiguousBoundWrappedEarly0.html -// @has - '//*[@class="rust item-decl"]//code' "AmbiguousBoundWrapper<'s, 'r, dyn Trait + 's>;" +//@ has user/type.AmbiguousBoundWrappedEarly0.html +//@ has - '//*[@class="rust item-decl"]//code' "AmbiguousBoundWrapper<'s, 'r, dyn Trait + 's>;" pub use dyn_trait::AmbiguousBoundWrappedEarly0; -// @has user/type.AmbiguousBoundWrappedEarly1.html -// @has - '//*[@class="rust item-decl"]//code' "AmbiguousBoundWrapper<'s, 'r, dyn Trait + 'r>;" +//@ has user/type.AmbiguousBoundWrappedEarly1.html +//@ has - '//*[@class="rust item-decl"]//code' "AmbiguousBoundWrapper<'s, 'r, dyn Trait + 'r>;" pub use dyn_trait::AmbiguousBoundWrappedEarly1; -// @has user/type.AmbiguousBoundWrappedStatic.html -// @has - '//*[@class="rust item-decl"]//code' "AmbiguousBoundWrapper<'q, 'q, dyn Trait + 'static>;" +//@ has user/type.AmbiguousBoundWrappedStatic.html +//@ has - '//*[@class="rust item-decl"]//code' "AmbiguousBoundWrapper<'q, 'q, dyn Trait + 'static>;" pub use dyn_trait::AmbiguousBoundWrappedStatic; -// @has user/type.NoBoundsWrappedDefaulted.html -// @has - '//*[@class="rust item-decl"]//code' "Box<dyn Trait>;" +//@ has user/type.NoBoundsWrappedDefaulted.html +//@ has - '//*[@class="rust item-decl"]//code' "Box<dyn Trait>;" pub use dyn_trait::NoBoundsWrappedDefaulted; -// @has user/type.NoBoundsWrappedEarly.html -// @has - '//*[@class="rust item-decl"]//code' "Box<dyn Trait + 'e>;" +//@ has user/type.NoBoundsWrappedEarly.html +//@ has - '//*[@class="rust item-decl"]//code' "Box<dyn Trait + 'e>;" pub use dyn_trait::NoBoundsWrappedEarly; -// @has user/fn.nbwl.html -// @has - '//pre[@class="rust item-decl"]' "nbwl<'l>(_: Box<dyn Trait + 'l>)" +//@ has user/fn.nbwl.html +//@ has - '//pre[@class="rust item-decl"]' "nbwl<'l>(_: Box<dyn Trait + 'l>)" pub use dyn_trait::no_bounds_wrapped_late as nbwl; -// @has user/fn.nbwel.html -// @has - '//pre[@class="rust item-decl"]' "nbwel(_: Box<dyn Trait + '_>)" +//@ has user/fn.nbwel.html +//@ has - '//pre[@class="rust item-decl"]' "nbwel(_: Box<dyn Trait + '_>)" // NB: It might seem counterintuitive to display the explicitly elided lifetime `'_` here instead of // eliding it but this behavior is correct: The default is `'static` here which != `'_`. pub use dyn_trait::no_bounds_wrapped_elided as nbwel; -// @has user/type.BareNoBoundsDefaulted.html -// @has - '//*[@class="rust item-decl"]//code' "dyn Trait;" +//@ has user/type.BareNoBoundsDefaulted.html +//@ has - '//*[@class="rust item-decl"]//code' "dyn Trait;" pub use dyn_trait::BareNoBoundsDefaulted; -// @has user/type.BareNoBoundsEarly.html -// @has - '//*[@class="rust item-decl"]//code' "dyn Trait + 'p;" +//@ has user/type.BareNoBoundsEarly.html +//@ has - '//*[@class="rust item-decl"]//code' "dyn Trait + 'p;" pub use dyn_trait::BareNoBoundsEarly; -// @has user/type.BareEarlyBoundDefaulted0.html -// @has - '//*[@class="rust item-decl"]//code' "dyn EarlyBoundTrait0<'u>;" +//@ has user/type.BareEarlyBoundDefaulted0.html +//@ has - '//*[@class="rust item-decl"]//code' "dyn EarlyBoundTrait0<'u>;" pub use dyn_trait::BareEarlyBoundDefaulted0; -// @has user/type.BareEarlyBoundDefaulted1.html -// @has - '//*[@class="rust item-decl"]//code' "dyn for<'any> EarlyBoundTrait0<'any>;" +//@ has user/type.BareEarlyBoundDefaulted1.html +//@ has - '//*[@class="rust item-decl"]//code' "dyn for<'any> EarlyBoundTrait0<'any>;" pub use dyn_trait::BareEarlyBoundDefaulted1; -// @has user/type.BareEarlyBoundDefaulted2.html -// @has - '//*[@class="rust item-decl"]//code' "dyn EarlyBoundTrait1<'static, 'w>;" +//@ has user/type.BareEarlyBoundDefaulted2.html +//@ has - '//*[@class="rust item-decl"]//code' "dyn EarlyBoundTrait1<'static, 'w>;" pub use dyn_trait::BareEarlyBoundDefaulted2; -// @has user/type.BareEarlyBoundEarly.html -// @has - '//*[@class="rust item-decl"]//code' "dyn EarlyBoundTrait0<'i> + 'j;" +//@ has user/type.BareEarlyBoundEarly.html +//@ has - '//*[@class="rust item-decl"]//code' "dyn EarlyBoundTrait0<'i> + 'j;" pub use dyn_trait::BareEarlyBoundEarly; -// @has user/type.BareEarlyBoundStatic.html -// @has - '//*[@class="rust item-decl"]//code' "dyn EarlyBoundTrait0<'i> + 'static;" +//@ has user/type.BareEarlyBoundStatic.html +//@ has - '//*[@class="rust item-decl"]//code' "dyn EarlyBoundTrait0<'i> + 'static;" pub use dyn_trait::BareEarlyBoundStatic; -// @has user/type.BareStaticBoundDefaulted.html -// @has - '//*[@class="rust item-decl"]//code' "dyn StaticBoundTrait;" +//@ has user/type.BareStaticBoundDefaulted.html +//@ has - '//*[@class="rust item-decl"]//code' "dyn StaticBoundTrait;" pub use dyn_trait::BareStaticBoundDefaulted; -// @has user/type.BareHigherRankedBoundDefaulted0.html -// @has - '//*[@class="rust item-decl"]//code' "dyn HigherRankedBoundTrait0;" +//@ has user/type.BareHigherRankedBoundDefaulted0.html +//@ has - '//*[@class="rust item-decl"]//code' "dyn HigherRankedBoundTrait0;" pub use dyn_trait::BareHigherRankedBoundDefaulted0; -// @has user/type.BareHigherRankedBoundDefaulted1.html -// @has - '//*[@class="rust item-decl"]//code' "dyn HigherRankedBoundTrait1<'r>;" +//@ has user/type.BareHigherRankedBoundDefaulted1.html +//@ has - '//*[@class="rust item-decl"]//code' "dyn HigherRankedBoundTrait1<'r>;" pub use dyn_trait::BareHigherRankedBoundDefaulted1; -// @has user/type.BareAmbiguousBoundEarly0.html -// @has - '//*[@class="rust item-decl"]//code' "dyn AmbiguousBoundTrait<'m, 'n> + 'm;" +//@ has user/type.BareAmbiguousBoundEarly0.html +//@ has - '//*[@class="rust item-decl"]//code' "dyn AmbiguousBoundTrait<'m, 'n> + 'm;" pub use dyn_trait::BareAmbiguousBoundEarly0; -// @has user/type.BareAmbiguousBoundEarly1.html -// @has - '//*[@class="rust item-decl"]//code' "dyn AmbiguousBoundTrait<'m, 'n> + 'n;" +//@ has user/type.BareAmbiguousBoundEarly1.html +//@ has - '//*[@class="rust item-decl"]//code' "dyn AmbiguousBoundTrait<'m, 'n> + 'n;" pub use dyn_trait::BareAmbiguousBoundEarly1; -// @has user/type.BareAmbiguousBoundStatic.html -// @has - '//*[@class="rust item-decl"]//code' "dyn AmbiguousBoundTrait<'o, 'o> + 'static;" +//@ has user/type.BareAmbiguousBoundStatic.html +//@ has - '//*[@class="rust item-decl"]//code' "dyn AmbiguousBoundTrait<'o, 'o> + 'static;" pub use dyn_trait::BareAmbiguousBoundStatic; // Regression test for issue #115179: -// @has user/type.NestedTraitObjects.html -// @has - '//*[@class="rust item-decl"]//code' "dyn Outer<dyn Inner>;" +//@ has user/type.NestedTraitObjects.html +//@ has - '//*[@class="rust item-decl"]//code' "dyn Outer<dyn Inner>;" pub use dyn_trait::NestedTraitObjects; -// @has user/fn.apit_rpit.html -// @has - '//pre[@class="rust item-decl"]' \ +//@ has user/fn.apit_rpit.html +//@ has - '//pre[@class="rust item-decl"]' \ // "apit_rpit(o: impl Outer<dyn Inner>) -> impl Outer<dyn Inner>" pub use dyn_trait::apit_rpit; -// @has user/type.AssocTy.html -// @has - '//*[@class="rust item-decl"]//code' "<() as Base>::Type<dyn Inner>" +//@ has user/type.AssocTy.html +//@ has - '//*[@class="rust item-decl"]//code' "<() as Base>::Type<dyn Inner>" pub use dyn_trait::AssocTy; diff --git a/tests/rustdoc/inline_cross/early-late-bound-lifetime-params.rs b/tests/rustdoc/inline_cross/early-late-bound-lifetime-params.rs index 97dd623bb07..36542a2d6fc 100644 --- a/tests/rustdoc/inline_cross/early-late-bound-lifetime-params.rs +++ b/tests/rustdoc/inline_cross/early-late-bound-lifetime-params.rs @@ -8,10 +8,10 @@ //@ aux-crate:dep=early-late-bound-lifetime-params.rs //@ edition:2021 -// @has usr/fn.f.html -// @has - '//pre[@class="rust item-decl"]' "fn f<'a, 'b, 'c, 'd, T, const N: usize>(_: impl Copy)" +//@ has usr/fn.f.html +//@ has - '//pre[@class="rust item-decl"]' "fn f<'a, 'b, 'c, 'd, T, const N: usize>(_: impl Copy)" pub use dep::f; -// @has usr/struct.Ty.html -// @has - '//*[@id="method.f"]' "fn f<'a, 'b, 'c, 'd, T, const N: usize>(_: impl Copy)" +//@ has usr/struct.Ty.html +//@ has - '//*[@id="method.f"]' "fn f<'a, 'b, 'c, 'd, T, const N: usize>(_: impl Copy)" pub use dep::Ty; diff --git a/tests/rustdoc/inline_cross/fn-type.rs b/tests/rustdoc/inline_cross/fn-type.rs index 222557a4663..8db6f65f421 100644 --- a/tests/rustdoc/inline_cross/fn-type.rs +++ b/tests/rustdoc/inline_cross/fn-type.rs @@ -6,7 +6,7 @@ //@ edition: 2021 #![crate_name = "user"] -// @has user/type.F.html -// @has - '//*[@class="rust item-decl"]//code' \ +//@ has user/type.F.html +//@ has - '//*[@class="rust item-decl"]//code' \ // "for<'z, 'a, '_unused> fn(_: &'z for<'b> fn(_: &'b str), _: &'a ()) -> &'a ();" pub use fn_type::F; diff --git a/tests/rustdoc/inline_cross/generic-const-items.rs b/tests/rustdoc/inline_cross/generic-const-items.rs index 77011a05d2f..70018b6ddb5 100644 --- a/tests/rustdoc/inline_cross/generic-const-items.rs +++ b/tests/rustdoc/inline_cross/generic-const-items.rs @@ -3,23 +3,23 @@ //@ aux-crate:generic_const_items=generic-const-items.rs //@ edition:2021 -// @has 'user/constant.K.html' -// @has - '//*[@class="rust item-decl"]//code' \ +//@ has 'user/constant.K.html' +//@ has - '//*[@class="rust item-decl"]//code' \ // "pub const K<'a, T: 'a + Copy, const N: usize>: Option<[T; N]> \ // where \ // String: From<T>;" pub use generic_const_items::K; -// @has user/trait.Trait.html -// @has - '//*[@id="associatedconstant.C"]' \ +//@ has user/trait.Trait.html +//@ has - '//*[@id="associatedconstant.C"]' \ // "const C<'a>: &'a T \ // where \ // T: 'a + Eq" pub use generic_const_items::Trait; -// @has user/struct.Implementor.html -// @has - '//h3[@class="code-header"]' 'impl Trait<str> for Implementor' -// @has - '//*[@id="associatedconstant.C"]' \ +//@ has user/struct.Implementor.html +//@ has - '//h3[@class="code-header"]' 'impl Trait<str> for Implementor' +//@ has - '//*[@id="associatedconstant.C"]' \ // "const C<'a>: &'a str = \"C\" \ // where \ // str: 'a" diff --git a/tests/rustdoc/inline_cross/hidden-use.rs b/tests/rustdoc/inline_cross/hidden-use.rs index f747c94915c..3f15881345c 100644 --- a/tests/rustdoc/inline_cross/hidden-use.rs +++ b/tests/rustdoc/inline_cross/hidden-use.rs @@ -4,9 +4,9 @@ extern crate rustdoc_hidden; -// @has hidden_use/index.html -// @!hasraw - 'rustdoc_hidden' -// @!hasraw - 'Bar' -// @!has hidden_use/struct.Bar.html +//@ has hidden_use/index.html +//@ !hasraw - 'rustdoc_hidden' +//@ !hasraw - 'Bar' +//@ !has hidden_use/struct.Bar.html #[doc(hidden)] pub use rustdoc_hidden::Bar; diff --git a/tests/rustdoc/inline_cross/impl-inline-without-trait.rs b/tests/rustdoc/inline_cross/impl-inline-without-trait.rs index 60265b5df8f..d2f19400271 100644 --- a/tests/rustdoc/inline_cross/impl-inline-without-trait.rs +++ b/tests/rustdoc/inline_cross/impl-inline-without-trait.rs @@ -6,7 +6,7 @@ extern crate impl_inline_without_trait; -// @has 'foo/struct.MyStruct.html' -// @has - '//*[@id="method.my_trait_method"]' 'fn my_trait_method()' -// @has - '//div[@class="docblock"]' 'docs for my_trait_method' +//@ has 'foo/struct.MyStruct.html' +//@ has - '//*[@id="method.my_trait_method"]' 'fn my_trait_method()' +//@ has - '//div[@class="docblock"]' 'docs for my_trait_method' pub use impl_inline_without_trait::MyStruct; diff --git a/tests/rustdoc/inline_cross/impl-sized.rs b/tests/rustdoc/inline_cross/impl-sized.rs index b62a1e61e2b..edef114422c 100644 --- a/tests/rustdoc/inline_cross/impl-sized.rs +++ b/tests/rustdoc/inline_cross/impl-sized.rs @@ -3,25 +3,25 @@ //@ aux-crate:impl_sized=impl-sized.rs //@ edition:2021 -// @has user/fn.sized.html -// @has - '//pre[@class="rust item-decl"]' "sized(x: impl Sized) -> impl Sized" +//@ has user/fn.sized.html +//@ has - '//pre[@class="rust item-decl"]' "sized(x: impl Sized) -> impl Sized" pub use impl_sized::sized; -// @has user/fn.sized_outlives.html -// @has - '//pre[@class="rust item-decl"]' \ +//@ has user/fn.sized_outlives.html +//@ has - '//pre[@class="rust item-decl"]' \ // "sized_outlives<'a>(x: impl Sized + 'a) -> impl Sized + 'a" pub use impl_sized::sized_outlives; -// @has user/fn.maybe_sized.html -// @has - '//pre[@class="rust item-decl"]' "maybe_sized(x: &impl ?Sized) -> &impl ?Sized" +//@ has user/fn.maybe_sized.html +//@ has - '//pre[@class="rust item-decl"]' "maybe_sized(x: &impl ?Sized) -> &impl ?Sized" pub use impl_sized::maybe_sized; -// @has user/fn.debug_maybe_sized.html -// @has - '//pre[@class="rust item-decl"]' \ +//@ has user/fn.debug_maybe_sized.html +//@ has - '//pre[@class="rust item-decl"]' \ // "debug_maybe_sized(x: &(impl Debug + ?Sized)) -> &(impl Debug + ?Sized)" pub use impl_sized::debug_maybe_sized; -// @has user/fn.maybe_sized_outlives.html -// @has - '//pre[@class="rust item-decl"]' \ +//@ has user/fn.maybe_sized_outlives.html +//@ has - '//pre[@class="rust item-decl"]' \ // "maybe_sized_outlives<'t>(x: &(impl ?Sized + 't)) -> &(impl ?Sized + 't)" pub use impl_sized::maybe_sized_outlives; diff --git a/tests/rustdoc/inline_cross/impl_trait.rs b/tests/rustdoc/inline_cross/impl_trait.rs index 19d1673f2eb..e6baf33660a 100644 --- a/tests/rustdoc/inline_cross/impl_trait.rs +++ b/tests/rustdoc/inline_cross/impl_trait.rs @@ -3,37 +3,37 @@ extern crate impl_trait_aux; -// @has impl_trait/fn.func.html -// @has - '//pre[@class="rust item-decl"]' "pub fn func<'a>(_x: impl Clone + Into<Vec<u8>> + 'a)" -// @!has - '//pre[@class="rust item-decl"]' 'where' +//@ has impl_trait/fn.func.html +//@ has - '//pre[@class="rust item-decl"]' "pub fn func<'a>(_x: impl Clone + Into<Vec<u8>> + 'a)" +//@ !has - '//pre[@class="rust item-decl"]' 'where' pub use impl_trait_aux::func; -// @has impl_trait/fn.func2.html -// @has - '//pre[@class="rust item-decl"]' "func2<T>(" -// @has - '//pre[@class="rust item-decl"]' "_x: impl Deref<Target = Option<T>> + Iterator<Item = T>," -// @has - '//pre[@class="rust item-decl"]' "_y: impl Iterator<Item = u8>, )" -// @!has - '//pre[@class="rust item-decl"]' 'where' +//@ has impl_trait/fn.func2.html +//@ has - '//pre[@class="rust item-decl"]' "func2<T>(" +//@ has - '//pre[@class="rust item-decl"]' "_x: impl Deref<Target = Option<T>> + Iterator<Item = T>," +//@ has - '//pre[@class="rust item-decl"]' "_y: impl Iterator<Item = u8>, )" +//@ !has - '//pre[@class="rust item-decl"]' 'where' pub use impl_trait_aux::func2; -// @has impl_trait/fn.func3.html -// @has - '//pre[@class="rust item-decl"]' "func3(" -// @has - '//pre[@class="rust item-decl"]' "_x: impl Iterator<Item = impl Iterator<Item = u8>> + Clone)" -// @!has - '//pre[@class="rust item-decl"]' 'where' +//@ has impl_trait/fn.func3.html +//@ has - '//pre[@class="rust item-decl"]' "func3(" +//@ has - '//pre[@class="rust item-decl"]' "_x: impl Iterator<Item = impl Iterator<Item = u8>> + Clone)" +//@ !has - '//pre[@class="rust item-decl"]' 'where' pub use impl_trait_aux::func3; -// @has impl_trait/fn.func4.html -// @has - '//pre[@class="rust item-decl"]' "func4<T>(" -// @has - '//pre[@class="rust item-decl"]' "T: Iterator<Item = impl Clone>," +//@ has impl_trait/fn.func4.html +//@ has - '//pre[@class="rust item-decl"]' "func4<T>(" +//@ has - '//pre[@class="rust item-decl"]' "T: Iterator<Item = impl Clone>," pub use impl_trait_aux::func4; -// @has impl_trait/fn.func5.html -// @has - '//pre[@class="rust item-decl"]' "func5(" -// @has - '//pre[@class="rust item-decl"]' "_f: impl for<'any> Fn(&'any str, &'any str) -> bool + for<'r> Other<T<'r> = ()>," -// @has - '//pre[@class="rust item-decl"]' "_a: impl for<'beta, 'alpha, '_gamma> Auxiliary<'alpha, Item<'beta> = fn(_: &'beta ())>" -// @!has - '//pre[@class="rust item-decl"]' 'where' +//@ has impl_trait/fn.func5.html +//@ has - '//pre[@class="rust item-decl"]' "func5(" +//@ has - '//pre[@class="rust item-decl"]' "_f: impl for<'any> Fn(&'any str, &'any str) -> bool + for<'r> Other<T<'r> = ()>," +//@ has - '//pre[@class="rust item-decl"]' "_a: impl for<'beta, 'alpha, '_gamma> Auxiliary<'alpha, Item<'beta> = fn(_: &'beta ())>" +//@ !has - '//pre[@class="rust item-decl"]' 'where' pub use impl_trait_aux::func5; -// @has impl_trait/struct.Foo.html -// @has - '//*[@id="method.method"]//h4[@class="code-header"]' "pub fn method<'a>(_x: impl Clone + Into<Vec<u8>> + 'a)" -// @!has - '//*[@id="method.method"]//h4[@class="code-header"]' 'where' +//@ has impl_trait/struct.Foo.html +//@ has - '//*[@id="method.method"]//h4[@class="code-header"]' "pub fn method<'a>(_x: impl Clone + Into<Vec<u8>> + 'a)" +//@ !has - '//*[@id="method.method"]//h4[@class="code-header"]' 'where' pub use impl_trait_aux::Foo; diff --git a/tests/rustdoc/inline_cross/implementors-js.rs b/tests/rustdoc/inline_cross/implementors-js.rs index 099da54093c..e5b1049ff56 100644 --- a/tests/rustdoc/inline_cross/implementors-js.rs +++ b/tests/rustdoc/inline_cross/implementors-js.rs @@ -4,13 +4,13 @@ extern crate implementors_inline; -// @!has trait.impl/implementors_js/trait.MyTrait.js -// @has trait.impl/implementors_inline/my_trait/trait.MyTrait.js -// @!has trait.impl/implementors_inline/prelude/trait.MyTrait.js -// @has implementors_inline/my_trait/trait.MyTrait.html -// @has - '//script/@src' '../../trait.impl/implementors_inline/my_trait/trait.MyTrait.js' -// @has implementors_js/trait.MyTrait.html -// @has - '//script/@src' '../trait.impl/implementors_inline/my_trait/trait.MyTrait.js' +//@ !has trait.impl/implementors_js/trait.MyTrait.js +//@ has trait.impl/implementors_inline/my_trait/trait.MyTrait.js +//@ !has trait.impl/implementors_inline/prelude/trait.MyTrait.js +//@ has implementors_inline/my_trait/trait.MyTrait.html +//@ has - '//script/@src' '../../trait.impl/implementors_inline/my_trait/trait.MyTrait.js' +//@ has implementors_js/trait.MyTrait.html +//@ has - '//script/@src' '../trait.impl/implementors_inline/my_trait/trait.MyTrait.js' /// When re-exporting this trait, the HTML will be inlined, /// but, vitally, the JavaScript will be located only at the /// one canonical path. diff --git a/tests/rustdoc/inline_cross/inline_hidden.rs b/tests/rustdoc/inline_cross/inline_hidden.rs index 2a3dd72749c..095cd2d3c55 100644 --- a/tests/rustdoc/inline_cross/inline_hidden.rs +++ b/tests/rustdoc/inline_cross/inline_hidden.rs @@ -4,23 +4,23 @@ extern crate rustdoc_hidden; -// @has inline_hidden/index.html +//@ has inline_hidden/index.html // Ensures this item is not inlined. -// @has - '//*[@id="reexport.Foo"]/code' 'pub use rustdoc_hidden::Foo;' +//@ has - '//*[@id="reexport.Foo"]/code' 'pub use rustdoc_hidden::Foo;' #[doc(no_inline)] pub use rustdoc_hidden::Foo; // Even if the foreign item has `doc(hidden)`, we should be able to inline it. -// @has - '//*[@class="item-name"]/a[@class="struct"]' 'Inlined' +//@ has - '//*[@class="item-name"]/a[@class="struct"]' 'Inlined' #[doc(inline)] pub use rustdoc_hidden::Foo as Inlined; // Even with this import, we should not see `Foo`. -// @count - '//*[@class="item-name"]' 4 -// @has - '//*[@class="item-name"]/a[@class="struct"]' 'Bar' -// @has - '//*[@class="item-name"]/a[@class="fn"]' 'foo' +//@ count - '//*[@class="item-name"]' 4 +//@ has - '//*[@class="item-name"]/a[@class="struct"]' 'Bar' +//@ has - '//*[@class="item-name"]/a[@class="fn"]' 'foo' pub use rustdoc_hidden::*; -// @has inline_hidden/fn.foo.html -// @!has - '//a/@title' 'Foo' +//@ has inline_hidden/fn.foo.html +//@ !has - '//a/@title' 'Foo' pub fn foo(_: Foo) {} diff --git a/tests/rustdoc/inline_cross/issue-24183.rs b/tests/rustdoc/inline_cross/issue-24183.rs index cd39cda718b..8299eecc575 100644 --- a/tests/rustdoc/inline_cross/issue-24183.rs +++ b/tests/rustdoc/inline_cross/issue-24183.rs @@ -4,15 +4,15 @@ //@ aux-crate:issue_24183=issue-24183.rs //@ edition: 2021 -// @has usr/trait.U.html -// @has - '//*[@class="rust item-decl"]' "pub trait U {" -// @has - '//*[@id="method.modified"]' \ +//@ has usr/trait.U.html +//@ has - '//*[@class="rust item-decl"]' "pub trait U {" +//@ has - '//*[@id="method.modified"]' \ // "fn modified(self) -> Self\ // where \ // Self: Sized" -// @snapshot method_no_where_self_sized - '//*[@id="method.touch"]/*[@class="code-header"]' +//@ snapshot method_no_where_self_sized - '//*[@id="method.touch"]/*[@class="code-header"]' pub use issue_24183::U; -// @has usr/trait.S.html -// @has - '//*[@class="rust item-decl"]' 'pub trait S: Sized {' +//@ has usr/trait.S.html +//@ has - '//*[@class="rust item-decl"]' 'pub trait S: Sized {' pub use issue_24183::S; diff --git a/tests/rustdoc/inline_cross/issue-28480.rs b/tests/rustdoc/inline_cross/issue-28480.rs index 9d221a46d92..004510fd922 100644 --- a/tests/rustdoc/inline_cross/issue-28480.rs +++ b/tests/rustdoc/inline_cross/issue-28480.rs @@ -2,12 +2,12 @@ //@ build-aux-docs //@ ignore-cross-compile -// @has rustdoc_hidden_sig/struct.Bar.html -// @!has - '//a/@title' 'Hidden' -// @has - '//a' 'u8' +//@ has rustdoc_hidden_sig/struct.Bar.html +//@ !has - '//a/@title' 'Hidden' +//@ has - '//a' 'u8' extern crate rustdoc_hidden_sig; -// @has issue_28480/struct.Bar.html -// @!has - '//a/@title' 'Hidden' -// @has - '//a' 'u8' +//@ has issue_28480/struct.Bar.html +//@ !has - '//a/@title' 'Hidden' +//@ has - '//a' 'u8' pub use rustdoc_hidden_sig::Bar; diff --git a/tests/rustdoc/inline_cross/issue-31948-1.rs b/tests/rustdoc/inline_cross/issue-31948-1.rs index ee053f40638..e59da87c29d 100644 --- a/tests/rustdoc/inline_cross/issue-31948-1.rs +++ b/tests/rustdoc/inline_cross/issue-31948-1.rs @@ -4,24 +4,24 @@ extern crate rustdoc_nonreachable_impls; -// @has issue_31948_1/struct.Wobble.html -// @has - '//*[@class="impl"]//h3[@class="code-header"]' 'Bark for' -// @has - '//*[@class="impl"]//h3[@class="code-header"]' 'Woof for' -// @!has - '//*[@class="impl"]//h3[@class="code-header"]' 'Bar for' -// @!has - '//*[@class="impl"]//h3[@class="code-header"]' 'Qux for' +//@ has issue_31948_1/struct.Wobble.html +//@ has - '//*[@class="impl"]//h3[@class="code-header"]' 'Bark for' +//@ has - '//*[@class="impl"]//h3[@class="code-header"]' 'Woof for' +//@ !has - '//*[@class="impl"]//h3[@class="code-header"]' 'Bar for' +//@ !has - '//*[@class="impl"]//h3[@class="code-header"]' 'Qux for' pub use rustdoc_nonreachable_impls::hidden::Wobble; -// @has issue_31948_1/trait.Bark.html -// @has - '//h3[@class="code-header"]' 'for Foo' -// @has - '//h3[@class="code-header"]' 'for Wobble' -// @!has - '//h3[@class="code-header"]' 'for Wibble' +//@ has issue_31948_1/trait.Bark.html +//@ has - '//h3[@class="code-header"]' 'for Foo' +//@ has - '//h3[@class="code-header"]' 'for Wobble' +//@ !has - '//h3[@class="code-header"]' 'for Wibble' pub use rustdoc_nonreachable_impls::Bark; -// @has issue_31948_1/trait.Woof.html -// @has - '//h3[@class="code-header"]' 'for Foo' -// @has - '//h3[@class="code-header"]' 'for Wobble' -// @!has - '//h3[@class="code-header"]' 'for Wibble' +//@ has issue_31948_1/trait.Woof.html +//@ has - '//h3[@class="code-header"]' 'for Foo' +//@ has - '//h3[@class="code-header"]' 'for Wobble' +//@ !has - '//h3[@class="code-header"]' 'for Wibble' pub use rustdoc_nonreachable_impls::Woof; -// @!has issue_31948_1/trait.Bar.html -// @!has issue_31948_1/trait.Qux.html +//@ !has issue_31948_1/trait.Bar.html +//@ !has issue_31948_1/trait.Qux.html diff --git a/tests/rustdoc/inline_cross/issue-31948-2.rs b/tests/rustdoc/inline_cross/issue-31948-2.rs index 5019f0369b7..34b57052883 100644 --- a/tests/rustdoc/inline_cross/issue-31948-2.rs +++ b/tests/rustdoc/inline_cross/issue-31948-2.rs @@ -4,18 +4,18 @@ extern crate rustdoc_nonreachable_impls; -// @has issue_31948_2/struct.Wobble.html -// @has - '//*[@class="impl"]//h3[@class="code-header"]' 'Qux for' -// @has - '//*[@class="impl"]//h3[@class="code-header"]' 'Bark for' -// @has - '//*[@class="impl"]//h3[@class="code-header"]' 'Woof for' -// @!has - '//*[@class="impl"]//h3[@class="code-header"]' 'Bar for' +//@ has issue_31948_2/struct.Wobble.html +//@ has - '//*[@class="impl"]//h3[@class="code-header"]' 'Qux for' +//@ has - '//*[@class="impl"]//h3[@class="code-header"]' 'Bark for' +//@ has - '//*[@class="impl"]//h3[@class="code-header"]' 'Woof for' +//@ !has - '//*[@class="impl"]//h3[@class="code-header"]' 'Bar for' pub use rustdoc_nonreachable_impls::hidden::Wobble; -// @has issue_31948_2/trait.Qux.html -// @has - '//h3[@class="code-header"]' 'for Foo' -// @has - '//h3[@class="code-header"]' 'for Wobble' +//@ has issue_31948_2/trait.Qux.html +//@ has - '//h3[@class="code-header"]' 'for Foo' +//@ has - '//h3[@class="code-header"]' 'for Wobble' pub use rustdoc_nonreachable_impls::hidden::Qux; -// @!has issue_31948_2/trait.Bar.html -// @!has issue_31948_2/trait.Woof.html -// @!has issue_31948_2/trait.Bark.html +//@ !has issue_31948_2/trait.Bar.html +//@ !has issue_31948_2/trait.Woof.html +//@ !has issue_31948_2/trait.Bark.html diff --git a/tests/rustdoc/inline_cross/issue-31948.rs b/tests/rustdoc/inline_cross/issue-31948.rs index eaed8509520..7a43fc7b279 100644 --- a/tests/rustdoc/inline_cross/issue-31948.rs +++ b/tests/rustdoc/inline_cross/issue-31948.rs @@ -4,26 +4,26 @@ extern crate rustdoc_nonreachable_impls; -// @has issue_31948/struct.Foo.html -// @has - '//*[@class="impl"]//h3[@class="code-header"]' 'Bark for' -// @has - '//*[@class="impl"]//h3[@class="code-header"]' 'Woof for' -// @!has - '//*[@class="impl"]//h3[@class="code-header"]' 'Bar for' -// @!has - '//*[@class="impl"]//h3[@class="code-header"]' 'Qux for' +//@ has issue_31948/struct.Foo.html +//@ has - '//*[@class="impl"]//h3[@class="code-header"]' 'Bark for' +//@ has - '//*[@class="impl"]//h3[@class="code-header"]' 'Woof for' +//@ !has - '//*[@class="impl"]//h3[@class="code-header"]' 'Bar for' +//@ !has - '//*[@class="impl"]//h3[@class="code-header"]' 'Qux for' pub use rustdoc_nonreachable_impls::Foo; -// @has issue_31948/trait.Bark.html -// @has - '//h3[@class="code-header"]' 'for Foo' -// @!has - '//h3[@class="code-header"]' 'for Wibble' -// @!has - '//h3[@class="code-header"]' 'for Wobble' +//@ has issue_31948/trait.Bark.html +//@ has - '//h3[@class="code-header"]' 'for Foo' +//@ !has - '//h3[@class="code-header"]' 'for Wibble' +//@ !has - '//h3[@class="code-header"]' 'for Wobble' pub use rustdoc_nonreachable_impls::Bark; -// @has issue_31948/trait.Woof.html -// @has - '//h3[@class="code-header"]' 'for Foo' -// @!has - '//h3[@class="code-header"]' 'for Wibble' -// @!has - '//h3[@class="code-header"]' 'for Wobble' +//@ has issue_31948/trait.Woof.html +//@ has - '//h3[@class="code-header"]' 'for Foo' +//@ !has - '//h3[@class="code-header"]' 'for Wibble' +//@ !has - '//h3[@class="code-header"]' 'for Wobble' pub use rustdoc_nonreachable_impls::Woof; -// @!has issue_31948/trait.Bar.html -// @!has issue_31948/trait.Qux.html -// @!has issue_31948/struct.Wibble.html -// @!has issue_31948/struct.Wobble.html +//@ !has issue_31948/trait.Bar.html +//@ !has issue_31948/trait.Qux.html +//@ !has issue_31948/struct.Wibble.html +//@ !has issue_31948/struct.Wobble.html diff --git a/tests/rustdoc/inline_cross/issue-32881.rs b/tests/rustdoc/inline_cross/issue-32881.rs index 93e868b466a..d4ebf10a1ca 100644 --- a/tests/rustdoc/inline_cross/issue-32881.rs +++ b/tests/rustdoc/inline_cross/issue-32881.rs @@ -4,8 +4,8 @@ extern crate rustdoc_trait_object_impl; -// @has issue_32881/trait.Bar.html -// @has - '//h3[@class="code-header"]' "impl<'a> dyn Bar" -// @has - '//h3[@class="code-header"]' "impl<'a> Debug for dyn Bar" +//@ has issue_32881/trait.Bar.html +//@ has - '//h3[@class="code-header"]' "impl<'a> dyn Bar" +//@ has - '//h3[@class="code-header"]' "impl<'a> Debug for dyn Bar" pub use rustdoc_trait_object_impl::Bar; diff --git a/tests/rustdoc/inline_cross/issue-33113.rs b/tests/rustdoc/inline_cross/issue-33113.rs index 807bbcbe9b8..05e87d962cb 100644 --- a/tests/rustdoc/inline_cross/issue-33113.rs +++ b/tests/rustdoc/inline_cross/issue-33113.rs @@ -4,7 +4,7 @@ extern crate bar; -// @has issue_33113/trait.Bar.html -// @has - '//h3[@class="code-header"]' "for &'a char" -// @has - '//h3[@class="code-header"]' "for Foo" +//@ has issue_33113/trait.Bar.html +//@ has - '//h3[@class="code-header"]' "for &'a char" +//@ has - '//h3[@class="code-header"]' "for Foo" pub use bar::Bar; diff --git a/tests/rustdoc/inline_cross/issue-76736-1.rs b/tests/rustdoc/inline_cross/issue-76736-1.rs index 692677a3eee..fe52702fd6f 100644 --- a/tests/rustdoc/inline_cross/issue-76736-1.rs +++ b/tests/rustdoc/inline_cross/issue-76736-1.rs @@ -6,10 +6,10 @@ extern crate issue_76736_1; extern crate issue_76736_2; -// @has foo/struct.Foo.html -// @!has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult' +//@ has foo/struct.Foo.html +//@ !has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult' pub struct Foo; -// @has foo/struct.Bar.html -// @!has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult' +//@ has foo/struct.Bar.html +//@ !has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult' pub use issue_76736_2::Bar; diff --git a/tests/rustdoc/inline_cross/issue-76736-2.rs b/tests/rustdoc/inline_cross/issue-76736-2.rs index d4e6a697fc8..df376ebe9a1 100644 --- a/tests/rustdoc/inline_cross/issue-76736-2.rs +++ b/tests/rustdoc/inline_cross/issue-76736-2.rs @@ -9,10 +9,10 @@ extern crate issue_76736_1; extern crate issue_76736_2; -// @has foo/struct.Foo.html -// @!has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult' +//@ has foo/struct.Foo.html +//@ !has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult' pub struct Foo; -// @has foo/struct.Bar.html -// @!has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult' +//@ has foo/struct.Bar.html +//@ !has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult' pub use issue_76736_2::Bar; diff --git a/tests/rustdoc/inline_cross/issue-76736-3.rs b/tests/rustdoc/inline_cross/issue-76736-3.rs index cf75c8d0321..1bed4621c04 100644 --- a/tests/rustdoc/inline_cross/issue-76736-3.rs +++ b/tests/rustdoc/inline_cross/issue-76736-3.rs @@ -7,10 +7,10 @@ extern crate issue_76736_1; extern crate issue_76736_2; -// @has foo/struct.Foo.html -// @has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult' +//@ has foo/struct.Foo.html +//@ has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult' pub struct Foo; -// @has foo/struct.Bar.html -// @has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult' +//@ has foo/struct.Bar.html +//@ has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult' pub use issue_76736_2::Bar; diff --git a/tests/rustdoc/inline_cross/issue-76736-4.rs b/tests/rustdoc/inline_cross/issue-76736-4.rs index 297657ef9de..487e9030108 100644 --- a/tests/rustdoc/inline_cross/issue-76736-4.rs +++ b/tests/rustdoc/inline_cross/issue-76736-4.rs @@ -10,10 +10,10 @@ extern crate issue_76736_1; extern crate issue_76736_2; -// @has foo/struct.Foo.html -// @has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult' +//@ has foo/struct.Foo.html +//@ has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult' pub struct Foo; -// @has foo/struct.Bar.html -// @has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult' +//@ has foo/struct.Bar.html +//@ has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult' pub use issue_76736_2::Bar; diff --git a/tests/rustdoc/inline_cross/macro-vis.rs b/tests/rustdoc/inline_cross/macro-vis.rs index 6b811f1452a..b38748407b3 100644 --- a/tests/rustdoc/inline_cross/macro-vis.rs +++ b/tests/rustdoc/inline_cross/macro-vis.rs @@ -4,29 +4,29 @@ #[macro_use] extern crate qwop; -// @has macro_vis/macro.some_macro.html -// @has macro_vis/index.html '//a/@href' 'macro.some_macro.html' +//@ has macro_vis/macro.some_macro.html +//@ has macro_vis/index.html '//a/@href' 'macro.some_macro.html' pub use qwop::some_macro; -// @has macro_vis/macro.renamed_macro.html -// @!has - '//pre' 'some_macro' -// @has macro_vis/index.html '//a/@href' 'macro.renamed_macro.html' +//@ has macro_vis/macro.renamed_macro.html +//@ !has - '//pre' 'some_macro' +//@ has macro_vis/index.html '//a/@href' 'macro.renamed_macro.html' #[doc(inline)] pub use qwop::some_macro as renamed_macro; -// @!has macro_vis/macro.other_macro.html -// @!has macro_vis/index.html '//a/@href' 'macro.other_macro.html' -// @!has - '//code' 'pub use qwop::other_macro;' +//@ !has macro_vis/macro.other_macro.html +//@ !has macro_vis/index.html '//a/@href' 'macro.other_macro.html' +//@ !has - '//code' 'pub use qwop::other_macro;' #[doc(hidden)] pub use qwop::other_macro; -// @has macro_vis/index.html '//code' 'pub use qwop::super_macro;' -// @!has macro_vis/macro.super_macro.html +//@ has macro_vis/index.html '//code' 'pub use qwop::super_macro;' +//@ !has macro_vis/macro.super_macro.html #[doc(no_inline)] pub use qwop::super_macro; -// @has macro_vis/macro.this_is_dope.html -// @has macro_vis/index.html '//a/@href' 'macro.this_is_dope.html' +//@ has macro_vis/macro.this_is_dope.html +//@ has macro_vis/index.html '//a/@href' 'macro.this_is_dope.html' /// What it says on the tin. #[macro_export] macro_rules! this_is_dope { diff --git a/tests/rustdoc/inline_cross/macros.rs b/tests/rustdoc/inline_cross/macros.rs index c711216d2b5..aab7a3650b1 100644 --- a/tests/rustdoc/inline_cross/macros.rs +++ b/tests/rustdoc/inline_cross/macros.rs @@ -6,14 +6,14 @@ extern crate macros; -// @has foo/index.html '//*[@class="item-name"]/span[@class="stab deprecated"]' \ +//@ has foo/index.html '//*[@class="item-name"]/span[@class="stab deprecated"]' \ // Deprecated -// @has - '//*[@class="item-name"]/span[@class="stab unstable"]' \ +//@ has - '//*[@class="item-name"]/span[@class="stab unstable"]' \ // Experimental -// @has foo/macro.my_macro.html -// @has - '//*[@class="docblock"]' 'docs for my_macro' -// @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.2.3: text' -// @has - '//*[@class="stab unstable"]' 'macro_test' -// @has - '//a/@href' '../src/macros/macros.rs.html#8' +//@ has foo/macro.my_macro.html +//@ has - '//*[@class="docblock"]' 'docs for my_macro' +//@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.2.3: text' +//@ has - '//*[@class="stab unstable"]' 'macro_test' +//@ has - '//a/@href' '../src/macros/macros.rs.html#8' pub use macros::my_macro; diff --git a/tests/rustdoc/inline_cross/non_lifetime_binders.rs b/tests/rustdoc/inline_cross/non_lifetime_binders.rs index edc48c88d9c..95723a61ce7 100644 --- a/tests/rustdoc/inline_cross/non_lifetime_binders.rs +++ b/tests/rustdoc/inline_cross/non_lifetime_binders.rs @@ -2,12 +2,12 @@ //@ edition: 2021 #![crate_name = "user"] -// @has user/fn.f.html -// @has - '//pre[@class="rust item-decl"]' "f(_: impl for<T> Trait<T>)" +//@ has user/fn.f.html +//@ has - '//pre[@class="rust item-decl"]' "f(_: impl for<T> Trait<T>)" pub use non_lifetime_binders::f; -// @has user/fn.g.html -// @has - '//pre[@class="rust item-decl"]' "g<T>(_: T)\ +//@ has user/fn.g.html +//@ has - '//pre[@class="rust item-decl"]' "g<T>(_: T)\ // where \ // T: for<U> Trait<U>" pub use non_lifetime_binders::g; diff --git a/tests/rustdoc/inline_cross/proc_macro.rs b/tests/rustdoc/inline_cross/proc_macro.rs index 4d3b0d554ab..de1a4b82cc4 100644 --- a/tests/rustdoc/inline_cross/proc_macro.rs +++ b/tests/rustdoc/inline_cross/proc_macro.rs @@ -3,34 +3,34 @@ extern crate some_macros; -// @has proc_macro/index.html -// @has - '//a/@href' 'macro.some_proc_macro.html' -// @has - '//a/@href' 'attr.some_proc_attr.html' -// @has - '//a/@href' 'derive.SomeDerive.html' -// @has proc_macro/macro.some_proc_macro.html -// @has proc_macro/attr.some_proc_attr.html -// @has proc_macro/derive.SomeDerive.html - -// @has proc_macro/macro.some_proc_macro.html -// @hasraw - 'a proc-macro that swallows its input and does nothing.' +//@ has proc_macro/index.html +//@ has - '//a/@href' 'macro.some_proc_macro.html' +//@ has - '//a/@href' 'attr.some_proc_attr.html' +//@ has - '//a/@href' 'derive.SomeDerive.html' +//@ has proc_macro/macro.some_proc_macro.html +//@ has proc_macro/attr.some_proc_attr.html +//@ has proc_macro/derive.SomeDerive.html + +//@ has proc_macro/macro.some_proc_macro.html +//@ hasraw - 'a proc-macro that swallows its input and does nothing.' pub use some_macros::some_proc_macro; -// @has proc_macro/macro.reexported_macro.html -// @hasraw - 'Doc comment from the original crate' +//@ has proc_macro/macro.reexported_macro.html +//@ hasraw - 'Doc comment from the original crate' pub use some_macros::reexported_macro; -// @has proc_macro/attr.some_proc_attr.html -// @hasraw - 'a proc-macro attribute that passes its item through verbatim.' +//@ has proc_macro/attr.some_proc_attr.html +//@ hasraw - 'a proc-macro attribute that passes its item through verbatim.' pub use some_macros::some_proc_attr; -// @has proc_macro/derive.SomeDerive.html -// @hasraw - 'a derive attribute that adds nothing to its input.' +//@ has proc_macro/derive.SomeDerive.html +//@ hasraw - 'a derive attribute that adds nothing to its input.' pub use some_macros::SomeDerive; -// @has proc_macro/attr.first_attr.html -// @hasraw - 'Generated doc comment' +//@ has proc_macro/attr.first_attr.html +//@ hasraw - 'Generated doc comment' pub use some_macros::first_attr; -// @has proc_macro/attr.second_attr.html -// @hasraw - 'Generated doc comment' +//@ has proc_macro/attr.second_attr.html +//@ hasraw - 'Generated doc comment' pub use some_macros::second_attr; diff --git a/tests/rustdoc/inline_cross/qpath-self-85454.rs b/tests/rustdoc/inline_cross/qpath-self-85454.rs index de806db7709..4751b7b1db4 100644 --- a/tests/rustdoc/inline_cross/qpath-self-85454.rs +++ b/tests/rustdoc/inline_cross/qpath-self-85454.rs @@ -5,8 +5,8 @@ extern crate issue_85454; -// @has foo/trait.FromResidual.html -// @has - '//pre[@class="rust item-decl"]' 'pub trait FromResidual<R = <Self as Try>::Residual> { // Required method fn from_residual(residual: R) -> Self; }' +//@ has foo/trait.FromResidual.html +//@ has - '//pre[@class="rust item-decl"]' 'pub trait FromResidual<R = <Self as Try>::Residual> { // Required method fn from_residual(residual: R) -> Self; }' pub trait FromResidual<R = <Self as Try>::Residual> { fn from_residual(residual: R) -> Self; } @@ -24,7 +24,7 @@ pub enum ControlFlow<B, C = ()> { } pub mod reexport { - // @has foo/reexport/trait.FromResidual.html - // @has - '//pre[@class="rust item-decl"]' 'pub trait FromResidual<R = <Self as Try>::Residual> { // Required method fn from_residual(residual: R) -> Self; }' + //@ has foo/reexport/trait.FromResidual.html + //@ has - '//pre[@class="rust item-decl"]' 'pub trait FromResidual<R = <Self as Try>::Residual> { // Required method fn from_residual(residual: R) -> Self; }' pub use issue_85454::*; } diff --git a/tests/rustdoc/inline_cross/reexport-with-anonymous-lifetime-98697.rs b/tests/rustdoc/inline_cross/reexport-with-anonymous-lifetime-98697.rs index fe6e5a39c81..bb4ced085c3 100644 --- a/tests/rustdoc/inline_cross/reexport-with-anonymous-lifetime-98697.rs +++ b/tests/rustdoc/inline_cross/reexport-with-anonymous-lifetime-98697.rs @@ -9,10 +9,10 @@ extern crate reexport_with_anonymous_lifetime_98697; -// @has foo/fn.repro.html '//pre[@class="rust item-decl"]/code' 'fn repro<F>()where F: Fn(&str)' -// @!has foo/fn.repro.html '//pre[@class="rust item-decl"]/code' 'for<' +//@ has foo/fn.repro.html '//pre[@class="rust item-decl"]/code' 'fn repro<F>()where F: Fn(&str)' +//@ !has foo/fn.repro.html '//pre[@class="rust item-decl"]/code' 'for<' pub use reexport_with_anonymous_lifetime_98697::repro; -// @has foo/struct.Extra.html '//div[@id="trait-implementations-list"]//h3[@class="code-header"]' 'impl MyTrait<&Extra> for Extra' -// @!has foo/struct.Extra.html '//div[@id="trait-implementations-list"]//h3[@class="code-header"]' 'impl<' +//@ has foo/struct.Extra.html '//div[@id="trait-implementations-list"]//h3[@class="code-header"]' 'impl MyTrait<&Extra> for Extra' +//@ !has foo/struct.Extra.html '//div[@id="trait-implementations-list"]//h3[@class="code-header"]' 'impl<' pub use reexport_with_anonymous_lifetime_98697::Extra; diff --git a/tests/rustdoc/inline_cross/renamed-via-module.rs b/tests/rustdoc/inline_cross/renamed-via-module.rs index 1f6a9cff8ce..bdaf2cf1f62 100644 --- a/tests/rustdoc/inline_cross/renamed-via-module.rs +++ b/tests/rustdoc/inline_cross/renamed-via-module.rs @@ -6,19 +6,19 @@ extern crate foo; -// @has foo/iter/index.html -// @has - '//a/[@href="struct.DeprecatedStepBy.html"]' "DeprecatedStepBy" -// @has - '//a/[@href="struct.StepBy.html"]' "StepBy" -// @has foo/iter/struct.DeprecatedStepBy.html -// @has - '//h1' "Struct foo::iter::DeprecatedStepBy" -// @has foo/iter/struct.StepBy.html -// @has - '//h1' "Struct foo::iter::StepBy" +//@ has foo/iter/index.html +//@ has - '//a/[@href="struct.DeprecatedStepBy.html"]' "DeprecatedStepBy" +//@ has - '//a/[@href="struct.StepBy.html"]' "StepBy" +//@ has foo/iter/struct.DeprecatedStepBy.html +//@ has - '//h1' "Struct foo::iter::DeprecatedStepBy" +//@ has foo/iter/struct.StepBy.html +//@ has - '//h1' "Struct foo::iter::StepBy" -// @has bar/iter/index.html -// @has - '//a/[@href="struct.DeprecatedStepBy.html"]' "DeprecatedStepBy" -// @has - '//a/[@href="struct.StepBy.html"]' "StepBy" -// @has bar/iter/struct.DeprecatedStepBy.html -// @has - '//h1' "Struct bar::iter::DeprecatedStepBy" -// @has bar/iter/struct.StepBy.html -// @has - '//h1' "Struct bar::iter::StepBy" +//@ has bar/iter/index.html +//@ has - '//a/[@href="struct.DeprecatedStepBy.html"]' "DeprecatedStepBy" +//@ has - '//a/[@href="struct.StepBy.html"]' "StepBy" +//@ has bar/iter/struct.DeprecatedStepBy.html +//@ has - '//h1' "Struct bar::iter::DeprecatedStepBy" +//@ has bar/iter/struct.StepBy.html +//@ has - '//h1' "Struct bar::iter::StepBy" pub use foo::iter; diff --git a/tests/rustdoc/inline_cross/repr.rs b/tests/rustdoc/inline_cross/repr.rs index 1d63bd1d7cb..d13e560b8d7 100644 --- a/tests/rustdoc/inline_cross/repr.rs +++ b/tests/rustdoc/inline_cross/repr.rs @@ -7,34 +7,34 @@ extern crate repr; -// @has 'foo/struct.ReprC.html' -// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(C, align(8))]' +//@ has 'foo/struct.ReprC.html' +//@ has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(C, align(8))]' pub use repr::ReprC; -// @has 'foo/struct.ReprSimd.html' -// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(simd, packed(2))]' +//@ has 'foo/struct.ReprSimd.html' +//@ has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(simd, packed(2))]' pub use repr::ReprSimd; -// @has 'foo/struct.ReprTransparent.html' -// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' +//@ has 'foo/struct.ReprTransparent.html' +//@ has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' pub use repr::ReprTransparent; -// @has 'foo/enum.ReprIsize.html' -// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(isize)]' +//@ has 'foo/enum.ReprIsize.html' +//@ has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(isize)]' pub use repr::ReprIsize; -// @has 'foo/enum.ReprU8.html' -// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(u8)]' +//@ has 'foo/enum.ReprU8.html' +//@ has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(u8)]' pub use repr::ReprU8; // Regression test for <https://github.com/rust-lang/rust/issues/90435>. // Check that we show `#[repr(transparent)]` iff the non-1-ZST field is public or at least one // field is public in case all fields are 1-ZST fields. -// @has 'foo/struct.ReprTransparentPrivField.html' -// @!has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' +//@ has 'foo/struct.ReprTransparentPrivField.html' +//@ !has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' pub use repr::ReprTransparentPrivField; -// @has 'foo/struct.ReprTransparentPriv1ZstFields.html' -// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' +//@ has 'foo/struct.ReprTransparentPriv1ZstFields.html' +//@ has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' pub use repr::ReprTransparentPriv1ZstFields; -// @has 'foo/struct.ReprTransparentPrivFieldPub1ZstFields.html' -// @!has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' +//@ has 'foo/struct.ReprTransparentPrivFieldPub1ZstFields.html' +//@ !has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' pub use repr::ReprTransparentPrivFieldPub1ZstFields; diff --git a/tests/rustdoc/inline_cross/ret-pos-impl-trait-in-trait.rs b/tests/rustdoc/inline_cross/ret-pos-impl-trait-in-trait.rs index 1292e7c74ed..fba39ca8358 100644 --- a/tests/rustdoc/inline_cross/ret-pos-impl-trait-in-trait.rs +++ b/tests/rustdoc/inline_cross/ret-pos-impl-trait-in-trait.rs @@ -7,29 +7,29 @@ // their desugaring. We count the number of associated items and ensure that it is exactly one. // This is more robust than checking for the absence of the associated type. -// @has user/trait.Trait.html -// @has - '//*[@id="method.create"]' 'fn create() -> impl Iterator<Item = u64>' +//@ has user/trait.Trait.html +//@ has - '//*[@id="method.create"]' 'fn create() -> impl Iterator<Item = u64>' // The class "method" is used for all three kinds of associated items at the time of writing. -// @count - '//*[@id="main-content"]//section[@class="method"]' 1 +//@ count - '//*[@id="main-content"]//section[@class="method"]' 1 pub use rpitit::Trait; -// @has user/struct.Basic.html -// @has - '//*[@id="method.create"]' 'fn create() -> impl Iterator<Item = u64>' -// @count - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]' 1 +//@ has user/struct.Basic.html +//@ has - '//*[@id="method.create"]' 'fn create() -> impl Iterator<Item = u64>' +//@ count - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]' 1 pub use rpitit::Basic; -// @has user/struct.Intermediate.html -// @has - '//*[@id="method.create"]' 'fn create() -> Range<u64>' -// @count - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]' 1 +//@ has user/struct.Intermediate.html +//@ has - '//*[@id="method.create"]' 'fn create() -> Range<u64>' +//@ count - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]' 1 pub use rpitit::Intermediate; -// @has user/struct.Advanced.html -// @has - '//*[@id="method.create"]' 'fn create() -> impl Iterator<Item = u64>' -// @count - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]' 1 +//@ has user/struct.Advanced.html +//@ has - '//*[@id="method.create"]' 'fn create() -> impl Iterator<Item = u64>' +//@ count - '//*[@id="trait-implementations-list"]//*[@class="impl-items"]' 1 pub use rpitit::Advanced; // Regression test for issue #113929: -// @has user/trait.Def.html -// @has - '//*[@id="method.def"]' 'fn def<T>() -> impl Default' +//@ has user/trait.Def.html +//@ has - '//*[@id="method.def"]' 'fn def<T>() -> impl Default' pub use rpitit::Def; diff --git a/tests/rustdoc/inline_cross/sugar-closure-crate-21801.rs b/tests/rustdoc/inline_cross/sugar-closure-crate-21801.rs index a00dcaf409b..0cd400c03ec 100644 --- a/tests/rustdoc/inline_cross/sugar-closure-crate-21801.rs +++ b/tests/rustdoc/inline_cross/sugar-closure-crate-21801.rs @@ -6,7 +6,7 @@ extern crate issue_21801; -// @has issue_21801/struct.Foo.html -// @has - '//*[@id="method.new"]' \ +//@ has issue_21801/struct.Foo.html +//@ has - '//*[@id="method.new"]' \ // 'fn new<F>(f: F) -> Foowhere F: FnMut() -> i32' pub use issue_21801::Foo; diff --git a/tests/rustdoc/inline_cross/trait-vis.rs b/tests/rustdoc/inline_cross/trait-vis.rs index fc992ab3110..1fae6305b04 100644 --- a/tests/rustdoc/inline_cross/trait-vis.rs +++ b/tests/rustdoc/inline_cross/trait-vis.rs @@ -2,6 +2,6 @@ extern crate inner; -// @has trait_vis/struct.SomeStruct.html -// @has - '//h3[@class="code-header"]' 'impl Clone for SomeStruct' +//@ has trait_vis/struct.SomeStruct.html +//@ has - '//h3[@class="code-header"]' 'impl Clone for SomeStruct' pub use inner::SomeStruct; diff --git a/tests/rustdoc/inline_cross/use_crate.rs b/tests/rustdoc/inline_cross/use_crate.rs index 38cbcfa6b84..fdbc41c0bb0 100644 --- a/tests/rustdoc/inline_cross/use_crate.rs +++ b/tests/rustdoc/inline_cross/use_crate.rs @@ -10,18 +10,18 @@ #![crate_name = "local"] -// @!has-dir local/use_crate -// @has local/index.html -// @has - '//code' 'pub use use_crate' +//@ !has-dir local/use_crate +//@ has local/index.html +//@ has - '//code' 'pub use use_crate' pub use use_crate; -// @has-dir local/asdf -// @has local/asdf/index.html -// @has local/index.html '//a/@href' 'asdf/index.html' +//@ has-dir local/asdf +//@ has local/asdf/index.html +//@ has local/index.html '//a/@href' 'asdf/index.html' pub use use_crate::asdf; -// @has-dir local/use_crate_2 -// @has local/use_crate_2/index.html -// @has local/index.html '//a/@href' 'use_crate_2/index.html' +//@ has-dir local/use_crate_2 +//@ has local/use_crate_2/index.html +//@ has local/index.html '//a/@href' 'use_crate_2/index.html' #[doc(inline)] pub use use_crate_2; diff --git a/tests/rustdoc/inline_local/blanket-impl-reexported-trait-94183.rs b/tests/rustdoc/inline_local/blanket-impl-reexported-trait-94183.rs index 343e030da9e..66d313a4506 100644 --- a/tests/rustdoc/inline_local/blanket-impl-reexported-trait-94183.rs +++ b/tests/rustdoc/inline_local/blanket-impl-reexported-trait-94183.rs @@ -5,28 +5,28 @@ // https://github.com/rust-lang/rust/issues/94183 #![crate_name = "foo"] -// @has 'foo/struct.S.html' +//@ has 'foo/struct.S.html' mod actual_sub { pub trait Actual {} pub trait Another {} // `Another` is publicly re-exported so it should appear in the blanket impl list. - // @has - '//*[@id="blanket-implementations-list"]//*[@class="code-header"]' 'impl<T> Another for T' + //@ has - '//*[@id="blanket-implementations-list"]//*[@class="code-header"]' 'impl<T> Another for T' impl<T> Another for T {} trait Foo {} // `Foo` is not publicly re-exported nor reachable so it shouldn't appear in the // blanket impl list. - // @!has - '//*[@id="blanket-implementations-list"]//*[@class="code-header"]' 'impl<T> Foo for T' + //@ !has - '//*[@id="blanket-implementations-list"]//*[@class="code-header"]' 'impl<T> Foo for T' impl<T> Foo for T {} } pub use actual_sub::{Actual, Another}; // `Actual` is publicly re-exported so it should appear in the blanket impl list. -// @has - '//*[@id="blanket-implementations-list"]//*[@class="code-header"]' 'impl<T> Actual for T' +//@ has - '//*[@id="blanket-implementations-list"]//*[@class="code-header"]' 'impl<T> Actual for T' impl<T> Actual for T {} pub struct S; diff --git a/tests/rustdoc/inline_local/enum-variant-reexport-46766.rs b/tests/rustdoc/inline_local/enum-variant-reexport-46766.rs index ea6b7bac4c7..8a41f9d1fc5 100644 --- a/tests/rustdoc/inline_local/enum-variant-reexport-46766.rs +++ b/tests/rustdoc/inline_local/enum-variant-reexport-46766.rs @@ -4,4 +4,4 @@ pub enum Enum{Variant} pub use self::Enum::Variant; -// @!has foo/index.html '//a/@href' './Enum/index.html' +//@ !has foo/index.html '//a/@href' './Enum/index.html' diff --git a/tests/rustdoc/inline_local/glob-extern-document-private-items.rs b/tests/rustdoc/inline_local/glob-extern-document-private-items.rs index 9a11f88c81a..f58474bf5f9 100644 --- a/tests/rustdoc/inline_local/glob-extern-document-private-items.rs +++ b/tests/rustdoc/inline_local/glob-extern-document-private-items.rs @@ -11,15 +11,15 @@ mod mod1 { pub use mod1::*; -// @has foo/index.html -// @hasraw - "mod1" -// @hasraw - "public_fn" -// @!hasraw - "private_fn" -// @has foo/fn.public_fn.html -// @!has foo/fn.private_fn.html +//@ has foo/index.html +//@ hasraw - "mod1" +//@ hasraw - "public_fn" +//@ !hasraw - "private_fn" +//@ has foo/fn.public_fn.html +//@ !has foo/fn.private_fn.html -// @has foo/mod1/index.html -// @hasraw - "public_fn" -// @hasraw - "private_fn" -// @has foo/mod1/fn.public_fn.html -// @has foo/mod1/fn.private_fn.html +//@ has foo/mod1/index.html +//@ hasraw - "public_fn" +//@ hasraw - "private_fn" +//@ has foo/mod1/fn.public_fn.html +//@ has foo/mod1/fn.private_fn.html diff --git a/tests/rustdoc/inline_local/glob-extern.rs b/tests/rustdoc/inline_local/glob-extern.rs index c592a4db19d..5e7a631ad18 100644 --- a/tests/rustdoc/inline_local/glob-extern.rs +++ b/tests/rustdoc/inline_local/glob-extern.rs @@ -9,13 +9,13 @@ mod mod1 { pub use mod1::*; -// @has foo/index.html -// @!hasraw - "mod1" -// @hasraw - "public_fn" -// @!hasraw - "private_fn" -// @has foo/fn.public_fn.html -// @!has foo/fn.private_fn.html +//@ has foo/index.html +//@ !hasraw - "mod1" +//@ hasraw - "public_fn" +//@ !hasraw - "private_fn" +//@ has foo/fn.public_fn.html +//@ !has foo/fn.private_fn.html -// @!has foo/mod1/index.html -// @has foo/mod1/fn.public_fn.html -// @!has foo/mod1/fn.private_fn.html +//@ !has foo/mod1/index.html +//@ has foo/mod1/fn.public_fn.html +//@ !has foo/mod1/fn.private_fn.html diff --git a/tests/rustdoc/inline_local/glob-private-document-private-items.rs b/tests/rustdoc/inline_local/glob-private-document-private-items.rs index 4ad217d2270..4ad36da843f 100644 --- a/tests/rustdoc/inline_local/glob-private-document-private-items.rs +++ b/tests/rustdoc/inline_local/glob-private-document-private-items.rs @@ -14,35 +14,35 @@ mod mod1 { } pub use mod1::*; -// @has foo/index.html -// @hasraw - "mod1" -// @hasraw - "Mod1Public" -// @!hasraw - "Mod1Private" -// @!hasraw - "mod2" -// @hasraw - "Mod2Public" -// @!hasraw - "Mod2Private" -// @has foo/struct.Mod1Public.html -// @!has foo/struct.Mod1Private.html -// @has foo/struct.Mod2Public.html -// @!has foo/struct.Mod2Private.html +//@ has foo/index.html +//@ hasraw - "mod1" +//@ hasraw - "Mod1Public" +//@ !hasraw - "Mod1Private" +//@ !hasraw - "mod2" +//@ hasraw - "Mod2Public" +//@ !hasraw - "Mod2Private" +//@ has foo/struct.Mod1Public.html +//@ !has foo/struct.Mod1Private.html +//@ has foo/struct.Mod2Public.html +//@ !has foo/struct.Mod2Private.html -// @has foo/mod1/index.html -// @hasraw - "mod2" -// @hasraw - "Mod1Public" -// @hasraw - "Mod1Private" -// @!hasraw - "Mod2Public" -// @!hasraw - "Mod2Private" -// @has foo/mod1/struct.Mod1Public.html -// @has foo/mod1/struct.Mod1Private.html -// @!has foo/mod1/struct.Mod2Public.html -// @!has foo/mod1/struct.Mod2Private.html +//@ has foo/mod1/index.html +//@ hasraw - "mod2" +//@ hasraw - "Mod1Public" +//@ hasraw - "Mod1Private" +//@ !hasraw - "Mod2Public" +//@ !hasraw - "Mod2Private" +//@ has foo/mod1/struct.Mod1Public.html +//@ has foo/mod1/struct.Mod1Private.html +//@ !has foo/mod1/struct.Mod2Public.html +//@ !has foo/mod1/struct.Mod2Private.html -// @has foo/mod1/mod2/index.html -// @hasraw - "Mod2Public" -// @hasraw - "Mod2Private" -// @has foo/mod1/mod2/struct.Mod2Public.html -// @has foo/mod1/mod2/struct.Mod2Private.html +//@ has foo/mod1/mod2/index.html +//@ hasraw - "Mod2Public" +//@ hasraw - "Mod2Private" +//@ has foo/mod1/mod2/struct.Mod2Public.html +//@ has foo/mod1/mod2/struct.Mod2Private.html -// @!has foo/mod2/index.html -// @!has foo/mod2/struct.Mod2Public.html -// @!has foo/mod2/struct.Mod2Private.html +//@ !has foo/mod2/index.html +//@ !has foo/mod2/struct.Mod2Public.html +//@ !has foo/mod2/struct.Mod2Private.html diff --git a/tests/rustdoc/inline_local/glob-private.rs b/tests/rustdoc/inline_local/glob-private.rs index 303f1d61048..d6499d27a25 100644 --- a/tests/rustdoc/inline_local/glob-private.rs +++ b/tests/rustdoc/inline_local/glob-private.rs @@ -12,31 +12,31 @@ mod mod1 { } pub use mod1::*; -// @has foo/index.html -// @!hasraw - "mod1" -// @hasraw - "Mod1Public" -// @!hasraw - "Mod1Private" -// @!hasraw - "mod2" -// @hasraw - "Mod2Public" -// @!hasraw - "Mod2Private" -// @has foo/struct.Mod1Public.html -// @!has foo/struct.Mod1Private.html -// @has foo/struct.Mod2Public.html -// @!has foo/struct.Mod2Private.html +//@ has foo/index.html +//@ !hasraw - "mod1" +//@ hasraw - "Mod1Public" +//@ !hasraw - "Mod1Private" +//@ !hasraw - "mod2" +//@ hasraw - "Mod2Public" +//@ !hasraw - "Mod2Private" +//@ has foo/struct.Mod1Public.html +//@ !has foo/struct.Mod1Private.html +//@ has foo/struct.Mod2Public.html +//@ !has foo/struct.Mod2Private.html -// @has-dir foo/mod1 -// @!has foo/mod1/index.html -// @has foo/mod1/struct.Mod1Public.html -// @!has foo/mod1/struct.Mod1Private.html -// @!has foo/mod1/struct.Mod2Public.html -// @!has foo/mod1/struct.Mod2Private.html +//@ has-dir foo/mod1 +//@ !has foo/mod1/index.html +//@ has foo/mod1/struct.Mod1Public.html +//@ !has foo/mod1/struct.Mod1Private.html +//@ !has foo/mod1/struct.Mod2Public.html +//@ !has foo/mod1/struct.Mod2Private.html -// @has-dir foo/mod1/mod2 -// @!has foo/mod1/mod2/index.html -// @has foo/mod1/mod2/struct.Mod2Public.html -// @!has foo/mod1/mod2/struct.Mod2Private.html +//@ has-dir foo/mod1/mod2 +//@ !has foo/mod1/mod2/index.html +//@ has foo/mod1/mod2/struct.Mod2Public.html +//@ !has foo/mod1/mod2/struct.Mod2Private.html -// @!has-dir foo/mod2 -// @!has foo/mod2/index.html -// @!has foo/mod2/struct.Mod2Public.html -// @!has foo/mod2/struct.Mod2Private.html +//@ !has-dir foo/mod2 +//@ !has foo/mod2/index.html +//@ !has foo/mod2/struct.Mod2Public.html +//@ !has foo/mod2/struct.Mod2Private.html diff --git a/tests/rustdoc/inline_local/hidden-use.rs b/tests/rustdoc/inline_local/hidden-use.rs index de512fb26e6..35bce2932f9 100644 --- a/tests/rustdoc/inline_local/hidden-use.rs +++ b/tests/rustdoc/inline_local/hidden-use.rs @@ -2,9 +2,9 @@ mod private { pub struct Foo {} } -// @has hidden_use/index.html -// @!hasraw - 'private' -// @!hasraw - 'Foo' -// @!has hidden_use/struct.Foo.html +//@ has hidden_use/index.html +//@ !hasraw - 'private' +//@ !hasraw - 'Foo' +//@ !has hidden_use/struct.Foo.html #[doc(hidden)] pub use private::Foo; diff --git a/tests/rustdoc/inline_local/issue-28537.rs b/tests/rustdoc/inline_local/issue-28537.rs index da9cc4c940d..d5ba94d2e6c 100644 --- a/tests/rustdoc/inline_local/issue-28537.rs +++ b/tests/rustdoc/inline_local/issue-28537.rs @@ -10,8 +10,8 @@ mod bar { } } -// @has issue_28537/struct.Foo.html +//@ has issue_28537/struct.Foo.html pub use foo::Foo; -// @has issue_28537/struct.Bar.html +//@ has issue_28537/struct.Bar.html pub use self::bar::Bar; diff --git a/tests/rustdoc/inline_local/issue-32343.rs b/tests/rustdoc/inline_local/issue-32343.rs index 5620ae0dced..2ec123fdc5c 100644 --- a/tests/rustdoc/inline_local/issue-32343.rs +++ b/tests/rustdoc/inline_local/issue-32343.rs @@ -1,14 +1,14 @@ -// @!has issue_32343/struct.Foo.html -// @has issue_32343/index.html -// @has - '//code' 'pub use foo::Foo' -// @!has - '//code/a' 'Foo' +//@ !has issue_32343/struct.Foo.html +//@ has issue_32343/index.html +//@ has - '//code' 'pub use foo::Foo' +//@ !has - '//code/a' 'Foo' #[doc(no_inline)] pub use foo::Foo; -// @!has issue_32343/struct.Bar.html -// @has issue_32343/index.html -// @has - '//code' 'pub use foo::Bar' -// @has - '//code/a' 'Bar' +//@ !has issue_32343/struct.Bar.html +//@ has issue_32343/index.html +//@ has - '//code' 'pub use foo::Bar' +//@ has - '//code/a' 'Bar' #[doc(no_inline)] pub use foo::Bar; @@ -18,6 +18,6 @@ mod foo { } pub mod bar { - // @has issue_32343/bar/struct.Bar.html + //@ has issue_32343/bar/struct.Bar.html pub use ::foo::Bar; } diff --git a/tests/rustdoc/inline_local/macro_by_example.rs b/tests/rustdoc/inline_local/macro_by_example.rs index 5c33c0037e4..584a149968e 100644 --- a/tests/rustdoc/inline_local/macro_by_example.rs +++ b/tests/rustdoc/inline_local/macro_by_example.rs @@ -5,13 +5,13 @@ macro_rules! foo { ($($tt:tt)*) => {} } -// @has macro_by_example/macros/index.html +//@ has macro_by_example/macros/index.html pub mod macros { - // @!hasraw - 'pub use foo as bar;' - // @has macro_by_example/macros/macro.bar.html - // @has - '//*[@class="docblock"]' 'docs for foo' - // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.2.3: text' - // @has - '//a/@href' 'macro_by_example.rs.html#4-6' + //@ !hasraw - 'pub use foo as bar;' + //@ has macro_by_example/macros/macro.bar.html + //@ has - '//*[@class="docblock"]' 'docs for foo' + //@ has - '//*[@class="stab deprecated"]' 'Deprecated since 1.2.3: text' + //@ has - '//a/@href' 'macro_by_example.rs.html#4-6' #[doc(inline)] pub use foo as bar; } diff --git a/tests/rustdoc/inline_local/please_inline.rs b/tests/rustdoc/inline_local/please_inline.rs index e4429ef33a9..ad7a30012a8 100644 --- a/tests/rustdoc/inline_local/please_inline.rs +++ b/tests/rustdoc/inline_local/please_inline.rs @@ -2,18 +2,18 @@ pub mod foo { pub struct Foo; } -// @has please_inline/a/index.html +//@ has please_inline/a/index.html pub mod a { - // @!hasraw - 'pub use foo::' - // @has please_inline/a/struct.Foo.html + //@ !hasraw - 'pub use foo::' + //@ has please_inline/a/struct.Foo.html #[doc(inline)] pub use foo::Foo; } -// @has please_inline/b/index.html +//@ has please_inline/b/index.html pub mod b { - // @hasraw - 'pub use foo::' - // @!has please_inline/b/struct.Foo.html + //@ hasraw - 'pub use foo::' + //@ !has please_inline/b/struct.Foo.html #[feature(inline)] pub use foo::Foo; } diff --git a/tests/rustdoc/inline_local/private-reexport-in-public-api-81141-2.rs b/tests/rustdoc/inline_local/private-reexport-in-public-api-81141-2.rs index c066f54b32b..9dcdc6a0f34 100644 --- a/tests/rustdoc/inline_local/private-reexport-in-public-api-81141-2.rs +++ b/tests/rustdoc/inline_local/private-reexport-in-public-api-81141-2.rs @@ -8,7 +8,7 @@ use external::Public as Private; pub mod external { pub struct Public; - // @has 'foo/external/fn.make.html' - // @has - '//*[@class="rust item-decl"]/code' 'pub fn make() -> Public' + //@ has 'foo/external/fn.make.html' + //@ has - '//*[@class="rust item-decl"]/code' 'pub fn make() -> Public' pub fn make() -> ::Private { super::Private } } diff --git a/tests/rustdoc/inline_local/private-reexport-in-public-api-81141.rs b/tests/rustdoc/inline_local/private-reexport-in-public-api-81141.rs index d695ed7fbfa..55d95c32ce2 100644 --- a/tests/rustdoc/inline_local/private-reexport-in-public-api-81141.rs +++ b/tests/rustdoc/inline_local/private-reexport-in-public-api-81141.rs @@ -16,57 +16,57 @@ mod bar { pub use self::Bar as Inner; } -// @has 'foo/fn.bar.html' -// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar() -> Bar' +//@ has 'foo/fn.bar.html' +//@ has - '//*[@class="rust item-decl"]/code' 'pub fn bar() -> Bar' pub fn bar() -> Alias { Alias } -// @has 'foo/fn.bar2.html' -// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar2() -> Whatever' +//@ has 'foo/fn.bar2.html' +//@ has - '//*[@class="rust item-decl"]/code' 'pub fn bar2() -> Whatever' pub fn bar2() -> Whatever3 { Whatever } -// @has 'foo/fn.bar3.html' -// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar3() -> Whatever4' +//@ has 'foo/fn.bar3.html' +//@ has - '//*[@class="rust item-decl"]/code' 'pub fn bar3() -> Whatever4' pub fn bar3() -> Whatever4 { Whatever } -// @has 'foo/fn.bar4.html' -// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar4() -> Bar' +//@ has 'foo/fn.bar4.html' +//@ has - '//*[@class="rust item-decl"]/code' 'pub fn bar4() -> Bar' pub fn bar4() -> crate::Alias { Alias } -// @has 'foo/fn.bar5.html' -// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar5() -> Whatever' +//@ has 'foo/fn.bar5.html' +//@ has - '//*[@class="rust item-decl"]/code' 'pub fn bar5() -> Whatever' pub fn bar5() -> crate::Whatever3 { Whatever } -// @has 'foo/fn.bar6.html' -// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar6() -> Whatever4' +//@ has 'foo/fn.bar6.html' +//@ has - '//*[@class="rust item-decl"]/code' 'pub fn bar6() -> Whatever4' pub fn bar6() -> crate::Whatever4 { Whatever } -// @has 'foo/fn.bar7.html' -// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar7() -> Bar' +//@ has 'foo/fn.bar7.html' +//@ has - '//*[@class="rust item-decl"]/code' 'pub fn bar7() -> Bar' pub fn bar7() -> self::Alias { Alias } -// @has 'foo/fn.bar8.html' -// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar8() -> Whatever' +//@ has 'foo/fn.bar8.html' +//@ has - '//*[@class="rust item-decl"]/code' 'pub fn bar8() -> Whatever' pub fn bar8() -> self::Whatever3 { Whatever } -// @has 'foo/fn.bar9.html' -// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar9() -> Whatever4' +//@ has 'foo/fn.bar9.html' +//@ has - '//*[@class="rust item-decl"]/code' 'pub fn bar9() -> Whatever4' pub fn bar9() -> self::Whatever4 { Whatever } @@ -78,38 +78,38 @@ mod nested { pub(crate) use crate::nested as nested2; } -// @has 'foo/fn.bar10.html' -// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar10() -> Bar' +//@ has 'foo/fn.bar10.html' +//@ has - '//*[@class="rust item-decl"]/code' 'pub fn bar10() -> Bar' pub fn bar10() -> nested::Alias { Alias } -// @has 'foo/fn.bar11.html' -// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar11() -> Whatever' +//@ has 'foo/fn.bar11.html' +//@ has - '//*[@class="rust item-decl"]/code' 'pub fn bar11() -> Whatever' pub fn bar11() -> nested::Whatever3 { Whatever } -// @has 'foo/fn.bar12.html' -// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar12() -> Whatever4' +//@ has 'foo/fn.bar12.html' +//@ has - '//*[@class="rust item-decl"]/code' 'pub fn bar12() -> Whatever4' pub fn bar12() -> nested::Whatever4 { Whatever } -// @has 'foo/fn.bar13.html' -// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar13() -> Bar' +//@ has 'foo/fn.bar13.html' +//@ has - '//*[@class="rust item-decl"]/code' 'pub fn bar13() -> Bar' pub fn bar13() -> nested::nested2::Alias { Alias } -// @has 'foo/fn.bar14.html' -// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar14() -> Whatever' +//@ has 'foo/fn.bar14.html' +//@ has - '//*[@class="rust item-decl"]/code' 'pub fn bar14() -> Whatever' pub fn bar14() -> nested::nested2::Whatever3 { Whatever } -// @has 'foo/fn.bar15.html' -// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar15() -> Whatever4' +//@ has 'foo/fn.bar15.html' +//@ has - '//*[@class="rust item-decl"]/code' 'pub fn bar15() -> Whatever4' pub fn bar15() -> nested::nested2::Whatever4 { Whatever } @@ -119,7 +119,7 @@ use external::Public as Private; pub mod external { pub struct Public; - // @has 'foo/external/fn.make.html' - // @has - '//*[@class="rust item-decl"]/code' 'pub fn make() -> Public' + //@ has 'foo/external/fn.make.html' + //@ has - '//*[@class="rust item-decl"]/code' 'pub fn make() -> Public' pub fn make() -> super::Private { super::Private } } diff --git a/tests/rustdoc/inline_local/private-reexport-in-public-api-generics-81141.rs b/tests/rustdoc/inline_local/private-reexport-in-public-api-generics-81141.rs index 1c86c769a12..a0b637f0992 100644 --- a/tests/rustdoc/inline_local/private-reexport-in-public-api-generics-81141.rs +++ b/tests/rustdoc/inline_local/private-reexport-in-public-api-generics-81141.rs @@ -7,8 +7,8 @@ pub mod bar { pub struct Foo<'a, T>(&'a T); } -// @has "foo/fn.foo.html" -// @has - '//*[@class="rust item-decl"]/code' "pub fn foo<'a, T>(f: Foo<'a, T>) -> Foo<'a, usize>" +//@ has "foo/fn.foo.html" +//@ has - '//*[@class="rust item-decl"]/code' "pub fn foo<'a, T>(f: Foo<'a, T>) -> Foo<'a, usize>" pub fn foo<'a, T>(f: Alias<'a, T>) -> Alias<'a, usize> { Alias(&0) } diff --git a/tests/rustdoc/inline_local/private-reexport-in-public-api-hidden-81141.rs b/tests/rustdoc/inline_local/private-reexport-in-public-api-hidden-81141.rs index 7d6fadf26e2..62127daaec8 100644 --- a/tests/rustdoc/inline_local/private-reexport-in-public-api-hidden-81141.rs +++ b/tests/rustdoc/inline_local/private-reexport-in-public-api-hidden-81141.rs @@ -10,8 +10,8 @@ mod bar { pub struct Bar; } -// @has 'foo/fn.bar.html' -// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar() -> Alias' +//@ has 'foo/fn.bar.html' +//@ has - '//*[@class="rust item-decl"]/code' 'pub fn bar() -> Alias' pub fn bar() -> Alias { Alias } diff --git a/tests/rustdoc/inline_local/private-reexport-in-public-api-private-81141.rs b/tests/rustdoc/inline_local/private-reexport-in-public-api-private-81141.rs index 6bf507838d5..adf41aa10cb 100644 --- a/tests/rustdoc/inline_local/private-reexport-in-public-api-private-81141.rs +++ b/tests/rustdoc/inline_local/private-reexport-in-public-api-private-81141.rs @@ -12,22 +12,22 @@ mod bar { } // It's a fully private re-export so it should not be displayed. -// @has 'foo/fn.bar.html' -// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar() -> Bar' +//@ has 'foo/fn.bar.html' +//@ has - '//*[@class="rust item-decl"]/code' 'pub fn bar() -> Bar' pub fn bar() -> Alias { Alias } // It's public re-export inside a private module so it should be visible. -// @has 'foo/fn.bar2.html' -// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar2() -> Inner' +//@ has 'foo/fn.bar2.html' +//@ has - '//*[@class="rust item-decl"]/code' 'pub fn bar2() -> Inner' pub fn bar2() -> crate::bar::Inner { Alias } // It's a non-public, so it doesn't appear in documentation so it should not be visible. -// @has 'foo/fn.bar3.html' -// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar3() -> Bar' +//@ has 'foo/fn.bar3.html' +//@ has - '//*[@class="rust item-decl"]/code' 'pub fn bar3() -> Bar' pub fn bar3() -> CrateAlias { Alias } diff --git a/tests/rustdoc/inline_local/reexported-macro-and-macro-export-sidebar-89852.rs b/tests/rustdoc/inline_local/reexported-macro-and-macro-export-sidebar-89852.rs index cffe1289ce8..6cdfc71b13f 100644 --- a/tests/rustdoc/inline_local/reexported-macro-and-macro-export-sidebar-89852.rs +++ b/tests/rustdoc/inline_local/reexported-macro-and-macro-export-sidebar-89852.rs @@ -5,8 +5,8 @@ #![no_core] #![feature(no_core)] -// @matchesraw 'foo/sidebar-items.js' '"repro"' -// @!matchesraw 'foo/sidebar-items.js' '"repro".*"repro"' +//@ matchesraw 'foo/sidebar-items.js' '"repro"' +//@ !matchesraw 'foo/sidebar-items.js' '"repro".*"repro"' #[macro_export] macro_rules! repro { diff --git a/tests/rustdoc/inline_local/trait-vis.rs b/tests/rustdoc/inline_local/trait-vis.rs index 19b69da1513..1e5929a9ccf 100644 --- a/tests/rustdoc/inline_local/trait-vis.rs +++ b/tests/rustdoc/inline_local/trait-vis.rs @@ -12,7 +12,7 @@ mod asdf { impl PrivateTrait for SomeStruct {} } -// @has trait_vis/struct.SomeStruct.html -// @has - '//h3[@class="code-header"]' 'impl ThisTrait for SomeStruct' -// @!has - '//h3[@class="code-header"]' 'impl PrivateTrait for SomeStruct' +//@ has trait_vis/struct.SomeStruct.html +//@ has - '//h3[@class="code-header"]' 'impl ThisTrait for SomeStruct' +//@ !has - '//h3[@class="code-header"]' 'impl PrivateTrait for SomeStruct' pub use asdf::SomeStruct; diff --git a/tests/rustdoc/internal.rs b/tests/rustdoc/internal.rs index 4663965f621..e0bccefda1d 100644 --- a/tests/rustdoc/internal.rs +++ b/tests/rustdoc/internal.rs @@ -2,16 +2,16 @@ // Check that the unstable marker is not added for "rustc_private". -// @!matches internal/index.html \ +//@ !matches internal/index.html \ // '//*[@class="desc docblock-short"]/span[@class="stab unstable"]' \ // '' -// @!matches internal/index.html \ +//@ !matches internal/index.html \ // '//*[@class="desc docblock-short"]/span[@class="stab internal"]' \ // '' -// @matches - '//*[@class="desc docblock-short"]' 'Docs' +//@ matches - '//*[@class="desc docblock-short"]' 'Docs' -// @!has internal/struct.S.html '//*[@class="stab unstable"]' '' -// @!has internal/struct.S.html '//*[@class="stab internal"]' '' +//@ !has internal/struct.S.html '//*[@class="stab unstable"]' '' +//@ !has internal/struct.S.html '//*[@class="stab internal"]' '' /// Docs pub struct S; diff --git a/tests/rustdoc/intra-doc-crate/self.rs b/tests/rustdoc/intra-doc-crate/self.rs index 015611610ac..95b21a3303f 100644 --- a/tests/rustdoc/intra-doc-crate/self.rs +++ b/tests/rustdoc/intra-doc-crate/self.rs @@ -3,7 +3,7 @@ extern crate cross_crate_self; -// @has self/struct.S.html '//a[@href="struct.S.html#method.f"]' "Self::f" -// @has self/struct.S.html '//a[@href="struct.S.html"]' "Self" -// @has self/struct.S.html '//a[@href="../cross_crate_self/index.html"]' "crate" +//@ has self/struct.S.html '//a[@href="struct.S.html#method.f"]' "Self::f" +//@ has self/struct.S.html '//a[@href="struct.S.html"]' "Self" +//@ has self/struct.S.html '//a[@href="../cross_crate_self/index.html"]' "crate" pub use cross_crate_self::S; diff --git a/tests/rustdoc/intra-doc-link-method-trait-impl-72340.rs b/tests/rustdoc/intra-doc-link-method-trait-impl-72340.rs index 880a308f9ab..0cf46bb3f95 100644 --- a/tests/rustdoc/intra-doc-link-method-trait-impl-72340.rs +++ b/tests/rustdoc/intra-doc-link-method-trait-impl-72340.rs @@ -12,7 +12,7 @@ impl Body { } impl Default for Body { - // @has foo/struct.Body.html '//a/@href' 'struct.Body.html#method.empty' + //@ has foo/struct.Body.html '//a/@href' 'struct.Body.html#method.empty' /// Returns [`Body::empty()`](Body::empty). fn default() -> Body { diff --git a/tests/rustdoc/intra-doc/anchors.rs b/tests/rustdoc/intra-doc/anchors.rs index 3d4c464960b..68f8c4fefd9 100644 --- a/tests/rustdoc/intra-doc/anchors.rs +++ b/tests/rustdoc/intra-doc/anchors.rs @@ -3,8 +3,8 @@ /// # Anchor! pub struct Something; -// @has anchors/struct.SomeOtherType.html -// @has - '//a/@href' 'struct.Something.html#Anchor!' +//@ has anchors/struct.SomeOtherType.html +//@ has - '//a/@href' 'struct.Something.html#Anchor!' /// I want... /// @@ -14,11 +14,11 @@ pub struct SomeOtherType; /// Primitives? /// /// [u32#hello] -// @has anchors/fn.x.html -// @has - '//a/@href' '{{channel}}/std/primitive.u32.html#hello' +//@ has anchors/fn.x.html +//@ has - '//a/@href' '{{channel}}/std/primitive.u32.html#hello' pub fn x() {} /// [prim@usize#x] -// @has anchors/usize/index.html -// @has - '//a/@href' '{{channel}}/std/primitive.usize.html#x' +//@ has anchors/usize/index.html +//@ has - '//a/@href' '{{channel}}/std/primitive.usize.html#x' pub mod usize {} diff --git a/tests/rustdoc/intra-doc/assoc-reexport-super.rs b/tests/rustdoc/intra-doc/assoc-reexport-super.rs index a7bc1c6a29f..2a55586925f 100644 --- a/tests/rustdoc/intra-doc/assoc-reexport-super.rs +++ b/tests/rustdoc/intra-doc/assoc-reexport-super.rs @@ -14,7 +14,7 @@ pub use generated::MyNewType; mod prelude { impl super::MyNewType { /// An alias for [`Self::FOO`]. - // @has 'foo/struct.MyNewType.html' '//a[@href="struct.MyNewType.html#associatedconstant.FOO"]' 'Self::FOO' + //@ has 'foo/struct.MyNewType.html' '//a[@href="struct.MyNewType.html#associatedconstant.FOO"]' 'Self::FOO' pub const FOO2: Self = Self::FOO; } } diff --git a/tests/rustdoc/intra-doc/associated-defaults.rs b/tests/rustdoc/intra-doc/associated-defaults.rs index c7e66c826be..b5ba55dd30f 100644 --- a/tests/rustdoc/intra-doc/associated-defaults.rs +++ b/tests/rustdoc/intra-doc/associated-defaults.rs @@ -9,14 +9,14 @@ pub trait TraitWithDefault { } /// Link to [UsesDefaults::T] and [UsesDefaults::f] -// @has 'associated_defaults/struct.UsesDefaults.html' '//a[@href="struct.UsesDefaults.html#associatedtype.T"]' 'UsesDefaults::T' -// @has 'associated_defaults/struct.UsesDefaults.html' '//a[@href="struct.UsesDefaults.html#method.f"]' 'UsesDefaults::f' +//@ has 'associated_defaults/struct.UsesDefaults.html' '//a[@href="struct.UsesDefaults.html#associatedtype.T"]' 'UsesDefaults::T' +//@ has 'associated_defaults/struct.UsesDefaults.html' '//a[@href="struct.UsesDefaults.html#method.f"]' 'UsesDefaults::f' pub struct UsesDefaults; impl TraitWithDefault for UsesDefaults {} /// Link to [OverridesDefaults::T] and [OverridesDefaults::f] -// @has 'associated_defaults/struct.OverridesDefaults.html' '//a[@href="struct.OverridesDefaults.html#associatedtype.T"]' 'OverridesDefaults::T' -// @has 'associated_defaults/struct.OverridesDefaults.html' '//a[@href="struct.OverridesDefaults.html#method.f"]' 'OverridesDefaults::f' +//@ has 'associated_defaults/struct.OverridesDefaults.html' '//a[@href="struct.OverridesDefaults.html#associatedtype.T"]' 'OverridesDefaults::T' +//@ has 'associated_defaults/struct.OverridesDefaults.html' '//a[@href="struct.OverridesDefaults.html#method.f"]' 'OverridesDefaults::f' pub struct OverridesDefaults; impl TraitWithDefault for OverridesDefaults { type T = bool; diff --git a/tests/rustdoc/intra-doc/associated-items.rs b/tests/rustdoc/intra-doc/associated-items.rs index 0b958eb8eac..84cfd06111d 100644 --- a/tests/rustdoc/intra-doc/associated-items.rs +++ b/tests/rustdoc/intra-doc/associated-items.rs @@ -3,16 +3,16 @@ /// [`std::collections::BTreeMap::into_iter`] /// [`String::from`] is ambiguous as to which `From` impl /// [Vec::into_iter()] uses a disambiguator -// @has 'associated_items/fn.foo.html' '//a[@href="{{channel}}/alloc/collections/btree/map/struct.BTreeMap.html#method.into_iter"]' 'std::collections::BTreeMap::into_iter' -// @has 'associated_items/fn.foo.html' '//a[@href="{{channel}}/alloc/string/struct.String.html#method.from"]' 'String::from' -// @has 'associated_items/fn.foo.html' '//a[@href="{{channel}}/alloc/vec/struct.Vec.html#method.into_iter"]' 'Vec::into_iter' +//@ has 'associated_items/fn.foo.html' '//a[@href="{{channel}}/alloc/collections/btree/map/struct.BTreeMap.html#method.into_iter"]' 'std::collections::BTreeMap::into_iter' +//@ has 'associated_items/fn.foo.html' '//a[@href="{{channel}}/alloc/string/struct.String.html#method.from"]' 'String::from' +//@ has 'associated_items/fn.foo.html' '//a[@href="{{channel}}/alloc/vec/struct.Vec.html#method.into_iter"]' 'Vec::into_iter' pub fn foo() {} /// Link to [MyStruct], [link from struct][MyStruct::method], [MyStruct::clone], [MyStruct::Input] -// @has 'associated_items/struct.MyStruct.html' '//a[@href="struct.MyStruct.html"]' 'MyStruct' -// @has 'associated_items/struct.MyStruct.html' '//a[@href="struct.MyStruct.html#method.method"]' 'link from struct' -// @has 'associated_items/struct.MyStruct.html' '//a[@href="struct.MyStruct.html#method.clone"]' 'MyStruct::clone' -// @has 'associated_items/struct.MyStruct.html' '//a[@href="struct.MyStruct.html#associatedtype.Input"]' 'MyStruct::Input' +//@ has 'associated_items/struct.MyStruct.html' '//a[@href="struct.MyStruct.html"]' 'MyStruct' +//@ has 'associated_items/struct.MyStruct.html' '//a[@href="struct.MyStruct.html#method.method"]' 'link from struct' +//@ has 'associated_items/struct.MyStruct.html' '//a[@href="struct.MyStruct.html#method.clone"]' 'MyStruct::clone' +//@ has 'associated_items/struct.MyStruct.html' '//a[@href="struct.MyStruct.html#associatedtype.Input"]' 'MyStruct::Input' pub struct MyStruct { foo: () } impl Clone for MyStruct { @@ -30,7 +30,7 @@ impl T for MyStruct { type Input = usize; /// [link from method][MyStruct::method] on method - // @has 'associated_items/struct.MyStruct.html' '//a[@href="struct.MyStruct.html#method.method"]' 'link from method' + //@ has 'associated_items/struct.MyStruct.html' '//a[@href="struct.MyStruct.html#method.method"]' 'link from method' fn method(i: usize) { } } @@ -57,7 +57,7 @@ impl T2 for S { fn ambiguous_method() {} } -// @has associated_items/enum.MyEnum.html '//a/@href' 'enum.MyEnum.html#variant.MyVariant' +//@ has associated_items/enum.MyEnum.html '//a/@href' 'enum.MyEnum.html#variant.MyVariant' /// Link to [MyEnumAlias::MyVariant] pub enum MyEnum { MyVariant, diff --git a/tests/rustdoc/intra-doc/basic.rs b/tests/rustdoc/intra-doc/basic.rs index c88a7887f11..9d0d1d51647 100644 --- a/tests/rustdoc/intra-doc/basic.rs +++ b/tests/rustdoc/intra-doc/basic.rs @@ -1,44 +1,44 @@ #![allow(rustdoc::redundant_explicit_links)] -// @has basic/index.html -// @has - '//a/@href' 'struct.ThisType.html' -// @has - '//a/@title' 'struct basic::ThisType' -// @has - '//a/@href' 'struct.ThisType.html#method.this_method' -// @has - '//a/@title' 'method basic::ThisType::this_method' -// @has - '//a/@href' 'struct.ThisType.html#method.this_assoc_fn' -// @has - '//a/@title' 'associated function basic::ThisType::this_assoc_fn' -// @has - '//a/@href' 'enum.ThisEnum.html' -// @has - '//a/@title' 'enum basic::ThisEnum' -// @has - '//a/@href' 'enum.ThisEnum.html#variant.ThisVariant' -// @has - '//a/@title' 'variant basic::ThisEnum::ThisVariant' -// @has - '//a/@href' 'trait.ThisTrait.html' -// @has - '//a/@title' 'trait basic::ThisTrait' -// @has - '//a/@href' 'trait.ThisTrait.html#tymethod.this_associated_method' -// @has - '//a/@title' 'method basic::ThisTrait::this_associated_method' -// @has - '//a/@href' 'trait.ThisTrait.html#tymethod.this_associated_fn' -// @has - '//a/@title' 'associated function basic::ThisTrait::this_associated_fn' -// @has - '//a/@href' 'trait.ThisTrait.html#associatedtype.ThisAssociatedType' -// @has - '//a/@title' 'associated type basic::ThisTrait::ThisAssociatedType' -// @has - '//a/@href' 'trait.ThisTrait.html#associatedconstant.THIS_ASSOCIATED_CONST' -// @has - '//a/@title' 'associated constant basic::ThisTrait::THIS_ASSOCIATED_CONST' -// @has - '//a/@href' 'trait.ThisTrait.html' -// @has - '//a/@title' 'trait basic::ThisTrait' -// @has - '//a/@href' 'type.ThisAlias.html' -// @has - '//a/@title' 'type basic::ThisAlias' -// @has - '//a/@href' 'union.ThisUnion.html' -// @has - '//a/@title' 'union basic::ThisUnion' -// @has - '//a/@href' 'fn.this_function.html' -// @has - '//a/@title' 'fn basic::this_function' -// @has - '//a/@href' 'constant.THIS_CONST.html' -// @has - '//a/@title' 'constant basic::THIS_CONST' -// @has - '//a/@href' 'static.THIS_STATIC.html' -// @has - '//a/@title' 'static basic::THIS_STATIC' -// @has - '//a/@href' 'macro.this_macro.html' -// @has - '//a/@title' 'macro basic::this_macro' -// @has - '//a/@href' 'trait.SoAmbiguous.html' -// @has - '//a/@title' 'trait basic::SoAmbiguous' -// @has - '//a/@href' 'fn.SoAmbiguous.html' -// @has - '//a/@title' 'fn basic::SoAmbiguous' +//@ has basic/index.html +//@ has - '//a/@href' 'struct.ThisType.html' +//@ has - '//a/@title' 'struct basic::ThisType' +//@ has - '//a/@href' 'struct.ThisType.html#method.this_method' +//@ has - '//a/@title' 'method basic::ThisType::this_method' +//@ has - '//a/@href' 'struct.ThisType.html#method.this_assoc_fn' +//@ has - '//a/@title' 'associated function basic::ThisType::this_assoc_fn' +//@ has - '//a/@href' 'enum.ThisEnum.html' +//@ has - '//a/@title' 'enum basic::ThisEnum' +//@ has - '//a/@href' 'enum.ThisEnum.html#variant.ThisVariant' +//@ has - '//a/@title' 'variant basic::ThisEnum::ThisVariant' +//@ has - '//a/@href' 'trait.ThisTrait.html' +//@ has - '//a/@title' 'trait basic::ThisTrait' +//@ has - '//a/@href' 'trait.ThisTrait.html#tymethod.this_associated_method' +//@ has - '//a/@title' 'method basic::ThisTrait::this_associated_method' +//@ has - '//a/@href' 'trait.ThisTrait.html#tymethod.this_associated_fn' +//@ has - '//a/@title' 'associated function basic::ThisTrait::this_associated_fn' +//@ has - '//a/@href' 'trait.ThisTrait.html#associatedtype.ThisAssociatedType' +//@ has - '//a/@title' 'associated type basic::ThisTrait::ThisAssociatedType' +//@ has - '//a/@href' 'trait.ThisTrait.html#associatedconstant.THIS_ASSOCIATED_CONST' +//@ has - '//a/@title' 'associated constant basic::ThisTrait::THIS_ASSOCIATED_CONST' +//@ has - '//a/@href' 'trait.ThisTrait.html' +//@ has - '//a/@title' 'trait basic::ThisTrait' +//@ has - '//a/@href' 'type.ThisAlias.html' +//@ has - '//a/@title' 'type basic::ThisAlias' +//@ has - '//a/@href' 'union.ThisUnion.html' +//@ has - '//a/@title' 'union basic::ThisUnion' +//@ has - '//a/@href' 'fn.this_function.html' +//@ has - '//a/@title' 'fn basic::this_function' +//@ has - '//a/@href' 'constant.THIS_CONST.html' +//@ has - '//a/@title' 'constant basic::THIS_CONST' +//@ has - '//a/@href' 'static.THIS_STATIC.html' +//@ has - '//a/@title' 'static basic::THIS_STATIC' +//@ has - '//a/@href' 'macro.this_macro.html' +//@ has - '//a/@title' 'macro basic::this_macro' +//@ has - '//a/@href' 'trait.SoAmbiguous.html' +//@ has - '//a/@title' 'trait basic::SoAmbiguous' +//@ has - '//a/@href' 'fn.SoAmbiguous.html' +//@ has - '//a/@title' 'fn basic::SoAmbiguous' //! In this crate we would like to link to: //! //! * [`ThisType`](ThisType) @@ -71,7 +71,7 @@ macro_rules! this_macro { () => {}; } -// @has basic/struct.ThisType.html '//a/@href' 'macro.this_macro.html' +//@ has basic/struct.ThisType.html '//a/@href' 'macro.this_macro.html' /// another link to [`this_macro!()`] pub struct ThisType; @@ -99,10 +99,10 @@ pub trait SoAmbiguous {} pub fn SoAmbiguous() {} -// @has basic/struct.SomeOtherType.html '//a/@href' 'struct.ThisType.html' -// @has - '//a/@href' 'struct.ThisType.html#method.this_method' -// @has - '//a/@href' 'enum.ThisEnum.html' -// @has - '//a/@href' 'enum.ThisEnum.html#variant.ThisVariant' +//@ has basic/struct.SomeOtherType.html '//a/@href' 'struct.ThisType.html' +//@ has - '//a/@href' 'struct.ThisType.html#method.this_method' +//@ has - '//a/@href' 'enum.ThisEnum.html' +//@ has - '//a/@href' 'enum.ThisEnum.html#variant.ThisVariant' /// Shortcut links for: /// * [`ThisType`] /// * [`ThisType::this_method`] diff --git a/tests/rustdoc/intra-doc/builtin-macros.rs b/tests/rustdoc/intra-doc/builtin-macros.rs index bbdbe246bbc..12fc7c600ff 100644 --- a/tests/rustdoc/intra-doc/builtin-macros.rs +++ b/tests/rustdoc/intra-doc/builtin-macros.rs @@ -1,3 +1,3 @@ -// @has builtin_macros/index.html -// @has - '//a/@href' '{{channel}}/core/macro.cfg.html' +//@ has builtin_macros/index.html +//@ has - '//a/@href' '{{channel}}/core/macro.cfg.html' //! [cfg] diff --git a/tests/rustdoc/intra-doc/crate-relative-assoc.rs b/tests/rustdoc/intra-doc/crate-relative-assoc.rs index d4a0ecc35ae..1625b98dea6 100644 --- a/tests/rustdoc/intra-doc/crate-relative-assoc.rs +++ b/tests/rustdoc/intra-doc/crate-relative-assoc.rs @@ -5,7 +5,7 @@ pub mod io { } pub mod bufreader { - // @has crate_relative_assoc/bufreader/index.html '//a/@href' 'struct.TcpStream.html#method.read' + //@ has crate_relative_assoc/bufreader/index.html '//a/@href' 'struct.TcpStream.html#method.read' //! [`crate::TcpStream::read`] use crate::io::Read; } diff --git a/tests/rustdoc/intra-doc/crate-relative.rs b/tests/rustdoc/intra-doc/crate-relative.rs index bacbcabfc60..b4cae5e5585 100644 --- a/tests/rustdoc/intra-doc/crate-relative.rs +++ b/tests/rustdoc/intra-doc/crate-relative.rs @@ -6,8 +6,8 @@ impl<'a> Test<'a> { pub fn do_test(&self) {} } -// @has crate_relative/demo/index.html -// @has - '//a/@href' '../struct.Test.html#method.do_test' +//@ has crate_relative/demo/index.html +//@ has - '//a/@href' '../struct.Test.html#method.do_test' pub mod demo { //! [`crate::Test::do_test`] } diff --git a/tests/rustdoc/intra-doc/cross-crate/additional_doc.rs b/tests/rustdoc/intra-doc/cross-crate/additional_doc.rs index dc928c64f6d..02e4ada14a3 100644 --- a/tests/rustdoc/intra-doc/cross-crate/additional_doc.rs +++ b/tests/rustdoc/intra-doc/cross-crate/additional_doc.rs @@ -4,7 +4,7 @@ extern crate my_rand; -// @has 'additional_doc/trait.Rng.html' '//a[@href="trait.Rng.html"]' 'Rng' -// @has 'additional_doc/trait.Rng.html' '//a[@href="../my_rand/trait.RngCore.html"]' 'RngCore' +//@ has 'additional_doc/trait.Rng.html' '//a[@href="trait.Rng.html"]' 'Rng' +//@ has 'additional_doc/trait.Rng.html' '//a[@href="../my_rand/trait.RngCore.html"]' 'RngCore' /// This is an [`Rng`]. pub use my_rand::Rng; diff --git a/tests/rustdoc/intra-doc/cross-crate/basic.rs b/tests/rustdoc/intra-doc/cross-crate/basic.rs index f17c638b578..45f7a8a2b6b 100644 --- a/tests/rustdoc/intra-doc/cross-crate/basic.rs +++ b/tests/rustdoc/intra-doc/cross-crate/basic.rs @@ -5,5 +5,5 @@ // from https://github.com/rust-lang/rust/issues/65983 extern crate a; -// @has 'basic/struct.Bar.html' '//a[@href="../a/struct.Foo.html"]' 'Foo' +//@ has 'basic/struct.Bar.html' '//a[@href="../a/struct.Foo.html"]' 'Foo' pub use a::Bar; diff --git a/tests/rustdoc/intra-doc/cross-crate/crate.rs b/tests/rustdoc/intra-doc/cross-crate/crate.rs index 34fff1f1f26..511812f2bdb 100644 --- a/tests/rustdoc/intra-doc/cross-crate/crate.rs +++ b/tests/rustdoc/intra-doc/cross-crate/crate.rs @@ -2,5 +2,5 @@ //@ build-aux-docs #![crate_name = "outer"] extern crate inner; -// @has outer/fn.f.html '//a[@href="../inner/fn.g.html"]' "crate::g" +//@ has outer/fn.f.html '//a[@href="../inner/fn.g.html"]' "crate::g" pub use inner::f; diff --git a/tests/rustdoc/intra-doc/cross-crate/hidden.rs b/tests/rustdoc/intra-doc/cross-crate/hidden.rs index 026c0fb4fdb..490f1d23ca0 100644 --- a/tests/rustdoc/intra-doc/cross-crate/hidden.rs +++ b/tests/rustdoc/intra-doc/cross-crate/hidden.rs @@ -6,5 +6,5 @@ extern crate hidden_dep; -// @has 'hidden/struct.Ready.html' '//a/@href' 'fn.ready.html' +//@ has 'hidden/struct.Ready.html' '//a/@href' 'fn.ready.html' pub use hidden_dep::future::{ready, Ready}; diff --git a/tests/rustdoc/intra-doc/cross-crate/macro.rs b/tests/rustdoc/intra-doc/cross-crate/macro.rs index cd8f1c3969f..19ca5f6f243 100644 --- a/tests/rustdoc/intra-doc/cross-crate/macro.rs +++ b/tests/rustdoc/intra-doc/cross-crate/macro.rs @@ -5,7 +5,7 @@ extern crate macro_inner; extern crate proc_macro_inner; -// @has 'macro/macro.my_macro.html' '//a[@href="../macro_inner/struct.Foo.html"]' 'Foo' +//@ has 'macro/macro.my_macro.html' '//a[@href="../macro_inner/struct.Foo.html"]' 'Foo' pub use macro_inner::my_macro; -// @has 'macro/derive.DeriveA.html' '//a[@href="../proc_macro_inner/derive.OtherDerive.html"]' 'OtherDerive' +//@ has 'macro/derive.DeriveA.html' '//a[@href="../proc_macro_inner/derive.OtherDerive.html"]' 'OtherDerive' pub use proc_macro_inner::DeriveA; diff --git a/tests/rustdoc/intra-doc/cross-crate/module.rs b/tests/rustdoc/intra-doc/cross-crate/module.rs index 2323cc94f8a..0f9fa4e2276 100644 --- a/tests/rustdoc/intra-doc/cross-crate/module.rs +++ b/tests/rustdoc/intra-doc/cross-crate/module.rs @@ -3,6 +3,6 @@ //@ build-aux-docs #![deny(rustdoc::broken_intra_doc_links)] extern crate module_inner; -// @has 'module/bar/index.html' '//a[@href="../../module_inner/trait.SomeTrait.html"]' 'SomeTrait' -// @has 'module/bar/index.html' '//a[@href="../../module_inner/struct.SomeType.html"]' 'SomeType' +//@ has 'module/bar/index.html' '//a[@href="../../module_inner/trait.SomeTrait.html"]' 'SomeTrait' +//@ has 'module/bar/index.html' '//a[@href="../../module_inner/struct.SomeType.html"]' 'SomeType' pub use module_inner::bar; diff --git a/tests/rustdoc/intra-doc/cross-crate/submodule-inner.rs b/tests/rustdoc/intra-doc/cross-crate/submodule-inner.rs index 08996826561..cc139e3daaf 100644 --- a/tests/rustdoc/intra-doc/cross-crate/submodule-inner.rs +++ b/tests/rustdoc/intra-doc/cross-crate/submodule-inner.rs @@ -4,5 +4,5 @@ extern crate a; -// @has 'submodule_inner/struct.Foo.html' '//a[@href="../a/bar/struct.Bar.html"]' 'Bar' +//@ has 'submodule_inner/struct.Foo.html' '//a[@href="../a/bar/struct.Bar.html"]' 'Bar' pub use a::foo::Foo; diff --git a/tests/rustdoc/intra-doc/cross-crate/submodule-outer.rs b/tests/rustdoc/intra-doc/cross-crate/submodule-outer.rs index 29b98036a96..93121a6938d 100644 --- a/tests/rustdoc/intra-doc/cross-crate/submodule-outer.rs +++ b/tests/rustdoc/intra-doc/cross-crate/submodule-outer.rs @@ -11,6 +11,6 @@ pub mod bar { // NOTE: we re-exported both `Foo` and `Bar` here, // NOTE: so they are inlined and therefore we link to the current module. -// @has 'submodule_outer/trait.Foo.html' '//a[@href="bar/trait.Bar.html"]' 'Bar' -// @has 'submodule_outer/trait.Foo.html' '//a[@href="trait.Baz.html"]' 'Baz' +//@ has 'submodule_outer/trait.Foo.html' '//a[@href="bar/trait.Bar.html"]' 'Bar' +//@ has 'submodule_outer/trait.Foo.html' '//a[@href="trait.Baz.html"]' 'Baz' pub use ::bar_::{Foo, Baz}; diff --git a/tests/rustdoc/intra-doc/cross-crate/traits.rs b/tests/rustdoc/intra-doc/cross-crate/traits.rs index 4b1625e5a51..70382062a61 100644 --- a/tests/rustdoc/intra-doc/cross-crate/traits.rs +++ b/tests/rustdoc/intra-doc/cross-crate/traits.rs @@ -7,8 +7,8 @@ use inner::SomeTrait; pub struct SomeStruct; - // @has 'traits/struct.SomeStruct.html' '//a[@href="../inner/trait.SomeTrait.html"]' 'SomeTrait' + //@ has 'traits/struct.SomeStruct.html' '//a[@href="../inner/trait.SomeTrait.html"]' 'SomeTrait' impl SomeTrait for SomeStruct { - // @has 'traits/struct.SomeStruct.html' '//a[@href="../inner/trait.SomeTrait.html"]' 'a trait' + //@ has 'traits/struct.SomeStruct.html' '//a[@href="../inner/trait.SomeTrait.html"]' 'a trait' fn foo() {} } diff --git a/tests/rustdoc/intra-doc/disambiguators-removed.rs b/tests/rustdoc/intra-doc/disambiguators-removed.rs index 331a314130a..613156222ed 100644 --- a/tests/rustdoc/intra-doc/disambiguators-removed.rs +++ b/tests/rustdoc/intra-doc/disambiguators-removed.rs @@ -1,50 +1,50 @@ #![deny(rustdoc::broken_intra_doc_links)] // first try backticks /// Trait: [`trait@Name`], fn: [`fn@Name`], [`Name`][`macro@Name`] -// @has disambiguators_removed/struct.AtDisambiguator.html -// @has - '//a[@href="trait.Name.html"][code]' "Name" -// @has - '//a[@href="fn.Name.html"][code]' "Name" -// @has - '//a[@href="macro.Name.html"][code]' "Name" +//@ has disambiguators_removed/struct.AtDisambiguator.html +//@ has - '//a[@href="trait.Name.html"][code]' "Name" +//@ has - '//a[@href="fn.Name.html"][code]' "Name" +//@ has - '//a[@href="macro.Name.html"][code]' "Name" pub struct AtDisambiguator; /// fn: [`Name()`], macro: [`Name!`] -// @has disambiguators_removed/struct.SymbolDisambiguator.html -// @has - '//a[@href="fn.Name.html"][code]' "Name()" -// @has - '//a[@href="macro.Name.html"][code]' "Name!" +//@ has disambiguators_removed/struct.SymbolDisambiguator.html +//@ has - '//a[@href="fn.Name.html"][code]' "Name()" +//@ has - '//a[@href="macro.Name.html"][code]' "Name!" pub struct SymbolDisambiguator; // Now make sure that backticks aren't added if they weren't already there /// [fn@Name] -// @has disambiguators_removed/trait.Name.html -// @has - '//a[@href="fn.Name.html"]' "Name" -// @!has - '//a[@href="fn.Name.html"][code]' "Name" +//@ has disambiguators_removed/trait.Name.html +//@ has - '//a[@href="fn.Name.html"]' "Name" +//@ !has - '//a[@href="fn.Name.html"][code]' "Name" // FIXME: this will turn !() into ! alone /// [Name!()] -// @has - '//a[@href="macro.Name.html"]' "Name!" +//@ has - '//a[@href="macro.Name.html"]' "Name!" pub trait Name {} #[allow(non_snake_case)] // Try collapsed reference links /// [macro@Name][] -// @has disambiguators_removed/fn.Name.html -// @has - '//a[@href="macro.Name.html"]' "Name" +//@ has disambiguators_removed/fn.Name.html +//@ has - '//a[@href="macro.Name.html"]' "Name" // Try links that have the same text as a generated URL /// Weird URL aligned [macro.Name.html][trait@Name] -// @has - '//a[@href="trait.Name.html"]' "macro.Name.html" +//@ has - '//a[@href="trait.Name.html"]' "macro.Name.html" pub fn Name() {} #[macro_export] // Rustdoc doesn't currently handle links that have weird interspersing of inline code blocks. /// [fn@Na`m`e] -// @has disambiguators_removed/macro.Name.html -// @has - '//a[@href="fn.Name.html"]' "fn@Name" +//@ has disambiguators_removed/macro.Name.html +//@ has - '//a[@href="fn.Name.html"]' "fn@Name" // It also doesn't handle any case where the code block isn't the whole link text: /// [trait@`Name`] -// @has - '//a[@href="trait.Name.html"]' "trait@Name" +//@ has - '//a[@href="trait.Name.html"]' "trait@Name" macro_rules! Name { () => () } diff --git a/tests/rustdoc/intra-doc/email-address.rs b/tests/rustdoc/intra-doc/email-address.rs index 24161c3bb48..f689139357e 100644 --- a/tests/rustdoc/intra-doc/email-address.rs +++ b/tests/rustdoc/intra-doc/email-address.rs @@ -4,7 +4,7 @@ //! Email me at <hello-world@example.com>. //! Email me at <hello@localhost>. //! Email me at <prim@i32>. -// @has email_address/index.html '//a[@href="mailto:hello@example.com"]' 'hello@example.com' -// @has email_address/index.html '//a[@href="mailto:hello-world@example.com"]' 'hello-world@example.com' -// @has email_address/index.html '//a[@href="mailto:hello@localhost"]' 'hello@localhost' -// @has email_address/index.html '//a[@href="mailto:prim@i32"]' 'prim@i32' +//@ has email_address/index.html '//a[@href="mailto:hello@example.com"]' 'hello@example.com' +//@ has email_address/index.html '//a[@href="mailto:hello-world@example.com"]' 'hello-world@example.com' +//@ has email_address/index.html '//a[@href="mailto:hello@localhost"]' 'hello@localhost' +//@ has email_address/index.html '//a[@href="mailto:prim@i32"]' 'prim@i32' diff --git a/tests/rustdoc/intra-doc/enum-struct-field.rs b/tests/rustdoc/intra-doc/enum-struct-field.rs index 2270a1fafa1..71ba53b877f 100644 --- a/tests/rustdoc/intra-doc/enum-struct-field.rs +++ b/tests/rustdoc/intra-doc/enum-struct-field.rs @@ -11,4 +11,4 @@ pub enum Foo { /// I want [Foo::X::y]. pub fn foo() {} -// @has foo/fn.foo.html '//a/@href' 'enum.Foo.html#variant.X.field.y' +//@ has foo/fn.foo.html '//a/@href' 'enum.Foo.html#variant.X.field.y' diff --git a/tests/rustdoc/intra-doc/extern-crate-only-used-in-link.rs b/tests/rustdoc/intra-doc/extern-crate-only-used-in-link.rs index cbe5bf912a5..7cec30c8b74 100644 --- a/tests/rustdoc/intra-doc/extern-crate-only-used-in-link.rs +++ b/tests/rustdoc/intra-doc/extern-crate-only-used-in-link.rs @@ -8,12 +8,12 @@ //@ build-aux-docs //@ compile-flags:-Z unstable-options --edition 2018 -// @has extern_crate_only_used_in_link/index.html -// @has - '//a[@href="../issue_66159_1/struct.Something.html"]' 'issue_66159_1::Something' +//@ has extern_crate_only_used_in_link/index.html +//@ has - '//a[@href="../issue_66159_1/struct.Something.html"]' 'issue_66159_1::Something' //! [issue_66159_1::Something] -// @has - '//a[@href="../empty/index.html"]' 'empty' +//@ has - '//a[@href="../empty/index.html"]' 'empty' //! [`empty`] -// @has - '//a[@href="../empty2/index.html"]' 'empty2' +//@ has - '//a[@href="../empty2/index.html"]' 'empty2' //! [`empty2<x>`] diff --git a/tests/rustdoc/intra-doc/extern-type.rs b/tests/rustdoc/intra-doc/extern-type.rs index 5440f582dff..198ac8e43e0 100644 --- a/tests/rustdoc/intra-doc/extern-type.rs +++ b/tests/rustdoc/intra-doc/extern-type.rs @@ -24,12 +24,12 @@ impl G<usize> for ExternType { fn g(&self, n: usize) {} } -// @has 'extern_type/foreigntype.ExternType.html' -// @hasraw 'extern_type/fn.links_to_extern_type.html' \ +//@ has 'extern_type/foreigntype.ExternType.html' +//@ hasraw 'extern_type/fn.links_to_extern_type.html' \ // 'href="foreigntype.ExternType.html#method.f"' -// @hasraw 'extern_type/fn.links_to_extern_type.html' \ +//@ hasraw 'extern_type/fn.links_to_extern_type.html' \ // 'href="foreigntype.ExternType.html#method.test"' -// @hasraw 'extern_type/fn.links_to_extern_type.html' \ +//@ hasraw 'extern_type/fn.links_to_extern_type.html' \ // 'href="foreigntype.ExternType.html#method.g"' /// See also [ExternType::f] /// See also [ExternType::test] diff --git a/tests/rustdoc/intra-doc/field.rs b/tests/rustdoc/intra-doc/field.rs index 00114348924..ba6b320e560 100644 --- a/tests/rustdoc/intra-doc/field.rs +++ b/tests/rustdoc/intra-doc/field.rs @@ -1,4 +1,4 @@ -// @has field/index.html '//a[@href="{{channel}}/core/ops/range/struct.Range.html#structfield.start"]' 'start' -// @has field/index.html '//a[@href="{{channel}}/std/io/error/enum.ErrorKind.html#variant.NotFound"]' 'not_found' +//@ has field/index.html '//a[@href="{{channel}}/core/ops/range/struct.Range.html#structfield.start"]' 'start' +//@ has field/index.html '//a[@href="{{channel}}/std/io/error/enum.ErrorKind.html#variant.NotFound"]' 'not_found' //! [start][std::ops::Range::start] //! [not_found][std::io::ErrorKind::NotFound] diff --git a/tests/rustdoc/intra-doc/generic-params.rs b/tests/rustdoc/intra-doc/generic-params.rs index 359f775f97f..64e13c2e3ca 100644 --- a/tests/rustdoc/intra-doc/generic-params.rs +++ b/tests/rustdoc/intra-doc/generic-params.rs @@ -6,40 +6,40 @@ //! Here's a link to [`Vec<T>`] and one to [`Box<Vec<Option<T>>>`]. //! Here's a link to [`Iterator<Box<T>>::Item`]. //! -// @has foo/index.html '//a[@href="{{channel}}/alloc/vec/struct.Vec.html"]' 'Vec<T>' -// @has foo/index.html '//a[@href="{{channel}}/alloc/boxed/struct.Box.html"]' 'Box<Vec<Option<T>>>' -// @has foo/index.html '//a[@href="{{channel}}/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item"]' 'Iterator<Box<T>>::Item' +//@ has foo/index.html '//a[@href="{{channel}}/alloc/vec/struct.Vec.html"]' 'Vec<T>' +//@ has foo/index.html '//a[@href="{{channel}}/alloc/boxed/struct.Box.html"]' 'Box<Vec<Option<T>>>' +//@ has foo/index.html '//a[@href="{{channel}}/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item"]' 'Iterator<Box<T>>::Item' //! And what about a link to [just `Option`](Option) and, [with the generic, `Option<T>`](Option<T>)? //! -// @has foo/index.html '//a[@href="{{channel}}/core/option/enum.Option.html"]' 'just Option' -// @has foo/index.html '//a[@href="{{channel}}/core/option/enum.Option.html"]' 'with the generic, Option<T>' +//@ has foo/index.html '//a[@href="{{channel}}/core/option/enum.Option.html"]' 'just Option' +//@ has foo/index.html '//a[@href="{{channel}}/core/option/enum.Option.html"]' 'with the generic, Option<T>' //! We should also try linking to [`Result<T, E>`]; it has *two* generics! //! And [`Result<T, !>`] and [`Result<!, E>`]. //! -// @has foo/index.html '//a[@href="{{channel}}/core/result/enum.Result.html"]' 'Result<T, E>' -// @has foo/index.html '//a[@href="{{channel}}/core/result/enum.Result.html"]' 'Result<T, !>' -// @has foo/index.html '//a[@href="{{channel}}/core/result/enum.Result.html"]' 'Result<!, E>' +//@ has foo/index.html '//a[@href="{{channel}}/core/result/enum.Result.html"]' 'Result<T, E>' +//@ has foo/index.html '//a[@href="{{channel}}/core/result/enum.Result.html"]' 'Result<T, !>' +//@ has foo/index.html '//a[@href="{{channel}}/core/result/enum.Result.html"]' 'Result<!, E>' //! Now let's test a trickier case: [`Vec::<T>::new`], or you could write it //! [with parentheses as `Vec::<T>::new()`][Vec::<T>::new()]. //! And what about something even harder? That would be [`Vec::<Box<T>>::new()`]. //! -// @has foo/index.html '//a[@href="{{channel}}/alloc/vec/struct.Vec.html#method.new"]' 'Vec::<T>::new' -// @has foo/index.html '//a[@href="{{channel}}/alloc/vec/struct.Vec.html#method.new"]' 'with parentheses as Vec::<T>::new()' -// @has foo/index.html '//a[@href="{{channel}}/alloc/vec/struct.Vec.html#method.new"]' 'Vec::<Box<T>>::new()' +//@ has foo/index.html '//a[@href="{{channel}}/alloc/vec/struct.Vec.html#method.new"]' 'Vec::<T>::new' +//@ has foo/index.html '//a[@href="{{channel}}/alloc/vec/struct.Vec.html#method.new"]' 'with parentheses as Vec::<T>::new()' +//@ has foo/index.html '//a[@href="{{channel}}/alloc/vec/struct.Vec.html#method.new"]' 'Vec::<Box<T>>::new()' //! This is also pretty tricky: [`TypeId::of::<String>()`]. //! And this too: [`Vec::<std::error::Error>::len`]. //! -// @has foo/index.html '//a[@href="{{channel}}/core/any/struct.TypeId.html#method.of"]' 'TypeId::of::<String>()' -// @has foo/index.html '//a[@href="{{channel}}/alloc/vec/struct.Vec.html#method.len"]' 'Vec::<std::error::Error>::len' +//@ has foo/index.html '//a[@href="{{channel}}/core/any/struct.TypeId.html#method.of"]' 'TypeId::of::<String>()' +//@ has foo/index.html '//a[@href="{{channel}}/alloc/vec/struct.Vec.html#method.len"]' 'Vec::<std::error::Error>::len' //! We unofficially and implicitly support things that aren't valid in the actual Rust syntax, like //! [`Box::<T>new()`]. We may not support them in the future! //! -// @has foo/index.html '//a[@href="{{channel}}/alloc/boxed/struct.Box.html#method.new"]' 'Box::<T>new()' +//@ has foo/index.html '//a[@href="{{channel}}/alloc/boxed/struct.Box.html#method.new"]' 'Box::<T>new()' //! These will be resolved as regular links: //! - [`this is <invalid syntax> first`](https://www.rust-lang.org) @@ -53,11 +53,11 @@ //! [rlo]: https://www.rust-lang.org //! [c > d]: https://www.rust-lang.org //! -// @has foo/index.html '//a[@href="https://www.rust-lang.org"]' 'this is <invalid syntax> first' -// @has foo/index.html '//a[@href="https://www.rust-lang.org"]' 'this is <invalid syntax> twice' -// @has foo/index.html '//a[@href="https://www.rust-lang.org"]' '<invalid syntax> thrice' -// @has foo/index.html '//a[@href="https://www.rust-lang.org"]' '<invalid syntax> four times' -// @has foo/index.html '//a[@href="https://www.rust-lang.org"]' 'a < b' -// @has foo/index.html '//a[@href="https://www.rust-lang.org"]' 'c > d' +//@ has foo/index.html '//a[@href="https://www.rust-lang.org"]' 'this is <invalid syntax> first' +//@ has foo/index.html '//a[@href="https://www.rust-lang.org"]' 'this is <invalid syntax> twice' +//@ has foo/index.html '//a[@href="https://www.rust-lang.org"]' '<invalid syntax> thrice' +//@ has foo/index.html '//a[@href="https://www.rust-lang.org"]' '<invalid syntax> four times' +//@ has foo/index.html '//a[@href="https://www.rust-lang.org"]' 'a < b' +//@ has foo/index.html '//a[@href="https://www.rust-lang.org"]' 'c > d' use std::any::TypeId; diff --git a/tests/rustdoc/intra-doc/generic-trait-impl.rs b/tests/rustdoc/intra-doc/generic-trait-impl.rs index ba8595abfa9..314b6321cbb 100644 --- a/tests/rustdoc/intra-doc/generic-trait-impl.rs +++ b/tests/rustdoc/intra-doc/generic-trait-impl.rs @@ -15,6 +15,6 @@ impl<T, U> Bar<T> for Foo<U> { fn bar(&self) {} } -// @has generic_trait_impl/fn.main.html '//a[@href="struct.Foo.html#method.bar"]' 'Foo::bar' +//@ has generic_trait_impl/fn.main.html '//a[@href="struct.Foo.html#method.bar"]' 'Foo::bar' /// link to [`Foo::bar`] pub fn main() {} diff --git a/tests/rustdoc/intra-doc/inherent-associated-types.rs b/tests/rustdoc/intra-doc/inherent-associated-types.rs index 2b28d2ae60b..b7eedee2c17 100644 --- a/tests/rustdoc/intra-doc/inherent-associated-types.rs +++ b/tests/rustdoc/intra-doc/inherent-associated-types.rs @@ -3,9 +3,9 @@ #![allow(incomplete_features)] #![deny(rustdoc::broken_intra_doc_links)] -// @has inherent_associated_types/index.html +//@ has inherent_associated_types/index.html -// @has - '//a/@href' 'enum.Simple.html#associatedtype.Type' +//@ has - '//a/@href' 'enum.Simple.html#associatedtype.Type' //! [`Simple::Type`] pub enum Simple {} @@ -16,7 +16,7 @@ impl Simple { //////////////////////////////////////// -// @has 'inherent_associated_types/type.Test0.html' '//a/@href' \ +//@ has 'inherent_associated_types/type.Test0.html' '//a/@href' \ // 'struct.Parametrized.html#associatedtype.Proj' /// [`Parametrized<bool>::Proj`] pub type Test0 = (); @@ -28,9 +28,9 @@ pub type Test0 = (); // Further, at some point we should reject the intra-doc link `Parametrized::Proj`. // It currently links to `Parametrized<bool>::Proj`. -// @has 'inherent_associated_types/type.Test1.html' -// @has - '//a/@href' 'struct.Parametrized.html#associatedtype.Proj' -// @!has - '//a/@href' 'struct.Parametrized.html#associatedtype.Proj-1' +//@ has 'inherent_associated_types/type.Test1.html' +//@ has - '//a/@href' 'struct.Parametrized.html#associatedtype.Proj' +//@ !has - '//a/@href' 'struct.Parametrized.html#associatedtype.Proj-1' /// [`Parametrized<i32>::Proj`] pub type Test1 = (); diff --git a/tests/rustdoc/intra-doc/issue-108459.rs b/tests/rustdoc/intra-doc/issue-108459.rs index b8cd478b4df..18424c069d3 100644 --- a/tests/rustdoc/intra-doc/issue-108459.rs +++ b/tests/rustdoc/intra-doc/issue-108459.rs @@ -13,26 +13,26 @@ pub struct MyStruct1; // the same target but different text /// See also [crate::char] and [mod@char] and [prim@char] -// @has issue_108459/struct.MyStruct2.html '//*[@href="char/index.html"]' 'crate::char' -// @has - '//*[@href="char/index.html"]' 'char' -// @has - '//*[@href="{{channel}}/std/primitive.char.html"]' 'char' +//@ has issue_108459/struct.MyStruct2.html '//*[@href="char/index.html"]' 'crate::char' +//@ has - '//*[@href="char/index.html"]' 'char' +//@ has - '//*[@href="{{channel}}/std/primitive.char.html"]' 'char' pub struct MyStruct2; /// See also [mod@char] and [prim@char] and [crate::char] -// @has issue_108459/struct.MyStruct3.html '//*[@href="char/index.html"]' 'crate::char' -// @has - '//*[@href="char/index.html"]' 'char' -// @has - '//*[@href="{{channel}}/std/primitive.char.html"]' 'char' +//@ has issue_108459/struct.MyStruct3.html '//*[@href="char/index.html"]' 'crate::char' +//@ has - '//*[@href="char/index.html"]' 'char' +//@ has - '//*[@href="{{channel}}/std/primitive.char.html"]' 'char' pub struct MyStruct3; // Ensure that links are correct even if there are multiple links with the same text but // different targets /// See also [char][mod@char] and [char][prim@char] -// @has issue_108459/struct.MyStruct4.html '//*[@href="char/index.html"]' 'char' -// @has - '//*[@href="{{channel}}/std/primitive.char.html"]' 'char' +//@ has issue_108459/struct.MyStruct4.html '//*[@href="char/index.html"]' 'char' +//@ has - '//*[@href="{{channel}}/std/primitive.char.html"]' 'char' pub struct MyStruct4; /// See also [char][prim@char] and [char][crate::char] -// @has issue_108459/struct.MyStruct5.html '//*[@href="char/index.html"]' 'char' -// @has - '//*[@href="{{channel}}/std/primitive.char.html"]' 'char' +//@ has issue_108459/struct.MyStruct5.html '//*[@href="char/index.html"]' 'char' +//@ has - '//*[@href="{{channel}}/std/primitive.char.html"]' 'char' pub struct MyStruct5; diff --git a/tests/rustdoc/intra-doc/issue-66159.rs b/tests/rustdoc/intra-doc/issue-66159.rs index b3e7f9171ad..5d50f63f299 100644 --- a/tests/rustdoc/intra-doc/issue-66159.rs +++ b/tests/rustdoc/intra-doc/issue-66159.rs @@ -6,5 +6,5 @@ // Since we don't generate the docs for the auxiliary files, we can't actually // verify that the struct is linked correctly. -// @has issue_66159/index.html +//@ has issue_66159/index.html //! [pub_struct::SomeStruct] diff --git a/tests/rustdoc/intra-doc/issue-82209.rs b/tests/rustdoc/intra-doc/issue-82209.rs index a5fe855cb36..46d028e535c 100644 --- a/tests/rustdoc/intra-doc/issue-82209.rs +++ b/tests/rustdoc/intra-doc/issue-82209.rs @@ -8,4 +8,4 @@ pub enum Foo { }, } -// @has foo/enum.Foo.html '//a/@href' 'enum.Foo.html#variant.Bar.field.abc' +//@ has foo/enum.Foo.html '//a/@href' 'enum.Foo.html#variant.Bar.field.abc' diff --git a/tests/rustdoc/intra-doc/macros-disambiguators.rs b/tests/rustdoc/intra-doc/macros-disambiguators.rs index cd4caa6a894..d84ab8011dc 100644 --- a/tests/rustdoc/intra-doc/macros-disambiguators.rs +++ b/tests/rustdoc/intra-doc/macros-disambiguators.rs @@ -2,22 +2,22 @@ #![deny(rustdoc::broken_intra_doc_links)] //! [foo!()] -// @has foo/index.html '//a[@href="macro.foo.html"]' 'foo!()' +//@ has foo/index.html '//a[@href="macro.foo.html"]' 'foo!()' //! [foo!{}] -// @has - '//a[@href="macro.foo.html"]' 'foo!{}' +//@ has - '//a[@href="macro.foo.html"]' 'foo!{}' //! [foo![]](foo![]) -// @has - '//a[@href="macro.foo.html"]' 'foo![]' +//@ has - '//a[@href="macro.foo.html"]' 'foo![]' //! [foo1](foo!()) -// @has - '//a[@href="macro.foo.html"]' 'foo1' +//@ has - '//a[@href="macro.foo.html"]' 'foo1' //! [foo2](foo!{}) -// @has - '//a[@href="macro.foo.html"]' 'foo2' +//@ has - '//a[@href="macro.foo.html"]' 'foo2' //! [foo3](foo![]) -// @has - '//a[@href="macro.foo.html"]' 'foo3' +//@ has - '//a[@href="macro.foo.html"]' 'foo3' #[macro_export] macro_rules! foo { diff --git a/tests/rustdoc/intra-doc/mod-ambiguity.rs b/tests/rustdoc/intra-doc/mod-ambiguity.rs index 0c7acbaf093..5e2b1ffe6f2 100644 --- a/tests/rustdoc/intra-doc/mod-ambiguity.rs +++ b/tests/rustdoc/intra-doc/mod-ambiguity.rs @@ -6,11 +6,11 @@ pub fn foo() { } pub mod foo {} -// @has mod_ambiguity/struct.A.html '//a/@href' 'foo/index.html' +//@ has mod_ambiguity/struct.A.html '//a/@href' 'foo/index.html' /// Module is [`module@foo`] pub struct A; -// @has mod_ambiguity/struct.B.html '//a/@href' 'fn.foo.html' +//@ has mod_ambiguity/struct.B.html '//a/@href' 'fn.foo.html' /// Function is [`fn@foo`] pub struct B; diff --git a/tests/rustdoc/intra-doc/mod-relative.rs b/tests/rustdoc/intra-doc/mod-relative.rs index 49d3399b972..d3239973d1c 100644 --- a/tests/rustdoc/intra-doc/mod-relative.rs +++ b/tests/rustdoc/intra-doc/mod-relative.rs @@ -8,8 +8,8 @@ pub mod wrapper { pub fn do_test(&self) {} } - // @has mod_relative/wrapper/demo/index.html - // @has - '//a/@href' '../struct.Test.html#method.do_test' + //@ has mod_relative/wrapper/demo/index.html + //@ has - '//a/@href' '../struct.Test.html#method.do_test' /// [`Test::do_test`] pub mod demo { } diff --git a/tests/rustdoc/intra-doc/module-scope-name-resolution-55364.rs b/tests/rustdoc/intra-doc/module-scope-name-resolution-55364.rs index c07aba628c9..06cb764423e 100644 --- a/tests/rustdoc/intra-doc/module-scope-name-resolution-55364.rs +++ b/tests/rustdoc/intra-doc/module-scope-name-resolution-55364.rs @@ -3,50 +3,50 @@ // First a module with inner documentation -// @has foo/subone/index.html +//@ has foo/subone/index.html // These foo/bar links in the module's documentation should refer inside `subone` -// @has - '//section[@id="main-content"]/details[@open=""]/div[@class="docblock"]//a[@href="fn.foo.html"]' 'foo' -// @has - '//section[@id="main-content"]/details[@open=""]/div[@class="docblock"]//a[@href="fn.bar.html"]' 'bar' +//@ has - '//section[@id="main-content"]/details[@open=""]/div[@class="docblock"]//a[@href="fn.foo.html"]' 'foo' +//@ has - '//section[@id="main-content"]/details[@open=""]/div[@class="docblock"]//a[@href="fn.bar.html"]' 'bar' pub mod subone { //! See either [foo] or [bar]. // This should refer to subone's `bar` - // @has foo/subone/fn.foo.html - // @has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="fn.bar.html"]' 'bar' + //@ has foo/subone/fn.foo.html + //@ has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="fn.bar.html"]' 'bar' /// See [bar] pub fn foo() {} // This should refer to subone's `foo` - // @has foo/subone/fn.bar.html - // @has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="fn.foo.html"]' 'foo' + //@ has foo/subone/fn.bar.html + //@ has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="fn.foo.html"]' 'foo' /// See [foo] pub fn bar() {} } // A module with outer documentation -// @has foo/subtwo/index.html +//@ has foo/subtwo/index.html // These foo/bar links in the module's documentation should not reference inside `subtwo` -// @!has - '//section[@id="main-content"]/div[@class="docblock"]//a[@href="fn.foo.html"]' 'foo' -// @!has - '//section[@id="main-content"]/div[@class="docblock"]//a[@href="fn.bar.html"]' 'bar' +//@ !has - '//section[@id="main-content"]/div[@class="docblock"]//a[@href="fn.foo.html"]' 'foo' +//@ !has - '//section[@id="main-content"]/div[@class="docblock"]//a[@href="fn.bar.html"]' 'bar' // Instead it should be referencing the top level functions -// @has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="../fn.foo.html"]' 'foo' -// @has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="../fn.bar.html"]' 'bar' +//@ has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="../fn.foo.html"]' 'foo' +//@ has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="../fn.bar.html"]' 'bar' // Though there should be such links later -// @has - '//section[@id="main-content"]/ul[@class="item-table"]//div[@class="item-name"]/a[@class="fn"][@href="fn.foo.html"]' 'foo' -// @has - '//section[@id="main-content"]/ul[@class="item-table"]//div[@class="item-name"]/a[@class="fn"][@href="fn.bar.html"]' 'bar' +//@ has - '//section[@id="main-content"]/ul[@class="item-table"]//div[@class="item-name"]/a[@class="fn"][@href="fn.foo.html"]' 'foo' +//@ has - '//section[@id="main-content"]/ul[@class="item-table"]//div[@class="item-name"]/a[@class="fn"][@href="fn.bar.html"]' 'bar' /// See either [foo] or [bar]. pub mod subtwo { // Despite the module's docs referring to the top level foo/bar, // this should refer to subtwo's `bar` - // @has foo/subtwo/fn.foo.html - // @has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="fn.bar.html"]' 'bar' + //@ has foo/subtwo/fn.foo.html + //@ has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="fn.bar.html"]' 'bar' /// See [bar] pub fn foo() {} // Despite the module's docs referring to the top level foo/bar, // this should refer to subtwo's `foo` - // @has foo/subtwo/fn.bar.html - // @has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="fn.foo.html"]' 'foo' + //@ has foo/subtwo/fn.bar.html + //@ has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="fn.foo.html"]' 'foo' /// See [foo] pub fn bar() {} } @@ -60,19 +60,19 @@ pub fn bar() {} // This module refers to the outer foo/bar by means of `super::` -// @has foo/subthree/index.html +//@ has foo/subthree/index.html // This module should also refer to the top level foo/bar -// @has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="../fn.foo.html"]' 'foo' -// @has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="../fn.bar.html"]' 'bar' +//@ has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="../fn.foo.html"]' 'foo' +//@ has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="../fn.bar.html"]' 'bar' pub mod subthree { //! See either [foo][super::foo] or [bar][super::bar] } // Next we go *deeper* - In order to ensure it's not just "this or parent" // we test `crate::` and a `super::super::...` chain -// @has foo/subfour/subfive/subsix/subseven/subeight/index.html -// @has - '//section[@id="main-content"]/ul[@class="item-table"]//div[@class="desc docblock-short"]//a[@href="../../../../../subone/fn.foo.html"]' 'other foo' -// @has - '//section[@id="main-content"]/ul[@class="item-table"]//div[@class="desc docblock-short"]//a[@href="../../../../../subtwo/fn.bar.html"]' 'other bar' +//@ has foo/subfour/subfive/subsix/subseven/subeight/index.html +//@ has - '//section[@id="main-content"]/ul[@class="item-table"]//div[@class="desc docblock-short"]//a[@href="../../../../../subone/fn.foo.html"]' 'other foo' +//@ has - '//section[@id="main-content"]/ul[@class="item-table"]//div[@class="desc docblock-short"]//a[@href="../../../../../subtwo/fn.bar.html"]' 'other bar' pub mod subfour { pub mod subfive { pub mod subsix { diff --git a/tests/rustdoc/intra-doc/nested-use.rs b/tests/rustdoc/intra-doc/nested-use.rs index 19ebfff1bce..2aaaed196fd 100644 --- a/tests/rustdoc/intra-doc/nested-use.rs +++ b/tests/rustdoc/intra-doc/nested-use.rs @@ -2,9 +2,9 @@ #![crate_name = "foo"] -// @has foo/struct.Foo.html -// @has - '//a[@href="struct.Foo.html"]' 'Foo' -// @has - '//a[@href="struct.Bar.html"]' 'Bar' +//@ has foo/struct.Foo.html +//@ has - '//a[@href="struct.Foo.html"]' 'Foo' +//@ has - '//a[@href="struct.Bar.html"]' 'Bar' /// [`Foo`] pub use m::{Foo, Bar}; diff --git a/tests/rustdoc/intra-doc/no-doc-primitive.rs b/tests/rustdoc/intra-doc/no-doc-primitive.rs index 711ac09ba9a..1f8622ab867 100644 --- a/tests/rustdoc/intra-doc/no-doc-primitive.rs +++ b/tests/rustdoc/intra-doc/no-doc-primitive.rs @@ -6,7 +6,7 @@ #![rustc_coherence_is_core] #![crate_type = "rlib"] -// @has no_doc_primitive/index.html +//@ has no_doc_primitive/index.html //! A [`char`] and its [`char::len_utf8`]. impl char { pub fn len_utf8(self) -> usize { diff --git a/tests/rustdoc/intra-doc/non-path-primitives.rs b/tests/rustdoc/intra-doc/non-path-primitives.rs index be4b44b3142..88edf12bfb5 100644 --- a/tests/rustdoc/intra-doc/non-path-primitives.rs +++ b/tests/rustdoc/intra-doc/non-path-primitives.rs @@ -2,45 +2,45 @@ #![feature(intra_doc_pointers)] #![deny(rustdoc::broken_intra_doc_links)] -// @has foo/index.html '//a[@href="{{channel}}/std/primitive.slice.html#method.rotate_left"]' 'slice::rotate_left' +//@ has foo/index.html '//a[@href="{{channel}}/std/primitive.slice.html#method.rotate_left"]' 'slice::rotate_left' //! [slice::rotate_left] -// @has - '//a[@href="{{channel}}/std/primitive.array.html#method.map"]' 'array::map' +//@ has - '//a[@href="{{channel}}/std/primitive.array.html#method.map"]' 'array::map' //! [array::map] -// @has - '//a[@href="{{channel}}/std/primitive.str.html"]' 'owned str' -// @has - '//a[@href="{{channel}}/std/primitive.str.html"]' 'str ref' -// @has - '//a[@href="{{channel}}/std/primitive.str.html#method.is_empty"]' 'str::is_empty' -// @has - '//a[@href="{{channel}}/std/primitive.str.html#method.len"]' '&str::len' +//@ has - '//a[@href="{{channel}}/std/primitive.str.html"]' 'owned str' +//@ has - '//a[@href="{{channel}}/std/primitive.str.html"]' 'str ref' +//@ has - '//a[@href="{{channel}}/std/primitive.str.html#method.is_empty"]' 'str::is_empty' +//@ has - '//a[@href="{{channel}}/std/primitive.str.html#method.len"]' '&str::len' //! [owned str][str] //! [str ref][&str] //! [str::is_empty] //! [&str::len] -// @has - '//a[@href="{{channel}}/std/primitive.pointer.html#method.is_null"]' 'pointer::is_null' -// @has - '//a[@href="{{channel}}/std/primitive.pointer.html#method.is_null"]' '*const::is_null' -// @has - '//a[@href="{{channel}}/std/primitive.pointer.html#method.is_null"]' '*mut::is_null' +//@ has - '//a[@href="{{channel}}/std/primitive.pointer.html#method.is_null"]' 'pointer::is_null' +//@ has - '//a[@href="{{channel}}/std/primitive.pointer.html#method.is_null"]' '*const::is_null' +//@ has - '//a[@href="{{channel}}/std/primitive.pointer.html#method.is_null"]' '*mut::is_null' //! [pointer::is_null] //! [*const::is_null] //! [*mut::is_null] -// @has - '//a[@href="{{channel}}/std/primitive.unit.html"]' 'unit' +//@ has - '//a[@href="{{channel}}/std/primitive.unit.html"]' 'unit' //! [unit] -// @has - '//a[@href="{{channel}}/std/primitive.tuple.html"]' 'tuple' +//@ has - '//a[@href="{{channel}}/std/primitive.tuple.html"]' 'tuple' //! [tuple] -// @has - '//a[@href="{{channel}}/std/primitive.reference.html"]' 'reference' -// @has - '//a[@href="{{channel}}/std/primitive.reference.html"]' '&' -// @has - '//a[@href="{{channel}}/std/primitive.reference.html"]' '&mut' +//@ has - '//a[@href="{{channel}}/std/primitive.reference.html"]' 'reference' +//@ has - '//a[@href="{{channel}}/std/primitive.reference.html"]' '&' +//@ has - '//a[@href="{{channel}}/std/primitive.reference.html"]' '&mut' //! [reference] //! [&] //! [&mut] -// @has - '//a[@href="{{channel}}/std/primitive.fn.html"]' 'fn' +//@ has - '//a[@href="{{channel}}/std/primitive.fn.html"]' 'fn' //! [fn] -// @has - '//a[@href="{{channel}}/std/primitive.never.html"]' 'never' -// @has - '//a[@href="{{channel}}/std/primitive.never.html"]' '!' +//@ has - '//a[@href="{{channel}}/std/primitive.never.html"]' 'never' +//@ has - '//a[@href="{{channel}}/std/primitive.never.html"]' '!' //! [never] //! [!] diff --git a/tests/rustdoc/intra-doc/prim-assoc.rs b/tests/rustdoc/intra-doc/prim-assoc.rs index dfa7db8a558..41695205d9d 100644 --- a/tests/rustdoc/intra-doc/prim-assoc.rs +++ b/tests/rustdoc/intra-doc/prim-assoc.rs @@ -1,4 +1,4 @@ #![deny(rustdoc::broken_intra_doc_links)] //! [i32::MAX] -// @has prim_assoc/index.html '//a[@href="{{channel}}/std/primitive.i32.html#associatedconstant.MAX"]' "i32::MAX" +//@ has prim_assoc/index.html '//a[@href="{{channel}}/std/primitive.i32.html#associatedconstant.MAX"]' "i32::MAX" diff --git a/tests/rustdoc/intra-doc/prim-associated-traits.rs b/tests/rustdoc/intra-doc/prim-associated-traits.rs index 71d7d2189e6..41a3931222f 100644 --- a/tests/rustdoc/intra-doc/prim-associated-traits.rs +++ b/tests/rustdoc/intra-doc/prim-associated-traits.rs @@ -1,24 +1,24 @@ #![feature(never_type)] use std::str::FromStr; -// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.f64.html#method.from_str"]' 'f64::from_str()' -// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.f32.html#method.from_str"]' 'f32::from_str()' -// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.isize.html#method.from_str"]' 'isize::from_str()' -// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.i8.html#method.from_str"]' 'i8::from_str()' -// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.i16.html#method.from_str"]' 'i16::from_str()' -// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.i32.html#method.from_str"]' 'i32::from_str()' -// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.i64.html#method.from_str"]' 'i64::from_str()' -// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.i128.html#method.from_str"]' 'i128::from_str()' -// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.usize.html#method.from_str"]' 'usize::from_str()' -// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.u8.html#method.from_str"]' 'u8::from_str()' -// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.u16.html#method.from_str"]' 'u16::from_str()' -// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.u32.html#method.from_str"]' 'u32::from_str()' -// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.u64.html#method.from_str"]' 'u64::from_str()' -// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.u128.html#method.from_str"]' 'u128::from_str()' -// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.char.html#method.from_str"]' 'char::from_str()' -// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.bool.html#method.from_str"]' 'bool::from_str()' -// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.str.html#method.eq"]' 'str::eq()' -// @has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.never.html#method.eq"]' 'never::eq()' +//@ has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.f64.html#method.from_str"]' 'f64::from_str()' +//@ has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.f32.html#method.from_str"]' 'f32::from_str()' +//@ has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.isize.html#method.from_str"]' 'isize::from_str()' +//@ has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.i8.html#method.from_str"]' 'i8::from_str()' +//@ has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.i16.html#method.from_str"]' 'i16::from_str()' +//@ has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.i32.html#method.from_str"]' 'i32::from_str()' +//@ has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.i64.html#method.from_str"]' 'i64::from_str()' +//@ has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.i128.html#method.from_str"]' 'i128::from_str()' +//@ has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.usize.html#method.from_str"]' 'usize::from_str()' +//@ has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.u8.html#method.from_str"]' 'u8::from_str()' +//@ has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.u16.html#method.from_str"]' 'u16::from_str()' +//@ has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.u32.html#method.from_str"]' 'u32::from_str()' +//@ has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.u64.html#method.from_str"]' 'u64::from_str()' +//@ has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.u128.html#method.from_str"]' 'u128::from_str()' +//@ has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.char.html#method.from_str"]' 'char::from_str()' +//@ has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.bool.html#method.from_str"]' 'bool::from_str()' +//@ has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.str.html#method.eq"]' 'str::eq()' +//@ has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.never.html#method.eq"]' 'never::eq()' /// [`f64::from_str()`] [`f32::from_str()`] [`isize::from_str()`] [`i8::from_str()`] /// [`i16::from_str()`] [`i32::from_str()`] [`i64::from_str()`] [`i128::from_str()`] /// [`u16::from_str()`] [`u32::from_str()`] [`u64::from_str()`] [`u128::from_str()`] diff --git a/tests/rustdoc/intra-doc/prim-methods-external-core.rs b/tests/rustdoc/intra-doc/prim-methods-external-core.rs index 76e96d7037f..41a07460b06 100644 --- a/tests/rustdoc/intra-doc/prim-methods-external-core.rs +++ b/tests/rustdoc/intra-doc/prim-methods-external-core.rs @@ -8,9 +8,9 @@ #![no_core] #![crate_type = "rlib"] -// @has prim_methods_external_core/index.html -// @has - '//*[@id="main-content"]//a[@href="../my_core/primitive.char.html"]' 'char' -// @has - '//*[@id="main-content"]//a[@href="../my_core/primitive.char.html#method.len_utf8"]' 'char::len_utf8' +//@ has prim_methods_external_core/index.html +//@ has - '//*[@id="main-content"]//a[@href="../my_core/primitive.char.html"]' 'char' +//@ has - '//*[@id="main-content"]//a[@href="../my_core/primitive.char.html#method.len_utf8"]' 'char::len_utf8' //! A [`char`] and its [`char::len_utf8`]. diff --git a/tests/rustdoc/intra-doc/prim-methods-local.rs b/tests/rustdoc/intra-doc/prim-methods-local.rs index 6de4ec1802f..a9e71c58be3 100644 --- a/tests/rustdoc/intra-doc/prim-methods-local.rs +++ b/tests/rustdoc/intra-doc/prim-methods-local.rs @@ -4,9 +4,9 @@ #![rustc_coherence_is_core] #![crate_type = "rlib"] -// @has prim_methods_local/index.html -// @has - '//*[@id="main-content"]//a[@href="primitive.char.html"]' 'char' -// @has - '//*[@id="main-content"]//a[@href="primitive.char.html#method.len_utf8"]' 'char::len_utf8' +//@ has prim_methods_local/index.html +//@ has - '//*[@id="main-content"]//a[@href="primitive.char.html"]' 'char' +//@ has - '//*[@id="main-content"]//a[@href="primitive.char.html#method.len_utf8"]' 'char::len_utf8' //! A [prim@`char`] and its [`char::len_utf8`]. diff --git a/tests/rustdoc/intra-doc/prim-methods.rs b/tests/rustdoc/intra-doc/prim-methods.rs index bc1965aac55..3ee7eba86ad 100644 --- a/tests/rustdoc/intra-doc/prim-methods.rs +++ b/tests/rustdoc/intra-doc/prim-methods.rs @@ -1,9 +1,9 @@ #![deny(rustdoc::broken_intra_doc_links)] -// @has prim_methods/index.html -// @has - '//*[@id="main-content"]//a[@href="{{channel}}/std/primitive.char.html"]' 'char' -// @has - '//*[@id="main-content"]//a[@href="{{channel}}/std/primitive.char.html"]/@title' 'primitive char' -// @has - '//*[@id="main-content"]//a[@href="{{channel}}/std/primitive.char.html#method.len_utf8"]' 'char::len_utf8' -// @has - '//*[@id="main-content"]//a[@href="{{channel}}/std/primitive.char.html#method.len_utf8"]/@title' 'method char::len_utf8' +//@ has prim_methods/index.html +//@ has - '//*[@id="main-content"]//a[@href="{{channel}}/std/primitive.char.html"]' 'char' +//@ has - '//*[@id="main-content"]//a[@href="{{channel}}/std/primitive.char.html"]/@title' 'primitive char' +//@ has - '//*[@id="main-content"]//a[@href="{{channel}}/std/primitive.char.html#method.len_utf8"]' 'char::len_utf8' +//@ has - '//*[@id="main-content"]//a[@href="{{channel}}/std/primitive.char.html#method.len_utf8"]/@title' 'method char::len_utf8' //! A [`char`] and its [`char::len_utf8`]. diff --git a/tests/rustdoc/intra-doc/prim-precedence.rs b/tests/rustdoc/intra-doc/prim-precedence.rs index c5a64e42a01..56d556e8f1d 100644 --- a/tests/rustdoc/intra-doc/prim-precedence.rs +++ b/tests/rustdoc/intra-doc/prim-precedence.rs @@ -2,15 +2,15 @@ pub mod char { /// [char] - // @has prim_precedence/char/struct.Inner.html '//a/@href' '{{channel}}/std/primitive.char.html' + //@ has prim_precedence/char/struct.Inner.html '//a/@href' '{{channel}}/std/primitive.char.html' pub struct Inner; } /// See [prim@char] -// @has prim_precedence/struct.MyString.html '//a/@href' '{{channel}}/std/primitive.char.html' +//@ has prim_precedence/struct.MyString.html '//a/@href' '{{channel}}/std/primitive.char.html' pub struct MyString; /// See also [crate::char] and [mod@char] -// @has prim_precedence/struct.MyString2.html '//*[@href="char/index.html"]' 'crate::char' -// @has - '//*[@href="char/index.html"]' 'char' +//@ has prim_precedence/struct.MyString2.html '//*[@href="char/index.html"]' 'crate::char' +//@ has - '//*[@href="char/index.html"]' 'char' pub struct MyString2; diff --git a/tests/rustdoc/intra-doc/prim-self.rs b/tests/rustdoc/intra-doc/prim-self.rs index d13858a53cf..d5bfd570d54 100644 --- a/tests/rustdoc/intra-doc/prim-self.rs +++ b/tests/rustdoc/intra-doc/prim-self.rs @@ -10,9 +10,9 @@ /// [Self::f] /// [Self::MAX] -// @has prim_self/primitive.usize.html -// @has - '//a[@href="primitive.usize.html#method.f"]' 'Self::f' -// @has - '//a[@href="primitive.usize.html#associatedconstant.MAX"]' 'Self::MAX' +//@ has prim_self/primitive.usize.html +//@ has - '//a[@href="primitive.usize.html#method.f"]' 'Self::f' +//@ has - '//a[@href="primitive.usize.html#associatedconstant.MAX"]' 'Self::MAX' impl usize { /// Some docs pub fn f() {} @@ -20,7 +20,7 @@ impl usize { /// 10 and 2^32 are basically the same. pub const MAX: usize = 10; - // @has - '//a[@href="primitive.usize.html#associatedtype.ME"]' 'Self::ME' + //@ has - '//a[@href="primitive.usize.html#associatedtype.ME"]' 'Self::ME' /// [Self::ME] pub type ME = usize; } diff --git a/tests/rustdoc/intra-doc/primitive-disambiguators.rs b/tests/rustdoc/intra-doc/primitive-disambiguators.rs index adcab767d0b..1d657b32f8b 100644 --- a/tests/rustdoc/intra-doc/primitive-disambiguators.rs +++ b/tests/rustdoc/intra-doc/primitive-disambiguators.rs @@ -1,4 +1,4 @@ #![deny(rustdoc::broken_intra_doc_links)] -// @has primitive_disambiguators/index.html -// @has - '//a/@href' '{{channel}}/std/primitive.str.html#method.trim' +//@ has primitive_disambiguators/index.html +//@ has - '//a/@href' '{{channel}}/std/primitive.str.html#method.trim' //! [str::trim()] diff --git a/tests/rustdoc/intra-doc/primitive-non-default-impl.rs b/tests/rustdoc/intra-doc/primitive-non-default-impl.rs index 474bf347750..66d82d04d7d 100644 --- a/tests/rustdoc/intra-doc/primitive-non-default-impl.rs +++ b/tests/rustdoc/intra-doc/primitive-non-default-impl.rs @@ -1,31 +1,31 @@ #![deny(rustdoc::broken_intra_doc_links)] -// @has primitive_non_default_impl/fn.str_methods.html +//@ has primitive_non_default_impl/fn.str_methods.html /// [`str::trim`] -// @has - '//*[@href="{{channel}}/std/primitive.str.html#method.trim"]' 'str::trim' +//@ has - '//*[@href="{{channel}}/std/primitive.str.html#method.trim"]' 'str::trim' /// [`str::to_lowercase`] -// @has - '//*[@href="{{channel}}/std/primitive.str.html#method.to_lowercase"]' 'str::to_lowercase' +//@ has - '//*[@href="{{channel}}/std/primitive.str.html#method.to_lowercase"]' 'str::to_lowercase' /// [`str::into_boxed_bytes`] -// @has - '//*[@href="{{channel}}/std/primitive.str.html#method.into_boxed_bytes"]' 'str::into_boxed_bytes' +//@ has - '//*[@href="{{channel}}/std/primitive.str.html#method.into_boxed_bytes"]' 'str::into_boxed_bytes' /// [`str::replace`] -// @has - '//*[@href="{{channel}}/std/primitive.str.html#method.replace"]' 'str::replace' +//@ has - '//*[@href="{{channel}}/std/primitive.str.html#method.replace"]' 'str::replace' pub fn str_methods() {} -// @has primitive_non_default_impl/fn.f32_methods.html +//@ has primitive_non_default_impl/fn.f32_methods.html /// [f32::powi] -// @has - '//*[@href="{{channel}}/std/primitive.f32.html#method.powi"]' 'f32::powi' +//@ has - '//*[@href="{{channel}}/std/primitive.f32.html#method.powi"]' 'f32::powi' /// [f32::sqrt] -// @has - '//*[@href="{{channel}}/std/primitive.f32.html#method.sqrt"]' 'f32::sqrt' +//@ has - '//*[@href="{{channel}}/std/primitive.f32.html#method.sqrt"]' 'f32::sqrt' /// [f32::mul_add] -// @has - '//*[@href="{{channel}}/std/primitive.f32.html#method.mul_add"]' 'f32::mul_add' +//@ has - '//*[@href="{{channel}}/std/primitive.f32.html#method.mul_add"]' 'f32::mul_add' pub fn f32_methods() {} -// @has primitive_non_default_impl/fn.f64_methods.html +//@ has primitive_non_default_impl/fn.f64_methods.html /// [`f64::powi`] -// @has - '//*[@href="{{channel}}/std/primitive.f64.html#method.powi"]' 'f64::powi' +//@ has - '//*[@href="{{channel}}/std/primitive.f64.html#method.powi"]' 'f64::powi' /// [`f64::sqrt`] -// @has - '//*[@href="{{channel}}/std/primitive.f64.html#method.sqrt"]' 'f64::sqrt' +//@ has - '//*[@href="{{channel}}/std/primitive.f64.html#method.sqrt"]' 'f64::sqrt' /// [`f64::mul_add`] -// @has - '//*[@href="{{channel}}/std/primitive.f64.html#method.mul_add"]' 'f64::mul_add' +//@ has - '//*[@href="{{channel}}/std/primitive.f64.html#method.mul_add"]' 'f64::mul_add' pub fn f64_methods() {} diff --git a/tests/rustdoc/intra-doc/private.rs b/tests/rustdoc/intra-doc/private.rs index d1ad210dc31..48d86a30768 100644 --- a/tests/rustdoc/intra-doc/private.rs +++ b/tests/rustdoc/intra-doc/private.rs @@ -7,9 +7,9 @@ #![crate_name = "private"] /// docs [DontDocMe] [DontDocMe::f] [DontDocMe::x] -// @has private/struct.DocMe.html '//*a[@href="struct.DontDocMe.html"]' 'DontDocMe' -// @has private/struct.DocMe.html '//*a[@href="struct.DontDocMe.html#method.f"]' 'DontDocMe::f' -// @has private/struct.DocMe.html '//*a[@href="struct.DontDocMe.html#structfield.x"]' 'DontDocMe::x' +//@ has private/struct.DocMe.html '//*a[@href="struct.DontDocMe.html"]' 'DontDocMe' +//@ has private/struct.DocMe.html '//*a[@href="struct.DontDocMe.html#method.f"]' 'DontDocMe::f' +//@ has private/struct.DocMe.html '//*a[@href="struct.DontDocMe.html#structfield.x"]' 'DontDocMe::x' pub struct DocMe; struct DontDocMe { x: usize, diff --git a/tests/rustdoc/intra-doc/proc-macro.rs b/tests/rustdoc/intra-doc/proc-macro.rs index e7c92259da1..ed18b9dbcfa 100644 --- a/tests/rustdoc/intra-doc/proc-macro.rs +++ b/tests/rustdoc/intra-doc/proc-macro.rs @@ -8,18 +8,18 @@ extern crate proc_macro_macro; pub use proc_macro_macro::{DeriveA, attr_a}; use proc_macro_macro::{DeriveB, attr_b}; -// @has proc_macro/struct.Foo.html -// @has - '//a/@href' 'derive.DeriveA.html' -// @has - '//a/@href' 'attr.attr_a.html' -// @has - '//a/@href' 'trait.DeriveTrait.html' -// @has - '//a/@href' '../proc_macro_macro/derive.DeriveB.html' -// @has - '//a/@href' '../proc_macro_macro/attr.attr_b.html' +//@ has proc_macro/struct.Foo.html +//@ has - '//a/@href' 'derive.DeriveA.html' +//@ has - '//a/@href' 'attr.attr_a.html' +//@ has - '//a/@href' 'trait.DeriveTrait.html' +//@ has - '//a/@href' '../proc_macro_macro/derive.DeriveB.html' +//@ has - '//a/@href' '../proc_macro_macro/attr.attr_b.html' /// Link to [DeriveA], [attr_a], [DeriveB], [attr_b], [DeriveTrait] pub struct Foo; -// @has proc_macro/struct.Bar.html -// @has - '//a/@href' 'derive.DeriveA.html' -// @has - '//a/@href' 'attr.attr_a.html' +//@ has proc_macro/struct.Bar.html +//@ has - '//a/@href' 'derive.DeriveA.html' +//@ has - '//a/@href' 'attr.attr_a.html' /// Link to [deriveA](derive@DeriveA) [attr](macro@attr_a) pub struct Bar; diff --git a/tests/rustdoc/intra-doc/pub-use.rs b/tests/rustdoc/intra-doc/pub-use.rs index f6347ed2eab..7c70adad7d9 100644 --- a/tests/rustdoc/intra-doc/pub-use.rs +++ b/tests/rustdoc/intra-doc/pub-use.rs @@ -5,13 +5,13 @@ extern crate inner; /// [mod@std::env] [g] -// @has outer/index.html -// @has - '//a[@href="{{channel}}/std/env/index.html"]' "std::env" -// @has - '//a[@href="fn.f.html"]' "g" +//@ has outer/index.html +//@ has - '//a[@href="{{channel}}/std/env/index.html"]' "std::env" +//@ has - '//a[@href="fn.f.html"]' "g" pub use f as g; // Make sure the documentation is actually correct by documenting an inlined re-export /// [mod@std::env] -// @has outer/fn.f.html -// @has - '//a[@href="{{channel}}/std/env/index.html"]' "std::env" +//@ has outer/fn.f.html +//@ has - '//a[@href="{{channel}}/std/env/index.html"]' "std::env" pub use inner::f; diff --git a/tests/rustdoc/intra-doc/raw-ident-self.rs b/tests/rustdoc/intra-doc/raw-ident-self.rs index 1ed33db9300..5aecfadb362 100644 --- a/tests/rustdoc/intra-doc/raw-ident-self.rs +++ b/tests/rustdoc/intra-doc/raw-ident-self.rs @@ -4,8 +4,8 @@ pub mod r#impl { impl S { /// See [Self::b]. - // @has raw_ident_self/impl/struct.S.html - // @has - '//a[@href="struct.S.html#method.b"]' 'Self::b' + //@ has raw_ident_self/impl/struct.S.html + //@ has - '//a[@href="struct.S.html#method.b"]' 'Self::b' pub fn a() {} pub fn b() {} diff --git a/tests/rustdoc/intra-doc/reexport-additional-docs.rs b/tests/rustdoc/intra-doc/reexport-additional-docs.rs index 7912fd3681e..1caa109d1fd 100644 --- a/tests/rustdoc/intra-doc/reexport-additional-docs.rs +++ b/tests/rustdoc/intra-doc/reexport-additional-docs.rs @@ -3,19 +3,19 @@ #![crate_name = "foo"] extern crate inner; -// @has foo/struct.Inner.html '//a[@href="fn.with_code.html"]' 'crate::with_code' +//@ has foo/struct.Inner.html '//a[@href="fn.with_code.html"]' 'crate::with_code' /// [crate::with_code] -// @has - '//a[@href="fn.with_code.html"]' 'different text' +//@ has - '//a[@href="fn.with_code.html"]' 'different text' /// [different text][with_code] -// @has - '//a[@href="fn.me_too.html"]' 'me_too' +//@ has - '//a[@href="fn.me_too.html"]' 'me_too' #[doc = "[me_too]"] -// @has - '//a[@href="fn.me_three.html"]' 'reference link' +//@ has - '//a[@href="fn.me_three.html"]' 'reference link' /// This [reference link] #[doc = "has an attr in the way"] /// /// [reference link]: me_three // Should still resolve links from the original module in that scope -// @has - '//a[@href="../inner/fn.f.html"]' 'f()' +//@ has - '//a[@href="../inner/fn.f.html"]' 'f()' pub use inner::Inner; pub fn with_code() {} diff --git a/tests/rustdoc/intra-doc/self-cache.rs b/tests/rustdoc/intra-doc/self-cache.rs index 63bf7fa5768..26cbeb56ad5 100644 --- a/tests/rustdoc/intra-doc/self-cache.rs +++ b/tests/rustdoc/intra-doc/self-cache.rs @@ -1,12 +1,12 @@ #![crate_name = "foo"] -// @has foo/enum.E1.html '//a/@href' 'enum.E1.html#variant.A' +//@ has foo/enum.E1.html '//a/@href' 'enum.E1.html#variant.A' /// [Self::A::b] pub enum E1 { A { b: usize } } -// @has foo/enum.E2.html '//a/@href' 'enum.E2.html#variant.A' +//@ has foo/enum.E2.html '//a/@href' 'enum.E2.html#variant.A' /// [Self::A::b] pub enum E2 { diff --git a/tests/rustdoc/intra-doc/self.rs b/tests/rustdoc/intra-doc/self.rs index 0ba7df8a78a..2c33be781e2 100644 --- a/tests/rustdoc/intra-doc/self.rs +++ b/tests/rustdoc/intra-doc/self.rs @@ -1,8 +1,8 @@ #![crate_name = "foo"] -// @has foo/index.html '//a/@href' 'struct.Foo.html#method.new' -// @has foo/struct.Foo.html '//a/@href' 'struct.Foo.html#method.new' +//@ has foo/index.html '//a/@href' 'struct.Foo.html#method.new' +//@ has foo/struct.Foo.html '//a/@href' 'struct.Foo.html#method.new' /// Use [`new`] to create a new instance. /// @@ -15,8 +15,8 @@ impl Foo { } } -// @has foo/index.html '//a/@href' 'struct.Bar.html#method.new2' -// @has foo/struct.Bar.html '//a/@href' 'struct.Bar.html#method.new2' +//@ has foo/index.html '//a/@href' 'struct.Bar.html#method.new2' +//@ has foo/struct.Bar.html '//a/@href' 'struct.Bar.html#method.new2' /// Use [`new2`] to create a new instance. /// @@ -30,7 +30,7 @@ impl Bar { } pub struct MyStruct { - // @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#structfield.struct_field' + //@ has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#structfield.struct_field' /// [`struct_field`] /// @@ -39,7 +39,7 @@ pub struct MyStruct { } pub enum MyEnum { - // @has foo/enum.MyEnum.html '//a/@href' 'enum.MyEnum.html#variant.EnumVariant' + //@ has foo/enum.MyEnum.html '//a/@href' 'enum.MyEnum.html#variant.EnumVariant' /// [`EnumVariant`] /// @@ -48,7 +48,7 @@ pub enum MyEnum { } pub union MyUnion { - // @has foo/union.MyUnion.html '//a/@href' 'union.MyUnion.html#structfield.union_field' + //@ has foo/union.MyUnion.html '//a/@href' 'union.MyUnion.html#structfield.union_field' /// [`union_field`] /// @@ -57,21 +57,21 @@ pub union MyUnion { } pub trait MyTrait { - // @has foo/trait.MyTrait.html '//a/@href' 'trait.MyTrait.html#associatedtype.AssoType' + //@ has foo/trait.MyTrait.html '//a/@href' 'trait.MyTrait.html#associatedtype.AssoType' /// [`AssoType`] /// /// [`AssoType`]: Self::AssoType type AssoType; - // @has foo/trait.MyTrait.html '//a/@href' 'trait.MyTrait.html#associatedconstant.ASSO_CONST' + //@ has foo/trait.MyTrait.html '//a/@href' 'trait.MyTrait.html#associatedconstant.ASSO_CONST' /// [`ASSO_CONST`] /// /// [`ASSO_CONST`]: Self::ASSO_CONST const ASSO_CONST: i32 = 1; - // @has foo/trait.MyTrait.html '//a/@href' 'trait.MyTrait.html#method.asso_fn' + //@ has foo/trait.MyTrait.html '//a/@href' 'trait.MyTrait.html#method.asso_fn' /// [`asso_fn`] /// @@ -80,7 +80,7 @@ pub trait MyTrait { } impl MyStruct { - // @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#method.for_impl' + //@ has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#method.for_impl' /// [`for_impl`] /// @@ -91,21 +91,21 @@ impl MyStruct { } impl MyTrait for MyStruct { - // @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#associatedtype.AssoType' + //@ has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#associatedtype.AssoType' /// [`AssoType`] /// /// [`AssoType`]: Self::AssoType type AssoType = u32; - // @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#associatedconstant.ASSO_CONST' + //@ has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#associatedconstant.ASSO_CONST' /// [`ASSO_CONST`] /// /// [`ASSO_CONST`]: Self::ASSO_CONST const ASSO_CONST: i32 = 10; - // @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#method.asso_fn' + //@ has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#method.asso_fn' /// [`asso_fn`] /// diff --git a/tests/rustdoc/intra-doc/trait-impl.rs b/tests/rustdoc/intra-doc/trait-impl.rs index cf60dc1dbd5..925a63187f4 100644 --- a/tests/rustdoc/intra-doc/trait-impl.rs +++ b/tests/rustdoc/intra-doc/trait-impl.rs @@ -5,21 +5,21 @@ pub struct MyStruct; impl MyTrait for MyStruct { -// @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#associatedtype.AssoType' +//@ has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#associatedtype.AssoType' /// [`AssoType`] /// /// [`AssoType`]: MyStruct::AssoType type AssoType = u32; -// @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#associatedconstant.ASSO_CONST' +//@ has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#associatedconstant.ASSO_CONST' /// [`ASSO_CONST`] /// /// [`ASSO_CONST`]: MyStruct::ASSO_CONST const ASSO_CONST: i32 = 10; -// @has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#method.trait_fn' +//@ has foo/struct.MyStruct.html '//a/@href' 'struct.MyStruct.html#method.trait_fn' /// [`trait_fn`] /// diff --git a/tests/rustdoc/intra-doc/trait-item.rs b/tests/rustdoc/intra-doc/trait-item.rs index e95dba33b5f..2563a768cc3 100644 --- a/tests/rustdoc/intra-doc/trait-item.rs +++ b/tests/rustdoc/intra-doc/trait-item.rs @@ -2,8 +2,8 @@ /// Link to [S::assoc_fn()] /// Link to [Default::default()] -// @has trait_item/struct.S.html '//*[@href="struct.S.html#method.assoc_fn"]' 'S::assoc_fn()' -// @has - '//*[@href="{{channel}}/core/default/trait.Default.html#tymethod.default"]' 'Default::default()' +//@ has trait_item/struct.S.html '//*[@href="struct.S.html#method.assoc_fn"]' 'S::assoc_fn()' +//@ has - '//*[@href="{{channel}}/core/default/trait.Default.html#tymethod.default"]' 'Default::default()' pub struct S; impl S { diff --git a/tests/rustdoc/intra-doc/true-false.rs b/tests/rustdoc/intra-doc/true-false.rs index e02be9cabd2..ce38ee11d5c 100644 --- a/tests/rustdoc/intra-doc/true-false.rs +++ b/tests/rustdoc/intra-doc/true-false.rs @@ -1,8 +1,8 @@ #![deny(rustdoc::broken_intra_doc_links)] #![crate_name = "foo"] -// @has foo/index.html -// @has - '//*[@id="main-content"]//a[@href="{{channel}}/std/primitive.bool.html"]' 'true' -// @has - '//*[@id="main-content"]//a[@href="{{channel}}/std/primitive.bool.html"]' 'false' +//@ has foo/index.html +//@ has - '//*[@id="main-content"]//a[@href="{{channel}}/std/primitive.bool.html"]' 'true' +//@ has - '//*[@id="main-content"]//a[@href="{{channel}}/std/primitive.bool.html"]' 'false' //! A `bool` is either [`true`] or [`false`]. diff --git a/tests/rustdoc/intra-doc/type-alias.rs b/tests/rustdoc/intra-doc/type-alias.rs index 6c52082a277..43e27483445 100644 --- a/tests/rustdoc/intra-doc/type-alias.rs +++ b/tests/rustdoc/intra-doc/type-alias.rs @@ -15,5 +15,5 @@ impl Bar { /// The minimum is [`Self::MIN`]. pub type Int = i32; -// @has foo/type.Bar.html '//a[@href="struct.Foo.html#method.bar"]' 'Self::bar' -// @has foo/type.Int.html '//a[@href="{{channel}}/std/primitive.i32.html#associatedconstant.MIN"]' 'Self::MIN' +//@ has foo/type.Bar.html '//a[@href="struct.Foo.html#method.bar"]' 'Self::bar' +//@ has foo/type.Int.html '//a[@href="{{channel}}/std/primitive.i32.html#associatedconstant.MIN"]' 'Self::MIN' diff --git a/tests/rustdoc/issue-100204-inline-impl-through-glob-import.rs b/tests/rustdoc/issue-100204-inline-impl-through-glob-import.rs index 95fd3c12d6f..7f05e57ec09 100644 --- a/tests/rustdoc/issue-100204-inline-impl-through-glob-import.rs +++ b/tests/rustdoc/issue-100204-inline-impl-through-glob-import.rs @@ -8,7 +8,7 @@ extern crate first; pub mod prelude {} -// @has first/struct.Bot.html '//h4[@class="code-header"]' 'pub fn new() -> Bot' -// @has second/struct.Bot.html '//h4[@class="code-header"]' 'pub fn new() -> Bot' +//@ has first/struct.Bot.html '//h4[@class="code-header"]' 'pub fn new() -> Bot' +//@ has second/struct.Bot.html '//h4[@class="code-header"]' 'pub fn new() -> Bot' #[doc(inline)] pub use first::*; diff --git a/tests/rustdoc/issue-101743-bold-tag.rs b/tests/rustdoc/issue-101743-bold-tag.rs index 631181fec66..a81767eeeeb 100644 --- a/tests/rustdoc/issue-101743-bold-tag.rs +++ b/tests/rustdoc/issue-101743-bold-tag.rs @@ -14,6 +14,6 @@ impl<const B: Word> Repr<B> { // If we change back to rendering the value of consts, check this doesn't add // a <b> tag, but escapes correctly - // @has foo/struct.Repr.html '//section[@id="associatedconstant.BASE"]/h4' '= _' + //@ has foo/struct.Repr.html '//section[@id="associatedconstant.BASE"]/h4' '= _' pub const BASE: IBig = base_as_ibig::<B>(); } diff --git a/tests/rustdoc/issue-105735-overlapping-reexport-2.rs b/tests/rustdoc/issue-105735-overlapping-reexport-2.rs index 2905e7d44bc..946184c5a04 100644 --- a/tests/rustdoc/issue-105735-overlapping-reexport-2.rs +++ b/tests/rustdoc/issue-105735-overlapping-reexport-2.rs @@ -3,13 +3,13 @@ #![crate_name = "foo"] #![no_std] -// @has 'foo/index.html' -// @has - '//*[@class="item-name"]/a[@class="type"]' 'AtomicU8' -// @has - '//*[@class="item-name"]/a[@class="constant"]' 'AtomicU8' +//@ has 'foo/index.html' +//@ has - '//*[@class="item-name"]/a[@class="type"]' 'AtomicU8' +//@ has - '//*[@class="item-name"]/a[@class="constant"]' 'AtomicU8' // We also ensure we don't have another item displayed. -// @count - '//*[@id="main-content"]/*[@class="section-header"]' 2 -// @has - '//*[@id="main-content"]/*[@class="section-header"]' 'Type Aliases' -// @has - '//*[@id="main-content"]/*[@class="section-header"]' 'Constants' +//@ count - '//*[@id="main-content"]/*[@class="section-header"]' 2 +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Type Aliases' +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Constants' mod other { pub type AtomicU8 = (); diff --git a/tests/rustdoc/issue-105735-overlapping-reexport.rs b/tests/rustdoc/issue-105735-overlapping-reexport.rs index 7fa7df7701a..0fd17fd9577 100644 --- a/tests/rustdoc/issue-105735-overlapping-reexport.rs +++ b/tests/rustdoc/issue-105735-overlapping-reexport.rs @@ -3,13 +3,13 @@ #![crate_name = "foo"] #![no_std] -// @has 'foo/index.html' -// @has - '//*[@class="item-name"]/a[@class="struct"]' 'AtomicU8' -// @has - '//*[@class="item-name"]/a[@class="constant"]' 'AtomicU8' +//@ has 'foo/index.html' +//@ has - '//*[@class="item-name"]/a[@class="struct"]' 'AtomicU8' +//@ has - '//*[@class="item-name"]/a[@class="constant"]' 'AtomicU8' // We also ensure we don't have another item displayed. -// @count - '//*[@id="main-content"]/*[@class="section-header"]' 2 -// @has - '//*[@id="main-content"]/*[@class="section-header"]' 'Structs' -// @has - '//*[@id="main-content"]/*[@class="section-header"]' 'Constants' +//@ count - '//*[@id="main-content"]/*[@class="section-header"]' 2 +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Structs' +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Constants' mod thing { pub use core::sync::atomic::AtomicU8; diff --git a/tests/rustdoc/issue-105952.rs b/tests/rustdoc/issue-105952.rs index e3f1df0063d..173efb82f4b 100644 --- a/tests/rustdoc/issue-105952.rs +++ b/tests/rustdoc/issue-105952.rs @@ -9,6 +9,6 @@ pub trait Parse { } pub trait RenderRaw {} -// @hasraw foo/trait.RenderRaw.html 'impl' -// @hasraw foo/trait.RenderRaw.html 'ParseMode::Raw' +//@ hasraw foo/trait.RenderRaw.html 'impl' +//@ hasraw foo/trait.RenderRaw.html 'ParseMode::Raw' impl<T: Parse<PARSE_MODE = { ParseMode::Raw }>> RenderRaw for T {} diff --git a/tests/rustdoc/issue-106142.rs b/tests/rustdoc/issue-106142.rs index 41505e72405..52adc5dbbf1 100644 --- a/tests/rustdoc/issue-106142.rs +++ b/tests/rustdoc/issue-106142.rs @@ -1,5 +1,5 @@ -// @has 'issue_106142/a/index.html' -// @count 'issue_106142/a/index.html' '//ul[@class="item-table"]//li//a' 1 +//@ has 'issue_106142/a/index.html' +//@ count 'issue_106142/a/index.html' '//ul[@class="item-table"]//li//a' 1 #![allow(rustdoc::broken_intra_doc_links)] diff --git a/tests/rustdoc/issue-106421-not-internal.rs b/tests/rustdoc/issue-106421-not-internal.rs index 1d744fba53f..f328a1036eb 100644 --- a/tests/rustdoc/issue-106421-not-internal.rs +++ b/tests/rustdoc/issue-106421-not-internal.rs @@ -4,5 +4,5 @@ // In this case, the item shouldn't be documented, because regular users can't get at it. extern crate foo; -// @!has issue_106421_not_internal/struct.FatalError.html '//*[@id="method.raise"]' 'fn raise' +//@ !has issue_106421_not_internal/struct.FatalError.html '//*[@id="method.raise"]' 'fn raise' pub use foo::FatalError; diff --git a/tests/rustdoc/issue-106421.rs b/tests/rustdoc/issue-106421.rs index d4141a4ab0c..c2064c71090 100644 --- a/tests/rustdoc/issue-106421.rs +++ b/tests/rustdoc/issue-106421.rs @@ -4,5 +4,5 @@ extern crate foo; -// @has issue_106421/struct.FatalError.html '//*[@id="method.raise"]' 'fn raise' +//@ has issue_106421/struct.FatalError.html '//*[@id="method.raise"]' 'fn raise' pub use foo::FatalError; diff --git a/tests/rustdoc/issue-107350.rs b/tests/rustdoc/issue-107350.rs index 75f378ed249..4ec9133e2d2 100644 --- a/tests/rustdoc/issue-107350.rs +++ b/tests/rustdoc/issue-107350.rs @@ -3,7 +3,7 @@ #![crate_name = "foo"] -// @has 'foo/oops/enum.OhNo.html' +//@ has 'foo/oops/enum.OhNo.html' pub mod oops { pub use crate::oops::OhNo; diff --git a/tests/rustdoc/issue-107995.rs b/tests/rustdoc/issue-107995.rs index 1273e4fdd12..57669909aa1 100644 --- a/tests/rustdoc/issue-107995.rs +++ b/tests/rustdoc/issue-107995.rs @@ -2,26 +2,26 @@ #![crate_name = "foo"] -// @has 'foo/fn.foo.html' -// @has - '//*[@class="docblock"]//a[@href="fn.bar.html"]' 'bar`' +//@ has 'foo/fn.foo.html' +//@ has - '//*[@class="docblock"]//a[@href="fn.bar.html"]' 'bar`' /// A foo, see also [ bar`] pub fn foo() {} -// @has 'foo/fn.bar.html' -// @has - '//*[@class="docblock"]' 'line Path line' -// @has - '//*[@class="docblock"]//a[@href="struct.Path.html"]' 'Path' +//@ has 'foo/fn.bar.html' +//@ has - '//*[@class="docblock"]' 'line Path line' +//@ has - '//*[@class="docblock"]//a[@href="struct.Path.html"]' 'Path' #[doc = "line ["] #[doc = "Path"] #[doc = "] line"] pub fn bar() {} -// @has 'foo/fn.another.html' -// @has - '//*[@class="docblock"]//a[@href="struct.Path.html"]' 'Path' +//@ has 'foo/fn.another.html' +//@ has - '//*[@class="docblock"]//a[@href="struct.Path.html"]' 'Path' /// [ `Path`] pub fn another() {} -// @has 'foo/fn.last.html' -// @has - '//*[@class="docblock"]//a[@href="struct.Path.html"]' 'Path' +//@ has 'foo/fn.last.html' +//@ has - '//*[@class="docblock"]//a[@href="struct.Path.html"]' 'Path' /// [ Path`] pub fn last() {} diff --git a/tests/rustdoc/issue-108231.rs b/tests/rustdoc/issue-108231.rs index 684f0494fd5..0d3ad1b0571 100644 --- a/tests/rustdoc/issue-108231.rs +++ b/tests/rustdoc/issue-108231.rs @@ -4,9 +4,9 @@ #![crate_name = "foo"] -// @has 'foo/index.html' -// @count - '//*[@id="main-content"]//a[@class="macro"]' 1 -// @has - '//*[@id="main-content"]//a[@class="macro"]' 'foo' +//@ has 'foo/index.html' +//@ count - '//*[@id="main-content"]//a[@class="macro"]' 1 +//@ has - '//*[@id="main-content"]//a[@class="macro"]' 'foo' #[doc(hidden)] pub mod __internal { diff --git a/tests/rustdoc/issue-108281.rs b/tests/rustdoc/issue-108281.rs index 8e1b6ba88a6..ba6c570b59b 100644 --- a/tests/rustdoc/issue-108281.rs +++ b/tests/rustdoc/issue-108281.rs @@ -3,7 +3,7 @@ #![crate_name = "foo"] -// @has 'foo/index.html' +//@ has 'foo/index.html' #[doc(hidden)] pub fn bar() {} @@ -11,15 +11,15 @@ mod sub { pub fn public() {} } -// @matches - '//*[@class="desc docblock-short"]' '^Displayed$' +//@ matches - '//*[@class="desc docblock-short"]' '^Displayed$' /// Displayed #[doc(inline)] pub use crate::bar as Bar; -// @matches - '//*[@class="desc docblock-short"]' '^Hello\sDisplayed$' +//@ matches - '//*[@class="desc docblock-short"]' '^Hello\sDisplayed$' #[doc(inline)] /// Hello pub use crate::Bar as Bar2; -// @matches - '//*[@class="desc docblock-short"]' '^Public$' +//@ matches - '//*[@class="desc docblock-short"]' '^Public$' /// Public pub use crate::sub::public as Public; diff --git a/tests/rustdoc/issue-108679-reexport-of-reexport.rs b/tests/rustdoc/issue-108679-reexport-of-reexport.rs index 5f977801cfd..5c1b4bcbd83 100644 --- a/tests/rustdoc/issue-108679-reexport-of-reexport.rs +++ b/tests/rustdoc/issue-108679-reexport-of-reexport.rs @@ -5,12 +5,12 @@ #![crate_name = "foo"] pub mod a { - // @has 'foo/a/index.html' + //@ has 'foo/a/index.html' // Should only contain "Structs". - // @count - '//*[@id="main-content"]//*[@class="item-table"]' 1 - // @has - '//*[@id="structs"]' 'Structs' - // @has - '//*[@id="main-content"]//a[@href="struct.A.html"]' 'A' - // @has - '//*[@id="main-content"]//a[@href="struct.B.html"]' 'B' + //@ count - '//*[@id="main-content"]//*[@class="item-table"]' 1 + //@ has - '//*[@id="structs"]' 'Structs' + //@ has - '//*[@id="main-content"]//a[@href="struct.A.html"]' 'A' + //@ has - '//*[@id="main-content"]//a[@href="struct.B.html"]' 'B' mod b { pub struct B; } @@ -18,12 +18,12 @@ pub mod a { pub struct A; } -// @has 'foo/index.html' -// @!has - '//*[@id="structs"]' 'Structs' -// @has - '//*[@id="reexports"]' 'Re-exports' -// @has - '//*[@id="modules"]' 'Modules' -// @has - '//*[@id="main-content"]//*[@id="reexport.A"]' 'pub use self::a::A;' -// @has - '//*[@id="main-content"]//*[@id="reexport.B"]' 'pub use self::a::B;' +//@ has 'foo/index.html' +//@ !has - '//*[@id="structs"]' 'Structs' +//@ has - '//*[@id="reexports"]' 'Re-exports' +//@ has - '//*[@id="modules"]' 'Modules' +//@ has - '//*[@id="main-content"]//*[@id="reexport.A"]' 'pub use self::a::A;' +//@ has - '//*[@id="main-content"]//*[@id="reexport.B"]' 'pub use self::a::B;' // Should only contain "Modules" and "Re-exports". -// @count - '//*[@id="main-content"]//*[@class="item-table"]' 2 +//@ count - '//*[@id="main-content"]//*[@class="item-table"]' 2 pub use self::a::{A, B}; diff --git a/tests/rustdoc/issue-108925.rs b/tests/rustdoc/issue-108925.rs index 9c36d0d71c4..a332771616d 100644 --- a/tests/rustdoc/issue-108925.rs +++ b/tests/rustdoc/issue-108925.rs @@ -1,7 +1,7 @@ -// @has issue_108925/enum.MyThing.html -// @has - '//code' 'Shown' -// @!has - '//code' 'NotShown' -// @!has - '//code' '// some variants omitted' +//@ has issue_108925/enum.MyThing.html +//@ has - '//code' 'Shown' +//@ !has - '//code' 'NotShown' +//@ !has - '//code' '// some variants omitted' #[non_exhaustive] pub enum MyThing { Shown, diff --git a/tests/rustdoc/issue-108931-anonymous-reexport.rs b/tests/rustdoc/issue-108931-anonymous-reexport.rs index 302f7413398..300ee3baf05 100644 --- a/tests/rustdoc/issue-108931-anonymous-reexport.rs +++ b/tests/rustdoc/issue-108931-anonymous-reexport.rs @@ -10,12 +10,12 @@ mod bar { pub struct Bar; } -// @has 'foo/index.html' +//@ has 'foo/index.html' // We check that the only "h2" present are "Re-exports" and "Modules". -// @count - '//*[@id="main-content"]/h2' 2 -// @has - '//*[@id="main-content"]/h2' 'Re-exports' -// @has - '//*[@id="main-content"]/h2' 'Modules' -// @has - '//*[@id="main-content"]//*[@class="item-table"]//li//code' 'pub use foo::Foo as _;' -// @has - '//*[@id="main-content"]//*[@class="item-table"]//li//code' 'pub use bar::Bar as _;' +//@ count - '//*[@id="main-content"]/h2' 2 +//@ has - '//*[@id="main-content"]/h2' 'Re-exports' +//@ has - '//*[@id="main-content"]/h2' 'Modules' +//@ has - '//*[@id="main-content"]//*[@class="item-table"]//li//code' 'pub use foo::Foo as _;' +//@ has - '//*[@id="main-content"]//*[@class="item-table"]//li//code' 'pub use bar::Bar as _;' pub use foo::Foo as _; pub use bar::Bar as _; diff --git a/tests/rustdoc/issue-109258-missing-private-inlining.rs b/tests/rustdoc/issue-109258-missing-private-inlining.rs index 12c5556f132..7f010f160c4 100644 --- a/tests/rustdoc/issue-109258-missing-private-inlining.rs +++ b/tests/rustdoc/issue-109258-missing-private-inlining.rs @@ -2,23 +2,23 @@ #![crate_name = "foo"] -// @has 'foo/index.html' +//@ has 'foo/index.html' // We should only have a "Re-exports" and a "Modules" headers. -// @count - '//*[@id="main-content"]/h2[@class="section-header"]' 2 -// @has - '//*[@id="main-content"]/h2[@class="section-header"]' 'Re-exports' -// @has - '//*[@id="main-content"]/h2[@class="section-header"]' 'Modules' +//@ count - '//*[@id="main-content"]/h2[@class="section-header"]' 2 +//@ has - '//*[@id="main-content"]/h2[@class="section-header"]' 'Re-exports' +//@ has - '//*[@id="main-content"]/h2[@class="section-header"]' 'Modules' -// @has - '//*[@id="reexport.Foo"]' 'pub use crate::issue_109258::Foo;' -// @has - '//*[@id="reexport.Foo"]//a[@href="issue_109258/struct.Foo.html"]' 'Foo' -// @!has 'foo/struct.Foo.html' +//@ has - '//*[@id="reexport.Foo"]' 'pub use crate::issue_109258::Foo;' +//@ has - '//*[@id="reexport.Foo"]//a[@href="issue_109258/struct.Foo.html"]' 'Foo' +//@ !has 'foo/struct.Foo.html' pub use crate::issue_109258::Foo; -// @has 'foo/issue_109258/index.html' +//@ has 'foo/issue_109258/index.html' // We should only have a "Structs" header. -// @count - '//*[@id="main-content"]/h2[@class="section-header"]' 1 -// @has - '//*[@id="main-content"]/h2[@class="section-header"]' 'Structs' -// @has - '//*[@id="main-content"]//a[@href="struct.Foo.html"]' 'Foo' -// @has 'foo/issue_109258/struct.Foo.html' +//@ count - '//*[@id="main-content"]/h2[@class="section-header"]' 1 +//@ has - '//*[@id="main-content"]/h2[@class="section-header"]' 'Structs' +//@ has - '//*[@id="main-content"]//a[@href="struct.Foo.html"]' 'Foo' +//@ has 'foo/issue_109258/struct.Foo.html' pub mod issue_109258 { mod priv_mod { pub struct Foo; diff --git a/tests/rustdoc/issue-109449-doc-hidden-reexports.rs b/tests/rustdoc/issue-109449-doc-hidden-reexports.rs index 9fb2f7c7c05..cc3679f6196 100644 --- a/tests/rustdoc/issue-109449-doc-hidden-reexports.rs +++ b/tests/rustdoc/issue-109449-doc-hidden-reexports.rs @@ -23,75 +23,75 @@ pub struct FooFoo; // Checking that re-exporting a `#[doc(hidden)]` item will NOT inline it. pub mod single_reexport { - // @has 'foo/single_reexport/index.html' + //@ has 'foo/single_reexport/index.html' // First we check that we have 4 type aliases. - // @count - '//*[@id="main-content"]/*[@class="item-table"]//code' 4 + //@ count - '//*[@id="main-content"]/*[@class="item-table"]//code' 4 // Then we check that we have the correct link for each re-export. - // @!has - '//*[@href="struct.Foo.html"]' 'Foo' - // @has - '//*[@id="reexport.Foo"]/code' 'pub use crate::private_module::Public as Foo;' + //@ !has - '//*[@href="struct.Foo.html"]' 'Foo' + //@ has - '//*[@id="reexport.Foo"]/code' 'pub use crate::private_module::Public as Foo;' pub use crate::private_module::Public as Foo; - // @!has - '//*[@href="type.Foo2.html"]' 'Foo2' - // @has - '//*[@id="reexport.Foo2"]/code' 'pub use crate::private_module::Bar as Foo2;' + //@ !has - '//*[@href="type.Foo2.html"]' 'Foo2' + //@ has - '//*[@id="reexport.Foo2"]/code' 'pub use crate::private_module::Bar as Foo2;' pub use crate::private_module::Bar as Foo2; - // @!has - '//*[@href="type.Yo.html"]' 'Yo' - // @has - '//*[@id="reexport.Yo"]/code' 'pub use crate::Bar3 as Yo;' + //@ !has - '//*[@href="type.Yo.html"]' 'Yo' + //@ has - '//*[@id="reexport.Yo"]/code' 'pub use crate::Bar3 as Yo;' pub use crate::Bar3 as Yo; - // @!has - '//*[@href="struct.Yo2.html"]' 'Yo2' - // @has - '//*[@id="reexport.Yo2"]/code' 'pub use crate::FooFoo as Yo2;' + //@ !has - '//*[@href="struct.Yo2.html"]' 'Yo2' + //@ has - '//*[@id="reexport.Yo2"]/code' 'pub use crate::FooFoo as Yo2;' pub use crate::FooFoo as Yo2; // Checking that each file is also created as expected. - // @!has 'foo/single_reexport/struct.Foo.html' - // @!has 'foo/single_reexport/type.Foo2.html' - // @!has 'foo/single_reexport/type.Yo.html' - // @!has 'foo/single_reexport/struct.Yo2.html' + //@ !has 'foo/single_reexport/struct.Foo.html' + //@ !has 'foo/single_reexport/type.Foo2.html' + //@ !has 'foo/single_reexport/type.Yo.html' + //@ !has 'foo/single_reexport/struct.Yo2.html' } // However, re-exporting an item inheriting `#[doc(hidden)]` will inline it. pub mod single_reexport_inherit_hidden { - // @has 'foo/single_reexport_inherit_hidden/index.html' + //@ has 'foo/single_reexport_inherit_hidden/index.html' - // @has - '//*[@href="struct.Foo3.html"]' 'Foo3' + //@ has - '//*[@href="struct.Foo3.html"]' 'Foo3' pub use crate::module::Public2 as Foo3; - // @has - '//*[@href="type.Foo4.html"]' 'Foo4' + //@ has - '//*[@href="type.Foo4.html"]' 'Foo4' pub use crate::module::Bar2 as Foo4; - // @has 'foo/single_reexport_inherit_hidden/struct.Foo3.html' - // @has 'foo/single_reexport_inherit_hidden/type.Foo4.html' + //@ has 'foo/single_reexport_inherit_hidden/struct.Foo3.html' + //@ has 'foo/single_reexport_inherit_hidden/type.Foo4.html' } pub mod single_reexport_no_inline { // First we ensure that we only have re-exports and no inlined items. - // @has 'foo/single_reexport_no_inline/index.html' - // @count - '//*[@id="main-content"]/*[@class="section-header"]' 1 - // @has - '//*[@id="main-content"]/*[@class="section-header"]' 'Re-exports' + //@ has 'foo/single_reexport_no_inline/index.html' + //@ count - '//*[@id="main-content"]/*[@class="section-header"]' 1 + //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Re-exports' // Now we check that we don't have links to the items, just `pub use`. - // @has - '//*[@id="main-content"]//*' 'pub use crate::private_module::Public as XFoo;' - // @!has - '//*[@id="main-content"]//a' 'XFoo' + //@ has - '//*[@id="main-content"]//*' 'pub use crate::private_module::Public as XFoo;' + //@ !has - '//*[@id="main-content"]//a' 'XFoo' #[doc(no_inline)] pub use crate::private_module::Public as XFoo; - // @has - '//*[@id="main-content"]//*' 'pub use crate::private_module::Bar as Foo2;' - // @!has - '//*[@id="main-content"]//a' 'Foo2' + //@ has - '//*[@id="main-content"]//*' 'pub use crate::private_module::Bar as Foo2;' + //@ !has - '//*[@id="main-content"]//a' 'Foo2' #[doc(no_inline)] pub use crate::private_module::Bar as Foo2; - // @has - '//*[@id="main-content"]//*' 'pub use crate::Bar3 as Yo;' - // @!has - '//*[@id="main-content"]//a' 'Yo' + //@ has - '//*[@id="main-content"]//*' 'pub use crate::Bar3 as Yo;' + //@ !has - '//*[@id="main-content"]//a' 'Yo' #[doc(no_inline)] pub use crate::Bar3 as Yo; - // @has - '//*[@id="main-content"]//*' 'pub use crate::FooFoo as Yo2;' - // @!has - '//*[@id="main-content"]//a' 'Yo2' + //@ has - '//*[@id="main-content"]//*' 'pub use crate::FooFoo as Yo2;' + //@ !has - '//*[@id="main-content"]//a' 'Yo2' #[doc(no_inline)] pub use crate::FooFoo as Yo2; - // @has - '//*[@id="main-content"]//*' 'pub use crate::module::Public2 as Foo3;' - // @!has - '//*[@id="main-content"]//a' 'Foo3' + //@ has - '//*[@id="main-content"]//*' 'pub use crate::module::Public2 as Foo3;' + //@ !has - '//*[@id="main-content"]//a' 'Foo3' #[doc(no_inline)] pub use crate::module::Public2 as Foo3; - // @has - '//*[@id="main-content"]//*' 'pub use crate::module::Bar2 as Foo4;' - // @!has - '//*[@id="main-content"]//a' 'Foo4' + //@ has - '//*[@id="main-content"]//*' 'pub use crate::module::Bar2 as Foo4;' + //@ !has - '//*[@id="main-content"]//a' 'Foo4' #[doc(no_inline)] pub use crate::module::Bar2 as Foo4; } @@ -100,25 +100,25 @@ pub mod single_reexport_no_inline { pub mod glob_reexport { // With glob re-exports, we don't inline `#[doc(hidden)]` items so only `module` items // should be inlined. - // @has 'foo/glob_reexport/index.html' - // @count - '//*[@id="main-content"]/*[@class="section-header"]' 3 - // @has - '//*[@id="main-content"]/*[@class="section-header"]' 'Re-exports' - // @has - '//*[@id="main-content"]/*[@class="section-header"]' 'Structs' - // @has - '//*[@id="main-content"]/*[@class="section-header"]' 'Type Aliases' + //@ has 'foo/glob_reexport/index.html' + //@ count - '//*[@id="main-content"]/*[@class="section-header"]' 3 + //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Re-exports' + //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Structs' + //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Type Aliases' // Now we check we have 1 re-export and 2 inlined items. // If not item from a glob re-export is visible, we don't show the re-export. - // @!has - '//*[@id="main-content"]//*' 'pub use crate::private_module::*;' + //@ !has - '//*[@id="main-content"]//*' 'pub use crate::private_module::*;' pub use crate::private_module::*; - // @has - '//*[@id="main-content"]//*' 'pub use crate::*;' + //@ has - '//*[@id="main-content"]//*' 'pub use crate::*;' pub use crate::*; // This one should be inlined. - // @!has - '//*[@id="main-content"]//*' 'pub use crate::module::*;' - // @has - '//*[@id="main-content"]//a[@href="struct.Public2.html"]' 'Public2' - // @has - '//*[@id="main-content"]//a[@href="type.Bar2.html"]' 'Bar2' + //@ !has - '//*[@id="main-content"]//*' 'pub use crate::module::*;' + //@ has - '//*[@id="main-content"]//a[@href="struct.Public2.html"]' 'Public2' + //@ has - '//*[@id="main-content"]//a[@href="type.Bar2.html"]' 'Bar2' // And we check that the two files were created too. - // @has 'foo/glob_reexport/struct.Public2.html' - // @has 'foo/glob_reexport/type.Bar2.html' + //@ has 'foo/glob_reexport/struct.Public2.html' + //@ has 'foo/glob_reexport/type.Bar2.html' pub use crate::module::*; } @@ -129,12 +129,12 @@ mod private { // Checking that `#[doc(hidden)]` re-exports documentation isn't generated. pub mod doc_hidden_reexport { - // @has 'foo/doc_hidden_reexport/index.html' + //@ has 'foo/doc_hidden_reexport/index.html' // Ensure there is only one item in this page and that it's a struct. - // @count - '//*[@class="item-name"]' 1 - // @has - '//a[@class="struct"]' 'Reexport' + //@ count - '//*[@class="item-name"]' 1 + //@ has - '//a[@class="struct"]' 'Reexport' // Check that the `#[doc(hidden)]` re-export's attributes are not taken into account. - // @has - '//*[@class="desc docblock-short"]' 'Visible. Original.' + //@ has - '//*[@class="desc docblock-short"]' 'Visible. Original.' /// Visible. pub use self::Bar3 as Reexport; /// Hidden. diff --git a/tests/rustdoc/issue-109695-crate-doc-hidden.rs b/tests/rustdoc/issue-109695-crate-doc-hidden.rs index 7a3e53a0d32..8dc077d1565 100644 --- a/tests/rustdoc/issue-109695-crate-doc-hidden.rs +++ b/tests/rustdoc/issue-109695-crate-doc-hidden.rs @@ -1,8 +1,8 @@ // This test ensures that even if the crate module is `#[doc(hidden)]`, the file // is generated. -// @has 'foo/index.html' -// @has 'foo/all.html' +//@ has 'foo/index.html' +//@ has 'foo/all.html' #![crate_name = "foo"] #![doc(hidden)] diff --git a/tests/rustdoc/issue-110422-inner-private.rs b/tests/rustdoc/issue-110422-inner-private.rs index ca9ec70aaa4..31e28676879 100644 --- a/tests/rustdoc/issue-110422-inner-private.rs +++ b/tests/rustdoc/issue-110422-inner-private.rs @@ -6,22 +6,22 @@ #![crate_name = "foo"] -// @has 'foo/index.html' +//@ has 'foo/index.html' // Checking there is no "trait" entry. -// @count - '//*[@id="main-content"]/*[@class="section-header"]' 4 -// @has - '//*[@id="main-content"]/*[@class="section-header"]' 'Structs' -// @has - '//*[@id="main-content"]/*[@class="section-header"]' 'Constants' -// @has - '//*[@id="main-content"]/*[@class="section-header"]' 'Functions' -// @has - '//*[@id="main-content"]/*[@class="section-header"]' 'Macros' +//@ count - '//*[@id="main-content"]/*[@class="section-header"]' 4 +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Structs' +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Constants' +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Functions' +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Macros' -// @has - '//a[@href="fn.foo.html"]' 'foo' +//@ has - '//a[@href="fn.foo.html"]' 'foo' fn foo() { fn bar() {} - // @has - '//a[@class="macro"]' 'visible_macro' - // @!has - '//a[@class="macro"]' 'non_visible_macro' - // @has 'foo/macro.visible_macro.html' - // @!has 'foo/macro.non_visible_macro.html' + //@ has - '//a[@class="macro"]' 'visible_macro' + //@ !has - '//a[@class="macro"]' 'non_visible_macro' + //@ has 'foo/macro.visible_macro.html' + //@ !has 'foo/macro.non_visible_macro.html' #[macro_export] macro_rules! visible_macro { () => {} @@ -32,30 +32,30 @@ fn foo() { } } -// @has 'foo/index.html' -// @has - '//a[@href="struct.Bar.html"]' 'Bar' +//@ has 'foo/index.html' +//@ has - '//a[@href="struct.Bar.html"]' 'Bar' struct Bar; const BAR: i32 = { - // @!has - '//a[@href="fn.yo.html"]' 'yo' - // @!has 'foo/fn.yo.html' + //@ !has - '//a[@href="fn.yo.html"]' 'yo' + //@ !has 'foo/fn.yo.html' fn yo() {} - // @!has 'foo/index.html' '//a[@href="trait.Foo.html"]' 'Foo' - // @!has 'foo/trait.Foo.html' + //@ !has 'foo/index.html' '//a[@href="trait.Foo.html"]' 'Foo' + //@ !has 'foo/trait.Foo.html' trait Foo { fn babar() {} } impl Foo for Bar {} - // @has 'foo/struct.Bar.html' - // @has - '//*[@id="method.foo"]/*[@class="code-header"]' 'pub(crate) fn foo()' - // @count - '//*[@id="main-content"]/*[@class="section-header"]' 3 + //@ has 'foo/struct.Bar.html' + //@ has - '//*[@id="method.foo"]/*[@class="code-header"]' 'pub(crate) fn foo()' + //@ count - '//*[@id="main-content"]/*[@class="section-header"]' 3 // We now check that the `Foo` trait is not documented nor visible on `Bar` page. - // @has - '//*[@id="main-content"]/*[@class="section-header"]' 'Implementations' - // @has - '//*[@id="main-content"]/*[@class="section-header"]' 'Auto Trait Implementations' - // @has - '//*[@id="main-content"]/*[@class="section-header"]' 'Blanket Implementations' - // @!has - '//*[@href="trait.Foo.html#method.babar"]/*[@class="code-header"]' 'fn babar()' + //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Implementations' + //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Auto Trait Implementations' + //@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Blanket Implementations' + //@ !has - '//*[@href="trait.Foo.html#method.babar"]/*[@class="code-header"]' 'fn babar()' impl Bar { fn foo() {} } diff --git a/tests/rustdoc/issue-110629-private-type-cycle.rs b/tests/rustdoc/issue-110629-private-type-cycle.rs index e8847d7f125..22ea721fd44 100644 --- a/tests/rustdoc/issue-110629-private-type-cycle.rs +++ b/tests/rustdoc/issue-110629-private-type-cycle.rs @@ -4,8 +4,8 @@ type Bar<'a, 'b> = impl PartialEq<Bar<'a, 'b>> + std::fmt::Debug; -// @has issue_110629_private_type_cycle/type.Bar.html -// @has - '//pre[@class="rust item-decl"]' \ +//@ has issue_110629_private_type_cycle/type.Bar.html +//@ has - '//pre[@class="rust item-decl"]' \ // "pub(crate) type Bar<'a, 'b> = impl PartialEq<Bar<'a, 'b>> + Debug;" fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { diff --git a/tests/rustdoc/issue-111064-reexport-trait-from-hidden-2.rs b/tests/rustdoc/issue-111064-reexport-trait-from-hidden-2.rs index 65c26d6a837..4b80f508e7f 100644 --- a/tests/rustdoc/issue-111064-reexport-trait-from-hidden-2.rs +++ b/tests/rustdoc/issue-111064-reexport-trait-from-hidden-2.rs @@ -2,17 +2,17 @@ #![no_core] #![crate_name = "foo"] -// @files "foo" "['sidebar-items.js', 'all.html', 'hidden', 'index.html', 'struct.Bar.html', \ +//@ files "foo" "['sidebar-items.js', 'all.html', 'hidden', 'index.html', 'struct.Bar.html', \ // 'visible']" -// @files "foo/hidden" "['inner']" -// @files "foo/hidden/inner" "['trait.Foo.html']" -// @files "foo/visible" "['index.html', 'sidebar-items.js', 'trait.Foo.html']" +//@ files "foo/hidden" "['inner']" +//@ files "foo/hidden/inner" "['trait.Foo.html']" +//@ files "foo/visible" "['index.html', 'sidebar-items.js', 'trait.Foo.html']" -// @!has 'foo/hidden/index.html' -// @!has 'foo/hidden/inner/index.html' +//@ !has 'foo/hidden/index.html' +//@ !has 'foo/hidden/inner/index.html' // FIXME: Should be `@!has`: https://github.com/rust-lang/rust/issues/111249 -// @has 'foo/hidden/inner/trait.Foo.html' -// @matchesraw - '<meta http-equiv="refresh" content="0;URL=../../../foo/visible/trait.Foo.html">' +//@ has 'foo/hidden/inner/trait.Foo.html' +//@ matchesraw - '<meta http-equiv="refresh" content="0;URL=../../../foo/visible/trait.Foo.html">' #[doc(hidden)] pub mod hidden { pub mod inner { @@ -23,13 +23,13 @@ pub mod hidden { } } -// @has 'foo/visible/index.html' -// @has 'foo/visible/trait.Foo.html' +//@ has 'foo/visible/index.html' +//@ has 'foo/visible/trait.Foo.html' #[doc(inline)] pub use hidden::inner as visible; -// @has 'foo/struct.Bar.html' -// @count - '//*[@id="impl-Foo-for-Bar"]' 1 +//@ has 'foo/struct.Bar.html' +//@ count - '//*[@id="impl-Foo-for-Bar"]' 1 pub struct Bar; impl visible::Foo for Bar { diff --git a/tests/rustdoc/issue-111064-reexport-trait-from-hidden.rs b/tests/rustdoc/issue-111064-reexport-trait-from-hidden.rs index a9ce4a34507..84ec818ef33 100644 --- a/tests/rustdoc/issue-111064-reexport-trait-from-hidden.rs +++ b/tests/rustdoc/issue-111064-reexport-trait-from-hidden.rs @@ -4,11 +4,11 @@ #![crate_name = "foo"] -// @has 'foo/index.html' -// @has - '//*[@id="main-content"]//*[@class="item-name"]/a[@href="trait.Foo.html"]' 'Foo' +//@ has 'foo/index.html' +//@ has - '//*[@id="main-content"]//*[@class="item-name"]/a[@href="trait.Foo.html"]' 'Foo' -// @has 'foo/trait.Foo.html' -// @has - '//*[@id="main-content"]//*[@class="code-header"]' 'fn test()' +//@ has 'foo/trait.Foo.html' +//@ has - '//*[@id="main-content"]//*[@class="code-header"]' 'fn test()' #[doc(hidden)] mod hidden { diff --git a/tests/rustdoc/issue-111249-file-creation.rs b/tests/rustdoc/issue-111249-file-creation.rs index afd65ddaf94..89a25aef97d 100644 --- a/tests/rustdoc/issue-111249-file-creation.rs +++ b/tests/rustdoc/issue-111249-file-creation.rs @@ -2,20 +2,20 @@ #![feature(no_core)] #![no_core] -// @files "foo" "['all.html', 'visible', 'index.html', 'sidebar-items.js', 'hidden', \ +//@ files "foo" "['all.html', 'visible', 'index.html', 'sidebar-items.js', 'hidden', \ // 'struct.Bar.html']" -// @files "foo/visible" "['trait.Foo.html', 'index.html', 'sidebar-items.js']" -// @files "foo/hidden" "['inner']" -// @files "foo/hidden/inner" "['trait.Foo.html']" +//@ files "foo/visible" "['trait.Foo.html', 'index.html', 'sidebar-items.js']" +//@ files "foo/hidden" "['inner']" +//@ files "foo/hidden/inner" "['trait.Foo.html']" // The following five should not fail! -// @!has 'foo/hidden/index.html' -// @!has 'foo/hidden/inner/index.html' +//@ !has 'foo/hidden/index.html' +//@ !has 'foo/hidden/inner/index.html' // FIXME: Should be `@!has`: https://github.com/rust-lang/rust/issues/111249 -// @has 'foo/hidden/inner/trait.Foo.html' -// @matchesraw - '<meta http-equiv="refresh" content="0;URL=../../../foo/visible/trait.Foo.html">' -// @!has 'foo/hidden/inner/inner_hidden/index.html' -// @!has 'foo/hidden/inner/inner_hidden/trait.HiddenFoo.html' +//@ has 'foo/hidden/inner/trait.Foo.html' +//@ matchesraw - '<meta http-equiv="refresh" content="0;URL=../../../foo/visible/trait.Foo.html">' +//@ !has 'foo/hidden/inner/inner_hidden/index.html' +//@ !has 'foo/hidden/inner/inner_hidden/trait.HiddenFoo.html' #[doc(hidden)] pub mod hidden { pub mod inner { @@ -28,13 +28,13 @@ pub mod hidden { } } -// @has 'foo/visible/index.html' -// @has 'foo/visible/trait.Foo.html' +//@ has 'foo/visible/index.html' +//@ has 'foo/visible/trait.Foo.html' #[doc(inline)] pub use hidden::inner as visible; -// @has 'foo/struct.Bar.html' -// @count - '//*[@id="impl-Foo-for-Bar"]' 1 +//@ has 'foo/struct.Bar.html' +//@ count - '//*[@id="impl-Foo-for-Bar"]' 1 pub struct Bar; impl visible::Foo for Bar {} diff --git a/tests/rustdoc/issue-113982-doc_auto_cfg-reexport-foreign.rs b/tests/rustdoc/issue-113982-doc_auto_cfg-reexport-foreign.rs index 6d84ceb0165..c083d9495f4 100644 --- a/tests/rustdoc/issue-113982-doc_auto_cfg-reexport-foreign.rs +++ b/tests/rustdoc/issue-113982-doc_auto_cfg-reexport-foreign.rs @@ -6,14 +6,14 @@ extern crate colors; -// @has 'foo/index.html' '//*[@class="stab portability"]' 'Non-colors' -// @has 'foo/struct.Color.html' '//*[@class="stab portability"]' \ +//@ has 'foo/index.html' '//*[@class="stab portability"]' 'Non-colors' +//@ has 'foo/struct.Color.html' '//*[@class="stab portability"]' \ // 'Available on non-crate feature colors only.' #[cfg(not(feature = "colors"))] pub use colors::*; -// @has 'foo/index.html' '//*[@class="stab portability"]' 'Non-fruits' -// @has 'foo/struct.Red.html' '//*[@class="stab portability"]' \ +//@ has 'foo/index.html' '//*[@class="stab portability"]' 'Non-fruits' +//@ has 'foo/struct.Red.html' '//*[@class="stab portability"]' \ // 'Available on non-crate feature fruits only.' #[cfg(not(feature = "fruits"))] pub use colors::Color as Red; diff --git a/tests/rustdoc/issue-115295-macro-const-display.rs b/tests/rustdoc/issue-115295-macro-const-display.rs index 2916c7a84a1..0dadb76ae5c 100644 --- a/tests/rustdoc/issue-115295-macro-const-display.rs +++ b/tests/rustdoc/issue-115295-macro-const-display.rs @@ -1,9 +1,9 @@ #![crate_name = "foo"] -// @has foo/trait.Trait.html +//@ has foo/trait.Trait.html pub trait Trait<T> {} -// @has foo/struct.WithConst.html +//@ has foo/struct.WithConst.html pub struct WithConst<const N: usize>; macro_rules! spans_from_macro { @@ -22,19 +22,19 @@ macro_rules! spans_from_macro { }; } -// @has - '//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has - '//*[@class="impl"]//h3[@class="code-header"]' \ // "impl Trait<WithConst<41>> for WithConst<41>" impl Trait<WithConst<41>> for WithConst<41> {} -// @has - '//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has - '//*[@class="impl"]//h3[@class="code-header"]' \ // "impl WithConst<42>" -// @has - '//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has - '//*[@class="impl"]//h3[@class="code-header"]' \ // "impl Trait<WithConst<42>> for WithConst<42>" -// @has - '//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has - '//*[@class="impl"]//h3[@class="code-header"]' \ // "impl Trait<WithConst<43>> for WithConst<{ 43 }>" -// @has - '//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has - '//*[@class="impl"]//h3[@class="code-header"]' \ // "impl Trait<WithConst<44>> for WithConst<44>" -// @has foo/struct.Other.html -// @has - //pre "pub field: WithConst<42>" +//@ has foo/struct.Other.html +//@ has - //pre "pub field: WithConst<42>" spans_from_macro!(); diff --git a/tests/rustdoc/issue-118180-empty-tuple-struct.rs b/tests/rustdoc/issue-118180-empty-tuple-struct.rs index bc6ddbe5def..2cd1df27b2b 100644 --- a/tests/rustdoc/issue-118180-empty-tuple-struct.rs +++ b/tests/rustdoc/issue-118180-empty-tuple-struct.rs @@ -1,9 +1,9 @@ -// @has issue_118180_empty_tuple_struct/enum.Enum.html +//@ has issue_118180_empty_tuple_struct/enum.Enum.html pub enum Enum { - // @has - '//*[@id="variant.Empty"]//h3' 'Empty()' + //@ has - '//*[@id="variant.Empty"]//h3' 'Empty()' Empty(), } -// @has issue_118180_empty_tuple_struct/struct.Empty.html -// @has - '//pre/code' 'Empty()' +//@ has issue_118180_empty_tuple_struct/struct.Empty.html +//@ has - '//pre/code' 'Empty()' pub struct Empty(); diff --git a/tests/rustdoc/issue-99221-multiple-macro-rules-w-same-name.rs b/tests/rustdoc/issue-99221-multiple-macro-rules-w-same-name.rs index f4f62717cea..e7fb4fb3f0e 100644 --- a/tests/rustdoc/issue-99221-multiple-macro-rules-w-same-name.rs +++ b/tests/rustdoc/issue-99221-multiple-macro-rules-w-same-name.rs @@ -9,7 +9,7 @@ extern crate issue_99221_aux; pub use issue_99221_aux::*; -// @count foo/index.html '//a[@class="macro"]' 1 +//@ count foo/index.html '//a[@class="macro"]' 1 #[macro_export] macro_rules! print { diff --git a/tests/rustdoc/issue-99221-multiple-structs-w-same-name.rs b/tests/rustdoc/issue-99221-multiple-structs-w-same-name.rs index 4852ee71da7..8758342fe07 100644 --- a/tests/rustdoc/issue-99221-multiple-structs-w-same-name.rs +++ b/tests/rustdoc/issue-99221-multiple-structs-w-same-name.rs @@ -9,6 +9,6 @@ extern crate issue_99221_aux; pub use issue_99221_aux::*; -// @count foo/index.html '//a[@class="struct"][@title="struct foo::Print"]' 1 +//@ count foo/index.html '//a[@class="struct"][@title="struct foo::Print"]' 1 pub struct Print; diff --git a/tests/rustdoc/issue-99734-multiple-foreigns-w-same-name.rs b/tests/rustdoc/issue-99734-multiple-foreigns-w-same-name.rs index 9c94fdd9160..d7c4f1db320 100644 --- a/tests/rustdoc/issue-99734-multiple-foreigns-w-same-name.rs +++ b/tests/rustdoc/issue-99734-multiple-foreigns-w-same-name.rs @@ -9,7 +9,7 @@ extern crate issue_99734_aux; pub use issue_99734_aux::*; -// @count foo/index.html '//a[@class="fn"][@title="fn foo::main"]' 1 +//@ count foo/index.html '//a[@class="fn"][@title="fn foo::main"]' 1 extern "C" { pub fn main() -> std::ffi::c_int; diff --git a/tests/rustdoc/issue-99734-multiple-mods-w-same-name.rs b/tests/rustdoc/issue-99734-multiple-mods-w-same-name.rs index 41aeb30a461..627cfc0b80b 100644 --- a/tests/rustdoc/issue-99734-multiple-mods-w-same-name.rs +++ b/tests/rustdoc/issue-99734-multiple-mods-w-same-name.rs @@ -9,6 +9,6 @@ extern crate issue_99734_aux; pub use issue_99734_aux::*; -// @count foo/index.html '//a[@class="mod"][@title="mod foo::task"]' 1 +//@ count foo/index.html '//a[@class="mod"][@title="mod foo::task"]' 1 pub mod task {} diff --git a/tests/rustdoc/item-desc-list-at-start.rs b/tests/rustdoc/item-desc-list-at-start.rs index d88c61d333e..fbcc36066f1 100644 --- a/tests/rustdoc/item-desc-list-at-start.rs +++ b/tests/rustdoc/item-desc-list-at-start.rs @@ -1,7 +1,7 @@ -// @has item_desc_list_at_start/index.html -// @count - '//ul[@class="item-table"]/li/div/li' 0 -// @count - '//ul[@class="item-table"]/li' 1 -// @snapshot item-table - '//ul[@class="item-table"]' +//@ has item_desc_list_at_start/index.html +//@ count - '//ul[@class="item-table"]/li/div/li' 0 +//@ count - '//ul[@class="item-table"]/li' 1 +//@ snapshot item-table - '//ul[@class="item-table"]' // based on https://docs.rs/gl_constants/0.1.1/src/gl_constants/lib.rs.html#16 diff --git a/tests/rustdoc/jump-to-def-doc-links-calls.rs b/tests/rustdoc/jump-to-def-doc-links-calls.rs index 4101058edbf..61856978773 100644 --- a/tests/rustdoc/jump-to-def-doc-links-calls.rs +++ b/tests/rustdoc/jump-to-def-doc-links-calls.rs @@ -2,21 +2,21 @@ #![crate_name = "foo"] -// @has 'src/foo/jump-to-def-doc-links-calls.rs.html' +//@ has 'src/foo/jump-to-def-doc-links-calls.rs.html' -// @has - '//a[@href="../../foo/struct.Bar.html"]' 'Bar' +//@ has - '//a[@href="../../foo/struct.Bar.html"]' 'Bar' pub struct Bar; impl std::default::Default for Bar { - // @has - '//a[@href="#20-22"]' 'Self::new' + //@ has - '//a[@href="#20-22"]' 'Self::new' fn default() -> Self { Self::new() } } -// @has - '//a[@href="#8"]' 'Bar' +//@ has - '//a[@href="#8"]' 'Bar' impl Bar { - // @has - '//a[@href="#24-26"]' 'Self::bar' + //@ has - '//a[@href="#24-26"]' 'Self::bar' pub fn new()-> Self { Self::bar() } diff --git a/tests/rustdoc/jump-to-def-doc-links.rs b/tests/rustdoc/jump-to-def-doc-links.rs index 1722aa40437..2abb52e0a00 100644 --- a/tests/rustdoc/jump-to-def-doc-links.rs +++ b/tests/rustdoc/jump-to-def-doc-links.rs @@ -2,19 +2,19 @@ #![crate_name = "foo"] -// @has 'src/foo/jump-to-def-doc-links.rs.html' +//@ has 'src/foo/jump-to-def-doc-links.rs.html' -// @has - '//a[@href="../../foo/struct.Bar.html"]' 'Bar' -// @has - '//a[@href="../../foo/struct.Foo.html"]' 'Foo' +//@ has - '//a[@href="../../foo/struct.Bar.html"]' 'Bar' +//@ has - '//a[@href="../../foo/struct.Foo.html"]' 'Foo' pub struct Bar; pub struct Foo; -// @has - '//a[@href="../../foo/enum.Enum.html"]' 'Enum' +//@ has - '//a[@href="../../foo/enum.Enum.html"]' 'Enum' pub enum Enum { Variant1(String), Variant2(u8), } -// @has - '//a[@href="../../foo/struct.Struct.html"]' 'Struct' +//@ has - '//a[@href="../../foo/struct.Struct.html"]' 'Struct' pub struct Struct { pub a: u8, b: Foo, @@ -27,7 +27,7 @@ impl Struct { fn bar(&self) {} } -// @has - '//a[@href="../../foo/trait.Trait.html"]' 'Trait' +//@ has - '//a[@href="../../foo/trait.Trait.html"]' 'Trait' pub trait Trait { fn foo(); } @@ -36,16 +36,16 @@ impl Trait for Struct { fn foo() {} } -// @has - '//a[@href="../../foo/union.Union.html"]' 'Union' +//@ has - '//a[@href="../../foo/union.Union.html"]' 'Union' pub union Union { pub a: u16, pub f: u32, } -// @has - '//a[@href="../../foo/fn.bar.html"]' 'bar' +//@ has - '//a[@href="../../foo/fn.bar.html"]' 'bar' pub fn bar(b: Bar) { let x = Foo; } -// @has - '//a[@href="../../foo/bar/index.html"]' 'bar' +//@ has - '//a[@href="../../foo/bar/index.html"]' 'bar' pub mod bar {} diff --git a/tests/rustdoc/jump-to-def-macro.rs b/tests/rustdoc/jump-to-def-macro.rs index e8e97a442dd..680477937c6 100644 --- a/tests/rustdoc/jump-to-def-macro.rs +++ b/tests/rustdoc/jump-to-def-macro.rs @@ -4,12 +4,12 @@ #![crate_name = "foo"] -// @has 'src/foo/jump-to-def-macro.rs.html' +//@ has 'src/foo/jump-to-def-macro.rs.html' #[macro_use] extern crate jump_to_def_macro; -// @has - '//a[@href="../../jump_to_def_macro/macro.symbols.html"]' 'symbols!' +//@ has - '//a[@href="../../jump_to_def_macro/macro.symbols.html"]' 'symbols!' symbols! { A = 12 } diff --git a/tests/rustdoc/jump-to-non-local-method.rs b/tests/rustdoc/jump-to-non-local-method.rs index bc44d9a9708..e2f530425f0 100644 --- a/tests/rustdoc/jump-to-non-local-method.rs +++ b/tests/rustdoc/jump-to-non-local-method.rs @@ -2,46 +2,46 @@ #![crate_name = "foo"] -// @has 'src/foo/jump-to-non-local-method.rs.html' +//@ has 'src/foo/jump-to-non-local-method.rs.html' -// @has - '//a[@href="{{channel}}/core/sync/atomic/struct.AtomicIsize.html"]' 'std::sync::atomic::AtomicIsize' +//@ has - '//a[@href="{{channel}}/core/sync/atomic/struct.AtomicIsize.html"]' 'std::sync::atomic::AtomicIsize' use std::sync::atomic::AtomicIsize; -// @has - '//a[@href="{{channel}}/std/io/trait.Read.html"]' 'std::io::Read' +//@ has - '//a[@href="{{channel}}/std/io/trait.Read.html"]' 'std::io::Read' use std::io::Read; -// @has - '//a[@href="{{channel}}/std/io/index.html"]' 'std::io' +//@ has - '//a[@href="{{channel}}/std/io/index.html"]' 'std::io' use std::io; -// @has - '//a[@href="{{channel}}/std/process/fn.exit.html"]' 'std::process::exit' +//@ has - '//a[@href="{{channel}}/std/process/fn.exit.html"]' 'std::process::exit' use std::process::exit; use std::cmp::Ordering; use std::marker::PhantomData; pub fn bar2<T: Read>(readable: T) { - // @has - '//a[@href="{{channel}}/std/io/trait.Read.html#tymethod.read"]' 'read' + //@ has - '//a[@href="{{channel}}/std/io/trait.Read.html#tymethod.read"]' 'read' let _ = readable.read(&mut []); } pub fn bar() { - // @has - '//a[@href="{{channel}}/core/sync/atomic/struct.AtomicIsize.html#method.new"]' 'AtomicIsize::new' + //@ has - '//a[@href="{{channel}}/core/sync/atomic/struct.AtomicIsize.html#method.new"]' 'AtomicIsize::new' let _ = AtomicIsize::new(0); - // @has - '//a[@href="#48"]' 'local_private' + //@ has - '//a[@href="#48"]' 'local_private' local_private(); } pub fn extern_call() { - // @has - '//a[@href="{{channel}}/std/process/fn.exit.html"]' 'exit' + //@ has - '//a[@href="{{channel}}/std/process/fn.exit.html"]' 'exit' exit(0); } pub fn macro_call() -> Result<(), ()> { - // @has - '//a[@href="{{channel}}/core/macro.try.html"]' 'try!' + //@ has - '//a[@href="{{channel}}/core/macro.try.html"]' 'try!' try!(Err(())); Ok(()) } pub fn variant() { - // @has - '//a[@href="{{channel}}/core/cmp/enum.Ordering.html#variant.Less"]' 'Ordering::Less' + //@ has - '//a[@href="{{channel}}/core/cmp/enum.Ordering.html#variant.Less"]' 'Ordering::Less' let _ = Ordering::Less; - // @has - '//a[@href="{{channel}}/core/marker/struct.PhantomData.html"]' 'PhantomData' + //@ has - '//a[@href="{{channel}}/core/marker/struct.PhantomData.html"]' 'PhantomData' let _: PhantomData::<usize> = PhantomData; } diff --git a/tests/rustdoc/keyword.rs b/tests/rustdoc/keyword.rs index 4d047af3255..0157c35288e 100644 --- a/tests/rustdoc/keyword.rs +++ b/tests/rustdoc/keyword.rs @@ -2,22 +2,22 @@ #![feature(rustdoc_internals)] -// @has foo/index.html '//h2[@id="keywords"]' 'Keywords' -// @has foo/index.html '//a[@href="keyword.match.html"]' 'match' -// @has foo/index.html '//div[@class="sidebar-elems"]//li/a' 'Keywords' -// @has foo/index.html '//div[@class="sidebar-elems"]//li/a/@href' '#keywords' -// @has foo/keyword.match.html '//a[@class="keyword"]' 'match' -// @has foo/keyword.match.html '//h1' 'Keyword match' -// @has foo/keyword.match.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' -// @has foo/index.html '//a/@href' '../foo/index.html' -// @!has foo/foo/index.html -// @!has-dir foo/foo -// @!has foo/index.html '//span' '🔒' +//@ has foo/index.html '//h2[@id="keywords"]' 'Keywords' +//@ has foo/index.html '//a[@href="keyword.match.html"]' 'match' +//@ has foo/index.html '//div[@class="sidebar-elems"]//li/a' 'Keywords' +//@ has foo/index.html '//div[@class="sidebar-elems"]//li/a/@href' '#keywords' +//@ has foo/keyword.match.html '//a[@class="keyword"]' 'match' +//@ has foo/keyword.match.html '//h1' 'Keyword match' +//@ has foo/keyword.match.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' +//@ has foo/index.html '//a/@href' '../foo/index.html' +//@ !has foo/foo/index.html +//@ !has-dir foo/foo +//@ !has foo/index.html '//span' '🔒' #[doc(keyword = "match")] /// this is a test! mod foo{} -// @has foo/keyword.foo.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'hello' +//@ has foo/keyword.foo.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'hello' #[doc(keyword = "foo")] /// hello mod bar {} diff --git a/tests/rustdoc/legacy-const-generic.rs b/tests/rustdoc/legacy-const-generic.rs index 3a488bdd208..41df535f3e0 100644 --- a/tests/rustdoc/legacy-const-generic.rs +++ b/tests/rustdoc/legacy-const-generic.rs @@ -1,15 +1,15 @@ #![crate_name = "foo"] #![feature(rustc_attrs)] -// @has 'foo/fn.foo.html' -// @has - '//pre[@class="rust item-decl"]' 'fn foo(x: usize, const Y: usize, z: usize) -> [usize; 3]' +//@ has 'foo/fn.foo.html' +//@ has - '//pre[@class="rust item-decl"]' 'fn foo(x: usize, const Y: usize, z: usize) -> [usize; 3]' #[rustc_legacy_const_generics(1)] pub fn foo<const Y: usize>(x: usize, z: usize) -> [usize; 3] { [x, Y, z] } -// @has 'foo/fn.bar.html' -// @has - '//pre[@class="rust item-decl"]' 'fn bar(x: usize, const Y: usize, const Z: usize) -> [usize; 3]' +//@ has 'foo/fn.bar.html' +//@ has - '//pre[@class="rust item-decl"]' 'fn bar(x: usize, const Y: usize, const Z: usize) -> [usize; 3]' #[rustc_legacy_const_generics(1, 2)] pub fn bar<const Y: usize, const Z: usize>(x: usize) -> [usize; 3] { [x, Y, z] diff --git a/tests/rustdoc/lifetime-name.rs b/tests/rustdoc/lifetime-name.rs index 15e09f5165a..1e583f1811d 100644 --- a/tests/rustdoc/lifetime-name.rs +++ b/tests/rustdoc/lifetime-name.rs @@ -1,5 +1,5 @@ #![crate_name = "foo"] -// @has 'foo/type.Resolutions.html' -// @has - '//pre[@class="rust item-decl"]' "pub type Resolutions<'tcx> = &'tcx u8;" +//@ has 'foo/type.Resolutions.html' +//@ has - '//pre[@class="rust item-decl"]' "pub type Resolutions<'tcx> = &'tcx u8;" pub type Resolutions<'tcx> = &'tcx u8; diff --git a/tests/rustdoc/line-breaks.rs b/tests/rustdoc/line-breaks.rs index 0f760d51973..b82894ab68f 100644 --- a/tests/rustdoc/line-breaks.rs +++ b/tests/rustdoc/line-breaks.rs @@ -3,7 +3,7 @@ use std::fmt::Display; use std::ops::Add; -// @matches foo/fn.function_with_a_really_long_name.html '//*[@class="rust item-decl"]//code' "\ +//@ matches foo/fn.function_with_a_really_long_name.html '//*[@class="rust item-decl"]//code' "\ // function_with_a_really_long_name\(\n\ // \ parameter_one: i32,\n\ // \ parameter_two: i32,\n\ @@ -12,13 +12,13 @@ pub fn function_with_a_really_long_name(parameter_one: i32, parameter_two: i32) Some(parameter_one + parameter_two) } -// @matches foo/fn.short_name.html '//*[@class="rust item-decl"]//code' \ +//@ matches foo/fn.short_name.html '//*[@class="rust item-decl"]//code' \ // "short_name\(param: i32\) -> i32$" pub fn short_name(param: i32) -> i32 { param + 1 } -// @matches foo/fn.where_clause.html '//*[@class="rust item-decl"]//code' "\ +//@ matches foo/fn.where_clause.html '//*[@class="rust item-decl"]//code' "\ // where_clause<T, U>\(param_one: T, param_two: U\)where\n\ // \ T: Add<U> \+ Display \+ Copy,\n\ // \ U: Add<T> \+ Display \+ Copy,\n\ diff --git a/tests/rustdoc/link-assoc-const.rs b/tests/rustdoc/link-assoc-const.rs index 75a2531a308..56b82fb2d39 100644 --- a/tests/rustdoc/link-assoc-const.rs +++ b/tests/rustdoc/link-assoc-const.rs @@ -1,7 +1,7 @@ #![crate_name = "foo"] -// @has foo/index.html '//a[@href="foo/constant.FIRSTCONST.html"]' 'foo::FIRSTCONST' -// @has foo/index.html '//a[@href="struct.Bar.html#associatedconstant.CONST"]' 'Bar::CONST' +//@ has foo/index.html '//a[@href="foo/constant.FIRSTCONST.html"]' 'foo::FIRSTCONST' +//@ has foo/index.html '//a[@href="struct.Bar.html#associatedconstant.CONST"]' 'Bar::CONST' //! We have here [`foo::FIRSTCONST`] and [`Bar::CONST`]. diff --git a/tests/rustdoc/link-extern-crate-33178.rs b/tests/rustdoc/link-extern-crate-33178.rs index d62bab5111f..94822798af3 100644 --- a/tests/rustdoc/link-extern-crate-33178.rs +++ b/tests/rustdoc/link-extern-crate-33178.rs @@ -6,12 +6,12 @@ // https://github.com/rust-lang/rust/issues/33178 #![crate_name="issue_33178"] -// @has issue_33178/index.html -// @has - '//a[@title="mod empty"][@href="../empty/index.html"]' empty +//@ has issue_33178/index.html +//@ has - '//a[@title="mod empty"][@href="../empty/index.html"]' empty pub extern crate empty; -// @has - '//a[@title="mod variant_struct"][@href="../variant_struct/index.html"]' variant_struct +//@ has - '//a[@title="mod variant_struct"][@href="../variant_struct/index.html"]' variant_struct pub extern crate variant_struct as foo; -// @has - '//a[@title="mod issue_33178"][@href="index.html"]' self +//@ has - '//a[@title="mod issue_33178"][@href="index.html"]' self pub extern crate self as bar; diff --git a/tests/rustdoc/link-extern-crate-item-30109.rs b/tests/rustdoc/link-extern-crate-item-30109.rs index a57d16da820..544cfa14971 100644 --- a/tests/rustdoc/link-extern-crate-item-30109.rs +++ b/tests/rustdoc/link-extern-crate-item-30109.rs @@ -11,7 +11,7 @@ pub mod quux { pub trait Foo {} - // @has issue_30109/quux/trait.Foo.html \ + //@ has issue_30109/quux/trait.Foo.html \ // '//a/@href' '../issue_30109_1/struct.Bar.html' impl Foo for Bar {} } diff --git a/tests/rustdoc/link-extern-crate-title-33178.rs b/tests/rustdoc/link-extern-crate-title-33178.rs index e85ddb2c891..39c4fec1cd9 100644 --- a/tests/rustdoc/link-extern-crate-title-33178.rs +++ b/tests/rustdoc/link-extern-crate-title-33178.rs @@ -5,9 +5,9 @@ // https://github.com/rust-lang/rust/issues/33178 #![crate_name="issue_33178_1"] -// @has issue_33178_1/index.html -// @!has - //a/@title empty +//@ has issue_33178_1/index.html +//@ !has - //a/@title empty pub extern crate empty; -// @!has - //a/@title variant_struct +//@ !has - //a/@title variant_struct pub extern crate variant_struct as foo; diff --git a/tests/rustdoc/link-title-escape.rs b/tests/rustdoc/link-title-escape.rs index 7a322ea6d34..35e55c0f904 100644 --- a/tests/rustdoc/link-title-escape.rs +++ b/tests/rustdoc/link-title-escape.rs @@ -6,4 +6,4 @@ //! //! [foo]: url 'title & <stuff> & "things"' -// @hasraw 'foo/index.html' 'title & <stuff> & "things"' +//@ hasraw 'foo/index.html' 'title & <stuff> & "things"' diff --git a/tests/rustdoc/links-in-headings.rs b/tests/rustdoc/links-in-headings.rs index c5bee1a7975..5a23af0e797 100644 --- a/tests/rustdoc/links-in-headings.rs +++ b/tests/rustdoc/links-in-headings.rs @@ -8,7 +8,7 @@ //! //! ! -// @has 'foo/index.html' -// @has - '//h2/a[@href="https://a.com"]' 'a link' -// @has - '//h3/a[@href="https://b.com"]' 'multiple' -// @has - '//h3/a[@href="https://c.com"]' 'links' +//@ has 'foo/index.html' +//@ has - '//h2/a[@href="https://a.com"]' 'a link' +//@ has - '//h3/a[@href="https://b.com"]' 'multiple' +//@ has - '//h3/a[@href="https://c.com"]' 'links' diff --git a/tests/rustdoc/local-reexport-doc.rs b/tests/rustdoc/local-reexport-doc.rs index 5dc857773a3..6db8f999d29 100644 --- a/tests/rustdoc/local-reexport-doc.rs +++ b/tests/rustdoc/local-reexport-doc.rs @@ -3,8 +3,8 @@ #![crate_name = "foo"] -// @has 'foo/fn.g.html' -// @has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' \ +//@ has 'foo/fn.g.html' +//@ has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' \ // 'outer module inner module' mod inner_mod { diff --git a/tests/rustdoc/logo-class-default.rs b/tests/rustdoc/logo-class-default.rs index 6b46b46051f..cabf95569ee 100644 --- a/tests/rustdoc/logo-class-default.rs +++ b/tests/rustdoc/logo-class-default.rs @@ -1,4 +1,4 @@ // Note: this test is paired with logo-class.rs and logo-class-rust.rs. -// @!has logo_class_default/struct.SomeStruct.html '//*[@class="logo-container"]/img' '' -// @!has src/logo_class_default/logo-class-default.rs.html '//*[@class="sub-logo-container"]/img' '' +//@ !has logo_class_default/struct.SomeStruct.html '//*[@class="logo-container"]/img' '' +//@ !has src/logo_class_default/logo-class-default.rs.html '//*[@class="sub-logo-container"]/img' '' pub struct SomeStruct; diff --git a/tests/rustdoc/logo-class-rust.rs b/tests/rustdoc/logo-class-rust.rs index c8f7f063dde..d37438f7619 100644 --- a/tests/rustdoc/logo-class-rust.rs +++ b/tests/rustdoc/logo-class-rust.rs @@ -2,5 +2,5 @@ #![allow(internal_features)] #![doc(rust_logo)] // Note: this test is paired with logo-class.rs and logo-class-default.rs. -// @has logo_class_rust/struct.SomeStruct.html '//*[@class="logo-container"]/img[@class="rust-logo"]' '' +//@ has logo_class_rust/struct.SomeStruct.html '//*[@class="logo-container"]/img[@class="rust-logo"]' '' pub struct SomeStruct; diff --git a/tests/rustdoc/logo-class.rs b/tests/rustdoc/logo-class.rs index 816f40df014..73d5244fc41 100644 --- a/tests/rustdoc/logo-class.rs +++ b/tests/rustdoc/logo-class.rs @@ -2,6 +2,6 @@ "https://raw.githubusercontent.com/sagebind/isahc/master/media/isahc.svg.png")] // Note: this test is paired with logo-class-default.rs and logo-class-rust.rs. -// @has logo_class/struct.SomeStruct.html '//*[@class="logo-container"]/img[@src="https://raw.githubusercontent.com/sagebind/isahc/master/media/isahc.svg.png"]' '' -// @!has logo_class/struct.SomeStruct.html '//*[@class="logo-container"]/img[@class="rust-logo"]' '' +//@ has logo_class/struct.SomeStruct.html '//*[@class="logo-container"]/img[@src="https://raw.githubusercontent.com/sagebind/isahc/master/media/isahc.svg.png"]' '' +//@ !has logo_class/struct.SomeStruct.html '//*[@class="logo-container"]/img[@class="rust-logo"]' '' pub struct SomeStruct; diff --git a/tests/rustdoc/macro-doc-comment-23812.rs b/tests/rustdoc/macro-doc-comment-23812.rs index 57c18510b1e..03fda4a25b9 100644 --- a/tests/rustdoc/macro-doc-comment-23812.rs +++ b/tests/rustdoc/macro-doc-comment-23812.rs @@ -18,11 +18,11 @@ doc! { } } -// @has issue_23812/Foo/index.html -// @hasraw - 'Outer comment' -// @!hasraw - '/// Outer comment' -// @hasraw - 'Inner comment' -// @!hasraw - '//! Inner comment' +//@ has issue_23812/Foo/index.html +//@ hasraw - 'Outer comment' +//@ !hasraw - '/// Outer comment' +//@ hasraw - 'Inner comment' +//@ !hasraw - '//! Inner comment' doc! { @@ -32,8 +32,8 @@ doc! { } } -// @has issue_23812/Bar/index.html -// @hasraw - 'Outer block comment' -// @!hasraw - '/** Outer block comment */' -// @hasraw - 'Inner block comment' -// @!hasraw - '/*! Inner block comment */' +//@ has issue_23812/Bar/index.html +//@ hasraw - 'Outer block comment' +//@ !hasraw - '/** Outer block comment */' +//@ hasraw - 'Inner block comment' +//@ !hasraw - '/*! Inner block comment */' diff --git a/tests/rustdoc/macro-document-private-duplicate.rs b/tests/rustdoc/macro-document-private-duplicate.rs index 703317be8c9..35cdc60dfdc 100644 --- a/tests/rustdoc/macro-document-private-duplicate.rs +++ b/tests/rustdoc/macro-document-private-duplicate.rs @@ -10,15 +10,15 @@ // //@ compile-flags: --document-private-items -// @hasraw macro_document_private_duplicate/index.html 'Doc 1.' -// @hasraw macro_document_private_duplicate/macro.a_macro.html 'Doc 1.' +//@ hasraw macro_document_private_duplicate/index.html 'Doc 1.' +//@ hasraw macro_document_private_duplicate/macro.a_macro.html 'Doc 1.' /// Doc 1. macro_rules! a_macro { () => () } -// @hasraw macro_document_private_duplicate/index.html 'Doc 2.' -// @!hasraw macro_document_private_duplicate/macro.a_macro.html 'Doc 2.' +//@ hasraw macro_document_private_duplicate/index.html 'Doc 2.' +//@ !hasraw macro_document_private_duplicate/macro.a_macro.html 'Doc 2.' /// Doc 2. macro_rules! a_macro { () => () diff --git a/tests/rustdoc/macro-document-private.rs b/tests/rustdoc/macro-document-private.rs index 2252aa87eba..224e31f8312 100644 --- a/tests/rustdoc/macro-document-private.rs +++ b/tests/rustdoc/macro-document-private.rs @@ -8,12 +8,12 @@ #![feature(decl_macro)] -// @has macro_document_private/macro.some_macro.html +//@ has macro_document_private/macro.some_macro.html macro some_macro { (a: tt) => {} } -// @has macro_document_private/macro.another_macro.html +//@ has macro_document_private/macro.another_macro.html macro_rules! another_macro { (a: tt) => {} } diff --git a/tests/rustdoc/macro-generated-macro.rs b/tests/rustdoc/macro-generated-macro.rs index 1a423cac1b5..e77d0cf89e7 100644 --- a/tests/rustdoc/macro-generated-macro.rs +++ b/tests/rustdoc/macro-generated-macro.rs @@ -7,23 +7,23 @@ macro_rules! make_macro { } } -// @has macro_generated_macro/macro.interpolations.html //pre 'macro_rules! interpolations {' -// @has - //pre '(<= type $($i:ident)::* + $e:expr =>) => { ... };' +//@ has macro_generated_macro/macro.interpolations.html //pre 'macro_rules! interpolations {' +//@ has - //pre '(<= type $($i:ident)::* + $e:expr =>) => { ... };' make_macro!(interpolations type $($i:ident)::* + $e:expr); interpolations!(<= type foo::bar + x.sort() =>); -// @has macro_generated_macro/macro.attributes.html //pre 'macro_rules! attributes {' -// @has - //pre '(<= #![no_std] #[cfg(feature = "alloc")] =>) => { ... };' +//@ has macro_generated_macro/macro.attributes.html //pre 'macro_rules! attributes {' +//@ has - //pre '(<= #![no_std] #[cfg(feature = "alloc")] =>) => { ... };' make_macro!(attributes #![no_std] #[cfg(feature = "alloc")]); -// @has macro_generated_macro/macro.groups.html //pre 'macro_rules! groups {' -// @has - //pre '(<= fn {} () { foo[0] } =>) => { ... };' +//@ has macro_generated_macro/macro.groups.html //pre 'macro_rules! groups {' +//@ has - //pre '(<= fn {} () { foo[0] } =>) => { ... };' make_macro!(groups fn {}() {foo[0]}); -// @snapshot macro_linebreak_pre macro_generated_macro/macro.linebreak.html //pre/text() +//@ snapshot macro_linebreak_pre macro_generated_macro/macro.linebreak.html //pre/text() make_macro!(linebreak 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28); -// @snapshot macro_morestuff_pre macro_generated_macro/macro.morestuff.html //pre/text() +//@ snapshot macro_morestuff_pre macro_generated_macro/macro.morestuff.html //pre/text() make_macro!(morestuff "space between most kinds of tokens": 1 $x + @ :: >>= 'static "no space inside paren or bracket": (2 a) [2 a] $(2 $a:tt)* diff --git a/tests/rustdoc/macro-higher-kinded-function.rs b/tests/rustdoc/macro-higher-kinded-function.rs index a45ef37a7fc..f14125d1309 100644 --- a/tests/rustdoc/macro-higher-kinded-function.rs +++ b/tests/rustdoc/macro-higher-kinded-function.rs @@ -10,11 +10,11 @@ macro_rules! gen { } } -// @has 'foo/struct.Providers.html' -// @has - '//*[@class="rust item-decl"]//code' "pub a: for<'tcx> fn(_: TyCtxt<'tcx>, _: u8) -> i8," -// @has - '//*[@class="rust item-decl"]//code' "pub b: for<'tcx> fn(_: TyCtxt<'tcx>, _: u16) -> i16," -// @has - '//*[@id="structfield.a"]/code' "a: for<'tcx> fn(_: TyCtxt<'tcx>, _: u8) -> i8" -// @has - '//*[@id="structfield.b"]/code' "b: for<'tcx> fn(_: TyCtxt<'tcx>, _: u16) -> i16" +//@ has 'foo/struct.Providers.html' +//@ has - '//*[@class="rust item-decl"]//code' "pub a: for<'tcx> fn(_: TyCtxt<'tcx>, _: u8) -> i8," +//@ has - '//*[@class="rust item-decl"]//code' "pub b: for<'tcx> fn(_: TyCtxt<'tcx>, _: u16) -> i16," +//@ has - '//*[@id="structfield.a"]/code' "a: for<'tcx> fn(_: TyCtxt<'tcx>, _: u8) -> i8" +//@ has - '//*[@id="structfield.b"]/code' "b: for<'tcx> fn(_: TyCtxt<'tcx>, _: u16) -> i16" gen! { (a, 'tcx, [u8], [i8]) (b, 'tcx, [u16], [i16]) diff --git a/tests/rustdoc/macro-indirect-use.rs b/tests/rustdoc/macro-indirect-use.rs index b2d9336cffc..e410e96ae6a 100644 --- a/tests/rustdoc/macro-indirect-use.rs +++ b/tests/rustdoc/macro-indirect-use.rs @@ -11,6 +11,6 @@ mod outer { } } -// @has macro_indirect_use/inner/index.html -// @has macro_indirect_use/inner/macro.some_macro.html +//@ has macro_indirect_use/inner/index.html +//@ has macro_indirect_use/inner/macro.some_macro.html pub use outer::inner; diff --git a/tests/rustdoc/macro-private-not-documented.rs b/tests/rustdoc/macro-private-not-documented.rs index f135a3a9ca6..bd97be5d366 100644 --- a/tests/rustdoc/macro-private-not-documented.rs +++ b/tests/rustdoc/macro-private-not-documented.rs @@ -6,14 +6,14 @@ // This is a regression text for issue #88453. #![feature(decl_macro)] -// @!hasraw macro_private_not_documented/index.html 'a_macro' -// @!has macro_private_not_documented/macro.a_macro.html +//@ !hasraw macro_private_not_documented/index.html 'a_macro' +//@ !has macro_private_not_documented/macro.a_macro.html macro_rules! a_macro { () => () } -// @!hasraw macro_private_not_documented/index.html 'another_macro' -// @!has macro_private_not_documented/macro.another_macro.html +//@ !hasraw macro_private_not_documented/index.html 'another_macro' +//@ !has macro_private_not_documented/macro.another_macro.html macro another_macro { () => () } diff --git a/tests/rustdoc/macro_pub_in_module.rs b/tests/rustdoc/macro_pub_in_module.rs index 06b7047893b..2dce73c2cf2 100644 --- a/tests/rustdoc/macro_pub_in_module.rs +++ b/tests/rustdoc/macro_pub_in_module.rs @@ -7,79 +7,79 @@ #![crate_name = "krate"] #![no_core] -// @has external_crate/some_module/macro.external_macro.html -// @!has external_crate/macro.external_macro.html +//@ has external_crate/some_module/macro.external_macro.html +//@ !has external_crate/macro.external_macro.html extern crate external_crate; pub mod inner { - // @has krate/inner/macro.raw_const.html - // @!has krate/macro.raw_const.html + //@ has krate/inner/macro.raw_const.html + //@ !has krate/macro.raw_const.html pub macro raw_const() {} - // @has krate/inner/attr.test.html - // @!has krate/macro.test.html - // @!has krate/inner/macro.test.html - // @!has krate/attr.test.html + //@ has krate/inner/attr.test.html + //@ !has krate/macro.test.html + //@ !has krate/inner/macro.test.html + //@ !has krate/attr.test.html #[rustc_builtin_macro] pub macro test($item:item) {} - // @has krate/inner/derive.Clone.html - // @!has krate/inner/macro.Clone.html - // @!has krate/macro.Clone.html - // @!has krate/derive.Clone.html + //@ has krate/inner/derive.Clone.html + //@ !has krate/inner/macro.Clone.html + //@ !has krate/macro.Clone.html + //@ !has krate/derive.Clone.html #[rustc_builtin_macro] pub macro Clone($item:item) {} // Make sure the logic is not affected by re-exports. mod unrenamed { - // @!has krate/macro.unrenamed.html + //@ !has krate/macro.unrenamed.html #[rustc_macro_transparency = "semitransparent"] pub macro unrenamed() {} } - // @has krate/inner/macro.unrenamed.html + //@ has krate/inner/macro.unrenamed.html pub use unrenamed::unrenamed; mod private { - // @!has krate/macro.m.html + //@ !has krate/macro.m.html pub macro m() {} } - // @has krate/inner/macro.renamed.html - // @!has krate/macro.renamed.html + //@ has krate/inner/macro.renamed.html + //@ !has krate/macro.renamed.html pub use private::m as renamed; mod private2 { - // @!has krate/macro.m2.html + //@ !has krate/macro.m2.html pub macro m2() {} } use private2 as renamed_mod; - // @has krate/inner/macro.m2.html + //@ has krate/inner/macro.m2.html pub use renamed_mod::m2; - // @has krate/inner/macro.external_macro.html - // @!has krate/macro.external_macro.html + //@ has krate/inner/macro.external_macro.html + //@ !has krate/macro.external_macro.html pub use ::external_crate::some_module::external_macro; } // Namespaces: Make sure the logic does not mix up a function name with a module name… fn both_fn_and_mod() { - // @!has krate/macro.in_both_fn_and_mod.html + //@ !has krate/macro.in_both_fn_and_mod.html pub macro in_both_fn_and_mod() {} } pub mod both_fn_and_mod { - // @!has krate/both_fn_and_mod/macro.in_both_fn_and_mod.html + //@ !has krate/both_fn_and_mod/macro.in_both_fn_and_mod.html } const __: () = { - // @!has krate/macro.in_both_const_and_mod.html + //@ !has krate/macro.in_both_const_and_mod.html pub macro in_both_const_and_mod() {} }; pub mod __ { - // @!has krate/__/macro.in_both_const_and_mod.html + //@ !has krate/__/macro.in_both_const_and_mod.html } enum Enum { Crazy = { - // @!has krate/macro.this_is_getting_weird.html; + //@ !has krate/macro.this_is_getting_weird.html; pub macro this_is_getting_weird() {} 42 }, diff --git a/tests/rustdoc/macro_rules-matchers.rs b/tests/rustdoc/macro_rules-matchers.rs index 96f4126c7c2..c3ee8febdf5 100644 --- a/tests/rustdoc/macro_rules-matchers.rs +++ b/tests/rustdoc/macro_rules-matchers.rs @@ -3,29 +3,29 @@ #![crate_name = "foo"] -// @has 'foo/macro.todo.html' -// @has - '//span[@class="macro"]' 'macro_rules!' -// @hasraw - ' todo {' +//@ has 'foo/macro.todo.html' +//@ has - '//span[@class="macro"]' 'macro_rules!' +//@ hasraw - ' todo {' -// @hasraw - '{ () => { ... }; ($(' -// @has - '//span[@class="macro-nonterminal"]' '$' -// @has - '//span[@class="macro-nonterminal"]' 'arg' -// @hasraw - ':tt)+' -// @hasraw - ') => { ... }; }' +//@ hasraw - '{ () => { ... }; ($(' +//@ has - '//span[@class="macro-nonterminal"]' '$' +//@ has - '//span[@class="macro-nonterminal"]' 'arg' +//@ hasraw - ':tt)+' +//@ hasraw - ') => { ... }; }' pub use std::todo; mod mod1 { - // @has 'foo/macro.macro1.html' - // @hasraw - 'macro_rules!' - // @hasraw - 'macro1' - // @hasraw - '{ () => { ... }; ($(' - // @has - '//span[@class="macro-nonterminal"]' '$' - // @has - '//span[@class="macro-nonterminal"]' 'arg' - // @hasraw - ':' - // @hasraw - 'expr' - // @hasraw - '),' - // @hasraw - '+' - // @hasraw - ') => { ... }; }' + //@ has 'foo/macro.macro1.html' + //@ hasraw - 'macro_rules!' + //@ hasraw - 'macro1' + //@ hasraw - '{ () => { ... }; ($(' + //@ has - '//span[@class="macro-nonterminal"]' '$' + //@ has - '//span[@class="macro-nonterminal"]' 'arg' + //@ hasraw - ':' + //@ hasraw - 'expr' + //@ hasraw - '),' + //@ hasraw - '+' + //@ hasraw - ') => { ... }; }' #[macro_export] macro_rules! macro1 { () => {}; diff --git a/tests/rustdoc/macros.rs b/tests/rustdoc/macros.rs index ae0cf7a1478..d08babc25f8 100644 --- a/tests/rustdoc/macros.rs +++ b/tests/rustdoc/macros.rs @@ -1,7 +1,7 @@ -// @has macros/macro.my_macro.html //pre 'macro_rules! my_macro {' -// @has - //pre '() => { ... };' -// @has - //pre '($a:tt) => { ... };' -// @has - //pre '($e:expr) => { ... };' +//@ has macros/macro.my_macro.html //pre 'macro_rules! my_macro {' +//@ has - //pre '() => { ... };' +//@ has - //pre '($a:tt) => { ... };' +//@ has - //pre '($e:expr) => { ... };' #[macro_export] macro_rules! my_macro { () => []; @@ -10,10 +10,10 @@ macro_rules! my_macro { } // Check that exported macro defined in a module are shown at crate root. -// @has macros/macro.my_sub_macro.html //pre 'macro_rules! my_sub_macro {' -// @has - //pre '() => { ... };' -// @has - //pre '($a:tt) => { ... };' -// @has - //pre '($e:expr) => { ... };' +//@ has macros/macro.my_sub_macro.html //pre 'macro_rules! my_sub_macro {' +//@ has - //pre '() => { ... };' +//@ has - //pre '($a:tt) => { ... };' +//@ has - //pre '($e:expr) => { ... };' mod sub { #[macro_export] macro_rules! my_sub_macro { diff --git a/tests/rustdoc/manual_impl.rs b/tests/rustdoc/manual_impl.rs index b2ee077bc6b..281262bb40a 100644 --- a/tests/rustdoc/manual_impl.rs +++ b/tests/rustdoc/manual_impl.rs @@ -1,7 +1,7 @@ -// @has manual_impl/trait.T.html -// @has - '//*[@class="docblock"]' 'Docs associated with the trait definition.' -// @has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.' -// @has - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.' +//@ has manual_impl/trait.T.html +//@ has - '//*[@class="docblock"]' 'Docs associated with the trait definition.' +//@ has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.' +//@ has - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.' /// Docs associated with the trait definition. pub trait T { /// Docs associated with the trait a_method definition. @@ -20,14 +20,14 @@ pub trait T { } } -// @has manual_impl/struct.S1.html '//*[@class="trait"]' 'T' -// @has - '//*[@class="docblock"]' 'Docs associated with the S1 trait implementation.' -// @has - '//*[@class="docblock"]' 'Docs associated with the S1 trait a_method implementation.' -// @!has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.' -// @has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Docs associated with the trait b_method definition.' -// @has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Docs associated with the trait c_method definition.' -// @!has - '//*[@class="docblock"]' 'There is another line' -// @has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Read more' +//@ has manual_impl/struct.S1.html '//*[@class="trait"]' 'T' +//@ has - '//*[@class="docblock"]' 'Docs associated with the S1 trait implementation.' +//@ has - '//*[@class="docblock"]' 'Docs associated with the S1 trait a_method implementation.' +//@ !has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.' +//@ has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Docs associated with the trait b_method definition.' +//@ has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Docs associated with the trait c_method definition.' +//@ !has - '//*[@class="docblock"]' 'There is another line' +//@ has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Read more' pub struct S1(usize); /// Docs associated with the S1 trait implementation. @@ -38,11 +38,11 @@ impl T for S1 { } } -// @has manual_impl/struct.S2.html '//*[@class="trait"]' 'T' -// @has - '//*[@class="docblock"]' 'Docs associated with the S2 trait implementation.' -// @has - '//*[@class="docblock"]' 'Docs associated with the S2 trait a_method implementation.' -// @has - '//*[@class="docblock"]' 'Docs associated with the S2 trait c_method implementation.' -// @has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Docs associated with the trait b_method definition.' +//@ has manual_impl/struct.S2.html '//*[@class="trait"]' 'T' +//@ has - '//*[@class="docblock"]' 'Docs associated with the S2 trait implementation.' +//@ has - '//*[@class="docblock"]' 'Docs associated with the S2 trait a_method implementation.' +//@ has - '//*[@class="docblock"]' 'Docs associated with the S2 trait c_method implementation.' +//@ has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Docs associated with the trait b_method definition.' pub struct S2(usize); /// Docs associated with the S2 trait implementation. @@ -58,10 +58,10 @@ impl T for S2 { } } -// @has manual_impl/struct.S3.html '//*[@class="trait"]' 'T' -// @has - '//div[@class="docblock"]' 'Docs associated with the S3 trait implementation.' -// @has - '//div[@class="docblock"]' 'Docs associated with the S3 trait b_method implementation.' -// @has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Docs associated with the trait a_method definition.' +//@ has manual_impl/struct.S3.html '//*[@class="trait"]' 'T' +//@ has - '//div[@class="docblock"]' 'Docs associated with the S3 trait implementation.' +//@ has - '//div[@class="docblock"]' 'Docs associated with the S3 trait b_method implementation.' +//@ has - '//div[@class="impl-items"]//div[@class="docblock"]' 'Docs associated with the trait a_method definition.' pub struct S3(usize); /// Docs associated with the S3 trait implementation. diff --git a/tests/rustdoc/markdown-table-escape-pipe-27862.rs b/tests/rustdoc/markdown-table-escape-pipe-27862.rs index 9af75d24888..bf4c75a97a8 100644 --- a/tests/rustdoc/markdown-table-escape-pipe-27862.rs +++ b/tests/rustdoc/markdown-table-escape-pipe-27862.rs @@ -4,4 +4,4 @@ /// Tests | Table /// ------|------------- /// t = b | id = \|x\| x -pub struct Foo; // @has issue_27862/struct.Foo.html //td 'id = |x| x' +pub struct Foo; //@ has issue_27862/struct.Foo.html //td 'id = |x| x' diff --git a/tests/rustdoc/masked.rs b/tests/rustdoc/masked.rs index 03e5e53f424..4f361ca881e 100644 --- a/tests/rustdoc/masked.rs +++ b/tests/rustdoc/masked.rs @@ -7,25 +7,25 @@ #[doc(masked)] extern crate masked; -// @!hasraw 'search-index.js' 'masked_method' +//@ !hasraw 'search-index.js' 'masked_method' -// @!hasraw 'foo/struct.String.html' 'MaskedTrait' -// @!hasraw 'foo/struct.String.html' 'MaskedBlanketTrait' -// @!hasraw 'foo/struct.String.html' 'masked_method' +//@ !hasraw 'foo/struct.String.html' 'MaskedTrait' +//@ !hasraw 'foo/struct.String.html' 'MaskedBlanketTrait' +//@ !hasraw 'foo/struct.String.html' 'masked_method' pub use std::string::String; -// @!hasraw 'foo/trait.Clone.html' 'MaskedStruct' +//@ !hasraw 'foo/trait.Clone.html' 'MaskedStruct' pub use std::clone::Clone; -// @!hasraw 'foo/struct.MyStruct.html' 'MaskedTrait' -// @!hasraw 'foo/struct.MyStruct.html' 'masked_method' +//@ !hasraw 'foo/struct.MyStruct.html' 'MaskedTrait' +//@ !hasraw 'foo/struct.MyStruct.html' 'masked_method' pub struct MyStruct; impl masked::MaskedTrait for MyStruct { fn masked_method() {} } -// @!hasraw 'foo/trait.MyTrait.html' 'MaskedStruct' +//@ !hasraw 'foo/trait.MyTrait.html' 'MaskedStruct' pub trait MyTrait {} impl MyTrait for masked::MaskedStruct {} diff --git a/tests/rustdoc/method-anchor-in-blanket-impl-86620.rs b/tests/rustdoc/method-anchor-in-blanket-impl-86620.rs index 537dadd2124..89e8712169a 100644 --- a/tests/rustdoc/method-anchor-in-blanket-impl-86620.rs +++ b/tests/rustdoc/method-anchor-in-blanket-impl-86620.rs @@ -6,6 +6,6 @@ extern crate issue_86620_1; use issue_86620_1::*; -// @!has foo/struct.S.html '//*[@id="method.vzip"]//a[@class="fnname"]/@href' #tymethod.vzip -// @has foo/struct.S.html '//*[@id="method.vzip"]//a[@class="anchor"]/@href' #method.vzip +//@ !has foo/struct.S.html '//*[@id="method.vzip"]//a[@class="fnname"]/@href' #tymethod.vzip +//@ has foo/struct.S.html '//*[@id="method.vzip"]//a[@class="anchor"]/@href' #method.vzip pub struct S; diff --git a/tests/rustdoc/method-link-foreign-trait-impl-17476.rs b/tests/rustdoc/method-link-foreign-trait-impl-17476.rs index 5f341e6c21c..cda828d3967 100644 --- a/tests/rustdoc/method-link-foreign-trait-impl-17476.rs +++ b/tests/rustdoc/method-link-foreign-trait-impl-17476.rs @@ -8,7 +8,7 @@ extern crate issue_17476; pub struct Foo; -// @has issue_17476/struct.Foo.html \ +//@ has issue_17476/struct.Foo.html \ // '//*[@href="http://example.com/issue_17476/trait.Foo.html#method.foo"]' \ // 'foo' impl issue_17476::Foo for Foo {} diff --git a/tests/rustdoc/method-list.rs b/tests/rustdoc/method-list.rs index 50f4af3aaaf..b7a0bc3c260 100644 --- a/tests/rustdoc/method-list.rs +++ b/tests/rustdoc/method-list.rs @@ -1,8 +1,8 @@ #![crate_name = "foo"] -// @has foo/struct.Foo.html -// @has - '//*[@class="sidebar-elems"]//section//a' 'super_long_name' -// @has - '//*[@class="sidebar-elems"]//section//a' 'Disp' +//@ has foo/struct.Foo.html +//@ has - '//*[@class="sidebar-elems"]//section//a' 'super_long_name' +//@ has - '//*[@class="sidebar-elems"]//section//a' 'Disp' pub struct Foo(usize); impl Foo { diff --git a/tests/rustdoc/mixing-doc-comments-and-attrs.rs b/tests/rustdoc/mixing-doc-comments-and-attrs.rs index 010058361fa..076a59c426b 100644 --- a/tests/rustdoc/mixing-doc-comments-and-attrs.rs +++ b/tests/rustdoc/mixing-doc-comments-and-attrs.rs @@ -1,15 +1,15 @@ #![crate_name = "foo"] -// @has 'foo/struct.S1.html' -// @snapshot S1_top-doc - '//details[@class="toggle top-doc"]/div[@class="docblock"]' +//@ has 'foo/struct.S1.html' +//@ snapshot S1_top-doc - '//details[@class="toggle top-doc"]/div[@class="docblock"]' #[doc = "Hello world!\n\n"] /// Goodbye! #[doc = " Hello again!\n"] pub struct S1; -// @has 'foo/struct.S2.html' -// @snapshot S2_top-doc - '//details[@class="toggle top-doc"]/div[@class="docblock"]' +//@ has 'foo/struct.S2.html' +//@ snapshot S2_top-doc - '//details[@class="toggle top-doc"]/div[@class="docblock"]' /// Hello world! /// @@ -17,8 +17,8 @@ pub struct S1; /// Hello again! pub struct S2; -// @has 'foo/struct.S3.html' -// @snapshot S3_top-doc - '//details[@class="toggle top-doc"]/div[@class="docblock"]' +//@ has 'foo/struct.S3.html' +//@ snapshot S3_top-doc - '//details[@class="toggle top-doc"]/div[@class="docblock"]' /** Par 1 */ /// /// Par 2 diff --git a/tests/rustdoc/module-impls.rs b/tests/rustdoc/module-impls.rs index 852f444e99b..b66721ecb13 100644 --- a/tests/rustdoc/module-impls.rs +++ b/tests/rustdoc/module-impls.rs @@ -2,4 +2,4 @@ pub use std::marker::Send; -// @!hasraw foo/index.html 'Implementations' +//@ !hasraw foo/index.html 'Implementations' diff --git a/tests/rustdoc/multiple-import-levels.rs b/tests/rustdoc/multiple-import-levels.rs index 29b67c6b2b1..ac00f1fbdfc 100644 --- a/tests/rustdoc/multiple-import-levels.rs +++ b/tests/rustdoc/multiple-import-levels.rs @@ -20,15 +20,15 @@ mod c { pub use crate::b::Type as Woof; } -// @has 'foo/struct.Type.html' -// @has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'foo 2 1' +//@ has 'foo/struct.Type.html' +//@ has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'foo 2 1' /// foo pub use b::Type; -// @has 'foo/struct.Whatever.html' -// @has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'whatever 3 2 1' +//@ has 'foo/struct.Whatever.html' +//@ has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'whatever 3 2 1' /// whatever pub use c::Type as Whatever; -// @has 'foo/struct.Woof.html' -// @has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'a dog 4 2 1' +//@ has 'foo/struct.Woof.html' +//@ has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'a dog 4 2 1' /// a dog pub use c::Woof; diff --git a/tests/rustdoc/multiple-macro-rules-w-same-name-submodule-99221.rs b/tests/rustdoc/multiple-macro-rules-w-same-name-submodule-99221.rs index ed1e42c1f4e..bf59788073e 100644 --- a/tests/rustdoc/multiple-macro-rules-w-same-name-submodule-99221.rs +++ b/tests/rustdoc/multiple-macro-rules-w-same-name-submodule-99221.rs @@ -10,7 +10,7 @@ extern crate issue_99221_aux; pub use issue_99221_aux::*; -// @count foo/index.html '//a[@class="macro"]' 1 +//@ count foo/index.html '//a[@class="macro"]' 1 mod inner { #[macro_export] diff --git a/tests/rustdoc/multiple-mods-w-same-name-doc-inline-83375.rs b/tests/rustdoc/multiple-mods-w-same-name-doc-inline-83375.rs index 9b3dfd45370..6d255ed6004 100644 --- a/tests/rustdoc/multiple-mods-w-same-name-doc-inline-83375.rs +++ b/tests/rustdoc/multiple-mods-w-same-name-doc-inline-83375.rs @@ -9,8 +9,8 @@ pub mod sub { } } -// @count foo/index.html '//a[@class="mod"][@title="mod foo::prelude"]' 1 -// @count foo/prelude/index.html '//div[@class="item-row"]' 0 +//@ count foo/index.html '//a[@class="mod"][@title="mod foo::prelude"]' 1 +//@ count foo/prelude/index.html '//div[@class="item-row"]' 0 pub mod prelude {} #[doc(inline)] diff --git a/tests/rustdoc/multiple-mods-w-same-name-doc-inline-last-item-83375.rs b/tests/rustdoc/multiple-mods-w-same-name-doc-inline-last-item-83375.rs index 7bad825b35f..a59b48232a3 100644 --- a/tests/rustdoc/multiple-mods-w-same-name-doc-inline-last-item-83375.rs +++ b/tests/rustdoc/multiple-mods-w-same-name-doc-inline-last-item-83375.rs @@ -12,6 +12,6 @@ pub mod sub { #[doc(inline)] pub use sub::*; -// @count foo/index.html '//a[@class="mod"][@title="mod foo::prelude"]' 1 -// @count foo/prelude/index.html '//div[@class="item-row"]' 0 +//@ count foo/index.html '//a[@class="mod"][@title="mod foo::prelude"]' 1 +//@ count foo/prelude/index.html '//div[@class="item-row"]' 0 pub mod prelude {} diff --git a/tests/rustdoc/must_implement_one_of.rs b/tests/rustdoc/must_implement_one_of.rs index 1f1dd5d5796..ab965bab356 100644 --- a/tests/rustdoc/must_implement_one_of.rs +++ b/tests/rustdoc/must_implement_one_of.rs @@ -2,7 +2,7 @@ #![feature(rustc_attrs)] #[rustc_must_implement_one_of(a, b)] -// @matches c/trait.Trait.html '//*[@class="stab must_implement"]' \ +//@ matches c/trait.Trait.html '//*[@class="stab must_implement"]' \ // 'At least one of the `a`, `b` methods is required.$' pub trait Trait { fn a() {} diff --git a/tests/rustdoc/mut-params.rs b/tests/rustdoc/mut-params.rs index e403b7b78c9..b3d4fe8c059 100644 --- a/tests/rustdoc/mut-params.rs +++ b/tests/rustdoc/mut-params.rs @@ -5,14 +5,14 @@ pub struct Foo; -// @count foo/struct.Foo.html '//*[@class="impl-items"]//*[@class="method"]' 2 -// @!has - '//*[@class="impl-items"]//*[@class="method"]' 'mut' +//@ count foo/struct.Foo.html '//*[@class="impl-items"]//*[@class="method"]' 2 +//@ !has - '//*[@class="impl-items"]//*[@class="method"]' 'mut' impl Foo { pub fn foo(mut self) {} pub fn bar(mut bar: ()) {} } -// @count foo/fn.baz.html '//pre[@class="rust item-decl"]' 1 -// @!has - '//pre[@class="rust item-decl"]' 'mut' +//@ count foo/fn.baz.html '//pre[@class="rust item-decl"]' 1 +//@ !has - '//pre[@class="rust item-decl"]' 'mut' pub fn baz(mut foo: Foo) {} diff --git a/tests/rustdoc/namespaces.rs b/tests/rustdoc/namespaces.rs index ad828e5ee3e..12248509d07 100644 --- a/tests/rustdoc/namespaces.rs +++ b/tests/rustdoc/namespaces.rs @@ -8,9 +8,9 @@ mod inner { pub fn sync() {} } -// @has namespaces/sync/index.html -// @has namespaces/fn.sync.html -// @has namespaces/index.html '//a/@href' 'sync/index.html' -// @has - '//a/@href' 'fn.sync.html' +//@ has namespaces/sync/index.html +//@ has namespaces/fn.sync.html +//@ has namespaces/index.html '//a/@href' 'sync/index.html' +//@ has - '//a/@href' 'fn.sync.html' #[doc(inline)] pub use inner::sync; diff --git a/tests/rustdoc/negative-impl-sidebar.rs b/tests/rustdoc/negative-impl-sidebar.rs index 4af6d008492..1742dce1945 100644 --- a/tests/rustdoc/negative-impl-sidebar.rs +++ b/tests/rustdoc/negative-impl-sidebar.rs @@ -3,7 +3,7 @@ pub struct Foo; -// @has foo/struct.Foo.html -// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#trait-implementations"]' 'Trait Implementations' -// @has - '//*[@class="sidebar-elems"]//section//a' '!Sync' +//@ has foo/struct.Foo.html +//@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#trait-implementations"]' 'Trait Implementations' +//@ has - '//*[@class="sidebar-elems"]//section//a' '!Sync' impl !Sync for Foo {} diff --git a/tests/rustdoc/negative-impl.rs b/tests/rustdoc/negative-impl.rs index 51223af6737..f057a749b72 100644 --- a/tests/rustdoc/negative-impl.rs +++ b/tests/rustdoc/negative-impl.rs @@ -1,14 +1,14 @@ #![feature(negative_impls)] -// @matches negative_impl/struct.Alpha.html '//pre' "pub struct Alpha" +//@ matches negative_impl/struct.Alpha.html '//pre' "pub struct Alpha" pub struct Alpha; -// @matches negative_impl/struct.Bravo.html '//pre' "pub struct Bravo<B>" +//@ matches negative_impl/struct.Bravo.html '//pre' "pub struct Bravo<B>" pub struct Bravo<B>(B); -// @matches negative_impl/struct.Alpha.html '//*[@class="impl"]//h3[@class="code-header"]' \ +//@ matches negative_impl/struct.Alpha.html '//*[@class="impl"]//h3[@class="code-header"]' \ // "impl !Send for Alpha" impl !Send for Alpha {} -// @matches negative_impl/struct.Bravo.html '//*[@class="impl"]//h3[@class="code-header"]' "\ +//@ matches negative_impl/struct.Bravo.html '//*[@class="impl"]//h3[@class="code-header"]' "\ // impl<B> !Send for Bravo<B>" impl<B> !Send for Bravo<B> {} diff --git a/tests/rustdoc/nested-items-issue-111415.rs b/tests/rustdoc/nested-items-issue-111415.rs index c117569d9b4..a5cd3ca0b1a 100644 --- a/tests/rustdoc/nested-items-issue-111415.rs +++ b/tests/rustdoc/nested-items-issue-111415.rs @@ -3,22 +3,22 @@ #![crate_name = "foo"] -// @has 'foo/index.html' +//@ has 'foo/index.html' // Checking there are only three sections. -// @count - '//*[@id="main-content"]/*[@class="section-header"]' 3 -// @has - '//*[@id="main-content"]/*[@class="section-header"]' 'Structs' -// @has - '//*[@id="main-content"]/*[@class="section-header"]' 'Functions' -// @has - '//*[@id="main-content"]/*[@class="section-header"]' 'Traits' +//@ count - '//*[@id="main-content"]/*[@class="section-header"]' 3 +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Structs' +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Functions' +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Traits' // Checking that there are only three items. -// @count - '//*[@id="main-content"]//*[@class="item-name"]' 3 -// @has - '//*[@id="main-content"]//a[@href="struct.Bar.html"]' 'Bar' -// @has - '//*[@id="main-content"]//a[@href="fn.foo.html"]' 'foo' -// @has - '//*[@id="main-content"]//a[@href="trait.Foo.html"]' 'Foo' +//@ count - '//*[@id="main-content"]//*[@class="item-name"]' 3 +//@ has - '//*[@id="main-content"]//a[@href="struct.Bar.html"]' 'Bar' +//@ has - '//*[@id="main-content"]//a[@href="fn.foo.html"]' 'foo' +//@ has - '//*[@id="main-content"]//a[@href="trait.Foo.html"]' 'Foo' // Now checking that the `foo` method is visible in `Bar` page. -// @has 'foo/struct.Bar.html' -// @has - '//*[@id="method.foo"]/*[@class="code-header"]' 'pub fn foo()' -// @has - '//*[@id="method.bar"]/*[@class="code-header"]' 'fn bar()' +//@ has 'foo/struct.Bar.html' +//@ has - '//*[@id="method.foo"]/*[@class="code-header"]' 'pub fn foo()' +//@ has - '//*[@id="method.bar"]/*[@class="code-header"]' 'fn bar()' pub struct Bar; pub trait Foo { diff --git a/tests/rustdoc/nested-modules.rs b/tests/rustdoc/nested-modules.rs index 12234d2cf7e..1e1d80e7e73 100644 --- a/tests/rustdoc/nested-modules.rs +++ b/tests/rustdoc/nested-modules.rs @@ -6,37 +6,37 @@ mod a_module { pub use a_module::private_function as other_private_function; pub mod a_nested_module { - // @has aCrate/a_nested_module/index.html '//a[@href="fn.a_nested_public_function.html"]' 'a_nested_public_function' - // @hasraw aCrate/a_nested_module/fn.a_nested_public_function.html 'pub fn a_nested_public_function()' + //@ has aCrate/a_nested_module/index.html '//a[@href="fn.a_nested_public_function.html"]' 'a_nested_public_function' + //@ hasraw aCrate/a_nested_module/fn.a_nested_public_function.html 'pub fn a_nested_public_function()' pub fn a_nested_public_function() {} - // @has aCrate/a_nested_module/index.html '//a[@href="fn.another_nested_public_function.html"]' 'another_nested_public_function' - // @hasraw aCrate/a_nested_module/fn.another_nested_public_function.html 'pub fn another_nested_public_function()' + //@ has aCrate/a_nested_module/index.html '//a[@href="fn.another_nested_public_function.html"]' 'another_nested_public_function' + //@ hasraw aCrate/a_nested_module/fn.another_nested_public_function.html 'pub fn another_nested_public_function()' pub use a_nested_module::a_nested_public_function as another_nested_public_function; } - // @!hasraw aCrate/a_nested_module/index.html 'yet_another_nested_public_function' + //@ !hasraw aCrate/a_nested_module/index.html 'yet_another_nested_public_function' pub use a_nested_module::a_nested_public_function as yet_another_nested_public_function; - // @!hasraw aCrate/a_nested_module/index.html 'one_last_nested_public_function' + //@ !hasraw aCrate/a_nested_module/index.html 'one_last_nested_public_function' pub use a_nested_module::another_nested_public_function as one_last_nested_public_function; } -// @!hasraw aCrate/index.html 'a_module' -// @has aCrate/index.html '//a[@href="a_nested_module/index.html"]' 'a_nested_module' +//@ !hasraw aCrate/index.html 'a_module' +//@ has aCrate/index.html '//a[@href="a_nested_module/index.html"]' 'a_nested_module' pub use a_module::a_nested_module; -// @has aCrate/index.html '//a[@href="fn.a_nested_public_function.html"]' 'a_nested_public_function' -// @has aCrate/index.html '//a[@href="fn.another_nested_public_function.html"]' 'another_nested_public_function' -// @has aCrate/index.html '//a[@href="fn.yet_another_nested_public_function.html"]' 'yet_another_nested_public_function' -// @has aCrate/index.html '//a[@href="fn.one_last_nested_public_function.html"]' 'one_last_nested_public_function' +//@ has aCrate/index.html '//a[@href="fn.a_nested_public_function.html"]' 'a_nested_public_function' +//@ has aCrate/index.html '//a[@href="fn.another_nested_public_function.html"]' 'another_nested_public_function' +//@ has aCrate/index.html '//a[@href="fn.yet_another_nested_public_function.html"]' 'yet_another_nested_public_function' +//@ has aCrate/index.html '//a[@href="fn.one_last_nested_public_function.html"]' 'one_last_nested_public_function' pub use a_module::{ a_nested_module::{a_nested_public_function, another_nested_public_function}, one_last_nested_public_function, yet_another_nested_public_function, }; -// @has aCrate/index.html '//a[@href="fn.private_function.html"]' 'private_function' -// @!hasraw aCrate/fn.private_function.html 'a_module' -// @has aCrate/index.html '//a[@href="fn.other_private_function.html"]' 'other_private_function' -// @!hasraw aCrate/fn.other_private_function.html 'a_module' +//@ has aCrate/index.html '//a[@href="fn.private_function.html"]' 'private_function' +//@ !hasraw aCrate/fn.private_function.html 'a_module' +//@ has aCrate/index.html '//a[@href="fn.other_private_function.html"]' 'other_private_function' +//@ !hasraw aCrate/fn.other_private_function.html 'a_module' pub use a_module::{other_private_function, private_function}; diff --git a/tests/rustdoc/no-compiler-reexport.rs b/tests/rustdoc/no-compiler-reexport.rs index d1567c4fdda..355d47d7ba7 100644 --- a/tests/rustdoc/no-compiler-reexport.rs +++ b/tests/rustdoc/no-compiler-reexport.rs @@ -2,6 +2,6 @@ #![crate_name = "foo"] -// @!has 'foo/index.html' '//code' 'extern crate std;' -// @!has 'foo/index.html' '//code' 'use std::prelude' +//@ !has 'foo/index.html' '//code' 'extern crate std;' +//@ !has 'foo/index.html' '//code' 'use std::prelude' pub struct Foo; diff --git a/tests/rustdoc/no-unit-struct-field.rs b/tests/rustdoc/no-unit-struct-field.rs index d301954b6b5..6ac44037cea 100644 --- a/tests/rustdoc/no-unit-struct-field.rs +++ b/tests/rustdoc/no-unit-struct-field.rs @@ -1,10 +1,10 @@ // This test ensures that the tuple struct fields are not generated in the // search index. -// @!hasraw search-index.js '"0"' -// @!hasraw search-index.js '"1"' -// @hasraw search-index.js '"foo_a"' -// @hasraw search-index.js '"bar_a"' +//@ !hasraw search-index.js '"0"' +//@ !hasraw search-index.js '"1"' +//@ hasraw search-index.js '"foo_a"' +//@ hasraw search-index.js '"bar_a"' pub struct Bar(pub u32, pub u8); pub struct Foo { diff --git a/tests/rustdoc/no_std-primitive.rs b/tests/rustdoc/no_std-primitive.rs index 22fd392dd36..78076a601de 100644 --- a/tests/rustdoc/no_std-primitive.rs +++ b/tests/rustdoc/no_std-primitive.rs @@ -1,6 +1,6 @@ #![no_std] /// Link to [intra-doc link][u8] -// @has 'no_std_primitive/fn.foo.html' '//a[@href="{{channel}}/core/primitive.u8.html"]' 'intra-doc link' -// @has - '//a[@href="{{channel}}/core/primitive.u8.html"]' 'u8' +//@ has 'no_std_primitive/fn.foo.html' '//a[@href="{{channel}}/core/primitive.u8.html"]' 'intra-doc link' +//@ has - '//a[@href="{{channel}}/core/primitive.u8.html"]' 'u8' pub fn foo() -> u8 {} diff --git a/tests/rustdoc/non_lifetime_binders.rs b/tests/rustdoc/non_lifetime_binders.rs index da9a4e6a84d..34e83a78787 100644 --- a/tests/rustdoc/non_lifetime_binders.rs +++ b/tests/rustdoc/non_lifetime_binders.rs @@ -5,5 +5,5 @@ pub trait Trait {} pub struct Wrapper<T: ?Sized>(Box<T>); -// @has non_lifetime_binders/fn.foo.html '//pre' "fn foo()where for<'a, T> &'a Wrapper<T>: Trait" +//@ has non_lifetime_binders/fn.foo.html '//pre' "fn foo()where for<'a, T> &'a Wrapper<T>: Trait" pub fn foo() where for<'a, T> &'a Wrapper<T>: Trait {} diff --git a/tests/rustdoc/normalize-assoc-item.rs b/tests/rustdoc/normalize-assoc-item.rs index d45bb1bff65..7ef9d3067e1 100644 --- a/tests/rustdoc/normalize-assoc-item.rs +++ b/tests/rustdoc/normalize-assoc-item.rs @@ -19,20 +19,20 @@ impl Trait for isize { type X = <() as Trait>::X; } -// @has 'normalize_assoc_item/fn.f.html' '//pre[@class="rust item-decl"]' 'pub fn f() -> isize' +//@ has 'normalize_assoc_item/fn.f.html' '//pre[@class="rust item-decl"]' 'pub fn f() -> isize' pub fn f() -> <usize as Trait>::X { 0 } -// @has 'normalize_assoc_item/fn.f2.html' '//pre[@class="rust item-decl"]' 'pub fn f2() -> fn() -> i32' +//@ has 'normalize_assoc_item/fn.f2.html' '//pre[@class="rust item-decl"]' 'pub fn f2() -> fn() -> i32' pub fn f2() -> <isize as Trait>::X { todo!() } pub struct S { - // @has 'normalize_assoc_item/struct.S.html' '//span[@id="structfield.box_me_up"]' 'box_me_up: Box<S>' + //@ has 'normalize_assoc_item/struct.S.html' '//span[@id="structfield.box_me_up"]' 'box_me_up: Box<S>' pub box_me_up: <S as Trait>::X, - // @has 'normalize_assoc_item/struct.S.html' '//span[@id="structfield.generic"]' 'generic: (usize, isize)' + //@ has 'normalize_assoc_item/struct.S.html' '//span[@id="structfield.generic"]' 'generic: (usize, isize)' pub generic: <Generic<usize> as Trait>::X, } @@ -49,10 +49,10 @@ impl<Inner: Trait> Trait for Generic<Inner> { // These can't be normalized because they depend on a generic parameter. // However the user can choose whether the text should be displayed as `Inner::X` or `<Inner as Trait>::X`. -// @has 'normalize_assoc_item/struct.Unknown.html' '//pre[@class="rust item-decl"]' 'pub struct Unknown<Inner: Trait>(pub <Inner as Trait>::X);' +//@ has 'normalize_assoc_item/struct.Unknown.html' '//pre[@class="rust item-decl"]' 'pub struct Unknown<Inner: Trait>(pub <Inner as Trait>::X);' pub struct Unknown<Inner: Trait>(pub <Inner as Trait>::X); -// @has 'normalize_assoc_item/struct.Unknown2.html' '//pre[@class="rust item-decl"]' 'pub struct Unknown2<Inner: Trait>(pub Inner::X);' +//@ has 'normalize_assoc_item/struct.Unknown2.html' '//pre[@class="rust item-decl"]' 'pub struct Unknown2<Inner: Trait>(pub Inner::X);' pub struct Unknown2<Inner: Trait>(pub Inner::X); trait Lifetimes<'a> { @@ -63,20 +63,20 @@ impl<'a> Lifetimes<'a> for usize { type Y = &'a isize; } -// @has 'normalize_assoc_item/fn.g.html' '//pre[@class="rust item-decl"]' "pub fn g() -> &'static isize" +//@ has 'normalize_assoc_item/fn.g.html' '//pre[@class="rust item-decl"]' "pub fn g() -> &'static isize" pub fn g() -> <usize as Lifetimes<'static>>::Y { &0 } -// @has 'normalize_assoc_item/constant.A.html' '//pre[@class="rust item-decl"]' "pub const A: &'static isize" +//@ has 'normalize_assoc_item/constant.A.html' '//pre[@class="rust item-decl"]' "pub const A: &'static isize" pub const A: <usize as Lifetimes<'static>>::Y = &0; // test cross-crate re-exports extern crate inner; -// @has 'normalize_assoc_item/fn.foo.html' '//pre[@class="rust item-decl"]' "pub fn foo() -> i32" +//@ has 'normalize_assoc_item/fn.foo.html' '//pre[@class="rust item-decl"]' "pub fn foo() -> i32" pub use inner::foo; -// @has 'normalize_assoc_item/fn.h.html' '//pre[@class="rust item-decl"]' "pub fn h<T>() -> IntoIter<T>" +//@ has 'normalize_assoc_item/fn.h.html' '//pre[@class="rust item-decl"]' "pub fn h<T>() -> IntoIter<T>" pub fn h<T>() -> <Vec<T> as IntoIterator>::IntoIter { vec![].into_iter() } diff --git a/tests/rustdoc/notable-trait/doc-notable_trait-mut_t_is_not_an_iterator.rs b/tests/rustdoc/notable-trait/doc-notable_trait-mut_t_is_not_an_iterator.rs index 5af5f7616b5..043d787396d 100644 --- a/tests/rustdoc/notable-trait/doc-notable_trait-mut_t_is_not_an_iterator.rs +++ b/tests/rustdoc/notable-trait/doc-notable_trait-mut_t_is_not_an_iterator.rs @@ -16,8 +16,8 @@ /// that are implemented on foreign types don't show up. mod reference {} -// @has doc_notable_trait_mut_t_is_not_an_iterator/fn.fn_no_matches.html -// @!has - '//code[@class="content"]' 'Iterator' +//@ has doc_notable_trait_mut_t_is_not_an_iterator/fn.fn_no_matches.html +//@ !has - '//code[@class="content"]' 'Iterator' pub fn fn_no_matches<'a, T: 'a>() -> &'a mut T { panic!() } diff --git a/tests/rustdoc/notable-trait/doc-notable_trait-mut_t_is_not_ref_t.rs b/tests/rustdoc/notable-trait/doc-notable_trait-mut_t_is_not_ref_t.rs index 6c980aaa2b1..6a9fbb9ac0b 100644 --- a/tests/rustdoc/notable-trait/doc-notable_trait-mut_t_is_not_ref_t.rs +++ b/tests/rustdoc/notable-trait/doc-notable_trait-mut_t_is_not_ref_t.rs @@ -14,8 +14,8 @@ /// that are implemented on foreign types don't show up. mod reference {} -// @has doc_notable_trait_mut_t_is_not_ref_t/fn.fn_no_matches.html -// @!has - '//code[@class="content"]' "impl<'_, I> Iterator for &'_ mut I" +//@ has doc_notable_trait_mut_t_is_not_ref_t/fn.fn_no_matches.html +//@ !has - '//code[@class="content"]' "impl<'_, I> Iterator for &'_ mut I" pub fn fn_no_matches<'a, T: Iterator + 'a>() -> &'a T { loop {} } diff --git a/tests/rustdoc/notable-trait/doc-notable_trait-negative.rs b/tests/rustdoc/notable-trait/doc-notable_trait-negative.rs index 2bbe0a3ef8c..feb40b3797b 100644 --- a/tests/rustdoc/notable-trait/doc-notable_trait-negative.rs +++ b/tests/rustdoc/notable-trait/doc-notable_trait-negative.rs @@ -9,14 +9,14 @@ impl SomeTrait for Positive {} pub struct Negative; impl !SomeTrait for Negative {} -// @has doc_notable_trait_negative/fn.positive.html -// @snapshot positive - '//script[@id="notable-traits-data"]' +//@ has doc_notable_trait_negative/fn.positive.html +//@ snapshot positive - '//script[@id="notable-traits-data"]' pub fn positive() -> Positive { todo!() } -// @has doc_notable_trait_negative/fn.negative.html -// @count - '//script[@id="notable-traits-data"]' 0 +//@ has doc_notable_trait_negative/fn.negative.html +//@ count - '//script[@id="notable-traits-data"]' 0 pub fn negative() -> Negative { &[] } diff --git a/tests/rustdoc/notable-trait/doc-notable_trait-slice.rs b/tests/rustdoc/notable-trait/doc-notable_trait-slice.rs index ef206710b4b..f89f582a4bb 100644 --- a/tests/rustdoc/notable-trait/doc-notable_trait-slice.rs +++ b/tests/rustdoc/notable-trait/doc-notable_trait-slice.rs @@ -7,20 +7,20 @@ pub struct SomeStruct; pub struct OtherStruct; impl SomeTrait for &[SomeStruct] {} -// @has doc_notable_trait_slice/fn.bare_fn_matches.html -// @snapshot bare_fn_matches - '//script[@id="notable-traits-data"]' +//@ has doc_notable_trait_slice/fn.bare_fn_matches.html +//@ snapshot bare_fn_matches - '//script[@id="notable-traits-data"]' pub fn bare_fn_matches() -> &'static [SomeStruct] { &[] } -// @has doc_notable_trait_slice/fn.bare_fn_no_matches.html -// @count - '//script[@id="notable-traits-data"]' 0 +//@ has doc_notable_trait_slice/fn.bare_fn_no_matches.html +//@ count - '//script[@id="notable-traits-data"]' 0 pub fn bare_fn_no_matches() -> &'static [OtherStruct] { &[] } -// @has doc_notable_trait_slice/fn.bare_fn_mut_no_matches.html -// @count - '//script[@id="notable-traits-data"]' 0 +//@ has doc_notable_trait_slice/fn.bare_fn_mut_no_matches.html +//@ count - '//script[@id="notable-traits-data"]' 0 pub fn bare_fn_mut_no_matches() -> &'static mut [SomeStruct] { &mut [] } diff --git a/tests/rustdoc/notable-trait/doc-notable_trait.rs b/tests/rustdoc/notable-trait/doc-notable_trait.rs index d8941769fa6..83fe6172e94 100644 --- a/tests/rustdoc/notable-trait/doc-notable_trait.rs +++ b/tests/rustdoc/notable-trait/doc-notable_trait.rs @@ -8,9 +8,9 @@ impl<T: SomeTrait> SomeTrait for Wrapper<T> {} #[doc(notable_trait)] pub trait SomeTrait { - // @has doc_notable_trait/trait.SomeTrait.html - // @has - '//a[@class="tooltip"]/@data-notable-ty' 'Wrapper<Self>' - // @snapshot wrap-me - '//script[@id="notable-traits-data"]' + //@ has doc_notable_trait/trait.SomeTrait.html + //@ has - '//a[@class="tooltip"]/@data-notable-ty' 'Wrapper<Self>' + //@ snapshot wrap-me - '//script[@id="notable-traits-data"]' fn wrap_me(self) -> Wrapper<Self> where Self: Sized { Wrapper { inner: self, @@ -22,17 +22,17 @@ pub struct SomeStruct; impl SomeTrait for SomeStruct {} impl SomeStruct { - // @has doc_notable_trait/struct.SomeStruct.html - // @has - '//a[@class="tooltip"]/@data-notable-ty' 'SomeStruct' - // @snapshot some-struct-new - '//script[@id="notable-traits-data"]' + //@ has doc_notable_trait/struct.SomeStruct.html + //@ has - '//a[@class="tooltip"]/@data-notable-ty' 'SomeStruct' + //@ snapshot some-struct-new - '//script[@id="notable-traits-data"]' pub fn new() -> SomeStruct { SomeStruct } } -// @has doc_notable_trait/fn.bare_fn.html -// @has - '//a[@class="tooltip"]/@data-notable-ty' 'SomeStruct' -// @snapshot bare-fn - '//script[@id="notable-traits-data"]' +//@ has doc_notable_trait/fn.bare_fn.html +//@ has - '//a[@class="tooltip"]/@data-notable-ty' 'SomeStruct' +//@ snapshot bare-fn - '//script[@id="notable-traits-data"]' pub fn bare_fn() -> SomeStruct { SomeStruct } diff --git a/tests/rustdoc/notable-trait/doc-notable_trait_box_is_not_an_iterator.rs b/tests/rustdoc/notable-trait/doc-notable_trait_box_is_not_an_iterator.rs index 6b94d799483..dcdcbfb7ec1 100644 --- a/tests/rustdoc/notable-trait/doc-notable_trait_box_is_not_an_iterator.rs +++ b/tests/rustdoc/notable-trait/doc-notable_trait_box_is_not_an_iterator.rs @@ -30,12 +30,12 @@ impl<T> Pin<T> { impl<I: FakeIterator> FakeIterator for Pin<I> {} -// @!has doc_notable_trait_box_is_not_an_iterator/fn.foo.html '//*' 'Notable' +//@ !has doc_notable_trait_box_is_not_an_iterator/fn.foo.html '//*' 'Notable' pub fn foo<T>(x: T) -> Box<T> { Box::new(x) } -// @!has doc_notable_trait_box_is_not_an_iterator/fn.bar.html '//*' 'Notable' +//@ !has doc_notable_trait_box_is_not_an_iterator/fn.bar.html '//*' 'Notable' pub fn bar<T>(x: T) -> Pin<T> { Pin::new(x) } diff --git a/tests/rustdoc/notable-trait/notable-trait-generics.rs b/tests/rustdoc/notable-trait/notable-trait-generics.rs index 611902abad6..60d09661aff 100644 --- a/tests/rustdoc/notable-trait/notable-trait-generics.rs +++ b/tests/rustdoc/notable-trait/notable-trait-generics.rs @@ -10,8 +10,8 @@ pub mod generic_return { impl NotableTrait for Wrapper<u8> {} - // @has notable_trait_generics/generic_return/fn.returning.html - // @!has - '//a[@class="tooltip"]/@data-notable-ty' 'Wrapper<T>' + //@ has notable_trait_generics/generic_return/fn.returning.html + //@ !has - '//a[@class="tooltip"]/@data-notable-ty' 'Wrapper<T>' pub fn returning<T>() -> Wrapper<T> { loop {} } @@ -27,8 +27,8 @@ pub mod generic_impl { impl<T> NotableTrait for Wrapper<T> {} - // @has notable_trait_generics/generic_impl/fn.returning.html - // @has - '//a[@class="tooltip"]/@data-notable-ty' 'Wrapper<u8>' + //@ has notable_trait_generics/generic_impl/fn.returning.html + //@ has - '//a[@class="tooltip"]/@data-notable-ty' 'Wrapper<u8>' pub fn returning() -> Wrapper<u8> { loop {} } diff --git a/tests/rustdoc/notable-trait/spotlight-from-dependency.rs b/tests/rustdoc/notable-trait/spotlight-from-dependency.rs index 426759c7bf8..992102f87c7 100644 --- a/tests/rustdoc/notable-trait/spotlight-from-dependency.rs +++ b/tests/rustdoc/notable-trait/spotlight-from-dependency.rs @@ -2,9 +2,9 @@ use std::iter::Iterator; -// @has foo/struct.Odd.html -// @has - '//*[@id="method.new"]//a[@class="tooltip"]/@data-notable-ty' 'Odd' -// @snapshot odd - '//script[@id="notable-traits-data"]' +//@ has foo/struct.Odd.html +//@ has - '//*[@id="method.new"]//a[@class="tooltip"]/@data-notable-ty' 'Odd' +//@ snapshot odd - '//script[@id="notable-traits-data"]' pub struct Odd { current: usize, } diff --git a/tests/rustdoc/nul-error.rs b/tests/rustdoc/nul-error.rs index e8aa786534b..54688efc48c 100644 --- a/tests/rustdoc/nul-error.rs +++ b/tests/rustdoc/nul-error.rs @@ -3,6 +3,6 @@ #![crate_name = "foo"] -// @has foo/fn.foo.html '//code' '' +//@ has foo/fn.foo.html '//code' '' #[doc = "Attempted to pass a string containing `\0`"] pub fn foo() {} diff --git a/tests/rustdoc/playground-arg.rs b/tests/rustdoc/playground-arg.rs index 58d87c653b4..5875451a859 100644 --- a/tests/rustdoc/playground-arg.rs +++ b/tests/rustdoc/playground-arg.rs @@ -10,4 +10,4 @@ pub fn dummy() {} // ensure that `extern crate foo;` was inserted into code snips automatically: -// @matches foo/index.html '//a[@class="test-arrow"][@href="https://example.com/?code=%23!%5Ballow(unused)%5D%0A%23%5Ballow(unused_extern_crates)%5D%0Aextern+crate+r%23foo;%0Afn+main()+%7B%0A++++use+foo::dummy;%0A++++dummy();%0A%7D&edition=2015"]' "Run" +//@ matches foo/index.html '//a[@class="test-arrow"][@href="https://example.com/?code=%23!%5Ballow(unused)%5D%0A%23%5Ballow(unused_extern_crates)%5D%0Aextern+crate+r%23foo;%0Afn+main()+%7B%0A++++use+foo::dummy;%0A++++dummy();%0A%7D&edition=2015"]' "Run" diff --git a/tests/rustdoc/playground-empty.rs b/tests/rustdoc/playground-empty.rs index bfba9ffdbf4..61c422c436b 100644 --- a/tests/rustdoc/playground-empty.rs +++ b/tests/rustdoc/playground-empty.rs @@ -10,4 +10,4 @@ //! println!("Hello, world!"); //! ``` -// @!has foo/index.html '//a[@class="test-arrow"]' "Run" +//@ !has foo/index.html '//a[@class="test-arrow"]' "Run" diff --git a/tests/rustdoc/playground-none.rs b/tests/rustdoc/playground-none.rs index ff51c68d8a2..924c0525190 100644 --- a/tests/rustdoc/playground-none.rs +++ b/tests/rustdoc/playground-none.rs @@ -6,4 +6,4 @@ //! println!("Hello, world!"); //! ``` -// @!has foo/index.html '//a[@class="test-arrow"]' "Run" +//@ !has foo/index.html '//a[@class="test-arrow"]' "Run" diff --git a/tests/rustdoc/playground-syntax-error.rs b/tests/rustdoc/playground-syntax-error.rs index 8918ae874f8..f5067145e02 100644 --- a/tests/rustdoc/playground-syntax-error.rs +++ b/tests/rustdoc/playground-syntax-error.rs @@ -16,6 +16,6 @@ /// ``` pub fn bar() {} -// @has foo/fn.bar.html -// @has - '//a[@class="test-arrow"]' "Run" -// @has - '//*[@class="docblock"]' 'foo_recursive' +//@ has foo/fn.bar.html +//@ has - '//a[@class="test-arrow"]' "Run" +//@ has - '//*[@class="docblock"]' 'foo_recursive' diff --git a/tests/rustdoc/playground.rs b/tests/rustdoc/playground.rs index a2fc9eb7387..7880f779067 100644 --- a/tests/rustdoc/playground.rs +++ b/tests/rustdoc/playground.rs @@ -22,6 +22,6 @@ //! } //! ``` -// @matches foo/index.html '//a[@class="test-arrow"][@href="https://www.example.com/?code=%23!%5Ballow(unused)%5D%0Afn+main()+%7B%0A++++println!(%22Hello,+world!%22);%0A%7D&edition=2015"]' "Run" -// @matches foo/index.html '//a[@class="test-arrow"][@href="https://www.example.com/?code=%23!%5Ballow(unused)%5D%0Afn+main()+%7B%0A++++println!(%22Hello,+world!%22);%0A%7D&edition=2015"]' "Run" -// @matches foo/index.html '//a[@class="test-arrow"][@href="https://www.example.com/?code=%23!%5Ballow(unused)%5D%0A%23!%5Bfeature(something)%5D%0A%0Afn+main()+%7B%0A++++println!(%22Hello,+world!%22);%0A%7D&version=nightly&edition=2015"]' "Run" +//@ matches foo/index.html '//a[@class="test-arrow"][@href="https://www.example.com/?code=%23!%5Ballow(unused)%5D%0Afn+main()+%7B%0A++++println!(%22Hello,+world!%22);%0A%7D&edition=2015"]' "Run" +//@ matches foo/index.html '//a[@class="test-arrow"][@href="https://www.example.com/?code=%23!%5Ballow(unused)%5D%0Afn+main()+%7B%0A++++println!(%22Hello,+world!%22);%0A%7D&edition=2015"]' "Run" +//@ matches foo/index.html '//a[@class="test-arrow"][@href="https://www.example.com/?code=%23!%5Ballow(unused)%5D%0A%23!%5Bfeature(something)%5D%0A%0Afn+main()+%7B%0A++++println!(%22Hello,+world!%22);%0A%7D&version=nightly&edition=2015"]' "Run" diff --git a/tests/rustdoc/primitive-link.rs b/tests/rustdoc/primitive-link.rs index 125e0c84973..3fe9cdc3ca7 100644 --- a/tests/rustdoc/primitive-link.rs +++ b/tests/rustdoc/primitive-link.rs @@ -1,12 +1,12 @@ #![crate_name = "foo"] -// @has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="{{channel}}/std/primitive.u32.html"]' 'u32' -// @has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="{{channel}}/std/primitive.i64.html"]' 'i64' -// @has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="{{channel}}/std/primitive.i32.html"]' 'std::primitive::i32' -// @has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="{{channel}}/std/primitive.str.html"]' 'std::primitive::str' +//@ has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="{{channel}}/std/primitive.u32.html"]' 'u32' +//@ has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="{{channel}}/std/primitive.i64.html"]' 'i64' +//@ has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="{{channel}}/std/primitive.i32.html"]' 'std::primitive::i32' +//@ has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="{{channel}}/std/primitive.str.html"]' 'std::primitive::str' -// @has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="{{channel}}/std/primitive.i32.html#associatedconstant.MAX"]' 'std::primitive::i32::MAX' +//@ has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="{{channel}}/std/primitive.i32.html#associatedconstant.MAX"]' 'std::primitive::i32::MAX' /// It contains [`u32`] and [i64]. /// It also links to [std::primitive::i32], [std::primitive::str], diff --git a/tests/rustdoc/primitive-raw-pointer-dox-15318-3.rs b/tests/rustdoc/primitive-raw-pointer-dox-15318-3.rs index 80c55975687..5520abf2925 100644 --- a/tests/rustdoc/primitive-raw-pointer-dox-15318-3.rs +++ b/tests/rustdoc/primitive-raw-pointer-dox-15318-3.rs @@ -2,7 +2,7 @@ #![crate_name="issue_15318_3"] #![feature(rustc_attrs)] -// @has issue_15318_3/primitive.pointer.html +//@ has issue_15318_3/primitive.pointer.html /// dox #[rustc_doc_primitive = "pointer"] diff --git a/tests/rustdoc/primitive-raw-pointer-link-15318.rs b/tests/rustdoc/primitive-raw-pointer-link-15318.rs index 66d84e9aaa3..a6f6f67dc84 100644 --- a/tests/rustdoc/primitive-raw-pointer-link-15318.rs +++ b/tests/rustdoc/primitive-raw-pointer-link-15318.rs @@ -7,7 +7,7 @@ extern crate issue_15318; -// @has issue_15318/fn.bar.html \ +//@ has issue_15318/fn.bar.html \ // '//*[@href="http://example.com/issue_15318/primitive.pointer.html"]' \ // '*mut T' pub fn bar<T>(ptr: *mut T) {} diff --git a/tests/rustdoc/primitive-raw-pointer-link-no-inlined-15318-2.rs b/tests/rustdoc/primitive-raw-pointer-link-no-inlined-15318-2.rs index e6c69c3407e..16b007e8bbd 100644 --- a/tests/rustdoc/primitive-raw-pointer-link-no-inlined-15318-2.rs +++ b/tests/rustdoc/primitive-raw-pointer-link-no-inlined-15318-2.rs @@ -9,7 +9,7 @@ extern crate issue_15318; pub use issue_15318::ptr; -// @!has issue_15318_2/fn.bar.html \ +//@ !has issue_15318_2/fn.bar.html \ // '//*[@href="primitive.pointer.html"]' \ // '*mut T' pub fn bar<T>(ptr: *mut T) {} diff --git a/tests/rustdoc/primitive-reexport.rs b/tests/rustdoc/primitive-reexport.rs index 7dbb7c6db50..eb255745392 100644 --- a/tests/rustdoc/primitive-reexport.rs +++ b/tests/rustdoc/primitive-reexport.rs @@ -3,26 +3,26 @@ #![crate_name = "bar"] -// @has bar/p/index.html -// @has - '//code' 'pub use bool;' -// @has - '//code/a[@href="{{channel}}/std/primitive.bool.html"]' 'bool' -// @has - '//code' 'pub use char as my_char;' -// @has - '//code/a[@href="{{channel}}/std/primitive.char.html"]' 'char' +//@ has bar/p/index.html +//@ has - '//code' 'pub use bool;' +//@ has - '//code/a[@href="{{channel}}/std/primitive.bool.html"]' 'bool' +//@ has - '//code' 'pub use char as my_char;' +//@ has - '//code/a[@href="{{channel}}/std/primitive.char.html"]' 'char' pub mod p { pub use foo::bar::*; } -// @has bar/baz/index.html -// @has - '//code' 'pub use bool;' -// @has - '//code/a[@href="{{channel}}/std/primitive.bool.html"]' 'bool' -// @has - '//code' 'pub use char as my_char;' -// @has - '//code/a[@href="{{channel}}/std/primitive.char.html"]' 'char' +//@ has bar/baz/index.html +//@ has - '//code' 'pub use bool;' +//@ has - '//code/a[@href="{{channel}}/std/primitive.bool.html"]' 'bool' +//@ has - '//code' 'pub use char as my_char;' +//@ has - '//code/a[@href="{{channel}}/std/primitive.char.html"]' 'char' pub use foo::bar as baz; -// @has bar/index.html -// @has - '//code' 'pub use str;' -// @has - '//code/a[@href="{{channel}}/std/primitive.str.html"]' 'str' -// @has - '//code' 'pub use i32 as my_i32;' -// @has - '//code/a[@href="{{channel}}/std/primitive.i32.html"]' 'i32' +//@ has bar/index.html +//@ has - '//code' 'pub use str;' +//@ has - '//code/a[@href="{{channel}}/std/primitive.str.html"]' 'str' +//@ has - '//code' 'pub use i32 as my_i32;' +//@ has - '//code/a[@href="{{channel}}/std/primitive.i32.html"]' 'i32' pub use str; pub use i32 as my_i32; diff --git a/tests/rustdoc/primitive-reference.rs b/tests/rustdoc/primitive-reference.rs index 6f034224df5..c12d65ee0c5 100644 --- a/tests/rustdoc/primitive-reference.rs +++ b/tests/rustdoc/primitive-reference.rs @@ -2,19 +2,19 @@ #![feature(rustc_attrs)] -// @has foo/index.html -// @has - '//h2[@id="primitives"]' 'Primitive Types' -// @has - '//a[@href="primitive.reference.html"]' 'reference' -// @has - '//div[@class="sidebar-elems"]//li/a' 'Primitive Types' -// @has - '//div[@class="sidebar-elems"]//li/a/@href' '#primitives' -// @has foo/primitive.reference.html -// @has - '//a[@class="primitive"]' 'reference' -// @has - '//h1' 'Primitive Type reference' -// @has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' +//@ has foo/index.html +//@ has - '//h2[@id="primitives"]' 'Primitive Types' +//@ has - '//a[@href="primitive.reference.html"]' 'reference' +//@ has - '//div[@class="sidebar-elems"]//li/a' 'Primitive Types' +//@ has - '//div[@class="sidebar-elems"]//li/a/@href' '#primitives' +//@ has foo/primitive.reference.html +//@ has - '//a[@class="primitive"]' 'reference' +//@ has - '//h1' 'Primitive Type reference' +//@ has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' // There should be only one implementation listed. -// @count - '//*[@class="impl"]' 1 -// @has - '//*[@id="impl-Foo%3C%26A%3E-for-%26B"]/*[@class="code-header"]' \ +//@ count - '//*[@class="impl"]' 1 +//@ has - '//*[@id="impl-Foo%3C%26A%3E-for-%26B"]/*[@class="code-header"]' \ // 'impl<A, B> Foo<&A> for &B' #[rustc_doc_primitive = "reference"] /// this is a test! diff --git a/tests/rustdoc/primitive-slice-auto-trait.rs b/tests/rustdoc/primitive-slice-auto-trait.rs index 359a08f6a31..a877b73cf9f 100644 --- a/tests/rustdoc/primitive-slice-auto-trait.rs +++ b/tests/rustdoc/primitive-slice-auto-trait.rs @@ -3,12 +3,12 @@ #![crate_name = "foo"] #![feature(rustc_attrs)] -// @has foo/primitive.slice.html '//a[@class="primitive"]' 'slice' -// @has - '//h1' 'Primitive Type slice' -// @has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' -// @has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations' -// @has - '//div[@id="synthetic-implementations-list"]//h3' 'impl<T> Send for [T]where T: Send' -// @has - '//div[@id="synthetic-implementations-list"]//h3' 'impl<T> Sync for [T]where T: Sync' +//@ has foo/primitive.slice.html '//a[@class="primitive"]' 'slice' +//@ has - '//h1' 'Primitive Type slice' +//@ has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' +//@ has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations' +//@ has - '//div[@id="synthetic-implementations-list"]//h3' 'impl<T> Send for [T]where T: Send' +//@ has - '//div[@id="synthetic-implementations-list"]//h3' 'impl<T> Sync for [T]where T: Sync' #[rustc_doc_primitive = "slice"] /// this is a test! mod slice_prim {} diff --git a/tests/rustdoc/primitive-tuple-auto-trait.rs b/tests/rustdoc/primitive-tuple-auto-trait.rs index 79737da3a2d..060c4ecfbdc 100644 --- a/tests/rustdoc/primitive-tuple-auto-trait.rs +++ b/tests/rustdoc/primitive-tuple-auto-trait.rs @@ -3,17 +3,17 @@ #![crate_name = "foo"] #![feature(rustc_attrs)] -// @has foo/primitive.tuple.html '//a[@class="primitive"]' 'tuple' -// @has - '//h1' 'Primitive Type tuple' -// @has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' -// @has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations' -// @has - '//div[@id="synthetic-implementations-list"]//h3' 'Send' -// @has - '//div[@id="synthetic-implementations-list"]//h3' 'Sync' +//@ has foo/primitive.tuple.html '//a[@class="primitive"]' 'tuple' +//@ has - '//h1' 'Primitive Type tuple' +//@ has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' +//@ has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations' +//@ has - '//div[@id="synthetic-implementations-list"]//h3' 'Send' +//@ has - '//div[@id="synthetic-implementations-list"]//h3' 'Sync' #[rustc_doc_primitive = "tuple"] /// this is a test! /// // Hardcoded anchor to header written in library/core/src/primitive_docs.rs -// @has - '//h2[@id="trait-implementations-1"]' 'Trait implementations' +//@ has - '//h2[@id="trait-implementations-1"]' 'Trait implementations' /// # Trait implementations /// /// This header is hard-coded in the HTML format linking for `#[doc(fake_variadics)]`. diff --git a/tests/rustdoc/primitive-tuple-variadic.rs b/tests/rustdoc/primitive-tuple-variadic.rs index 546cf2ace42..4b2fb786a89 100644 --- a/tests/rustdoc/primitive-tuple-variadic.rs +++ b/tests/rustdoc/primitive-tuple-variadic.rs @@ -5,14 +5,14 @@ pub trait Foo {} -// @has foo/trait.Foo.html -// @has - '//section[@id="impl-Foo-for-(T,)"]/h3' 'impl<T> Foo for (T₁, T₂, …, Tₙ)' +//@ has foo/trait.Foo.html +//@ has - '//section[@id="impl-Foo-for-(T,)"]/h3' 'impl<T> Foo for (T₁, T₂, …, Tₙ)' #[doc(fake_variadic)] impl<T> Foo for (T,) {} pub trait Bar {} -// @has foo/trait.Bar.html -// @has - '//section[@id="impl-Bar-for-(U,)"]/h3' 'impl<U: Foo> Bar for (U₁, U₂, …, Uₙ)' +//@ has foo/trait.Bar.html +//@ has - '//section[@id="impl-Bar-for-(U,)"]/h3' 'impl<U: Foo> Bar for (U₁, U₂, …, Uₙ)' #[doc(fake_variadic)] impl<U: Foo> Bar for (U,) {} diff --git a/tests/rustdoc/primitive-unit-auto-trait.rs b/tests/rustdoc/primitive-unit-auto-trait.rs index ff86a555cda..7751a2bf1d0 100644 --- a/tests/rustdoc/primitive-unit-auto-trait.rs +++ b/tests/rustdoc/primitive-unit-auto-trait.rs @@ -3,12 +3,12 @@ #![crate_name = "foo"] #![feature(rustc_attrs)] -// @has foo/primitive.unit.html '//a[@class="primitive"]' 'unit' -// @has - '//h1' 'Primitive Type unit' -// @has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' -// @has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations' -// @has - '//div[@id="synthetic-implementations-list"]//h3' 'impl Send for ()' -// @has - '//div[@id="synthetic-implementations-list"]//h3' 'impl Sync for ()' +//@ has foo/primitive.unit.html '//a[@class="primitive"]' 'unit' +//@ has - '//h1' 'Primitive Type unit' +//@ has - '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' +//@ has - '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementations' +//@ has - '//div[@id="synthetic-implementations-list"]//h3' 'impl Send for ()' +//@ has - '//div[@id="synthetic-implementations-list"]//h3' 'impl Sync for ()' #[rustc_doc_primitive = "unit"] /// this is a test! mod unit_prim {} diff --git a/tests/rustdoc/primitive/no_std.rs b/tests/rustdoc/primitive/no_std.rs index f0f70cb6c18..b3d47e7384b 100644 --- a/tests/rustdoc/primitive/no_std.rs +++ b/tests/rustdoc/primitive/no_std.rs @@ -2,8 +2,8 @@ #![deny(warnings)] #![deny(rustdoc::broken_intra_doc_links)] -// @has no_std/fn.foo.html '//a/[@href="{{channel}}/core/primitive.u8.html"]' 'u8' -// @has no_std/fn.foo.html '//a/[@href="{{channel}}/core/primitive.u8.html"]' 'primitive link' +//@ has no_std/fn.foo.html '//a/[@href="{{channel}}/core/primitive.u8.html"]' 'u8' +//@ has no_std/fn.foo.html '//a/[@href="{{channel}}/core/primitive.u8.html"]' 'primitive link' /// Link to [primitive link][u8] pub fn foo() -> u8 {} diff --git a/tests/rustdoc/primitive/primitive-generic-impl.rs b/tests/rustdoc/primitive/primitive-generic-impl.rs index 558336d7316..b342e977cf0 100644 --- a/tests/rustdoc/primitive/primitive-generic-impl.rs +++ b/tests/rustdoc/primitive/primitive-generic-impl.rs @@ -1,7 +1,7 @@ #![feature(rustc_attrs)] #![crate_name = "foo"] -// @has foo/primitive.i32.html '//*[@id="impl-ToString-for-T"]//h3[@class="code-header"]' 'impl<T> ToString for T' +//@ has foo/primitive.i32.html '//*[@id="impl-ToString-for-T"]//h3[@class="code-header"]' 'impl<T> ToString for T' #[rustc_doc_primitive = "i32"] /// Some useless docs, wouhou! diff --git a/tests/rustdoc/primitive/primitive.rs b/tests/rustdoc/primitive/primitive.rs index 4b89fd9dfb7..b54c3dd1cd6 100644 --- a/tests/rustdoc/primitive/primitive.rs +++ b/tests/rustdoc/primitive/primitive.rs @@ -4,30 +4,30 @@ #![feature(f16)] #![feature(f128)] -// @has foo/index.html '//h2[@id="primitives"]' 'Primitive Types' -// @has foo/index.html '//a[@href="primitive.i32.html"]' 'i32' -// @has foo/index.html '//div[@class="sidebar-elems"]//li/a' 'Primitive Types' -// @has foo/index.html '//div[@class="sidebar-elems"]//li/a/@href' '#primitives' -// @has foo/primitive.i32.html '//a[@class="primitive"]' 'i32' -// @has foo/primitive.i32.html '//h1' 'Primitive Type i32' -// @has foo/primitive.i32.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' -// @has foo/index.html '//a/@href' '../foo/index.html' -// @!has foo/index.html '//span' '🔒' +//@ has foo/index.html '//h2[@id="primitives"]' 'Primitive Types' +//@ has foo/index.html '//a[@href="primitive.i32.html"]' 'i32' +//@ has foo/index.html '//div[@class="sidebar-elems"]//li/a' 'Primitive Types' +//@ has foo/index.html '//div[@class="sidebar-elems"]//li/a/@href' '#primitives' +//@ has foo/primitive.i32.html '//a[@class="primitive"]' 'i32' +//@ has foo/primitive.i32.html '//h1' 'Primitive Type i32' +//@ has foo/primitive.i32.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' +//@ has foo/index.html '//a/@href' '../foo/index.html' +//@ !has foo/index.html '//span' '🔒' #[rustc_doc_primitive = "i32"] /// this is a test! mod i32 {} -// @has foo/primitive.bool.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'hello' +//@ has foo/primitive.bool.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'hello' #[rustc_doc_primitive = "bool"] /// hello mod bool {} -// @has foo/primitive.f16.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'hello' +//@ has foo/primitive.f16.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'hello' #[rustc_doc_primitive = "f16"] /// hello mod f16 {} -// @has foo/primitive.f128.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'hello' +//@ has foo/primitive.f128.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'hello' #[rustc_doc_primitive = "f128"] /// hello mod f128 {} diff --git a/tests/rustdoc/private-fields-tuple-struct.rs b/tests/rustdoc/private-fields-tuple-struct.rs index c6989dd8cdf..51141923cd8 100644 --- a/tests/rustdoc/private-fields-tuple-struct.rs +++ b/tests/rustdoc/private-fields-tuple-struct.rs @@ -1,15 +1,15 @@ // This test checks the diplay of "/* private fields */" sentence in tuple structs. #![crate_name = "foo"] -// @has 'foo/struct.A.html' '//*[@class="rust item-decl"]/code' 'pub struct A(pub u8, _);' +//@ has 'foo/struct.A.html' '//*[@class="rust item-decl"]/code' 'pub struct A(pub u8, _);' pub struct A(pub u8, u8); -// @has 'foo/struct.B.html' '//*[@class="rust item-decl"]/code' 'pub struct B(_, pub u8);' +//@ has 'foo/struct.B.html' '//*[@class="rust item-decl"]/code' 'pub struct B(_, pub u8);' pub struct B(u8, pub u8); -// @has 'foo/struct.C.html' '//*[@class="rust item-decl"]/code' 'pub struct C(_, pub u8, _);' +//@ has 'foo/struct.C.html' '//*[@class="rust item-decl"]/code' 'pub struct C(_, pub u8, _);' pub struct C(u8, pub u8, u8); -// @has 'foo/struct.D.html' '//*[@class="rust item-decl"]/code' 'pub struct D(pub u8, _, pub u8);' +//@ has 'foo/struct.D.html' '//*[@class="rust item-decl"]/code' 'pub struct D(pub u8, _, pub u8);' pub struct D(pub u8, u8, pub u8); -// @has 'foo/struct.E.html' '//*[@class="rust item-decl"]/code' 'pub struct E(/* private fields */);' +//@ has 'foo/struct.E.html' '//*[@class="rust item-decl"]/code' 'pub struct E(/* private fields */);' pub struct E(u8); -// @has 'foo/struct.F.html' '//*[@class="rust item-decl"]/code' 'pub struct F(/* private fields */);' +//@ has 'foo/struct.F.html' '//*[@class="rust item-decl"]/code' 'pub struct F(/* private fields */);' pub struct F(u8, u8); diff --git a/tests/rustdoc/private-non-local-fields-2.rs b/tests/rustdoc/private-non-local-fields-2.rs index 615b957f697..f2d3530c088 100644 --- a/tests/rustdoc/private-non-local-fields-2.rs +++ b/tests/rustdoc/private-non-local-fields-2.rs @@ -7,5 +7,5 @@ use std::collections::BTreeMap; -// @has 'foo/type.FooBar.html' '//*[@class="rust item-decl"]/code' 'struct FooBar { /* private fields */ }' +//@ has 'foo/type.FooBar.html' '//*[@class="rust item-decl"]/code' 'struct FooBar { /* private fields */ }' pub type FooBar = BTreeMap<u32, String>; diff --git a/tests/rustdoc/private-non-local-fields.rs b/tests/rustdoc/private-non-local-fields.rs index 7922ce074dd..aa7f01a58c6 100644 --- a/tests/rustdoc/private-non-local-fields.rs +++ b/tests/rustdoc/private-non-local-fields.rs @@ -5,5 +5,5 @@ use std::collections::BTreeMap; -// @has 'foo/type.FooBar.html' '//*[@class="rust item-decl"]/code' 'struct FooBar { /* private fields */ }' +//@ has 'foo/type.FooBar.html' '//*[@class="rust item-decl"]/code' 'struct FooBar { /* private fields */ }' pub type FooBar = BTreeMap<u32, String>; diff --git a/tests/rustdoc/private-type-alias.rs b/tests/rustdoc/private-type-alias.rs index ec7385404f0..5b5f52728a9 100644 --- a/tests/rustdoc/private-type-alias.rs +++ b/tests/rustdoc/private-type-alias.rs @@ -1,12 +1,12 @@ type MyResultPriv<T> = Result<T, u16>; pub type MyResultPub<T> = Result<T, u64>; -// @has private_type_alias/fn.get_result_priv.html '//pre' 'Result<u8, u16>' +//@ has private_type_alias/fn.get_result_priv.html '//pre' 'Result<u8, u16>' pub fn get_result_priv() -> MyResultPriv<u8> { panic!(); } -// @has private_type_alias/fn.get_result_pub.html '//pre' 'MyResultPub<u32>' +//@ has private_type_alias/fn.get_result_pub.html '//pre' 'MyResultPub<u32>' pub fn get_result_pub() -> MyResultPub<u32> { panic!(); } @@ -18,14 +18,14 @@ type PrivRecursive1 = PrivRecursive3; // PrivRecursive1 is expanded twice and stops at u8 // PrivRecursive2 is expanded once and stops at public type alias PubRecursive -// @has private_type_alias/fn.get_result_recursive.html '//pre' '(u8, PubRecursive)' +//@ has private_type_alias/fn.get_result_recursive.html '//pre' '(u8, PubRecursive)' pub fn get_result_recursive() -> (PrivRecursive1, PrivRecursive2) { panic!(); } type MyLifetimePriv<'a> = &'a isize; -// @has private_type_alias/fn.get_lifetime_priv.html '//pre' "&'static isize" +//@ has private_type_alias/fn.get_lifetime_priv.html '//pre' "&'static isize" pub fn get_lifetime_priv() -> MyLifetimePriv<'static> { panic!(); } diff --git a/tests/rustdoc/private-use-decl-macro-47038.rs b/tests/rustdoc/private-use-decl-macro-47038.rs index 8944bdd42b4..b72fca06d3b 100644 --- a/tests/rustdoc/private-use-decl-macro-47038.rs +++ b/tests/rustdoc/private-use-decl-macro-47038.rs @@ -6,7 +6,7 @@ use std::vec; -// @has 'foo/index.html' -// @!has - '//*[@id="macros"]' 'Macros' -// @!has - '//a/@href' 'macro.vec.html' -// @!has 'foo/macro.vec.html' +//@ has 'foo/index.html' +//@ !has - '//*[@id="macros"]' 'Macros' +//@ !has - '//a/@href' 'macro.vec.html' +//@ !has 'foo/macro.vec.html' diff --git a/tests/rustdoc/proc-macro.rs b/tests/rustdoc/proc-macro.rs index 57bf228052c..a821f68ab93 100644 --- a/tests/rustdoc/proc-macro.rs +++ b/tests/rustdoc/proc-macro.rs @@ -5,8 +5,8 @@ #![crate_type="proc-macro"] #![crate_name="some_macros"] -// @has some_macros/index.html -// @has - '//a/[@href="attr.some_proc_attr.html"]' 'some_proc_attr' +//@ has some_macros/index.html +//@ has - '//a/[@href="attr.some_proc_attr.html"]' 'some_proc_attr' //! include a link to [some_proc_macro!] to make sure it works. @@ -14,59 +14,59 @@ extern crate proc_macro; use proc_macro::TokenStream; -// @has some_macros/index.html -// @has - '//h2' 'Macros' -// @has - '//h2' 'Attribute Macros' -// @has - '//h2' 'Derive Macros' -// @!has - '//h2' 'Functions' +//@ has some_macros/index.html +//@ has - '//h2' 'Macros' +//@ has - '//h2' 'Attribute Macros' +//@ has - '//h2' 'Derive Macros' +//@ !has - '//h2' 'Functions' -// @has some_macros/all.html -// @has - '//a[@href="macro.some_proc_macro.html"]' 'some_proc_macro' -// @has - '//a[@href="attr.some_proc_attr.html"]' 'some_proc_attr' -// @has - '//a[@href="derive.SomeDerive.html"]' 'SomeDerive' -// @!has - '//a/@href' 'fn.some_proc_macro.html' -// @!has - '//a/@href' 'fn.some_proc_attr.html' -// @!has - '//a/@href' 'fn.some_derive.html' +//@ has some_macros/all.html +//@ has - '//a[@href="macro.some_proc_macro.html"]' 'some_proc_macro' +//@ has - '//a[@href="attr.some_proc_attr.html"]' 'some_proc_attr' +//@ has - '//a[@href="derive.SomeDerive.html"]' 'SomeDerive' +//@ !has - '//a/@href' 'fn.some_proc_macro.html' +//@ !has - '//a/@href' 'fn.some_proc_attr.html' +//@ !has - '//a/@href' 'fn.some_derive.html' -// @has some_macros/index.html '//a/@href' 'macro.some_proc_macro.html' -// @!has - '//a/@href' 'fn.some_proc_macro.html' -// @has some_macros/macro.some_proc_macro.html -// @!has some_macros/fn.some_proc_macro.html +//@ has some_macros/index.html '//a/@href' 'macro.some_proc_macro.html' +//@ !has - '//a/@href' 'fn.some_proc_macro.html' +//@ has some_macros/macro.some_proc_macro.html +//@ !has some_macros/fn.some_proc_macro.html /// a proc-macro that swallows its input and does nothing. #[proc_macro] pub fn some_proc_macro(_input: TokenStream) -> TokenStream { TokenStream::new() } -// @has some_macros/index.html '//a/@href' 'attr.some_proc_attr.html' -// @!has - '//a/@href' 'fn.some_proc_attr.html' -// @has some_macros/attr.some_proc_attr.html -// @!has some_macros/fn.some_proc_attr.html +//@ has some_macros/index.html '//a/@href' 'attr.some_proc_attr.html' +//@ !has - '//a/@href' 'fn.some_proc_attr.html' +//@ has some_macros/attr.some_proc_attr.html +//@ !has some_macros/fn.some_proc_attr.html /// a proc-macro attribute that passes its item through verbatim. #[proc_macro_attribute] pub fn some_proc_attr(_attr: TokenStream, item: TokenStream) -> TokenStream { item } -// @has some_macros/index.html '//a/@href' 'derive.SomeDerive.html' -// @!has - '//a/@href' 'fn.some_derive.html' -// @has some_macros/derive.SomeDerive.html -// @!has some_macros/fn.some_derive.html +//@ has some_macros/index.html '//a/@href' 'derive.SomeDerive.html' +//@ !has - '//a/@href' 'fn.some_derive.html' +//@ has some_macros/derive.SomeDerive.html +//@ !has some_macros/fn.some_derive.html /// a derive attribute that adds nothing to its input. #[proc_macro_derive(SomeDerive)] pub fn some_derive(_item: TokenStream) -> TokenStream { TokenStream::new() } -// @has some_macros/foo/index.html +//@ has some_macros/foo/index.html mod foo { - // @has - '//code' 'pub use some_proc_macro;' - // @has - '//a/@href' '../macro.some_proc_macro.html' + //@ has - '//code' 'pub use some_proc_macro;' + //@ has - '//a/@href' '../macro.some_proc_macro.html' pub use some_proc_macro; - // @has - '//code' 'pub use some_proc_attr;' - // @has - '//a/@href' '../attr.some_proc_attr.html' + //@ has - '//code' 'pub use some_proc_attr;' + //@ has - '//a/@href' '../attr.some_proc_attr.html' pub use some_proc_attr; - // @has - '//code' 'pub use some_derive;' - // @has - '//a/@href' '../derive.SomeDerive.html' + //@ has - '//code' 'pub use some_derive;' + //@ has - '//a/@href' '../derive.SomeDerive.html' pub use some_derive; } diff --git a/tests/rustdoc/pub-extern-crate.rs b/tests/rustdoc/pub-extern-crate.rs index c5be51f35ac..05f70301e33 100644 --- a/tests/rustdoc/pub-extern-crate.rs +++ b/tests/rustdoc/pub-extern-crate.rs @@ -1,9 +1,9 @@ //@ aux-build:pub-extern-crate.rs -// @has pub_extern_crate/index.html -// @!has - '//code' 'pub extern crate inner' -// @has - '//a/@href' 'inner/index.html' -// @has pub_extern_crate/inner/index.html -// @has pub_extern_crate/inner/struct.SomeStruct.html +//@ has pub_extern_crate/index.html +//@ !has - '//code' 'pub extern crate inner' +//@ has - '//a/@href' 'inner/index.html' +//@ has pub_extern_crate/inner/index.html +//@ has pub_extern_crate/inner/struct.SomeStruct.html #[doc(inline)] pub extern crate inner; diff --git a/tests/rustdoc/pub-method.rs b/tests/rustdoc/pub-method.rs index 2a77aa75352..a759967fae5 100644 --- a/tests/rustdoc/pub-method.rs +++ b/tests/rustdoc/pub-method.rs @@ -2,16 +2,16 @@ #![crate_name = "foo"] -// @has foo/fn.bar.html -// @has - '//pre[@class="rust item-decl"]' 'pub fn bar() -> ' +//@ has foo/fn.bar.html +//@ has - '//pre[@class="rust item-decl"]' 'pub fn bar() -> ' /// foo pub fn bar() -> usize { 2 } -// @has foo/struct.Foo.html -// @has - '//*[@class="method"]' 'pub fn new()' -// @has - '//*[@class="method"]' 'fn not_pub()' +//@ has foo/struct.Foo.html +//@ has - '//*[@class="method"]' 'pub fn new()' +//@ has - '//*[@class="method"]' 'fn not_pub()' pub struct Foo(usize); impl Foo { diff --git a/tests/rustdoc/pub-reexport-of-pub-reexport-46506.rs b/tests/rustdoc/pub-reexport-of-pub-reexport-46506.rs index ae0aead244b..f9569902927 100644 --- a/tests/rustdoc/pub-reexport-of-pub-reexport-46506.rs +++ b/tests/rustdoc/pub-reexport-of-pub-reexport-46506.rs @@ -3,11 +3,11 @@ #![crate_name = "foo"] -// @has 'foo/associations/index.html' -// @count - '//*[@id="main-content"]/*[@class="section-header"]' 1 -// @has - '//*[@id="main-content"]/*[@class="section-header"]' 'Traits' -// @has - '//*[@id="main-content"]//a[@href="trait.GroupedBy.html"]' 'GroupedBy' -// @has 'foo/associations/trait.GroupedBy.html' +//@ has 'foo/associations/index.html' +//@ count - '//*[@id="main-content"]/*[@class="section-header"]' 1 +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Traits' +//@ has - '//*[@id="main-content"]//a[@href="trait.GroupedBy.html"]' 'GroupedBy' +//@ has 'foo/associations/trait.GroupedBy.html' pub mod associations { mod belongs_to { pub trait GroupedBy {} @@ -15,10 +15,10 @@ pub mod associations { pub use self::belongs_to::GroupedBy; } -// @has 'foo/prelude/index.html' -// @count - '//*[@id="main-content"]/*[@class="section-header"]' 1 -// @has - '//*[@id="main-content"]/*[@class="section-header"]' 'Re-exports' -// @has - '//*[@id="main-content"]//*[@id="reexport.GroupedBy"]' 'pub use associations::GroupedBy;' +//@ has 'foo/prelude/index.html' +//@ count - '//*[@id="main-content"]/*[@class="section-header"]' 1 +//@ has - '//*[@id="main-content"]/*[@class="section-header"]' 'Re-exports' +//@ has - '//*[@id="main-content"]//*[@id="reexport.GroupedBy"]' 'pub use associations::GroupedBy;' pub mod prelude { pub use associations::GroupedBy; } diff --git a/tests/rustdoc/pub-use-extern-macros.rs b/tests/rustdoc/pub-use-extern-macros.rs index d3d667297fb..2316e620343 100644 --- a/tests/rustdoc/pub-use-extern-macros.rs +++ b/tests/rustdoc/pub-use-extern-macros.rs @@ -2,16 +2,16 @@ extern crate macros; -// @has pub_use_extern_macros/macro.bar.html -// @!has pub_use_extern_macros/index.html '//code' 'pub use macros::bar;' +//@ has pub_use_extern_macros/macro.bar.html +//@ !has pub_use_extern_macros/index.html '//code' 'pub use macros::bar;' pub use macros::bar; -// @has pub_use_extern_macros/macro.baz.html -// @!has pub_use_extern_macros/index.html '//code' 'pub use macros::baz;' +//@ has pub_use_extern_macros/macro.baz.html +//@ !has pub_use_extern_macros/index.html '//code' 'pub use macros::baz;' #[doc(inline)] pub use macros::baz; -// @!has pub_use_extern_macros/macro.quux.html -// @!has pub_use_extern_macros/index.html '//code' 'pub use macros::quux;' +//@ !has pub_use_extern_macros/macro.quux.html +//@ !has pub_use_extern_macros/index.html '//code' 'pub use macros::quux;' #[doc(hidden)] pub use macros::quux; diff --git a/tests/rustdoc/pub-use-root-path-95873.rs b/tests/rustdoc/pub-use-root-path-95873.rs index 5a817fb3409..e3d5ee6e315 100644 --- a/tests/rustdoc/pub-use-root-path-95873.rs +++ b/tests/rustdoc/pub-use-root-path-95873.rs @@ -1,5 +1,5 @@ // https://github.com/rust-lang/rust/issues/95873 #![crate_name = "foo"] -// @has foo/index.html "//*[@class='item-name']" "pub use ::std as x;" +//@ has foo/index.html "//*[@class='item-name']" "pub use ::std as x;" pub use ::std as x; diff --git a/tests/rustdoc/public-impl-mention-private-generic-46380-2.rs b/tests/rustdoc/public-impl-mention-private-generic-46380-2.rs index 96ebd888eb5..0445ae75e85 100644 --- a/tests/rustdoc/public-impl-mention-private-generic-46380-2.rs +++ b/tests/rustdoc/public-impl-mention-private-generic-46380-2.rs @@ -3,10 +3,10 @@ pub trait PublicTrait<T> {} -// @has foo/struct.PublicStruct.html +//@ has foo/struct.PublicStruct.html pub struct PublicStruct; -// @!has - '//*[@class="impl"]' 'impl PublicTrait<PrivateStruct> for PublicStruct' +//@ !has - '//*[@class="impl"]' 'impl PublicTrait<PrivateStruct> for PublicStruct' impl PublicTrait<PrivateStruct> for PublicStruct {} struct PrivateStruct; diff --git a/tests/rustdoc/range-arg-pattern.rs b/tests/rustdoc/range-arg-pattern.rs index d0d9111bb40..e5de6ba464b 100644 --- a/tests/rustdoc/range-arg-pattern.rs +++ b/tests/rustdoc/range-arg-pattern.rs @@ -1,5 +1,5 @@ #![crate_name = "foo"] -// @has foo/fn.f.html -// @has - '//pre[@class="rust item-decl"]' 'pub fn f(_: u8)' +//@ has foo/fn.f.html +//@ has - '//pre[@class="rust item-decl"]' 'pub fn f(_: u8)' pub fn f(0u8..=255: u8) {} diff --git a/tests/rustdoc/raw-ident-eliminate-r-hashtag.rs b/tests/rustdoc/raw-ident-eliminate-r-hashtag.rs index 7dbe63854f3..d9b88627ae5 100644 --- a/tests/rustdoc/raw-ident-eliminate-r-hashtag.rs +++ b/tests/rustdoc/raw-ident-eliminate-r-hashtag.rs @@ -1,7 +1,7 @@ #![crate_type="lib"] pub mod internal { - // @has 'raw_ident_eliminate_r_hashtag/internal/struct.mod.html' + //@ has 'raw_ident_eliminate_r_hashtag/internal/struct.mod.html' #[allow(non_camel_case_types)] pub struct r#mod; @@ -9,13 +9,13 @@ pub mod internal { /// /// [name]: mod /// [other name]: crate::internal::mod - // @has 'raw_ident_eliminate_r_hashtag/internal/struct.B.html' '//*a[@href="struct.mod.html"]' 'name' - // @has 'raw_ident_eliminate_r_hashtag/internal/struct.B.html' '//*a[@href="struct.mod.html"]' 'other name' + //@ has 'raw_ident_eliminate_r_hashtag/internal/struct.B.html' '//*a[@href="struct.mod.html"]' 'name' + //@ has 'raw_ident_eliminate_r_hashtag/internal/struct.B.html' '//*a[@href="struct.mod.html"]' 'other name' pub struct B; } /// See [name]. /// /// [name]: internal::mod -// @has 'raw_ident_eliminate_r_hashtag/struct.A.html' '//*a[@href="internal/struct.mod.html"]' 'name' +//@ has 'raw_ident_eliminate_r_hashtag/struct.A.html' '//*a[@href="internal/struct.mod.html"]' 'name' pub struct A; diff --git a/tests/rustdoc/read-more-unneeded.rs b/tests/rustdoc/read-more-unneeded.rs index 0303e444261..783ebe78200 100644 --- a/tests/rustdoc/read-more-unneeded.rs +++ b/tests/rustdoc/read-more-unneeded.rs @@ -23,12 +23,12 @@ pub trait MyFrom { pub struct NonZero; -// @has 'foo/struct.NonZero.html' +//@ has 'foo/struct.NonZero.html' impl MyFrom for NonZero { - // @matches - '//*[@class="docblock"]' '^Hello Read more$' + //@ matches - '//*[@class="docblock"]' '^Hello Read more$' fn try_from1() {} - // @matches - '//*[@class="docblock"]' '^a\sb\sc$' + //@ matches - '//*[@class="docblock"]' '^a\sb\sc$' fn try_from2() {} - // @matches - '//*[@class="docblock"]' '^a Read more$' + //@ matches - '//*[@class="docblock"]' '^a Read more$' fn try_from3() {} } diff --git a/tests/rustdoc/redirect-const.rs b/tests/rustdoc/redirect-const.rs index 453da8387ea..e636a915f30 100644 --- a/tests/rustdoc/redirect-const.rs +++ b/tests/rustdoc/redirect-const.rs @@ -4,10 +4,10 @@ pub use hidden::STATIC_FOO; pub use hidden::CONST_FOO; mod hidden { - // @has foo/hidden/static.STATIC_FOO.html - // @has - '//p/a' '../../foo/static.STATIC_FOO.html' + //@ has foo/hidden/static.STATIC_FOO.html + //@ has - '//p/a' '../../foo/static.STATIC_FOO.html' pub static STATIC_FOO: u64 = 0; - // @has foo/hidden/constant.CONST_FOO.html - // @has - '//p/a' '../../foo/constant.CONST_FOO.html' + //@ has foo/hidden/constant.CONST_FOO.html + //@ has - '//p/a' '../../foo/constant.CONST_FOO.html' pub const CONST_FOO: u64 = 0; } diff --git a/tests/rustdoc/redirect-map-empty.rs b/tests/rustdoc/redirect-map-empty.rs index 12e500e785e..7d215fc230e 100644 --- a/tests/rustdoc/redirect-map-empty.rs +++ b/tests/rustdoc/redirect-map-empty.rs @@ -2,5 +2,5 @@ #![crate_name = "foo"] -// @!has foo/redirect-map.json +//@ !has foo/redirect-map.json pub struct Foo; diff --git a/tests/rustdoc/redirect-map.rs b/tests/rustdoc/redirect-map.rs index 3ad25298494..0207ba98fdb 100644 --- a/tests/rustdoc/redirect-map.rs +++ b/tests/rustdoc/redirect-map.rs @@ -2,9 +2,9 @@ #![crate_name = "foo"] -// @!has foo/private/struct.Quz.html -// @!has foo/hidden/struct.Bar.html -// @has foo/redirect-map.json +//@ !has foo/private/struct.Quz.html +//@ !has foo/hidden/struct.Bar.html +//@ has foo/redirect-map.json pub use private::Quz; pub use hidden::Bar; diff --git a/tests/rustdoc/redirect-rename.rs b/tests/rustdoc/redirect-rename.rs index 504c0687c8d..724dd4978ca 100644 --- a/tests/rustdoc/redirect-rename.rs +++ b/tests/rustdoc/redirect-rename.rs @@ -1,34 +1,34 @@ #![crate_name = "foo"] mod hidden { - // @has foo/hidden/struct.Foo.html - // @has - '//p/a' '../../foo/struct.FooBar.html' + //@ has foo/hidden/struct.Foo.html + //@ has - '//p/a' '../../foo/struct.FooBar.html' pub struct Foo {} pub union U { a: usize } pub enum Empty {} pub const C: usize = 1; pub static S: usize = 1; - // @has foo/hidden/bar/index.html - // @has - '//p/a' '../../foo/baz/index.html' + //@ has foo/hidden/bar/index.html + //@ has - '//p/a' '../../foo/baz/index.html' pub mod bar { - // @has foo/hidden/bar/struct.Thing.html - // @has - '//p/a' '../../foo/baz/struct.Thing.html' + //@ has foo/hidden/bar/struct.Thing.html + //@ has - '//p/a' '../../foo/baz/struct.Thing.html' pub struct Thing {} } } -// @has foo/struct.FooBar.html +//@ has foo/struct.FooBar.html pub use hidden::Foo as FooBar; -// @has foo/union.FooU.html +//@ has foo/union.FooU.html pub use hidden::U as FooU; -// @has foo/enum.FooEmpty.html +//@ has foo/enum.FooEmpty.html pub use hidden::Empty as FooEmpty; -// @has foo/constant.FooC.html +//@ has foo/constant.FooC.html pub use hidden::C as FooC; -// @has foo/static.FooS.html +//@ has foo/static.FooS.html pub use hidden::S as FooS; -// @has foo/baz/index.html -// @has foo/baz/struct.Thing.html +//@ has foo/baz/index.html +//@ has foo/baz/struct.Thing.html pub use hidden::bar as baz; diff --git a/tests/rustdoc/redirect.rs b/tests/rustdoc/redirect.rs index dc3a06b94d0..e52d3e5e83e 100644 --- a/tests/rustdoc/redirect.rs +++ b/tests/rustdoc/redirect.rs @@ -6,25 +6,25 @@ extern crate reexp_stripped; pub trait Foo {} -// @has redirect/index.html -// @has - '//code' 'pub use reexp_stripped::Bar' -// @has - '//code/a' 'Bar' -// @has - '//a[@href="../reexp_stripped/hidden/struct.Bar.html"]' 'Bar' +//@ has redirect/index.html +//@ has - '//code' 'pub use reexp_stripped::Bar' +//@ has - '//code/a' 'Bar' +//@ has - '//a[@href="../reexp_stripped/hidden/struct.Bar.html"]' 'Bar' // FIXME: Should be `@!has`: https://github.com/rust-lang/rust/issues/111249 -// @has reexp_stripped/hidden/struct.Bar.html -// @matchesraw - '<meta http-equiv="refresh" content="0;URL=../../reexp_stripped/struct.Bar.html">' -// @has 'reexp_stripped/struct.Bar.html' -// @has - '//a[@href="struct.Bar.html"]' 'Bar' +//@ has reexp_stripped/hidden/struct.Bar.html +//@ matchesraw - '<meta http-equiv="refresh" content="0;URL=../../reexp_stripped/struct.Bar.html">' +//@ has 'reexp_stripped/struct.Bar.html' +//@ has - '//a[@href="struct.Bar.html"]' 'Bar' #[doc(no_inline)] pub use reexp_stripped::Bar; impl Foo for Bar {} -// @has redirect/index.html -// @has - '//code' 'pub use reexp_stripped::Quz' -// @has - '//code/a' 'Quz' -// @has reexp_stripped/private/struct.Quz.html -// @has - '//p/a' '../../reexp_stripped/struct.Quz.html' -// @has 'reexp_stripped/struct.Quz.html' +//@ has redirect/index.html +//@ has - '//code' 'pub use reexp_stripped::Quz' +//@ has - '//code/a' 'Quz' +//@ has reexp_stripped/private/struct.Quz.html +//@ has - '//p/a' '../../reexp_stripped/struct.Quz.html' +//@ has 'reexp_stripped/struct.Quz.html' #[doc(no_inline)] pub use reexp_stripped::Quz; impl Foo for Quz {} @@ -34,9 +34,9 @@ mod private_no_inline { impl ::Foo for Qux {} } -// @has redirect/index.html -// @has - '//code' 'pub use private_no_inline::Qux' -// @!has - '//a' 'Qux' -// @!has redirect/struct.Qux.html +//@ has redirect/index.html +//@ has - '//code' 'pub use private_no_inline::Qux' +//@ !has - '//a' 'Qux' +//@ !has redirect/struct.Qux.html #[doc(no_inline)] pub use private_no_inline::Qux; diff --git a/tests/rustdoc/reexport-attr-merge.rs b/tests/rustdoc/reexport-attr-merge.rs index 6cc054e7a8b..e4a406c3845 100644 --- a/tests/rustdoc/reexport-attr-merge.rs +++ b/tests/rustdoc/reexport-attr-merge.rs @@ -5,7 +5,7 @@ #![crate_name = "foo"] #![feature(doc_cfg)] -// @has 'foo/index.html' +//@ has 'foo/index.html' #[doc(hidden, cfg(feature = "foo"))] pub struct Foo; @@ -18,16 +18,16 @@ pub use Foo1 as Foo2; // First we ensure that only the reexport `Bar2` and the inlined struct `Bar` // are inlined. -// @count - '//a[@class="struct"]' 2 +//@ count - '//a[@class="struct"]' 2 // Then we check that `cfg` is displayed for base item, but not for intermediate re-exports. -// @has - '//*[@class="stab portability"]' 'foo' -// @!has - '//*[@class="stab portability"]' 'bar' +//@ has - '//*[@class="stab portability"]' 'foo' +//@ !has - '//*[@class="stab portability"]' 'bar' // And finally we check that the only element displayed is `Bar`. -// @has - '//a[@class="struct"]' 'Bar' +//@ has - '//a[@class="struct"]' 'Bar' #[doc(inline)] pub use Foo2 as Bar; // This one should appear but `Bar2` won't be linked because there is no // `#[doc(inline)]`. -// @has - '//*[@id="reexport.Bar2"]' 'pub use Foo2 as Bar2;' +//@ has - '//*[@id="reexport.Bar2"]' 'pub use Foo2 as Bar2;' pub use Foo2 as Bar2; diff --git a/tests/rustdoc/reexport-cfg.rs b/tests/rustdoc/reexport-cfg.rs index a6179fad873..7270da3d678 100644 --- a/tests/rustdoc/reexport-cfg.rs +++ b/tests/rustdoc/reexport-cfg.rs @@ -12,19 +12,19 @@ mod foo { pub struct Bar2; } -// @has 'foo/index.html' -// @has - '//*[@class="item-name"]' 'BabarNon-lie' +//@ has 'foo/index.html' +//@ has - '//*[@class="item-name"]' 'BabarNon-lie' #[cfg(not(feature = "lie"))] pub use crate::foo::Bar as Babar; -// @has - '//*[@class="item-name"]' 'Babar2Non-cake' +//@ has - '//*[@class="item-name"]' 'Babar2Non-cake' #[doc(cfg(not(feature = "cake")))] pub use crate::foo::Bar2 as Babar2; -// @has - '//*[@class="item-table"]/li' 'pub use crate::Babar as Elephant;Non-robot' +//@ has - '//*[@class="item-table"]/li' 'pub use crate::Babar as Elephant;Non-robot' #[cfg(not(feature = "robot"))] pub use crate::Babar as Elephant; -// @has - '//*[@class="item-table"]/li' 'pub use crate::Babar2 as Elephant2;Non-cat' +//@ has - '//*[@class="item-table"]/li' 'pub use crate::Babar2 as Elephant2;Non-cat' #[doc(cfg(not(feature = "cat")))] pub use crate::Babar2 as Elephant2; diff --git a/tests/rustdoc/reexport-check.rs b/tests/rustdoc/reexport-check.rs index 92729b82ae2..0f4e203d1d3 100644 --- a/tests/rustdoc/reexport-check.rs +++ b/tests/rustdoc/reexport-check.rs @@ -3,18 +3,18 @@ extern crate reexport_check; -// @!has 'foo/index.html' '//code' 'pub use self::i32;' -// @has 'foo/i32/index.html' +//@ !has 'foo/index.html' '//code' 'pub use self::i32;' +//@ has 'foo/i32/index.html' #[allow(deprecated, deprecated_in_future)] pub use std::i32; -// @!has 'foo/index.html' '//code' 'pub use self::string::String;' -// @has 'foo/index.html' '//div[@class="item-name"]' 'String' +//@ !has 'foo/index.html' '//code' 'pub use self::string::String;' +//@ has 'foo/index.html' '//div[@class="item-name"]' 'String' pub use std::string::String; // i32 is deprecated, String is not -// @count 'foo/index.html' '//span[@class="stab deprecated"]' 1 +//@ count 'foo/index.html' '//span[@class="stab deprecated"]' 1 -// @has 'foo/index.html' '//div[@class="desc docblock-short"]' 'Docs in original' +//@ has 'foo/index.html' '//div[@class="desc docblock-short"]' 'Docs in original' // this is a no-op, but shows what happens if there's an attribute that isn't a doc-comment #[doc(inline)] pub use reexport_check::S; diff --git a/tests/rustdoc/reexport-dep-foreign-fn.rs b/tests/rustdoc/reexport-dep-foreign-fn.rs index 1da3d8044b9..1b63fcff017 100644 --- a/tests/rustdoc/reexport-dep-foreign-fn.rs +++ b/tests/rustdoc/reexport-dep-foreign-fn.rs @@ -7,6 +7,6 @@ extern crate all_item_types; -// @has 'foo/fn.foo_ffn.html' -// @has - '//*[@class="rust item-decl"]//code' 'pub unsafe extern "C" fn foo_ffn()' +//@ has 'foo/fn.foo_ffn.html' +//@ has - '//*[@class="rust item-decl"]//code' 'pub unsafe extern "C" fn foo_ffn()' pub use all_item_types::foo_ffn; diff --git a/tests/rustdoc/reexport-doc-hidden-inside-private.rs b/tests/rustdoc/reexport-doc-hidden-inside-private.rs index e9d243d8abf..fac928fc2a3 100644 --- a/tests/rustdoc/reexport-doc-hidden-inside-private.rs +++ b/tests/rustdoc/reexport-doc-hidden-inside-private.rs @@ -8,9 +8,9 @@ mod private_module { pub struct Public; } -// @has 'foo/index.html' -// @has - '//*[@id="reexport.Foo"]/code' 'pub use crate::private_module::Public as Foo;' +//@ has 'foo/index.html' +//@ has - '//*[@id="reexport.Foo"]/code' 'pub use crate::private_module::Public as Foo;' pub use crate::private_module::Public as Foo; // Glob re-exports with no visible items should not be displayed. -// @count - '//*[@class="item-table"]/li' 1 +//@ count - '//*[@class="item-table"]/li' 1 pub use crate::private_module::*; diff --git a/tests/rustdoc/reexport-doc-hidden.rs b/tests/rustdoc/reexport-doc-hidden.rs index d9ed954868e..b912362f298 100644 --- a/tests/rustdoc/reexport-doc-hidden.rs +++ b/tests/rustdoc/reexport-doc-hidden.rs @@ -7,11 +7,11 @@ #[doc(hidden)] pub type Type = u32; -// @has 'foo/index.html' -// @has - '//*[@id="reexport.Type2"]/code' 'pub use crate::Type as Type2;' +//@ has 'foo/index.html' +//@ has - '//*[@id="reexport.Type2"]/code' 'pub use crate::Type as Type2;' pub use crate::Type as Type2; -// @count - '//*[@id="reexport.Type3"]' 0 +//@ count - '//*[@id="reexport.Type3"]' 0 #[doc(hidden)] pub use crate::Type as Type3; @@ -21,5 +21,5 @@ macro_rules! foo { () => {}; } -// @has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;' +//@ has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;' pub use crate::foo as Macro; diff --git a/tests/rustdoc/reexport-doc.rs b/tests/rustdoc/reexport-doc.rs index cb1a398b1c3..0c20de41231 100644 --- a/tests/rustdoc/reexport-doc.rs +++ b/tests/rustdoc/reexport-doc.rs @@ -2,7 +2,7 @@ extern crate reexport_doc_aux as dep; -// @has 'reexport_doc/struct.Foo.html' -// @count - '//p' 'These are the docs for Foo.' 1 +//@ has 'reexport_doc/struct.Foo.html' +//@ count - '//p' 'These are the docs for Foo.' 1 /// These are the docs for Foo. pub use dep::Foo; diff --git a/tests/rustdoc/reexport-hidden-macro.rs b/tests/rustdoc/reexport-hidden-macro.rs index 47a21e39462..9b83bca3906 100644 --- a/tests/rustdoc/reexport-hidden-macro.rs +++ b/tests/rustdoc/reexport-hidden-macro.rs @@ -3,12 +3,12 @@ #![crate_name = "foo"] -// @has 'foo/index.html' -// @has - '//*[@id="main-content"]//a[@href="macro.Macro2.html"]' 'Macro2' -// @has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;' +//@ has 'foo/index.html' +//@ has - '//*[@id="main-content"]//a[@href="macro.Macro2.html"]' 'Macro2' +//@ has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;' -// @has 'foo/macro.Macro2.html' -// @has - '//*[@class="docblock"]' 'Displayed' +//@ has 'foo/macro.Macro2.html' +//@ has - '//*[@class="docblock"]' 'Displayed' #[macro_export] #[doc(hidden)] diff --git a/tests/rustdoc/reexport-macro.rs b/tests/rustdoc/reexport-macro.rs index c4dec703aed..7e041eb90ba 100644 --- a/tests/rustdoc/reexport-macro.rs +++ b/tests/rustdoc/reexport-macro.rs @@ -3,9 +3,9 @@ #![crate_name = "foo"] -// @has 'foo/macro.foo.html' -// @!has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'x y' -// @has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'y' +//@ has 'foo/macro.foo.html' +//@ !has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'x y' +//@ has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'y' #[macro_use] mod my_module { /// y @@ -15,8 +15,8 @@ mod my_module { } } -// @has 'foo/another_mod/macro.bar.html' -// @has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'x y' +//@ has 'foo/another_mod/macro.bar.html' +//@ has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'x y' pub mod another_mod { /// x pub use crate::foo as bar; diff --git a/tests/rustdoc/reexport-of-doc-hidden.rs b/tests/rustdoc/reexport-of-doc-hidden.rs index b733716c22a..21511bc2aea 100644 --- a/tests/rustdoc/reexport-of-doc-hidden.rs +++ b/tests/rustdoc/reexport-of-doc-hidden.rs @@ -11,32 +11,32 @@ macro_rules! foo { () => {}; } -// @has 'foo/index.html' -// @has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;' +//@ has 'foo/index.html' +//@ has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;' pub use crate::foo as Macro; -// @has - '//*[@id="reexport.Macro2"]/code' 'pub use crate::foo as Macro2;' +//@ has - '//*[@id="reexport.Macro2"]/code' 'pub use crate::foo as Macro2;' pub use crate::foo as Macro2; -// @has - '//*[@id="reexport.Boo"]/code' 'pub use crate::Bar as Boo;' +//@ has - '//*[@id="reexport.Boo"]/code' 'pub use crate::Bar as Boo;' pub use crate::Bar as Boo; -// @has - '//*[@id="reexport.Boo2"]/code' 'pub use crate::Bar as Boo2;' +//@ has - '//*[@id="reexport.Boo2"]/code' 'pub use crate::Bar as Boo2;' pub use crate::Bar as Boo2; pub fn fofo() {} -// @has - '//*[@id="reexport.f1"]/code' 'pub use crate::fofo as f1;' +//@ has - '//*[@id="reexport.f1"]/code' 'pub use crate::fofo as f1;' pub use crate::fofo as f1; -// @has - '//*[@id="reexport.f2"]/code' 'pub use crate::fofo as f2;' +//@ has - '//*[@id="reexport.f2"]/code' 'pub use crate::fofo as f2;' pub use crate::fofo as f2; pub mod sub { - // @has 'foo/sub/index.html' - // @has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;' + //@ has 'foo/sub/index.html' + //@ has - '//*[@id="reexport.Macro"]/code' 'pub use crate::foo as Macro;' pub use crate::foo as Macro; - // @has - '//*[@id="reexport.Macro2"]/code' 'pub use crate::foo as Macro2;' + //@ has - '//*[@id="reexport.Macro2"]/code' 'pub use crate::foo as Macro2;' pub use crate::foo as Macro2; - // @has - '//*[@id="reexport.f1"]/code' 'pub use crate::fofo as f1;' + //@ has - '//*[@id="reexport.f1"]/code' 'pub use crate::fofo as f1;' pub use crate::fofo as f1; - // @has - '//*[@id="reexport.f2"]/code' 'pub use crate::fofo as f2;' + //@ has - '//*[@id="reexport.f2"]/code' 'pub use crate::fofo as f2;' pub use crate::fofo as f2; } diff --git a/tests/rustdoc/reexport-stability-tags-deprecated-and-portability.rs b/tests/rustdoc/reexport-stability-tags-deprecated-and-portability.rs index c81c654a20e..f83f28f458e 100644 --- a/tests/rustdoc/reexport-stability-tags-deprecated-and-portability.rs +++ b/tests/rustdoc/reexport-stability-tags-deprecated-and-portability.rs @@ -15,34 +15,34 @@ pub mod tag { pub trait None {} } -// @has foo/mod1/index.html +//@ has foo/mod1/index.html pub mod mod1 { - // @has - '//code' 'pub use tag::Deprecated;' - // @has - '//span' 'Deprecated' - // @!has - '//span' 'sync' + //@ has - '//code' 'pub use tag::Deprecated;' + //@ has - '//span' 'Deprecated' + //@ !has - '//span' 'sync' pub use tag::Deprecated; } -// @has foo/mod2/index.html +//@ has foo/mod2/index.html pub mod mod2 { - // @has - '//code' 'pub use tag::Portability;' - // @!has - '//span' 'Deprecated' - // @!has - '//span' 'sync' + //@ has - '//code' 'pub use tag::Portability;' + //@ !has - '//span' 'Deprecated' + //@ !has - '//span' 'sync' pub use tag::Portability; } -// @has foo/mod3/index.html +//@ has foo/mod3/index.html pub mod mod3 { - // @has - '//code' 'pub use tag::Both;' - // @has - '//span' 'Deprecated' - // @!has - '//span' 'sync' + //@ has - '//code' 'pub use tag::Both;' + //@ has - '//span' 'Deprecated' + //@ !has - '//span' 'sync' pub use tag::Both; } -// @has foo/mod4/index.html +//@ has foo/mod4/index.html pub mod mod4 { - // @has - '//code' 'pub use tag::None;' - // @!has - '//span' 'Deprecated' - // @!has - '//span' 'sync' + //@ has - '//code' 'pub use tag::None;' + //@ !has - '//span' 'Deprecated' + //@ !has - '//span' 'sync' pub use tag::None; } diff --git a/tests/rustdoc/reexport-stability-tags-unstable-and-portability.rs b/tests/rustdoc/reexport-stability-tags-unstable-and-portability.rs index 423838e251b..adf3eed204a 100644 --- a/tests/rustdoc/reexport-stability-tags-unstable-and-portability.rs +++ b/tests/rustdoc/reexport-stability-tags-unstable-and-portability.rs @@ -20,42 +20,42 @@ pub mod tag { pub trait None {} } -// @has foo/mod1/index.html +//@ has foo/mod1/index.html #[stable(feature = "rust1", since = "1.0.0")] pub mod mod1 { - // @has - '//code' 'pub use tag::Unstable;' - // @has - '//span' 'Experimental' - // @!has - '//span' 'sync' + //@ has - '//code' 'pub use tag::Unstable;' + //@ has - '//span' 'Experimental' + //@ !has - '//span' 'sync' #[stable(feature = "rust1", since = "1.0.0")] pub use tag::Unstable; } -// @has foo/mod2/index.html +//@ has foo/mod2/index.html #[stable(feature = "rust1", since = "1.0.0")] pub mod mod2 { - // @has - '//code' 'pub use tag::Portability;' - // @!has - '//span' 'Experimental' - // @!has - '//span' 'sync' + //@ has - '//code' 'pub use tag::Portability;' + //@ !has - '//span' 'Experimental' + //@ !has - '//span' 'sync' #[stable(feature = "rust1", since = "1.0.0")] pub use tag::Portability; } -// @has foo/mod3/index.html +//@ has foo/mod3/index.html #[stable(feature = "rust1", since = "1.0.0")] pub mod mod3 { - // @has - '//code' 'pub use tag::Both;' - // @has - '//span' 'Experimental' - // @!has - '//span' 'sync' + //@ has - '//code' 'pub use tag::Both;' + //@ has - '//span' 'Experimental' + //@ !has - '//span' 'sync' #[stable(feature = "rust1", since = "1.0.0")] pub use tag::Both; } -// @has foo/mod4/index.html +//@ has foo/mod4/index.html #[stable(feature = "rust1", since = "1.0.0")] pub mod mod4 { - // @has - '//code' 'pub use tag::None;' - // @!has - '//span' 'Experimental' - // @!has - '//span' 'sync' + //@ has - '//code' 'pub use tag::None;' + //@ !has - '//span' 'Experimental' + //@ !has - '//span' 'sync' #[stable(feature = "rust1", since = "1.0.0")] pub use tag::None; } diff --git a/tests/rustdoc/reexports-of-same-name.rs b/tests/rustdoc/reexports-of-same-name.rs index fe6f1b38ca6..6e5d328b081 100644 --- a/tests/rustdoc/reexports-of-same-name.rs +++ b/tests/rustdoc/reexports-of-same-name.rs @@ -4,7 +4,7 @@ #![crate_name = "foo"] -// @has 'foo/index.html' +//@ has 'foo/index.html' pub mod nested { /// Foo the struct @@ -15,12 +15,12 @@ pub mod nested { pub fn Foo() {} } -// @count - '//*[@id="main-content"]//code' 'pub use nested::Foo;' 2 -// @has - '//*[@id="reexport.Foo"]//a[@href="nested/struct.Foo.html"]' 'Foo' -// @has - '//*[@id="reexport.Foo-1"]//a[@href="nested/fn.Foo.html"]' 'Foo' +//@ count - '//*[@id="main-content"]//code' 'pub use nested::Foo;' 2 +//@ has - '//*[@id="reexport.Foo"]//a[@href="nested/struct.Foo.html"]' 'Foo' +//@ has - '//*[@id="reexport.Foo-1"]//a[@href="nested/fn.Foo.html"]' 'Foo' pub use nested::Foo; -// @count - '//*[@id="main-content"]//code' 'pub use Foo as Bar;' 2 -// @has - '//*[@id="reexport.Bar"]//a[@href="nested/struct.Foo.html"]' 'Foo' -// @has - '//*[@id="reexport.Bar-1"]//a[@href="nested/fn.Foo.html"]' 'Foo' +//@ count - '//*[@id="main-content"]//code' 'pub use Foo as Bar;' 2 +//@ has - '//*[@id="reexport.Bar"]//a[@href="nested/struct.Foo.html"]' 'Foo' +//@ has - '//*[@id="reexport.Bar-1"]//a[@href="nested/fn.Foo.html"]' 'Foo' pub use Foo as Bar; diff --git a/tests/rustdoc/reexports-priv.rs b/tests/rustdoc/reexports-priv.rs index 97318a01410..4521b4feebc 100644 --- a/tests/rustdoc/reexports-priv.rs +++ b/tests/rustdoc/reexports-priv.rs @@ -5,131 +5,131 @@ extern crate reexports; -// @has 'foo/macro.addr_of.html' '//*[@class="rust item-decl"]' 'pub macro addr_of($place:expr) {' +//@ has 'foo/macro.addr_of.html' '//*[@class="rust item-decl"]' 'pub macro addr_of($place:expr) {' pub use reexports::addr_of; -// @!has 'foo/macro.addr_of_crate.html' +//@ !has 'foo/macro.addr_of_crate.html' pub(crate) use reexports::addr_of_crate; -// @!has 'foo/macro.addr_of_self.html' +//@ !has 'foo/macro.addr_of_self.html' pub(self) use reexports::addr_of_self; -// @!has 'foo/macro.addr_of_local.html' +//@ !has 'foo/macro.addr_of_local.html' use reexports::addr_of_local; -// @has 'foo/struct.Foo.html' '//*[@class="rust item-decl"]' 'pub struct Foo;' +//@ has 'foo/struct.Foo.html' '//*[@class="rust item-decl"]' 'pub struct Foo;' pub use reexports::Foo; -// @!has 'foo/struct.FooCrate.html' +//@ !has 'foo/struct.FooCrate.html' pub(crate) use reexports::FooCrate; -// @!has 'foo/struct.FooSelf.html' +//@ !has 'foo/struct.FooSelf.html' pub(self) use reexports::FooSelf; -// @!has 'foo/struct.FooLocal.html' +//@ !has 'foo/struct.FooLocal.html' use reexports::FooLocal; -// @has 'foo/enum.Bar.html' '//*[@class="rust item-decl"]' 'pub enum Bar {' +//@ has 'foo/enum.Bar.html' '//*[@class="rust item-decl"]' 'pub enum Bar {' pub use reexports::Bar; -// @!has 'foo/enum.BarCrate.html' +//@ !has 'foo/enum.BarCrate.html' pub(crate) use reexports::BarCrate; -// @!has 'foo/enum.BarSelf.html' +//@ !has 'foo/enum.BarSelf.html' pub(self) use reexports::BarSelf; -// @!has 'foo/enum.BarLocal.html' +//@ !has 'foo/enum.BarLocal.html' use reexports::BarLocal; -// @has 'foo/fn.foo.html' '//pre[@class="rust item-decl"]' 'pub fn foo()' +//@ has 'foo/fn.foo.html' '//pre[@class="rust item-decl"]' 'pub fn foo()' pub use reexports::foo; -// @!has 'foo/fn.foo_crate.html' +//@ !has 'foo/fn.foo_crate.html' pub(crate) use reexports::foo_crate; -// @!has 'foo/fn.foo_self.html' +//@ !has 'foo/fn.foo_self.html' pub(self) use reexports::foo_self; -// @!has 'foo/fn.foo_local.html' +//@ !has 'foo/fn.foo_local.html' use reexports::foo_local; -// @has 'foo/type.Type.html' '//pre[@class="rust item-decl"]' 'pub type Type =' +//@ has 'foo/type.Type.html' '//pre[@class="rust item-decl"]' 'pub type Type =' pub use reexports::Type; -// @!has 'foo/type.TypeCrate.html' +//@ !has 'foo/type.TypeCrate.html' pub(crate) use reexports::TypeCrate; -// @!has 'foo/type.TypeSelf.html' +//@ !has 'foo/type.TypeSelf.html' pub(self) use reexports::TypeSelf; -// @!has 'foo/type.TypeLocal.html' +//@ !has 'foo/type.TypeLocal.html' use reexports::TypeLocal; -// @has 'foo/union.Union.html' '//*[@class="rust item-decl"]' 'pub union Union {' +//@ has 'foo/union.Union.html' '//*[@class="rust item-decl"]' 'pub union Union {' pub use reexports::Union; -// @!has 'foo/union.UnionCrate.html' +//@ !has 'foo/union.UnionCrate.html' pub(crate) use reexports::UnionCrate; -// @!has 'foo/union.UnionSelf.html' +//@ !has 'foo/union.UnionSelf.html' pub(self) use reexports::UnionSelf; -// @!has 'foo/union.UnionLocal.html' +//@ !has 'foo/union.UnionLocal.html' use reexports::UnionLocal; pub mod outer { pub mod inner { - // @has 'foo/outer/inner/macro.addr_of.html' '//*[@class="rust item-decl"]' 'pub macro addr_of($place:expr) {' + //@ has 'foo/outer/inner/macro.addr_of.html' '//*[@class="rust item-decl"]' 'pub macro addr_of($place:expr) {' pub use reexports::addr_of; - // @has 'foo/outer/inner/macro.addr_of_crate.html' '//*[@class="rust item-decl"]' 'pub(crate) macro addr_of_crate($place:expr) {' + //@ has 'foo/outer/inner/macro.addr_of_crate.html' '//*[@class="rust item-decl"]' 'pub(crate) macro addr_of_crate($place:expr) {' pub(crate) use reexports::addr_of_crate; - // @has 'foo/outer/inner/macro.addr_of_super.html' '//*[@class="rust item-decl"]' 'pub(in outer) macro addr_of_super($place:expr) {' + //@ has 'foo/outer/inner/macro.addr_of_super.html' '//*[@class="rust item-decl"]' 'pub(in outer) macro addr_of_super($place:expr) {' pub(super) use reexports::addr_of_super; - // @!has 'foo/outer/inner/macro.addr_of_self.html' + //@ !has 'foo/outer/inner/macro.addr_of_self.html' pub(self) use reexports::addr_of_self; - // @!has 'foo/outer/inner/macro.addr_of_local.html' + //@ !has 'foo/outer/inner/macro.addr_of_local.html' use reexports::addr_of_local; - // @has 'foo/outer/inner/struct.Foo.html' '//*[@class="rust item-decl"]' 'pub struct Foo;' + //@ has 'foo/outer/inner/struct.Foo.html' '//*[@class="rust item-decl"]' 'pub struct Foo;' pub use reexports::Foo; - // @has 'foo/outer/inner/struct.FooCrate.html' '//*[@class="rust item-decl"]' 'pub(crate) struct FooCrate;' + //@ has 'foo/outer/inner/struct.FooCrate.html' '//*[@class="rust item-decl"]' 'pub(crate) struct FooCrate;' pub(crate) use reexports::FooCrate; - // @has 'foo/outer/inner/struct.FooSuper.html' '//*[@class="rust item-decl"]' 'pub(in outer) struct FooSuper;' + //@ has 'foo/outer/inner/struct.FooSuper.html' '//*[@class="rust item-decl"]' 'pub(in outer) struct FooSuper;' pub(super) use reexports::FooSuper; - // @!has 'foo/outer/inner/struct.FooSelf.html' + //@ !has 'foo/outer/inner/struct.FooSelf.html' pub(self) use reexports::FooSelf; - // @!has 'foo/outer/inner/struct.FooLocal.html' + //@ !has 'foo/outer/inner/struct.FooLocal.html' use reexports::FooLocal; - // @has 'foo/outer/inner/enum.Bar.html' '//*[@class="rust item-decl"]' 'pub enum Bar {' + //@ has 'foo/outer/inner/enum.Bar.html' '//*[@class="rust item-decl"]' 'pub enum Bar {' pub use reexports::Bar; - // @has 'foo/outer/inner/enum.BarCrate.html' '//*[@class="rust item-decl"]' 'pub(crate) enum BarCrate {' + //@ has 'foo/outer/inner/enum.BarCrate.html' '//*[@class="rust item-decl"]' 'pub(crate) enum BarCrate {' pub(crate) use reexports::BarCrate; - // @has 'foo/outer/inner/enum.BarSuper.html' '//*[@class="rust item-decl"]' 'pub(in outer) enum BarSuper {' + //@ has 'foo/outer/inner/enum.BarSuper.html' '//*[@class="rust item-decl"]' 'pub(in outer) enum BarSuper {' pub(super) use reexports::BarSuper; - // @!has 'foo/outer/inner/enum.BarSelf.html' + //@ !has 'foo/outer/inner/enum.BarSelf.html' pub(self) use reexports::BarSelf; - // @!has 'foo/outer/inner/enum.BarLocal.html' + //@ !has 'foo/outer/inner/enum.BarLocal.html' use reexports::BarLocal; - // @has 'foo/outer/inner/fn.foo.html' '//pre[@class="rust item-decl"]' 'pub fn foo()' + //@ has 'foo/outer/inner/fn.foo.html' '//pre[@class="rust item-decl"]' 'pub fn foo()' pub use reexports::foo; - // @has 'foo/outer/inner/fn.foo_crate.html' '//pre[@class="rust item-decl"]' 'pub(crate) fn foo_crate()' + //@ has 'foo/outer/inner/fn.foo_crate.html' '//pre[@class="rust item-decl"]' 'pub(crate) fn foo_crate()' pub(crate) use reexports::foo_crate; - // @has 'foo/outer/inner/fn.foo_super.html' '//pre[@class="rust item-decl"]' 'pub(in outer) fn foo_super()' + //@ has 'foo/outer/inner/fn.foo_super.html' '//pre[@class="rust item-decl"]' 'pub(in outer) fn foo_super()' pub(super) use::reexports::foo_super; - // @!has 'foo/outer/inner/fn.foo_self.html' + //@ !has 'foo/outer/inner/fn.foo_self.html' pub(self) use reexports::foo_self; - // @!has 'foo/outer/inner/fn.foo_local.html' + //@ !has 'foo/outer/inner/fn.foo_local.html' use reexports::foo_local; - // @has 'foo/outer/inner/type.Type.html' '//pre[@class="rust item-decl"]' 'pub type Type =' + //@ has 'foo/outer/inner/type.Type.html' '//pre[@class="rust item-decl"]' 'pub type Type =' pub use reexports::Type; - // @has 'foo/outer/inner/type.TypeCrate.html' '//pre[@class="rust item-decl"]' 'pub(crate) type TypeCrate =' + //@ has 'foo/outer/inner/type.TypeCrate.html' '//pre[@class="rust item-decl"]' 'pub(crate) type TypeCrate =' pub(crate) use reexports::TypeCrate; - // @has 'foo/outer/inner/type.TypeSuper.html' '//pre[@class="rust item-decl"]' 'pub(in outer) type TypeSuper =' + //@ has 'foo/outer/inner/type.TypeSuper.html' '//pre[@class="rust item-decl"]' 'pub(in outer) type TypeSuper =' pub(super) use reexports::TypeSuper; - // @!has 'foo/outer/inner/type.TypeSelf.html' + //@ !has 'foo/outer/inner/type.TypeSelf.html' pub(self) use reexports::TypeSelf; - // @!has 'foo/outer/inner/type.TypeLocal.html' + //@ !has 'foo/outer/inner/type.TypeLocal.html' use reexports::TypeLocal; - // @has 'foo/outer/inner/union.Union.html' '//*[@class="rust item-decl"]' 'pub union Union {' + //@ has 'foo/outer/inner/union.Union.html' '//*[@class="rust item-decl"]' 'pub union Union {' pub use reexports::Union; - // @has 'foo/outer/inner/union.UnionCrate.html' '//*[@class="rust item-decl"]' 'pub(crate) union UnionCrate {' + //@ has 'foo/outer/inner/union.UnionCrate.html' '//*[@class="rust item-decl"]' 'pub(crate) union UnionCrate {' pub(crate) use reexports::UnionCrate; - // @has 'foo/outer/inner/union.UnionSuper.html' '//*[@class="rust item-decl"]' 'pub(in outer) union UnionSuper {' + //@ has 'foo/outer/inner/union.UnionSuper.html' '//*[@class="rust item-decl"]' 'pub(in outer) union UnionSuper {' pub(super) use reexports::UnionSuper; - // @!has 'foo/outer/inner/union.UnionSelf.html' + //@ !has 'foo/outer/inner/union.UnionSelf.html' pub(self) use reexports::UnionSelf; - // @!has 'foo/outer/inner/union.UnionLocal.html' + //@ !has 'foo/outer/inner/union.UnionLocal.html' use reexports::UnionLocal; } } mod re_re_exports { - // @!has 'foo/re_re_exports/union.Union.html' + //@ !has 'foo/re_re_exports/union.Union.html' use crate::reexports::Union; } diff --git a/tests/rustdoc/reexports.rs b/tests/rustdoc/reexports.rs index e1da1fd552f..b17e9cd719a 100644 --- a/tests/rustdoc/reexports.rs +++ b/tests/rustdoc/reexports.rs @@ -4,126 +4,126 @@ extern crate reexports; -// @has 'foo/macro.addr_of.html' '//*[@class="rust item-decl"]' 'pub macro addr_of($place:expr) {' +//@ has 'foo/macro.addr_of.html' '//*[@class="rust item-decl"]' 'pub macro addr_of($place:expr) {' pub use reexports::addr_of; -// @!has 'foo/macro.addr_of_crate.html' +//@ !has 'foo/macro.addr_of_crate.html' pub(crate) use reexports::addr_of_crate; -// @!has 'foo/macro.addr_of_self.html' +//@ !has 'foo/macro.addr_of_self.html' pub(self) use reexports::addr_of_self; -// @!has 'foo/macro.addr_of_local.html' +//@ !has 'foo/macro.addr_of_local.html' use reexports::addr_of_local; -// @has 'foo/struct.Foo.html' '//*[@class="rust item-decl"]' 'pub struct Foo;' +//@ has 'foo/struct.Foo.html' '//*[@class="rust item-decl"]' 'pub struct Foo;' pub use reexports::Foo; -// @!has 'foo/struct.FooCrate.html' +//@ !has 'foo/struct.FooCrate.html' pub(crate) use reexports::FooCrate; -// @!has 'foo/struct.FooSelf.html' +//@ !has 'foo/struct.FooSelf.html' pub(self) use reexports::FooSelf; -// @!has 'foo/struct.FooLocal.html' +//@ !has 'foo/struct.FooLocal.html' use reexports::FooLocal; -// @has 'foo/enum.Bar.html' '//*[@class="rust item-decl"]' 'pub enum Bar {' +//@ has 'foo/enum.Bar.html' '//*[@class="rust item-decl"]' 'pub enum Bar {' pub use reexports::Bar; -// @!has 'foo/enum.BarCrate.html' +//@ !has 'foo/enum.BarCrate.html' pub(crate) use reexports::BarCrate; -// @!has 'foo/enum.BarSelf.html' +//@ !has 'foo/enum.BarSelf.html' pub(self) use reexports::BarSelf; -// @!has 'foo/enum.BarLocal.html' +//@ !has 'foo/enum.BarLocal.html' use reexports::BarLocal; -// @has 'foo/fn.foo.html' '//pre[@class="rust item-decl"]' 'pub fn foo()' +//@ has 'foo/fn.foo.html' '//pre[@class="rust item-decl"]' 'pub fn foo()' pub use reexports::foo; -// @!has 'foo/fn.foo_crate.html' +//@ !has 'foo/fn.foo_crate.html' pub(crate) use reexports::foo_crate; -// @!has 'foo/fn.foo_self.html' +//@ !has 'foo/fn.foo_self.html' pub(self) use reexports::foo_self; -// @!has 'foo/fn.foo_local.html' +//@ !has 'foo/fn.foo_local.html' use reexports::foo_local; -// @has 'foo/type.Type.html' '//pre[@class="rust item-decl"]' 'pub type Type =' +//@ has 'foo/type.Type.html' '//pre[@class="rust item-decl"]' 'pub type Type =' pub use reexports::Type; -// @!has 'foo/type.TypeCrate.html' +//@ !has 'foo/type.TypeCrate.html' pub(crate) use reexports::TypeCrate; -// @!has 'foo/type.TypeSelf.html' +//@ !has 'foo/type.TypeSelf.html' pub(self) use reexports::TypeSelf; -// @!has 'foo/type.TypeLocal.html' +//@ !has 'foo/type.TypeLocal.html' use reexports::TypeLocal; -// @has 'foo/union.Union.html' '//*[@class="rust item-decl"]' 'pub union Union {' +//@ has 'foo/union.Union.html' '//*[@class="rust item-decl"]' 'pub union Union {' pub use reexports::Union; -// @!has 'foo/union.UnionCrate.html' +//@ !has 'foo/union.UnionCrate.html' pub(crate) use reexports::UnionCrate; -// @!has 'foo/union.UnionSelf.html' +//@ !has 'foo/union.UnionSelf.html' pub(self) use reexports::UnionSelf; -// @!has 'foo/union.UnionLocal.html' +//@ !has 'foo/union.UnionLocal.html' use reexports::UnionLocal; pub mod outer { pub mod inner { - // @has 'foo/outer/inner/macro.addr_of.html' '//*[@class="rust item-decl"]' 'pub macro addr_of($place:expr) {' + //@ has 'foo/outer/inner/macro.addr_of.html' '//*[@class="rust item-decl"]' 'pub macro addr_of($place:expr) {' pub use reexports::addr_of; - // @!has 'foo/outer/inner/macro.addr_of_crate.html' + //@ !has 'foo/outer/inner/macro.addr_of_crate.html' pub(crate) use reexports::addr_of_crate; - // @!has 'foo/outer/inner/macro.addr_of_super.html' + //@ !has 'foo/outer/inner/macro.addr_of_super.html' pub(super) use reexports::addr_of_super; - // @!has 'foo/outer/inner/macro.addr_of_self.html' + //@ !has 'foo/outer/inner/macro.addr_of_self.html' pub(self) use reexports::addr_of_self; - // @!has 'foo/outer/inner/macro.addr_of_local.html' + //@ !has 'foo/outer/inner/macro.addr_of_local.html' use reexports::addr_of_local; - // @has 'foo/outer/inner/struct.Foo.html' '//*[@class="rust item-decl"]' 'pub struct Foo;' + //@ has 'foo/outer/inner/struct.Foo.html' '//*[@class="rust item-decl"]' 'pub struct Foo;' pub use reexports::Foo; - // @!has 'foo/outer/inner/struct.FooCrate.html' + //@ !has 'foo/outer/inner/struct.FooCrate.html' pub(crate) use reexports::FooCrate; - // @!has 'foo/outer/inner/struct.FooSuper.html' + //@ !has 'foo/outer/inner/struct.FooSuper.html' pub(super) use reexports::FooSuper; - // @!has 'foo/outer/inner/struct.FooSelf.html' + //@ !has 'foo/outer/inner/struct.FooSelf.html' pub(self) use reexports::FooSelf; - // @!has 'foo/outer/inner/struct.FooLocal.html' + //@ !has 'foo/outer/inner/struct.FooLocal.html' use reexports::FooLocal; - // @has 'foo/outer/inner/enum.Bar.html' '//*[@class="rust item-decl"]' 'pub enum Bar {' + //@ has 'foo/outer/inner/enum.Bar.html' '//*[@class="rust item-decl"]' 'pub enum Bar {' pub use reexports::Bar; - // @!has 'foo/outer/inner/enum.BarCrate.html' + //@ !has 'foo/outer/inner/enum.BarCrate.html' pub(crate) use reexports::BarCrate; - // @!has 'foo/outer/inner/enum.BarSuper.html' + //@ !has 'foo/outer/inner/enum.BarSuper.html' pub(super) use reexports::BarSuper; - // @!has 'foo/outer/inner/enum.BarSelf.html' + //@ !has 'foo/outer/inner/enum.BarSelf.html' pub(self) use reexports::BarSelf; - // @!has 'foo/outer/inner/enum.BarLocal.html' + //@ !has 'foo/outer/inner/enum.BarLocal.html' use reexports::BarLocal; - // @has 'foo/outer/inner/fn.foo.html' '//pre[@class="rust item-decl"]' 'pub fn foo()' + //@ has 'foo/outer/inner/fn.foo.html' '//pre[@class="rust item-decl"]' 'pub fn foo()' pub use reexports::foo; - // @!has 'foo/outer/inner/fn.foo_crate.html' + //@ !has 'foo/outer/inner/fn.foo_crate.html' pub(crate) use reexports::foo_crate; - // @!has 'foo/outer/inner/fn.foo_super.html' + //@ !has 'foo/outer/inner/fn.foo_super.html' pub(super) use::reexports::foo_super; - // @!has 'foo/outer/inner/fn.foo_self.html' + //@ !has 'foo/outer/inner/fn.foo_self.html' pub(self) use reexports::foo_self; - // @!has 'foo/outer/inner/fn.foo_local.html' + //@ !has 'foo/outer/inner/fn.foo_local.html' use reexports::foo_local; - // @has 'foo/outer/inner/type.Type.html' '//pre[@class="rust item-decl"]' 'pub type Type =' + //@ has 'foo/outer/inner/type.Type.html' '//pre[@class="rust item-decl"]' 'pub type Type =' pub use reexports::Type; - // @!has 'foo/outer/inner/type.TypeCrate.html' + //@ !has 'foo/outer/inner/type.TypeCrate.html' pub(crate) use reexports::TypeCrate; - // @!has 'foo/outer/inner/type.TypeSuper.html' + //@ !has 'foo/outer/inner/type.TypeSuper.html' pub(super) use reexports::TypeSuper; - // @!has 'foo/outer/inner/type.TypeSelf.html' + //@ !has 'foo/outer/inner/type.TypeSelf.html' pub(self) use reexports::TypeSelf; - // @!has 'foo/outer/inner/type.TypeLocal.html' + //@ !has 'foo/outer/inner/type.TypeLocal.html' use reexports::TypeLocal; - // @has 'foo/outer/inner/union.Union.html' '//*[@class="rust item-decl"]' 'pub union Union {' + //@ has 'foo/outer/inner/union.Union.html' '//*[@class="rust item-decl"]' 'pub union Union {' pub use reexports::Union; - // @!has 'foo/outer/inner/union.UnionCrate.html' + //@ !has 'foo/outer/inner/union.UnionCrate.html' pub(crate) use reexports::UnionCrate; - // @!has 'foo/outer/inner/union.UnionSuper.html' + //@ !has 'foo/outer/inner/union.UnionSuper.html' pub(super) use reexports::UnionSuper; - // @!has 'foo/outer/inner/union.UnionSelf.html' + //@ !has 'foo/outer/inner/union.UnionSelf.html' pub(self) use reexports::UnionSelf; - // @!has 'foo/outer/inner/union.UnionLocal.html' + //@ !has 'foo/outer/inner/union.UnionLocal.html' use reexports::UnionLocal; } } diff --git a/tests/rustdoc/remove-duplicates.rs b/tests/rustdoc/remove-duplicates.rs index 759bf84db62..1e5bf9b0198 100644 --- a/tests/rustdoc/remove-duplicates.rs +++ b/tests/rustdoc/remove-duplicates.rs @@ -9,6 +9,6 @@ mod foo { } } -// @count foo/index.html '//*[@class="trait"]' 1 +//@ count foo/index.html '//*[@class="trait"]' 1 pub use foo::bar::*; pub use foo::*; diff --git a/tests/rustdoc/remove-url-from-headings.rs b/tests/rustdoc/remove-url-from-headings.rs index 8f477028619..6e15f57e7ba 100644 --- a/tests/rustdoc/remove-url-from-headings.rs +++ b/tests/rustdoc/remove-url-from-headings.rs @@ -2,11 +2,11 @@ #![crate_name = "foo"] -// @has foo/fn.foo.html -// @has - '//a[@href="http://a.a"]' 'stuff' -// @has - '//*[@id="implementing-stuff-somewhere"]' 'Implementing stuff somewhere' -// @has - '//a[@href="http://b.b"]' 'one' -// @has - '//*[@id="another-one-urg"]' 'Another one urg' +//@ has foo/fn.foo.html +//@ has - '//a[@href="http://a.a"]' 'stuff' +//@ has - '//*[@id="implementing-stuff-somewhere"]' 'Implementing stuff somewhere' +//@ has - '//a[@href="http://b.b"]' 'one' +//@ has - '//*[@id="another-one-urg"]' 'Another one urg' /// fooo /// diff --git a/tests/rustdoc/render-enum-variant-structlike-32395.rs b/tests/rustdoc/render-enum-variant-structlike-32395.rs index dbe40304c17..d4cefb2911d 100644 --- a/tests/rustdoc/render-enum-variant-structlike-32395.rs +++ b/tests/rustdoc/render-enum-variant-structlike-32395.rs @@ -5,14 +5,14 @@ // https://github.com/rust-lang/rust/issues/32395 #![crate_name="issue_32395"] -// @has variant_struct/enum.Foo.html -// @!hasraw - 'pub qux' -// @!hasraw - 'pub(crate) qux' -// @!hasraw - 'pub Bar' +//@ has variant_struct/enum.Foo.html +//@ !hasraw - 'pub qux' +//@ !hasraw - 'pub(crate) qux' +//@ !hasraw - 'pub Bar' extern crate variant_struct; -// @has issue_32395/enum.Foo.html -// @!hasraw - 'pub qux' -// @!hasraw - 'pub(crate) qux' -// @!hasraw - 'pub Bar' +//@ has issue_32395/enum.Foo.html +//@ !hasraw - 'pub qux' +//@ !hasraw - 'pub(crate) qux' +//@ !hasraw - 'pub Bar' pub use variant_struct::Foo; diff --git a/tests/rustdoc/repr.rs b/tests/rustdoc/repr.rs index fbb46e126ba..f4f683b3d81 100644 --- a/tests/rustdoc/repr.rs +++ b/tests/rustdoc/repr.rs @@ -2,15 +2,15 @@ // Check that we show `#[repr(transparent)]` iff the non-1-ZST field is public or at least one // field is public in case all fields are 1-ZST fields. -// @has 'repr/struct.ReprTransparentPrivField.html' -// @!has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' +//@ has 'repr/struct.ReprTransparentPrivField.html' +//@ !has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' #[repr(transparent)] // private pub struct ReprTransparentPrivField { field: u32, // non-1-ZST field } -// @has 'repr/struct.ReprTransparentPriv1ZstFields.html' -// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' +//@ has 'repr/struct.ReprTransparentPriv1ZstFields.html' +//@ has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' #[repr(transparent)] // public pub struct ReprTransparentPriv1ZstFields { marker0: Marker, @@ -18,8 +18,8 @@ pub struct ReprTransparentPriv1ZstFields { marker1: Marker, } -// @has 'repr/struct.ReprTransparentPub1ZstField.html' -// @has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' +//@ has 'repr/struct.ReprTransparentPub1ZstField.html' +//@ has - '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[repr(transparent)]' #[repr(transparent)] // public pub struct ReprTransparentPub1ZstField { marker0: Marker, diff --git a/tests/rustdoc/return-impl-trait.rs b/tests/rustdoc/return-impl-trait.rs index 1ccf5ac4611..175867d2204 100644 --- a/tests/rustdoc/return-impl-trait.rs +++ b/tests/rustdoc/return-impl-trait.rs @@ -8,7 +8,7 @@ pub struct Module<T>(T); pub type BackendImpl = impl Backend; -// @has return_impl_trait/fn.make_module.html +//@ has return_impl_trait/fn.make_module.html /// Documentation pub fn make_module() -> Module<BackendImpl> { Module(()) diff --git a/tests/rustdoc/rfc-2632-const-trait-impl.rs b/tests/rustdoc/rfc-2632-const-trait-impl.rs index d165a406f56..f6a5555dbad 100644 --- a/tests/rustdoc/rfc-2632-const-trait-impl.rs +++ b/tests/rustdoc/rfc-2632-const-trait-impl.rs @@ -15,16 +15,16 @@ use std::marker::Destruct; pub struct S<T>(T); -// @!has foo/trait.Tr.html '//pre[@class="rust item-decl"]/code/a[@class="trait"]' '~const' -// @has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Fn' -// @!has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' '~const' -// @has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' ': Fn' +//@ !has foo/trait.Tr.html '//pre[@class="rust item-decl"]/code/a[@class="trait"]' '~const' +//@ has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Fn' +//@ !has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' '~const' +//@ has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' ': Fn' #[const_trait] pub trait Tr<T> { - // @!has - '//section[@id="method.a"]/h4[@class="code-header"]' '~const' - // @has - '//section[@id="method.a"]/h4[@class="code-header"]/a[@class="trait"]' 'Fn' - // @!has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where"]' '~const' - // @has - '//section[@id="method.a"]/h4[@class="code-header"]/div[@class="where"]' ': Fn' + //@ !has - '//section[@id="method.a"]/h4[@class="code-header"]' '~const' + //@ has - '//section[@id="method.a"]/h4[@class="code-header"]/a[@class="trait"]' 'Fn' + //@ !has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where"]' '~const' + //@ has - '//section[@id="method.a"]/h4[@class="code-header"]/div[@class="where"]' ': Fn' fn a<A: /* ~const */ Fn() /* + ~const Destruct */>() where Option<A>: /* ~const */ Fn() /* + ~const Destruct */, @@ -32,11 +32,11 @@ pub trait Tr<T> { } } -// @has - '//section[@id="impl-Tr%3CT%3E-for-T"]' '' -// @!has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]' '~const' -// @has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/a[@class="trait"]' 'Fn' -// @!has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/span[@class="where"]' '~const' -// @has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/div[@class="where"]' ': Fn' +//@ has - '//section[@id="impl-Tr%3CT%3E-for-T"]' '' +//@ !has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]' '~const' +//@ has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/a[@class="trait"]' 'Fn' +//@ !has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/span[@class="where"]' '~const' +//@ has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/div[@class="where"]' ': Fn' impl<T: /* ~const */ Fn() /* + ~const Destruct */> const Tr<T> for T where Option<T>: /* ~const */ Fn() /* + ~const Destruct */, @@ -48,10 +48,10 @@ where } } -// @!has foo/fn.foo.html '//pre[@class="rust item-decl"]/code/a[@class="trait"]' '~const' -// @has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Fn' -// @!has - '//pre[@class="rust item-decl"]/code/div[@class="where"]' '~const' -// @has - '//pre[@class="rust item-decl"]/code/div[@class="where"]' ': Fn' +//@ !has foo/fn.foo.html '//pre[@class="rust item-decl"]/code/a[@class="trait"]' '~const' +//@ has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Fn' +//@ !has - '//pre[@class="rust item-decl"]/code/div[@class="where"]' '~const' +//@ has - '//pre[@class="rust item-decl"]/code/div[@class="where"]' ': Fn' pub const fn foo<F: /* ~const */ Fn() /* + ~const Destruct */>() where Option<F>: /* ~const */ Fn() /* + ~const Destruct */, @@ -60,10 +60,10 @@ where } impl<T> S<T> { - // @!has foo/struct.S.html '//section[@id="method.foo"]/h4[@class="code-header"]' '~const' - // @has - '//section[@id="method.foo"]/h4[@class="code-header"]/a[@class="trait"]' 'Fn' - // @!has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where"]' '~const' - // @has - '//section[@id="method.foo"]/h4[@class="code-header"]/div[@class="where"]' ': Fn' + //@ !has foo/struct.S.html '//section[@id="method.foo"]/h4[@class="code-header"]' '~const' + //@ has - '//section[@id="method.foo"]/h4[@class="code-header"]/a[@class="trait"]' 'Fn' + //@ !has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where"]' '~const' + //@ has - '//section[@id="method.foo"]/h4[@class="code-header"]/div[@class="where"]' ': Fn' pub const fn foo<B, C: /* ~const */ Fn() /* + ~const Destruct */>() where B: /* ~const */ Fn() /* + ~const Destruct */, diff --git a/tests/rustdoc/rustc-incoherent-impls.rs b/tests/rustdoc/rustc-incoherent-impls.rs index 4f0eca291f7..81a7025906b 100644 --- a/tests/rustdoc/rustc-incoherent-impls.rs +++ b/tests/rustdoc/rustc-incoherent-impls.rs @@ -10,8 +10,8 @@ extern crate incoherent_impl_types; #[doc(inline)] pub use incoherent_impl_types::FooTrait; -// @has foo/trait.FooTrait.html -// @count - '//section[@id="method.do_something"]' 1 +//@ has foo/trait.FooTrait.html +//@ count - '//section[@id="method.do_something"]' 1 impl dyn FooTrait { #[rustc_allow_incoherent_impl] pub fn do_something() {} @@ -20,8 +20,8 @@ impl dyn FooTrait { #[doc(inline)] pub use incoherent_impl_types::FooStruct; -// @has foo/struct.FooStruct.html -// @count - '//section[@id="method.do_something"]' 1 +//@ has foo/struct.FooStruct.html +//@ count - '//section[@id="method.do_something"]' 1 impl FooStruct { #[rustc_allow_incoherent_impl] pub fn do_something() {} diff --git a/tests/rustdoc/safe-intrinsic.rs b/tests/rustdoc/safe-intrinsic.rs index c508909f9aa..b46ffed99c3 100644 --- a/tests/rustdoc/safe-intrinsic.rs +++ b/tests/rustdoc/safe-intrinsic.rs @@ -6,17 +6,17 @@ #![crate_name = "foo"] extern "rust-intrinsic" { - // @has 'foo/fn.abort.html' - // @has - '//pre[@class="rust item-decl"]' 'pub extern "rust-intrinsic" fn abort() -> !' + //@ has 'foo/fn.abort.html' + //@ has - '//pre[@class="rust item-decl"]' 'pub extern "rust-intrinsic" fn abort() -> !' #[rustc_safe_intrinsic] pub fn abort() -> !; - // @has 'foo/fn.unreachable.html' - // @has - '//pre[@class="rust item-decl"]' 'pub unsafe extern "rust-intrinsic" fn unreachable() -> !' + //@ has 'foo/fn.unreachable.html' + //@ has - '//pre[@class="rust item-decl"]' 'pub unsafe extern "rust-intrinsic" fn unreachable() -> !' pub fn unreachable() -> !; } extern "C" { - // @has 'foo/fn.needs_drop.html' - // @has - '//pre[@class="rust item-decl"]' 'pub unsafe extern "C" fn needs_drop() -> !' + //@ has 'foo/fn.needs_drop.html' + //@ has - '//pre[@class="rust item-decl"]' 'pub unsafe extern "C" fn needs_drop() -> !' pub fn needs_drop() -> !; } diff --git a/tests/rustdoc/same-crate-hidden-impl-parameter.rs b/tests/rustdoc/same-crate-hidden-impl-parameter.rs index d55393af859..b0beb1bdfa0 100644 --- a/tests/rustdoc/same-crate-hidden-impl-parameter.rs +++ b/tests/rustdoc/same-crate-hidden-impl-parameter.rs @@ -9,7 +9,7 @@ pub trait HiddenTrait {} pub enum MyLibType {} -// @!has foo/enum.MyLibType.html '//*[@id="impl-From%3CHiddenType%3E"]' 'impl From<HiddenType> for MyLibType' +//@ !has foo/enum.MyLibType.html '//*[@id="impl-From%3CHiddenType%3E"]' 'impl From<HiddenType> for MyLibType' impl From<HiddenType> for MyLibType { fn from(it: HiddenType) -> MyLibType { match it {} @@ -18,17 +18,17 @@ impl From<HiddenType> for MyLibType { pub struct T<T>(T); -// @!has foo/enum.MyLibType.html '//*[@id="impl-From%3CT%3CT%3CT%3CT%3CHiddenType%3E%3E%3E%3E%3E"]' 'impl From<T<T<T<T<HiddenType>>>>> for MyLibType' +//@ !has foo/enum.MyLibType.html '//*[@id="impl-From%3CT%3CT%3CT%3CT%3CHiddenType%3E%3E%3E%3E%3E"]' 'impl From<T<T<T<T<HiddenType>>>>> for MyLibType' impl From<T<T<T<T<HiddenType>>>>> for MyLibType { fn from(it: T<T<T<T<HiddenType>>>>) -> MyLibType { todo!() } } -// @!has foo/enum.MyLibType.html '//*[@id="impl-HiddenTrait"]' 'impl HiddenTrait for MyLibType' +//@ !has foo/enum.MyLibType.html '//*[@id="impl-HiddenTrait"]' 'impl HiddenTrait for MyLibType' impl HiddenTrait for MyLibType {} -// @!has foo/struct.T.html '//*[@id="impl-From%3CMyLibType%3E"]' 'impl From<MyLibType> for T<T<T<T<HiddenType>>>>' +//@ !has foo/struct.T.html '//*[@id="impl-From%3CMyLibType%3E"]' 'impl From<MyLibType> for T<T<T<T<HiddenType>>>>' impl From<MyLibType> for T<T<T<T<HiddenType>>>> { fn from(it: MyLibType) -> T<T<T<T<HiddenType>>>> { match it {} diff --git a/tests/rustdoc/search-index-primitive-inherent-method-23511.rs b/tests/rustdoc/search-index-primitive-inherent-method-23511.rs index 1d0fe27e192..6054d8f12f5 100644 --- a/tests/rustdoc/search-index-primitive-inherent-method-23511.rs +++ b/tests/rustdoc/search-index-primitive-inherent-method-23511.rs @@ -9,7 +9,7 @@ pub mod str { #![rustc_doc_primitive = "str"] impl str { - // @hasraw search-index.js foo + //@ hasraw search-index.js foo #[rustc_allow_incoherent_impl] pub fn foo(&self) {} } diff --git a/tests/rustdoc/search-index-summaries.rs b/tests/rustdoc/search-index-summaries.rs index 529b42d0ca9..55db04340a6 100644 --- a/tests/rustdoc/search-index-summaries.rs +++ b/tests/rustdoc/search-index-summaries.rs @@ -1,8 +1,8 @@ #![crate_name = "foo"] -// @hasraw 'search.desc/foo/foo-desc-0-.js' 'Foo short link.' -// @!hasraw - 'www.example.com' -// @!hasraw - 'More Foo.' +//@ hasraw 'search.desc/foo/foo-desc-0-.js' 'Foo short link.' +//@ !hasraw - 'www.example.com' +//@ !hasraw - 'More Foo.' /// Foo short [link](https://www.example.com/). /// diff --git a/tests/rustdoc/search-index.rs b/tests/rustdoc/search-index.rs index d1d05eb886b..f53862ede38 100644 --- a/tests/rustdoc/search-index.rs +++ b/tests/rustdoc/search-index.rs @@ -2,25 +2,25 @@ use std::ops::Deref; -// @hasraw search-index.js Foo +//@ hasraw search-index.js Foo pub use private::Foo; mod private { pub struct Foo; impl Foo { - pub fn test_method() {} // @hasraw - test_method - fn priv_method() {} // @!hasraw - priv_method + pub fn test_method() {} //@ hasraw - test_method + fn priv_method() {} //@ !hasraw - priv_method } pub trait PrivateTrait { - fn trait_method(&self) {} // @!hasraw - priv_method + fn trait_method(&self) {} //@ !hasraw - priv_method } } pub struct Bar; impl Deref for Bar { - // @!hasraw search-index.js Target + //@ !hasraw search-index.js Target type Target = Bar; fn deref(&self) -> &Bar { self } } diff --git a/tests/rustdoc/short-docblock-codeblock.rs b/tests/rustdoc/short-docblock-codeblock.rs index 7ecd80b8c72..82486a9ea2d 100644 --- a/tests/rustdoc/short-docblock-codeblock.rs +++ b/tests/rustdoc/short-docblock-codeblock.rs @@ -1,6 +1,6 @@ #![crate_name = "foo"] -// @count foo/index.html '//*[@class="desc docblock-short"]' 0 +//@ count foo/index.html '//*[@class="desc docblock-short"]' 0 /// ``` /// let x = 12; diff --git a/tests/rustdoc/short-docblock.rs b/tests/rustdoc/short-docblock.rs index 151a42a9c9e..c80a5025ebe 100644 --- a/tests/rustdoc/short-docblock.rs +++ b/tests/rustdoc/short-docblock.rs @@ -1,26 +1,26 @@ #![crate_name = "foo"] -// @has foo/index.html '//*[@class="desc docblock-short"]' 'fooo' -// @!has foo/index.html '//*[@class="desc docblock-short"]/h1' 'fooo' +//@ has foo/index.html '//*[@class="desc docblock-short"]' 'fooo' +//@ !has foo/index.html '//*[@class="desc docblock-short"]/h1' 'fooo' -// @has foo/fn.foo.html '//h2[@id="fooo"]' 'fooo' -// @has foo/fn.foo.html '//h2[@id="fooo"]/a[@href="#fooo"]' '§' +//@ has foo/fn.foo.html '//h2[@id="fooo"]' 'fooo' +//@ has foo/fn.foo.html '//h2[@id="fooo"]/a[@href="#fooo"]' '§' /// # fooo /// /// foo pub fn foo() {} -// @has foo/index.html '//*[@class="desc docblock-short"]' 'mooood' -// @!has foo/index.html '//*[@class="desc docblock-short"]/h2' 'mooood' +//@ has foo/index.html '//*[@class="desc docblock-short"]' 'mooood' +//@ !has foo/index.html '//*[@class="desc docblock-short"]/h2' 'mooood' -// @has foo/foo/index.html '//h3[@id="mooood"]' 'mooood' -// @has foo/foo/index.html '//h3[@id="mooood"]/a[@href="#mooood"]' '§' +//@ has foo/foo/index.html '//h3[@id="mooood"]' 'mooood' +//@ has foo/foo/index.html '//h3[@id="mooood"]/a[@href="#mooood"]' '§' /// ## mooood /// /// foo mod pub mod foo {} -// @has foo/index.html '//*[@class="desc docblock-short"]/a[@href=\ +//@ has foo/index.html '//*[@class="desc docblock-short"]/a[@href=\ // "https://nougat.world"]/code' 'nougat' /// [`nougat`](https://nougat.world) diff --git a/tests/rustdoc/show-const-contents.rs b/tests/rustdoc/show-const-contents.rs index 91df03adbbc..6d2701693ce 100644 --- a/tests/rustdoc/show-const-contents.rs +++ b/tests/rustdoc/show-const-contents.rs @@ -1,57 +1,57 @@ // Test that the contents of constants are displayed as part of the // documentation. -// @hasraw show_const_contents/constant.CONST_S.html 'show this' -// @!hasraw show_const_contents/constant.CONST_S.html '; //' +//@ hasraw show_const_contents/constant.CONST_S.html 'show this' +//@ !hasraw show_const_contents/constant.CONST_S.html '; //' pub const CONST_S: &'static str = "show this"; -// @hasraw show_const_contents/constant.CONST_I32.html '= 42;' -// @!hasraw show_const_contents/constant.CONST_I32.html '; //' +//@ hasraw show_const_contents/constant.CONST_I32.html '= 42;' +//@ !hasraw show_const_contents/constant.CONST_I32.html '; //' pub const CONST_I32: i32 = 42; -// @hasraw show_const_contents/constant.CONST_I32_HEX.html '= 0x42;' -// @!hasraw show_const_contents/constant.CONST_I32_HEX.html '; //' +//@ hasraw show_const_contents/constant.CONST_I32_HEX.html '= 0x42;' +//@ !hasraw show_const_contents/constant.CONST_I32_HEX.html '; //' pub const CONST_I32_HEX: i32 = 0x42; -// @hasraw show_const_contents/constant.CONST_NEG_I32.html '= -42;' -// @!hasraw show_const_contents/constant.CONST_NEG_I32.html '; //' +//@ hasraw show_const_contents/constant.CONST_NEG_I32.html '= -42;' +//@ !hasraw show_const_contents/constant.CONST_NEG_I32.html '; //' pub const CONST_NEG_I32: i32 = -42; -// @hasraw show_const_contents/constant.CONST_EQ_TO_VALUE_I32.html '= 42i32;' -// @!hasraw show_const_contents/constant.CONST_EQ_TO_VALUE_I32.html '// 42i32' +//@ hasraw show_const_contents/constant.CONST_EQ_TO_VALUE_I32.html '= 42i32;' +//@ !hasraw show_const_contents/constant.CONST_EQ_TO_VALUE_I32.html '// 42i32' pub const CONST_EQ_TO_VALUE_I32: i32 = 42i32; -// @hasraw show_const_contents/constant.CONST_CALC_I32.html '= _; // 43i32' +//@ hasraw show_const_contents/constant.CONST_CALC_I32.html '= _; // 43i32' pub const CONST_CALC_I32: i32 = 42 + 1; -// @!hasraw show_const_contents/constant.CONST_REF_I32.html '= &42;' -// @!hasraw show_const_contents/constant.CONST_REF_I32.html '; //' +//@ !hasraw show_const_contents/constant.CONST_REF_I32.html '= &42;' +//@ !hasraw show_const_contents/constant.CONST_REF_I32.html '; //' pub const CONST_REF_I32: &'static i32 = &42; -// @hasraw show_const_contents/constant.CONST_I32_MAX.html '= i32::MAX; // 2_147_483_647i32' +//@ hasraw show_const_contents/constant.CONST_I32_MAX.html '= i32::MAX; // 2_147_483_647i32' pub const CONST_I32_MAX: i32 = i32::MAX; -// @!hasraw show_const_contents/constant.UNIT.html '= ();' -// @!hasraw show_const_contents/constant.UNIT.html '; //' +//@ !hasraw show_const_contents/constant.UNIT.html '= ();' +//@ !hasraw show_const_contents/constant.UNIT.html '; //' pub const UNIT: () = (); pub struct MyType(i32); -// @!hasraw show_const_contents/constant.MY_TYPE.html '= MyType(42);' -// @!hasraw show_const_contents/constant.MY_TYPE.html '; //' +//@ !hasraw show_const_contents/constant.MY_TYPE.html '= MyType(42);' +//@ !hasraw show_const_contents/constant.MY_TYPE.html '; //' pub const MY_TYPE: MyType = MyType(42); pub struct MyTypeWithStr(&'static str); -// @!hasraw show_const_contents/constant.MY_TYPE_WITH_STR.html '= MyTypeWithStr("show this");' -// @!hasraw show_const_contents/constant.MY_TYPE_WITH_STR.html '; //' +//@ !hasraw show_const_contents/constant.MY_TYPE_WITH_STR.html '= MyTypeWithStr("show this");' +//@ !hasraw show_const_contents/constant.MY_TYPE_WITH_STR.html '; //' pub const MY_TYPE_WITH_STR: MyTypeWithStr = MyTypeWithStr("show this"); -// @hasraw show_const_contents/constant.PI.html '= 3.14159265358979323846264338327950288_f32;' -// @hasraw show_const_contents/constant.PI.html '; // 3.14159274f32' +//@ hasraw show_const_contents/constant.PI.html '= 3.14159265358979323846264338327950288_f32;' +//@ hasraw show_const_contents/constant.PI.html '; // 3.14159274f32' pub use std::f32::consts::PI; -// @hasraw show_const_contents/constant.MAX.html '= i32::MAX; // 2_147_483_647i32' +//@ hasraw show_const_contents/constant.MAX.html '= i32::MAX; // 2_147_483_647i32' #[allow(deprecated, deprecated_in_future)] pub use std::i32::MAX; @@ -61,8 +61,8 @@ macro_rules! int_module { ) } -// @hasraw show_const_contents/constant.MIN.html '= i16::MIN; // -32_768i16' +//@ hasraw show_const_contents/constant.MIN.html '= i16::MIN; // -32_768i16' int_module!(i16); -// @has show_const_contents/constant.ESCAPE.html //pre '= r#"<script>alert("ESCAPE");</script>"#;' +//@ has show_const_contents/constant.ESCAPE.html //pre '= r#"<script>alert("ESCAPE");</script>"#;' pub const ESCAPE: &str = r#"<script>alert("ESCAPE");</script>"#; diff --git a/tests/rustdoc/sidebar-all-page.rs b/tests/rustdoc/sidebar-all-page.rs index 4c8a0f543a5..1f97a414048 100644 --- a/tests/rustdoc/sidebar-all-page.rs +++ b/tests/rustdoc/sidebar-all-page.rs @@ -1,17 +1,17 @@ #![crate_name = "foo"] #![feature(rustc_attrs)] -// @has 'foo/all.html' -// @has - '//*[@class="sidebar-elems"]//li' 'Structs' -// @has - '//*[@class="sidebar-elems"]//li' 'Enums' -// @has - '//*[@class="sidebar-elems"]//li' 'Unions' -// @has - '//*[@class="sidebar-elems"]//li' 'Functions' -// @has - '//*[@class="sidebar-elems"]//li' 'Traits' -// @has - '//*[@class="sidebar-elems"]//li' 'Macros' -// @has - '//*[@class="sidebar-elems"]//li' 'Type Aliases' -// @has - '//*[@class="sidebar-elems"]//li' 'Constants' -// @has - '//*[@class="sidebar-elems"]//li' 'Statics' -// @has - '//*[@class="sidebar-elems"]//li' 'Primitive Types' +//@ has 'foo/all.html' +//@ has - '//*[@class="sidebar-elems"]//li' 'Structs' +//@ has - '//*[@class="sidebar-elems"]//li' 'Enums' +//@ has - '//*[@class="sidebar-elems"]//li' 'Unions' +//@ has - '//*[@class="sidebar-elems"]//li' 'Functions' +//@ has - '//*[@class="sidebar-elems"]//li' 'Traits' +//@ has - '//*[@class="sidebar-elems"]//li' 'Macros' +//@ has - '//*[@class="sidebar-elems"]//li' 'Type Aliases' +//@ has - '//*[@class="sidebar-elems"]//li' 'Constants' +//@ has - '//*[@class="sidebar-elems"]//li' 'Statics' +//@ has - '//*[@class="sidebar-elems"]//li' 'Primitive Types' pub struct Foo; pub enum Enum { diff --git a/tests/rustdoc/sidebar-items.rs b/tests/rustdoc/sidebar-items.rs index b746f698264..f3812143a7d 100644 --- a/tests/rustdoc/sidebar-items.rs +++ b/tests/rustdoc/sidebar-items.rs @@ -1,20 +1,20 @@ #![feature(associated_type_defaults)] #![crate_name = "foo"] -// @has foo/trait.Foo.html -// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#required-methods"]' 'Required Methods' -// @has - '//*[@class="sidebar-elems"]//section//a' 'bar' -// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#provided-methods"]' 'Provided Methods' -// @has - '//*[@class="sidebar-elems"]//section//a' 'foo' -// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#required-associated-consts"]' 'Required Associated Constants' -// @has - '//*[@class="sidebar-elems"]//section//a' 'FOO' -// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#provided-associated-consts"]' 'Provided Associated Constants' -// @has - '//*[@class="sidebar-elems"]//section//a' 'BAR' -// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#required-associated-types"]' 'Required Associated Types' -// @has - '//*[@class="sidebar-elems"]//section//a' 'Output' -// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#provided-associated-types"]' 'Provided Associated Types' -// @has - '//*[@class="sidebar-elems"]//section//a' 'Extra' -// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#object-safety"]' 'Object Safety' +//@ has foo/trait.Foo.html +//@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#required-methods"]' 'Required Methods' +//@ has - '//*[@class="sidebar-elems"]//section//a' 'bar' +//@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#provided-methods"]' 'Provided Methods' +//@ has - '//*[@class="sidebar-elems"]//section//a' 'foo' +//@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#required-associated-consts"]' 'Required Associated Constants' +//@ has - '//*[@class="sidebar-elems"]//section//a' 'FOO' +//@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#provided-associated-consts"]' 'Provided Associated Constants' +//@ has - '//*[@class="sidebar-elems"]//section//a' 'BAR' +//@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#required-associated-types"]' 'Required Associated Types' +//@ has - '//*[@class="sidebar-elems"]//section//a' 'Output' +//@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#provided-associated-types"]' 'Provided Associated Types' +//@ has - '//*[@class="sidebar-elems"]//section//a' 'Extra' +//@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#object-safety"]' 'Object Safety' pub trait Foo { const FOO: usize; const BAR: u32 = 0; @@ -25,37 +25,37 @@ pub trait Foo { fn bar() -> Self::Output; } -// @has foo/trait.Safe.html -// @!has - '//div[@class="sidebar-elems"]//h3/a[@href="#object-safety"]' '' +//@ has foo/trait.Safe.html +//@ !has - '//div[@class="sidebar-elems"]//h3/a[@href="#object-safety"]' '' pub trait Safe { fn access(&self); } -// @has foo/struct.Bar.html -// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#fields"]' 'Fields' -// @has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.f"]' 'f' -// @has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.u"]' 'u' -// @!has - '//*[@class="sidebar-elems"]//section//a' 'waza' +//@ has foo/struct.Bar.html +//@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#fields"]' 'Fields' +//@ has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.f"]' 'f' +//@ has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.u"]' 'u' +//@ !has - '//*[@class="sidebar-elems"]//section//a' 'waza' pub struct Bar { pub f: u32, pub u: u32, waza: u32, } -// @has foo/enum.En.html -// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#variants"]' 'Variants' -// @has - '//*[@class="sidebar-elems"]//section//a' 'Foo' -// @has - '//*[@class="sidebar-elems"]//section//a' 'Bar' +//@ has foo/enum.En.html +//@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#variants"]' 'Variants' +//@ has - '//*[@class="sidebar-elems"]//section//a' 'Foo' +//@ has - '//*[@class="sidebar-elems"]//section//a' 'Bar' pub enum En { Foo, Bar, } -// @has foo/union.MyUnion.html -// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#fields"]' 'Fields' -// @has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.f1"]' 'f1' -// @has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.f2"]' 'f2' -// @!has - '//*[@class="sidebar-elems"]//section//a' 'waza' +//@ has foo/union.MyUnion.html +//@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#fields"]' 'Fields' +//@ has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.f1"]' 'f1' +//@ has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.f2"]' 'f2' +//@ !has - '//*[@class="sidebar-elems"]//section//a' 'waza' pub union MyUnion { pub f1: u32, pub f2: f32, diff --git a/tests/rustdoc/sidebar-link-generation.rs b/tests/rustdoc/sidebar-link-generation.rs index 7858f35a261..ee868ec75d3 100644 --- a/tests/rustdoc/sidebar-link-generation.rs +++ b/tests/rustdoc/sidebar-link-generation.rs @@ -1,6 +1,6 @@ #![crate_name = "foo"] -// @has foo/struct.SomeStruct.html '//*[@class="sidebar-elems"]//section//li/a[@href="#method.some_fn-1"]' \ +//@ has foo/struct.SomeStruct.html '//*[@class="sidebar-elems"]//section//li/a[@href="#method.some_fn-1"]' \ // "some_fn" pub struct SomeStruct<T> { _inner: T } diff --git a/tests/rustdoc/sidebar-links-to-foreign-impl.rs b/tests/rustdoc/sidebar-links-to-foreign-impl.rs index 733a18ad94a..7c039eeb39f 100644 --- a/tests/rustdoc/sidebar-links-to-foreign-impl.rs +++ b/tests/rustdoc/sidebar-links-to-foreign-impl.rs @@ -2,13 +2,13 @@ #![crate_name = "foo"] -// @has foo/trait.Foo.html -// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#foreign-impls"]' 'Implementations on Foreign Types' -// @has - '//h2[@id="foreign-impls"]' 'Implementations on Foreign Types' -// @has - '//*[@class="sidebar-elems"]//section//a[@href="#impl-Foo-for-u32"]' 'u32' -// @has - '//*[@id="impl-Foo-for-u32"]//h3[@class="code-header"]' 'impl Foo for u32' -// @has - "//*[@class=\"sidebar-elems\"]//section//a[@href=\"#impl-Foo-for-%26str\"]" "&'a str" -// @has - "//*[@id=\"impl-Foo-for-%26str\"]//h3[@class=\"code-header\"]" "impl<'a> Foo for &'a str" +//@ has foo/trait.Foo.html +//@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#foreign-impls"]' 'Implementations on Foreign Types' +//@ has - '//h2[@id="foreign-impls"]' 'Implementations on Foreign Types' +//@ has - '//*[@class="sidebar-elems"]//section//a[@href="#impl-Foo-for-u32"]' 'u32' +//@ has - '//*[@id="impl-Foo-for-u32"]//h3[@class="code-header"]' 'impl Foo for u32' +//@ has - "//*[@class=\"sidebar-elems\"]//section//a[@href=\"#impl-Foo-for-%26str\"]" "&'a str" +//@ has - "//*[@id=\"impl-Foo-for-%26str\"]//h3[@class=\"code-header\"]" "impl<'a> Foo for &'a str" pub trait Foo {} impl Foo for u32 {} diff --git a/tests/rustdoc/sidebar-trait-impl-disambiguate-78701.rs b/tests/rustdoc/sidebar-trait-impl-disambiguate-78701.rs index 89b7ccb5222..b1bf029cf84 100644 --- a/tests/rustdoc/sidebar-trait-impl-disambiguate-78701.rs +++ b/tests/rustdoc/sidebar-trait-impl-disambiguate-78701.rs @@ -5,9 +5,9 @@ // link to the blanket impl and not the other impl. Basically, we're checking if // the ID is correctly derived. -// @has 'foo/struct.AnotherStruct.html' -// @count - '//*[@class="sidebar"]//a[@href="#impl-AnAmazingTrait-for-AnotherStruct%3C()%3E"]' 1 -// @count - '//*[@class="sidebar"]//a[@href="#impl-AnAmazingTrait-for-T"]' 1 +//@ has 'foo/struct.AnotherStruct.html' +//@ count - '//*[@class="sidebar"]//a[@href="#impl-AnAmazingTrait-for-AnotherStruct%3C()%3E"]' 1 +//@ count - '//*[@class="sidebar"]//a[@href="#impl-AnAmazingTrait-for-T"]' 1 pub trait Something {} diff --git a/tests/rustdoc/sized_trait.rs b/tests/rustdoc/sized_trait.rs index feef4de8d57..4df62fdc081 100644 --- a/tests/rustdoc/sized_trait.rs +++ b/tests/rustdoc/sized_trait.rs @@ -1,17 +1,17 @@ #![crate_name = "foo"] -// @has foo/struct.Bar.html -// @!has - '//*[@id="impl-Sized"]' '' +//@ has foo/struct.Bar.html +//@ !has - '//*[@id="impl-Sized"]' '' pub struct Bar { a: u16, } -// @has foo/struct.Foo.html -// @!has - '//*[@id="impl-Sized"]' '' +//@ has foo/struct.Foo.html +//@ !has - '//*[@id="impl-Sized"]' '' pub struct Foo<T: ?Sized>(T); -// @has foo/struct.Unsized.html -// @has - '//*[@id="impl-Sized-for-Unsized"]//h3[@class="code-header"]' 'impl !Sized for Unsized' +//@ has foo/struct.Unsized.html +//@ has - '//*[@id="impl-Sized-for-Unsized"]//h3[@class="code-header"]' 'impl !Sized for Unsized' pub struct Unsized { data: [u8], } diff --git a/tests/rustdoc/slice-links.rs b/tests/rustdoc/slice-links.rs index 6dea3b74ea3..74f260976c0 100644 --- a/tests/rustdoc/slice-links.rs +++ b/tests/rustdoc/slice-links.rs @@ -3,26 +3,26 @@ pub struct MyBox<T: ?Sized>(*const T); -// @has 'foo/fn.alpha.html' -// @snapshot link_slice_u32 - '//pre[@class="rust item-decl"]/code' +//@ has 'foo/fn.alpha.html' +//@ snapshot link_slice_u32 - '//pre[@class="rust item-decl"]/code' pub fn alpha() -> &'static [u32] { loop {} } -// @has 'foo/fn.beta.html' -// @snapshot link_slice_generic - '//pre[@class="rust item-decl"]/code' +//@ has 'foo/fn.beta.html' +//@ snapshot link_slice_generic - '//pre[@class="rust item-decl"]/code' pub fn beta<T>() -> &'static [T] { loop {} } -// @has 'foo/fn.gamma.html' -// @snapshot link_box_u32 - '//pre[@class="rust item-decl"]/code' +//@ has 'foo/fn.gamma.html' +//@ snapshot link_box_u32 - '//pre[@class="rust item-decl"]/code' pub fn gamma() -> MyBox<[u32]> { loop {} } -// @has 'foo/fn.delta.html' -// @snapshot link_box_generic - '//pre[@class="rust item-decl"]/code' +//@ has 'foo/fn.delta.html' +//@ snapshot link_box_generic - '//pre[@class="rust item-decl"]/code' pub fn delta<T>() -> MyBox<[T]> { loop {} } diff --git a/tests/rustdoc/smart-punct.rs b/tests/rustdoc/smart-punct.rs index 7ae5bd69945..41b3ee3f14e 100644 --- a/tests/rustdoc/smart-punct.rs +++ b/tests/rustdoc/smart-punct.rs @@ -20,9 +20,9 @@ //! I say "don't smart-punct me -- please!" //! ``` -// @has "foo/index.html" "//p" "This is the “start” of the ‘document’! How’d you know that “it’s” the start?" -// @has "foo/index.html" "//h2" "Header with “smart punct’”" -// @has "foo/index.html" '//a[@href="https://www.rust-lang.org"]' "link with “smart punct’” – yessiree!" -// @has "foo/index.html" '//code' "this inline code -- it shouldn't have \"smart punct\"" -// @has "foo/index.html" '//pre' "let x = \"don't smart-punct me -- please!\";" -// @has "foo/index.html" '//pre' "I say \"don't smart-punct me -- please!\"" +//@ has "foo/index.html" "//p" "This is the “start” of the ‘document’! How’d you know that “it’s” the start?" +//@ has "foo/index.html" "//h2" "Header with “smart punct’”" +//@ has "foo/index.html" '//a[@href="https://www.rust-lang.org"]' "link with “smart punct’” – yessiree!" +//@ has "foo/index.html" '//code' "this inline code -- it shouldn't have \"smart punct\"" +//@ has "foo/index.html" '//pre' "let x = \"don't smart-punct me -- please!\";" +//@ has "foo/index.html" '//pre' "I say \"don't smart-punct me -- please!\"" diff --git a/tests/rustdoc/smoke.rs b/tests/rustdoc/smoke.rs index c1ed3a0c953..415fca313fc 100644 --- a/tests/rustdoc/smoke.rs +++ b/tests/rustdoc/smoke.rs @@ -1,25 +1,25 @@ -// @has smoke/index.html +//@ has smoke/index.html //! Very docs -// @has smoke/bar/index.html +//@ has smoke/bar/index.html pub mod bar { /// So correct - // @has smoke/bar/baz/index.html + //@ has smoke/bar/baz/index.html pub mod baz { /// Much detail - // @has smoke/bar/baz/fn.baz.html + //@ has smoke/bar/baz/fn.baz.html pub fn baz() { } } /// *wow* - // @has smoke/bar/trait.Doge.html + //@ has smoke/bar/trait.Doge.html pub trait Doge { fn dummy(&self) { } } - // @has smoke/bar/struct.Foo.html + //@ has smoke/bar/struct.Foo.html pub struct Foo { x: isize, y: usize } - // @has smoke/bar/fn.prawns.html + //@ has smoke/bar/fn.prawns.html pub fn prawns((a, b): (isize, usize), Foo { x, y }: Foo) { } } diff --git a/tests/rustdoc/sort-53812.rs b/tests/rustdoc/sort-53812.rs index 968ae035043..21cb0ad9308 100644 --- a/tests/rustdoc/sort-53812.rs +++ b/tests/rustdoc/sort-53812.rs @@ -14,10 +14,10 @@ macro_rules! array_impls { } } -// @has foo/trait.MyIterator.html -// @has - '//*[@id="implementors-list"]/*[@class="impl"][1]' 'MyStruct<[T; 0]>' -// @has - '//*[@id="implementors-list"]/*[@class="impl"][2]' 'MyStruct<[T; 1]>' -// @has - '//*[@id="implementors-list"]/*[@class="impl"][3]' 'MyStruct<[T; 2]>' -// @has - '//*[@id="implementors-list"]/*[@class="impl"][4]' 'MyStruct<[T; 3]>' -// @has - '//*[@id="implementors-list"]/*[@class="impl"][5]' 'MyStruct<[T; 10]>' +//@ has foo/trait.MyIterator.html +//@ has - '//*[@id="implementors-list"]/*[@class="impl"][1]' 'MyStruct<[T; 0]>' +//@ has - '//*[@id="implementors-list"]/*[@class="impl"][2]' 'MyStruct<[T; 1]>' +//@ has - '//*[@id="implementors-list"]/*[@class="impl"][3]' 'MyStruct<[T; 2]>' +//@ has - '//*[@id="implementors-list"]/*[@class="impl"][4]' 'MyStruct<[T; 3]>' +//@ has - '//*[@id="implementors-list"]/*[@class="impl"][5]' 'MyStruct<[T; 10]>' array_impls! { 10 3 2 1 0 } diff --git a/tests/rustdoc/sort-modules-by-appearance.rs b/tests/rustdoc/sort-modules-by-appearance.rs index 2d224107d22..1254116afdf 100644 --- a/tests/rustdoc/sort-modules-by-appearance.rs +++ b/tests/rustdoc/sort-modules-by-appearance.rs @@ -9,5 +9,5 @@ pub mod module_c {} pub mod module_a {} -// @matchesraw 'sort_modules_by_appearance/index.html' '(?s)module_b.*module_c.*module_a' -// @matchesraw 'sort_modules_by_appearance/sidebar-items.js' '"module_b".*"module_c".*"module_a"' +//@ matchesraw 'sort_modules_by_appearance/index.html' '(?s)module_b.*module_c.*module_a' +//@ matchesraw 'sort_modules_by_appearance/sidebar-items.js' '"module_b".*"module_c".*"module_a"' diff --git a/tests/rustdoc/source-code-highlight.rs b/tests/rustdoc/source-code-highlight.rs index 0a1be791ec2..f1c905e64c0 100644 --- a/tests/rustdoc/source-code-highlight.rs +++ b/tests/rustdoc/source-code-highlight.rs @@ -4,26 +4,26 @@ //@ compile-flags: -Zunstable-options --generate-link-to-definition #![crate_name = "foo"] -// @has 'src/foo/source-code-highlight.rs.html' +//@ has 'src/foo/source-code-highlight.rs.html' -// @hasraw - '<a href="../../foo/macro.foo.html">foo</a>' +//@ hasraw - '<a href="../../foo/macro.foo.html">foo</a>' #[macro_export] macro_rules! foo { () => {} } -// @hasraw - '<span class="macro">foo!</span>' +//@ hasraw - '<span class="macro">foo!</span>' foo! {} -// @hasraw - '<a href="../../foo/fn.f.html">f</a>' +//@ hasraw - '<a href="../../foo/fn.f.html">f</a>' #[rustfmt::skip] pub fn f () {} -// @hasraw - '<a href="../../foo/struct.Bar.html">Bar</a>' -// @hasraw - '<a href="../../foo/struct.Bar.html">Bar</a>' -// @hasraw - '<a href="{{channel}}/std/primitive.u32.html">u32</a>' +//@ hasraw - '<a href="../../foo/struct.Bar.html">Bar</a>' +//@ hasraw - '<a href="../../foo/struct.Bar.html">Bar</a>' +//@ hasraw - '<a href="{{channel}}/std/primitive.u32.html">u32</a>' #[rustfmt::skip] pub struct Bar ( u32 ); -// @hasraw - '<a href="../../foo/enum.Foo.html">Foo</a>' +//@ hasraw - '<a href="../../foo/enum.Foo.html">Foo</a>' pub enum Foo { A, } diff --git a/tests/rustdoc/source-file.rs b/tests/rustdoc/source-file.rs index 16d4cbe3a34..6cff5edf146 100644 --- a/tests/rustdoc/source-file.rs +++ b/tests/rustdoc/source-file.rs @@ -1,5 +1,5 @@ #![crate_name = "foo"] -// @hasraw src-files.js source-file.rs +//@ hasraw src-files.js source-file.rs pub struct Foo; diff --git a/tests/rustdoc/source-version-separator.rs b/tests/rustdoc/source-version-separator.rs index 7256f731573..a998c538eed 100644 --- a/tests/rustdoc/source-version-separator.rs +++ b/tests/rustdoc/source-version-separator.rs @@ -2,24 +2,24 @@ #![crate_name = "foo"] #![feature(staged_api)] -// @has foo/trait.Bar.html -// @has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.0 · source · ' +//@ has foo/trait.Bar.html +//@ has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.0 · source · ' #[stable(feature = "bar", since = "1.0")] pub trait Bar { - // @has - '//*[@id="tymethod.foo"]/*[@class="rightside"]' '3.0.0 · source' + //@ has - '//*[@id="tymethod.foo"]/*[@class="rightside"]' '3.0.0 · source' #[stable(feature = "foobar", since = "3.0")] fn foo(); } -// @has - '//div[@id="implementors-list"]//*[@class="rightside"]' '4.0.0 · source' +//@ has - '//div[@id="implementors-list"]//*[@class="rightside"]' '4.0.0 · source' -// @has foo/struct.Foo.html -// @has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.0 · source · ' +//@ has foo/struct.Foo.html +//@ has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.0 · source · ' #[stable(feature = "baz", since = "1.0")] pub struct Foo; impl Foo { - // @has - '//*[@id="method.foofoo"]/*[@class="rightside"]' '3.0.0 · source' + //@ has - '//*[@id="method.foofoo"]/*[@class="rightside"]' '3.0.0 · source' #[stable(feature = "foobar", since = "3.0")] pub fn foofoo() {} } diff --git a/tests/rustdoc/src-link-external-macro-26606.rs b/tests/rustdoc/src-link-external-macro-26606.rs index a5b34867869..b5662be9b2d 100644 --- a/tests/rustdoc/src-link-external-macro-26606.rs +++ b/tests/rustdoc/src-link-external-macro-26606.rs @@ -5,10 +5,10 @@ // https://github.com/rust-lang/rust/issues/26606 #![crate_name="issue_26606"] -// @has issue_26606_macro/macro.make_item.html +//@ has issue_26606_macro/macro.make_item.html #[macro_use] extern crate issue_26606_macro; -// @has issue_26606/constant.FOO.html -// @has - '//a[@href="../src/issue_26606/src-link-external-macro-26606.rs.html#14"]' 'source' +//@ has issue_26606/constant.FOO.html +//@ has - '//a[@href="../src/issue_26606/src-link-external-macro-26606.rs.html#14"]' 'source' make_item!(FOO); diff --git a/tests/rustdoc/src-links-auto-impls.rs b/tests/rustdoc/src-links-auto-impls.rs index 08a497d4cf5..dd07f85eee7 100644 --- a/tests/rustdoc/src-links-auto-impls.rs +++ b/tests/rustdoc/src-links-auto-impls.rs @@ -1,12 +1,12 @@ #![crate_name = "foo"] -// @has foo/struct.Unsized.html -// @has - '//*[@id="impl-Sized-for-Unsized"]/h3[@class="code-header"]' 'impl !Sized for Unsized' -// @!has - '//*[@id="impl-Sized-for-Unsized"]//a[@class="src"]' 'source' -// @has - '//*[@id="impl-Sync-for-Unsized"]/h3[@class="code-header"]' 'impl Sync for Unsized' -// @!has - '//*[@id="impl-Sync-for-Unsized"]//a[@class="src"]' 'source' -// @has - '//*[@id="impl-Any-for-T"]/h3[@class="code-header"]' 'impl<T> Any for T' -// @has - '//*[@id="impl-Any-for-T"]//a[@class="src rightside"]' 'source' +//@ has foo/struct.Unsized.html +//@ has - '//*[@id="impl-Sized-for-Unsized"]/h3[@class="code-header"]' 'impl !Sized for Unsized' +//@ !has - '//*[@id="impl-Sized-for-Unsized"]//a[@class="src"]' 'source' +//@ has - '//*[@id="impl-Sync-for-Unsized"]/h3[@class="code-header"]' 'impl Sync for Unsized' +//@ !has - '//*[@id="impl-Sync-for-Unsized"]//a[@class="src"]' 'source' +//@ has - '//*[@id="impl-Any-for-T"]/h3[@class="code-header"]' 'impl<T> Any for T' +//@ has - '//*[@id="impl-Any-for-T"]//a[@class="src rightside"]' 'source' pub struct Unsized { data: [u8], } diff --git a/tests/rustdoc/src-links-external.rs b/tests/rustdoc/src-links-external.rs index fd48b964ab9..e8acbf1b9b4 100644 --- a/tests/rustdoc/src-links-external.rs +++ b/tests/rustdoc/src-links-external.rs @@ -6,8 +6,8 @@ extern crate src_links_external; -// @has foo/bar/index.html '//a/@href' '../../src/src_links_external/src-links-external.rs.html#1' +//@ has foo/bar/index.html '//a/@href' '../../src/src_links_external/src-links-external.rs.html#1' #[doc(inline)] pub use src_links_external as bar; -// @has foo/bar/struct.Foo.html '//a/@href' '../../src/src_links_external/src-links-external.rs.html#1' +//@ has foo/bar/struct.Foo.html '//a/@href' '../../src/src_links_external/src-links-external.rs.html#1' diff --git a/tests/rustdoc/src-links-implementor-43893.rs b/tests/rustdoc/src-links-implementor-43893.rs index 811957c430b..d9abdcde08d 100644 --- a/tests/rustdoc/src-links-implementor-43893.rs +++ b/tests/rustdoc/src-links-implementor-43893.rs @@ -7,15 +7,15 @@ pub trait SomeTrait {} pub struct SomeStruct; -// @has foo/trait.SomeTrait.html '//a/@href' '../src/foo/src-links-implementor-43893.rs.html#11' +//@ has foo/trait.SomeTrait.html '//a/@href' '../src/foo/src-links-implementor-43893.rs.html#11' impl SomeTrait for usize {} -// @has foo/trait.SomeTrait.html '//a/@href' '../src/foo/src-links-implementor-43893.rs.html#14-16' +//@ has foo/trait.SomeTrait.html '//a/@href' '../src/foo/src-links-implementor-43893.rs.html#14-16' impl SomeTrait for SomeStruct { // deliberately multi-line impl } pub trait AnotherTrait {} -// @has foo/trait.AnotherTrait.html '//a/@href' '../src/foo/src-links-implementor-43893.rs.html#21' +//@ has foo/trait.AnotherTrait.html '//a/@href' '../src/foo/src-links-implementor-43893.rs.html#21' impl<T> AnotherTrait for T {} diff --git a/tests/rustdoc/src-links-inlined-34274.rs b/tests/rustdoc/src-links-inlined-34274.rs index 6d6999cf866..8675ae4736e 100644 --- a/tests/rustdoc/src-links-inlined-34274.rs +++ b/tests/rustdoc/src-links-inlined-34274.rs @@ -7,5 +7,5 @@ extern crate issue_34274; -// @has foo/fn.extern_c_fn.html '//a/@href' '../src/issue_34274/issue-34274.rs.html#2' +//@ has foo/fn.extern_c_fn.html '//a/@href' '../src/issue_34274/issue-34274.rs.html#2' pub use issue_34274::extern_c_fn; diff --git a/tests/rustdoc/src-links.rs b/tests/rustdoc/src-links.rs index 7a6c733d464..24039a5d84e 100644 --- a/tests/rustdoc/src-links.rs +++ b/tests/rustdoc/src-links.rs @@ -1,51 +1,51 @@ #![crate_name = "foo"] //! Dox -// @has src/foo/src-links.rs.html -// @has foo/index.html '//a/@href' '../src/foo/src-links.rs.html' +//@ has src/foo/src-links.rs.html +//@ has foo/index.html '//a/@href' '../src/foo/src-links.rs.html' #[path = "src-links/mod.rs"] pub mod qux; -// @has src/foo/src-links.rs.html -// @has foo/fizz/index.html '//a/@href' '../src/foo/src-links/fizz.rs.html' +//@ has src/foo/src-links.rs.html +//@ has foo/fizz/index.html '//a/@href' '../src/foo/src-links/fizz.rs.html' #[path = "src-links/../src-links/fizz.rs"] pub mod fizz; -// @has foo/bar/index.html '//a/@href' '../../src/foo/src-links.rs.html' +//@ has foo/bar/index.html '//a/@href' '../../src/foo/src-links.rs.html' pub mod bar { /// Dox - // @has foo/bar/baz/index.html '//a/@href' '../../../src/foo/src-links.rs.html' + //@ has foo/bar/baz/index.html '//a/@href' '../../../src/foo/src-links.rs.html' pub mod baz { /// Dox - // @has foo/bar/baz/fn.baz.html '//a/@href' '../../../src/foo/src-links.rs.html' + //@ has foo/bar/baz/fn.baz.html '//a/@href' '../../../src/foo/src-links.rs.html' pub fn baz() { } } /// Dox - // @has foo/bar/trait.Foobar.html '//a/@href' '../../src/foo/src-links.rs.html' + //@ has foo/bar/trait.Foobar.html '//a/@href' '../../src/foo/src-links.rs.html' pub trait Foobar { fn dummy(&self) { } } - // @has foo/bar/struct.Foo.html '//a/@href' '../../src/foo/src-links.rs.html' + //@ has foo/bar/struct.Foo.html '//a/@href' '../../src/foo/src-links.rs.html' pub struct Foo { x: i32, y: u32 } - // @has foo/bar/fn.prawns.html '//a/@href' '../../src/foo/src-links.rs.html' + //@ has foo/bar/fn.prawns.html '//a/@href' '../../src/foo/src-links.rs.html' pub fn prawns((a, b): (i32, u32), Foo { x, y }: Foo) { } } /// Dox -// @has foo/fn.modfn.html '//a/@href' '../src/foo/src-links.rs.html' +//@ has foo/fn.modfn.html '//a/@href' '../src/foo/src-links.rs.html' pub fn modfn() { } // same hierarchy as above, but just for the submodule -// @has src/foo/src-links/mod.rs.html -// @has foo/qux/index.html '//a/@href' '../../src/foo/src-links/mod.rs.html' -// @has foo/qux/bar/index.html '//a/@href' '../../../src/foo/src-links/mod.rs.html' -// @has foo/qux/bar/baz/index.html '//a/@href' '../../../../src/foo/src-links/mod.rs.html' -// @has foo/qux/bar/baz/fn.baz.html '//a/@href' '../../../../src/foo/src-links/mod.rs.html' -// @has foo/qux/bar/trait.Foobar.html '//a/@href' '../../../src/foo/src-links/mod.rs.html' -// @has foo/qux/bar/struct.Foo.html '//a/@href' '../../../src/foo/src-links/mod.rs.html' -// @has foo/qux/bar/fn.prawns.html '//a/@href' '../../../src/foo/src-links/mod.rs.html' -// @has foo/qux/fn.modfn.html '//a/@href' '../../src/foo/src-links/mod.rs.html' +//@ has src/foo/src-links/mod.rs.html +//@ has foo/qux/index.html '//a/@href' '../../src/foo/src-links/mod.rs.html' +//@ has foo/qux/bar/index.html '//a/@href' '../../../src/foo/src-links/mod.rs.html' +//@ has foo/qux/bar/baz/index.html '//a/@href' '../../../../src/foo/src-links/mod.rs.html' +//@ has foo/qux/bar/baz/fn.baz.html '//a/@href' '../../../../src/foo/src-links/mod.rs.html' +//@ has foo/qux/bar/trait.Foobar.html '//a/@href' '../../../src/foo/src-links/mod.rs.html' +//@ has foo/qux/bar/struct.Foo.html '//a/@href' '../../../src/foo/src-links/mod.rs.html' +//@ has foo/qux/bar/fn.prawns.html '//a/@href' '../../../src/foo/src-links/mod.rs.html' +//@ has foo/qux/fn.modfn.html '//a/@href' '../../src/foo/src-links/mod.rs.html' diff --git a/tests/rustdoc/src-mod-path-absolute-26995.rs b/tests/rustdoc/src-mod-path-absolute-26995.rs index 47045503bb9..f754b64977f 100644 --- a/tests/rustdoc/src-mod-path-absolute-26995.rs +++ b/tests/rustdoc/src-mod-path-absolute-26995.rs @@ -4,7 +4,7 @@ // https://github.com/rust-lang/rust/issues/26995 #![crate_name="issue_26995"] -// @has src/issue_26995/dev/null.html -// @has issue_26995/null/index.html '//a/@href' '../../src/issue_26995/dev/null.html' +//@ has src/issue_26995/dev/null.html +//@ has issue_26995/null/index.html '//a/@href' '../../src/issue_26995/dev/null.html' #[path="/dev/null"] pub mod null; diff --git a/tests/rustdoc/stability.rs b/tests/rustdoc/stability.rs index c4d7118d07f..270da822c00 100644 --- a/tests/rustdoc/stability.rs +++ b/tests/rustdoc/stability.rs @@ -2,19 +2,19 @@ #![unstable(feature = "test", issue = "none")] -// @has stability/index.html -// @has - '//ul[@class="item-table"]/li[1]//a' AaStable -// @has - '//ul[@class="item-table"]/li[2]//a' ZzStable -// @has - '//ul[@class="item-table"]/li[3]//a' Unstable +//@ has stability/index.html +//@ has - '//ul[@class="item-table"]/li[1]//a' AaStable +//@ has - '//ul[@class="item-table"]/li[2]//a' ZzStable +//@ has - '//ul[@class="item-table"]/li[3]//a' Unstable #[stable(feature = "rust2", since = "2.2.2")] pub struct AaStable; pub struct Unstable { - // @has stability/struct.Unstable.html \ + //@ has stability/struct.Unstable.html \ // '//span[@class="item-info"]//div[@class="stab unstable"]' \ // 'This is a nightly-only experimental API' - // @count stability/struct.Unstable.html '//span[@class="stab unstable"]' 0 + //@ count stability/struct.Unstable.html '//span[@class="stab unstable"]' 0 pub foo: u32, pub bar: u32, } diff --git a/tests/rustdoc/staged-api-deprecated-unstable-32374.rs b/tests/rustdoc/staged-api-deprecated-unstable-32374.rs index d282dea907e..556b6fb61ac 100644 --- a/tests/rustdoc/staged-api-deprecated-unstable-32374.rs +++ b/tests/rustdoc/staged-api-deprecated-unstable-32374.rs @@ -4,29 +4,29 @@ #![unstable(feature = "test", issue = "32374")] #![crate_name="issue_32374"] -// @matches issue_32374/index.html '//*[@class="item-name"]/span[@class="stab deprecated"]' \ +//@ matches issue_32374/index.html '//*[@class="item-name"]/span[@class="stab deprecated"]' \ // 'Deprecated' -// @matches issue_32374/index.html '//*[@class="item-name"]/span[@class="stab unstable"]' \ +//@ matches issue_32374/index.html '//*[@class="item-name"]/span[@class="stab unstable"]' \ // 'Experimental' -// @matches issue_32374/index.html '//*[@class="desc docblock-short"]/text()' 'Docs' +//@ matches issue_32374/index.html '//*[@class="desc docblock-short"]/text()' 'Docs' -// @has issue_32374/struct.T.html '//*[@class="stab deprecated"]/span' '👎' -// @has issue_32374/struct.T.html '//*[@class="stab deprecated"]/span' \ +//@ has issue_32374/struct.T.html '//*[@class="stab deprecated"]/span' '👎' +//@ has issue_32374/struct.T.html '//*[@class="stab deprecated"]/span' \ // 'Deprecated since 1.0.0: text' -// @hasraw - '<code>test</code> <a href="https://issue_url/32374">#32374</a>' -// @matches issue_32374/struct.T.html '//*[@class="stab unstable"]' '🔬' -// @matches issue_32374/struct.T.html '//*[@class="stab unstable"]' \ +//@ hasraw - '<code>test</code> <a href="https://issue_url/32374">#32374</a>' +//@ matches issue_32374/struct.T.html '//*[@class="stab unstable"]' '🔬' +//@ matches issue_32374/struct.T.html '//*[@class="stab unstable"]' \ // 'This is a nightly-only experimental API. \(test\s#32374\)$' /// Docs #[deprecated(since = "1.0.0", note = "text")] #[unstable(feature = "test", issue = "32374")] pub struct T; -// @has issue_32374/struct.U.html '//*[@class="stab deprecated"]' '👎' -// @has issue_32374/struct.U.html '//*[@class="stab deprecated"]' \ +//@ has issue_32374/struct.U.html '//*[@class="stab deprecated"]' '👎' +//@ has issue_32374/struct.U.html '//*[@class="stab deprecated"]' \ // 'Deprecated since 1.0.0: deprecated' -// @has issue_32374/struct.U.html '//*[@class="stab unstable"]' '🔬' -// @has issue_32374/struct.U.html '//*[@class="stab unstable"]' \ +//@ has issue_32374/struct.U.html '//*[@class="stab unstable"]' '🔬' +//@ has issue_32374/struct.U.html '//*[@class="stab unstable"]' \ // 'This is a nightly-only experimental API. (test #32374)' #[deprecated(since = "1.0.0", note = "deprecated")] #[unstable(feature = "test", issue = "32374", reason = "unstable")] diff --git a/tests/rustdoc/staged-api-feature-issue-27759.rs b/tests/rustdoc/staged-api-feature-issue-27759.rs index 56a45a600da..32e5c495846 100644 --- a/tests/rustdoc/staged-api-feature-issue-27759.rs +++ b/tests/rustdoc/staged-api-feature-issue-27759.rs @@ -6,12 +6,12 @@ #![unstable(feature="test", issue="27759")] -// @has issue_27759/unstable/index.html -// @hasraw - '<code>test</code> <a href="http://issue_url/27759">#27759</a>' +//@ has issue_27759/unstable/index.html +//@ hasraw - '<code>test</code> <a href="http://issue_url/27759">#27759</a>' #[unstable(feature="test", issue="27759")] pub mod unstable { - // @has issue_27759/unstable/fn.issue.html - // @hasraw - '<code>test_function</code> <a href="http://issue_url/12345">#12345</a>' + //@ has issue_27759/unstable/fn.issue.html + //@ hasraw - '<code>test_function</code> <a href="http://issue_url/12345">#12345</a>' #[unstable(feature="test_function", issue="12345")] pub fn issue() {} } diff --git a/tests/rustdoc/static-root-path.rs b/tests/rustdoc/static-root-path.rs index e101d152fee..1bca4e40f44 100644 --- a/tests/rustdoc/static-root-path.rs +++ b/tests/rustdoc/static-root-path.rs @@ -1,18 +1,18 @@ //@ compile-flags:-Z unstable-options --static-root-path /cache/ -// @has static_root_path/struct.SomeStruct.html -// @matchesraw - '"/cache/main-' -// @!matchesraw - '"\.\./main' -// @matchesraw - 'data-root-path="\.\./"' -// @!matchesraw - '"/cache/search-index\.js"' +//@ has static_root_path/struct.SomeStruct.html +//@ matchesraw - '"/cache/main-' +//@ !matchesraw - '"\.\./main' +//@ matchesraw - 'data-root-path="\.\./"' +//@ !matchesraw - '"/cache/search-index\.js"' pub struct SomeStruct; -// @has src/static_root_path/static-root-path.rs.html -// @matchesraw - '"/cache/src-script-' -// @!matchesraw - '"\.\./\.\./src-script' -// @matchesraw - '"\.\./\.\./src-files.js"' -// @!matchesraw - '"/cache/src-files\.js"' +//@ has src/static_root_path/static-root-path.rs.html +//@ matchesraw - '"/cache/src-script-' +//@ !matchesraw - '"\.\./\.\./src-script' +//@ matchesraw - '"\.\./\.\./src-files.js"' +//@ !matchesraw - '"/cache/src-files\.js"' -// @has settings.html -// @matchesraw - '/cache/settings-' -// @!matchesraw - '\../settings' +//@ has settings.html +//@ matchesraw - '/cache/settings-' +//@ !matchesraw - '\../settings' diff --git a/tests/rustdoc/static.rs b/tests/rustdoc/static.rs index d127f0c5829..b777aa945ff 100644 --- a/tests/rustdoc/static.rs +++ b/tests/rustdoc/static.rs @@ -2,11 +2,11 @@ #![crate_type = "lib"] -// @has static/static.FOO.html '//pre' 'static FOO: usize' +//@ has static/static.FOO.html '//pre' 'static FOO: usize' static FOO: usize = 1; -// @has static/static.BAR.html '//pre' 'pub static BAR: usize' +//@ has static/static.BAR.html '//pre' 'pub static BAR: usize' pub static BAR: usize = 1; -// @has static/static.BAZ.html '//pre' 'pub static mut BAZ: usize' +//@ has static/static.BAZ.html '//pre' 'pub static mut BAZ: usize' pub static mut BAZ: usize = 1; diff --git a/tests/rustdoc/strip-block-doc-comments-stars.rs b/tests/rustdoc/strip-block-doc-comments-stars.rs index ca4c93f92e0..329e760b43e 100644 --- a/tests/rustdoc/strip-block-doc-comments-stars.rs +++ b/tests/rustdoc/strip-block-doc-comments-stars.rs @@ -3,8 +3,8 @@ // The goal of this test is to ensure that it won't be generated as a list because // block doc comments can have their lines starting with a star. -// @has foo/fn.foo.html -// @snapshot docblock - '//*[@class="toggle top-doc"]//*[@class="docblock"]' +//@ has foo/fn.foo.html +//@ snapshot docblock - '//*[@class="toggle top-doc"]//*[@class="docblock"]' /** * a */ diff --git a/tests/rustdoc/strip-enum-variant.rs b/tests/rustdoc/strip-enum-variant.rs index 2512fa34b39..9874588ef59 100644 --- a/tests/rustdoc/strip-enum-variant.rs +++ b/tests/rustdoc/strip-enum-variant.rs @@ -1,9 +1,9 @@ -// @has strip_enum_variant/enum.MyThing.html -// @has - '//code' 'Shown' -// @!has - '//code' 'NotShown' -// @has - '//code' '// some variants omitted' +//@ has strip_enum_variant/enum.MyThing.html +//@ has - '//code' 'Shown' +//@ !has - '//code' 'NotShown' +//@ has - '//code' '// some variants omitted' // Also check that `NotShown` isn't displayed in the sidebar. -// @snapshot no-not-shown - '//*[@class="sidebar-elems"]/section/*[@class="block variant"]' +//@ snapshot no-not-shown - '//*[@class="sidebar-elems"]/section/*[@class="block variant"]' pub enum MyThing { Shown, #[doc(hidden)] diff --git a/tests/rustdoc/strip-priv-imports-pass-27104.rs b/tests/rustdoc/strip-priv-imports-pass-27104.rs index b7198e82a03..ad6b66dbc81 100644 --- a/tests/rustdoc/strip-priv-imports-pass-27104.rs +++ b/tests/rustdoc/strip-priv-imports-pass-27104.rs @@ -5,9 +5,9 @@ // https://github.com/rust-lang/rust/issues/27104 #![crate_name="issue_27104"] -// @has issue_27104/index.html -// @!hasraw - 'extern crate std' -// @!hasraw - 'use std::prelude::' +//@ has issue_27104/index.html +//@ !hasraw - 'extern crate std' +//@ !hasraw - 'use std::prelude::' -// @hasraw - 'pub extern crate empty' +//@ hasraw - 'pub extern crate empty' pub extern crate empty; diff --git a/tests/rustdoc/struct-arg-pattern.rs b/tests/rustdoc/struct-arg-pattern.rs index 6f06c8c9c49..af94089bf1a 100644 --- a/tests/rustdoc/struct-arg-pattern.rs +++ b/tests/rustdoc/struct-arg-pattern.rs @@ -4,7 +4,7 @@ struct BodyId { hir_id: usize, } -// @has 'foo/fn.body_owner.html' '//pre[@class="rust item-decl"]' 'pub fn body_owner(_: BodyId)' +//@ has 'foo/fn.body_owner.html' '//pre[@class="rust item-decl"]' 'pub fn body_owner(_: BodyId)' pub fn body_owner(BodyId { hir_id }: BodyId) { // ... } diff --git a/tests/rustdoc/struct-field.rs b/tests/rustdoc/struct-field.rs index 998683bdde7..c04fcb344a1 100644 --- a/tests/rustdoc/struct-field.rs +++ b/tests/rustdoc/struct-field.rs @@ -1,9 +1,9 @@ #![crate_name = "foo"] -// @has foo/index.html '//*[@class="docblock"]/p/a[@href="struct.Foo.html#structfield.bar"]' 'Foo::bar' -// @has foo/index.html '//*[@class="docblock"]/p/a[@href="union.Bar.html#structfield.foo"]' 'Bar::foo' -// @has foo/index.html '//*[@class="docblock"]/p/a[@href="enum.Uniooon.html#variant.X"]' 'Uniooon::X' +//@ has foo/index.html '//*[@class="docblock"]/p/a[@href="struct.Foo.html#structfield.bar"]' 'Foo::bar' +//@ has foo/index.html '//*[@class="docblock"]/p/a[@href="union.Bar.html#structfield.foo"]' 'Bar::foo' +//@ has foo/index.html '//*[@class="docblock"]/p/a[@href="enum.Uniooon.html#variant.X"]' 'Uniooon::X' //! Test with [Foo::bar], [Bar::foo], [Uniooon::X] diff --git a/tests/rustdoc/struct-implementations-title.rs b/tests/rustdoc/struct-implementations-title.rs index 5468796f669..ca5b5c0ee20 100644 --- a/tests/rustdoc/struct-implementations-title.rs +++ b/tests/rustdoc/struct-implementations-title.rs @@ -2,8 +2,8 @@ pub struct Struc; -// @has foo/struct.Struc.html -// @has - '//*[@id="main-content"]/h2[@id="implementations"]' "Implementations" +//@ has foo/struct.Struc.html +//@ has - '//*[@id="main-content"]/h2[@id="implementations"]' "Implementations" impl Struc { pub const S: u64 = 0; } diff --git a/tests/rustdoc/structfields.rs b/tests/rustdoc/structfields.rs index 7e1cada4b98..b7644f3bb59 100644 --- a/tests/rustdoc/structfields.rs +++ b/tests/rustdoc/structfields.rs @@ -1,44 +1,44 @@ -// @has structfields/struct.Foo.html +//@ has structfields/struct.Foo.html pub struct Foo { - // @has - //pre "pub a: ()" + //@ has - //pre "pub a: ()" pub a: (), - // @has - //pre "/* private fields */" - // @!has - //pre "b: ()" + //@ has - //pre "/* private fields */" + //@ !has - //pre "b: ()" b: (), - // @!has - //pre "c: usize" + //@ !has - //pre "c: usize" #[doc(hidden)] c: usize, - // @has - //pre "pub d: usize" + //@ has - //pre "pub d: usize" pub d: usize, } -// @has structfields/struct.Bar.html +//@ has structfields/struct.Bar.html pub struct Bar { - // @has - //pre "pub a: ()" + //@ has - //pre "pub a: ()" pub a: (), - // @!has - //pre "/* private fields */" + //@ !has - //pre "/* private fields */" } -// @has structfields/enum.Qux.html +//@ has structfields/enum.Qux.html pub enum Qux { Quz { - // @has - //pre "a: ()" + //@ has - //pre "a: ()" a: (), - // @!has - //pre "b: ()" + //@ !has - //pre "b: ()" #[doc(hidden)] b: (), - // @has - //pre "c: usize" + //@ has - //pre "c: usize" c: usize, - // @has - //pre "/* private fields */" + //@ has - //pre "/* private fields */" }, } -// @has structfields/struct.Baz.html //pre "pub struct Baz { /* private fields */ }" +//@ has structfields/struct.Baz.html //pre "pub struct Baz { /* private fields */ }" pub struct Baz { x: u8, #[doc(hidden)] pub y: u8, } -// @has structfields/struct.Quux.html //pre "pub struct Quux {}" +//@ has structfields/struct.Quux.html //pre "pub struct Quux {}" pub struct Quux {} diff --git a/tests/rustdoc/summary-codeblock-31899.rs b/tests/rustdoc/summary-codeblock-31899.rs index c1b33058c9e..9cbf6492610 100644 --- a/tests/rustdoc/summary-codeblock-31899.rs +++ b/tests/rustdoc/summary-codeblock-31899.rs @@ -1,11 +1,11 @@ // https://github.com/rust-lang/rust/issues/31899 #![crate_name="issue_31899"] -// @has issue_31899/index.html -// @hasraw - 'Make this line a bit longer.' -// @!hasraw - 'rust rust-example-rendered' -// @!hasraw - 'use ndarray::arr2' -// @!hasraw - 'prohibited' +//@ has issue_31899/index.html +//@ hasraw - 'Make this line a bit longer.' +//@ !hasraw - 'rust rust-example-rendered' +//@ !hasraw - 'use ndarray::arr2' +//@ !hasraw - 'prohibited' /// A tuple or fixed size array that can be used to index an array. /// Make this line a bit longer. diff --git a/tests/rustdoc/summary-header-46377.rs b/tests/rustdoc/summary-header-46377.rs index aec74f493d4..11445f0dad6 100644 --- a/tests/rustdoc/summary-header-46377.rs +++ b/tests/rustdoc/summary-header-46377.rs @@ -1,6 +1,6 @@ // https://github.com/rust-lang/rust/issues/46377 #![crate_name="foo"] -// @has 'foo/index.html' '//*[@class="desc docblock-short"]' 'Check out this struct!' +//@ has 'foo/index.html' '//*[@class="desc docblock-short"]' 'Check out this struct!' /// # Check out this struct! pub struct SomeStruct; diff --git a/tests/rustdoc/summary-reference-link-30366.rs b/tests/rustdoc/summary-reference-link-30366.rs index 5b9854c5390..b406946ccfb 100644 --- a/tests/rustdoc/summary-reference-link-30366.rs +++ b/tests/rustdoc/summary-reference-link-30366.rs @@ -1,4 +1,4 @@ -// @has issue_30366/index.html '//a/@href' 'http://www.rust-lang.org/' +//@ has issue_30366/index.html '//a/@href' 'http://www.rust-lang.org/' // https://github.com/rust-lang/rust/issues/30366 #![crate_name="issue_30366"] diff --git a/tests/rustdoc/synthetic_auto/auto-trait-lifetimes-56822.rs b/tests/rustdoc/synthetic_auto/auto-trait-lifetimes-56822.rs index 315b20ddd70..4ed1b6c5913 100644 --- a/tests/rustdoc/synthetic_auto/auto-trait-lifetimes-56822.rs +++ b/tests/rustdoc/synthetic_auto/auto-trait-lifetimes-56822.rs @@ -19,8 +19,8 @@ impl<'a, T> MyTrait for Inner<'a, T> { type Output = &'a T; } -// @has foo/struct.Parser.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has foo/struct.Parser.html +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<'a> Send for Parser<'a>" pub struct Parser<'a> { field: <Wrapper<Inner<'a, u8>> as MyTrait>::Output diff --git a/tests/rustdoc/synthetic_auto/basic.rs b/tests/rustdoc/synthetic_auto/basic.rs index 16b8cce490c..9daf8963997 100644 --- a/tests/rustdoc/synthetic_auto/basic.rs +++ b/tests/rustdoc/synthetic_auto/basic.rs @@ -1,8 +1,8 @@ -// @has basic/struct.Foo.html -// @has - '//h3[@class="code-header"]' 'impl<T> Send for Foo<T>where T: Send' -// @has - '//h3[@class="code-header"]' 'impl<T> Sync for Foo<T>where T: Sync' -// @count - '//*[@id="implementations-list"]//*[@class="impl"]' 0 -// @count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 6 +//@ has basic/struct.Foo.html +//@ has - '//h3[@class="code-header"]' 'impl<T> Send for Foo<T>where T: Send' +//@ has - '//h3[@class="code-header"]' 'impl<T> Sync for Foo<T>where T: Sync' +//@ count - '//*[@id="implementations-list"]//*[@class="impl"]' 0 +//@ count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 6 pub struct Foo<T> { field: T, } diff --git a/tests/rustdoc/synthetic_auto/bounds.rs b/tests/rustdoc/synthetic_auto/bounds.rs index 17528d01c8d..e93639acd07 100644 --- a/tests/rustdoc/synthetic_auto/bounds.rs +++ b/tests/rustdoc/synthetic_auto/bounds.rs @@ -1,8 +1,8 @@ pub struct Outer<T>(Inner<T>); pub struct Inner<T>(T); -// @has bounds/struct.Outer.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has bounds/struct.Outer.html +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<T> Unpin for Outer<T>where \ // T: for<'any> Trait<A = (), B<'any> = (), X = ()>," diff --git a/tests/rustdoc/synthetic_auto/complex.rs b/tests/rustdoc/synthetic_auto/complex.rs index 2722f6d338f..51303658890 100644 --- a/tests/rustdoc/synthetic_auto/complex.rs +++ b/tests/rustdoc/synthetic_auto/complex.rs @@ -19,8 +19,8 @@ mod foo { } } -// @has complex/struct.NotOuter.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has complex/struct.NotOuter.html +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<'a, T, K> Send for Outer<'a, T, K>where 'a: 'static, T: MyTrait<'a>, \ // K: for<'b> Fn((&'b bool, &'a u8)) -> &'b i8 + ?Sized, <T as MyTrait<'a>>::MyItem: Copy," diff --git a/tests/rustdoc/synthetic_auto/crate-local.rs b/tests/rustdoc/synthetic_auto/crate-local.rs index ed01f63f998..b3bd67f839c 100644 --- a/tests/rustdoc/synthetic_auto/crate-local.rs +++ b/tests/rustdoc/synthetic_auto/crate-local.rs @@ -2,8 +2,8 @@ pub auto trait Banana {} -// @has crate_local/struct.Peach.html -// @has - '//h3[@class="code-header"]' 'impl Banana for Peach' -// @has - '//h3[@class="code-header"]' 'impl Send for Peach' -// @has - '//h3[@class="code-header"]' 'impl Sync for Peach' +//@ has crate_local/struct.Peach.html +//@ has - '//h3[@class="code-header"]' 'impl Banana for Peach' +//@ has - '//h3[@class="code-header"]' 'impl Send for Peach' +//@ has - '//h3[@class="code-header"]' 'impl Sync for Peach' pub struct Peach; diff --git a/tests/rustdoc/synthetic_auto/lifetimes.rs b/tests/rustdoc/synthetic_auto/lifetimes.rs index 23e1efdaeef..c47bd8f065c 100644 --- a/tests/rustdoc/synthetic_auto/lifetimes.rs +++ b/tests/rustdoc/synthetic_auto/lifetimes.rs @@ -8,11 +8,11 @@ where T: for<'b> Fn(&'b bool) -> &'a u8, {} -// @has lifetimes/struct.Foo.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has lifetimes/struct.Foo.html +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<'c, K> Send for Foo<'c, K>where 'c: 'static, K: for<'b> Fn(&'b bool) -> &'c u8," // -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<'c, K> Sync for Foo<'c, K>where K: Sync" pub struct Foo<'c, K: 'c> { inner_field: Inner<'c, K>, diff --git a/tests/rustdoc/synthetic_auto/manual.rs b/tests/rustdoc/synthetic_auto/manual.rs index 692d68294a7..bbf361a6e59 100644 --- a/tests/rustdoc/synthetic_auto/manual.rs +++ b/tests/rustdoc/synthetic_auto/manual.rs @@ -1,12 +1,12 @@ -// @has manual/struct.Foo.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has manual/struct.Foo.html +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // 'impl<T> Sync for Foo<T>where T: Sync' // -// @has - '//*[@id="trait-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has - '//*[@id="trait-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // 'impl<T> Send for Foo<T>' // -// @count - '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1 -// @count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 5 +//@ count - '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1 +//@ count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 5 pub struct Foo<T> { field: T, } diff --git a/tests/rustdoc/synthetic_auto/negative.rs b/tests/rustdoc/synthetic_auto/negative.rs index 97da2d57424..a2fe6187e8e 100644 --- a/tests/rustdoc/synthetic_auto/negative.rs +++ b/tests/rustdoc/synthetic_auto/negative.rs @@ -2,11 +2,11 @@ pub struct Inner<T: Copy> { field: *mut T, } -// @has negative/struct.Outer.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has negative/struct.Outer.html +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<T> !Send for Outer<T>" // -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<T> !Sync for Outer<T>" pub struct Outer<T: Copy> { inner_field: Inner<T>, diff --git a/tests/rustdoc/synthetic_auto/nested.rs b/tests/rustdoc/synthetic_auto/nested.rs index e4aead71bf2..edd7ca64698 100644 --- a/tests/rustdoc/synthetic_auto/nested.rs +++ b/tests/rustdoc/synthetic_auto/nested.rs @@ -8,11 +8,11 @@ where { } -// @has nested/struct.Foo.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has nested/struct.Foo.html +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // 'impl<T> Send for Foo<T>where T: Copy' // -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // 'impl<T> Sync for Foo<T>where T: Sync' pub struct Foo<T> { inner_field: Inner<T>, diff --git a/tests/rustdoc/synthetic_auto/no-redundancy.rs b/tests/rustdoc/synthetic_auto/no-redundancy.rs index 64dab429647..7260107d861 100644 --- a/tests/rustdoc/synthetic_auto/no-redundancy.rs +++ b/tests/rustdoc/synthetic_auto/no-redundancy.rs @@ -8,8 +8,8 @@ where { } -// @has no_redundancy/struct.Outer.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has no_redundancy/struct.Outer.html +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<T> Send for Outer<T>where T: Copy + Send" pub struct Outer<T> { inner_field: Inner<T>, diff --git a/tests/rustdoc/synthetic_auto/normalize-auto-trait-80233.rs b/tests/rustdoc/synthetic_auto/normalize-auto-trait-80233.rs index 06498018630..2552bca87d2 100644 --- a/tests/rustdoc/synthetic_auto/normalize-auto-trait-80233.rs +++ b/tests/rustdoc/synthetic_auto/normalize-auto-trait-80233.rs @@ -32,8 +32,8 @@ impl<T: Trait3> Trait3 for Vec<T> { pub struct Struct1 {} -// @has foo/struct.Question.html -// @has - '//h3[@class="code-header"]' 'impl<T> Send for Question<T>' +//@ has foo/struct.Question.html +//@ has - '//h3[@class="code-header"]' 'impl<T> Send for Question<T>' pub struct Question<T: Trait1> { pub ins: <<Vec<T> as Trait3>::Type3 as Trait2>::Type2, } diff --git a/tests/rustdoc/synthetic_auto/overflow.rs b/tests/rustdoc/synthetic_auto/overflow.rs index 35a487c764d..634217cfcdd 100644 --- a/tests/rustdoc/synthetic_auto/overflow.rs +++ b/tests/rustdoc/synthetic_auto/overflow.rs @@ -20,8 +20,8 @@ enum TyData<I: Interner> { struct VariableKind<I: Interner>(I::InternedType); -// @has overflow/struct.BoundVarsCollector.html -// @has - '//h3[@class="code-header"]' "impl<'tcx> Send for BoundVarsCollector<'tcx>" +//@ has overflow/struct.BoundVarsCollector.html +//@ has - '//h3[@class="code-header"]' "impl<'tcx> Send for BoundVarsCollector<'tcx>" pub struct BoundVarsCollector<'tcx> { val: VariableKind<RustInterner<'tcx>> } diff --git a/tests/rustdoc/synthetic_auto/project.rs b/tests/rustdoc/synthetic_auto/project.rs index f4ede76e6de..10046bff913 100644 --- a/tests/rustdoc/synthetic_auto/project.rs +++ b/tests/rustdoc/synthetic_auto/project.rs @@ -22,11 +22,11 @@ where { } -// @has project/struct.Foo.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has project/struct.Foo.html +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<'c, K> Send for Foo<'c, K>where 'c: 'static, K: MyTrait<MyItem = bool>," // -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<'c, K> Sync for Foo<'c, K>where 'c: 'static, K: MyTrait, \ // <K as MyTrait>::MyItem: OtherTrait," pub struct Foo<'c, K: 'c> { diff --git a/tests/rustdoc/synthetic_auto/self-referential.rs b/tests/rustdoc/synthetic_auto/self-referential.rs index 145a2b7e00c..f6c7daeec8d 100644 --- a/tests/rustdoc/synthetic_auto/self-referential.rs +++ b/tests/rustdoc/synthetic_auto/self-referential.rs @@ -22,8 +22,8 @@ impl<T> Pattern for Wrapper<T> { } -// @has self_referential/struct.WriteAndThen.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has self_referential/struct.WriteAndThen.html +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<P1> Send for WriteAndThen<P1>where <P1 as Pattern>::Value: Send" pub struct WriteAndThen<P1>(pub P1::Value,pub <Constrain<P1, Wrapper<P1::Value>> as Pattern>::Value) where P1: Pattern; diff --git a/tests/rustdoc/synthetic_auto/send-impl-conditional-60726.rs b/tests/rustdoc/synthetic_auto/send-impl-conditional-60726.rs index ea10aee58e4..9937628cabe 100644 --- a/tests/rustdoc/synthetic_auto/send-impl-conditional-60726.rs +++ b/tests/rustdoc/synthetic_auto/send-impl-conditional-60726.rs @@ -28,10 +28,10 @@ where I:InterfaceType<Send=True> {} -// @has foo/struct.IntoIter.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has foo/struct.IntoIter.html +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<T> !Send for IntoIter<T>" -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<T> !Sync for IntoIter<T>" pub struct IntoIter<T>{ hello:DynTrait<FooInterface<T>>, diff --git a/tests/rustdoc/synthetic_auto/static-region.rs b/tests/rustdoc/synthetic_auto/static-region.rs index 9dc6211ec20..0b7d048765b 100644 --- a/tests/rustdoc/synthetic_auto/static-region.rs +++ b/tests/rustdoc/synthetic_auto/static-region.rs @@ -2,8 +2,8 @@ pub trait OwnedTrait<'a> { type Reader; } -// @has static_region/struct.Owned.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has static_region/struct.Owned.html +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<T> Send for Owned<T>where <T as OwnedTrait<'static>>::Reader: Send" pub struct Owned<T> where T: OwnedTrait<'static> { marker: <T as OwnedTrait<'static>>::Reader, diff --git a/tests/rustdoc/synthetic_auto/supertrait-bounds.rs b/tests/rustdoc/synthetic_auto/supertrait-bounds.rs index 503e65d0f4f..d96d16786e8 100644 --- a/tests/rustdoc/synthetic_auto/supertrait-bounds.rs +++ b/tests/rustdoc/synthetic_auto/supertrait-bounds.rs @@ -7,8 +7,8 @@ pub struct Type<T: Bound>(T); -// @has supertrait_bounds/struct.Type.html -// @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has supertrait_bounds/struct.Type.html +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<T> Send for Type<T>where T: Send," pub trait Bound: Copy + 'static {} diff --git a/tests/rustdoc/tab_title.rs b/tests/rustdoc/tab_title.rs index 8d781b40e46..59914065c91 100644 --- a/tests/rustdoc/tab_title.rs +++ b/tests/rustdoc/tab_title.rs @@ -4,42 +4,42 @@ // tests for the html <title> element -// @has foo/index.html '//head/title' 'foo - Rust' +//@ has foo/index.html '//head/title' 'foo - Rust' -// @has foo/fn.widget_count.html '//head/title' 'widget_count in foo - Rust' +//@ has foo/fn.widget_count.html '//head/title' 'widget_count in foo - Rust' /// blah pub fn widget_count() {} -// @has foo/struct.Widget.html '//head/title' 'Widget in foo - Rust' +//@ has foo/struct.Widget.html '//head/title' 'Widget in foo - Rust' pub struct Widget; -// @has foo/constant.ANSWER.html '//head/title' 'ANSWER in foo - Rust' +//@ has foo/constant.ANSWER.html '//head/title' 'ANSWER in foo - Rust' pub const ANSWER: u8 = 42; -// @has foo/blah/index.html '//head/title' 'foo::blah - Rust' +//@ has foo/blah/index.html '//head/title' 'foo::blah - Rust' pub mod blah { - // @has foo/blah/struct.Widget.html '//head/title' 'Widget in foo::blah - Rust' + //@ has foo/blah/struct.Widget.html '//head/title' 'Widget in foo::blah - Rust' pub struct Widget; - // @has foo/blah/trait.Awesome.html '//head/title' 'Awesome in foo::blah - Rust' + //@ has foo/blah/trait.Awesome.html '//head/title' 'Awesome in foo::blah - Rust' pub trait Awesome {} - // @has foo/blah/fn.make_widget.html '//head/title' 'make_widget in foo::blah - Rust' + //@ has foo/blah/fn.make_widget.html '//head/title' 'make_widget in foo::blah - Rust' pub fn make_widget() {} - // @has foo/macro.cool_macro.html '//head/title' 'cool_macro in foo - Rust' + //@ has foo/macro.cool_macro.html '//head/title' 'cool_macro in foo - Rust' #[macro_export] macro_rules! cool_macro { ($t:tt) => { $t } } } -// @has foo/keyword.continue.html '//head/title' 'continue - Rust' +//@ has foo/keyword.continue.html '//head/title' 'continue - Rust' #[doc(keyword = "continue")] mod continue_keyword {} -// @has foo/primitive.u8.html '//head/title' 'u8 - Rust' -// @!has - '//head/title' 'foo' +//@ has foo/primitive.u8.html '//head/title' 'u8 - Rust' +//@ !has - '//head/title' 'foo' #[rustc_doc_primitive = "u8"] /// `u8` docs mod u8 {} diff --git a/tests/rustdoc/table-in-docblock.rs b/tests/rustdoc/table-in-docblock.rs index 194f49f16d0..af376438ce6 100644 --- a/tests/rustdoc/table-in-docblock.rs +++ b/tests/rustdoc/table-in-docblock.rs @@ -1,8 +1,8 @@ #![crate_name = "foo"] -// @has foo/struct.Foo.html -// @count - '//*[@class="docblock"]/div/table' 2 -// @!has - '//*[@class="docblock"]/table' '' +//@ has foo/struct.Foo.html +//@ count - '//*[@class="docblock"]/div/table' 2 +//@ !has - '//*[@class="docblock"]/table' '' /// | hello | hello2 | /// | ----- | ------ | /// | data | data2 | diff --git a/tests/rustdoc/task-lists.rs b/tests/rustdoc/task-lists.rs index c2e7dd60f22..f32bac89a65 100644 --- a/tests/rustdoc/task-lists.rs +++ b/tests/rustdoc/task-lists.rs @@ -4,10 +4,10 @@ // has task_lists/index.html '//li/input[@type="checkbox"]/following-sibling::text()' 'b' // Unfortunately that requires LXML, because the built-in xml module doesn't support all of xpath. -// @has task_lists/index.html '//ul/li/input[@type="checkbox"]' '' -// @has task_lists/index.html '//ul/li/input[@disabled]' '' -// @has task_lists/index.html '//ul/li' 'a' -// @has task_lists/index.html '//ul/li' 'b' +//@ has task_lists/index.html '//ul/li/input[@type="checkbox"]' '' +//@ has task_lists/index.html '//ul/li/input[@disabled]' '' +//@ has task_lists/index.html '//ul/li' 'a' +//@ has task_lists/index.html '//ul/li' 'b' //! This tests 'task list' support, a common markdown extension. //! - [ ] a //! - [x] b diff --git a/tests/rustdoc/test-lists.rs b/tests/rustdoc/test-lists.rs index 6a510b9ac5d..661f8f4d6fb 100644 --- a/tests/rustdoc/test-lists.rs +++ b/tests/rustdoc/test-lists.rs @@ -1,21 +1,21 @@ #![crate_name = "foo"] -// @has foo/fn.f.html -// @has - //ol/li "list" -// @has - //ol/li/ol/li "fooooo" -// @has - //ol/li/ol/li "x" -// @has - //ol/li "foo" +//@ has foo/fn.f.html +//@ has - //ol/li "list" +//@ has - //ol/li/ol/li "fooooo" +//@ has - //ol/li/ol/li "x" +//@ has - //ol/li "foo" /// 1. list /// 1. fooooo /// 2. x /// 2. foo pub fn f() {} -// @has foo/fn.foo2.html -// @has - //ul/li "normal list" -// @has - //ul/li/ul/li "sub list" -// @has - //ul/li/ul/li "new elem still same elem and again same elem!" -// @has - //ul/li "new big elem" +//@ has foo/fn.foo2.html +//@ has - //ul/li "normal list" +//@ has - //ul/li/ul/li "sub list" +//@ has - //ul/li/ul/li "new elem still same elem and again same elem!" +//@ has - //ul/li "new big elem" /// * normal list /// * sub list /// * new elem diff --git a/tests/rustdoc/test-parens.rs b/tests/rustdoc/test-parens.rs index 9640b96b6b5..4f362740e6f 100644 --- a/tests/rustdoc/test-parens.rs +++ b/tests/rustdoc/test-parens.rs @@ -1,5 +1,5 @@ #![crate_name = "foo"] -// @has foo/fn.foo.html -// @has - '//pre[@class="rust item-decl"]' "_: &(dyn ToString + 'static)" +//@ has foo/fn.foo.html +//@ has - '//pre[@class="rust item-decl"]' "_: &(dyn ToString + 'static)" pub fn foo(_: &(ToString + 'static)) {} diff --git a/tests/rustdoc/test-strikethrough.rs b/tests/rustdoc/test-strikethrough.rs index 58162153b9e..6b9742e2a2f 100644 --- a/tests/rustdoc/test-strikethrough.rs +++ b/tests/rustdoc/test-strikethrough.rs @@ -3,11 +3,11 @@ // Test that strikethrough works with single and double tildes and that it shows up on // the item's dedicated page as well as the parent module's summary of items. -// @has foo/index.html //del 'strike' -// @has foo/index.html //del 'through' +//@ has foo/index.html //del 'strike' +//@ has foo/index.html //del 'through' -// @has foo/fn.f.html //del 'strike' -// @has foo/fn.f.html //del 'through' +//@ has foo/fn.f.html //del 'strike' +//@ has foo/fn.f.html //del 'through' /// ~~strike~~ ~through~ pub fn f() {} diff --git a/tests/rustdoc/thread-local-src.rs b/tests/rustdoc/thread-local-src.rs index 6de35e3233b..b23a9a48654 100644 --- a/tests/rustdoc/thread-local-src.rs +++ b/tests/rustdoc/thread-local-src.rs @@ -1,6 +1,6 @@ #![crate_name = "foo"] -// @has foo/index.html '//a[@href="../src/foo/thread-local-src.rs.html#1-6"]' 'source' +//@ has foo/index.html '//a[@href="../src/foo/thread-local-src.rs.html#1-6"]' 'source' -// @has foo/constant.FOO.html '//a[@href="../src/foo/thread-local-src.rs.html#6"]' 'source' +//@ has foo/constant.FOO.html '//a[@href="../src/foo/thread-local-src.rs.html#6"]' 'source' thread_local!(pub static FOO: bool = false); diff --git a/tests/rustdoc/titles.rs b/tests/rustdoc/titles.rs index f9da5a81375..bdf950b0a62 100644 --- a/tests/rustdoc/titles.rs +++ b/tests/rustdoc/titles.rs @@ -1,57 +1,57 @@ #![crate_name = "foo"] #![feature(rustc_attrs)] -// @matches 'foo/index.html' '//h1' 'Crate foo' -// @matches 'foo/index.html' '//div[@class="sidebar-crate"]/h2/a' 'foo' -// @count 'foo/index.html' '//h2[@class="location"]' 0 +//@ matches 'foo/index.html' '//h1' 'Crate foo' +//@ matches 'foo/index.html' '//div[@class="sidebar-crate"]/h2/a' 'foo' +//@ count 'foo/index.html' '//h2[@class="location"]' 0 -// @matches 'foo/foo_mod/index.html' '//h1' 'Module foo::foo_mod' -// @matches 'foo/foo_mod/index.html' '//h2[@class="location"]' 'Module foo_mod' +//@ matches 'foo/foo_mod/index.html' '//h1' 'Module foo::foo_mod' +//@ matches 'foo/foo_mod/index.html' '//h2[@class="location"]' 'Module foo_mod' pub mod foo_mod { pub struct __Thing {} } extern "C" { - // @matches 'foo/fn.foo_ffn.html' '//h1' 'Function foo::foo_ffn' + //@ matches 'foo/fn.foo_ffn.html' '//h1' 'Function foo::foo_ffn' pub fn foo_ffn(); } -// @matches 'foo/fn.foo_fn.html' '//h1' 'Function foo::foo_fn' +//@ matches 'foo/fn.foo_fn.html' '//h1' 'Function foo::foo_fn' pub fn foo_fn() {} -// @matches 'foo/trait.FooTrait.html' '//h1' 'Trait foo::FooTrait' -// @matches 'foo/trait.FooTrait.html' '//h2[@class="location"]' 'FooTrait' +//@ matches 'foo/trait.FooTrait.html' '//h1' 'Trait foo::FooTrait' +//@ matches 'foo/trait.FooTrait.html' '//h2[@class="location"]' 'FooTrait' pub trait FooTrait {} -// @matches 'foo/struct.FooStruct.html' '//h1' 'Struct foo::FooStruct' -// @matches 'foo/struct.FooStruct.html' '//h2[@class="location"]' 'FooStruct' +//@ matches 'foo/struct.FooStruct.html' '//h1' 'Struct foo::FooStruct' +//@ matches 'foo/struct.FooStruct.html' '//h2[@class="location"]' 'FooStruct' pub struct FooStruct; -// @matches 'foo/enum.FooEnum.html' '//h1' 'Enum foo::FooEnum' -// @matches 'foo/enum.FooEnum.html' '//h2[@class="location"]' 'FooEnum' +//@ matches 'foo/enum.FooEnum.html' '//h1' 'Enum foo::FooEnum' +//@ matches 'foo/enum.FooEnum.html' '//h2[@class="location"]' 'FooEnum' pub enum FooEnum {} -// @matches 'foo/type.FooType.html' '//h1' 'Type Alias foo::FooType' -// @matches 'foo/type.FooType.html' '//h2[@class="location"]' 'FooType' +//@ matches 'foo/type.FooType.html' '//h1' 'Type Alias foo::FooType' +//@ matches 'foo/type.FooType.html' '//h2[@class="location"]' 'FooType' pub type FooType = FooStruct; -// @matches 'foo/macro.foo_macro.html' '//h1' 'Macro foo::foo_macro' +//@ matches 'foo/macro.foo_macro.html' '//h1' 'Macro foo::foo_macro' #[macro_export] macro_rules! foo_macro { () => {}; } -// @matches 'foo/primitive.bool.html' '//h1' 'Primitive Type bool' +//@ matches 'foo/primitive.bool.html' '//h1' 'Primitive Type bool' #[rustc_doc_primitive = "bool"] mod bool {} -// @matches 'foo/static.FOO_STATIC.html' '//h1' 'Static foo::FOO_STATIC' +//@ matches 'foo/static.FOO_STATIC.html' '//h1' 'Static foo::FOO_STATIC' pub static FOO_STATIC: FooStruct = FooStruct; extern "C" { - // @matches 'foo/static.FOO_FSTATIC.html' '//h1' 'Static foo::FOO_FSTATIC' + //@ matches 'foo/static.FOO_FSTATIC.html' '//h1' 'Static foo::FOO_FSTATIC' pub static FOO_FSTATIC: FooStruct; } -// @matches 'foo/constant.FOO_CONSTANT.html' '//h1' 'Constant foo::FOO_CONSTANT' +//@ matches 'foo/constant.FOO_CONSTANT.html' '//h1' 'Constant foo::FOO_CONSTANT' pub const FOO_CONSTANT: FooStruct = FooStruct; diff --git a/tests/rustdoc/toggle-item-contents.rs b/tests/rustdoc/toggle-item-contents.rs index 1f745043894..1cc1da59105 100644 --- a/tests/rustdoc/toggle-item-contents.rs +++ b/tests/rustdoc/toggle-item-contents.rs @@ -1,15 +1,15 @@ #![allow(unused)] -// @has 'toggle_item_contents/struct.PubStruct.html' -// @count - '//details[@class="toggle type-contents-toggle"]' 0 +//@ has 'toggle_item_contents/struct.PubStruct.html' +//@ count - '//details[@class="toggle type-contents-toggle"]' 0 pub struct PubStruct { pub a: usize, pub b: usize, } -// @has 'toggle_item_contents/struct.BigPubStruct.html' -// @count - '//details[@class="toggle type-contents-toggle"]' 1 -// @has - '//details[@class="toggle type-contents-toggle"]' 'Show 13 fields' +//@ has 'toggle_item_contents/struct.BigPubStruct.html' +//@ count - '//details[@class="toggle type-contents-toggle"]' 1 +//@ has - '//details[@class="toggle type-contents-toggle"]' 'Show 13 fields' pub struct BigPubStruct { pub a: usize, pub b: usize, @@ -26,9 +26,9 @@ pub struct BigPubStruct { pub m: usize, } -// @has 'toggle_item_contents/union.BigUnion.html' -// @count - '//details[@class="toggle type-contents-toggle"]' 1 -// @has - '//details[@class="toggle type-contents-toggle"]' 'Show 13 fields' +//@ has 'toggle_item_contents/union.BigUnion.html' +//@ count - '//details[@class="toggle type-contents-toggle"]' 1 +//@ has - '//details[@class="toggle type-contents-toggle"]' 'Show 13 fields' pub union BigUnion { pub a: usize, pub b: usize, @@ -45,24 +45,24 @@ pub union BigUnion { pub m: usize, } -// @has 'toggle_item_contents/union.Union.html' -// @count - '//details[@class="toggle type-contents-toggle"]' 0 +//@ has 'toggle_item_contents/union.Union.html' +//@ count - '//details[@class="toggle type-contents-toggle"]' 0 pub union Union { pub a: usize, pub b: usize, pub c: usize, } -// @has 'toggle_item_contents/struct.PrivStruct.html' -// @count - '//details[@class="toggle type-contents-toggle"]' 0 -// @has - '//pre[@class="rust item-decl"]' '/* private fields */' +//@ has 'toggle_item_contents/struct.PrivStruct.html' +//@ count - '//details[@class="toggle type-contents-toggle"]' 0 +//@ has - '//pre[@class="rust item-decl"]' '/* private fields */' pub struct PrivStruct { a: usize, b: usize, } -// @has 'toggle_item_contents/enum.Enum.html' -// @!has - '//details[@class="toggle type-contents-toggle"]' '' +//@ has 'toggle_item_contents/enum.Enum.html' +//@ !has - '//details[@class="toggle type-contents-toggle"]' '' pub enum Enum { A, B, C, D { @@ -71,8 +71,8 @@ pub enum Enum { } } -// @has 'toggle_item_contents/enum.EnumStructVariant.html' -// @!has - '//details[@class="toggle type-contents-toggle"]' '' +//@ has 'toggle_item_contents/enum.EnumStructVariant.html' +//@ !has - '//details[@class="toggle type-contents-toggle"]' '' pub enum EnumStructVariant { A, B, C, D { @@ -80,15 +80,15 @@ pub enum EnumStructVariant { } } -// @has 'toggle_item_contents/enum.LargeEnum.html' -// @count - '//pre[@class="rust item-decl"]//details[@class="toggle type-contents-toggle"]' 1 -// @has - '//pre[@class="rust item-decl"]//details[@class="toggle type-contents-toggle"]' 'Show 13 variants' +//@ has 'toggle_item_contents/enum.LargeEnum.html' +//@ count - '//pre[@class="rust item-decl"]//details[@class="toggle type-contents-toggle"]' 1 +//@ has - '//pre[@class="rust item-decl"]//details[@class="toggle type-contents-toggle"]' 'Show 13 variants' pub enum LargeEnum { A, B, C, D, E, F(u8), G, H, I, J, K, L, M } -// @has 'toggle_item_contents/trait.Trait.html' -// @count - '//details[@class="toggle type-contents-toggle"]' 0 +//@ has 'toggle_item_contents/trait.Trait.html' +//@ count - '//details[@class="toggle type-contents-toggle"]' 0 pub trait Trait { type A; #[must_use] @@ -96,9 +96,9 @@ pub trait Trait { fn bar(); } -// @has 'toggle_item_contents/trait.GinormousTrait.html' -// @count - '//details[@class="toggle type-contents-toggle"]' 1 -// @has - '//details[@class="toggle type-contents-toggle"]' 'Show 16 associated items' +//@ has 'toggle_item_contents/trait.GinormousTrait.html' +//@ count - '//details[@class="toggle type-contents-toggle"]' 1 +//@ has - '//details[@class="toggle type-contents-toggle"]' 'Show 16 associated items' pub trait GinormousTrait { type A; type B; @@ -119,9 +119,9 @@ pub trait GinormousTrait { fn bar(); } -// @has 'toggle_item_contents/trait.HugeTrait.html' -// @count - '//details[@class="toggle type-contents-toggle"]' 1 -// @has - '//details[@class="toggle type-contents-toggle"]' 'Show 12 associated constants and 2 methods' +//@ has 'toggle_item_contents/trait.HugeTrait.html' +//@ count - '//details[@class="toggle type-contents-toggle"]' 1 +//@ has - '//details[@class="toggle type-contents-toggle"]' 'Show 12 associated constants and 2 methods' pub trait HugeTrait { type A; const M: usize = 1; @@ -141,9 +141,9 @@ pub trait HugeTrait { fn bar(); } -// @has 'toggle_item_contents/trait.GiganticTrait.html' -// @count - '//details[@class="toggle type-contents-toggle"]' 1 -// @has - '//details[@class="toggle type-contents-toggle"]' 'Show 1 associated constant and 1 method' +//@ has 'toggle_item_contents/trait.GiganticTrait.html' +//@ count - '//details[@class="toggle type-contents-toggle"]' 1 +//@ has - '//details[@class="toggle type-contents-toggle"]' 'Show 1 associated constant and 1 method' pub trait GiganticTrait { type A; type B; @@ -162,9 +162,9 @@ pub trait GiganticTrait { fn foo(); } -// @has 'toggle_item_contents/trait.BigTrait.html' -// @count - '//details[@class="toggle type-contents-toggle"]' 1 -// @has - '//details[@class="toggle type-contents-toggle"]' 'Show 14 methods' +//@ has 'toggle_item_contents/trait.BigTrait.html' +//@ count - '//details[@class="toggle type-contents-toggle"]' 1 +//@ has - '//details[@class="toggle type-contents-toggle"]' 'Show 14 methods' pub trait BigTrait { type A; #[must_use] diff --git a/tests/rustdoc/toggle-method.rs b/tests/rustdoc/toggle-method.rs index ebc316ca8ad..21057dfeb65 100644 --- a/tests/rustdoc/toggle-method.rs +++ b/tests/rustdoc/toggle-method.rs @@ -3,10 +3,10 @@ // Struct methods with documentation should be wrapped in a <details> toggle with an appropriate // summary. Struct methods with no documentation should not be wrapped. // -// @has foo/struct.Foo.html -// @has - '//details[@class="toggle method-toggle"]//summary//h4[@class="code-header"]' 'is_documented()' -// @has - '//details[@class="toggle method-toggle"]//*[@class="docblock"]' 'is_documented is documented' -// @!has - '//details[@class="toggle method-toggle"]//summary//h4[@class="code-header"]' 'not_documented()' +//@ has foo/struct.Foo.html +//@ has - '//details[@class="toggle method-toggle"]//summary//h4[@class="code-header"]' 'is_documented()' +//@ has - '//details[@class="toggle method-toggle"]//*[@class="docblock"]' 'is_documented is documented' +//@ !has - '//details[@class="toggle method-toggle"]//summary//h4[@class="code-header"]' 'not_documented()' pub struct Foo { } diff --git a/tests/rustdoc/toggle-trait-fn.rs b/tests/rustdoc/toggle-trait-fn.rs index 686a174fc8f..44cc6c8632a 100644 --- a/tests/rustdoc/toggle-trait-fn.rs +++ b/tests/rustdoc/toggle-trait-fn.rs @@ -3,15 +3,15 @@ // Trait methods with documentation should be wrapped in a <details> toggle with an appropriate // summary. Trait methods with no documentation should not be wrapped. // -// @has foo/trait.Foo.html -// @has - '//details[@class="toggle"]//summary//h4[@class="code-header"]' 'type Item' -// @!has - '//details[@class="toggle"]//summary//h4[@class="code-header"]' 'type Item2' -// @has - '//details[@class="toggle method-toggle"]//summary//h4[@class="code-header"]' 'is_documented()' -// @!has - '//details[@class="toggle method-toggle"]//summary//h4[@class="code-header"]' 'not_documented()' -// @has - '//details[@class="toggle method-toggle"]//*[@class="docblock"]' 'is_documented is documented' -// @has - '//details[@class="toggle method-toggle"]//summary//h4[@class="code-header"]' 'is_documented_optional()' -// @!has - '//details[@class="toggle method-toggle"]//summary//h4[@class="code-header"]' 'not_documented_optional()' -// @has - '//details[@class="toggle method-toggle"]//*[@class="docblock"]' 'is_documented_optional is documented' +//@ has foo/trait.Foo.html +//@ has - '//details[@class="toggle"]//summary//h4[@class="code-header"]' 'type Item' +//@ !has - '//details[@class="toggle"]//summary//h4[@class="code-header"]' 'type Item2' +//@ has - '//details[@class="toggle method-toggle"]//summary//h4[@class="code-header"]' 'is_documented()' +//@ !has - '//details[@class="toggle method-toggle"]//summary//h4[@class="code-header"]' 'not_documented()' +//@ has - '//details[@class="toggle method-toggle"]//*[@class="docblock"]' 'is_documented is documented' +//@ has - '//details[@class="toggle method-toggle"]//summary//h4[@class="code-header"]' 'is_documented_optional()' +//@ !has - '//details[@class="toggle method-toggle"]//summary//h4[@class="code-header"]' 'not_documented_optional()' +//@ has - '//details[@class="toggle method-toggle"]//*[@class="docblock"]' 'is_documented_optional is documented' pub trait Foo { /// is documented type Item; diff --git a/tests/rustdoc/trait-alias-mention.rs b/tests/rustdoc/trait-alias-mention.rs index 102bdca7d35..b6ef926e644 100644 --- a/tests/rustdoc/trait-alias-mention.rs +++ b/tests/rustdoc/trait-alias-mention.rs @@ -5,6 +5,6 @@ extern crate trait_alias_mention; -// @has foo/fn.mention_alias_in_bounds.html '//a[@href="../trait_alias_mention/traitalias.SomeAlias.html"]' 'SomeAlias' +//@ has foo/fn.mention_alias_in_bounds.html '//a[@href="../trait_alias_mention/traitalias.SomeAlias.html"]' 'SomeAlias' pub fn mention_alias_in_bounds<T: trait_alias_mention::SomeAlias>() { } diff --git a/tests/rustdoc/trait-impl-items-links-and-anchors.rs b/tests/rustdoc/trait-impl-items-links-and-anchors.rs index a125fa03679..c1845a33b9d 100644 --- a/tests/rustdoc/trait-impl-items-links-and-anchors.rs +++ b/tests/rustdoc/trait-impl-items-links-and-anchors.rs @@ -7,59 +7,59 @@ pub trait MyTrait { } impl MyTrait for String { - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedtype.Assoc-1"]//a[@class="associatedtype"]/@href' #associatedtype.Assoc - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedtype.Assoc-1"]//a[@class="anchor"]/@href' #associatedtype.Assoc-1 + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedtype.Assoc-1"]//a[@class="associatedtype"]/@href' #associatedtype.Assoc + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedtype.Assoc-1"]//a[@class="anchor"]/@href' #associatedtype.Assoc-1 type Assoc = (); - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedconstant.VALUE-1"]//a[@class="constant"]/@href' #associatedconstant.VALUE - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedconstant.VALUE-1"]//a[@class="anchor"]/@href' #associatedconstant.VALUE-1 + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedconstant.VALUE-1"]//a[@class="constant"]/@href' #associatedconstant.VALUE + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedconstant.VALUE-1"]//a[@class="anchor"]/@href' #associatedconstant.VALUE-1 const VALUE: u32 = 5; - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.trait_function"]//a[@class="fn"]/@href' #tymethod.trait_function - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.trait_function"]//a[@class="anchor"]/@href' #method.trait_function + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.trait_function"]//a[@class="fn"]/@href' #tymethod.trait_function + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.trait_function"]//a[@class="anchor"]/@href' #method.trait_function fn trait_function(&self) {} - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.defaulted_override-1"]//a[@class="fn"]/@href' #method.defaulted_override - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.defaulted_override-1"]//a[@class="anchor"]/@href' #method.defaulted_override-1 + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.defaulted_override-1"]//a[@class="fn"]/@href' #method.defaulted_override + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.defaulted_override-1"]//a[@class="anchor"]/@href' #method.defaulted_override-1 fn defaulted_override(&self) {} } impl MyTrait for Vec<u8> { - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedtype.Assoc-2"]//a[@class="associatedtype"]/@href' #associatedtype.Assoc - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedtype.Assoc-2"]//a[@class="anchor"]/@href' #associatedtype.Assoc-2 + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedtype.Assoc-2"]//a[@class="associatedtype"]/@href' #associatedtype.Assoc + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedtype.Assoc-2"]//a[@class="anchor"]/@href' #associatedtype.Assoc-2 type Assoc = (); - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedconstant.VALUE-2"]//a[@class="constant"]/@href' #associatedconstant.VALUE - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedconstant.VALUE-2"]//a[@class="anchor"]/@href' #associatedconstant.VALUE-2 + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedconstant.VALUE-2"]//a[@class="constant"]/@href' #associatedconstant.VALUE + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedconstant.VALUE-2"]//a[@class="anchor"]/@href' #associatedconstant.VALUE-2 const VALUE: u32 = 5; - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.trait_function"]//a[@class="fn"]/@href' #tymethod.trait_function - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.trait_function-1"]//a[@class="anchor"]/@href' #method.trait_function-1 + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.trait_function"]//a[@class="fn"]/@href' #tymethod.trait_function + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.trait_function-1"]//a[@class="anchor"]/@href' #method.trait_function-1 fn trait_function(&self) {} - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.defaulted_override-2"]//a[@class="fn"]/@href' #method.defaulted_override - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.defaulted_override-2"]//a[@class="anchor"]/@href' #method.defaulted_override-2 + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.defaulted_override-2"]//a[@class="fn"]/@href' #method.defaulted_override + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="method.defaulted_override-2"]//a[@class="anchor"]/@href' #method.defaulted_override-2 fn defaulted_override(&self) {} } impl MyTrait for MyStruct { - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedtype.Assoc-3"]//a[@class="anchor"]/@href' #associatedtype.Assoc-3 - // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="associatedtype.Assoc"]//a[@class="associatedtype"]/@href' trait.MyTrait.html#associatedtype.Assoc - // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="associatedtype.Assoc"]//a[@class="anchor"]/@href' #associatedtype.Assoc + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedtype.Assoc-3"]//a[@class="anchor"]/@href' #associatedtype.Assoc-3 + //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="associatedtype.Assoc"]//a[@class="associatedtype"]/@href' trait.MyTrait.html#associatedtype.Assoc + //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="associatedtype.Assoc"]//a[@class="anchor"]/@href' #associatedtype.Assoc type Assoc = bool; - // @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedconstant.VALUE-3"]//a[@class="anchor"]/@href' #associatedconstant.VALUE-3 - // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="associatedconstant.VALUE"]//a[@class="constant"]/@href' trait.MyTrait.html#associatedconstant.VALUE - // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="associatedconstant.VALUE"]//a[@class="anchor"]/@href' #associatedconstant.VALUE + //@ has trait_impl_items_links_and_anchors/trait.MyTrait.html '//*[@id="associatedconstant.VALUE-3"]//a[@class="anchor"]/@href' #associatedconstant.VALUE-3 + //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="associatedconstant.VALUE"]//a[@class="constant"]/@href' trait.MyTrait.html#associatedconstant.VALUE + //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="associatedconstant.VALUE"]//a[@class="anchor"]/@href' #associatedconstant.VALUE const VALUE: u32 = 20; - // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.trait_function"]//a[@class="fn"]/@href' trait.MyTrait.html#tymethod.trait_function - // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.trait_function"]//a[@class="anchor"]/@href' #method.trait_function + //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.trait_function"]//a[@class="fn"]/@href' trait.MyTrait.html#tymethod.trait_function + //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.trait_function"]//a[@class="anchor"]/@href' #method.trait_function fn trait_function(&self) {} - // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.defaulted_override"]//a[@class="fn"]/@href' trait.MyTrait.html#method.defaulted_override - // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.defaulted_override"]//a[@class="anchor"]/@href' #method.defaulted_override + //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.defaulted_override"]//a[@class="fn"]/@href' trait.MyTrait.html#method.defaulted_override + //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.defaulted_override"]//a[@class="anchor"]/@href' #method.defaulted_override fn defaulted_override(&self) {} - // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.defaulted"]//a[@class="fn"]/@href' trait.MyTrait.html#method.defaulted - // @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.defaulted"]//a[@class="anchor"]/@href' #method.defaulted + //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.defaulted"]//a[@class="fn"]/@href' trait.MyTrait.html#method.defaulted + //@ has trait_impl_items_links_and_anchors/struct.MyStruct.html '//*[@id="method.defaulted"]//a[@class="anchor"]/@href' #method.defaulted } pub struct MyStruct; // We check that associated items with default values aren't generated in the implementors list. impl MyTrait for (u8, u8) { - // @!has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedconstant.VALUE-4"]' '' + //@ !has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedconstant.VALUE-4"]' '' type Assoc = bool; fn trait_function(&self) {} } diff --git a/tests/rustdoc/trait-impl.rs b/tests/rustdoc/trait-impl.rs index 9cf3226f738..c65eecc4edf 100644 --- a/tests/rustdoc/trait-impl.rs +++ b/tests/rustdoc/trait-impl.rs @@ -21,25 +21,25 @@ pub trait Trait { pub struct Struct; impl Trait for Struct { - // @has trait_impl/struct.Struct.html '//*[@id="method.a"]/../../div[@class="docblock"]' 'Some long docs' - // @!has - '//*[@id="method.a"]/../../div[@class="docblock"]' 'link will be added' - // @has - '//*[@id="method.a"]/../../div[@class="docblock"]/a' 'Read more' - // @has - '//*[@id="method.a"]/../../div[@class="docblock"]/a/@href' 'trait.Trait.html#tymethod.a' + //@ has trait_impl/struct.Struct.html '//*[@id="method.a"]/../../div[@class="docblock"]' 'Some long docs' + //@ !has - '//*[@id="method.a"]/../../div[@class="docblock"]' 'link will be added' + //@ has - '//*[@id="method.a"]/../../div[@class="docblock"]/a' 'Read more' + //@ has - '//*[@id="method.a"]/../../div[@class="docblock"]/a/@href' 'trait.Trait.html#tymethod.a' fn a() {} - // @has - '//*[@id="method.b"]/../../div[@class="docblock"]' 'These docs contain' - // @has - '//*[@id="method.b"]/../../div[@class="docblock"]/a' 'reference link' - // @has - '//*[@id="method.b"]/../../div[@class="docblock"]/a/@href' 'https://example.com' + //@ has - '//*[@id="method.b"]/../../div[@class="docblock"]' 'These docs contain' + //@ has - '//*[@id="method.b"]/../../div[@class="docblock"]/a' 'reference link' + //@ has - '//*[@id="method.b"]/../../div[@class="docblock"]/a/@href' 'https://example.com' fn b() {} - // @!has - '//*[@id="method.c"]/../../div[@class="docblock"]' 'code block' - // @has - '//*[@id="method.c"]/../../div[@class="docblock"]/a' 'Read more' - // @has - '//*[@id="method.c"]/../../div[@class="docblock"]/a/@href' 'trait.Trait.html#tymethod.c' + //@ !has - '//*[@id="method.c"]/../../div[@class="docblock"]' 'code block' + //@ has - '//*[@id="method.c"]/../../div[@class="docblock"]/a' 'Read more' + //@ has - '//*[@id="method.c"]/../../div[@class="docblock"]/a/@href' 'trait.Trait.html#tymethod.c' fn c() {} - // @has - '//*[@id="method.d"]/../../div[@class="docblock"]' 'Escaped formatting a*b*c* works' - // @!has - '//*[@id="method.d"]/../../div[@class="docblock"]/em' '' + //@ has - '//*[@id="method.d"]/../../div[@class="docblock"]' 'Escaped formatting a*b*c* works' + //@ !has - '//*[@id="method.d"]/../../div[@class="docblock"]/em' '' fn d() {} - // @has - '//*[@id="impl-Trait-for-Struct"]/h3//a/@href' 'trait.Trait.html' + //@ has - '//*[@id="impl-Trait-for-Struct"]/h3//a/@href' 'trait.Trait.html' } diff --git a/tests/rustdoc/trait-implementations-duplicate-self-45584.rs b/tests/rustdoc/trait-implementations-duplicate-self-45584.rs index 77b8c05f2fb..8eb6d007525 100644 --- a/tests/rustdoc/trait-implementations-duplicate-self-45584.rs +++ b/tests/rustdoc/trait-implementations-duplicate-self-45584.rs @@ -4,14 +4,14 @@ pub trait Bar<T, U> {} -// @has 'foo/struct.Foo1.html' +//@ has 'foo/struct.Foo1.html' pub struct Foo1; -// @count - '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1 -// @has - '//*[@class="impl"]' "impl Bar<Foo1, &'static Foo1> for Foo1" +//@ count - '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1 +//@ has - '//*[@class="impl"]' "impl Bar<Foo1, &'static Foo1> for Foo1" impl Bar<Foo1, &'static Foo1> for Foo1 {} -// @has 'foo/struct.Foo2.html' +//@ has 'foo/struct.Foo2.html' pub struct Foo2; -// @count - '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1 -// @has - '//*[@class="impl"]' "impl Bar<&'static Foo2, Foo2> for u8" +//@ count - '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1 +//@ has - '//*[@class="impl"]' "impl Bar<&'static Foo2, Foo2> for u8" impl Bar<&'static Foo2, Foo2> for u8 {} diff --git a/tests/rustdoc/trait-item-info.rs b/tests/rustdoc/trait-item-info.rs index 53a4c6917b9..f158bba9893 100644 --- a/tests/rustdoc/trait-item-info.rs +++ b/tests/rustdoc/trait-item-info.rs @@ -7,16 +7,16 @@ #![unstable(feature = "test", issue = "none")] -// @has 'foo/trait.Foo.html' +//@ has 'foo/trait.Foo.html' #[stable(feature = "rust2", since = "2.2.2")] pub trait Foo { - // @has - '//div[@class="methods"]/span[@class="item-info"]' 'bla' + //@ has - '//div[@class="methods"]/span[@class="item-info"]' 'bla' // Should not be in a `<details>` because there is no doc. #[unstable(feature = "bla", reason = "bla", issue = "111")] fn bla() {} - // @has - '//details[@class="toggle method-toggle"]/summary/span[@class="item-info"]' 'bar' + //@ has - '//details[@class="toggle method-toggle"]/summary/span[@class="item-info"]' 'bar' // Should have a `<summary>` in the `<details>` containing the unstable info. /// doc #[unstable(feature = "bar", reason = "bla", issue = "222")] diff --git a/tests/rustdoc/trait-object-safe.rs b/tests/rustdoc/trait-object-safe.rs index 8b028ad2e13..b4e986c8f69 100644 --- a/tests/rustdoc/trait-object-safe.rs +++ b/tests/rustdoc/trait-object-safe.rs @@ -1,27 +1,27 @@ #![crate_name = "foo"] -// @has 'foo/trait.Unsafe.html' -// @has - '//*[@class="object-safety-info"]' 'This trait is not object safe.' -// @has - '//*[@id="object-safety"]' 'Object Safety' +//@ has 'foo/trait.Unsafe.html' +//@ has - '//*[@class="object-safety-info"]' 'This trait is not object safe.' +//@ has - '//*[@id="object-safety"]' 'Object Safety' pub trait Unsafe { fn foo() -> Self; } -// @has 'foo/trait.Unsafe2.html' -// @has - '//*[@class="object-safety-info"]' 'This trait is not object safe.' -// @has - '//*[@id="object-safety"]' 'Object Safety' +//@ has 'foo/trait.Unsafe2.html' +//@ has - '//*[@class="object-safety-info"]' 'This trait is not object safe.' +//@ has - '//*[@id="object-safety"]' 'Object Safety' pub trait Unsafe2<T> { fn foo(i: T); } -// @has 'foo/trait.Safe.html' -// @!has - '//*[@class="object-safety-info"]' '' -// @!has - '//*[@id="object-safety"]' '' +//@ has 'foo/trait.Safe.html' +//@ !has - '//*[@class="object-safety-info"]' '' +//@ !has - '//*[@id="object-safety"]' '' pub trait Safe { fn foo(&self); } -// @has 'foo/struct.Foo.html' -// @count - '//*[@class="object-safety-info"]' 0 -// @count - '//*[@id="object-safety"]' 0 +//@ has 'foo/struct.Foo.html' +//@ count - '//*[@class="object-safety-info"]' 0 +//@ count - '//*[@id="object-safety"]' 0 pub struct Foo; diff --git a/tests/rustdoc/trait-self-link.rs b/tests/rustdoc/trait-self-link.rs index e311dadff0e..fe69158b1a2 100644 --- a/tests/rustdoc/trait-self-link.rs +++ b/tests/rustdoc/trait-self-link.rs @@ -1,4 +1,4 @@ -// @has trait_self_link/trait.Foo.html //a/@href trait.Foo.html +//@ has trait_self_link/trait.Foo.html //a/@href trait.Foo.html pub trait Foo {} pub struct Bar; diff --git a/tests/rustdoc/trait-src-link.rs b/tests/rustdoc/trait-src-link.rs index a6367efba61..7c3afb7d7d3 100644 --- a/tests/rustdoc/trait-src-link.rs +++ b/tests/rustdoc/trait-src-link.rs @@ -1,26 +1,26 @@ #![crate_name = "quix"] pub trait Foo { - // @has quix/trait.Foo.html '//a[@href="../src/quix/trait-src-link.rs.html#4"]' 'source' + //@ has quix/trait.Foo.html '//a[@href="../src/quix/trait-src-link.rs.html#4"]' 'source' fn required(); - // @has quix/trait.Foo.html '//a[@href="../src/quix/trait-src-link.rs.html#7"]' 'source' + //@ has quix/trait.Foo.html '//a[@href="../src/quix/trait-src-link.rs.html#7"]' 'source' fn provided() {} } pub struct Bar; impl Foo for Bar { - // @has quix/struct.Bar.html '//a[@href="../src/quix/trait-src-link.rs.html#14"]' 'source' + //@ has quix/struct.Bar.html '//a[@href="../src/quix/trait-src-link.rs.html#14"]' 'source' fn required() {} - // @has quix/struct.Bar.html '//a[@href="../src/quix/trait-src-link.rs.html#7"]' 'source' + //@ has quix/struct.Bar.html '//a[@href="../src/quix/trait-src-link.rs.html#7"]' 'source' } pub struct Baz; impl Foo for Baz { - // @has quix/struct.Baz.html '//a[@href="../src/quix/trait-src-link.rs.html#22"]' 'source' + //@ has quix/struct.Baz.html '//a[@href="../src/quix/trait-src-link.rs.html#22"]' 'source' fn required() {} - // @has quix/struct.Baz.html '//a[@href="../src/quix/trait-src-link.rs.html#25"]' 'source' + //@ has quix/struct.Baz.html '//a[@href="../src/quix/trait-src-link.rs.html#25"]' 'source' fn provided() {} } diff --git a/tests/rustdoc/trait-visibility.rs b/tests/rustdoc/trait-visibility.rs index af9750ac8d0..bdb71a1bb45 100644 --- a/tests/rustdoc/trait-visibility.rs +++ b/tests/rustdoc/trait-visibility.rs @@ -4,5 +4,5 @@ extern crate trait_visibility; -// @has foo/trait.Bar.html '//a[@href="#tymethod.foo"]/..' "fn foo()" +//@ has foo/trait.Bar.html '//a[@href="#tymethod.foo"]/..' "fn foo()" pub use trait_visibility::Bar; diff --git a/tests/rustdoc/trait_alias.rs b/tests/rustdoc/trait_alias.rs index 5c3f82c6b3c..bfdb9d40e2d 100644 --- a/tests/rustdoc/trait_alias.rs +++ b/tests/rustdoc/trait_alias.rs @@ -4,23 +4,23 @@ use std::fmt::Debug; -// @has foo/all.html '//a[@href="traitalias.CopyAlias.html"]' 'CopyAlias' -// @has foo/all.html '//a[@href="traitalias.Alias2.html"]' 'Alias2' -// @has foo/all.html '//a[@href="traitalias.Foo.html"]' 'Foo' +//@ has foo/all.html '//a[@href="traitalias.CopyAlias.html"]' 'CopyAlias' +//@ has foo/all.html '//a[@href="traitalias.Alias2.html"]' 'Alias2' +//@ has foo/all.html '//a[@href="traitalias.Foo.html"]' 'Foo' -// @has foo/index.html '//h2[@id="trait-aliases"]' 'Trait Aliases' -// @has foo/index.html '//a[@class="traitalias"]' 'CopyAlias' -// @has foo/index.html '//a[@class="traitalias"]' 'Alias2' -// @has foo/index.html '//a[@class="traitalias"]' 'Foo' +//@ has foo/index.html '//h2[@id="trait-aliases"]' 'Trait Aliases' +//@ has foo/index.html '//a[@class="traitalias"]' 'CopyAlias' +//@ has foo/index.html '//a[@class="traitalias"]' 'Alias2' +//@ has foo/index.html '//a[@class="traitalias"]' 'Foo' -// @has foo/traitalias.CopyAlias.html -// @has - '//section[@id="main-content"]/pre[@class="rust item-decl"]' 'trait CopyAlias = Copy;' +//@ has foo/traitalias.CopyAlias.html +//@ has - '//section[@id="main-content"]/pre[@class="rust item-decl"]' 'trait CopyAlias = Copy;' pub trait CopyAlias = Copy; -// @has foo/traitalias.Alias2.html -// @has - '//section[@id="main-content"]/pre[@class="rust item-decl"]' 'trait Alias2 = Copy + Debug;' +//@ has foo/traitalias.Alias2.html +//@ has - '//section[@id="main-content"]/pre[@class="rust item-decl"]' 'trait Alias2 = Copy + Debug;' pub trait Alias2 = Copy + Debug; -// @has foo/traitalias.Foo.html -// @has - '//section[@id="main-content"]/pre[@class="rust item-decl"]' 'trait Foo<T> = Into<T> + Debug;' +//@ has foo/traitalias.Foo.html +//@ has - '//section[@id="main-content"]/pre[@class="rust item-decl"]' 'trait Foo<T> = Into<T> + Debug;' pub trait Foo<T> = Into<T> + Debug; -// @has foo/fn.bar.html '//a[@href="traitalias.Alias2.html"]' 'Alias2' +//@ has foo/fn.bar.html '//a[@href="traitalias.Alias2.html"]' 'Alias2' pub fn bar<T>() where T: Alias2 {} diff --git a/tests/rustdoc/traits-in-bodies-private.rs b/tests/rustdoc/traits-in-bodies-private.rs index 5a21b8b2625..a3455b3255b 100644 --- a/tests/rustdoc/traits-in-bodies-private.rs +++ b/tests/rustdoc/traits-in-bodies-private.rs @@ -3,8 +3,8 @@ //@ compile-flags:--document-private-items -// @has traits_in_bodies_private/struct.SomeStruct.html -// @!has - '//code' 'impl HiddenTrait for SomeStruct' +//@ has traits_in_bodies_private/struct.SomeStruct.html +//@ !has - '//code' 'impl HiddenTrait for SomeStruct' pub struct SomeStruct; fn __implementation_details() { diff --git a/tests/rustdoc/traits-in-bodies.rs b/tests/rustdoc/traits-in-bodies.rs index a65dd7a546c..a6f6158afa4 100644 --- a/tests/rustdoc/traits-in-bodies.rs +++ b/tests/rustdoc/traits-in-bodies.rs @@ -3,8 +3,8 @@ pub struct Bounded<T: Clone>(T); -// @has traits_in_bodies/struct.SomeStruct.html -// @has - '//h3[@class="code-header"]' 'impl Clone for SomeStruct' +//@ has traits_in_bodies/struct.SomeStruct.html +//@ has - '//h3[@class="code-header"]' 'impl Clone for SomeStruct' pub struct SomeStruct; fn asdf() -> Bounded<SomeStruct> { @@ -17,8 +17,8 @@ fn asdf() -> Bounded<SomeStruct> { Bounded(SomeStruct) } -// @has traits_in_bodies/struct.Point.html -// @has - '//h3[@class="code-header"]' 'impl Copy for Point' +//@ has traits_in_bodies/struct.Point.html +//@ has - '//h3[@class="code-header"]' 'impl Copy for Point' #[derive(Clone)] pub struct Point { x: i32, @@ -30,8 +30,8 @@ const _FOO: () = { () }; -// @has traits_in_bodies/struct.Inception.html -// @has - '//h3[@class="code-header"]' 'impl Clone for Inception' +//@ has traits_in_bodies/struct.Inception.html +//@ has - '//h3[@class="code-header"]' 'impl Clone for Inception' pub struct Inception; static _BAR: usize = { diff --git a/tests/rustdoc/tuple-struct-fields-doc.rs b/tests/rustdoc/tuple-struct-fields-doc.rs index 2836ddedc2b..55ee6662139 100644 --- a/tests/rustdoc/tuple-struct-fields-doc.rs +++ b/tests/rustdoc/tuple-struct-fields-doc.rs @@ -1,14 +1,14 @@ #![crate_name = "foo"] -// @has foo/struct.Foo.html -// @has - '//h2[@id="fields"]' 'Tuple Fields' -// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#fields"]' 'Tuple Fields' -// @has - '//*[@id="structfield.0"]' '0: u32' -// @has - '//*[@id="main-content"]/div[@class="docblock"]' 'hello' -// @!has - '//*[@id="structfield.1"]' '' -// @has - '//*[@id="structfield.2"]' '2: char' -// @has - '//*[@id="structfield.3"]' '3: i8' -// @has - '//*[@id="main-content"]/div[@class="docblock"]' 'not hello' +//@ has foo/struct.Foo.html +//@ has - '//h2[@id="fields"]' 'Tuple Fields' +//@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#fields"]' 'Tuple Fields' +//@ has - '//*[@id="structfield.0"]' '0: u32' +//@ has - '//*[@id="main-content"]/div[@class="docblock"]' 'hello' +//@ !has - '//*[@id="structfield.1"]' '' +//@ has - '//*[@id="structfield.2"]' '2: char' +//@ has - '//*[@id="structfield.3"]' '3: i8' +//@ has - '//*[@id="main-content"]/div[@class="docblock"]' 'not hello' pub struct Foo( /// hello pub u32, @@ -18,15 +18,15 @@ pub struct Foo( pub i8, ); -// @has foo/enum.Bar.html -// @has - '//pre[@class="rust item-decl"]' 'BarVariant(String),' -// @matches - '//*[@id="variant.BarVariant.fields"]/h4' '^Tuple Fields$' -// @has - '//*[@id="variant.BarVariant.field.0"]' '0: String' -// @has - '//*[@id="variant.BarVariant.fields"]//*[@class="docblock"]' 'Hello docs' -// @matches - '//*[@id="variant.FooVariant.fields"]/h4' '^Fields$' -// @has - '//*[@id="variant.BazVariant.fields"]//*[@class="docblock"]' 'dox' -// @has - '//*[@id="variant.OtherVariant.fields"]//*[@class="docblock"]' 'dox' -// @!matches - '//*[@id="variant.QuuxVariant.fields"]/h4' '^Tuple Fields$' +//@ has foo/enum.Bar.html +//@ has - '//pre[@class="rust item-decl"]' 'BarVariant(String),' +//@ matches - '//*[@id="variant.BarVariant.fields"]/h4' '^Tuple Fields$' +//@ has - '//*[@id="variant.BarVariant.field.0"]' '0: String' +//@ has - '//*[@id="variant.BarVariant.fields"]//*[@class="docblock"]' 'Hello docs' +//@ matches - '//*[@id="variant.FooVariant.fields"]/h4' '^Fields$' +//@ has - '//*[@id="variant.BazVariant.fields"]//*[@class="docblock"]' 'dox' +//@ has - '//*[@id="variant.OtherVariant.fields"]//*[@class="docblock"]' 'dox' +//@ !matches - '//*[@id="variant.QuuxVariant.fields"]/h4' '^Tuple Fields$' pub enum Bar { BarVariant( /// Hello docs diff --git a/tests/rustdoc/tuple-struct-where-clause-34928.rs b/tests/rustdoc/tuple-struct-where-clause-34928.rs index 909b9146893..804663a86f4 100644 --- a/tests/rustdoc/tuple-struct-where-clause-34928.rs +++ b/tests/rustdoc/tuple-struct-where-clause-34928.rs @@ -4,5 +4,5 @@ pub trait Bar {} -// @has foo/struct.Foo.html '//pre' 'pub struct Foo<T>(pub T) where T: Bar;' +//@ has foo/struct.Foo.html '//pre' 'pub struct Foo<T>(pub T) where T: Bar;' pub struct Foo<T>(pub T) where T: Bar; diff --git a/tests/rustdoc/tuples.rs b/tests/rustdoc/tuples.rs index 0ea5b5bfac9..a0c0ad7cd9a 100644 --- a/tests/rustdoc/tuples.rs +++ b/tests/rustdoc/tuples.rs @@ -1,20 +1,20 @@ #![crate_name = "foo"] -// @has foo/fn.tuple0.html //pre 'pub fn tuple0(x: ())' -// @snapshot link_unit - '//pre[@class="rust item-decl"]/code' +//@ has foo/fn.tuple0.html //pre 'pub fn tuple0(x: ())' +//@ snapshot link_unit - '//pre[@class="rust item-decl"]/code' pub fn tuple0(x: ()) -> () { x } -// @has foo/fn.tuple1.html //pre 'pub fn tuple1(x: (i32,)) -> (i32,)' -// @snapshot link1_i32 - '//pre[@class="rust item-decl"]/code' +//@ has foo/fn.tuple1.html //pre 'pub fn tuple1(x: (i32,)) -> (i32,)' +//@ snapshot link1_i32 - '//pre[@class="rust item-decl"]/code' pub fn tuple1(x: (i32,)) -> (i32,) { x } -// @has foo/fn.tuple2.html //pre 'pub fn tuple2(x: (i32, i32)) -> (i32, i32)' -// @snapshot link2_i32 - '//pre[@class="rust item-decl"]/code' +//@ has foo/fn.tuple2.html //pre 'pub fn tuple2(x: (i32, i32)) -> (i32, i32)' +//@ snapshot link2_i32 - '//pre[@class="rust item-decl"]/code' pub fn tuple2(x: (i32, i32)) -> (i32, i32) { x } -// @has foo/fn.tuple1_t.html //pre 'pub fn tuple1_t<T>(x: (T,)) -> (T,)' -// @snapshot link1_t - '//pre[@class="rust item-decl"]/code' +//@ has foo/fn.tuple1_t.html //pre 'pub fn tuple1_t<T>(x: (T,)) -> (T,)' +//@ snapshot link1_t - '//pre[@class="rust item-decl"]/code' pub fn tuple1_t<T>(x: (T,)) -> (T,) { x } -// @has foo/fn.tuple2_t.html //pre 'pub fn tuple2_t<T>(x: (T, T)) -> (T, T)' -// @snapshot link2_t - '//pre[@class="rust item-decl"]/code' +//@ has foo/fn.tuple2_t.html //pre 'pub fn tuple2_t<T>(x: (T, T)) -> (T, T)' +//@ snapshot link2_t - '//pre[@class="rust item-decl"]/code' pub fn tuple2_t<T>(x: (T, T)) -> (T, T) { x } -// @has foo/fn.tuple2_tu.html //pre 'pub fn tuple2_tu<T, U>(x: (T, U)) -> (T, U)' -// @snapshot link2_tu - '//pre[@class="rust item-decl"]/code' +//@ has foo/fn.tuple2_tu.html //pre 'pub fn tuple2_tu<T, U>(x: (T, U)) -> (T, U)' +//@ snapshot link2_tu - '//pre[@class="rust item-decl"]/code' pub fn tuple2_tu<T, U>(x: (T, U)) -> (T, U) { x } diff --git a/tests/rustdoc/type-alias/cross-crate-115718.rs b/tests/rustdoc/type-alias/cross-crate-115718.rs index 3d94be5ddbd..578d2190c5e 100644 --- a/tests/rustdoc/type-alias/cross-crate-115718.rs +++ b/tests/rustdoc/type-alias/cross-crate-115718.rs @@ -23,12 +23,12 @@ impl MyTrait3 for MyType { fn method_trait_3() {} } -// @hasraw 'type.impl/parent_crate_115718/struct.MyStruct.js' 'method_trait_1' -// @hasraw 'type.impl/parent_crate_115718/struct.MyStruct.js' 'method_trait_2' +//@ hasraw 'type.impl/parent_crate_115718/struct.MyStruct.js' 'method_trait_1' +//@ hasraw 'type.impl/parent_crate_115718/struct.MyStruct.js' 'method_trait_2' // Avoid duplicating these docs. -// @!hasraw 'foo/type.MyType.html' 'method_trait_1' -// @!hasraw 'foo/type.MyType.html' 'method_trait_2' +//@ !hasraw 'foo/type.MyType.html' 'method_trait_1' +//@ !hasraw 'foo/type.MyType.html' 'method_trait_2' // The one made directly on the type alias should be attached to the HTML instead. -// @!hasraw 'type.impl/parent_crate_115718/struct.MyStruct.js' 'method_trait_3' -// @hasraw 'foo/type.MyType.html' 'method_trait_3' +//@ !hasraw 'type.impl/parent_crate_115718/struct.MyStruct.js' 'method_trait_3' +//@ hasraw 'foo/type.MyType.html' 'method_trait_3' pub type MyType = MyStruct<u16>; diff --git a/tests/rustdoc/type-alias/deref-32077.rs b/tests/rustdoc/type-alias/deref-32077.rs index 186ebb1a632..79a83381340 100644 --- a/tests/rustdoc/type-alias/deref-32077.rs +++ b/tests/rustdoc/type-alias/deref-32077.rs @@ -18,25 +18,25 @@ pub trait Bar {} impl<T> Foo for GenericStruct<T> {} impl Bar for GenericStruct<u32> {} -// @has 'foo/type.TypedefStruct.html' +//@ has 'foo/type.TypedefStruct.html' // We check that "Aliased type" is also present as a title in the sidebar. -// @has - '//*[@class="sidebar-elems"]//h3/a[@href="#aliased-type"]' 'Aliased type' +//@ has - '//*[@class="sidebar-elems"]//h3/a[@href="#aliased-type"]' 'Aliased type' // We check that we have the implementation of the type alias itself. -// @has - '//*[@id="impl-GenericStruct%3Cu8%3E"]/h3' 'impl TypedefStruct' -// @has - '//*[@id="method.on_alias"]/h4' 'pub fn on_alias()' +//@ has - '//*[@id="impl-GenericStruct%3Cu8%3E"]/h3' 'impl TypedefStruct' +//@ has - '//*[@id="method.on_alias"]/h4' 'pub fn on_alias()' // This trait implementation doesn't match the type alias parameters so shouldn't appear in docs. -// @!has - '//h3' 'impl Bar for GenericStruct<u32> {}' +//@ !has - '//h3' 'impl Bar for GenericStruct<u32> {}' // Same goes for the `Deref` impl. -// @!has - '//h2' 'Methods from Deref<Target = u32>' -// @count - '//nav[@class="sidebar"]//a' 'on_alias' 1 -// @!has - '//nav[@class="sidebar"]//a' 'on_gen' -// @!has - '//nav[@class="sidebar"]//a' 'Foo' -// @!has - '//nav[@class="sidebar"]//a' 'Bar' -// @!has - '//nav[@class="sidebar"]//a' 'on_u32' +//@ !has - '//h2' 'Methods from Deref<Target = u32>' +//@ count - '//nav[@class="sidebar"]//a' 'on_alias' 1 +//@ !has - '//nav[@class="sidebar"]//a' 'on_gen' +//@ !has - '//nav[@class="sidebar"]//a' 'Foo' +//@ !has - '//nav[@class="sidebar"]//a' 'Bar' +//@ !has - '//nav[@class="sidebar"]//a' 'on_u32' // TypedefStruct inlined to GenericStruct -// @hasraw 'type.impl/foo/struct.GenericStruct.js' 'TypedefStruct' -// @hasraw 'type.impl/foo/struct.GenericStruct.js' 'method.on_gen' -// @hasraw 'type.impl/foo/struct.GenericStruct.js' 'Foo' +//@ hasraw 'type.impl/foo/struct.GenericStruct.js' 'TypedefStruct' +//@ hasraw 'type.impl/foo/struct.GenericStruct.js' 'method.on_gen' +//@ hasraw 'type.impl/foo/struct.GenericStruct.js' 'Foo' pub type TypedefStruct = GenericStruct<u8>; impl TypedefStruct { @@ -53,12 +53,12 @@ impl std::ops::Deref for GenericStruct<u32> { pub struct Wrap<T>(GenericStruct<T>); -// @has 'foo/type.Alias.html' -// @!has - '//h2' 'Methods from Deref<Target = u32>' -// @!has - '//*[@id="impl-Deref-for-Wrap%3CT%3E"]/h3' 'impl<T> Deref for Wrap<T>' -// @hasraw 'type.impl/foo/struct.Wrap.js' 'impl-Deref-for-Wrap%3CT%3E' +//@ has 'foo/type.Alias.html' +//@ !has - '//h2' 'Methods from Deref<Target = u32>' +//@ !has - '//*[@id="impl-Deref-for-Wrap%3CT%3E"]/h3' 'impl<T> Deref for Wrap<T>' +//@ hasraw 'type.impl/foo/struct.Wrap.js' 'impl-Deref-for-Wrap%3CT%3E' // Deref Methods aren't gathered for type aliases, though the actual impl is. -// @!hasraw 'type.impl/foo/struct.Wrap.js' 'BITS' +//@ !hasraw 'type.impl/foo/struct.Wrap.js' 'BITS' pub type Alias = Wrap<u32>; impl<T> std::ops::Deref for Wrap<T> { diff --git a/tests/rustdoc/type-alias/primitive-local-link-121106.rs b/tests/rustdoc/type-alias/primitive-local-link-121106.rs index c11d35d8646..3bdce3846c8 100644 --- a/tests/rustdoc/type-alias/primitive-local-link-121106.rs +++ b/tests/rustdoc/type-alias/primitive-local-link-121106.rs @@ -2,18 +2,18 @@ #![feature(rustc_attrs)] -// @has foo/primitive.i32.html '//h1' 'Primitive Type i32' -// @has foo/index.html '//a/@href' '../foo/index.html' +//@ has foo/primitive.i32.html '//h1' 'Primitive Type i32' +//@ has foo/index.html '//a/@href' '../foo/index.html' #[rustc_doc_primitive = "i32"] mod i32 {} -// @has foo/struct.Node.html '//a/@href' 'primitive.i32.html' +//@ has foo/struct.Node.html '//a/@href' 'primitive.i32.html' pub struct Node; impl Node { pub fn edge(&self) -> i32 { 0 } } -// @!has foo/type.Alias.html '//a/@href' 'primitive.i32.html' -// @hasraw 'type.impl/foo/struct.Node.js' 'href=\"foo/primitive.i32.html\"' +//@ !has foo/type.Alias.html '//a/@href' 'primitive.i32.html' +//@ hasraw 'type.impl/foo/struct.Node.js' 'href=\"foo/primitive.i32.html\"' pub type Alias = Node; diff --git a/tests/rustdoc/type-alias/same-crate-115718.rs b/tests/rustdoc/type-alias/same-crate-115718.rs index 26e5db85cd6..ec847756822 100644 --- a/tests/rustdoc/type-alias/same-crate-115718.rs +++ b/tests/rustdoc/type-alias/same-crate-115718.rs @@ -27,8 +27,8 @@ impl MyTrait2 for MyStruct<u16> { fn method_trait_2() {} } -// @hasraw 'type.impl/foo/struct.MyStruct.js' 'method_u16' -// @!hasraw 'type.impl/foo/struct.MyStruct.js' 'method_u32' -// @!hasraw 'type.impl/foo/struct.MyStruct.js' 'method_trait_1' -// @hasraw 'type.impl/foo/struct.MyStruct.js' 'method_trait_2' +//@ hasraw 'type.impl/foo/struct.MyStruct.js' 'method_u16' +//@ !hasraw 'type.impl/foo/struct.MyStruct.js' 'method_u32' +//@ !hasraw 'type.impl/foo/struct.MyStruct.js' 'method_trait_1' +//@ hasraw 'type.impl/foo/struct.MyStruct.js' 'method_trait_2' pub type MyType = MyStruct<u16>; diff --git a/tests/rustdoc/type-layout-flag-required.rs b/tests/rustdoc/type-layout-flag-required.rs index 6bb5e10f881..699be973e90 100644 --- a/tests/rustdoc/type-layout-flag-required.rs +++ b/tests/rustdoc/type-layout-flag-required.rs @@ -1,4 +1,4 @@ // Tests that `--show-type-layout` is required in order to show layout info. -// @!hasraw type_layout_flag_required/struct.Foo.html 'Size: ' +//@ !hasraw type_layout_flag_required/struct.Foo.html 'Size: ' pub struct Foo(usize); diff --git a/tests/rustdoc/type-layout.rs b/tests/rustdoc/type-layout.rs index b2ff4add63e..1e462210cba 100644 --- a/tests/rustdoc/type-layout.rs +++ b/tests/rustdoc/type-layout.rs @@ -1,93 +1,93 @@ //@ compile-flags: --show-type-layout -Z unstable-options -// @hasraw type_layout/struct.Foo.html 'Size: ' -// @hasraw - ' bytes' -// @has - '//*[@id="layout"]/a[@href="#layout"]' '' +//@ hasraw type_layout/struct.Foo.html 'Size: ' +//@ hasraw - ' bytes' +//@ has - '//*[@id="layout"]/a[@href="#layout"]' '' pub struct Foo { pub a: usize, b: Vec<String>, } -// @hasraw type_layout/enum.Bar.html 'Size: ' -// @hasraw - ' bytes' +//@ hasraw type_layout/enum.Bar.html 'Size: ' +//@ hasraw - ' bytes' pub enum Bar<'a> { A(String), B(&'a str, (std::collections::HashMap<String, usize>, Foo)), } -// @hasraw type_layout/union.Baz.html 'Size: ' -// @hasraw - ' bytes' +//@ hasraw type_layout/union.Baz.html 'Size: ' +//@ hasraw - ' bytes' pub union Baz { a: &'static str, b: usize, c: &'static [u8], } -// @hasraw type_layout/struct.X.html 'Size: ' -// @hasraw - ' bytes' +//@ hasraw type_layout/struct.X.html 'Size: ' +//@ hasraw - ' bytes' pub struct X(usize); -// @hasraw type_layout/struct.Y.html 'Size: ' -// @hasraw - '1 byte' -// @!hasraw - ' bytes' +//@ hasraw type_layout/struct.Y.html 'Size: ' +//@ hasraw - '1 byte' +//@ !hasraw - ' bytes' pub struct Y(u8); -// @hasraw type_layout/struct.Z.html 'Size: ' -// @hasraw - '0 bytes' +//@ hasraw type_layout/struct.Z.html 'Size: ' +//@ hasraw - '0 bytes' pub struct Z; // We can't compute layout for generic types. -// @hasraw type_layout/struct.Generic.html 'Unable to compute type layout, possibly due to this type having generic parameters' -// @!hasraw - 'Size: ' +//@ hasraw type_layout/struct.Generic.html 'Unable to compute type layout, possibly due to this type having generic parameters' +//@ !hasraw - 'Size: ' pub struct Generic<T>(T); // We *can*, however, compute layout for types that are only generic over lifetimes, // because lifetimes are a type-system construct. -// @hasraw type_layout/struct.GenericLifetimes.html 'Size: ' -// @hasraw - ' bytes' +//@ hasraw type_layout/struct.GenericLifetimes.html 'Size: ' +//@ hasraw - ' bytes' pub struct GenericLifetimes<'a>(&'a str); -// @hasraw type_layout/struct.Unsized.html 'Size: ' -// @hasraw - '(unsized)' +//@ hasraw type_layout/struct.Unsized.html 'Size: ' +//@ hasraw - '(unsized)' pub struct Unsized([u8]); -// @hasraw type_layout/type.TypeAlias.html 'Size: ' -// @hasraw - ' bytes' +//@ hasraw type_layout/type.TypeAlias.html 'Size: ' +//@ hasraw - ' bytes' pub type TypeAlias = X; -// @hasraw type_layout/type.GenericTypeAlias.html 'Size: ' -// @hasraw - '8 bytes' +//@ hasraw type_layout/type.GenericTypeAlias.html 'Size: ' +//@ hasraw - '8 bytes' pub type GenericTypeAlias = (Generic<(u32, ())>, Generic<u32>); // Regression test for the rustdoc equivalent of #85103. -// @hasraw type_layout/type.Edges.html 'Encountered an error during type layout; the type failed to be normalized.' +//@ hasraw type_layout/type.Edges.html 'Encountered an error during type layout; the type failed to be normalized.' pub type Edges<'a, E> = std::borrow::Cow<'a, [E]>; -// @!hasraw type_layout/trait.MyTrait.html 'Size: ' +//@ !hasraw type_layout/trait.MyTrait.html 'Size: ' pub trait MyTrait {} -// @hasraw type_layout/enum.Variants.html 'Size: ' -// @hasraw - '2 bytes' -// @hasraw - '<code>A</code>: 0 bytes' -// @hasraw - '<code>B</code>: 1 byte' +//@ hasraw type_layout/enum.Variants.html 'Size: ' +//@ hasraw - '2 bytes' +//@ hasraw - '<code>A</code>: 0 bytes' +//@ hasraw - '<code>B</code>: 1 byte' pub enum Variants { A, B(u8), } -// @hasraw type_layout/enum.WithNiche.html 'Size: ' -// @has - //p '4 bytes' -// @hasraw - '<code>None</code>: 0 bytes' -// @hasraw - '<code>Some</code>: 4 bytes' +//@ hasraw type_layout/enum.WithNiche.html 'Size: ' +//@ has - //p '4 bytes' +//@ hasraw - '<code>None</code>: 0 bytes' +//@ hasraw - '<code>Some</code>: 4 bytes' pub enum WithNiche { None, Some(std::num::NonZero<u32>), } -// @hasraw type_layout/enum.Uninhabited.html 'Size: ' -// @hasraw - '0 bytes (<a href="https://doc.rust-lang.org/stable/reference/glossary.html#uninhabited">uninhabited</a>)' +//@ hasraw type_layout/enum.Uninhabited.html 'Size: ' +//@ hasraw - '0 bytes (<a href="https://doc.rust-lang.org/stable/reference/glossary.html#uninhabited">uninhabited</a>)' pub enum Uninhabited {} -// @hasraw type_layout/struct.Uninhabited2.html 'Size: ' -// @hasraw - '8 bytes (<a href="https://doc.rust-lang.org/stable/reference/glossary.html#uninhabited">uninhabited</a>)' +//@ hasraw type_layout/struct.Uninhabited2.html 'Size: ' +//@ hasraw - '8 bytes (<a href="https://doc.rust-lang.org/stable/reference/glossary.html#uninhabited">uninhabited</a>)' pub struct Uninhabited2(std::convert::Infallible, u64); diff --git a/tests/rustdoc/typedef-inner-variants-lazy_type_alias.rs b/tests/rustdoc/typedef-inner-variants-lazy_type_alias.rs index bea25c75aa4..c6bfe495bb0 100644 --- a/tests/rustdoc/typedef-inner-variants-lazy_type_alias.rs +++ b/tests/rustdoc/typedef-inner-variants-lazy_type_alias.rs @@ -3,32 +3,32 @@ #![feature(lazy_type_alias)] #![allow(incomplete_features)] -// @has 'inner_types_lazy/struct.Pair.html' +//@ has 'inner_types_lazy/struct.Pair.html' pub struct Pair<A, B> { pub first: A, pub second: B, } -// @has 'inner_types_lazy/type.ReversedTypesPair.html' -// @count - '//*[@id="aliased-type"]' 1 -// @count - '//*[@id="variants"]' 0 -// @count - '//*[@id="fields"]' 1 -// @count - '//div[@class="where"]' 0 +//@ has 'inner_types_lazy/type.ReversedTypesPair.html' +//@ count - '//*[@id="aliased-type"]' 1 +//@ count - '//*[@id="variants"]' 0 +//@ count - '//*[@id="fields"]' 1 +//@ count - '//div[@class="where"]' 0 pub type ReversedTypesPair<Q, R> = Pair<R, Q>; -// @has 'inner_types_lazy/type.ReadWrite.html' -// @count - '//*[@id="aliased-type"]' 1 -// @count - '//*[@id="variants"]' 0 -// @count - '//*[@id="fields"]' 1 -// @count - '//div[@class="where"]' 2 +//@ has 'inner_types_lazy/type.ReadWrite.html' +//@ count - '//*[@id="aliased-type"]' 1 +//@ count - '//*[@id="variants"]' 0 +//@ count - '//*[@id="fields"]' 1 +//@ count - '//div[@class="where"]' 2 pub type ReadWrite<R, W> = Pair<R, W> where R: std::io::Read, W: std::io::Write; -// @has 'inner_types_lazy/type.VecPair.html' -// @count - '//*[@id="aliased-type"]' 1 -// @count - '//*[@id="variants"]' 0 -// @count - '//*[@id="fields"]' 1 -// @count - '//div[@class="where"]' 0 +//@ has 'inner_types_lazy/type.VecPair.html' +//@ count - '//*[@id="aliased-type"]' 1 +//@ count - '//*[@id="variants"]' 0 +//@ count - '//*[@id="fields"]' 1 +//@ count - '//div[@class="where"]' 0 pub type VecPair<U, V> = Pair<Vec<U>, Vec<V>>; diff --git a/tests/rustdoc/typedef-inner-variants.rs b/tests/rustdoc/typedef-inner-variants.rs index 0e65fdaf2af..51644546c01 100644 --- a/tests/rustdoc/typedef-inner-variants.rs +++ b/tests/rustdoc/typedef-inner-variants.rs @@ -20,12 +20,12 @@ impl Interner for TyCtxt { type Ty = Ty; } -// @has 'inner_variants/type.AliasTy.html' -// @count - '//*[@id="variants"]' 0 -// @count - '//*[@id="fields"]' 0 +//@ has 'inner_variants/type.AliasTy.html' +//@ count - '//*[@id="variants"]' 0 +//@ count - '//*[@id="fields"]' 0 pub type AliasTy = Ty; -// @has 'inner_variants/enum.IrTyKind.html' +//@ has 'inner_variants/enum.IrTyKind.html' pub enum IrTyKind<A, I: Interner> { /// Doc comment for AdtKind AdtKind(I::Adt), @@ -37,39 +37,39 @@ pub enum IrTyKind<A, I: Interner> { Unspecified, } -// @has 'inner_variants/type.NearlyTyKind.html' -// @count - '//*[@id="aliased-type"]' 1 -// @count - '//*[@id="variants"]' 1 -// @count - '//*[@id="fields"]' 0 +//@ has 'inner_variants/type.NearlyTyKind.html' +//@ count - '//*[@id="aliased-type"]' 1 +//@ count - '//*[@id="variants"]' 1 +//@ count - '//*[@id="fields"]' 0 pub type NearlyTyKind<A> = IrTyKind<A, TyCtxt>; -// @has 'inner_variants/type.TyKind.html' -// @count - '//*[@id="aliased-type"]' 1 -// @count - '//*[@id="variants"]' 1 -// @count - '//*[@id="fields"]' 0 -// @count - '//*[@class="variant"]' 3 -// @matches - '//pre[@class="rust item-decl"]//code' "enum TyKind" -// @has - '//pre[@class="rust item-decl"]//code/a[1]' "Adt" -// @has - '//pre[@class="rust item-decl"]//code/a[2]' "Adt" -// @has - '//pre[@class="rust item-decl"]//code/a[3]' "Ty" -// @has - '//pre[@class="rust item-decl"]//code/a[4]' "i64" +//@ has 'inner_variants/type.TyKind.html' +//@ count - '//*[@id="aliased-type"]' 1 +//@ count - '//*[@id="variants"]' 1 +//@ count - '//*[@id="fields"]' 0 +//@ count - '//*[@class="variant"]' 3 +//@ matches - '//pre[@class="rust item-decl"]//code' "enum TyKind" +//@ has - '//pre[@class="rust item-decl"]//code/a[1]' "Adt" +//@ has - '//pre[@class="rust item-decl"]//code/a[2]' "Adt" +//@ has - '//pre[@class="rust item-decl"]//code/a[3]' "Ty" +//@ has - '//pre[@class="rust item-decl"]//code/a[4]' "i64" pub type TyKind = IrTyKind<i64, TyCtxt>; -// @has 'inner_variants/union.OneOr.html' +//@ has 'inner_variants/union.OneOr.html' pub union OneOr<A: Copy> { pub one: i64, pub or: A, } -// @has 'inner_variants/type.OneOrF64.html' -// @count - '//*[@id="aliased-type"]' 1 -// @count - '//*[@id="variants"]' 0 -// @count - '//*[@id="fields"]' 1 -// @count - '//*[@class="structfield section-header"]' 2 -// @matches - '//pre[@class="rust item-decl"]//code' "union OneOrF64" +//@ has 'inner_variants/type.OneOrF64.html' +//@ count - '//*[@id="aliased-type"]' 1 +//@ count - '//*[@id="variants"]' 0 +//@ count - '//*[@id="fields"]' 1 +//@ count - '//*[@class="structfield section-header"]' 2 +//@ matches - '//pre[@class="rust item-decl"]//code' "union OneOrF64" pub type OneOrF64 = OneOr<f64>; -// @has 'inner_variants/struct.One.html' +//@ has 'inner_variants/struct.One.html' pub struct One<T> { pub val: T, #[doc(hidden)] @@ -77,50 +77,50 @@ pub struct One<T> { __private: T, } -// @has 'inner_variants/type.OneU64.html' -// @count - '//*[@id="aliased-type"]' 1 -// @count - '//*[@id="variants"]' 0 -// @count - '//*[@id="fields"]' 1 -// @count - '//*[@class="structfield section-header"]' 1 -// @matches - '//pre[@class="rust item-decl"]//code' "struct OneU64" -// @matches - '//pre[@class="rust item-decl"]//code' "pub val" +//@ has 'inner_variants/type.OneU64.html' +//@ count - '//*[@id="aliased-type"]' 1 +//@ count - '//*[@id="variants"]' 0 +//@ count - '//*[@id="fields"]' 1 +//@ count - '//*[@class="structfield section-header"]' 1 +//@ matches - '//pre[@class="rust item-decl"]//code' "struct OneU64" +//@ matches - '//pre[@class="rust item-decl"]//code' "pub val" pub type OneU64 = One<u64>; -// @has 'inner_variants/struct.OnceA.html' +//@ has 'inner_variants/struct.OnceA.html' pub struct OnceA<'a, A> { pub a: &'a A, } -// @has 'inner_variants/type.Once.html' -// @count - '//*[@id="aliased-type"]' 1 -// @count - '//*[@id="variants"]' 0 -// @count - '//*[@id="fields"]' 1 -// @matches - '//pre[@class="rust item-decl"]//code' "struct Once<'a>" -// @matches - '//pre[@class="rust item-decl"]//code' "&'a" +//@ has 'inner_variants/type.Once.html' +//@ count - '//*[@id="aliased-type"]' 1 +//@ count - '//*[@id="variants"]' 0 +//@ count - '//*[@id="fields"]' 1 +//@ matches - '//pre[@class="rust item-decl"]//code' "struct Once<'a>" +//@ matches - '//pre[@class="rust item-decl"]//code' "&'a" pub type Once<'a> = OnceA<'a, i64>; -// @has 'inner_variants/struct.HighlyGenericStruct.html' +//@ has 'inner_variants/struct.HighlyGenericStruct.html' pub struct HighlyGenericStruct<A, B, C, D> { pub z: (A, B, C, D) } -// @has 'inner_variants/type.HighlyGenericAABB.html' -// @count - '//*[@id="aliased-type"]' 1 -// @count - '//*[@id="variants"]' 0 -// @count - '//*[@id="fields"]' 1 -// @matches - '//pre[@class="rust item-decl"]//code' "struct HighlyGenericAABB<A, B>" -// @matches - '//pre[@class="rust item-decl"]//code' "pub z" +//@ has 'inner_variants/type.HighlyGenericAABB.html' +//@ count - '//*[@id="aliased-type"]' 1 +//@ count - '//*[@id="variants"]' 0 +//@ count - '//*[@id="fields"]' 1 +//@ matches - '//pre[@class="rust item-decl"]//code' "struct HighlyGenericAABB<A, B>" +//@ matches - '//pre[@class="rust item-decl"]//code' "pub z" pub type HighlyGenericAABB<A, B> = HighlyGenericStruct<A, A, B, B>; -// @has 'inner_variants/type.InlineU64.html' -// @count - '//*[@id="aliased-type"]' 1 -// @count - '//*[@id="variants"]' 0 -// @count - '//*[@id="fields"]' 1 +//@ has 'inner_variants/type.InlineU64.html' +//@ count - '//*[@id="aliased-type"]' 1 +//@ count - '//*[@id="variants"]' 0 +//@ count - '//*[@id="fields"]' 1 pub use cross_crate_generic_typedef::InlineU64; -// @has 'inner_variants/type.InlineEnum.html' -// @count - '//*[@id="aliased-type"]' 1 -// @count - '//*[@id="variants"]' 1 -// @count - '//*[@id="fields"]' 0 -// @count - '//*[@class="variant"]' 2 +//@ has 'inner_variants/type.InlineEnum.html' +//@ count - '//*[@id="aliased-type"]' 1 +//@ count - '//*[@id="variants"]' 1 +//@ count - '//*[@id="fields"]' 0 +//@ count - '//*[@class="variant"]' 2 pub type InlineEnum = cross_crate_generic_typedef::GenericEnum<i32>; diff --git a/tests/rustdoc/typedef.rs b/tests/rustdoc/typedef.rs index 63e2973c759..3fdc2788bca 100644 --- a/tests/rustdoc/typedef.rs +++ b/tests/rustdoc/typedef.rs @@ -8,13 +8,13 @@ impl MyStruct { pub fn method_on_mystruct() {} } -// @has typedef/type.MyAlias.html -// @has - '//*[@class="impl"]//h3[@class="code-header"]' 'impl MyAlias' -// @has - '//*[@class="impl"]//h3[@class="code-header"]' 'impl MyTrait for MyAlias' -// @hasraw - 'Alias docstring' -// @has - '//*[@class="sidebar"]//*[@class="location"]' 'MyAlias' -// @has - '//*[@class="sidebar"]//a[@href="#implementations"]' 'Methods' -// @has - '//*[@class="sidebar"]//a[@href="#trait-implementations"]' 'Trait Implementations' +//@ has typedef/type.MyAlias.html +//@ has - '//*[@class="impl"]//h3[@class="code-header"]' 'impl MyAlias' +//@ has - '//*[@class="impl"]//h3[@class="code-header"]' 'impl MyTrait for MyAlias' +//@ hasraw - 'Alias docstring' +//@ has - '//*[@class="sidebar"]//*[@class="location"]' 'MyAlias' +//@ has - '//*[@class="sidebar"]//a[@href="#implementations"]' 'Methods' +//@ has - '//*[@class="sidebar"]//a[@href="#trait-implementations"]' 'Trait Implementations' /// Alias docstring pub type MyAlias = MyStruct; diff --git a/tests/rustdoc/underscore-import-61592.rs b/tests/rustdoc/underscore-import-61592.rs index d403f2cc7ab..d0fef96858a 100644 --- a/tests/rustdoc/underscore-import-61592.rs +++ b/tests/rustdoc/underscore-import-61592.rs @@ -4,14 +4,14 @@ extern crate foo; -// @has bar/index.html -// @has - '//a[@href="#reexports"]' 'Re-exports' -// @has - '//code' 'pub use foo::FooTrait as _;' -// @!has - '//a[@href="trait._.html"]' '' +//@ has bar/index.html +//@ has - '//a[@href="#reexports"]' 'Re-exports' +//@ has - '//code' 'pub use foo::FooTrait as _;' +//@ !has - '//a[@href="trait._.html"]' '' pub use foo::FooTrait as _; -// @has bar/index.html -// @has - '//a[@href="#reexports"]' 'Re-exports' -// @has - '//code' 'pub use foo::FooStruct as _;' -// @!has - '//a[@href="struct._.html"]' '' +//@ has bar/index.html +//@ has - '//a[@href="#reexports"]' 'Re-exports' +//@ has - '//code' 'pub use foo::FooStruct as _;' +//@ !has - '//a[@href="struct._.html"]' '' pub use foo::FooStruct as _; diff --git a/tests/rustdoc/unindent.rs b/tests/rustdoc/unindent.rs index 372af5f4672..f9787b076c1 100644 --- a/tests/rustdoc/unindent.rs +++ b/tests/rustdoc/unindent.rs @@ -1,7 +1,7 @@ #![crate_name = "foo"] -// @has foo/struct.Example.html -// @matches - '//pre[@class="rust rust-example-rendered"]' \ +//@ has foo/struct.Example.html +//@ matches - '//pre[@class="rust rust-example-rendered"]' \ // '(?m)let example = Example::new\(\)\n \.first\(\)\n \.second\(\)\n \.build\(\);\Z' /// ```rust /// let example = Example::new() @@ -11,8 +11,8 @@ /// ``` pub struct Example; -// @has foo/struct.F.html -// @matches - '//pre[@class="rust rust-example-rendered"]' \ +//@ has foo/struct.F.html +//@ matches - '//pre[@class="rust rust-example-rendered"]' \ // '(?m)let example = Example::new\(\)\n \.first\(\)\n \.another\(\)\n \.build\(\);\Z' ///```rust ///let example = Example::new() @@ -22,8 +22,8 @@ pub struct Example; /// ``` pub struct F; -// @has foo/struct.G.html -// @matches - '//pre[@class="rust rust-example-rendered"]' \ +//@ has foo/struct.G.html +//@ matches - '//pre[@class="rust rust-example-rendered"]' \ // '(?m)let example = Example::new\(\)\n\.first\(\)\n \.another\(\)\n\.build\(\);\Z' ///```rust ///let example = Example::new() @@ -33,27 +33,27 @@ pub struct F; ///``` pub struct G; -// @has foo/struct.H.html -// @has - '//div[@class="docblock"]/p' 'no whitespace lol' +//@ has foo/struct.H.html +//@ has - '//div[@class="docblock"]/p' 'no whitespace lol' ///no whitespace #[doc = " lol"] pub struct H; -// @has foo/struct.I.html -// @matches - '//pre[@class="rust rust-example-rendered"]' '(?m)4 whitespaces!\Z' +//@ has foo/struct.I.html +//@ matches - '//pre[@class="rust rust-example-rendered"]' '(?m)4 whitespaces!\Z' /// 4 whitespaces! #[doc = "something"] pub struct I; -// @has foo/struct.J.html -// @matches - '//div[@class="docblock"]/p' '(?m)a\nno whitespace\nJust some text.\Z' +//@ has foo/struct.J.html +//@ matches - '//div[@class="docblock"]/p' '(?m)a\nno whitespace\nJust some text.\Z' ///a ///no whitespace #[doc = include_str!("unindent.md")] pub struct J; -// @has foo/struct.K.html -// @matches - '//pre[@class="rust rust-example-rendered"]' '(?m)4 whitespaces!\Z' +//@ has foo/struct.K.html +//@ matches - '//pre[@class="rust rust-example-rendered"]' '(?m)4 whitespaces!\Z' ///a /// /// 4 whitespaces! diff --git a/tests/rustdoc/union-fields-html.rs b/tests/rustdoc/union-fields-html.rs index 1ac01232c3e..8550980b896 100644 --- a/tests/rustdoc/union-fields-html.rs +++ b/tests/rustdoc/union-fields-html.rs @@ -1,9 +1,9 @@ #![crate_name = "foo"] -// @has 'foo/union.Union.html' +//@ has 'foo/union.Union.html' // Checking that there is a whitespace after `:`. -// @has - '//*[@id="structfield.a"]/code' 'a: u8' -// @has - '//*[@id="structfield.b"]/code' 'b: u32' +//@ has - '//*[@id="structfield.a"]/code' 'a: u8' +//@ has - '//*[@id="structfield.b"]/code' 'b: u32' pub union Union { pub a: u8, /// tadam diff --git a/tests/rustdoc/union.rs b/tests/rustdoc/union.rs index 5a788eb1b1c..a3c046ec7c1 100644 --- a/tests/rustdoc/union.rs +++ b/tests/rustdoc/union.rs @@ -1,8 +1,8 @@ -// @has union/union.U.html +//@ has union/union.U.html pub union U { - // @has - //pre "pub a: u8" + //@ has - //pre "pub a: u8" pub a: u8, - // @has - //pre "/* private fields */" - // @!has - //pre "b: u16" + //@ has - //pre "/* private fields */" + //@ !has - //pre "b: u16" b: u16, } diff --git a/tests/rustdoc/unit-return.rs b/tests/rustdoc/unit-return.rs index 47a3e6d490b..2b3e6414ae5 100644 --- a/tests/rustdoc/unit-return.rs +++ b/tests/rustdoc/unit-return.rs @@ -4,14 +4,14 @@ extern crate unit_return; -// @has 'foo/fn.f0.html' '//pre[@class="rust item-decl"]' 'F: FnMut(u8) + Clone' +//@ has 'foo/fn.f0.html' '//pre[@class="rust item-decl"]' 'F: FnMut(u8) + Clone' pub fn f0<F: FnMut(u8) + Clone>(f: F) {} -// @has 'foo/fn.f1.html' '//pre[@class="rust item-decl"]' 'F: FnMut(u16) + Clone' +//@ has 'foo/fn.f1.html' '//pre[@class="rust item-decl"]' 'F: FnMut(u16) + Clone' pub fn f1<F: FnMut(u16) -> () + Clone>(f: F) {} -// @has 'foo/fn.f2.html' '//pre[@class="rust item-decl"]' 'F: FnMut(u32) + Clone' +//@ has 'foo/fn.f2.html' '//pre[@class="rust item-decl"]' 'F: FnMut(u32) + Clone' pub use unit_return::f2; -// @has 'foo/fn.f3.html' '//pre[@class="rust item-decl"]' 'F: FnMut(u64) + Clone' +//@ has 'foo/fn.f3.html' '//pre[@class="rust item-decl"]' 'F: FnMut(u64) + Clone' pub use unit_return::f3; diff --git a/tests/rustdoc/universal-impl-trait.rs b/tests/rustdoc/universal-impl-trait.rs index f5eabda59b7..b78d69c0690 100644 --- a/tests/rustdoc/universal-impl-trait.rs +++ b/tests/rustdoc/universal-impl-trait.rs @@ -3,17 +3,17 @@ use std::io::Read; use std::borrow::Borrow; -// @has foo/fn.foo.html -// @has - //pre 'foo(' -// @matchesraw - '_x: impl <a class="trait" href="[^"]+/trait\.Clone\.html"' -// @matchesraw - '_z: .+impl.+trait\.Copy\.html.+, impl.+trait\.Clone\.html' +//@ has foo/fn.foo.html +//@ has - //pre 'foo(' +//@ matchesraw - '_x: impl <a class="trait" href="[^"]+/trait\.Clone\.html"' +//@ matchesraw - '_z: .+impl.+trait\.Copy\.html.+, impl.+trait\.Clone\.html' pub fn foo(_x: impl Clone, _y: i32, _z: (impl Copy, impl Clone)) { } pub trait Trait { - // @has foo/trait.Trait.html - // @hasraw - 'method</a>(' - // @matchesraw - '_x: impl <a class="trait" href="[^"]+/trait\.Debug\.html"' + //@ has foo/trait.Trait.html + //@ hasraw - 'method</a>(' + //@ matchesraw - '_x: impl <a class="trait" href="[^"]+/trait\.Debug\.html"' fn method(&self, _x: impl std::fmt::Debug) { } } @@ -21,31 +21,31 @@ pub trait Trait { pub struct S<T>(T); impl<T> S<T> { - // @has foo/struct.S.html - // @hasraw - 'bar</a>(' - // @matchesraw - '_bar: impl <a class="trait" href="[^"]+/trait\.Copy\.html"' + //@ has foo/struct.S.html + //@ hasraw - 'bar</a>(' + //@ matchesraw - '_bar: impl <a class="trait" href="[^"]+/trait\.Copy\.html"' pub fn bar(_bar: impl Copy) { } - // @hasraw - 'baz</a>(' - // @matchesraw - '_baz:.+struct\.S\.html.+impl .+trait\.Clone\.html' + //@ hasraw - 'baz</a>(' + //@ matchesraw - '_baz:.+struct\.S\.html.+impl .+trait\.Clone\.html' pub fn baz(_baz: S<impl Clone>) { } - // @hasraw - 'qux</a>(' - // @matchesraw - 'trait\.Read\.html' + //@ hasraw - 'qux</a>(' + //@ matchesraw - 'trait\.Read\.html' pub fn qux(_qux: impl IntoIterator<Item = S<impl Read>>) { } } -// @hasraw - 'method</a>(' -// @matchesraw - '_x: impl <a class="trait" href="[^"]+/trait\.Debug\.html"' +//@ hasraw - 'method</a>(' +//@ matchesraw - '_x: impl <a class="trait" href="[^"]+/trait\.Debug\.html"' impl<T> Trait for S<T> {} -// @has foo/fn.much_universe.html -// @matchesraw - 'T:.+Borrow.+impl .+trait\.Trait\.html' -// @matchesraw - 'U:.+IntoIterator.+= impl.+Iterator\.html.+= impl.+Clone\.html' -// @matchesraw - '_: impl .+trait\.Read\.html.+ \+ .+trait\.Clone\.html' +//@ has foo/fn.much_universe.html +//@ matchesraw - 'T:.+Borrow.+impl .+trait\.Trait\.html' +//@ matchesraw - 'U:.+IntoIterator.+= impl.+Iterator\.html.+= impl.+Clone\.html' +//@ matchesraw - '_: impl .+trait\.Read\.html.+ \+ .+trait\.Clone\.html' pub fn much_universe< T: Borrow<impl Trait>, U: IntoIterator<Item = impl Iterator<Item = impl Clone>>, diff --git a/tests/rustdoc/unneeded-trait-implementations-title.rs b/tests/rustdoc/unneeded-trait-implementations-title.rs index e1bcfd3b97e..f7a97dfaaef 100644 --- a/tests/rustdoc/unneeded-trait-implementations-title.rs +++ b/tests/rustdoc/unneeded-trait-implementations-title.rs @@ -2,4 +2,4 @@ pub struct Bar; -// @count foo/struct.Bar.html '//*[@id="implementations"]' 0 +//@ count foo/struct.Bar.html '//*[@id="implementations"]' 0 diff --git a/tests/rustdoc/use-attr.rs b/tests/rustdoc/use-attr.rs index 68e44bdfdc4..82d696991a6 100644 --- a/tests/rustdoc/use-attr.rs +++ b/tests/rustdoc/use-attr.rs @@ -2,7 +2,7 @@ // ICE when rustdoc encountered a use statement of a non-macro attribute (see #58054) -// @has use_attr/index.html -// @has - '//code' 'pub use proc_macro_attribute' +//@ has use_attr/index.html +//@ has - '//code' 'pub use proc_macro_attribute' pub use proc_macro_attribute; use proc_macro_derive; diff --git a/tests/rustdoc/useless_lifetime_bound.rs b/tests/rustdoc/useless_lifetime_bound.rs index f530d8a654f..68d55eec10c 100644 --- a/tests/rustdoc/useless_lifetime_bound.rs +++ b/tests/rustdoc/useless_lifetime_bound.rs @@ -1,13 +1,13 @@ use std::marker::PhantomData; -// @has useless_lifetime_bound/struct.Scope.html -// @!has - '//*[@class="rust struct"]' "'env: 'env" +//@ has useless_lifetime_bound/struct.Scope.html +//@ !has - '//*[@class="rust struct"]' "'env: 'env" pub struct Scope<'env> { _marker: PhantomData<&'env mut &'env ()>, } -// @has useless_lifetime_bound/struct.Scope.html -// @!has - '//*[@class="rust struct"]' "T: 'a + 'a" +//@ has useless_lifetime_bound/struct.Scope.html +//@ !has - '//*[@class="rust struct"]' "T: 'a + 'a" pub struct SomeStruct<'a, T: 'a> { _marker: PhantomData<&'a T>, } diff --git a/tests/rustdoc/variadic.rs b/tests/rustdoc/variadic.rs index bd8f1775b3d..8bf40464eff 100644 --- a/tests/rustdoc/variadic.rs +++ b/tests/rustdoc/variadic.rs @@ -1,4 +1,4 @@ extern "C" { - // @has variadic/fn.foo.html //pre 'pub unsafe extern "C" fn foo(x: i32, ...)' + //@ has variadic/fn.foo.html //pre 'pub unsafe extern "C" fn foo(x: i32, ...)' pub fn foo(x: i32, ...); } diff --git a/tests/rustdoc/version-separator-without-source.rs b/tests/rustdoc/version-separator-without-source.rs index 4a855b7bb29..e439681484c 100644 --- a/tests/rustdoc/version-separator-without-source.rs +++ b/tests/rustdoc/version-separator-without-source.rs @@ -3,21 +3,21 @@ #![stable(feature = "bar", since = "1.0")] #![crate_name = "foo"] -// @has foo/fn.foo.html -// @has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.0 · ' -// @!has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.0 · source · ' +//@ has foo/fn.foo.html +//@ has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.0 · ' +//@ !has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.0 · source · ' #[stable(feature = "bar", since = "1.0")] pub fn foo() {} -// @has foo/struct.Bar.html -// @has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.0 · ' -// @!has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.0 · source · ' +//@ has foo/struct.Bar.html +//@ has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.0 · ' +//@ !has - '//div[@class="main-heading"]/*[@class="out-of-band"]' '1.0.0 · source · ' #[stable(feature = "bar", since = "1.0")] pub struct Bar; impl Bar { - // @has - '//*[@id="method.bar"]/*[@class="since rightside"]' '2.0.0' - // @!has - '//*[@id="method.bar"]/*[@class="rightside"]' '2.0.0 ·' + //@ has - '//*[@id="method.bar"]/*[@class="since rightside"]' '2.0.0' + //@ !has - '//*[@id="method.bar"]/*[@class="rightside"]' '2.0.0 ·' #[stable(feature = "foobar", since = "2.0")] pub fn bar() {} } diff --git a/tests/rustdoc/viewpath-rename.rs b/tests/rustdoc/viewpath-rename.rs index 54612763792..c2dcd1033b6 100644 --- a/tests/rustdoc/viewpath-rename.rs +++ b/tests/rustdoc/viewpath-rename.rs @@ -9,13 +9,13 @@ pub enum Maybe<A> { Nothing } -// @has foo/prelude/index.html +//@ has foo/prelude/index.html pub mod prelude { - // @has foo/prelude/index.html '//code' 'pub use io as FooIo;' - // @has foo/prelude/index.html '//code' 'pub use io::Reader as FooReader;' + //@ has foo/prelude/index.html '//code' 'pub use io as FooIo;' + //@ has foo/prelude/index.html '//code' 'pub use io::Reader as FooReader;' #[doc(no_inline)] pub use io::{self as FooIo, Reader as FooReader}; - // @has foo/prelude/index.html '//code' 'pub use Maybe;' - // @has foo/prelude/index.html '//code' 'pub use Maybe::Just as MaybeJust;' - // @has foo/prelude/index.html '//code' 'pub use Maybe::Nothing;' + //@ has foo/prelude/index.html '//code' 'pub use Maybe;' + //@ has foo/prelude/index.html '//code' 'pub use Maybe::Just as MaybeJust;' + //@ has foo/prelude/index.html '//code' 'pub use Maybe::Nothing;' #[doc(no_inline)] pub use Maybe::{self, Just as MaybeJust, Nothing}; } diff --git a/tests/rustdoc/viewpath-self.rs b/tests/rustdoc/viewpath-self.rs index a6b6592955f..5e998be6abe 100644 --- a/tests/rustdoc/viewpath-self.rs +++ b/tests/rustdoc/viewpath-self.rs @@ -9,13 +9,13 @@ pub enum Maybe<A> { Nothing } -// @has foo/prelude/index.html +//@ has foo/prelude/index.html pub mod prelude { - // @has foo/prelude/index.html '//code' 'pub use io;' - // @has foo/prelude/index.html '//code' 'pub use io::Reader;' + //@ has foo/prelude/index.html '//code' 'pub use io;' + //@ has foo/prelude/index.html '//code' 'pub use io::Reader;' #[doc(no_inline)] pub use io::{self, Reader}; - // @has foo/prelude/index.html '//code' 'pub use Maybe;' - // @has foo/prelude/index.html '//code' 'pub use Maybe::Just;' - // @has foo/prelude/index.html '//code' 'pub use Maybe::Nothing;' + //@ has foo/prelude/index.html '//code' 'pub use Maybe;' + //@ has foo/prelude/index.html '//code' 'pub use Maybe::Just;' + //@ has foo/prelude/index.html '//code' 'pub use Maybe::Nothing;' #[doc(no_inline)] pub use Maybe::{self, Just, Nothing}; } diff --git a/tests/rustdoc/visibility.rs b/tests/rustdoc/visibility.rs index 87ac9a9b74d..b6a757e5047 100644 --- a/tests/rustdoc/visibility.rs +++ b/tests/rustdoc/visibility.rs @@ -4,83 +4,83 @@ #![feature(inherent_associated_types)] #![allow(incomplete_features)] -// @!has 'foo/index.html' '//a[@href="struct.FooPublic.html"]/..' 'FooPublic 🔒' -// @has 'foo/struct.FooPublic.html' '//pre' 'pub struct FooPublic' +//@ !has 'foo/index.html' '//a[@href="struct.FooPublic.html"]/..' 'FooPublic 🔒' +//@ has 'foo/struct.FooPublic.html' '//pre' 'pub struct FooPublic' pub struct FooPublic; -// @has 'foo/index.html' '//a[@href="struct.FooJustCrate.html"]/..' 'FooJustCrate 🔒' -// @has 'foo/struct.FooJustCrate.html' '//pre' 'pub(crate) struct FooJustCrate' +//@ has 'foo/index.html' '//a[@href="struct.FooJustCrate.html"]/..' 'FooJustCrate 🔒' +//@ has 'foo/struct.FooJustCrate.html' '//pre' 'pub(crate) struct FooJustCrate' pub(crate) struct FooJustCrate; -// @has 'foo/index.html' '//a[@href="struct.FooPubCrate.html"]/..' 'FooPubCrate 🔒' -// @has 'foo/struct.FooPubCrate.html' '//pre' 'pub(crate) struct FooPubCrate' +//@ has 'foo/index.html' '//a[@href="struct.FooPubCrate.html"]/..' 'FooPubCrate 🔒' +//@ has 'foo/struct.FooPubCrate.html' '//pre' 'pub(crate) struct FooPubCrate' pub(crate) struct FooPubCrate; -// @has 'foo/index.html' '//a[@href="struct.FooSelf.html"]/..' 'FooSelf 🔒' -// @has 'foo/struct.FooSelf.html' '//pre' 'pub(crate) struct FooSelf' +//@ has 'foo/index.html' '//a[@href="struct.FooSelf.html"]/..' 'FooSelf 🔒' +//@ has 'foo/struct.FooSelf.html' '//pre' 'pub(crate) struct FooSelf' pub(self) struct FooSelf; -// @has 'foo/index.html' '//a[@href="struct.FooInSelf.html"]/..' 'FooInSelf 🔒' -// @has 'foo/struct.FooInSelf.html' '//pre' 'pub(crate) struct FooInSelf' +//@ has 'foo/index.html' '//a[@href="struct.FooInSelf.html"]/..' 'FooInSelf 🔒' +//@ has 'foo/struct.FooInSelf.html' '//pre' 'pub(crate) struct FooInSelf' pub(in self) struct FooInSelf; -// @has 'foo/index.html' '//a[@href="struct.FooPriv.html"]/..' 'FooPriv 🔒' -// @has 'foo/struct.FooPriv.html' '//pre' 'pub(crate) struct FooPriv' +//@ has 'foo/index.html' '//a[@href="struct.FooPriv.html"]/..' 'FooPriv 🔒' +//@ has 'foo/struct.FooPriv.html' '//pre' 'pub(crate) struct FooPriv' struct FooPriv; -// @!has 'foo/index.html' '//a[@href="pub_mod/index.html"]/..' 'pub_mod 🔒' +//@ !has 'foo/index.html' '//a[@href="pub_mod/index.html"]/..' 'pub_mod 🔒' pub mod pub_mod {} -// @has 'foo/index.html' '//a[@href="pub_crate_mod/index.html"]/..' 'pub_crate_mod 🔒' +//@ has 'foo/index.html' '//a[@href="pub_crate_mod/index.html"]/..' 'pub_crate_mod 🔒' pub(crate) mod pub_crate_mod {} -// @has 'foo/index.html' '//a[@href="a/index.html"]/..' 'a 🔒' +//@ has 'foo/index.html' '//a[@href="a/index.html"]/..' 'a 🔒' mod a { - // @has 'foo/a/index.html' '//a[@href="struct.FooASuper.html"]/..' 'FooASuper 🔒' - // @has 'foo/a/struct.FooASuper.html' '//pre' 'pub(crate) struct FooASuper' + //@ has 'foo/a/index.html' '//a[@href="struct.FooASuper.html"]/..' 'FooASuper 🔒' + //@ has 'foo/a/struct.FooASuper.html' '//pre' 'pub(crate) struct FooASuper' pub(super) struct FooASuper; - // @has 'foo/a/index.html' '//a[@href="struct.FooAInSuper.html"]/..' 'FooAInSuper 🔒' - // @has 'foo/a/struct.FooAInSuper.html' '//pre' 'pub(crate) struct FooAInSuper' + //@ has 'foo/a/index.html' '//a[@href="struct.FooAInSuper.html"]/..' 'FooAInSuper 🔒' + //@ has 'foo/a/struct.FooAInSuper.html' '//pre' 'pub(crate) struct FooAInSuper' pub(in super) struct FooAInSuper; - // @has 'foo/a/index.html' '//a[@href="struct.FooAInA.html"]/..' 'FooAInA 🔒' - // @has 'foo/a/struct.FooAInA.html' '//pre' 'struct FooAInA' - // @!has 'foo/a/struct.FooAInA.html' '//pre' 'pub' + //@ has 'foo/a/index.html' '//a[@href="struct.FooAInA.html"]/..' 'FooAInA 🔒' + //@ has 'foo/a/struct.FooAInA.html' '//pre' 'struct FooAInA' + //@ !has 'foo/a/struct.FooAInA.html' '//pre' 'pub' pub(in a) struct FooAInA; - // @has 'foo/a/index.html' '//a[@href="struct.FooAPriv.html"]/..' 'FooAPriv 🔒' - // @has 'foo/a/struct.FooAPriv.html' '//pre' 'struct FooAPriv' - // @!has 'foo/a/struct.FooAPriv.html' '//pre' 'pub' + //@ has 'foo/a/index.html' '//a[@href="struct.FooAPriv.html"]/..' 'FooAPriv 🔒' + //@ has 'foo/a/struct.FooAPriv.html' '//pre' 'struct FooAPriv' + //@ !has 'foo/a/struct.FooAPriv.html' '//pre' 'pub' struct FooAPriv; - // @has 'foo/a/index.html' '//a[@href="b/index.html"]/..' 'b 🔒' + //@ has 'foo/a/index.html' '//a[@href="b/index.html"]/..' 'b 🔒' mod b { - // @has 'foo/a/b/index.html' '//a[@href="struct.FooBSuper.html"]/..' 'FooBSuper 🔒' - // @has 'foo/a/b/struct.FooBSuper.html' '//pre' 'pub(super) struct FooBSuper' + //@ has 'foo/a/b/index.html' '//a[@href="struct.FooBSuper.html"]/..' 'FooBSuper 🔒' + //@ has 'foo/a/b/struct.FooBSuper.html' '//pre' 'pub(super) struct FooBSuper' pub(super) struct FooBSuper; - // @has 'foo/a/b/index.html' '//a[@href="struct.FooBInSuperSuper.html"]/..' 'FooBInSuperSuper 🔒' - // @has 'foo/a/b/struct.FooBInSuperSuper.html' '//pre' 'pub(crate) struct FooBInSuperSuper' + //@ has 'foo/a/b/index.html' '//a[@href="struct.FooBInSuperSuper.html"]/..' 'FooBInSuperSuper 🔒' + //@ has 'foo/a/b/struct.FooBInSuperSuper.html' '//pre' 'pub(crate) struct FooBInSuperSuper' pub(in super::super) struct FooBInSuperSuper; - // @has 'foo/a/b/index.html' '//a[@href="struct.FooBInAB.html"]/..' 'FooBInAB 🔒' - // @has 'foo/a/b/struct.FooBInAB.html' '//pre' 'struct FooBInAB' - // @!has 'foo/a/b/struct.FooBInAB.html' '//pre' 'pub' + //@ has 'foo/a/b/index.html' '//a[@href="struct.FooBInAB.html"]/..' 'FooBInAB 🔒' + //@ has 'foo/a/b/struct.FooBInAB.html' '//pre' 'struct FooBInAB' + //@ !has 'foo/a/b/struct.FooBInAB.html' '//pre' 'pub' pub(in a::b) struct FooBInAB; - // @has 'foo/a/b/index.html' '//a[@href="struct.FooBPriv.html"]/..' 'FooBPriv 🔒' - // @has 'foo/a/b/struct.FooBPriv.html' '//pre' 'struct FooBPriv' - // @!has 'foo/a/b/struct.FooBPriv.html' '//pre' 'pub' + //@ has 'foo/a/b/index.html' '//a[@href="struct.FooBPriv.html"]/..' 'FooBPriv 🔒' + //@ has 'foo/a/b/struct.FooBPriv.html' '//pre' 'struct FooBPriv' + //@ !has 'foo/a/b/struct.FooBPriv.html' '//pre' 'pub' struct FooBPriv; - // @!has 'foo/a/b/index.html' '//a[@href="struct.FooBPub.html"]/..' 'FooBPub 🔒' - // @has 'foo/a/b/struct.FooBPub.html' '//pre' 'pub struct FooBPub' + //@ !has 'foo/a/b/index.html' '//a[@href="struct.FooBPub.html"]/..' 'FooBPub 🔒' + //@ has 'foo/a/b/struct.FooBPub.html' '//pre' 'pub struct FooBPub' pub struct FooBPub; } } -// @has 'foo/trait.PubTrait.html' '//pre' 'pub trait PubTrait' +//@ has 'foo/trait.PubTrait.html' '//pre' 'pub trait PubTrait' // -// @has 'foo/trait.PubTrait.html' '//pre' 'type Type;' -// @!has 'foo/trait.PubTrait.html' '//pre' 'pub type Type;' +//@ has 'foo/trait.PubTrait.html' '//pre' 'type Type;' +//@ !has 'foo/trait.PubTrait.html' '//pre' 'pub type Type;' // -// @has 'foo/trait.PubTrait.html' '//pre' 'const CONST: usize;' -// @!has 'foo/trait.PubTrait.html' '//pre' 'pub const CONST: usize;' +//@ has 'foo/trait.PubTrait.html' '//pre' 'const CONST: usize;' +//@ !has 'foo/trait.PubTrait.html' '//pre' 'pub const CONST: usize;' // -// @has 'foo/trait.PubTrait.html' '//pre' 'fn function();' -// @!has 'foo/trait.PubTrait.html' '//pre' 'pub fn function();' +//@ has 'foo/trait.PubTrait.html' '//pre' 'fn function();' +//@ !has 'foo/trait.PubTrait.html' '//pre' 'pub fn function();' // -// @!has 'foo/index.html' '//a[@href="trait.PubTrait.html"]/..' 'PubTrait 🔒' +//@ !has 'foo/index.html' '//a[@href="trait.PubTrait.html"]/..' 'PubTrait 🔒' pub trait PubTrait { type Type; @@ -88,17 +88,17 @@ pub trait PubTrait { fn function(); } -// @has 'foo/index.html' '//a[@href="trait.PrivTrait.html"]/..' 'PrivTrait 🔒' +//@ has 'foo/index.html' '//a[@href="trait.PrivTrait.html"]/..' 'PrivTrait 🔒' trait PrivTrait {} -// @has 'foo/struct.FooPublic.html' '//h4[@class="code-header"]' 'type Type' -// @!has 'foo/struct.FooPublic.html' '//h4[@class="code-header"]' 'pub type Type' +//@ has 'foo/struct.FooPublic.html' '//h4[@class="code-header"]' 'type Type' +//@ !has 'foo/struct.FooPublic.html' '//h4[@class="code-header"]' 'pub type Type' // -// @has 'foo/struct.FooPublic.html' '//h4[@class="code-header"]' 'const CONST: usize' -// @!has 'foo/struct.FooPublic.html' '//h4[@class="code-header"]' 'pub const CONST: usize' +//@ has 'foo/struct.FooPublic.html' '//h4[@class="code-header"]' 'const CONST: usize' +//@ !has 'foo/struct.FooPublic.html' '//h4[@class="code-header"]' 'pub const CONST: usize' // -// @has 'foo/struct.FooPublic.html' '//h4[@class="code-header"]' 'fn function()' -// @!has 'foo/struct.FooPublic.html' '//h4[@class="code-header"]' 'pub fn function()' +//@ has 'foo/struct.FooPublic.html' '//h4[@class="code-header"]' 'fn function()' +//@ !has 'foo/struct.FooPublic.html' '//h4[@class="code-header"]' 'pub fn function()' impl PubTrait for FooPublic { type Type = usize; @@ -108,23 +108,23 @@ impl PubTrait for FooPublic { pub struct Assoc; -// @has foo/struct.Assoc.html +//@ has foo/struct.Assoc.html impl Assoc { - // @has - '//*[@id="associatedtype.TypePub"]' 'pub type TypePub' + //@ has - '//*[@id="associatedtype.TypePub"]' 'pub type TypePub' pub type TypePub = usize; - // @has - '//*[@id="associatedtype.TypePriv"]' 'pub(crate) type TypePriv' + //@ has - '//*[@id="associatedtype.TypePriv"]' 'pub(crate) type TypePriv' type TypePriv = usize; - // @has - '//*[@id="associatedconstant.CONST_PUB"]' 'pub const CONST_PUB' + //@ has - '//*[@id="associatedconstant.CONST_PUB"]' 'pub const CONST_PUB' pub const CONST_PUB: usize = 0; - // @has - '//*[@id="associatedconstant.CONST_PRIV"]' 'pub(crate) const CONST_PRIV' + //@ has - '//*[@id="associatedconstant.CONST_PRIV"]' 'pub(crate) const CONST_PRIV' const CONST_PRIV: usize = 0; - // @has - '//*[@id="method.function_pub"]' 'pub fn function_pub()' + //@ has - '//*[@id="method.function_pub"]' 'pub fn function_pub()' pub fn function_pub() {} - // @has - '//*[@id="method.function_priv"]' 'pub(crate) fn function_priv()' + //@ has - '//*[@id="method.function_priv"]' 'pub(crate) fn function_priv()' fn function_priv() {} } diff --git a/tests/rustdoc/where-clause-order.rs b/tests/rustdoc/where-clause-order.rs index e3184b646bf..d765fc10c72 100644 --- a/tests/rustdoc/where-clause-order.rs +++ b/tests/rustdoc/where-clause-order.rs @@ -6,8 +6,8 @@ where { } -// @has 'foo/trait.SomeTrait.html' -// @has - "//*[@id='impl-SomeTrait-for-(A,+B,+C,+D,+E)']/h3" "impl<A, B, C, D, E> SomeTrait for (A, B, C, D, E)where A: PartialOrd<A> + PartialEq<A>, B: PartialOrd<B> + PartialEq<B>, C: PartialOrd<C> + PartialEq<C>, D: PartialOrd<D> + PartialEq<D>, E: PartialOrd<E> + PartialEq<E> + ?Sized, " +//@ has 'foo/trait.SomeTrait.html' +//@ has - "//*[@id='impl-SomeTrait-for-(A,+B,+C,+D,+E)']/h3" "impl<A, B, C, D, E> SomeTrait for (A, B, C, D, E)where A: PartialOrd<A> + PartialEq<A>, B: PartialOrd<B> + PartialEq<B>, C: PartialOrd<C> + PartialEq<C>, D: PartialOrd<D> + PartialEq<D>, E: PartialOrd<E> + PartialEq<E> + ?Sized, " impl<A, B, C, D, E> SomeTrait<(A, B, C, D, E)> for (A, B, C, D, E) where A: PartialOrd<A> + PartialEq<A>, @@ -18,7 +18,7 @@ where { } -// @has - "//*[@id='impl-SomeTrait%3C(A,+B,+C,+D)%3E-for-(A,+B,+C,+D,+E)']/h3" "impl<A, B, C, D, E> SomeTrait<(A, B, C, D)> for (A, B, C, D, E)where A: PartialOrd<A> + PartialEq<A>, B: PartialOrd<B> + PartialEq<B>, C: PartialOrd<C> + PartialEq<C>, D: PartialOrd<D> + PartialEq<D>, E: PartialOrd<E> + PartialEq<E> + ?Sized, " +//@ has - "//*[@id='impl-SomeTrait%3C(A,+B,+C,+D)%3E-for-(A,+B,+C,+D,+E)']/h3" "impl<A, B, C, D, E> SomeTrait<(A, B, C, D)> for (A, B, C, D, E)where A: PartialOrd<A> + PartialEq<A>, B: PartialOrd<B> + PartialEq<B>, C: PartialOrd<C> + PartialEq<C>, D: PartialOrd<D> + PartialEq<D>, E: PartialOrd<E> + PartialEq<E> + ?Sized, " impl<A, B, C, D, E> SomeTrait<(A, B, C, D)> for (A, B, C, D, E) where A: PartialOrd<A> + PartialEq<A>, diff --git a/tests/rustdoc/where-sized.rs b/tests/rustdoc/where-sized.rs index c1ac834b2fc..28907de68d6 100644 --- a/tests/rustdoc/where-sized.rs +++ b/tests/rustdoc/where-sized.rs @@ -1,6 +1,6 @@ #![crate_name = "foo"] -// @has foo/fn.foo.html -// @has - '//pre[@class="rust item-decl"]' 'pub fn foo<X, Y: ?Sized>(_: &X)' -// @has - '//pre[@class="rust item-decl"]' 'where X: ?Sized,' +//@ has foo/fn.foo.html +//@ has - '//pre[@class="rust item-decl"]' 'pub fn foo<X, Y: ?Sized>(_: &X)' +//@ has - '//pre[@class="rust item-decl"]' 'where X: ?Sized,' pub fn foo<X, Y: ?Sized>(_: &X) where X: ?Sized {} diff --git a/tests/rustdoc/where.rs b/tests/rustdoc/where.rs index aea02c14039..aa1d61a0a18 100644 --- a/tests/rustdoc/where.rs +++ b/tests/rustdoc/where.rs @@ -4,35 +4,35 @@ use std::io::Lines; pub trait MyTrait { fn dummy(&self) { } } -// @has foo/struct.Alpha.html '//pre' "pub struct Alpha<A>(/* private fields */) where A: MyTrait" -// @snapshot alpha_trait_decl - '//*[@class="rust item-decl"]/code' +//@ has foo/struct.Alpha.html '//pre' "pub struct Alpha<A>(/* private fields */) where A: MyTrait" +//@ snapshot alpha_trait_decl - '//*[@class="rust item-decl"]/code' pub struct Alpha<A>(A) where A: MyTrait; -// @has foo/trait.Bravo.html '//pre' "pub trait Bravo<B>where B: MyTrait" -// @snapshot bravo_trait_decl - '//*[@class="rust item-decl"]/code' +//@ has foo/trait.Bravo.html '//pre' "pub trait Bravo<B>where B: MyTrait" +//@ snapshot bravo_trait_decl - '//*[@class="rust item-decl"]/code' pub trait Bravo<B> where B: MyTrait { fn get(&self, B: B); } -// @has foo/fn.charlie.html '//pre' "pub fn charlie<C>()where C: MyTrait" -// @snapshot charlie_fn_decl - '//*[@class="rust item-decl"]/code' +//@ has foo/fn.charlie.html '//pre' "pub fn charlie<C>()where C: MyTrait" +//@ snapshot charlie_fn_decl - '//*[@class="rust item-decl"]/code' pub fn charlie<C>() where C: MyTrait {} pub struct Delta<D>(D); -// @has foo/struct.Delta.html '//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has foo/struct.Delta.html '//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<D> Delta<D>where D: MyTrait" -// @snapshot SWhere_Echo_impl - '//*[@id="impl-Delta%3CD%3E"]/h3[@class="code-header"]' +//@ snapshot SWhere_Echo_impl - '//*[@id="impl-Delta%3CD%3E"]/h3[@class="code-header"]' impl<D> Delta<D> where D: MyTrait { pub fn delta() {} } pub struct Echo<E>(E); -// @has 'foo/struct.Simd.html' -// @snapshot SWhere_Simd_item-decl - '//pre[@class="rust item-decl"]' +//@ has 'foo/struct.Simd.html' +//@ snapshot SWhere_Simd_item-decl - '//pre[@class="rust item-decl"]' pub struct Simd<T>([T; 1]) where T: MyTrait; -// @has 'foo/trait.TraitWhere.html' -// @snapshot SWhere_TraitWhere_item-decl - '//pre[@class="rust item-decl"]' +//@ has 'foo/trait.TraitWhere.html' +//@ snapshot SWhere_TraitWhere_item-decl - '//pre[@class="rust item-decl"]' pub trait TraitWhere { type Item<'a> where Self: 'a; @@ -53,21 +53,21 @@ pub trait TraitWhere { { todo!() } } -// @has foo/struct.Echo.html '//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has foo/struct.Echo.html '//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<E> MyTrait for Echo<E>where E: MyTrait" -// @has foo/trait.MyTrait.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ +//@ has foo/trait.MyTrait.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ // "impl<E> MyTrait for Echo<E>where E: MyTrait" impl<E> MyTrait for Echo<E>where E: MyTrait {} pub enum Foxtrot<F> { Foxtrot1(F) } -// @has foo/enum.Foxtrot.html '//*[@class="impl"]//h3[@class="code-header"]' \ +//@ has foo/enum.Foxtrot.html '//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<F> MyTrait for Foxtrot<F>where F: MyTrait" -// @has foo/trait.MyTrait.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ +//@ has foo/trait.MyTrait.html '//*[@id="implementors-list"]//h3[@class="code-header"]' \ // "impl<F> MyTrait for Foxtrot<F>where F: MyTrait" impl<F> MyTrait for Foxtrot<F>where F: MyTrait {} -// @has foo/type.Golf.html '//pre[@class="rust item-decl"]' \ +//@ has foo/type.Golf.html '//pre[@class="rust item-decl"]' \ // "type Golf<T>where T: Clone, = (T, T)" -// @snapshot golf_type_alias_decl - '//*[@class="rust item-decl"]/code' +//@ snapshot golf_type_alias_decl - '//*[@class="rust item-decl"]/code' pub type Golf<T> where T: Clone = (T, T); diff --git a/tests/rustdoc/whitespace-after-where-clause.rs b/tests/rustdoc/whitespace-after-where-clause.rs index 832d3728e75..d1a45c7a768 100644 --- a/tests/rustdoc/whitespace-after-where-clause.rs +++ b/tests/rustdoc/whitespace-after-where-clause.rs @@ -3,8 +3,8 @@ #![crate_name = "foo"] -// @has 'foo/trait.ToOwned.html' -// @snapshot trait - '//*[@class="rust item-decl"]' +//@ has 'foo/trait.ToOwned.html' +//@ snapshot trait - '//*[@class="rust item-decl"]' pub trait ToOwned<T> where T: Clone, @@ -14,8 +14,8 @@ where fn whatever(&self) -> T; } -// @has 'foo/trait.ToOwned2.html' -// @snapshot trait2 - '//*[@class="rust item-decl"]' +//@ has 'foo/trait.ToOwned2.html' +//@ snapshot trait2 - '//*[@class="rust item-decl"]' // There should be a whitespace before `{` in this case! pub trait ToOwned2<T: Clone> { type Owned; @@ -23,8 +23,8 @@ pub trait ToOwned2<T: Clone> { fn whatever(&self) -> T; } -// @has 'foo/enum.Cow.html' -// @snapshot enum - '//*[@class="rust item-decl"]' +//@ has 'foo/enum.Cow.html' +//@ snapshot enum - '//*[@class="rust item-decl"]' pub enum Cow<'a, B: ?Sized + 'a> where B: ToOwned<()>, @@ -33,16 +33,16 @@ where Whatever(u32), } -// @has 'foo/enum.Cow2.html' -// @snapshot enum2 - '//*[@class="rust item-decl"]' +//@ has 'foo/enum.Cow2.html' +//@ snapshot enum2 - '//*[@class="rust item-decl"]' // There should be a whitespace before `{` in this case! pub enum Cow2<'a, B: ?Sized + ToOwned<()> + 'a> { Borrowed(&'a B), Whatever(u32), } -// @has 'foo/struct.Struct.html' -// @snapshot struct - '//*[@class="rust item-decl"]' +//@ has 'foo/struct.Struct.html' +//@ snapshot struct - '//*[@class="rust item-decl"]' pub struct Struct<'a, B: ?Sized + 'a> where B: ToOwned<()>, @@ -51,16 +51,16 @@ where pub b: u32, } -// @has 'foo/struct.Struct2.html' -// @snapshot struct2 - '//*[@class="rust item-decl"]' +//@ has 'foo/struct.Struct2.html' +//@ snapshot struct2 - '//*[@class="rust item-decl"]' // There should be a whitespace before `{` in this case! pub struct Struct2<'a, B: ?Sized + ToOwned<()> + 'a> { pub a: &'a B, pub b: u32, } -// @has 'foo/union.Union.html' -// @snapshot union - '//*[@class="rust item-decl"]' +//@ has 'foo/union.Union.html' +//@ snapshot union - '//*[@class="rust item-decl"]' pub union Union<'a, B: ?Sized + 'a> where B: ToOwned<()>, @@ -69,8 +69,8 @@ where b: u32, } -// @has 'foo/union.Union2.html' -// @snapshot union2 - '//*[@class="rust item-decl"]' +//@ has 'foo/union.Union2.html' +//@ snapshot union2 - '//*[@class="rust item-decl"]' // There should be a whitespace before `{` in this case! pub union Union2<'a, B: ?Sized + ToOwned<()> + 'a> { a: &'a B, diff --git a/tests/rustdoc/without-redirect.rs b/tests/rustdoc/without-redirect.rs index a076f8a3c5e..f8a332a5dd7 100644 --- a/tests/rustdoc/without-redirect.rs +++ b/tests/rustdoc/without-redirect.rs @@ -1,13 +1,13 @@ #![crate_name = "foo"] -// @has foo/macro.bar.html -// @has foo/macro.bar!.html -// @!has foo/bar.m.html +//@ has foo/macro.bar.html +//@ has foo/macro.bar!.html +//@ !has foo/bar.m.html #[macro_export] macro_rules! bar { () => {} } -// @has foo/struct.Bar.html -// @!has foo/Bar.t.html +//@ has foo/struct.Bar.html +//@ !has foo/Bar.t.html pub struct Bar; diff --git a/tests/rustdoc/wrapping.rs b/tests/rustdoc/wrapping.rs index dd5c700329f..43146c73dd0 100644 --- a/tests/rustdoc/wrapping.rs +++ b/tests/rustdoc/wrapping.rs @@ -1,5 +1,5 @@ use std::fmt::Debug; -// @has 'wrapping/fn.foo.html' '//pre[@class="rust item-decl"]' 'pub fn foo() -> impl Debug' -// @count - '//pre[@class="rust item-decl"]/br' 0 +//@ has 'wrapping/fn.foo.html' '//pre[@class="rust item-decl"]' 'pub fn foo() -> impl Debug' +//@ count - '//pre[@class="rust item-decl"]/br' 0 pub fn foo() -> impl Debug {} diff --git a/tests/ui/async-await/async-is-unwindsafe.stderr b/tests/ui/async-await/async-is-unwindsafe.stderr index 5d87fc74768..85fdcda3b8c 100644 --- a/tests/ui/async-await/async-is-unwindsafe.stderr +++ b/tests/ui/async-await/async-is-unwindsafe.stderr @@ -2,9 +2,8 @@ error[E0277]: the type `&mut Context<'_>` may not be safely transferred across a --> $DIR/async-is-unwindsafe.rs:12:5 | LL | is_unwindsafe(async { - | _____^_____________- - | |_____| - | || + | ______^ - + | | ___________________| LL | || LL | || use std::ptr::null; LL | || use std::task::{Context, RawWaker, RawWakerVTable, Waker}; diff --git a/tests/ui/attributes/key-value-expansion-scope-pass.rs b/tests/ui/attributes/key-value-expansion-scope-pass.rs new file mode 100644 index 00000000000..6b1f4e5bd4b --- /dev/null +++ b/tests/ui/attributes/key-value-expansion-scope-pass.rs @@ -0,0 +1,18 @@ +// Imports suppress the `out_of_scope_macro_calls` lint. + +//@ check-pass +//@ edition:2018 + +#![doc = in_root!()] + +macro_rules! in_root { () => { "" } } +use in_root; + +mod macros_stay { + #![doc = in_mod!()] + + macro_rules! in_mod { () => { "" } } + use in_mod; +} + +fn main() {} diff --git a/tests/ui/attributes/key-value-expansion-scope.rs b/tests/ui/attributes/key-value-expansion-scope.rs index b84fe4873c3..b6eab1571d4 100644 --- a/tests/ui/attributes/key-value-expansion-scope.rs +++ b/tests/ui/attributes/key-value-expansion-scope.rs @@ -1,6 +1,8 @@ -#![doc = in_root!()] // FIXME, this is a bug +#![doc = in_root!()] //~ WARN cannot find macro `in_root` in this scope + //~| WARN this was previously accepted by the compiler #![doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope -#![doc = in_mod_escape!()] // FIXME, this is a bug +#![doc = in_mod_escape!()] //~ WARN cannot find macro `in_mod_escape` in this scope + //~| WARN this was previously accepted by the compiler #![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope #[doc = in_root!()] //~ ERROR cannot find macro `in_root` in this scope @@ -16,8 +18,11 @@ fn before() { macro_rules! in_root { () => { "" } } +#[doc = in_mod!()] //~ WARN cannot find macro `in_mod` in this scope + //~| WARN this was previously accepted by the compiler mod macros_stay { - #![doc = in_mod!()] // FIXME, this is a bug + #![doc = in_mod!()] //~ WARN cannot find macro `in_mod` in this scope + //~| WARN this was previously accepted by the compiler macro_rules! in_mod { () => { "" } } @@ -28,8 +33,11 @@ mod macros_stay { } #[macro_use] +#[doc = in_mod_escape!()] //~ WARN cannot find macro `in_mod_escape` in this scope + //~| WARN this was previously accepted by the compiler mod macros_escape { - #![doc = in_mod_escape!()] // FIXME, this is a bug + #![doc = in_mod_escape!()] //~ WARN cannot find macro `in_mod_escape` in this scope + //~| WARN this was previously accepted by the compiler macro_rules! in_mod_escape { () => { "" } } @@ -39,8 +47,9 @@ mod macros_escape { } } +#[doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope fn block() { - #![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope + #![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope macro_rules! in_block { () => { "" } } diff --git a/tests/ui/attributes/key-value-expansion-scope.stderr b/tests/ui/attributes/key-value-expansion-scope.stderr index a66ee9b17fb..d22fef7dd25 100644 --- a/tests/ui/attributes/key-value-expansion-scope.stderr +++ b/tests/ui/attributes/key-value-expansion-scope.stderr @@ -1,5 +1,5 @@ error: cannot find macro `in_mod` in this scope - --> $DIR/key-value-expansion-scope.rs:2:10 + --> $DIR/key-value-expansion-scope.rs:3:10 | LL | #![doc = in_mod!()] | ^^^^^^ @@ -7,7 +7,7 @@ LL | #![doc = in_mod!()] = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_block` in this scope - --> $DIR/key-value-expansion-scope.rs:4:10 + --> $DIR/key-value-expansion-scope.rs:6:10 | LL | #![doc = in_block!()] | ^^^^^^^^ @@ -15,7 +15,7 @@ LL | #![doc = in_block!()] = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_root` in this scope - --> $DIR/key-value-expansion-scope.rs:6:9 + --> $DIR/key-value-expansion-scope.rs:8:9 | LL | #[doc = in_root!()] | ^^^^^^^ @@ -23,7 +23,7 @@ LL | #[doc = in_root!()] = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_mod` in this scope - --> $DIR/key-value-expansion-scope.rs:7:9 + --> $DIR/key-value-expansion-scope.rs:9:9 | LL | #[doc = in_mod!()] | ^^^^^^ @@ -31,7 +31,7 @@ LL | #[doc = in_mod!()] = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_mod_escape` in this scope - --> $DIR/key-value-expansion-scope.rs:8:9 + --> $DIR/key-value-expansion-scope.rs:10:9 | LL | #[doc = in_mod_escape!()] | ^^^^^^^^^^^^^ @@ -39,7 +39,7 @@ LL | #[doc = in_mod_escape!()] = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_block` in this scope - --> $DIR/key-value-expansion-scope.rs:9:9 + --> $DIR/key-value-expansion-scope.rs:11:9 | LL | #[doc = in_block!()] | ^^^^^^^^ @@ -47,7 +47,7 @@ LL | #[doc = in_block!()] = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_root` in this scope - --> $DIR/key-value-expansion-scope.rs:11:14 + --> $DIR/key-value-expansion-scope.rs:13:14 | LL | #![doc = in_root!()] | ^^^^^^^ @@ -55,7 +55,7 @@ LL | #![doc = in_root!()] = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_mod` in this scope - --> $DIR/key-value-expansion-scope.rs:12:14 + --> $DIR/key-value-expansion-scope.rs:14:14 | LL | #![doc = in_mod!()] | ^^^^^^ @@ -63,7 +63,7 @@ LL | #![doc = in_mod!()] = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_mod_escape` in this scope - --> $DIR/key-value-expansion-scope.rs:13:14 + --> $DIR/key-value-expansion-scope.rs:15:14 | LL | #![doc = in_mod_escape!()] | ^^^^^^^^^^^^^ @@ -71,7 +71,7 @@ LL | #![doc = in_mod_escape!()] = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_block` in this scope - --> $DIR/key-value-expansion-scope.rs:14:14 + --> $DIR/key-value-expansion-scope.rs:16:14 | LL | #![doc = in_block!()] | ^^^^^^^^ @@ -79,7 +79,15 @@ LL | #![doc = in_block!()] = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_block` in this scope - --> $DIR/key-value-expansion-scope.rs:43:14 + --> $DIR/key-value-expansion-scope.rs:50:9 + | +LL | #[doc = in_block!()] + | ^^^^^^^^ + | + = help: have you added the `#[macro_use]` on the module/import? + +error: cannot find macro `in_block` in this scope + --> $DIR/key-value-expansion-scope.rs:52:14 | LL | #![doc = in_block!()] | ^^^^^^^^ @@ -87,7 +95,7 @@ LL | #![doc = in_block!()] = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_mod` in this scope - --> $DIR/key-value-expansion-scope.rs:54:9 + --> $DIR/key-value-expansion-scope.rs:63:9 | LL | #[doc = in_mod!()] | ^^^^^^ @@ -95,7 +103,7 @@ LL | #[doc = in_mod!()] = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_block` in this scope - --> $DIR/key-value-expansion-scope.rs:56:9 + --> $DIR/key-value-expansion-scope.rs:65:9 | LL | #[doc = in_block!()] | ^^^^^^^^ @@ -103,7 +111,7 @@ LL | #[doc = in_block!()] = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_mod` in this scope - --> $DIR/key-value-expansion-scope.rs:59:14 + --> $DIR/key-value-expansion-scope.rs:68:14 | LL | #![doc = in_mod!()] | ^^^^^^ @@ -111,12 +119,73 @@ LL | #![doc = in_mod!()] = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_block` in this scope - --> $DIR/key-value-expansion-scope.rs:61:14 + --> $DIR/key-value-expansion-scope.rs:70:14 | LL | #![doc = in_block!()] | ^^^^^^^^ | = help: have you added the `#[macro_use]` on the module/import? -error: aborting due to 15 previous errors +warning: cannot find macro `in_root` in this scope + --> $DIR/key-value-expansion-scope.rs:1:10 + | +LL | #![doc = in_root!()] + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535> + = help: import `macro_rules` with `use` to make it callable above its definition + = note: `#[warn(out_of_scope_macro_calls)]` on by default + +warning: cannot find macro `in_mod_escape` in this scope + --> $DIR/key-value-expansion-scope.rs:4:10 + | +LL | #![doc = in_mod_escape!()] + | ^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535> + = help: import `macro_rules` with `use` to make it callable above its definition + +warning: cannot find macro `in_mod` in this scope + --> $DIR/key-value-expansion-scope.rs:21:9 + | +LL | #[doc = in_mod!()] + | ^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535> + = help: import `macro_rules` with `use` to make it callable above its definition + +warning: cannot find macro `in_mod` in this scope + --> $DIR/key-value-expansion-scope.rs:24:14 + | +LL | #![doc = in_mod!()] + | ^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535> + = help: import `macro_rules` with `use` to make it callable above its definition + +warning: cannot find macro `in_mod_escape` in this scope + --> $DIR/key-value-expansion-scope.rs:36:9 + | +LL | #[doc = in_mod_escape!()] + | ^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535> + = help: import `macro_rules` with `use` to make it callable above its definition + +warning: cannot find macro `in_mod_escape` in this scope + --> $DIR/key-value-expansion-scope.rs:39:14 + | +LL | #![doc = in_mod_escape!()] + | ^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #124535 <https://github.com/rust-lang/rust/issues/124535> + = help: import `macro_rules` with `use` to make it callable above its definition + +error: aborting due to 16 previous errors; 6 warnings emitted diff --git a/tests/ui/codegen/issue-82833-slice-miscompile.rs b/tests/ui/codegen/issue-82833-slice-miscompile.rs index 7723679dab1..32eac923a63 100644 --- a/tests/ui/codegen/issue-82833-slice-miscompile.rs +++ b/tests/ui/codegen/issue-82833-slice-miscompile.rs @@ -1,5 +1,5 @@ //@ run-pass -//@ compile-flags: -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Copt-level=0 -Cdebuginfo=2 +//@ compile-flags: -Ccodegen-units=1 -Cllvm-args=--inline-threshold=0 -Clink-dead-code -Copt-level=0 -Cdebuginfo=2 // Make sure LLVM does not miscompile this. diff --git a/tests/ui/consts/const-blocks/fn-call-in-non-const.stderr b/tests/ui/consts/const-blocks/fn-call-in-non-const.stderr index 14bce10f787..9dce29732ac 100644 --- a/tests/ui/consts/const-blocks/fn-call-in-non-const.stderr +++ b/tests/ui/consts/const-blocks/fn-call-in-non-const.stderr @@ -6,17 +6,15 @@ LL | let _: [Option<Bar>; 2] = [no_copy(); 2]; | = note: required for `Option<Bar>` to implement `Copy` = note: the `Copy` trait is required because this value will be copied for each element of the array - = help: create an inline `const` block, see RFC #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information help: consider annotating `Bar` with `#[derive(Copy)]` | LL + #[derive(Copy)] LL | struct Bar; | -help: consider creating a new `const` item and initializing it with the result of the function call to be used in the repeat position - | -LL ~ const ARRAY_REPEAT_VALUE: Option<Bar> = no_copy(); -LL ~ let _: [Option<Bar>; 2] = [ARRAY_REPEAT_VALUE; 2]; +help: create an inline `const` block | +LL | let _: [Option<Bar>; 2] = [const { no_copy() }; 2]; + | ~~~~~~~~~~~~~~~~~~~ error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-blocks/trait-error.stderr b/tests/ui/consts/const-blocks/trait-error.stderr index b0b1378bb7d..8f00f14dfb9 100644 --- a/tests/ui/consts/const-blocks/trait-error.stderr +++ b/tests/ui/consts/const-blocks/trait-error.stderr @@ -2,7 +2,10 @@ error[E0277]: the trait bound `String: Copy` is not satisfied --> $DIR/trait-error.rs:5:6 | LL | [Foo(String::new()); 4]; - | ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`, which is required by `Foo<String>: Copy` + | ^^^^^^^^^^^^^^^^^^ + | | + | the trait `Copy` is not implemented for `String`, which is required by `Foo<String>: Copy` + | help: create an inline `const` block: `const { Foo(String::new()) }` | note: required for `Foo<String>` to implement `Copy` --> $DIR/trait-error.rs:1:10 @@ -10,13 +13,7 @@ note: required for `Foo<String>` to implement `Copy` LL | #[derive(Copy, Clone)] | ^^^^ unsatisfied trait bound introduced in this `derive` macro = note: the `Copy` trait is required because this value will be copied for each element of the array - = help: create an inline `const` block, see RFC #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info) -help: consider creating a new `const` item and initializing it with the result of the function call to be used in the repeat position - | -LL ~ const ARRAY_REPEAT_VALUE: Foo<String> = Foo(String::new()); -LL ~ [ARRAY_REPEAT_VALUE; 4]; - | error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-fn-in-vec.stderr b/tests/ui/consts/const-fn-in-vec.stderr index 12098e8199c..7c6b3bee940 100644 --- a/tests/ui/consts/const-fn-in-vec.stderr +++ b/tests/ui/consts/const-fn-in-vec.stderr @@ -2,45 +2,36 @@ error[E0277]: the trait bound `String: Copy` is not satisfied --> $DIR/const-fn-in-vec.rs:1:47 | LL | static _MAYBE_STRINGS: [Option<String>; 5] = [None; 5]; - | ^^^^ the trait `Copy` is not implemented for `String`, which is required by `Option<String>: Copy` + | ^^^^ + | | + | the trait `Copy` is not implemented for `String`, which is required by `Option<String>: Copy` + | help: create an inline `const` block: `const { None }` | = note: required for `Option<String>` to implement `Copy` = note: the `Copy` trait is required because this value will be copied for each element of the array - = help: create an inline `const` block, see RFC #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information -help: consider creating a new `const` item and initializing it with the result of the constructor to be used in the repeat position - | -LL + const ARRAY_REPEAT_VALUE: Option<String> = None; -LL ~ static _MAYBE_STRINGS: [Option<String>; 5] = [ARRAY_REPEAT_VALUE; 5]; - | error[E0277]: the trait bound `String: Copy` is not satisfied --> $DIR/const-fn-in-vec.rs:7:34 | LL | let _strings: [String; 5] = [String::new(); 5]; - | ^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` + | ^^^^^^^^^^^^^ + | | + | the trait `Copy` is not implemented for `String` + | help: create an inline `const` block: `const { String::new() }` | = note: the `Copy` trait is required because this value will be copied for each element of the array - = help: create an inline `const` block, see RFC #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information -help: consider creating a new `const` item and initializing it with the result of the function call to be used in the repeat position - | -LL ~ const ARRAY_REPEAT_VALUE: String = String::new(); -LL ~ let _strings: [String; 5] = [ARRAY_REPEAT_VALUE; 5]; - | error[E0277]: the trait bound `String: Copy` is not satisfied --> $DIR/const-fn-in-vec.rs:9:48 | LL | let _maybe_strings: [Option<String>; 5] = [None; 5]; - | ^^^^ the trait `Copy` is not implemented for `String`, which is required by `Option<String>: Copy` + | ^^^^ + | | + | the trait `Copy` is not implemented for `String`, which is required by `Option<String>: Copy` + | help: create an inline `const` block: `const { None }` | = note: required for `Option<String>` to implement `Copy` = note: the `Copy` trait is required because this value will be copied for each element of the array - = help: create an inline `const` block, see RFC #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information -help: consider creating a new `const` item and initializing it with the result of the constructor to be used in the repeat position - | -LL ~ const ARRAY_REPEAT_VALUE: Option<String> = None; -LL ~ let _maybe_strings: [Option<String>; 5] = [ARRAY_REPEAT_VALUE; 5]; - | error: aborting due to 3 previous errors diff --git a/tests/ui/coverage-attr/bad-syntax.rs b/tests/ui/coverage-attr/bad-syntax.rs index 127179877e5..c8c92de8c38 100644 --- a/tests/ui/coverage-attr/bad-syntax.rs +++ b/tests/ui/coverage-attr/bad-syntax.rs @@ -1,58 +1,45 @@ #![feature(coverage_attribute)] +//@ edition: 2021 // Tests the error messages produced (or not produced) by various unusual // uses of the `#[coverage(..)]` attribute. -// FIXME(#126658): Multiple coverage attributes with the same value are useless, -// and should probably produce a diagnostic. -#[coverage(off)] +#[coverage(off)] //~ ERROR multiple `coverage` attributes #[coverage(off)] fn multiple_consistent() {} -// FIXME(#126658): When there are multiple inconsistent coverage attributes, -// it's unclear which one will prevail. -#[coverage(off)] +#[coverage(off)] //~ ERROR multiple `coverage` attributes #[coverage(on)] fn multiple_inconsistent() {} -#[coverage] //~ ERROR expected `coverage(off)` or `coverage(on)` +#[coverage] //~ ERROR malformed `coverage` attribute input fn bare_word() {} -// FIXME(#126658): This shows as multiple different errors, one of which suggests -// writing bare `#[coverage]`, which is not allowed. -#[coverage = true] -//~^ ERROR expected `coverage(off)` or `coverage(on)` -//~| ERROR malformed `coverage` attribute input -//~| HELP the following are the possible correct uses -//~| SUGGESTION #[coverage(on|off)] +#[coverage = true] //~ ERROR malformed `coverage` attribute input fn key_value() {} -#[coverage()] //~ ERROR expected `coverage(off)` or `coverage(on)` +#[coverage()] //~ ERROR malformed `coverage` attribute input fn list_empty() {} -#[coverage(off, off)] //~ ERROR expected `coverage(off)` or `coverage(on)` +#[coverage(off, off)] //~ ERROR malformed `coverage` attribute input fn list_consistent() {} -#[coverage(off, on)] //~ ERROR expected `coverage(off)` or `coverage(on)` +#[coverage(off, on)] //~ ERROR malformed `coverage` attribute input fn list_inconsistent() {} -#[coverage(bogus)] //~ ERROR expected `coverage(off)` or `coverage(on)` +#[coverage(bogus)] //~ ERROR malformed `coverage` attribute input fn bogus_word() {} -#[coverage(bogus, off)] //~ ERROR expected `coverage(off)` or `coverage(on)` +#[coverage(bogus, off)] //~ ERROR malformed `coverage` attribute input fn bogus_word_before() {} -#[coverage(off, bogus)] //~ ERROR expected `coverage(off)` or `coverage(on)` +#[coverage(off, bogus)] //~ ERROR malformed `coverage` attribute input fn bogus_word_after() {} -#[coverage(off,)] +#[coverage(off,)] // (OK!) fn comma_after() {} -// FIXME(#126658): This shows as multiple different errors. -#[coverage(,off)] -//~^ ERROR expected identifier, found `,` -//~| HELP remove this comma -//~| ERROR expected `coverage(off)` or `coverage(on)` +#[coverage(,off)] //~ ERROR expected identifier, found `,` fn comma_before() {} fn main() {} diff --git a/tests/ui/coverage-attr/bad-syntax.stderr b/tests/ui/coverage-attr/bad-syntax.stderr index f6181d12a94..a5868fcf19c 100644 --- a/tests/ui/coverage-attr/bad-syntax.stderr +++ b/tests/ui/coverage-attr/bad-syntax.stderr @@ -1,78 +1,139 @@ error: malformed `coverage` attribute input - --> $DIR/bad-syntax.rs:23:1 - | -LL | #[coverage = true] - | ^^^^^^^^^^^^^^^^^^ - | -help: the following are the possible correct uses - | -LL | #[coverage(on|off)] + --> $DIR/bad-syntax.rs:15:1 | LL | #[coverage] + | ^^^^^^^^^^^ | - -error: expected identifier, found `,` - --> $DIR/bad-syntax.rs:52:12 +help: the following are the possible correct uses | -LL | #[coverage(,off)] - | ^ - | | - | expected identifier - | help: remove this comma +LL | #[coverage(off)] + | ~~~~~~~~~~~~~~~~ +LL | #[coverage(on)] + | ~~~~~~~~~~~~~~~ -error: expected `coverage(off)` or `coverage(on)` +error: malformed `coverage` attribute input --> $DIR/bad-syntax.rs:18:1 | -LL | #[coverage] - | ^^^^^^^^^^^ - -error: expected `coverage(off)` or `coverage(on)` - --> $DIR/bad-syntax.rs:23:1 - | LL | #[coverage = true] | ^^^^^^^^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[coverage(off)] + | ~~~~~~~~~~~~~~~~ +LL | #[coverage(on)] + | ~~~~~~~~~~~~~~~ -error: expected `coverage(off)` or `coverage(on)` - --> $DIR/bad-syntax.rs:30:1 +error: malformed `coverage` attribute input + --> $DIR/bad-syntax.rs:21:1 | LL | #[coverage()] | ^^^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[coverage(off)] + | ~~~~~~~~~~~~~~~~ +LL | #[coverage(on)] + | ~~~~~~~~~~~~~~~ -error: expected `coverage(off)` or `coverage(on)` - --> $DIR/bad-syntax.rs:33:1 +error: malformed `coverage` attribute input + --> $DIR/bad-syntax.rs:24:1 | LL | #[coverage(off, off)] | ^^^^^^^^^^^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[coverage(off)] + | ~~~~~~~~~~~~~~~~ +LL | #[coverage(on)] + | ~~~~~~~~~~~~~~~ -error: expected `coverage(off)` or `coverage(on)` - --> $DIR/bad-syntax.rs:36:1 +error: malformed `coverage` attribute input + --> $DIR/bad-syntax.rs:27:1 | LL | #[coverage(off, on)] | ^^^^^^^^^^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[coverage(off)] + | ~~~~~~~~~~~~~~~~ +LL | #[coverage(on)] + | ~~~~~~~~~~~~~~~ -error: expected `coverage(off)` or `coverage(on)` - --> $DIR/bad-syntax.rs:39:1 +error: malformed `coverage` attribute input + --> $DIR/bad-syntax.rs:30:1 | LL | #[coverage(bogus)] | ^^^^^^^^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[coverage(off)] + | ~~~~~~~~~~~~~~~~ +LL | #[coverage(on)] + | ~~~~~~~~~~~~~~~ -error: expected `coverage(off)` or `coverage(on)` - --> $DIR/bad-syntax.rs:42:1 +error: malformed `coverage` attribute input + --> $DIR/bad-syntax.rs:33:1 | LL | #[coverage(bogus, off)] | ^^^^^^^^^^^^^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[coverage(off)] + | ~~~~~~~~~~~~~~~~ +LL | #[coverage(on)] + | ~~~~~~~~~~~~~~~ -error: expected `coverage(off)` or `coverage(on)` - --> $DIR/bad-syntax.rs:45:1 +error: malformed `coverage` attribute input + --> $DIR/bad-syntax.rs:36:1 | LL | #[coverage(off, bogus)] | ^^^^^^^^^^^^^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[coverage(off)] + | ~~~~~~~~~~~~~~~~ +LL | #[coverage(on)] + | ~~~~~~~~~~~~~~~ -error: expected `coverage(off)` or `coverage(on)` - --> $DIR/bad-syntax.rs:52:1 +error: expected identifier, found `,` + --> $DIR/bad-syntax.rs:42:12 | LL | #[coverage(,off)] - | ^^^^^^^^^^^^^^^^^ + | ^ + | | + | expected identifier + | help: remove this comma + +error: multiple `coverage` attributes + --> $DIR/bad-syntax.rs:7:1 + | +LL | #[coverage(off)] + | ^^^^^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/bad-syntax.rs:8:1 + | +LL | #[coverage(off)] + | ^^^^^^^^^^^^^^^^ + +error: multiple `coverage` attributes + --> $DIR/bad-syntax.rs:11:1 + | +LL | #[coverage(off)] + | ^^^^^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/bad-syntax.rs:12:1 + | +LL | #[coverage(on)] + | ^^^^^^^^^^^^^^^ error: aborting due to 11 previous errors diff --git a/tests/ui/coverage-attr/name-value.rs b/tests/ui/coverage-attr/name-value.rs index 24c329780c5..cfd78a03e43 100644 --- a/tests/ui/coverage-attr/name-value.rs +++ b/tests/ui/coverage-attr/name-value.rs @@ -8,57 +8,62 @@ // and in places that cannot have a coverage attribute, to demonstrate the // interaction between multiple errors. -// FIXME(#126658): The error messages for using this syntax are inconsistent -// with the error message in other cases. They also sometimes appear together -// with other errors, and they suggest using the incorrect `#[coverage]` syntax. - -#[coverage = "off"] //~ ERROR malformed `coverage` attribute input +#[coverage = "off"] +//~^ ERROR malformed `coverage` attribute input +//~| ERROR attribute should be applied to a function definition or closure mod my_mod {} mod my_mod_inner { - #![coverage = "off"] //~ ERROR malformed `coverage` attribute input + #![coverage = "off"] + //~^ ERROR malformed `coverage` attribute input + //~| ERROR attribute should be applied to a function definition or closure } #[coverage = "off"] -//~^ ERROR `#[coverage]` must be applied to coverable code -//~| ERROR malformed `coverage` attribute input +//~^ ERROR malformed `coverage` attribute input +//~| ERROR attribute should be applied to a function definition or closure struct MyStruct; -#[coverage = "off"] //~ ERROR malformed `coverage` attribute input +#[coverage = "off"] +//~^ ERROR malformed `coverage` attribute input +//~| ERROR attribute should be applied to a function definition or closure impl MyStruct { #[coverage = "off"] - //~^ ERROR `#[coverage]` must be applied to coverable code - //~| ERROR malformed `coverage` attribute input + //~^ ERROR malformed `coverage` attribute input + //~| ERROR attribute should be applied to a function definition or closure const X: u32 = 7; } -#[coverage = "off"] //~ ERROR malformed `coverage` attribute input +#[coverage = "off"] +//~^ ERROR malformed `coverage` attribute input +//~| ERROR attribute should be applied to a function definition or closure trait MyTrait { #[coverage = "off"] - //~^ ERROR `#[coverage]` must be applied to coverable code - //~| ERROR malformed `coverage` attribute input + //~^ ERROR malformed `coverage` attribute input + //~| ERROR attribute should be applied to a function definition or closure const X: u32; #[coverage = "off"] - //~^ ERROR `#[coverage]` must be applied to coverable code - //~| ERROR malformed `coverage` attribute input + //~^ ERROR malformed `coverage` attribute input + //~| ERROR attribute should be applied to a function definition or closure type T; } -#[coverage = "off"] //~ ERROR malformed `coverage` attribute input +#[coverage = "off"] +//~^ ERROR malformed `coverage` attribute input +//~| ERROR attribute should be applied to a function definition or closure impl MyTrait for MyStruct { #[coverage = "off"] - //~^ ERROR `#[coverage]` must be applied to coverable code - //~| ERROR malformed `coverage` attribute input + //~^ ERROR malformed `coverage` attribute input + //~| ERROR attribute should be applied to a function definition or closure const X: u32 = 8; #[coverage = "off"] - //~^ ERROR `#[coverage]` must be applied to coverable code - //~| ERROR malformed `coverage` attribute input + //~^ ERROR malformed `coverage` attribute input + //~| ERROR attribute should be applied to a function definition or closure type T = (); } #[coverage = "off"] -//~^ ERROR expected `coverage(off)` or `coverage(on)` -//~| ERROR malformed `coverage` attribute input +//~^ ERROR malformed `coverage` attribute input fn main() {} diff --git a/tests/ui/coverage-attr/name-value.stderr b/tests/ui/coverage-attr/name-value.stderr index 90bc3a3b53b..caac687c94d 100644 --- a/tests/ui/coverage-attr/name-value.stderr +++ b/tests/ui/coverage-attr/name-value.stderr @@ -1,28 +1,28 @@ error: malformed `coverage` attribute input - --> $DIR/name-value.rs:15:1 + --> $DIR/name-value.rs:11:1 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ | help: the following are the possible correct uses | -LL | #[coverage(on|off)] - | ~~~~~~~~~~~~~~~~~~~ -LL | #[coverage] - | ~~~~~~~~~~~ +LL | #[coverage(off)] + | +LL | #[coverage(on)] + | error: malformed `coverage` attribute input - --> $DIR/name-value.rs:19:5 + --> $DIR/name-value.rs:17:5 | LL | #![coverage = "off"] | ^^^^^^^^^^^^^^^^^^^^ | help: the following are the possible correct uses | -LL | #![coverage(on|off)] - | ~~~~~~~~~~~~~~~~~~~~ -LL | #![coverage] - | ~~~~~~~~~~~~ +LL | #![coverage(off)] + | +LL | #![coverage(on)] + | error: malformed `coverage` attribute input --> $DIR/name-value.rs:22:1 @@ -32,22 +32,22 @@ LL | #[coverage = "off"] | help: the following are the possible correct uses | -LL | #[coverage(on|off)] +LL | #[coverage(off)] | -LL | #[coverage] +LL | #[coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/name-value.rs:29:5 + --> $DIR/name-value.rs:31:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ | help: the following are the possible correct uses | -LL | #[coverage(on|off)] +LL | #[coverage(off)] | -LL | #[coverage] +LL | #[coverage(on)] | error: malformed `coverage` attribute input @@ -58,162 +58,220 @@ LL | #[coverage = "off"] | help: the following are the possible correct uses | -LL | #[coverage(on|off)] - | ~~~~~~~~~~~~~~~~~~~ -LL | #[coverage] - | ~~~~~~~~~~~ +LL | #[coverage(off)] + | +LL | #[coverage(on)] + | error: malformed `coverage` attribute input - --> $DIR/name-value.rs:37:5 + --> $DIR/name-value.rs:41:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ | help: the following are the possible correct uses | -LL | #[coverage(on|off)] +LL | #[coverage(off)] | -LL | #[coverage] +LL | #[coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/name-value.rs:42:5 + --> $DIR/name-value.rs:46:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ | help: the following are the possible correct uses | -LL | #[coverage(on|off)] +LL | #[coverage(off)] | -LL | #[coverage] +LL | #[coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/name-value.rs:35:1 + --> $DIR/name-value.rs:37:1 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ | help: the following are the possible correct uses | -LL | #[coverage(on|off)] - | ~~~~~~~~~~~~~~~~~~~ -LL | #[coverage] - | ~~~~~~~~~~~ +LL | #[coverage(off)] + | +LL | #[coverage(on)] + | error: malformed `coverage` attribute input - --> $DIR/name-value.rs:50:5 + --> $DIR/name-value.rs:56:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ | help: the following are the possible correct uses | -LL | #[coverage(on|off)] +LL | #[coverage(off)] | -LL | #[coverage] +LL | #[coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/name-value.rs:55:5 + --> $DIR/name-value.rs:61:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ | help: the following are the possible correct uses | -LL | #[coverage(on|off)] +LL | #[coverage(off)] | -LL | #[coverage] +LL | #[coverage(on)] | error: malformed `coverage` attribute input - --> $DIR/name-value.rs:48:1 + --> $DIR/name-value.rs:52:1 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ | help: the following are the possible correct uses | -LL | #[coverage(on|off)] - | ~~~~~~~~~~~~~~~~~~~ -LL | #[coverage] - | ~~~~~~~~~~~ +LL | #[coverage(off)] + | +LL | #[coverage(on)] + | error: malformed `coverage` attribute input - --> $DIR/name-value.rs:61:1 + --> $DIR/name-value.rs:67:1 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ | help: the following are the possible correct uses | -LL | #[coverage(on|off)] +LL | #[coverage(off)] | -LL | #[coverage] +LL | #[coverage(on)] + | + +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/name-value.rs:11:1 | +LL | #[coverage = "off"] + | ^^^^^^^^^^^^^^^^^^^ +... +LL | mod my_mod {} + | ------------- not a function or closure -error[E0788]: `#[coverage]` must be applied to coverable code +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/name-value.rs:17:5 + | +LL | / mod my_mod_inner { +LL | | #![coverage = "off"] + | | ^^^^^^^^^^^^^^^^^^^^ +LL | | +LL | | +LL | | } + | |_- not a function or closure + +error[E0788]: attribute should be applied to a function definition or closure --> $DIR/name-value.rs:22:1 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ ... LL | struct MyStruct; - | ---------------- not coverable code + | ---------------- not a function or closure + +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/name-value.rs:27:1 + | +LL | #[coverage = "off"] + | ^^^^^^^^^^^^^^^^^^^ +... +LL | / impl MyStruct { +LL | | #[coverage = "off"] +LL | | +LL | | +LL | | const X: u32 = 7; +LL | | } + | |_- not a function or closure + +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/name-value.rs:37:1 + | +LL | #[coverage = "off"] + | ^^^^^^^^^^^^^^^^^^^ +... +LL | / trait MyTrait { +LL | | #[coverage = "off"] +LL | | +LL | | +... | +LL | | type T; +LL | | } + | |_- not a function or closure -error[E0788]: `#[coverage]` must be applied to coverable code - --> $DIR/name-value.rs:37:5 +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/name-value.rs:52:1 + | +LL | #[coverage = "off"] + | ^^^^^^^^^^^^^^^^^^^ +... +LL | / impl MyTrait for MyStruct { +LL | | #[coverage = "off"] +LL | | +LL | | +... | +LL | | type T = (); +LL | | } + | |_- not a function or closure + +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/name-value.rs:41:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ ... LL | const X: u32; - | ------------- not coverable code + | ------------- not a function or closure -error[E0788]: `#[coverage]` must be applied to coverable code - --> $DIR/name-value.rs:42:5 +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/name-value.rs:46:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ ... LL | type T; - | ------- not coverable code + | ------- not a function or closure -error[E0788]: `#[coverage]` must be applied to coverable code - --> $DIR/name-value.rs:29:5 +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/name-value.rs:31:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ ... LL | const X: u32 = 7; - | ----------------- not coverable code + | ----------------- not a function or closure -error[E0788]: `#[coverage]` must be applied to coverable code - --> $DIR/name-value.rs:50:5 +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/name-value.rs:56:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ ... LL | const X: u32 = 8; - | ----------------- not coverable code + | ----------------- not a function or closure -error[E0788]: `#[coverage]` must be applied to coverable code - --> $DIR/name-value.rs:55:5 +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/name-value.rs:61:5 | LL | #[coverage = "off"] | ^^^^^^^^^^^^^^^^^^^ ... LL | type T = (); - | ------------ not coverable code - -error: expected `coverage(off)` or `coverage(on)` - --> $DIR/name-value.rs:61:1 - | -LL | #[coverage = "off"] - | ^^^^^^^^^^^^^^^^^^^ + | ------------ not a function or closure -error: aborting due to 19 previous errors +error: aborting due to 23 previous errors For more information about this error, try `rustc --explain E0788`. diff --git a/tests/ui/coverage-attr/no-coverage.rs b/tests/ui/coverage-attr/no-coverage.rs index 907d25d333e..5290fccca61 100644 --- a/tests/ui/coverage-attr/no-coverage.rs +++ b/tests/ui/coverage-attr/no-coverage.rs @@ -2,54 +2,48 @@ #![feature(coverage_attribute)] #![feature(impl_trait_in_assoc_type)] #![warn(unused_attributes)] -#![coverage(off)] -//~^ WARN: `#[coverage]` does not propagate into items and must be applied to the contained functions directly +#![coverage(off)] //~ ERROR attribute should be applied to a function definition or closure -#[coverage(off)] -//~^ WARN: `#[coverage]` does not propagate into items and must be applied to the contained functions directly +#[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure trait Trait { - #[coverage(off)] //~ ERROR `#[coverage]` must be applied to coverable code + #[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure const X: u32; - #[coverage(off)] //~ ERROR `#[coverage]` must be applied to coverable code + #[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure type T; type U; } -#[coverage(off)] -//~^ WARN: `#[coverage]` does not propagate into items and must be applied to the contained functions directly +#[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure impl Trait for () { const X: u32 = 0; - #[coverage(off)] //~ ERROR `#[coverage]` must be applied to coverable code + #[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure type T = Self; - #[coverage(off)] //~ ERROR `#[coverage]` must be applied to coverable code + #[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure type U = impl Trait; //~ ERROR unconstrained opaque type } extern "C" { - #[coverage(off)] //~ ERROR `#[coverage]` must be applied to coverable code + #[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure static X: u32; - #[coverage(off)] //~ ERROR `#[coverage]` must be applied to coverable code + #[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure type T; } #[coverage(off)] fn main() { - #[coverage(off)] - //~^ WARN `#[coverage]` may only be applied to function definitions + #[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure let _ = (); match () { - #[coverage(off)] - //~^ WARN `#[coverage]` may only be applied to function definitions + #[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure () => (), } - #[coverage(off)] - //~^ WARN `#[coverage]` may only be applied to function definitions + #[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure return (); } diff --git a/tests/ui/coverage-attr/no-coverage.stderr b/tests/ui/coverage-attr/no-coverage.stderr index a87b0fb49f0..c5e3b0922cb 100644 --- a/tests/ui/coverage-attr/no-coverage.stderr +++ b/tests/ui/coverage-attr/no-coverage.stderr @@ -1,101 +1,116 @@ -warning: `#[coverage]` does not propagate into items and must be applied to the contained functions directly - --> $DIR/no-coverage.rs:8:1 - | -LL | #[coverage(off)] - | ^^^^^^^^^^^^^^^^ - | -note: the lint level is defined here - --> $DIR/no-coverage.rs:4:9 - | -LL | #![warn(unused_attributes)] - | ^^^^^^^^^^^^^^^^^ +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/no-coverage.rs:7:1 + | +LL | #[coverage(off)] + | ^^^^^^^^^^^^^^^^ +LL | / trait Trait { +LL | | #[coverage(off)] +LL | | const X: u32; +... | +LL | | type U; +LL | | } + | |_- not a function or closure -warning: `#[coverage]` does not propagate into items and must be applied to the contained functions directly - --> $DIR/no-coverage.rs:20:1 - | -LL | #[coverage(off)] - | ^^^^^^^^^^^^^^^^ +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/no-coverage.rs:18:1 + | +LL | #[coverage(off)] + | ^^^^^^^^^^^^^^^^ +LL | / impl Trait for () { +LL | | const X: u32 = 0; +LL | | +LL | | #[coverage(off)] +... | +LL | | type U = impl Trait; +LL | | } + | |_- not a function or closure -warning: `#[coverage]` may only be applied to function definitions - --> $DIR/no-coverage.rs:42:5 +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/no-coverage.rs:39:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ +LL | let _ = (); + | ----------- not a function or closure -warning: `#[coverage]` may only be applied to function definitions - --> $DIR/no-coverage.rs:47:9 +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/no-coverage.rs:43:9 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ +LL | () => (), + | -------- not a function or closure -warning: `#[coverage]` may only be applied to function definitions - --> $DIR/no-coverage.rs:52:5 +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/no-coverage.rs:47:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ +LL | return (); + | --------- not a function or closure -error[E0788]: `#[coverage]` must be applied to coverable code - --> $DIR/no-coverage.rs:11:5 +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/no-coverage.rs:9:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ LL | const X: u32; - | ------------- not coverable code + | ------------- not a function or closure -error[E0788]: `#[coverage]` must be applied to coverable code - --> $DIR/no-coverage.rs:14:5 +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/no-coverage.rs:12:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ LL | type T; - | ------- not coverable code + | ------- not a function or closure -error[E0788]: `#[coverage]` must be applied to coverable code - --> $DIR/no-coverage.rs:25:5 +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/no-coverage.rs:22:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ LL | type T = Self; - | -------------- not coverable code + | -------------- not a function or closure -error[E0788]: `#[coverage]` must be applied to coverable code - --> $DIR/no-coverage.rs:28:5 +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/no-coverage.rs:25:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ LL | type U = impl Trait; - | -------------------- not coverable code + | -------------------- not a function or closure -error[E0788]: `#[coverage]` must be applied to coverable code - --> $DIR/no-coverage.rs:33:5 +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/no-coverage.rs:30:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ LL | static X: u32; - | -------------- not coverable code + | -------------- not a function or closure -error[E0788]: `#[coverage]` must be applied to coverable code - --> $DIR/no-coverage.rs:36:5 +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/no-coverage.rs:33:5 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ LL | type T; - | ------- not coverable code + | ------- not a function or closure -warning: `#[coverage]` does not propagate into items and must be applied to the contained functions directly +error[E0788]: attribute should be applied to a function definition or closure --> $DIR/no-coverage.rs:5:1 | LL | #![coverage(off)] - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^ not a function or closure error: unconstrained opaque type - --> $DIR/no-coverage.rs:29:14 + --> $DIR/no-coverage.rs:26:14 | LL | type U = impl Trait; | ^^^^^^^^^^ | = note: `U` must be used in combination with a concrete type within the same impl -error: aborting due to 7 previous errors; 6 warnings emitted +error: aborting due to 13 previous errors For more information about this error, try `rustc --explain E0788`. diff --git a/tests/ui/coverage-attr/subword.rs b/tests/ui/coverage-attr/subword.rs index 98b8c25113c..16582240b69 100644 --- a/tests/ui/coverage-attr/subword.rs +++ b/tests/ui/coverage-attr/subword.rs @@ -4,16 +4,16 @@ // Check that yes/no in `#[coverage(yes)]` and `#[coverage(no)]` must be bare // words, not part of a more complicated substructure. -#[coverage(yes(milord))] //~ ERROR expected `coverage(off)` or `coverage(on)` +#[coverage(yes(milord))] //~ ERROR malformed `coverage` attribute input fn yes_list() {} -#[coverage(no(milord))] //~ ERROR expected `coverage(off)` or `coverage(on)` +#[coverage(no(milord))] //~ ERROR malformed `coverage` attribute input fn no_list() {} -#[coverage(yes = "milord")] //~ ERROR expected `coverage(off)` or `coverage(on)` +#[coverage(yes = "milord")] //~ ERROR malformed `coverage` attribute input fn yes_key() {} -#[coverage(no = "milord")] //~ ERROR expected `coverage(off)` or `coverage(on)` +#[coverage(no = "milord")] //~ ERROR malformed `coverage` attribute input fn no_key() {} fn main() {} diff --git a/tests/ui/coverage-attr/subword.stderr b/tests/ui/coverage-attr/subword.stderr index 561573b8ada..3a106898f8b 100644 --- a/tests/ui/coverage-attr/subword.stderr +++ b/tests/ui/coverage-attr/subword.stderr @@ -1,26 +1,54 @@ -error: expected `coverage(off)` or `coverage(on)` +error: malformed `coverage` attribute input --> $DIR/subword.rs:7:1 | LL | #[coverage(yes(milord))] | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[coverage(off)] + | ~~~~~~~~~~~~~~~~ +LL | #[coverage(on)] + | ~~~~~~~~~~~~~~~ -error: expected `coverage(off)` or `coverage(on)` +error: malformed `coverage` attribute input --> $DIR/subword.rs:10:1 | LL | #[coverage(no(milord))] | ^^^^^^^^^^^^^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[coverage(off)] + | ~~~~~~~~~~~~~~~~ +LL | #[coverage(on)] + | ~~~~~~~~~~~~~~~ -error: expected `coverage(off)` or `coverage(on)` +error: malformed `coverage` attribute input --> $DIR/subword.rs:13:1 | LL | #[coverage(yes = "milord")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[coverage(off)] + | ~~~~~~~~~~~~~~~~ +LL | #[coverage(on)] + | ~~~~~~~~~~~~~~~ -error: expected `coverage(off)` or `coverage(on)` +error: malformed `coverage` attribute input --> $DIR/subword.rs:16:1 | LL | #[coverage(no = "milord")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[coverage(off)] + | ~~~~~~~~~~~~~~~~ +LL | #[coverage(on)] + | ~~~~~~~~~~~~~~~ error: aborting due to 4 previous errors diff --git a/tests/ui/coverage-attr/word-only.rs b/tests/ui/coverage-attr/word-only.rs index 5c723b1b6b6..0a61d1e709f 100644 --- a/tests/ui/coverage-attr/word-only.rs +++ b/tests/ui/coverage-attr/word-only.rs @@ -8,47 +8,62 @@ // and in places that cannot have a coverage attribute, to demonstrate the // interaction between multiple errors. -// FIXME(#126658): The error messages for using this syntax give the impression -// that it is legal, even though it should never be legal. - -// FIXME(#126658): This is silently allowed, but should not be. #[coverage] +//~^ ERROR malformed `coverage` attribute input +//~| ERROR attribute should be applied to a function definition or closure mod my_mod {} -// FIXME(#126658): This is silently allowed, but should not be. mod my_mod_inner { #![coverage] + //~^ ERROR malformed `coverage` attribute input + //~| ERROR attribute should be applied to a function definition or closure } -#[coverage] //~ ERROR `#[coverage]` must be applied to coverable code +#[coverage] +//~^ ERROR malformed `coverage` attribute input +//~| ERROR attribute should be applied to a function definition or closure struct MyStruct; -// FIXME(#126658): This is silently allowed, but should not be. #[coverage] +//~^ ERROR malformed `coverage` attribute input +//~| ERROR attribute should be applied to a function definition or closure impl MyStruct { - #[coverage] //~ ERROR `#[coverage]` must be applied to coverable code + #[coverage] + //~^ ERROR malformed `coverage` attribute input + //~| ERROR attribute should be applied to a function definition or closure const X: u32 = 7; } -// FIXME(#126658): This is silently allowed, but should not be. #[coverage] +//~^ ERROR malformed `coverage` attribute input +//~| ERROR attribute should be applied to a function definition or closure trait MyTrait { - #[coverage] //~ ERROR `#[coverage]` must be applied to coverable code + #[coverage] + //~^ ERROR malformed `coverage` attribute input + //~| ERROR attribute should be applied to a function definition or closure const X: u32; - #[coverage] //~ ERROR `#[coverage]` must be applied to coverable code + #[coverage] + //~^ ERROR malformed `coverage` attribute input + //~| ERROR attribute should be applied to a function definition or closure type T; } -// FIXME(#126658): This is silently allowed, but should not be. #[coverage] +//~^ ERROR malformed `coverage` attribute input +//~| ERROR attribute should be applied to a function definition or closure impl MyTrait for MyStruct { - #[coverage] //~ ERROR `#[coverage]` must be applied to coverable code + #[coverage] + //~^ ERROR malformed `coverage` attribute input + //~| ERROR attribute should be applied to a function definition or closure const X: u32 = 8; - #[coverage] //~ ERROR `#[coverage]` must be applied to coverable code + #[coverage] + //~^ ERROR malformed `coverage` attribute input + //~| ERROR attribute should be applied to a function definition or closure type T = (); } -#[coverage] //~ ERROR expected `coverage(off)` or `coverage(on)` +#[coverage] +//~^ ERROR malformed `coverage` attribute input fn main() {} diff --git a/tests/ui/coverage-attr/word-only.stderr b/tests/ui/coverage-attr/word-only.stderr index bcafc23bc8d..18b5fed7484 100644 --- a/tests/ui/coverage-attr/word-only.stderr +++ b/tests/ui/coverage-attr/word-only.stderr @@ -1,57 +1,277 @@ -error[E0788]: `#[coverage]` must be applied to coverable code - --> $DIR/word-only.rs:23:1 +error: malformed `coverage` attribute input + --> $DIR/word-only.rs:11:1 | LL | #[coverage] | ^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[coverage(off)] + | +LL | #[coverage(on)] + | + +error: malformed `coverage` attribute input + --> $DIR/word-only.rs:17:5 + | +LL | #![coverage] + | ^^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #![coverage(off)] + | +LL | #![coverage(on)] + | + +error: malformed `coverage` attribute input + --> $DIR/word-only.rs:22:1 + | +LL | #[coverage] + | ^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[coverage(off)] + | +LL | #[coverage(on)] + | + +error: malformed `coverage` attribute input + --> $DIR/word-only.rs:31:5 + | +LL | #[coverage] + | ^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[coverage(off)] + | +LL | #[coverage(on)] + | + +error: malformed `coverage` attribute input + --> $DIR/word-only.rs:27:1 + | +LL | #[coverage] + | ^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[coverage(off)] + | +LL | #[coverage(on)] + | + +error: malformed `coverage` attribute input + --> $DIR/word-only.rs:41:5 + | +LL | #[coverage] + | ^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[coverage(off)] + | +LL | #[coverage(on)] + | + +error: malformed `coverage` attribute input + --> $DIR/word-only.rs:46:5 + | +LL | #[coverage] + | ^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[coverage(off)] + | +LL | #[coverage(on)] + | + +error: malformed `coverage` attribute input + --> $DIR/word-only.rs:37:1 + | +LL | #[coverage] + | ^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[coverage(off)] + | +LL | #[coverage(on)] + | + +error: malformed `coverage` attribute input + --> $DIR/word-only.rs:56:5 + | +LL | #[coverage] + | ^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[coverage(off)] + | +LL | #[coverage(on)] + | + +error: malformed `coverage` attribute input + --> $DIR/word-only.rs:61:5 + | +LL | #[coverage] + | ^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[coverage(off)] + | +LL | #[coverage(on)] + | + +error: malformed `coverage` attribute input + --> $DIR/word-only.rs:52:1 + | +LL | #[coverage] + | ^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[coverage(off)] + | +LL | #[coverage(on)] + | + +error: malformed `coverage` attribute input + --> $DIR/word-only.rs:67:1 + | +LL | #[coverage] + | ^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[coverage(off)] + | +LL | #[coverage(on)] + | + +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/word-only.rs:11:1 + | +LL | #[coverage] + | ^^^^^^^^^^^ +... +LL | mod my_mod {} + | ------------- not a function or closure + +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/word-only.rs:17:5 + | +LL | / mod my_mod_inner { +LL | | #![coverage] + | | ^^^^^^^^^^^^ +LL | | +LL | | +LL | | } + | |_- not a function or closure + +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/word-only.rs:22:1 + | +LL | #[coverage] + | ^^^^^^^^^^^ +... LL | struct MyStruct; - | ---------------- not coverable code + | ---------------- not a function or closure + +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/word-only.rs:27:1 + | +LL | #[coverage] + | ^^^^^^^^^^^ +... +LL | / impl MyStruct { +LL | | #[coverage] +LL | | +LL | | +LL | | const X: u32 = 7; +LL | | } + | |_- not a function or closure + +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/word-only.rs:37:1 + | +LL | #[coverage] + | ^^^^^^^^^^^ +... +LL | / trait MyTrait { +LL | | #[coverage] +LL | | +LL | | +... | +LL | | type T; +LL | | } + | |_- not a function or closure + +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/word-only.rs:52:1 + | +LL | #[coverage] + | ^^^^^^^^^^^ +... +LL | / impl MyTrait for MyStruct { +LL | | #[coverage] +LL | | +LL | | +... | +LL | | type T = (); +LL | | } + | |_- not a function or closure -error[E0788]: `#[coverage]` must be applied to coverable code - --> $DIR/word-only.rs:36:5 +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/word-only.rs:41:5 | LL | #[coverage] | ^^^^^^^^^^^ +... LL | const X: u32; - | ------------- not coverable code + | ------------- not a function or closure -error[E0788]: `#[coverage]` must be applied to coverable code - --> $DIR/word-only.rs:39:5 +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/word-only.rs:46:5 | LL | #[coverage] | ^^^^^^^^^^^ +... LL | type T; - | ------- not coverable code + | ------- not a function or closure -error[E0788]: `#[coverage]` must be applied to coverable code - --> $DIR/word-only.rs:29:5 +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/word-only.rs:31:5 | LL | #[coverage] | ^^^^^^^^^^^ +... LL | const X: u32 = 7; - | ----------------- not coverable code + | ----------------- not a function or closure -error[E0788]: `#[coverage]` must be applied to coverable code - --> $DIR/word-only.rs:46:5 +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/word-only.rs:56:5 | LL | #[coverage] | ^^^^^^^^^^^ +... LL | const X: u32 = 8; - | ----------------- not coverable code + | ----------------- not a function or closure -error[E0788]: `#[coverage]` must be applied to coverable code - --> $DIR/word-only.rs:49:5 +error[E0788]: attribute should be applied to a function definition or closure + --> $DIR/word-only.rs:61:5 | LL | #[coverage] | ^^^^^^^^^^^ +... LL | type T = (); - | ------------ not coverable code - -error: expected `coverage(off)` or `coverage(on)` - --> $DIR/word-only.rs:53:1 - | -LL | #[coverage] - | ^^^^^^^^^^^ + | ------------ not a function or closure -error: aborting due to 7 previous errors +error: aborting due to 23 previous errors For more information about this error, try `rustc --explain E0788`. diff --git a/tests/ui/deployment-target/invalid-target.stderr b/tests/ui/deployment-target/invalid-target.stderr index eb4ac131c40..0ab548f339b 100644 --- a/tests/ui/deployment-target/invalid-target.stderr +++ b/tests/ui/deployment-target/invalid-target.stderr @@ -1,2 +1,4 @@ error: only Apple targets currently support deployment version info +error: aborting due to 1 previous error + diff --git a/tests/ui/deprecation/deprecated_inline_threshold.rs b/tests/ui/deprecation/deprecated_inline_threshold.rs new file mode 100644 index 00000000000..56e033b8cf5 --- /dev/null +++ b/tests/ui/deprecation/deprecated_inline_threshold.rs @@ -0,0 +1,4 @@ +//@ check-pass +//@ compile-flags: -Cinline-threshold=666 + +fn main() {} diff --git a/tests/ui/deprecation/deprecated_inline_threshold.stderr b/tests/ui/deprecation/deprecated_inline_threshold.stderr new file mode 100644 index 00000000000..c4f8ff092b2 --- /dev/null +++ b/tests/ui/deprecation/deprecated_inline_threshold.stderr @@ -0,0 +1,2 @@ +warning: the `-Cinline-threshold` flag is deprecated and does nothing (consider using `-Cllvm-args=--inline-threshold=...`) + diff --git a/tests/ui/deriving/deriving-smart-pointer.rs b/tests/ui/deriving/deriving-smart-pointer.rs new file mode 100644 index 00000000000..cfc3369850b --- /dev/null +++ b/tests/ui/deriving/deriving-smart-pointer.rs @@ -0,0 +1,55 @@ +//@ run-pass +#![feature(derive_smart_pointer, arbitrary_self_types)] + +use std::marker::SmartPointer; + +#[derive(SmartPointer)] +struct MyPointer<'a, #[pointee] T: ?Sized> { + ptr: &'a T, +} + +impl<T: ?Sized> Copy for MyPointer<'_, T> {} +impl<T: ?Sized> Clone for MyPointer<'_, T> { + fn clone(&self) -> Self { + Self { ptr: self.ptr } + } +} + +impl<'a, T: ?Sized> core::ops::Deref for MyPointer<'a, T> { + type Target = T; + fn deref(&self) -> &'a T { + self.ptr + } +} + +struct MyValue(u32); +impl MyValue { + fn through_pointer(self: MyPointer<'_, Self>) -> u32 { + self.ptr.0 + } +} + +trait MyTrait { + fn through_trait(&self) -> u32; + fn through_trait_and_pointer(self: MyPointer<'_, Self>) -> u32; +} + +impl MyTrait for MyValue { + fn through_trait(&self) -> u32 { + self.0 + } + + fn through_trait_and_pointer(self: MyPointer<'_, Self>) -> u32 { + self.ptr.0 + } +} + +pub fn main() { + let v = MyValue(10); + let ptr = MyPointer { ptr: &v }; + assert_eq!(v.0, ptr.through_pointer()); + assert_eq!(v.0, ptr.through_pointer()); + let dptr = ptr as MyPointer<dyn MyTrait>; + assert_eq!(v.0, dptr.through_trait()); + assert_eq!(v.0, dptr.through_trait_and_pointer()); +} diff --git a/tests/ui/feature-gates/feature-gate-derive-smart-pointer.rs b/tests/ui/feature-gates/feature-gate-derive-smart-pointer.rs new file mode 100644 index 00000000000..ae8005592cd --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-derive-smart-pointer.rs @@ -0,0 +1,9 @@ +use std::marker::SmartPointer; //~ ERROR use of unstable library feature 'derive_smart_pointer' + +#[derive(SmartPointer)] //~ ERROR use of unstable library feature 'derive_smart_pointer' +struct MyPointer<'a, #[pointee] T: ?Sized> { + //~^ ERROR the `#[pointee]` attribute is an experimental feature + ptr: &'a T, +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-derive-smart-pointer.stderr b/tests/ui/feature-gates/feature-gate-derive-smart-pointer.stderr new file mode 100644 index 00000000000..0ffd82fb9e1 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-derive-smart-pointer.stderr @@ -0,0 +1,33 @@ +error[E0658]: use of unstable library feature 'derive_smart_pointer' + --> $DIR/feature-gate-derive-smart-pointer.rs:3:10 + | +LL | #[derive(SmartPointer)] + | ^^^^^^^^^^^^ + | + = note: see issue #123430 <https://github.com/rust-lang/rust/issues/123430> for more information + = help: add `#![feature(derive_smart_pointer)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: the `#[pointee]` attribute is an experimental feature + --> $DIR/feature-gate-derive-smart-pointer.rs:4:22 + | +LL | struct MyPointer<'a, #[pointee] T: ?Sized> { + | ^^^^^^^^^^ + | + = note: see issue #123430 <https://github.com/rust-lang/rust/issues/123430> for more information + = help: add `#![feature(derive_smart_pointer)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: use of unstable library feature 'derive_smart_pointer' + --> $DIR/feature-gate-derive-smart-pointer.rs:1:5 + | +LL | use std::marker::SmartPointer; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #123430 <https://github.com/rust-lang/rust/issues/123430> for more information + = help: add `#![feature(derive_smart_pointer)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-optimize_attribute.stderr b/tests/ui/feature-gates/feature-gate-optimize_attribute.stderr index 815013733a9..609526150ba 100644 --- a/tests/ui/feature-gates/feature-gate-optimize_attribute.stderr +++ b/tests/ui/feature-gates/feature-gate-optimize_attribute.stderr @@ -1,47 +1,47 @@ error[E0658]: the `#[optimize]` attribute is an experimental feature - --> $DIR/feature-gate-optimize_attribute.rs:7:1 + --> $DIR/feature-gate-optimize_attribute.rs:2:1 | -LL | #[optimize(size)] - | ^^^^^^^^^^^^^^^^^ +LL | #![optimize(speed)] + | ^^^^^^^^^^^^^^^^^^^ | = note: see issue #54882 <https://github.com/rust-lang/rust/issues/54882> for more information = help: add `#![feature(optimize_attribute)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the `#[optimize]` attribute is an experimental feature - --> $DIR/feature-gate-optimize_attribute.rs:10:1 + --> $DIR/feature-gate-optimize_attribute.rs:4:1 | -LL | #[optimize(speed)] - | ^^^^^^^^^^^^^^^^^^ +LL | #[optimize(size)] + | ^^^^^^^^^^^^^^^^^ | = note: see issue #54882 <https://github.com/rust-lang/rust/issues/54882> for more information = help: add `#![feature(optimize_attribute)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the `#[optimize]` attribute is an experimental feature - --> $DIR/feature-gate-optimize_attribute.rs:13:1 + --> $DIR/feature-gate-optimize_attribute.rs:7:1 | -LL | #[optimize(banana)] - | ^^^^^^^^^^^^^^^^^^^ +LL | #[optimize(size)] + | ^^^^^^^^^^^^^^^^^ | = note: see issue #54882 <https://github.com/rust-lang/rust/issues/54882> for more information = help: add `#![feature(optimize_attribute)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the `#[optimize]` attribute is an experimental feature - --> $DIR/feature-gate-optimize_attribute.rs:4:1 + --> $DIR/feature-gate-optimize_attribute.rs:10:1 | -LL | #[optimize(size)] - | ^^^^^^^^^^^^^^^^^ +LL | #[optimize(speed)] + | ^^^^^^^^^^^^^^^^^^ | = note: see issue #54882 <https://github.com/rust-lang/rust/issues/54882> for more information = help: add `#![feature(optimize_attribute)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the `#[optimize]` attribute is an experimental feature - --> $DIR/feature-gate-optimize_attribute.rs:2:1 + --> $DIR/feature-gate-optimize_attribute.rs:13:1 | -LL | #![optimize(speed)] +LL | #[optimize(banana)] | ^^^^^^^^^^^^^^^^^^^ | = note: see issue #54882 <https://github.com/rust-lang/rust/issues/54882> for more information diff --git a/tests/ui/feature-gates/feature-gate-staged_api.stderr b/tests/ui/feature-gates/feature-gate-staged_api.stderr index 1a9fcb02b0d..86ba509ae7d 100644 --- a/tests/ui/feature-gates/feature-gate-staged_api.stderr +++ b/tests/ui/feature-gates/feature-gate-staged_api.stderr @@ -1,15 +1,15 @@ error[E0734]: stability attributes may not be used outside of the standard library - --> $DIR/feature-gate-staged_api.rs:8:1 - | -LL | #[stable(feature = "a", since = "3.3.3")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0734]: stability attributes may not be used outside of the standard library --> $DIR/feature-gate-staged_api.rs:1:1 | LL | #![stable(feature = "a", since = "3.3.3")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/feature-gate-staged_api.rs:8:1 + | +LL | #[stable(feature = "a", since = "3.3.3")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0734`. diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr index 88732f75cb4..e43cef7c150 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr +++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr @@ -42,6 +42,20 @@ warning: unknown lint: `x5100` LL | #![deny(x5100)] | ^^^^^ +warning: use of deprecated attribute `crate_id`: no longer used + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:84:1 + | +LL | #![crate_id = "10"] + | ^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | + = note: `#[warn(deprecated)]` on by default + +warning: use of deprecated attribute `no_start`: no longer used + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:94:1 + | +LL | #![no_start] + | ^^^^^^^^^^^^ help: remove this attribute + warning: unknown lint: `x5400` --> $DIR/issue-43106-gating-of-builtin-attrs.rs:105:8 | @@ -186,20 +200,6 @@ warning: unknown lint: `x5100` LL | #[deny(x5100)] impl S { } | ^^^^^ -warning: use of deprecated attribute `crate_id`: no longer used - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:84:1 - | -LL | #![crate_id = "10"] - | ^^^^^^^^^^^^^^^^^^^ help: remove this attribute - | - = note: `#[warn(deprecated)]` on by default - -warning: use of deprecated attribute `no_start`: no longer used - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:94:1 - | -LL | #![no_start] - | ^^^^^^^^^^^^ help: remove this attribute - warning: `#[macro_export]` only has an effect on macro definitions --> $DIR/issue-43106-gating-of-builtin-attrs.rs:198:1 | diff --git a/tests/ui/feature-gates/issue-43106-gating-of-stable.stderr b/tests/ui/feature-gates/issue-43106-gating-of-stable.stderr index 677fef3a926..bac3b018e2e 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-stable.stderr +++ b/tests/ui/feature-gates/issue-43106-gating-of-stable.stderr @@ -1,4 +1,16 @@ error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/issue-43106-gating-of-stable.rs:7:1 + | +LL | #![stable()] + | ^^^^^^^^^^^^ + +error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/issue-43106-gating-of-stable.rs:10:1 + | +LL | #[stable()] + | ^^^^^^^^^^^ + +error[E0734]: stability attributes may not be used outside of the standard library --> $DIR/issue-43106-gating-of-stable.rs:14:9 | LL | #![stable()] @@ -28,18 +40,6 @@ error[E0734]: stability attributes may not be used outside of the standard libra LL | #[stable()] | ^^^^^^^^^^^ -error[E0734]: stability attributes may not be used outside of the standard library - --> $DIR/issue-43106-gating-of-stable.rs:10:1 - | -LL | #[stable()] - | ^^^^^^^^^^^ - -error[E0734]: stability attributes may not be used outside of the standard library - --> $DIR/issue-43106-gating-of-stable.rs:7:1 - | -LL | #![stable()] - | ^^^^^^^^^^^^ - error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0734`. diff --git a/tests/ui/feature-gates/issue-43106-gating-of-unstable.stderr b/tests/ui/feature-gates/issue-43106-gating-of-unstable.stderr index a2f361878c6..9ea60f83800 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-unstable.stderr +++ b/tests/ui/feature-gates/issue-43106-gating-of-unstable.stderr @@ -1,4 +1,16 @@ error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/issue-43106-gating-of-unstable.rs:7:1 + | +LL | #![unstable()] + | ^^^^^^^^^^^^^^ + +error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/issue-43106-gating-of-unstable.rs:10:1 + | +LL | #[unstable()] + | ^^^^^^^^^^^^^ + +error[E0734]: stability attributes may not be used outside of the standard library --> $DIR/issue-43106-gating-of-unstable.rs:14:9 | LL | #![unstable()] @@ -28,18 +40,6 @@ error[E0734]: stability attributes may not be used outside of the standard libra LL | #[unstable()] | ^^^^^^^^^^^^^ -error[E0734]: stability attributes may not be used outside of the standard library - --> $DIR/issue-43106-gating-of-unstable.rs:10:1 - | -LL | #[unstable()] - | ^^^^^^^^^^^^^ - -error[E0734]: stability attributes may not be used outside of the standard library - --> $DIR/issue-43106-gating-of-unstable.rs:7:1 - | -LL | #![unstable()] - | ^^^^^^^^^^^^^^ - error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0734`. diff --git a/tests/ui/impl-trait/trait_upcasting.rs b/tests/ui/impl-trait/trait_upcasting.rs new file mode 100644 index 00000000000..ce811004fae --- /dev/null +++ b/tests/ui/impl-trait/trait_upcasting.rs @@ -0,0 +1,26 @@ +//! Test that we allow unsizing `Trait<Concrete>` to `Trait<Opaque>` and vice versa + +//@ check-pass + +trait Trait<T> {} + +impl<T, U> Trait<T> for U {} + +fn hello() -> &'static (dyn Trait<impl Sized> + Send) { + if false { + let x = hello(); + let _: &'static dyn Trait<()> = x; + } + todo!() +} + +fn bye() -> &'static dyn Trait<impl Sized> { + if false { + let mut x = bye(); + let y: &'static (dyn Trait<()> + Send) = &(); + x = y; + } + todo!() +} + +fn main() {} diff --git a/tests/ui/impl-trait/trait_upcasting_reference_mismatch.rs b/tests/ui/impl-trait/trait_upcasting_reference_mismatch.rs new file mode 100644 index 00000000000..bed88db1acc --- /dev/null +++ b/tests/ui/impl-trait/trait_upcasting_reference_mismatch.rs @@ -0,0 +1,18 @@ +//! Show an uninformative diagnostic that we could possibly improve in the future + +trait Trait<T> {} + +impl<T, U> Trait<T> for U {} + +fn hello() -> &'static (dyn Trait<impl Sized> + Send) { + //~^ ERROR: type annotations needed + if false { + let x = hello(); + let _: &'static dyn Trait<()> = &x; + //^ Note the extra `&`, paired with the blanket impl causing + // `impl Sized` to never get a hidden type registered. + } + todo!() +} + +fn main() {} diff --git a/tests/ui/impl-trait/trait_upcasting_reference_mismatch.stderr b/tests/ui/impl-trait/trait_upcasting_reference_mismatch.stderr new file mode 100644 index 00000000000..92da47b08e9 --- /dev/null +++ b/tests/ui/impl-trait/trait_upcasting_reference_mismatch.stderr @@ -0,0 +1,9 @@ +error[E0282]: type annotations needed + --> $DIR/trait_upcasting_reference_mismatch.rs:7:35 + | +LL | fn hello() -> &'static (dyn Trait<impl Sized> + Send) { + | ^^^^^^^^^^ cannot infer type + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/impl-trait/unsize_adt.rs b/tests/ui/impl-trait/unsize_adt.rs index fce5094bd40..825384b61e8 100644 --- a/tests/ui/impl-trait/unsize_adt.rs +++ b/tests/ui/impl-trait/unsize_adt.rs @@ -1,4 +1,6 @@ -//! Test that we do not allow unsizing `Foo<[Opaque; N]>` to `Foo<[Concrete]>`. +//! Test that we allow unsizing `Foo<[Opaque; N]>` to `Foo<[Concrete]>`. + +//@check-pass struct Foo<T: ?Sized>(T); @@ -6,7 +8,6 @@ fn hello() -> Foo<[impl Sized; 2]> { if false { let x = hello(); let _: &Foo<[i32]> = &x; - //~^ ERROR: mismatched types } todo!() } diff --git a/tests/ui/impl-trait/unsize_adt.stderr b/tests/ui/impl-trait/unsize_adt.stderr deleted file mode 100644 index 2b93b4a571b..00000000000 --- a/tests/ui/impl-trait/unsize_adt.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/unsize_adt.rs:8:30 - | -LL | fn hello() -> Foo<[impl Sized; 2]> { - | ---------- the found opaque type -... -LL | let _: &Foo<[i32]> = &x; - | ----------- ^^ expected `&Foo<[i32]>`, found `&Foo<[impl Sized; 2]>` - | | - | expected due to this - | - = note: expected reference `&Foo<[i32]>` - found reference `&Foo<[impl Sized; 2]>` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/unsize_slice.rs b/tests/ui/impl-trait/unsize_slice.rs index ec0f1626564..b0cf1c7ca6d 100644 --- a/tests/ui/impl-trait/unsize_slice.rs +++ b/tests/ui/impl-trait/unsize_slice.rs @@ -1,10 +1,11 @@ -//! Test that we do not allow unsizing `[Opaque; N]` to `[Concrete]`. +//! Test that we allow unsizing `[Opaque; N]` to `[Concrete]`. + +//@check-pass fn hello() -> [impl Sized; 2] { if false { let x = hello(); let _: &[i32] = &x; - //~^ ERROR: mismatched types } todo!() } diff --git a/tests/ui/impl-trait/unsize_slice.stderr b/tests/ui/impl-trait/unsize_slice.stderr deleted file mode 100644 index 6a7fdb46163..00000000000 --- a/tests/ui/impl-trait/unsize_slice.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/unsize_slice.rs:6:25 - | -LL | fn hello() -> [impl Sized; 2] { - | ---------- the found opaque type -... -LL | let _: &[i32] = &x; - | ------ ^^ expected `&[i32]`, found `&[impl Sized; 2]` - | | - | expected due to this - | - = note: expected reference `&[i32]` - found reference `&[impl Sized; 2]` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/unsize_tuple.rs b/tests/ui/impl-trait/unsize_tuple.rs index 630b8fd430f..2678564f0e8 100644 --- a/tests/ui/impl-trait/unsize_tuple.rs +++ b/tests/ui/impl-trait/unsize_tuple.rs @@ -1,4 +1,6 @@ -//! Test that we do not allow unsizing `([Opaque; N],)` to `([Concrete],)`. +//! Test that we allow unsizing `([Opaque; N],)` to `([Concrete],)`. + +//@check-pass #![feature(unsized_tuple_coercion)] @@ -6,7 +8,6 @@ fn hello() -> ([impl Sized; 2],) { if false { let x = hello(); let _: &([i32],) = &x; - //~^ ERROR: mismatched types } todo!() } diff --git a/tests/ui/impl-trait/unsize_tuple.stderr b/tests/ui/impl-trait/unsize_tuple.stderr deleted file mode 100644 index 8d3cf15887c..00000000000 --- a/tests/ui/impl-trait/unsize_tuple.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/unsize_tuple.rs:8:28 - | -LL | fn hello() -> ([impl Sized; 2],) { - | ---------- the found opaque type -... -LL | let _: &([i32],) = &x; - | --------- ^^ expected `&([i32],)`, found `&([impl Sized; 2],)` - | | - | expected due to this - | - = note: expected reference `&([i32],)` - found reference `&([impl Sized; 2],)` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/unsized_coercion.next.stderr b/tests/ui/impl-trait/unsized_coercion.next.stderr new file mode 100644 index 00000000000..49ac3f1845f --- /dev/null +++ b/tests/ui/impl-trait/unsized_coercion.next.stderr @@ -0,0 +1,26 @@ +error[E0271]: type mismatch resolving `impl Trait <: dyn Trait` + --> $DIR/unsized_coercion.rs:14:17 + | +LL | let x = hello(); + | ^^^^^^^ types differ + +error[E0308]: mismatched types + --> $DIR/unsized_coercion.rs:18:14 + | +LL | fn hello() -> Box<impl Trait> { + | ---------- the expected opaque type +... +LL | Box::new(1u32) + | -------- ^^^^ types differ + | | + | arguments to this function are incorrect + | + = note: expected opaque type `impl Trait` + found type `u32` +note: associated function defined here + --> $SRC_DIR/alloc/src/boxed.rs:LL:COL + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0271, E0308. +For more information about an error, try `rustc --explain E0271`. diff --git a/tests/ui/impl-trait/unsized_coercion.rs b/tests/ui/impl-trait/unsized_coercion.rs new file mode 100644 index 00000000000..46e040c1428 --- /dev/null +++ b/tests/ui/impl-trait/unsized_coercion.rs @@ -0,0 +1,21 @@ +//! This test checks that opaque types get unsized instead of +//! constraining their hidden type to a trait object. + +//@ revisions: next old +//@[next] compile-flags: -Znext-solver +//@[old] check-pass + +trait Trait {} + +impl Trait for u32 {} + +fn hello() -> Box<impl Trait> { + if true { + let x = hello(); + //[next]~^ ERROR: type mismatch resolving `impl Trait <: dyn Trait` + let y: Box<dyn Trait> = x; + } + Box::new(1u32) //[next]~ ERROR: mismatched types +} + +fn main() {} diff --git a/tests/ui/impl-trait/unsized_coercion2.old.stderr b/tests/ui/impl-trait/unsized_coercion2.old.stderr new file mode 100644 index 00000000000..a89d40f1130 --- /dev/null +++ b/tests/ui/impl-trait/unsized_coercion2.old.stderr @@ -0,0 +1,12 @@ +error[E0277]: the size for values of type `impl Trait + ?Sized` cannot be known at compilation time + --> $DIR/unsized_coercion2.rs:15:33 + | +LL | let y: Box<dyn Trait> = x; + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `impl Trait + ?Sized` + = note: required for the cast from `Box<impl Trait + ?Sized>` to `Box<dyn Trait>` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/unsized_coercion2.rs b/tests/ui/impl-trait/unsized_coercion2.rs new file mode 100644 index 00000000000..7368d47dbe2 --- /dev/null +++ b/tests/ui/impl-trait/unsized_coercion2.rs @@ -0,0 +1,21 @@ +//! This test checks that opaque types get unsized instead of +//! constraining their hidden type to a trait object. + +//@ revisions: next old +//@[next] compile-flags: -Znext-solver +//@[next] check-pass + +trait Trait {} + +impl Trait for u32 {} + +fn hello() -> Box<impl Trait + ?Sized> { + if true { + let x = hello(); + let y: Box<dyn Trait> = x; + //[old]~^ ERROR: the size for values of type `impl Trait + ?Sized` cannot be know + } + Box::new(1u32) +} + +fn main() {} diff --git a/tests/ui/impl-trait/unsized_coercion3.next.stderr b/tests/ui/impl-trait/unsized_coercion3.next.stderr new file mode 100644 index 00000000000..bab8d1cd83b --- /dev/null +++ b/tests/ui/impl-trait/unsized_coercion3.next.stderr @@ -0,0 +1,38 @@ +error[E0271]: type mismatch resolving `impl Trait + ?Sized <: dyn Send` + --> $DIR/unsized_coercion3.rs:13:17 + | +LL | let x = hello(); + | ^^^^^^^ types differ + +error[E0308]: mismatched types + --> $DIR/unsized_coercion3.rs:19:14 + | +LL | fn hello() -> Box<impl Trait + ?Sized> { + | ------------------- the expected opaque type +... +LL | Box::new(1u32) + | -------- ^^^^ types differ + | | + | arguments to this function are incorrect + | + = note: expected opaque type `impl Trait + ?Sized` + found type `u32` +note: associated function defined here + --> $SRC_DIR/alloc/src/boxed.rs:LL:COL + +error[E0277]: the size for values of type `impl Trait + ?Sized` cannot be known at compilation time + --> $DIR/unsized_coercion3.rs:19:14 + | +LL | Box::new(1u32) + | -------- ^^^^ doesn't have a size known at compile-time + | | + | required by a bound introduced by this call + | + = help: the trait `Sized` is not implemented for `impl Trait + ?Sized` +note: required by a bound in `Box::<T>::new` + --> $SRC_DIR/alloc/src/boxed.rs:LL:COL + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0271, E0277, E0308. +For more information about an error, try `rustc --explain E0271`. diff --git a/tests/ui/impl-trait/unsized_coercion3.old.stderr b/tests/ui/impl-trait/unsized_coercion3.old.stderr new file mode 100644 index 00000000000..24a302d7007 --- /dev/null +++ b/tests/ui/impl-trait/unsized_coercion3.old.stderr @@ -0,0 +1,26 @@ +error: cannot check whether the hidden type of opaque type satisfies auto traits + --> $DIR/unsized_coercion3.rs:15:32 + | +LL | let y: Box<dyn Send> = x; + | ^ + | + = note: fetching the hidden types of an opaque inside of the defining scope is not supported. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule +note: opaque type is declared here + --> $DIR/unsized_coercion3.rs:11:19 + | +LL | fn hello() -> Box<impl Trait + ?Sized> { + | ^^^^^^^^^^^^^^^^^^^ + = note: required for the cast from `Box<impl Trait + ?Sized>` to `Box<dyn Send>` + +error[E0277]: the size for values of type `impl Trait + ?Sized` cannot be known at compilation time + --> $DIR/unsized_coercion3.rs:15:32 + | +LL | let y: Box<dyn Send> = x; + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `impl Trait + ?Sized` + = note: required for the cast from `Box<impl Trait + ?Sized>` to `Box<dyn Send>` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/unsized_coercion3.rs b/tests/ui/impl-trait/unsized_coercion3.rs new file mode 100644 index 00000000000..85950ac583e --- /dev/null +++ b/tests/ui/impl-trait/unsized_coercion3.rs @@ -0,0 +1,24 @@ +//! This test checks that opaque types get unsized instead of +//! constraining their hidden type to a trait object. + +//@ revisions: next old +//@[next] compile-flags: -Znext-solver + +trait Trait {} + +impl Trait for u32 {} + +fn hello() -> Box<impl Trait + ?Sized> { + if true { + let x = hello(); + //[next]~^ ERROR: type mismatch resolving `impl Trait + ?Sized <: dyn Send` + let y: Box<dyn Send> = x; + //[old]~^ ERROR: the size for values of type `impl Trait + ?Sized` cannot be know + //[old]~| ERROR: cannot check whether the hidden type of opaque type satisfies auto traits + } + Box::new(1u32) + //[next]~^ ERROR: mismatched types + //[next]~| ERROR: the size for values of type `impl Trait + ?Sized` cannot be know +} + +fn main() {} diff --git a/tests/ui/impl-trait/unsized_coercion4.rs b/tests/ui/impl-trait/unsized_coercion4.rs new file mode 100644 index 00000000000..1c4d5462cee --- /dev/null +++ b/tests/ui/impl-trait/unsized_coercion4.rs @@ -0,0 +1,20 @@ +//! This test checks that opaque types get unsized instead of +//! constraining their hidden type to a trait object. + +//@ revisions: next old +//@[next] compile-flags: -Znext-solver +//@check-pass + +trait Trait {} + +impl Trait for u32 {} + +fn hello() -> Box<impl Trait + ?Sized> { + if true { + let x = hello() as Box<u32>; + let y: Box<dyn Send> = x; + } + Box::new(1u32) +} + +fn main() {} diff --git a/tests/ui/impl-trait/unsized_coercion5.next.stderr b/tests/ui/impl-trait/unsized_coercion5.next.stderr new file mode 100644 index 00000000000..5644ac7ab04 --- /dev/null +++ b/tests/ui/impl-trait/unsized_coercion5.next.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/unsized_coercion5.rs:16:32 + | +LL | let y: Box<dyn Send> = x as Box<dyn Trait + Send>; + | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait `Send`, found trait `Trait + Send` + | | + | expected due to this + | + = note: expected struct `Box<dyn Send>` + found struct `Box<dyn Trait + Send>` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/unsized_coercion5.old.stderr b/tests/ui/impl-trait/unsized_coercion5.old.stderr new file mode 100644 index 00000000000..b6437266f27 --- /dev/null +++ b/tests/ui/impl-trait/unsized_coercion5.old.stderr @@ -0,0 +1,38 @@ +error[E0308]: mismatched types + --> $DIR/unsized_coercion5.rs:16:32 + | +LL | let y: Box<dyn Send> = x as Box<dyn Trait + Send>; + | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait `Send`, found trait `Trait + Send` + | | + | expected due to this + | + = note: expected struct `Box<dyn Send>` + found struct `Box<dyn Trait + Send>` + +error: cannot check whether the hidden type of opaque type satisfies auto traits + --> $DIR/unsized_coercion5.rs:16:32 + | +LL | let y: Box<dyn Send> = x as Box<dyn Trait + Send>; + | ^ + | + = note: fetching the hidden types of an opaque inside of the defining scope is not supported. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule +note: opaque type is declared here + --> $DIR/unsized_coercion5.rs:13:19 + | +LL | fn hello() -> Box<impl Trait + ?Sized> { + | ^^^^^^^^^^^^^^^^^^^ + = note: required for the cast from `Box<impl Trait + ?Sized>` to `Box<dyn Trait + Send>` + +error[E0277]: the size for values of type `impl Trait + ?Sized` cannot be known at compilation time + --> $DIR/unsized_coercion5.rs:16:32 + | +LL | let y: Box<dyn Send> = x as Box<dyn Trait + Send>; + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `impl Trait + ?Sized` + = note: required for the cast from `Box<impl Trait + ?Sized>` to `Box<dyn Trait + Send>` + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/unsized_coercion5.rs b/tests/ui/impl-trait/unsized_coercion5.rs new file mode 100644 index 00000000000..b007267a006 --- /dev/null +++ b/tests/ui/impl-trait/unsized_coercion5.rs @@ -0,0 +1,24 @@ +//! This test checks that opaque types get unsized instead of +//! constraining their hidden type to a trait object. + +//@ revisions: next old +//@[next] compile-flags: -Znext-solver + +#![feature(trait_upcasting)] + +trait Trait {} + +impl Trait for u32 {} + +fn hello() -> Box<impl Trait + ?Sized> { + if true { + let x = hello(); + let y: Box<dyn Send> = x as Box<dyn Trait + Send>; + //[old]~^ ERROR: the size for values of type `impl Trait + ?Sized` cannot be know + //[old]~| ERROR: cannot check whether the hidden type of opaque type satisfies auto traits + //~^^^ ERROR: mismatched types + } + Box::new(1u32) +} + +fn main() {} diff --git a/tests/ui/layout/base-layout-is-sized-ice-123078.stderr b/tests/ui/layout/base-layout-is-sized-ice-123078.stderr index 7e0a41a4367..455bd2cbf8b 100644 --- a/tests/ui/layout/base-layout-is-sized-ice-123078.stderr +++ b/tests/ui/layout/base-layout-is-sized-ice-123078.stderr @@ -23,7 +23,7 @@ LL | const C: S = unsafe { std::mem::transmute(()) }; | ^^^^^^^^^^^^^^^^^^^ | = note: source type: `()` (0 bits) - = note: target type: `S` (this type does not have a fixed size) + = note: target type: `S` (size can vary because of [u8]) error: aborting due to 2 previous errors diff --git a/tests/ui/lint/dead-code/unused-variant.rs b/tests/ui/lint/dead-code/unused-variant.rs index 82108fa9c13..7030681eb36 100644 --- a/tests/ui/lint/dead-code/unused-variant.rs +++ b/tests/ui/lint/dead-code/unused-variant.rs @@ -6,7 +6,22 @@ enum Enum { Variant2, } +#[derive(Debug)] +enum TupleVariant { + Variant1(i32), //~ ERROR: variant `Variant1` is never constructed + Variant2, +} + +#[derive(Debug)] +enum StructVariant { + Variant1 { id: i32 }, //~ ERROR: variant `Variant1` is never constructed + Variant2, +} + fn main() { let e = Enum::Variant2; e.clone(); + + let _ = TupleVariant::Variant2; + let _ = StructVariant::Variant2; } diff --git a/tests/ui/lint/dead-code/unused-variant.stderr b/tests/ui/lint/dead-code/unused-variant.stderr index 0ae15fde47b..4bc8cf420da 100644 --- a/tests/ui/lint/dead-code/unused-variant.stderr +++ b/tests/ui/lint/dead-code/unused-variant.stderr @@ -13,5 +13,25 @@ note: the lint level is defined here LL | #![deny(dead_code)] | ^^^^^^^^^ -error: aborting due to 1 previous error +error: variant `Variant1` is never constructed + --> $DIR/unused-variant.rs:11:5 + | +LL | enum TupleVariant { + | ------------ variant in this enum +LL | Variant1(i32), + | ^^^^^^^^ + | + = note: `TupleVariant` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis + +error: variant `Variant1` is never constructed + --> $DIR/unused-variant.rs:17:5 + | +LL | enum StructVariant { + | ------------- variant in this enum +LL | Variant1 { id: i32 }, + | ^^^^^^^^ + | + = note: `StructVariant` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis + +error: aborting due to 3 previous errors diff --git a/tests/ui/lint/suggestions.stderr b/tests/ui/lint/suggestions.stderr index 4caee777a13..a4871ead74b 100644 --- a/tests/ui/lint/suggestions.stderr +++ b/tests/ui/lint/suggestions.stderr @@ -41,9 +41,8 @@ warning: variable does not need to be mutable --> $DIR/suggestions.rs:54:13 | LL | let mut - | ______________^ - | | _____________| - | || + | _____________^ + | |_____________| LL | || b = 1; | ||____________-^ | |_____________| diff --git a/tests/ui/stability-attribute/issue-106589.stderr b/tests/ui/stability-attribute/issue-106589.stderr index ccf3f7164e3..c14ad2da04b 100644 --- a/tests/ui/stability-attribute/issue-106589.stderr +++ b/tests/ui/stability-attribute/issue-106589.stderr @@ -1,13 +1,13 @@ error[E0734]: stability attributes may not be used outside of the standard library - --> $DIR/issue-106589.rs:6:1 + --> $DIR/issue-106589.rs:3:1 | -LL | #[unstable(feature = "foo", issue = "none")] +LL | #![stable(feature = "foo", since = "1.0.0")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0734]: stability attributes may not be used outside of the standard library - --> $DIR/issue-106589.rs:3:1 + --> $DIR/issue-106589.rs:6:1 | -LL | #![stable(feature = "foo", since = "1.0.0")] +LL | #[unstable(feature = "foo", issue = "none")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/transmute/transmute-different-sizes.rs b/tests/ui/transmute/transmute-different-sizes.rs index 4fe79b9fa4e..ac98eb231dd 100644 --- a/tests/ui/transmute/transmute-different-sizes.rs +++ b/tests/ui/transmute/transmute-different-sizes.rs @@ -28,4 +28,24 @@ unsafe fn specializable<T>(x: u16) -> <T as Specializable>::Output { //~^ ERROR cannot transmute between types of different sizes, or dependently-sized types } +#[repr(align(32))] +struct OverAlignZST; +pub struct PtrAndOverAlignZST<T: ?Sized> { + _inner: *mut T, + _other: OverAlignZST, +} +pub unsafe fn shouldnt_work<T: ?Sized>(from: *mut T) -> PtrAndOverAlignZST<T> { + transmute(from) + //~^ ERROR cannot transmute between types of different sizes, or dependently-sized types +} + +pub struct PtrAndEmptyArray<T: ?Sized> { + _inner: *mut T, + _other: [*mut T; 0], +} +pub unsafe fn shouldnt_work2<T: ?Sized>(from: *mut T) -> PtrAndEmptyArray<T> { + std::mem::transmute(from) + //~^ ERROR cannot transmute between types of different sizes, or dependently-sized types +} + fn main() {} diff --git a/tests/ui/transmute/transmute-different-sizes.stderr b/tests/ui/transmute/transmute-different-sizes.stderr index 07a38df6973..ea3a017c16e 100644 --- a/tests/ui/transmute/transmute-different-sizes.stderr +++ b/tests/ui/transmute/transmute-different-sizes.stderr @@ -25,6 +25,24 @@ LL | transmute(x) = note: source type: `u16` (N bits) = note: target type: `<T as Specializable>::Output` (this type does not have a fixed size) -error: aborting due to 3 previous errors +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-different-sizes.rs:38:5 + | +LL | transmute(from) + | ^^^^^^^^^ + | + = note: source type: `*mut T` (pointer to `T`) + = note: target type: `PtrAndOverAlignZST<T>` (size can vary because of <T as Pointee>::Metadata) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-different-sizes.rs:47:5 + | +LL | std::mem::transmute(from) + | ^^^^^^^^^^^^^^^^^^^ + | + = note: source type: `*mut T` (pointer to `T`) + = note: target type: `PtrAndEmptyArray<T>` (size can vary because of <T as Pointee>::Metadata) + +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0512`. diff --git a/tests/ui/transmute/transmute-zst-generics.rs b/tests/ui/transmute/transmute-zst-generics.rs index 9aeb21923ea..b80ec794f83 100644 --- a/tests/ui/transmute/transmute-zst-generics.rs +++ b/tests/ui/transmute/transmute-zst-generics.rs @@ -24,11 +24,21 @@ unsafe fn cast_zst3<T>(from: ()) -> [[T; 0]; 8] { ::std::mem::transmute::<(), [[T; 0]; 8]>(from) } +// Verify transmute with an extra ZST field +pub struct PtrAndZst<T: ?Sized> { + _inner: *mut T, + _other: (), +} +pub unsafe fn cast_ptr<T: ?Sized>(from: *mut T) -> PtrAndZst<T> { + std::mem::transmute(from) +} + pub fn main() { unsafe { let _: [u32; 0] = cast_zst0(()); let _ = cast_zst1::<u32>([]); let _: [(u32, u32); 0] = cast_zst2(()); let _: [[u32; 0]; 8] = cast_zst3(()); + cast_ptr(&mut 42); }; } diff --git a/triagebot.toml b/triagebot.toml index 3abff0f1c78..62e0917efab 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -811,6 +811,9 @@ If appropriate, please update `CONFIG_CHANGE_HISTORY` in `src/bootstrap/src/util [mentions."src/bootstrap/src/core/build_steps/llvm.rs"] message = "This PR changes how LLVM is built. Consider updating src/bootstrap/download-ci-llvm-stamp." +[mentions."test/crashes"] +message = "This PR changes a file inside `tests/crashes`. If a crash was fixed, please move into the correspondig `ui` subdir and add 'Fixes #<issueNr>' to the pr description to autoclose the issue upon merge." + [mentions."tests/ui/deriving/deriving-all-codegen.stdout"] message = "Changes to the code generated for builtin derived traits." cc = ["@nnethercote"] @@ -949,6 +952,7 @@ bootstrap = [ "@albertlarsan68", "@onur-ozkan", "@clubby789", + "@kobzol", ] infra-ci = [ "@Mark-Simulacrum", |
