1
Fork 0

Auto merge of #113732 - matthiaskrgr:rollup-nm5qy4i, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #113625 (Structurally normalize in selection)
 - #113644 (misc bootstrap cleanups)
 - #113663 (Implement "items do not inherit unsafety" note for THIR unsafeck)
 - #113683 (remove outdated `FIXME`s in bootstrap internals)
 - #113709 (rustdoc: use src consistently over source in CSS/JS)
 - #113724 (Migrate GUI colors test to original CSS color format)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2023-07-15 18:13:26 +00:00
commit 425726d46b
58 changed files with 449 additions and 278 deletions

View file

@ -312,6 +312,8 @@ mir_build_unreachable_pattern = unreachable pattern
.label = unreachable pattern .label = unreachable pattern
.catchall_label = matches any value .catchall_label = matches any value
mir_build_unsafe_not_inherited = items do not inherit unsafety from separate enclosing items
mir_build_unsafe_op_in_unsafe_fn_borrow_of_layout_constrained_field_requires_unsafe = mir_build_unsafe_op_in_unsafe_fn_borrow_of_layout_constrained_field_requires_unsafe =
borrow of layout constrained field with interior mutability is unsafe and requires unsafe block (error E0133) borrow of layout constrained field with interior mutability is unsafe and requires unsafe block (error E0133)
.note = references to fields of layout constrained fields lose the constraints. Coupled with interior mutability, the field can be changed to invalid values .note = references to fields of layout constrained fields lose the constraints. Coupled with interior mutability, the field can be changed to invalid values

View file

@ -91,7 +91,12 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> {
kind.emit_unsafe_op_in_unsafe_fn_lint(self.tcx, self.hir_context, span); kind.emit_unsafe_op_in_unsafe_fn_lint(self.tcx, self.hir_context, span);
} }
SafetyContext::Safe => { SafetyContext::Safe => {
kind.emit_requires_unsafe_err(self.tcx, span, unsafe_op_in_unsafe_fn_allowed); kind.emit_requires_unsafe_err(
self.tcx,
span,
self.hir_context,
unsafe_op_in_unsafe_fn_allowed,
);
} }
} }
} }
@ -602,98 +607,164 @@ impl UnsafeOpKind {
&self, &self,
tcx: TyCtxt<'_>, tcx: TyCtxt<'_>,
span: Span, span: Span,
hir_context: hir::HirId,
unsafe_op_in_unsafe_fn_allowed: bool, unsafe_op_in_unsafe_fn_allowed: bool,
) { ) {
let note_non_inherited = tcx.hir().parent_iter(hir_context).find(|(id, node)| {
if let hir::Node::Expr(block) = node
&& let hir::ExprKind::Block(block, _) = block.kind
&& let hir::BlockCheckMode::UnsafeBlock(_) = block.rules
{
true
}
else if let Some(sig) = tcx.hir().fn_sig_by_hir_id(*id)
&& sig.header.is_unsafe()
{
true
} else {
false
}
});
let unsafe_not_inherited_note = if let Some((id, _)) = note_non_inherited {
let span = tcx.hir().span(id);
let span = tcx.sess.source_map().guess_head_span(span);
Some(UnsafeNotInheritedNote { span })
} else {
None
};
match self { match self {
CallToUnsafeFunction(Some(did)) if unsafe_op_in_unsafe_fn_allowed => { CallToUnsafeFunction(Some(did)) if unsafe_op_in_unsafe_fn_allowed => {
tcx.sess.emit_err(CallToUnsafeFunctionRequiresUnsafeUnsafeOpInUnsafeFnAllowed { tcx.sess.emit_err(CallToUnsafeFunctionRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
span, span,
unsafe_not_inherited_note,
function: &tcx.def_path_str(*did), function: &tcx.def_path_str(*did),
}); });
} }
CallToUnsafeFunction(Some(did)) => { CallToUnsafeFunction(Some(did)) => {
tcx.sess.emit_err(CallToUnsafeFunctionRequiresUnsafe { tcx.sess.emit_err(CallToUnsafeFunctionRequiresUnsafe {
span, span,
unsafe_not_inherited_note,
function: &tcx.def_path_str(*did), function: &tcx.def_path_str(*did),
}); });
} }
CallToUnsafeFunction(None) if unsafe_op_in_unsafe_fn_allowed => { CallToUnsafeFunction(None) if unsafe_op_in_unsafe_fn_allowed => {
tcx.sess.emit_err( tcx.sess.emit_err(
CallToUnsafeFunctionRequiresUnsafeNamelessUnsafeOpInUnsafeFnAllowed { span }, CallToUnsafeFunctionRequiresUnsafeNamelessUnsafeOpInUnsafeFnAllowed {
span,
unsafe_not_inherited_note,
},
); );
} }
CallToUnsafeFunction(None) => { CallToUnsafeFunction(None) => {
tcx.sess.emit_err(CallToUnsafeFunctionRequiresUnsafeNameless { span }); tcx.sess.emit_err(CallToUnsafeFunctionRequiresUnsafeNameless {
span,
unsafe_not_inherited_note,
});
} }
UseOfInlineAssembly if unsafe_op_in_unsafe_fn_allowed => { UseOfInlineAssembly if unsafe_op_in_unsafe_fn_allowed => {
tcx.sess tcx.sess.emit_err(UseOfInlineAssemblyRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
.emit_err(UseOfInlineAssemblyRequiresUnsafeUnsafeOpInUnsafeFnAllowed { span }); span,
unsafe_not_inherited_note,
});
} }
UseOfInlineAssembly => { UseOfInlineAssembly => {
tcx.sess.emit_err(UseOfInlineAssemblyRequiresUnsafe { span }); tcx.sess.emit_err(UseOfInlineAssemblyRequiresUnsafe {
span,
unsafe_not_inherited_note,
});
} }
InitializingTypeWith if unsafe_op_in_unsafe_fn_allowed => { InitializingTypeWith if unsafe_op_in_unsafe_fn_allowed => {
tcx.sess tcx.sess.emit_err(InitializingTypeWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
.emit_err(InitializingTypeWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed { span }); span,
unsafe_not_inherited_note,
});
} }
InitializingTypeWith => { InitializingTypeWith => {
tcx.sess.emit_err(InitializingTypeWithRequiresUnsafe { span }); tcx.sess.emit_err(InitializingTypeWithRequiresUnsafe {
span,
unsafe_not_inherited_note,
});
} }
UseOfMutableStatic if unsafe_op_in_unsafe_fn_allowed => { UseOfMutableStatic if unsafe_op_in_unsafe_fn_allowed => {
tcx.sess tcx.sess.emit_err(UseOfMutableStaticRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
.emit_err(UseOfMutableStaticRequiresUnsafeUnsafeOpInUnsafeFnAllowed { span }); span,
unsafe_not_inherited_note,
});
} }
UseOfMutableStatic => { UseOfMutableStatic => {
tcx.sess.emit_err(UseOfMutableStaticRequiresUnsafe { span }); tcx.sess
.emit_err(UseOfMutableStaticRequiresUnsafe { span, unsafe_not_inherited_note });
} }
UseOfExternStatic if unsafe_op_in_unsafe_fn_allowed => { UseOfExternStatic if unsafe_op_in_unsafe_fn_allowed => {
tcx.sess tcx.sess.emit_err(UseOfExternStaticRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
.emit_err(UseOfExternStaticRequiresUnsafeUnsafeOpInUnsafeFnAllowed { span }); span,
unsafe_not_inherited_note,
});
} }
UseOfExternStatic => { UseOfExternStatic => {
tcx.sess.emit_err(UseOfExternStaticRequiresUnsafe { span }); tcx.sess
.emit_err(UseOfExternStaticRequiresUnsafe { span, unsafe_not_inherited_note });
} }
DerefOfRawPointer if unsafe_op_in_unsafe_fn_allowed => { DerefOfRawPointer if unsafe_op_in_unsafe_fn_allowed => {
tcx.sess tcx.sess.emit_err(DerefOfRawPointerRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
.emit_err(DerefOfRawPointerRequiresUnsafeUnsafeOpInUnsafeFnAllowed { span }); span,
unsafe_not_inherited_note,
});
} }
DerefOfRawPointer => { DerefOfRawPointer => {
tcx.sess.emit_err(DerefOfRawPointerRequiresUnsafe { span }); tcx.sess
.emit_err(DerefOfRawPointerRequiresUnsafe { span, unsafe_not_inherited_note });
} }
AccessToUnionField if unsafe_op_in_unsafe_fn_allowed => { AccessToUnionField if unsafe_op_in_unsafe_fn_allowed => {
tcx.sess tcx.sess.emit_err(AccessToUnionFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
.emit_err(AccessToUnionFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed { span }); span,
unsafe_not_inherited_note,
});
} }
AccessToUnionField => { AccessToUnionField => {
tcx.sess.emit_err(AccessToUnionFieldRequiresUnsafe { span }); tcx.sess
.emit_err(AccessToUnionFieldRequiresUnsafe { span, unsafe_not_inherited_note });
} }
MutationOfLayoutConstrainedField if unsafe_op_in_unsafe_fn_allowed => { MutationOfLayoutConstrainedField if unsafe_op_in_unsafe_fn_allowed => {
tcx.sess.emit_err( tcx.sess.emit_err(
MutationOfLayoutConstrainedFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed { MutationOfLayoutConstrainedFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
span, span,
unsafe_not_inherited_note,
}, },
); );
} }
MutationOfLayoutConstrainedField => { MutationOfLayoutConstrainedField => {
tcx.sess.emit_err(MutationOfLayoutConstrainedFieldRequiresUnsafe { span }); tcx.sess.emit_err(MutationOfLayoutConstrainedFieldRequiresUnsafe {
span,
unsafe_not_inherited_note,
});
} }
BorrowOfLayoutConstrainedField if unsafe_op_in_unsafe_fn_allowed => { BorrowOfLayoutConstrainedField if unsafe_op_in_unsafe_fn_allowed => {
tcx.sess.emit_err( tcx.sess.emit_err(
BorrowOfLayoutConstrainedFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed { span }, BorrowOfLayoutConstrainedFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
span,
unsafe_not_inherited_note,
},
); );
} }
BorrowOfLayoutConstrainedField => { BorrowOfLayoutConstrainedField => {
tcx.sess.emit_err(BorrowOfLayoutConstrainedFieldRequiresUnsafe { span }); tcx.sess.emit_err(BorrowOfLayoutConstrainedFieldRequiresUnsafe {
span,
unsafe_not_inherited_note,
});
} }
CallToFunctionWith(did) if unsafe_op_in_unsafe_fn_allowed => { CallToFunctionWith(did) if unsafe_op_in_unsafe_fn_allowed => {
tcx.sess.emit_err(CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed { tcx.sess.emit_err(CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
span, span,
unsafe_not_inherited_note,
function: &tcx.def_path_str(*did), function: &tcx.def_path_str(*did),
}); });
} }
CallToFunctionWith(did) => { CallToFunctionWith(did) => {
tcx.sess.emit_err(CallToFunctionWithRequiresUnsafe { tcx.sess.emit_err(CallToFunctionWithRequiresUnsafe {
span, span,
unsafe_not_inherited_note,
function: &tcx.def_path_str(*did), function: &tcx.def_path_str(*did),
}); });
} }

View file

@ -119,6 +119,8 @@ pub struct CallToUnsafeFunctionRequiresUnsafe<'a> {
#[label] #[label]
pub span: Span, pub span: Span,
pub function: &'a str, pub function: &'a str,
#[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
@ -128,6 +130,8 @@ pub struct CallToUnsafeFunctionRequiresUnsafeNameless {
#[primary_span] #[primary_span]
#[label] #[label]
pub span: Span, pub span: Span,
#[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
@ -138,6 +142,8 @@ pub struct CallToUnsafeFunctionRequiresUnsafeUnsafeOpInUnsafeFnAllowed<'a> {
#[label] #[label]
pub span: Span, pub span: Span,
pub function: &'a str, pub function: &'a str,
#[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
@ -150,6 +156,8 @@ pub struct CallToUnsafeFunctionRequiresUnsafeNamelessUnsafeOpInUnsafeFnAllowed {
#[primary_span] #[primary_span]
#[label] #[label]
pub span: Span, pub span: Span,
#[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
@ -159,6 +167,8 @@ pub struct UseOfInlineAssemblyRequiresUnsafe {
#[primary_span] #[primary_span]
#[label] #[label]
pub span: Span, pub span: Span,
#[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
@ -168,6 +178,8 @@ pub struct UseOfInlineAssemblyRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
#[primary_span] #[primary_span]
#[label] #[label]
pub span: Span, pub span: Span,
#[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
@ -177,6 +189,8 @@ pub struct InitializingTypeWithRequiresUnsafe {
#[primary_span] #[primary_span]
#[label] #[label]
pub span: Span, pub span: Span,
#[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
@ -189,6 +203,8 @@ pub struct InitializingTypeWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
#[primary_span] #[primary_span]
#[label] #[label]
pub span: Span, pub span: Span,
#[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
@ -198,6 +214,8 @@ pub struct UseOfMutableStaticRequiresUnsafe {
#[primary_span] #[primary_span]
#[label] #[label]
pub span: Span, pub span: Span,
#[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
@ -207,6 +225,8 @@ pub struct UseOfMutableStaticRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
#[primary_span] #[primary_span]
#[label] #[label]
pub span: Span, pub span: Span,
#[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
@ -216,6 +236,8 @@ pub struct UseOfExternStaticRequiresUnsafe {
#[primary_span] #[primary_span]
#[label] #[label]
pub span: Span, pub span: Span,
#[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
@ -225,6 +247,8 @@ pub struct UseOfExternStaticRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
#[primary_span] #[primary_span]
#[label] #[label]
pub span: Span, pub span: Span,
#[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
@ -234,6 +258,8 @@ pub struct DerefOfRawPointerRequiresUnsafe {
#[primary_span] #[primary_span]
#[label] #[label]
pub span: Span, pub span: Span,
#[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
@ -243,6 +269,8 @@ pub struct DerefOfRawPointerRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
#[primary_span] #[primary_span]
#[label] #[label]
pub span: Span, pub span: Span,
#[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
@ -252,6 +280,8 @@ pub struct AccessToUnionFieldRequiresUnsafe {
#[primary_span] #[primary_span]
#[label] #[label]
pub span: Span, pub span: Span,
#[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
@ -261,6 +291,8 @@ pub struct AccessToUnionFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed {
#[primary_span] #[primary_span]
#[label] #[label]
pub span: Span, pub span: Span,
#[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
@ -270,6 +302,8 @@ pub struct MutationOfLayoutConstrainedFieldRequiresUnsafe {
#[primary_span] #[primary_span]
#[label] #[label]
pub span: Span, pub span: Span,
#[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
@ -282,6 +316,8 @@ pub struct MutationOfLayoutConstrainedFieldRequiresUnsafeUnsafeOpInUnsafeFnAllow
#[primary_span] #[primary_span]
#[label] #[label]
pub span: Span, pub span: Span,
#[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
@ -291,6 +327,8 @@ pub struct BorrowOfLayoutConstrainedFieldRequiresUnsafe {
#[primary_span] #[primary_span]
#[label] #[label]
pub span: Span, pub span: Span,
#[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
@ -303,6 +341,8 @@ pub struct BorrowOfLayoutConstrainedFieldRequiresUnsafeUnsafeOpInUnsafeFnAllowed
#[primary_span] #[primary_span]
#[label] #[label]
pub span: Span, pub span: Span,
#[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
@ -313,6 +353,8 @@ pub struct CallToFunctionWithRequiresUnsafe<'a> {
#[label] #[label]
pub span: Span, pub span: Span,
pub function: &'a str, pub function: &'a str,
#[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
@ -323,6 +365,15 @@ pub struct CallToFunctionWithRequiresUnsafeUnsafeOpInUnsafeFnAllowed<'a> {
#[label] #[label]
pub span: Span, pub span: Span,
pub function: &'a str, pub function: &'a str,
#[subdiagnostic]
pub unsafe_not_inherited_note: Option<UnsafeNotInheritedNote>,
}
#[derive(Subdiagnostic)]
#[label(mir_build_unsafe_not_inherited)]
pub struct UnsafeNotInheritedNote {
#[primary_span]
pub span: Span,
} }
#[derive(LintDiagnostic)] #[derive(LintDiagnostic)]

View file

@ -5,7 +5,7 @@ use rustc_hir::def_id::DefId;
use rustc_infer::infer::{DefineOpaqueTypes, InferCtxt, InferOk}; use rustc_infer::infer::{DefineOpaqueTypes, InferCtxt, InferOk};
use rustc_infer::traits::util::supertraits; use rustc_infer::traits::util::supertraits;
use rustc_infer::traits::{ use rustc_infer::traits::{
Obligation, PolyTraitObligation, PredicateObligation, Selection, SelectionResult, Obligation, PolyTraitObligation, PredicateObligation, Selection, SelectionResult, TraitEngine,
}; };
use rustc_middle::traits::solve::{CanonicalInput, Certainty, Goal}; use rustc_middle::traits::solve::{CanonicalInput, Certainty, Goal};
use rustc_middle::traits::{ use rustc_middle::traits::{
@ -20,6 +20,8 @@ use crate::solve::eval_ctxt::{EvalCtxt, GenerateProofTree};
use crate::solve::inspect::ProofTreeBuilder; use crate::solve::inspect::ProofTreeBuilder;
use crate::solve::search_graph::OverflowHandler; use crate::solve::search_graph::OverflowHandler;
use crate::traits::vtable::{count_own_vtable_entries, prepare_vtable_segments, VtblSegment}; use crate::traits::vtable::{count_own_vtable_entries, prepare_vtable_segments, VtblSegment};
use crate::traits::StructurallyNormalizeExt;
use crate::traits::TraitEngineExt;
pub trait InferCtxtSelectExt<'tcx> { pub trait InferCtxtSelectExt<'tcx> {
fn select_in_new_trait_solver( fn select_in_new_trait_solver(
@ -228,18 +230,24 @@ fn rematch_object<'tcx>(
goal: Goal<'tcx, ty::TraitPredicate<'tcx>>, goal: Goal<'tcx, ty::TraitPredicate<'tcx>>,
mut nested: Vec<PredicateObligation<'tcx>>, mut nested: Vec<PredicateObligation<'tcx>>,
) -> SelectionResult<'tcx, Selection<'tcx>> { ) -> SelectionResult<'tcx, Selection<'tcx>> {
let self_ty = goal.predicate.self_ty(); let a_ty = structurally_normalize(goal.predicate.self_ty(), infcx, goal.param_env, &mut nested);
let ty::Dynamic(data, _, source_kind) = *self_ty.kind() else { bug!() }; let ty::Dynamic(data, _, source_kind) = *a_ty.kind() else { bug!() };
let source_trait_ref = data.principal().unwrap().with_self_ty(infcx.tcx, self_ty); let source_trait_ref = data.principal().unwrap().with_self_ty(infcx.tcx, a_ty);
let (is_upcasting, target_trait_ref_unnormalized) = let (is_upcasting, target_trait_ref_unnormalized) =
if Some(goal.predicate.def_id()) == infcx.tcx.lang_items().unsize_trait() { if Some(goal.predicate.def_id()) == infcx.tcx.lang_items().unsize_trait() {
assert_eq!(source_kind, ty::Dyn, "cannot upcast dyn*"); assert_eq!(source_kind, ty::Dyn, "cannot upcast dyn*");
if let ty::Dynamic(data, _, ty::Dyn) = goal.predicate.trait_ref.args.type_at(1).kind() { let b_ty = structurally_normalize(
goal.predicate.trait_ref.args.type_at(1),
infcx,
goal.param_env,
&mut nested,
);
if let ty::Dynamic(data, _, ty::Dyn) = *b_ty.kind() {
// FIXME: We also need to ensure that the source lifetime outlives the // FIXME: We also need to ensure that the source lifetime outlives the
// target lifetime. This doesn't matter for codegen, though, and only // target lifetime. This doesn't matter for codegen, though, and only
// *really* matters if the goal's certainty is ambiguous. // *really* matters if the goal's certainty is ambiguous.
(true, data.principal().unwrap().with_self_ty(infcx.tcx, self_ty)) (true, data.principal().unwrap().with_self_ty(infcx.tcx, a_ty))
} else { } else {
bug!() bug!()
} }
@ -447,3 +455,22 @@ fn rematch_unsize<'tcx>(
Ok(Some(ImplSource::Builtin(nested))) Ok(Some(ImplSource::Builtin(nested)))
} }
fn structurally_normalize<'tcx>(
ty: Ty<'tcx>,
infcx: &InferCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>,
nested: &mut Vec<PredicateObligation<'tcx>>,
) -> Ty<'tcx> {
if matches!(ty.kind(), ty::Alias(..)) {
let mut engine = <dyn TraitEngine<'tcx>>::new(infcx);
let normalized_ty = infcx
.at(&ObligationCause::dummy(), param_env)
.structurally_normalize(ty, &mut *engine)
.expect("normalization shouldn't fail if we got to here");
nested.extend(engine.pending_obligations());
normalized_ty
} else {
ty
}
}

View file

@ -914,12 +914,7 @@ class RustBuild(object):
# preserve existing RUSTFLAGS # preserve existing RUSTFLAGS
env.setdefault("RUSTFLAGS", "") env.setdefault("RUSTFLAGS", "")
# we need to explicitly add +xgot here so that we can successfully bootstrap
# a usable stage1 compiler
# FIXME: remove this if condition on the next bootstrap bump
# cfg(bootstrap)
if self.build_triple().startswith('mips'):
env["RUSTFLAGS"] += " -Ctarget-feature=+xgot"
target_features = [] target_features = []
if self.get_toml("crt-static", build_section) == "true": if self.get_toml("crt-static", build_section) == "true":
target_features += ["+crt-static"] target_features += ["+crt-static"]

View file

@ -395,7 +395,7 @@ impl StepDescription {
eprintln!( eprintln!(
"note: if you are adding a new Step to bootstrap itself, make sure you register it with `describe!`" "note: if you are adding a new Step to bootstrap itself, make sure you register it with `describe!`"
); );
crate::detail_exit_macro!(1); crate::exit!(1);
} }
} }
} }
@ -939,21 +939,6 @@ impl<'a> Builder<'a> {
Self::new_internal(build, kind, paths.to_owned()) Self::new_internal(build, kind, paths.to_owned())
} }
/// Creates a new standalone builder for use outside of the normal process
pub fn new_standalone(
build: &mut Build,
kind: Kind,
paths: Vec<PathBuf>,
stage: Option<u32>,
) -> Builder<'_> {
// FIXME: don't mutate `build`
if let Some(stage) = stage {
build.config.stage = stage;
}
Self::new_internal(build, kind, paths.to_owned())
}
pub fn execute_cli(&self) { pub fn execute_cli(&self) {
self.run_step_descriptions(&Builder::get_step_descriptions(self.kind), &self.paths); self.run_step_descriptions(&Builder::get_step_descriptions(self.kind), &self.paths);
} }
@ -1375,7 +1360,7 @@ impl<'a> Builder<'a> {
"error: `x.py clippy` requires a host `rustc` toolchain with the `clippy` component" "error: `x.py clippy` requires a host `rustc` toolchain with the `clippy` component"
); );
eprintln!("help: try `rustup component add clippy`"); eprintln!("help: try `rustup component add clippy`");
crate::detail_exit_macro!(1); crate::exit!(1);
}); });
if !t!(std::str::from_utf8(&output.stdout)).contains("nightly") { if !t!(std::str::from_utf8(&output.stdout)).contains("nightly") {
rustflags.arg("--cfg=bootstrap"); rustflags.arg("--cfg=bootstrap");

View file

@ -222,13 +222,6 @@ fn copy_third_party_objects(
) -> Vec<(PathBuf, DependencyType)> { ) -> Vec<(PathBuf, DependencyType)> {
let mut target_deps = vec![]; let mut target_deps = vec![];
// FIXME: remove this in 2021
if target == "x86_64-fortanix-unknown-sgx" {
if env::var_os("X86_FORTANIX_SGX_LIBS").is_some() {
builder.info("Warning: X86_FORTANIX_SGX_LIBS environment variable is ignored, libunwind is now compiled as part of rustbuild");
}
}
if builder.config.sanitizers_enabled(target) && compiler.stage != 0 { if builder.config.sanitizers_enabled(target) && compiler.stage != 0 {
// The sanitizers are only copied in stage1 or above, // The sanitizers are only copied in stage1 or above,
// to avoid creating dependency on LLVM. // to avoid creating dependency on LLVM.
@ -1820,7 +1813,7 @@ pub fn run_cargo(
}); });
if !ok { if !ok {
crate::detail_exit_macro!(1); crate::exit!(1);
} }
// Ok now we need to actually find all the files listed in `toplevel`. We've // Ok now we need to actually find all the files listed in `toplevel`. We've

View file

@ -23,7 +23,7 @@ use crate::channel::{self, GitInfo};
pub use crate::flags::Subcommand; pub use crate::flags::Subcommand;
use crate::flags::{Color, Flags, Warnings}; use crate::flags::{Color, Flags, Warnings};
use crate::util::{exe, output, t}; use crate::util::{exe, output, t};
use build_helper::detail_exit_macro; use build_helper::exit;
use once_cell::sync::OnceCell; use once_cell::sync::OnceCell;
use semver::Version; use semver::Version;
use serde::{Deserialize, Deserializer}; use serde::{Deserialize, Deserializer};
@ -646,7 +646,7 @@ macro_rules! define_config {
panic!("overriding existing option") panic!("overriding existing option")
} else { } else {
eprintln!("overriding existing option: `{}`", stringify!($field)); eprintln!("overriding existing option: `{}`", stringify!($field));
detail_exit_macro!(2); exit!(2);
} }
} else { } else {
self.$field = other.$field; self.$field = other.$field;
@ -745,7 +745,7 @@ impl<T> Merge for Option<T> {
panic!("overriding existing option") panic!("overriding existing option")
} else { } else {
eprintln!("overriding existing option"); eprintln!("overriding existing option");
detail_exit_macro!(2); exit!(2);
} }
} else { } else {
*self = other; *self = other;
@ -1101,7 +1101,7 @@ impl Config {
.and_then(|table: toml::Value| TomlConfig::deserialize(table)) .and_then(|table: toml::Value| TomlConfig::deserialize(table))
.unwrap_or_else(|err| { .unwrap_or_else(|err| {
eprintln!("failed to parse TOML configuration '{}': {err}", file.display()); eprintln!("failed to parse TOML configuration '{}': {err}", file.display());
detail_exit_macro!(2); exit!(2);
}) })
} }
Self::parse_inner(args, get_toml) Self::parse_inner(args, get_toml)
@ -1135,7 +1135,7 @@ impl Config {
eprintln!( eprintln!(
"Cannot use both `llvm_bolt_profile_generate` and `llvm_bolt_profile_use` at the same time" "Cannot use both `llvm_bolt_profile_generate` and `llvm_bolt_profile_use` at the same time"
); );
detail_exit_macro!(1); exit!(1);
} }
// Infer the rest of the configuration. // Infer the rest of the configuration.
@ -1259,7 +1259,7 @@ impl Config {
} }
} }
eprintln!("failed to parse override `{option}`: `{err}"); eprintln!("failed to parse override `{option}`: `{err}");
detail_exit_macro!(2) exit!(2)
} }
toml.merge(override_toml, ReplaceOpt::Override); toml.merge(override_toml, ReplaceOpt::Override);
@ -2007,7 +2007,7 @@ impl Config {
"Unexpected rustc version: {}, we should use {}/{} to build source with {}", "Unexpected rustc version: {}, we should use {}/{} to build source with {}",
rustc_version, prev_version, source_version, source_version rustc_version, prev_version, source_version, source_version
); );
detail_exit_macro!(1); exit!(1);
} }
} }
@ -2043,7 +2043,7 @@ impl Config {
println!("help: maybe your repository history is too shallow?"); println!("help: maybe your repository history is too shallow?");
println!("help: consider disabling `download-rustc`"); println!("help: consider disabling `download-rustc`");
println!("help: or fetch enough history to include one upstream commit"); println!("help: or fetch enough history to include one upstream commit");
crate::detail_exit_macro!(1); crate::exit!(1);
} }
// Warn if there were changes to the compiler or standard library since the ancestor commit. // Warn if there were changes to the compiler or standard library since the ancestor commit.

View file

@ -253,7 +253,7 @@ impl Config {
if !help_on_error.is_empty() { if !help_on_error.is_empty() {
eprintln!("{}", help_on_error); eprintln!("{}", help_on_error);
} }
crate::detail_exit_macro!(1); crate::exit!(1);
} }
} }

View file

@ -193,7 +193,7 @@ impl Flags {
} else { } else {
panic!("No paths available for subcommand `{}`", subcommand.as_str()); panic!("No paths available for subcommand `{}`", subcommand.as_str());
} }
crate::detail_exit_macro!(0); crate::exit!(0);
} }
Flags::parse_from(it) Flags::parse_from(it)
@ -538,7 +538,7 @@ pub fn get_completion<G: clap_complete::Generator>(shell: G, path: &Path) -> Opt
} else { } else {
std::fs::read_to_string(path).unwrap_or_else(|_| { std::fs::read_to_string(path).unwrap_or_else(|_| {
eprintln!("couldn't read {}", path.display()); eprintln!("couldn't read {}", path.display());
crate::detail_exit_macro!(1) crate::exit!(1)
}) })
}; };
let mut buf = Vec::new(); let mut buf = Vec::new();

View file

@ -40,7 +40,7 @@ fn rustfmt(src: &Path, rustfmt: &Path, paths: &[PathBuf], check: bool) -> impl F
code, run `./x.py fmt` instead.", code, run `./x.py fmt` instead.",
cmd_debug, cmd_debug,
); );
crate::detail_exit_macro!(1); crate::exit!(1);
} }
true true
} }
@ -200,7 +200,7 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
let rustfmt_path = build.initial_rustfmt().unwrap_or_else(|| { let rustfmt_path = build.initial_rustfmt().unwrap_or_else(|| {
eprintln!("./x.py fmt is not supported on this channel"); eprintln!("./x.py fmt is not supported on this channel");
crate::detail_exit_macro!(1); crate::exit!(1);
}); });
assert!(rustfmt_path.exists(), "{}", rustfmt_path.display()); assert!(rustfmt_path.exists(), "{}", rustfmt_path.display());
let src = build.src.clone(); let src = build.src.clone();

View file

@ -27,7 +27,7 @@ use std::process::{Command, Stdio};
use std::str; use std::str;
use build_helper::ci::{gha, CiEnv}; use build_helper::ci::{gha, CiEnv};
use build_helper::detail_exit_macro; use build_helper::exit;
use channel::GitInfo; use channel::GitInfo;
use config::{DryRun, Target}; use config::{DryRun, Target};
use filetime::FileTime; use filetime::FileTime;
@ -191,7 +191,7 @@ pub enum GitRepo {
/// although most functions are implemented as free functions rather than /// although most functions are implemented as free functions rather than
/// methods specifically on this structure itself (to make it easier to /// methods specifically on this structure itself (to make it easier to
/// organize). /// organize).
#[cfg_attr(not(feature = "build-metrics"), derive(Clone))] #[derive(Clone)]
pub struct Build { pub struct Build {
/// User-specified configuration from `config.toml`. /// User-specified configuration from `config.toml`.
config: Config, config: Config,
@ -711,7 +711,7 @@ impl Build {
for failure in failures.iter() { for failure in failures.iter() {
eprintln!(" - {}\n", failure); eprintln!(" - {}\n", failure);
} }
detail_exit_macro!(1); exit!(1);
} }
#[cfg(feature = "build-metrics")] #[cfg(feature = "build-metrics")]
@ -1529,7 +1529,7 @@ impl Build {
"Error: Unable to find the stamp file {}, did you try to keep a nonexistent build stage?", "Error: Unable to find the stamp file {}, did you try to keep a nonexistent build stage?",
stamp.display() stamp.display()
); );
crate::detail_exit_macro!(1); crate::exit!(1);
} }
let mut paths = Vec::new(); let mut paths = Vec::new();
@ -1721,7 +1721,7 @@ Alternatively, set `download-ci-llvm = true` in that `[llvm]` section
to download LLVM rather than building it. to download LLVM rather than building it.
" "
); );
detail_exit_macro!(1); exit!(1);
} }
} }

View file

@ -40,6 +40,13 @@ pub(crate) struct BuildMetrics {
state: RefCell<MetricsState>, state: RefCell<MetricsState>,
} }
/// NOTE: this isn't really cloning anything, but `x suggest` doesn't need metrics so this is probably ok.
impl Clone for BuildMetrics {
fn clone(&self) -> Self {
Self::init()
}
}
impl BuildMetrics { impl BuildMetrics {
pub(crate) fn init() -> Self { pub(crate) fn init() -> Self {
let state = RefCell::new(MetricsState { let state = RefCell::new(MetricsState {

View file

@ -30,7 +30,7 @@ pub(crate) fn try_run_tests(builder: &Builder<'_>, cmd: &mut Command, stream: bo
if !run_tests(builder, cmd, stream) { if !run_tests(builder, cmd, stream) {
if builder.fail_fast { if builder.fail_fast {
crate::detail_exit_macro!(1); crate::exit!(1);
} else { } else {
let mut failures = builder.delayed_failures.borrow_mut(); let mut failures = builder.delayed_failures.borrow_mut();
failures.push(format!("{cmd:?}")); failures.push(format!("{cmd:?}"));

View file

@ -104,7 +104,7 @@ You should install cmake, or set `download-ci-llvm = true` in the
than building it. than building it.
" "
); );
crate::detail_exit_macro!(1); crate::exit!(1);
} }
} }

View file

@ -203,7 +203,7 @@ fn setup_config_toml(path: &PathBuf, profile: Profile, config: &Config) {
"note: this will use the configuration in {}", "note: this will use the configuration in {}",
profile.include_path(&config.src).display() profile.include_path(&config.src).display()
); );
crate::detail_exit_macro!(1); crate::exit!(1);
} }
let settings = format!( let settings = format!(
@ -389,7 +389,7 @@ pub fn interactive_path() -> io::Result<Profile> {
io::stdin().read_line(&mut input)?; io::stdin().read_line(&mut input)?;
if input.is_empty() { if input.is_empty() {
eprintln!("EOF on stdin, when expecting answer to question. Giving up."); eprintln!("EOF on stdin, when expecting answer to question. Giving up.");
crate::detail_exit_macro!(1); crate::exit!(1);
} }
break match parse_with_abbrev(&input) { break match parse_with_abbrev(&input) {
Ok(profile) => profile, Ok(profile) => profile,

View file

@ -4,18 +4,11 @@ use std::str::FromStr;
use std::path::PathBuf; use std::path::PathBuf;
use crate::{ use clap::Parser;
builder::{Builder, Kind},
tool::Tool,
};
#[cfg(feature = "build-metrics")] use crate::{builder::Builder, tool::Tool};
pub fn suggest(builder: &Builder<'_>, run: bool) {
panic!("`x suggest` is not supported with `build-metrics`")
}
/// Suggests a list of possible `x.py` commands to run based on modified files in branch. /// Suggests a list of possible `x.py` commands to run based on modified files in branch.
#[cfg(not(feature = "build-metrics"))]
pub fn suggest(builder: &Builder<'_>, run: bool) { pub fn suggest(builder: &Builder<'_>, run: bool) {
let suggestions = let suggestions =
builder.tool_cmd(Tool::SuggestTests).output().expect("failed to run `suggest-tests` tool"); builder.tool_cmd(Tool::SuggestTests).output().expect("failed to run `suggest-tests` tool");
@ -67,12 +60,13 @@ pub fn suggest(builder: &Builder<'_>, run: bool) {
if run { if run {
for sug in suggestions { for sug in suggestions {
let mut build = builder.build.clone(); let mut build: crate::Build = builder.build.clone();
build.config.paths = sug.2;
let builder = build.config.cmd = crate::flags::Flags::parse_from(["x.py", sug.0]).cmd;
Builder::new_standalone(&mut build, Kind::parse(&sug.0).unwrap(), sug.2, sug.1); if let Some(stage) = sug.1 {
build.config.stage = stage;
builder.execute_cli() }
build.build();
} }
} else { } else {
println!("help: consider using the `--run` flag to automatically run suggested tests"); println!("help: consider using the `--run` flag to automatically run suggested tests");

View file

@ -833,7 +833,7 @@ impl Step for Clippy {
} }
if !builder.config.cmd.bless() { if !builder.config.cmd.bless() {
crate::detail_exit_macro!(1); crate::exit!(1);
} }
} }
} }
@ -1141,7 +1141,7 @@ help: to skip test's attempt to check tidiness, pass `--exclude src/tools/tidy`
PATH = inferred_rustfmt_dir.display(), PATH = inferred_rustfmt_dir.display(),
CHAN = builder.config.channel, CHAN = builder.config.channel,
); );
crate::detail_exit_macro!(1); crate::exit!(1);
} }
crate::format::format(&builder, !builder.config.cmd.bless(), &[]); crate::format::format(&builder, !builder.config.cmd.bless(), &[]);
} }
@ -1164,7 +1164,7 @@ help: to skip test's attempt to check tidiness, pass `--exclude src/tools/tidy`
eprintln!( eprintln!(
"x.py completions were changed; run `x.py run generate-completions` to update them" "x.py completions were changed; run `x.py run generate-completions` to update them"
); );
crate::detail_exit_macro!(1); crate::exit!(1);
} }
} }
} }
@ -1475,7 +1475,7 @@ help: to test the compiler, use `--stage 1` instead
help: to test the standard library, use `--stage 0 library/std` instead help: to test the standard library, use `--stage 0 library/std` instead
note: if you're sure you want to do this, please open an issue as to why. In the meantime, you can override this with `COMPILETEST_FORCE_STAGE0=1`." note: if you're sure you want to do this, please open an issue as to why. In the meantime, you can override this with `COMPILETEST_FORCE_STAGE0=1`."
); );
crate::detail_exit_macro!(1); crate::exit!(1);
} }
let mut compiler = self.compiler; let mut compiler = self.compiler;

View file

@ -117,7 +117,7 @@ impl Step for ToolBuild {
if !is_expected { if !is_expected {
if !is_optional_tool { if !is_optional_tool {
crate::detail_exit_macro!(1); crate::exit!(1);
} else { } else {
None None
} }

View file

@ -91,7 +91,7 @@ fn print_error(tool: &str, submodule: &str) {
eprintln!("If you do NOT intend to update '{}', please ensure you did not accidentally", tool); eprintln!("If you do NOT intend to update '{}', please ensure you did not accidentally", tool);
eprintln!("change the submodule at '{}'. You may ask your reviewer for the", submodule); eprintln!("change the submodule at '{}'. You may ask your reviewer for the", submodule);
eprintln!("proper steps."); eprintln!("proper steps.");
crate::detail_exit_macro!(3); crate::exit!(3);
} }
fn check_changed_files(toolstates: &HashMap<Box<str>, ToolState>) { fn check_changed_files(toolstates: &HashMap<Box<str>, ToolState>) {
@ -106,7 +106,7 @@ fn check_changed_files(toolstates: &HashMap<Box<str>, ToolState>) {
Ok(o) => o, Ok(o) => o,
Err(e) => { Err(e) => {
eprintln!("Failed to get changed files: {:?}", e); eprintln!("Failed to get changed files: {:?}", e);
crate::detail_exit_macro!(1); crate::exit!(1);
} }
}; };
@ -177,7 +177,7 @@ impl Step for ToolStateCheck {
} }
if did_error { if did_error {
crate::detail_exit_macro!(1); crate::exit!(1);
} }
check_changed_files(&toolstates); check_changed_files(&toolstates);
@ -223,7 +223,7 @@ impl Step for ToolStateCheck {
} }
if did_error { if did_error {
crate::detail_exit_macro!(1); crate::exit!(1);
} }
if builder.config.channel == "nightly" && env::var_os("TOOLSTATE_PUBLISH").is_some() { if builder.config.channel == "nightly" && env::var_os("TOOLSTATE_PUBLISH").is_some() {

View file

@ -229,7 +229,7 @@ pub fn is_valid_test_suite_arg<'a, P: AsRef<Path>>(
pub fn run(cmd: &mut Command, print_cmd_on_fail: bool) { pub fn run(cmd: &mut Command, print_cmd_on_fail: bool) {
if try_run(cmd, print_cmd_on_fail).is_err() { if try_run(cmd, print_cmd_on_fail).is_err() {
crate::detail_exit_macro!(1); crate::exit!(1);
} }
} }
@ -253,7 +253,7 @@ pub fn check_run(cmd: &mut Command, print_cmd_on_fail: bool) -> bool {
pub fn run_suppressed(cmd: &mut Command) { pub fn run_suppressed(cmd: &mut Command) {
if !try_run_suppressed(cmd) { if !try_run_suppressed(cmd) {
crate::detail_exit_macro!(1); crate::exit!(1);
} }
} }

View file

@ -1821,9 +1821,9 @@ fn render_rightside(
); );
if let Some(l) = src_href { if let Some(l) = src_href {
if has_stability { if has_stability {
write!(rightside, " · <a class=\"srclink\" href=\"{}\">source</a>", l) write!(rightside, " · <a class=\"src\" href=\"{}\">source</a>", l)
} else { } else {
write!(rightside, "<a class=\"srclink rightside\" href=\"{}\">source</a>", l) write!(rightside, "<a class=\"src rightside\" href=\"{}\">source</a>", l)
} }
} }
if has_stability && has_src_ref { if has_stability && has_src_ref {

View file

@ -270,7 +270,7 @@ pub(super) fn write_shared(
hierarchy.add_path(source); hierarchy.add_path(source);
} }
let hierarchy = Rc::try_unwrap(hierarchy).unwrap(); let hierarchy = Rc::try_unwrap(hierarchy).unwrap();
let dst = cx.dst.join(&format!("source-files{}.js", cx.shared.resource_suffix)); let dst = cx.dst.join(&format!("src-files{}.js", cx.shared.resource_suffix));
let make_sources = || { let make_sources = || {
let (mut all_sources, _krates) = let (mut all_sources, _krates) =
try_err!(collect_json(&dst, krate.name(cx.tcx()).as_str()), &dst); try_err!(collect_json(&dst, krate.name(cx.tcx()).as_str()), &dst);
@ -286,12 +286,12 @@ pub(super) fn write_shared(
.replace("\\\"", "\\\\\"") .replace("\\\"", "\\\\\"")
)); ));
all_sources.sort(); all_sources.sort();
let mut v = String::from("var sourcesIndex = JSON.parse('{\\\n"); let mut v = String::from("var srcIndex = JSON.parse('{\\\n");
v.push_str(&all_sources.join(",\\\n")); v.push_str(&all_sources.join(",\\\n"));
v.push_str("\\\n}');\ncreateSourceSidebar();\n"); v.push_str("\\\n}');\ncreateSrcSidebar();\n");
Ok(v.into_bytes()) Ok(v.into_bytes())
}; };
write_invocation_specific("source-files.js", &make_sources)?; write_invocation_specific("src-files.js", &make_sources)?;
} }
// Update the search index and crate list. // Update the search index and crate list.

View file

@ -227,7 +227,7 @@ impl SourceCollector<'_, '_> {
let desc = format!("Source of the Rust file `{}`.", filename.prefer_remapped()); let desc = format!("Source of the Rust file `{}`.", filename.prefer_remapped());
let page = layout::Page { let page = layout::Page {
title: &title, title: &title,
css_class: "source", css_class: "src",
root_path: &root_path, root_path: &root_path,
static_root_path: shared.static_root_path.as_deref(), static_root_path: shared.static_root_path.as_deref(),
description: &desc, description: &desc,

View file

@ -19,7 +19,7 @@ nav.sub {
display: none; display: none;
} }
.source .sidebar { .src .sidebar {
display: none; display: none;
} }

View file

@ -194,7 +194,7 @@ h1, h2, h3, h4, h5, h6,
.item-name > a, .item-name > a,
.out-of-band, .out-of-band,
span.since, span.since,
a.srclink, a.src,
#help-button > a, #help-button > a,
summary.hideme, summary.hideme,
.scraped-example-list, .scraped-example-list,
@ -206,7 +206,7 @@ ul.all-items {
#toggle-all-docs, #toggle-all-docs,
a.anchor, a.anchor,
.small-section-header a, .small-section-header a,
#source-sidebar a, #src-sidebar a,
.rust a, .rust a,
.sidebar h2 a, .sidebar h2 a,
.sidebar h3 a, .sidebar h3 a,
@ -315,7 +315,7 @@ main {
min-width: 0; /* avoid growing beyond the size limit */ min-width: 0; /* avoid growing beyond the size limit */
} }
.source main { .src main {
padding: 15px; padding: 15px;
} }
@ -350,10 +350,10 @@ pre.item-decl {
contain: initial; contain: initial;
} }
.source .content pre { .src .content pre {
padding: 20px; padding: 20px;
} }
.rustdoc.source .example-wrap pre.src-line-numbers { .rustdoc.src .example-wrap pre.src-line-numbers {
padding: 20px 0 20px 4px; padding: 20px 0 20px 4px;
} }
@ -392,7 +392,7 @@ img {
left: 0; left: 0;
} }
.rustdoc.source .sidebar { .rustdoc.src .sidebar {
flex-basis: 50px; flex-basis: 50px;
border-right: 1px solid; border-right: 1px solid;
overflow-x: hidden; overflow-x: hidden;
@ -402,7 +402,7 @@ img {
} }
.sidebar, .mobile-topbar, .sidebar-menu-toggle, .sidebar, .mobile-topbar, .sidebar-menu-toggle,
#src-sidebar-toggle, #source-sidebar { #src-sidebar-toggle, #src-sidebar {
background-color: var(--sidebar-background-color); background-color: var(--sidebar-background-color);
} }
@ -410,16 +410,16 @@ img {
background-color: var(--sidebar-background-color-hover); background-color: var(--sidebar-background-color-hover);
} }
.source .sidebar > *:not(#src-sidebar-toggle) { .src .sidebar > *:not(#src-sidebar-toggle) {
visibility: hidden; visibility: hidden;
} }
.source-sidebar-expanded .source .sidebar { .src-sidebar-expanded .src .sidebar {
overflow-y: auto; overflow-y: auto;
flex-basis: 300px; flex-basis: 300px;
} }
.source-sidebar-expanded .source .sidebar > *:not(#src-sidebar-toggle) { .src-sidebar-expanded .src .sidebar > *:not(#src-sidebar-toggle) {
visibility: visible; visibility: visible;
} }
@ -544,7 +544,7 @@ ul.block, .block li {
flex-grow: 1; flex-grow: 1;
} }
.rustdoc:not(.source) .example-wrap pre { .rustdoc:not(.src) .example-wrap pre {
overflow: auto hidden; overflow: auto hidden;
} }
@ -619,7 +619,7 @@ ul.block, .block li {
} }
.docblock code, .docblock-short code, .docblock code, .docblock-short code,
pre, .rustdoc.source .example-wrap { pre, .rustdoc.src .example-wrap {
background-color: var(--code-block-background-color); background-color: var(--code-block-background-color);
} }
@ -676,7 +676,7 @@ nav.sub {
height: 34px; height: 34px;
flex-grow: 1; flex-grow: 1;
} }
.source nav.sub { .src nav.sub {
margin: 0 0 15px 0; margin: 0 0 15px 0;
} }
@ -1074,7 +1074,7 @@ pre.rust .doccomment {
color: var(--code-highlight-doc-comment-color); color: var(--code-highlight-doc-comment-color);
} }
.rustdoc.source .example-wrap pre.rust a { .rustdoc.src .example-wrap pre.rust a {
background: var(--codeblock-link-background); background: var(--codeblock-link-background);
} }
@ -1301,22 +1301,22 @@ a.tooltip:hover::after {
align-items: stretch; align-items: stretch;
z-index: 10; z-index: 10;
} }
#source-sidebar { #src-sidebar {
width: 100%; width: 100%;
overflow: auto; overflow: auto;
} }
#source-sidebar > .title { #src-sidebar > .title {
font-size: 1.5rem; font-size: 1.5rem;
text-align: center; text-align: center;
border-bottom: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color);
margin-bottom: 6px; margin-bottom: 6px;
} }
#source-sidebar div.files > a:hover, details.dir-entry summary:hover, #src-sidebar div.files > a:hover, details.dir-entry summary:hover,
#source-sidebar div.files > a:focus, details.dir-entry summary:focus { #src-sidebar div.files > a:focus, details.dir-entry summary:focus {
background-color: var(--source-sidebar-background-hover); background-color: var(--src-sidebar-background-hover);
} }
#source-sidebar div.files > a.selected { #src-sidebar div.files > a.selected {
background-color: var(--source-sidebar-background-selected); background-color: var(--src-sidebar-background-selected);
} }
#src-sidebar-toggle > button { #src-sidebar-toggle > button {
font-size: inherit; font-size: inherit;
@ -1562,7 +1562,7 @@ However, it's not needed with smaller screen width because the doc/code block is
/* /*
WARNING: RUSTDOC_MOBILE_BREAKPOINT MEDIA QUERY WARNING: RUSTDOC_MOBILE_BREAKPOINT MEDIA QUERY
If you update this line, then you also need to update the line with the same warning If you update this line, then you also need to update the line with the same warning
in source-script.js in src-script.js
*/ */
@media (max-width: 700px) { @media (max-width: 700px) {
/* When linking to an item with an `id` (for instance, by clicking a link in the sidebar, /* When linking to an item with an `id` (for instance, by clicking a link in the sidebar,
@ -1619,8 +1619,8 @@ in source-script.js
/* The source view uses a different design for the sidebar toggle, and doesn't have a topbar, /* The source view uses a different design for the sidebar toggle, and doesn't have a topbar,
so don't bump down the main content or the sidebar. */ so don't bump down the main content or the sidebar. */
.source main, .src main,
.rustdoc.source .sidebar { .rustdoc.src .sidebar {
top: 0; top: 0;
padding: 0; padding: 0;
height: 100vh; height: 100vh;
@ -1628,8 +1628,8 @@ in source-script.js
} }
.sidebar.shown, .sidebar.shown,
.source-sidebar-expanded .source .sidebar, .src-sidebar-expanded .src .sidebar,
.rustdoc:not(.source) .sidebar:focus-within { .rustdoc:not(.src) .sidebar:focus-within {
left: 0; left: 0;
} }
@ -1709,7 +1709,7 @@ in source-script.js
border-left: 0; border-left: 0;
} }
.source-sidebar-expanded #src-sidebar-toggle { .src-sidebar-expanded #src-sidebar-toggle {
left: unset; left: unset;
top: unset; top: unset;
width: unset; width: unset;
@ -1749,7 +1749,7 @@ in source-script.js
display: inline; display: inline;
} }
.source-sidebar-expanded .source .sidebar { .src-sidebar-expanded .src .sidebar {
max-width: 100vw; max-width: 100vw;
width: 100vw; width: 100vw;
} }
@ -1769,7 +1769,7 @@ in source-script.js
margin-left: 34px; margin-left: 34px;
} }
.source nav.sub { .src nav.sub {
margin: 0; margin: 0;
padding: var(--nav-sub-mobile-padding); padding: var(--nav-sub-mobile-padding);
} }
@ -1792,7 +1792,7 @@ in source-script.js
} }
@media print { @media print {
nav.sidebar, nav.sub, .out-of-band, a.srclink, #copy-path, nav.sidebar, nav.sub, .out-of-band, a.src, #copy-path,
details.toggle[open] > summary::before, details.toggle > summary::before, details.toggle[open] > summary::before, details.toggle > summary::before,
details.toggle.top-doc > summary { details.toggle.top-doc > summary {
display: none; display: none;

View file

@ -89,8 +89,8 @@ Original by Dempfi (https://github.com/dempfi/ayu)
--crate-search-div-hover-filter: invert(98%) sepia(12%) saturate(81%) hue-rotate(343deg) --crate-search-div-hover-filter: invert(98%) sepia(12%) saturate(81%) hue-rotate(343deg)
brightness(113%) contrast(76%); brightness(113%) contrast(76%);
--crate-search-hover-border: #e0e0e0; --crate-search-hover-border: #e0e0e0;
--source-sidebar-background-selected: #14191f; --src-sidebar-background-selected: #14191f;
--source-sidebar-background-hover: #14191f; --src-sidebar-background-hover: #14191f;
--table-alt-row-background-color: #191f26; --table-alt-row-background-color: #191f26;
--codeblock-link-background: #333; --codeblock-link-background: #333;
--scrape-example-toggle-line-background: #999; --scrape-example-toggle-line-background: #999;
@ -107,7 +107,7 @@ Original by Dempfi (https://github.com/dempfi/ayu)
h1, h2, h3, h4, h1, h2, h3, h4,
h1 a, .sidebar h2 a, .sidebar h3 a, h1 a, .sidebar h2 a, .sidebar h3 a,
#source-sidebar > .title { #src-sidebar > .title {
color: #fff; color: #fff;
} }
h4 { h4 {
@ -124,15 +124,15 @@ h4 {
.docblock pre > code, .docblock pre > code,
pre, pre > code, pre, pre > code,
.item-info code, .item-info code,
.rustdoc.source .example-wrap { .rustdoc.src .example-wrap {
color: #e6e1cf; color: #e6e1cf;
} }
.sidebar .current, .sidebar .current,
.sidebar a:hover, .sidebar a:hover,
#source-sidebar div.files > a:hover, details.dir-entry summary:hover, #src-sidebar div.files > a:hover, details.dir-entry summary:hover,
#source-sidebar div.files > a:focus, details.dir-entry summary:focus, #src-sidebar div.files > a:focus, details.dir-entry summary:focus,
#source-sidebar div.files > a.selected { #src-sidebar div.files > a.selected {
color: #ffb44c; color: #ffb44c;
} }

View file

@ -84,8 +84,8 @@
--crate-search-div-hover-filter: invert(69%) sepia(60%) saturate(6613%) hue-rotate(184deg) --crate-search-div-hover-filter: invert(69%) sepia(60%) saturate(6613%) hue-rotate(184deg)
brightness(100%) contrast(91%); brightness(100%) contrast(91%);
--crate-search-hover-border: #2196f3; --crate-search-hover-border: #2196f3;
--source-sidebar-background-selected: #333; --src-sidebar-background-selected: #333;
--source-sidebar-background-hover: #444; --src-sidebar-background-hover: #444;
--table-alt-row-background-color: #2A2A2A; --table-alt-row-background-color: #2A2A2A;
--codeblock-link-background: #333; --codeblock-link-background: #333;
--scrape-example-toggle-line-background: #999; --scrape-example-toggle-line-background: #999;

View file

@ -81,8 +81,8 @@
--crate-search-div-hover-filter: invert(44%) sepia(18%) saturate(23%) hue-rotate(317deg) --crate-search-div-hover-filter: invert(44%) sepia(18%) saturate(23%) hue-rotate(317deg)
brightness(96%) contrast(93%); brightness(96%) contrast(93%);
--crate-search-hover-border: #717171; --crate-search-hover-border: #717171;
--source-sidebar-background-selected: #fff; --src-sidebar-background-selected: #fff;
--source-sidebar-background-hover: #e0e0e0; --src-sidebar-background-hover: #e0e0e0;
--table-alt-row-background-color: #F5F5F5; --table-alt-row-background-color: #F5F5F5;
--codeblock-link-background: #eee; --codeblock-link-background: #eee;
--scrape-example-toggle-line-background: #ccc; --scrape-example-toggle-line-background: #ccc;

View file

@ -1,5 +1,5 @@
// From rust: // From rust:
/* global sourcesIndex */ /* global srcIndex */
// Local js definitions: // Local js definitions:
/* global addClass, getCurrentValue, onEachLazy, removeClass, browserSupportsHistoryApi */ /* global addClass, getCurrentValue, onEachLazy, removeClass, browserSupportsHistoryApi */
@ -74,11 +74,11 @@ function createDirEntry(elem, parent, fullPath, hasFoundFile) {
function toggleSidebar() { function toggleSidebar() {
const child = this.parentNode.children[0]; const child = this.parentNode.children[0];
if (child.innerText === ">") { if (child.innerText === ">") {
addClass(document.documentElement, "source-sidebar-expanded"); addClass(document.documentElement, "src-sidebar-expanded");
child.innerText = "<"; child.innerText = "<";
updateLocalStorage("source-sidebar-show", "true"); updateLocalStorage("source-sidebar-show", "true");
} else { } else {
removeClass(document.documentElement, "source-sidebar-expanded"); removeClass(document.documentElement, "src-sidebar-expanded");
child.innerText = ">"; child.innerText = ">";
updateLocalStorage("source-sidebar-show", "false"); updateLocalStorage("source-sidebar-show", "false");
} }
@ -101,16 +101,16 @@ function createSidebarToggle() {
return sidebarToggle; return sidebarToggle;
} }
// This function is called from "source-files.js", generated in `html/render/write_shared.rs`. // This function is called from "src-files.js", generated in `html/render/write_shared.rs`.
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
function createSourceSidebar() { function createSrcSidebar() {
const container = document.querySelector("nav.sidebar"); const container = document.querySelector("nav.sidebar");
const sidebarToggle = createSidebarToggle(); const sidebarToggle = createSidebarToggle();
container.insertBefore(sidebarToggle, container.firstChild); container.insertBefore(sidebarToggle, container.firstChild);
const sidebar = document.createElement("div"); const sidebar = document.createElement("div");
sidebar.id = "source-sidebar"; sidebar.id = "src-sidebar";
let hasFoundFile = false; let hasFoundFile = false;
@ -118,9 +118,9 @@ function createSourceSidebar() {
title.className = "title"; title.className = "title";
title.innerText = "Files"; title.innerText = "Files";
sidebar.appendChild(title); sidebar.appendChild(title);
Object.keys(sourcesIndex).forEach(key => { Object.keys(srcIndex).forEach(key => {
sourcesIndex[key][NAME_OFFSET] = key; srcIndex[key][NAME_OFFSET] = key;
hasFoundFile = createDirEntry(sourcesIndex[key], sidebar, "", hasFoundFile); hasFoundFile = createDirEntry(srcIndex[key], sidebar, "", hasFoundFile);
}); });
container.appendChild(sidebar); container.appendChild(sidebar);
@ -133,7 +133,7 @@ function createSourceSidebar() {
const lineNumbersRegex = /^#?(\d+)(?:-(\d+))?$/; const lineNumbersRegex = /^#?(\d+)(?:-(\d+))?$/;
function highlightSourceLines(match) { function highlightSrcLines(match) {
if (typeof match === "undefined") { if (typeof match === "undefined") {
match = window.location.hash.match(lineNumbersRegex); match = window.location.hash.match(lineNumbersRegex);
} }
@ -172,7 +172,7 @@ function highlightSourceLines(match) {
} }
} }
const handleSourceHighlight = (function() { const handleSrcHighlight = (function() {
let prev_line_id = 0; let prev_line_id = 0;
const set_fragment = name => { const set_fragment = name => {
@ -180,7 +180,7 @@ const handleSourceHighlight = (function() {
y = window.scrollY; y = window.scrollY;
if (browserSupportsHistoryApi()) { if (browserSupportsHistoryApi()) {
history.replaceState(null, null, "#" + name); history.replaceState(null, null, "#" + name);
highlightSourceLines(); highlightSrcLines();
} else { } else {
location.replace("#" + name); location.replace("#" + name);
} }
@ -221,15 +221,15 @@ const handleSourceHighlight = (function() {
window.addEventListener("hashchange", () => { window.addEventListener("hashchange", () => {
const match = window.location.hash.match(lineNumbersRegex); const match = window.location.hash.match(lineNumbersRegex);
if (match) { if (match) {
return highlightSourceLines(match); return highlightSrcLines(match);
} }
}); });
onEachLazy(document.getElementsByClassName("src-line-numbers"), el => { onEachLazy(document.getElementsByClassName("src-line-numbers"), el => {
el.addEventListener("click", handleSourceHighlight); el.addEventListener("click", handleSrcHighlight);
}); });
highlightSourceLines(); highlightSrcLines();
window.createSourceSidebar = createSourceSidebar; window.createSrcSidebar = createSrcSidebar;
})(); })();

View file

@ -185,7 +185,7 @@ updateTheme();
if (getSettingValue("source-sidebar-show") === "true") { if (getSettingValue("source-sidebar-show") === "true") {
// At this point in page load, `document.body` is not available yet. // At this point in page load, `document.body` is not available yet.
// Set a class on the `<html>` element instead. // Set a class on the `<html>` element instead.
addClass(document.documentElement, "source-sidebar-expanded"); addClass(document.documentElement, "src-sidebar-expanded");
} }
// If we navigate away (for example to a settings page), and then use the back or // If we navigate away (for example to a settings page), and then use the back or

View file

@ -97,7 +97,7 @@ static_files! {
main_js => "static/js/main.js", main_js => "static/js/main.js",
search_js => "static/js/search.js", search_js => "static/js/search.js",
settings_js => "static/js/settings.js", settings_js => "static/js/settings.js",
source_script_js => "static/js/source-script.js", src_script_js => "static/js/src-script.js",
storage_js => "static/js/storage.js", storage_js => "static/js/storage.js",
scrape_examples_js => "static/js/scrape-examples.js", scrape_examples_js => "static/js/scrape-examples.js",
wheel_svg => "static/images/wheel.svg", wheel_svg => "static/images/wheel.svg",

View file

@ -42,9 +42,9 @@
<script src="{{static_root_path|safe}}{{files.storage_js}}"></script> {# #} <script src="{{static_root_path|safe}}{{files.storage_js}}"></script> {# #}
{% if page.css_class.contains("crate") %} {% if page.css_class.contains("crate") %}
<script defer src="{{page.root_path|safe}}crates{{page.resource_suffix}}.js"></script> {# #} <script defer src="{{page.root_path|safe}}crates{{page.resource_suffix}}.js"></script> {# #}
{% else if page.css_class == "source" %} {% else if page.css_class == "src" %}
<script defer src="{{static_root_path|safe}}{{files.source_script_js}}"></script> {# #} <script defer src="{{static_root_path|safe}}{{files.src_script_js}}"></script> {# #}
<script defer src="{{page.root_path|safe}}source-files{{page.resource_suffix}}.js"></script> {# #} <script defer src="{{page.root_path|safe}}src-files{{page.resource_suffix}}.js"></script> {# #}
{% else if !page.css_class.contains("mod") %} {% else if !page.css_class.contains("mod") %}
<script defer src="sidebar-items{{page.resource_suffix}}.js"></script> {# #} <script defer src="sidebar-items{{page.resource_suffix}}.js"></script> {# #}
{% endif %} {% endif %}
@ -85,7 +85,7 @@
</div> {# #} </div> {# #}
<![endif]--> {# #} <![endif]--> {# #}
{{ layout.external_html.before_content|safe }} {{ layout.external_html.before_content|safe }}
{% if page.css_class != "source" %} {% if page.css_class != "src" %}
<nav class="mobile-topbar"> {# #} <nav class="mobile-topbar"> {# #}
<button class="sidebar-menu-toggle">&#9776;</button> {# #} <button class="sidebar-menu-toggle">&#9776;</button> {# #}
<a class="logo-container" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {# #} <a class="logo-container" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {# #}
@ -99,7 +99,7 @@
</nav> {# #} </nav> {# #}
{% endif %} {% endif %}
<nav class="sidebar"> {# #} <nav class="sidebar"> {# #}
{% if page.css_class != "source" %} {% if page.css_class != "src" %}
<a class="logo-container" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {# #} <a class="logo-container" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {# #}
{% if !layout.logo.is_empty() %} {% if !layout.logo.is_empty() %}
<img src="{{layout.logo}}" alt="logo"> {# #} <img src="{{layout.logo}}" alt="logo"> {# #}
@ -111,9 +111,9 @@
{{ sidebar|safe }} {{ sidebar|safe }}
</nav> {# #} </nav> {# #}
<main> {# #} <main> {# #}
{% if page.css_class != "source" %}<div class="width-limiter">{% endif %} {% if page.css_class != "src" %}<div class="width-limiter">{% endif %}
<nav class="sub"> {# #} <nav class="sub"> {# #}
{% if page.css_class == "source" %} {% if page.css_class == "src" %}
<a class="sub-logo-container" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {# #} <a class="sub-logo-container" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {# #}
{% if !layout.logo.is_empty() %} {% if !layout.logo.is_empty() %}
<img src="{{layout.logo}}" alt="logo"> {# #} <img src="{{layout.logo}}" alt="logo"> {# #}
@ -144,7 +144,7 @@
</form> {# #} </form> {# #}
</nav> {# #} </nav> {# #}
<section id="main-content" class="content">{{ content|safe }}</section> {# #} <section id="main-content" class="content">{{ content|safe }}</section> {# #}
{% if page.css_class != "source" %}</div>{% endif %} {% if page.css_class != "src" %}</div>{% endif %}
</main> {# #} </main> {# #}
{{ layout.external_html.after_content|safe }} {{ layout.external_html.after_content|safe }}
</body> {# #} </body> {# #}

View file

@ -18,7 +18,7 @@
{% endif %} {% endif %}
{% match src_href %} {% match src_href %}
{% when Some with (href) %} {% when Some with (href) %}
<a class="srclink" href="{{href|safe}}">source</a> · {#+ #} <a class="src" href="{{href|safe}}">source</a> · {#+ #}
{% else %} {% else %}
{% endmatch %} {% endmatch %}
<button id="toggle-all-docs" title="collapse all docs"> {# #} <button id="toggle-all-docs" title="collapse all docs"> {# #}

View file

@ -1,10 +1,12 @@
use std::process::Command; use std::process::Command;
/// Invokes `build_helper::util::detail_exit` with `cfg!(test)` /// Invokes `build_helper::util::detail_exit` with `cfg!(test)`
///
/// This is a macro instead of a function so that it uses `cfg(test)` in the *calling* crate, not in build helper.
#[macro_export] #[macro_export]
macro_rules! detail_exit_macro { macro_rules! exit {
($code:expr) => { ($code:expr) => {
build_helper::util::detail_exit($code, cfg!(test)); $crate::util::detail_exit($code, cfg!(test));
}; };
} }

View file

@ -17,34 +17,34 @@ define-function: (
assert-css: (".main-heading h1 a:nth-of-type(1)", {"color": |main_heading_color|}) assert-css: (".main-heading h1 a:nth-of-type(1)", {"color": |main_heading_color|})
assert-css: (".main-heading a:nth-of-type(2)", {"color": |main_heading_type_color|}) assert-css: (".main-heading a:nth-of-type(2)", {"color": |main_heading_type_color|})
assert-css: ( assert-css: (
".rightside .srclink", ".rightside a.src",
{"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|}, {"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|},
ALL, ALL,
) )
compare-elements-css: ( compare-elements-css: (
".rightside .srclink", ".rightside a.src",
".rightside.srclink", "a.rightside.src",
["color", "text-decoration"], ["color", "text-decoration"],
) )
compare-elements-css: ( compare-elements-css: (
".main-heading .srclink", ".main-heading a.src",
".rightside.srclink", "a.rightside.src",
["color", "text-decoration"], ["color", "text-decoration"],
) )
move-cursor-to: ".main-heading .srclink" move-cursor-to: ".main-heading a.src"
assert-css: ( assert-css: (
".main-heading .srclink", ".main-heading a.src",
{"color": |src_link_color|, "text-decoration": "underline solid " + |src_link_color|}, {"color": |src_link_color|, "text-decoration": "underline solid " + |src_link_color|},
) )
move-cursor-to: ".impl-items .rightside .srclink" move-cursor-to: ".impl-items .rightside a.src"
assert-css: ( assert-css: (
".impl-items .rightside .srclink", ".impl-items .rightside a.src",
{"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|}, {"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|},
) )
move-cursor-to: ".impl-items .rightside.srclink" move-cursor-to: ".impl-items a.rightside.src"
assert-css: ( assert-css: (
".impl-items .rightside.srclink", ".impl-items a.rightside.src",
{"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|}, {"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|},
) )

View file

@ -1,6 +1,6 @@
// Small test to ensure the "src-line-numbers" element is only present once on // Small test to ensure the "src-line-numbers" element is only present once on
// the page. // the page.
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
click: ".srclink" click: "a.src"
wait-for: ".src-line-numbers" wait-for: ".src-line-numbers"
assert-count: (".src-line-numbers", 1) assert-count: (".src-line-numbers", 1)

View file

@ -1,7 +1,7 @@
// This test checks that the source code pages sidebar toggle is working as expected. // This test checks that the source code pages sidebar toggle is working as expected.
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
click: ".srclink" click: "a.src"
wait-for: "#src-sidebar-toggle" wait-for: "#src-sidebar-toggle"
click: "#src-sidebar-toggle" click: "#src-sidebar-toggle"
expect-failure: true expect-failure: true
assert-css: ("#source-sidebar", { "left": "-300px" }) assert-css: ("#src-sidebar", { "left": "-300px" })

View file

@ -194,27 +194,27 @@ call-function: (
"check-colors", "check-colors",
{ {
"theme": "ayu", "theme": "ayu",
"heading_color": "rgb(255, 255, 255)", "heading_color": "#fff",
"small_heading_color": "rgb(197, 197, 197)", "small_heading_color": "#c5c5c5",
"heading_border_color": "rgb(92, 103, 115)", "heading_border_color": "#5c6773",
}, },
) )
call-function: ( call-function: (
"check-colors", "check-colors",
{ {
"theme": "dark", "theme": "dark",
"heading_color": "rgb(221, 221, 221)", "heading_color": "#ddd",
"small_heading_color": "rgb(221, 221, 221)", "small_heading_color": "#ddd",
"heading_border_color": "rgb(210, 210, 210)", "heading_border_color": "#d2d2d2",
}, },
) )
call-function: ( call-function: (
"check-colors", "check-colors",
{ {
"theme": "light", "theme": "light",
"heading_color": "rgb(0, 0, 0)", "heading_color": "black",
"small_heading_color": "rgb(0, 0, 0)", "small_heading_color": "black",
"heading_border_color": "rgb(221, 221, 221)", "heading_border_color": "#ddd",
}, },
) )
@ -224,7 +224,7 @@ define-function: (
block { block {
set-local-storage: {"rustdoc-theme": |theme|} set-local-storage: {"rustdoc-theme": |theme|}
reload: reload:
assert-css: (".since", {"color": "rgb(128, 128, 128)"}, ALL) assert-css: (".since", {"color": "#808080"}, ALL)
}, },
) )

View file

@ -1,4 +1,4 @@
// We check the background color on the jump to definition links in the source code page. // We check the background color on the jump to definition links in the src code page.
go-to: "file://" + |DOC_PATH| + "/src/link_to_definition/lib.rs.html" go-to: "file://" + |DOC_PATH| + "/src/link_to_definition/lib.rs.html"
define-function: ( define-function: (
@ -10,7 +10,7 @@ define-function: (
// We reload the page so the local storage settings are being used. // We reload the page so the local storage settings are being used.
reload: reload:
assert-css: ( assert-css: (
"body.source .example-wrap pre.rust a", "body.src .example-wrap pre.rust a",
{"background-color": |background_color|}, {"background-color": |background_color|},
ALL, ALL,
) )

View file

@ -40,7 +40,7 @@ define-function: (
reload: reload:
wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"}) wait-for-css: ("#src-sidebar-toggle", {"visibility": "visible"})
assert-css: ( assert-css: (
"#source-sidebar details[open] > .files a.selected", "#src-sidebar details[open] > .files a.selected",
{"color": |color_hover|, "background-color": |background|}, {"color": |color_hover|, "background-color": |background|},
) )
@ -62,58 +62,58 @@ define-function: (
// Without hover or focus. // Without hover or focus.
assert-css: ( assert-css: (
"#source-sidebar details[open] > .files a:not(.selected)", "#src-sidebar details[open] > .files a:not(.selected)",
{"color": |color|, "background-color": |background_toggle|}, {"color": |color|, "background-color": |background_toggle|},
) )
// With focus. // With focus.
focus: "#source-sidebar details[open] > .files a:not(.selected)" focus: "#src-sidebar details[open] > .files a:not(.selected)"
wait-for-css: ( wait-for-css: (
"#source-sidebar details[open] > .files a:not(.selected):focus", "#src-sidebar details[open] > .files a:not(.selected):focus",
{"color": |color_hover|, "background-color": |background_hover|}, {"color": |color_hover|, "background-color": |background_hover|},
) )
focus: ".search-input" focus: ".search-input"
// With hover. // With hover.
move-cursor-to: "#source-sidebar details[open] > .files a:not(.selected)" move-cursor-to: "#src-sidebar details[open] > .files a:not(.selected)"
assert-css: ( assert-css: (
"#source-sidebar details[open] > .files a:not(.selected):hover", "#src-sidebar details[open] > .files a:not(.selected):hover",
{"color": |color_hover|, "background-color": |background_hover|}, {"color": |color_hover|, "background-color": |background_hover|},
) )
// Without hover or focus. // Without hover or focus.
assert-css: ( assert-css: (
"#source-sidebar .dir-entry summary", "#src-sidebar .dir-entry summary",
{"color": |color|, "background-color": |background_toggle|}, {"color": |color|, "background-color": |background_toggle|},
) )
// With focus. // With focus.
focus: "#source-sidebar .dir-entry summary" focus: "#src-sidebar .dir-entry summary"
wait-for-css: ( wait-for-css: (
"#source-sidebar .dir-entry summary:focus", "#src-sidebar .dir-entry summary:focus",
{"color": |color_hover|, "background-color": |background_hover|}, {"color": |color_hover|, "background-color": |background_hover|},
) )
focus: ".search-input" focus: ".search-input"
// With hover. // With hover.
move-cursor-to: "#source-sidebar .dir-entry summary" move-cursor-to: "#src-sidebar .dir-entry summary"
assert-css: ( assert-css: (
"#source-sidebar .dir-entry summary:hover", "#src-sidebar .dir-entry summary:hover",
{"color": |color_hover|, "background-color": |background_hover|}, {"color": |color_hover|, "background-color": |background_hover|},
) )
// Without hover or focus. // Without hover or focus.
assert-css: ( assert-css: (
"#source-sidebar details[open] > .folders > details > summary", "#src-sidebar details[open] > .folders > details > summary",
{"color": |color|, "background-color": |background_toggle|}, {"color": |color|, "background-color": |background_toggle|},
) )
// With focus. // With focus.
focus: "#source-sidebar details[open] > .folders > details > summary" focus: "#src-sidebar details[open] > .folders > details > summary"
wait-for-css: ( wait-for-css: (
"#source-sidebar details[open] > .folders > details > summary:focus", "#src-sidebar details[open] > .folders > details > summary:focus",
{"color": |color_hover|, "background-color": |background_hover|}, {"color": |color_hover|, "background-color": |background_hover|},
) )
focus: ".search-input" focus: ".search-input"
// With hover. // With hover.
move-cursor-to: "#source-sidebar details[open] > .folders > details > summary" move-cursor-to: "#src-sidebar details[open] > .folders > details > summary"
assert-css: ( assert-css: (
"#source-sidebar details[open] > .folders > details > summary:hover", "#src-sidebar details[open] > .folders > details > summary:hover",
{"color": |color_hover|, "background-color": |background_hover|}, {"color": |color_hover|, "background-color": |background_hover|},
) )
}, },
@ -190,16 +190,16 @@ assert-window-property: {"pageYOffset": "2542"}
// make it the current selection. // make it the current selection.
set-window-size: (500, 700) set-window-size: (500, 700)
click: "#src-sidebar-toggle" click: "#src-sidebar-toggle"
wait-for-css: ("#source-sidebar", {"visibility": "visible"}) wait-for-css: ("#src-sidebar", {"visibility": "visible"})
assert-local-storage: {"rustdoc-source-sidebar-show": "true"} assert-local-storage: {"rustdoc-source-sidebar-show": "true"}
click: ".sidebar a.selected" click: ".sidebar a.selected"
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
wait-for-css: ("#source-sidebar", {"visibility": "hidden"}) wait-for-css: ("#src-sidebar", {"visibility": "hidden"})
assert-local-storage: {"rustdoc-source-sidebar-show": "false"} assert-local-storage: {"rustdoc-source-sidebar-show": "false"}
// Resize back to desktop size, to check that the sidebar doesn't spontaneously open. // Resize back to desktop size, to check that the sidebar doesn't spontaneously open.
set-window-size: (1000, 1000) set-window-size: (1000, 1000)
wait-for-css: ("#source-sidebar", {"visibility": "hidden"}) wait-for-css: ("#src-sidebar", {"visibility": "hidden"})
assert-local-storage: {"rustdoc-source-sidebar-show": "false"} assert-local-storage: {"rustdoc-source-sidebar-show": "false"}
click: "#src-sidebar-toggle" click: "#src-sidebar-toggle"
wait-for-css: ("#source-sidebar", {"visibility": "visible"}) wait-for-css: ("#src-sidebar", {"visibility": "visible"})
assert-local-storage: {"rustdoc-source-sidebar-show": "true"} assert-local-storage: {"rustdoc-source-sidebar-show": "true"}

View file

@ -14,7 +14,7 @@ define-function: (
} }
reload: reload:
// Checking results colors. // Checking results colors.
assert-css: (".source .sidebar", { assert-css: (".src .sidebar", {
"color": |color|, "color": |color|,
"background-color": |background_color| "background-color": |background_color|
}, ALL) }, ALL)
@ -53,8 +53,8 @@ assert-css: ("nav.sidebar", {"width": "50px"})
// We now click on the button to expand the sidebar. // We now click on the button to expand the sidebar.
click: (10, 10) click: (10, 10)
// We wait for the sidebar to be expanded. // We wait for the sidebar to be expanded.
wait-for-css: (".source-sidebar-expanded nav.sidebar", {"width": "300px"}) wait-for-css: (".src-sidebar-expanded nav.sidebar", {"width": "300px"})
assert-css: (".source-sidebar-expanded nav.sidebar a", {"font-size": "14px"}) assert-css: (".src-sidebar-expanded nav.sidebar a", {"font-size": "14px"})
// We collapse the sidebar. // We collapse the sidebar.
click: (10, 10) click: (10, 10)
// We ensure that the class has been removed. // We ensure that the class has been removed.
@ -66,24 +66,24 @@ go-to: "file://" + |DOC_PATH| + "/src/lib2/another_folder/sub_mod/mod.rs.html"
// First we expand the sidebar again. // First we expand the sidebar again.
click: (10, 10) click: (10, 10)
// We wait for the sidebar to be expanded. // We wait for the sidebar to be expanded.
wait-for-css: (".source-sidebar-expanded nav.sidebar", {"width": "300px"}) wait-for-css: (".src-sidebar-expanded nav.sidebar", {"width": "300px"})
assert: "//*[@class='dir-entry' and @open]/*[text()='lib2']" assert: "//*[@class='dir-entry' and @open]/*[text()='lib2']"
assert: "//*[@class='dir-entry' and @open]/*[text()='another_folder']" assert: "//*[@class='dir-entry' and @open]/*[text()='another_folder']"
assert: "//*[@class='dir-entry' and @open]/*[text()='sub_mod']" assert: "//*[@class='dir-entry' and @open]/*[text()='sub_mod']"
// Only "another_folder" should be "open" in "lib2". // Only "another_folder" should be "open" in "lib2".
assert: "//*[@class='dir-entry' and not(@open)]/*[text()='another_mod']" assert: "//*[@class='dir-entry' and not(@open)]/*[text()='another_mod']"
// All other trees should be collapsed. // All other trees should be collapsed.
assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 9) assert-count: ("//*[@id='src-sidebar']/details[not(text()='lib2') and not(@open)]", 9)
// We now switch to mobile mode. // We now switch to mobile mode.
set-window-size: (600, 600) set-window-size: (600, 600)
wait-for-css: (".source-sidebar-expanded nav.sidebar", {"left": "0px"}) wait-for-css: (".src-sidebar-expanded nav.sidebar", {"left": "0px"})
// We collapse the sidebar. // We collapse the sidebar.
click: (10, 10) click: (10, 10)
// We check that the sidebar has been moved off-screen. // We check that the sidebar has been moved off-screen.
assert-css: ("nav.sidebar", {"left": "-1000px"}) assert-css: ("nav.sidebar", {"left": "-1000px"})
// We ensure that the class has been removed. // We ensure that the class has been removed.
assert-false: ".source-sidebar-expanded" assert-false: ".src-sidebar-expanded"
assert: "nav.sidebar" assert: "nav.sidebar"
// Check that the topbar is not visible // Check that the topbar is not visible

View file

@ -98,26 +98,26 @@ assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH)
// First we "open" it. // First we "open" it.
click: "#src-sidebar-toggle" click: "#src-sidebar-toggle"
assert: ".source-sidebar-expanded" assert: ".src-sidebar-expanded"
// We check that the first entry of the sidebar is collapsed // We check that the first entry of the sidebar is collapsed
assert-property: ("#source-sidebar details:first-of-type", {"open": "false"}) assert-property: ("#src-sidebar details:first-of-type", {"open": "false"})
assert-text: ("#source-sidebar details:first-of-type > summary", "extend_css") assert-text: ("#src-sidebar details:first-of-type > summary", "extend_css")
// We now click on it. // We now click on it.
click: "#source-sidebar details:first-of-type > summary" click: "#src-sidebar details:first-of-type > summary"
assert-property: ("#source-sidebar details:first-of-type", {"open": "true"}) assert-property: ("#src-sidebar details:first-of-type", {"open": "true"})
// And now we collapse it again. // And now we collapse it again.
click: "#source-sidebar details:first-of-type > summary" click: "#src-sidebar details:first-of-type > summary"
assert-property: ("#source-sidebar details:first-of-type", {"open": "false"}) assert-property: ("#src-sidebar details:first-of-type", {"open": "false"})
// And open it again, since it'll be the reference we use to check positions. // And open it again, since it'll be the reference we use to check positions.
click: "#source-sidebar details:first-of-type > summary" click: "#src-sidebar details:first-of-type > summary"
assert-property: ("#source-sidebar details:first-of-type", {"open": "true"}) assert-property: ("#src-sidebar details:first-of-type", {"open": "true"})
// Check the sidebar directory entries have a marker and spacing (desktop). // Check the sidebar directory entries have a marker and spacing (desktop).
store-property: ( store-property: (
"#source-sidebar > details:first-of-type.dir-entry[open] > .files > a", "#src-sidebar > details:first-of-type.dir-entry[open] > .files > a",
{"offsetHeight": link_height}, {"offsetHeight": link_height},
) )
define-function: ( define-function: (
@ -125,28 +125,28 @@ define-function: (
(x, y), (x, y),
block { block {
assert: "details:first-of-type.dir-entry[open] > summary::marker" assert: "details:first-of-type.dir-entry[open] > summary::marker"
assert-css: ("#source-sidebar > details:first-of-type.dir-entry", {"padding-left": "4px"}) assert-css: ("#src-sidebar > details:first-of-type.dir-entry", {"padding-left": "4px"})
// This check ensures that the summary is only one line. // This check ensures that the summary is only one line.
assert-property: ( assert-property: (
"#source-sidebar > details:first-of-type.dir-entry[open] > summary", "#src-sidebar > details:first-of-type.dir-entry[open] > summary",
{"offsetHeight": |link_height|} {"offsetHeight": |link_height|}
) )
assert-position: ( assert-position: (
"#source-sidebar > details:first-of-type.dir-entry[open] > summary", "#src-sidebar > details:first-of-type.dir-entry[open] > summary",
{"x": |x|, "y": |y|} {"x": |x|, "y": |y|}
) )
assert-property: ( assert-property: (
"#source-sidebar > details:first-of-type.dir-entry[open] > .files > a", "#src-sidebar > details:first-of-type.dir-entry[open] > .files > a",
{"offsetHeight": |link_height|} {"offsetHeight": |link_height|}
) )
assert-position: ( assert-position: (
"#source-sidebar > details:first-of-type.dir-entry[open] > .files > a", "#src-sidebar > details:first-of-type.dir-entry[open] > .files > a",
// left margin // left margin
{"x": |x| + 27, "y": |y| + |link_height|} {"x": |x| + 27, "y": |y| + |link_height|}
) )
} }
) )
store-property: ("#source-sidebar > .title", { store-property: ("#src-sidebar > .title", {
"offsetHeight": source_sidebar_title_height, "offsetHeight": source_sidebar_title_height,
"offsetTop": source_sidebar_title_y, "offsetTop": source_sidebar_title_y,
}) })
@ -175,7 +175,7 @@ assert-property: ("#main-content", {"offsetTop": 76})
// 21 = 76 - 34 - 21 // 21 = 76 - 34 - 21
// Check the sidebar directory entries have a marker and spacing (tablet). // Check the sidebar directory entries have a marker and spacing (tablet).
store-property: ("#source-sidebar > .title", { store-property: ("#src-sidebar > .title", {
"offsetHeight": source_sidebar_title_height, "offsetHeight": source_sidebar_title_height,
"offsetTop": source_sidebar_title_y, "offsetTop": source_sidebar_title_y,
}) })
@ -189,7 +189,7 @@ set-window-size: (450, 700)
assert-css: ("nav.sub", {"flex-direction": "column"}) assert-css: ("nav.sub", {"flex-direction": "column"})
// Check the sidebar directory entries have a marker and spacing (phone). // Check the sidebar directory entries have a marker and spacing (phone).
store-property: ("#source-sidebar > .title", { store-property: ("#src-sidebar > .title", {
"offsetHeight": source_sidebar_title_height, "offsetHeight": source_sidebar_title_height,
"offsetTop": source_sidebar_title_y, "offsetTop": source_sidebar_title_y,
}) })

View file

@ -4,13 +4,13 @@
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
show-text: true show-text: true
// Check the impl headers. // Check the impl headers.
assert-css: (".impl .srclink", {"font-size": "16px", "font-weight": 400}, ALL) assert-css: (".impl a.src", {"font-size": "16px", "font-weight": 400}, ALL)
assert-css: (".impl .code-header", {"font-size": "18px", "font-weight": 600}, ALL) assert-css: (".impl .code-header", {"font-size": "18px", "font-weight": 600}, ALL)
// Check the impl items. // Check the impl items.
assert-css: (".impl-items .srclink", {"font-size": "16px", "font-weight": 400}, ALL) assert-css: (".impl-items a.src", {"font-size": "16px", "font-weight": 400}, ALL)
assert-css: (".impl-items .code-header", {"font-size": "16px", "font-weight": 600}, ALL) assert-css: (".impl-items .code-header", {"font-size": "16px", "font-weight": 600}, ALL)
// Check that we can click on source link // Check that we can click on source link
store-document-property: {"URL": url} store-document-property: {"URL": url}
click: ".impl-items .srclink" click: ".impl-items a.src"
assert-document-property-false: {"URL": |url|} assert-document-property-false: {"URL": |url|}

View file

@ -1 +1 @@
<section id="associatedconstant.YOLO" class="method"><a class="srclink rightside" href="../src/foo/anchors.rs.html#16">source</a><h4 class="code-header">const <a href="#associatedconstant.YOLO" class="constant">YOLO</a>: <a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a></h4></section> <section id="associatedconstant.YOLO" class="method"><a class="src rightside" href="../src/foo/anchors.rs.html#16">source</a><h4 class="code-header">const <a href="#associatedconstant.YOLO" class="constant">YOLO</a>: <a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a></h4></section>

View file

@ -1 +1 @@
<section id="associatedconstant.X" class="associatedconstant"><a class="srclink rightside" href="../src/foo/anchors.rs.html#42">source</a><h4 class="code-header">pub const <a href="#associatedconstant.X" class="constant">X</a>: <a class="primitive" href="{{channel}}/std/primitive.i32.html">i32</a> = 0i32</h4></section> <section id="associatedconstant.X" class="associatedconstant"><a class="src rightside" href="../src/foo/anchors.rs.html#42">source</a><h4 class="code-header">pub const <a href="#associatedconstant.X" class="constant">X</a>: <a class="primitive" href="{{channel}}/std/primitive.i32.html">i32</a> = 0i32</h4></section>

View file

@ -1 +1 @@
<section id="method.new" class="method"><a class="srclink rightside" href="../src/foo/anchors.rs.html#48">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fn">new</a>() -&gt; Self</h4></section> <section id="method.new" class="method"><a class="src rightside" href="../src/foo/anchors.rs.html#48">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fn">new</a>() -&gt; Self</h4></section>

View file

@ -1 +1 @@
<section id="method.bar" class="method"><a class="srclink rightside" href="../src/foo/anchors.rs.html#23">source</a><h4 class="code-header">fn <a href="#method.bar" class="fn">bar</a>()</h4></section> <section id="method.bar" class="method"><a class="src rightside" href="../src/foo/anchors.rs.html#23">source</a><h4 class="code-header">fn <a href="#method.bar" class="fn">bar</a>()</h4></section>

View file

@ -1 +1 @@
<section id="tymethod.foo" class="method"><a class="srclink rightside" href="../src/foo/anchors.rs.html#20">source</a><h4 class="code-header">fn <a href="#tymethod.foo" class="fn">foo</a>()</h4></section> <section id="tymethod.foo" class="method"><a class="src rightside" href="../src/foo/anchors.rs.html#20">source</a><h4 class="code-header">fn <a href="#tymethod.foo" class="fn">foo</a>()</h4></section>

View file

@ -1 +1 @@
<section id="associatedtype.T" class="method"><a class="srclink rightside" href="../src/foo/anchors.rs.html#13">source</a><h4 class="code-header">type <a href="#associatedtype.T" class="associatedtype">T</a></h4></section> <section id="associatedtype.T" class="method"><a class="src rightside" href="../src/foo/anchors.rs.html#13">source</a><h4 class="code-header">type <a href="#associatedtype.T" class="associatedtype">T</a></h4></section>

View file

@ -2,5 +2,5 @@
// This test ensures that the [src] link is present on traits items. // This test ensures that the [src] link is present on traits items.
// @has foo/trait.Iterator.html '//*[@id="method.zip"]//a[@class="srclink rightside"]' "source" // @has foo/trait.Iterator.html '//*[@id="method.zip"]//a[@class="src rightside"]' "source"
pub use std::iter::Iterator; pub use std::iter::Iterator;

View file

@ -1,5 +1,5 @@
#![crate_name = "foo"] #![crate_name = "foo"]
// @hasraw source-files.js source-file.rs // @hasraw src-files.js source-file.rs
pub struct Foo; pub struct Foo;

View file

@ -2,11 +2,11 @@
// @has foo/struct.Unsized.html // @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"]/h3[@class="code-header"]' 'impl !Sized for Unsized'
// @!has - '//*[@id="impl-Sized-for-Unsized"]//a[@class="srclink"]' 'source' // @!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"]/h3[@class="code-header"]' 'impl Sync for Unsized'
// @!has - '//*[@id="impl-Sync-for-Unsized"]//a[@class="srclink"]' 'source' // @!has - '//*[@id="impl-Sync-for-Unsized"]//a[@class="src"]' 'source'
// @has - '//*[@id="impl-Any-for-Unsized"]/h3[@class="code-header"]' 'impl<T> Any for T' // @has - '//*[@id="impl-Any-for-Unsized"]/h3[@class="code-header"]' 'impl<T> Any for T'
// @has - '//*[@id="impl-Any-for-Unsized"]//a[@class="srclink rightside"]' 'source' // @has - '//*[@id="impl-Any-for-Unsized"]//a[@class="src rightside"]' 'source'
pub struct Unsized { pub struct Unsized {
data: [u8], data: [u8],
} }

View file

@ -8,10 +8,10 @@
pub struct SomeStruct; pub struct SomeStruct;
// @has src/static_root_path/static-root-path.rs.html // @has src/static_root_path/static-root-path.rs.html
// @matchesraw - '"/cache/source-script-' // @matchesraw - '"/cache/src-script-'
// @!matchesraw - '"\.\./\.\./source-script' // @!matchesraw - '"\.\./\.\./src-script'
// @matchesraw - '"\.\./\.\./source-files.js"' // @matchesraw - '"\.\./\.\./src-files.js"'
// @!matchesraw - '"/cache/source-files\.js"' // @!matchesraw - '"/cache/src-files\.js"'
// @has settings.html // @has settings.html
// @matchesraw - '/cache/settings-' // @matchesraw - '/cache/settings-'

View file

@ -0,0 +1,18 @@
// check-pass
// compile-flags: -Ztrait-solver=next
pub trait A {}
pub trait B: A {}
pub trait Mirror {
type Assoc: ?Sized;
}
impl<T: ?Sized> Mirror for T {
type Assoc = T;
}
pub fn foo<'a>(x: &'a <dyn B + 'static as Mirror>::Assoc) -> &'a (dyn A + 'static) {
x
}
fn main() {}

View file

@ -1,5 +1,5 @@
error[E0133]: use of mutable static is unsafe and requires unsafe function or block error[E0133]: use of mutable static is unsafe and requires unsafe function or block
--> $DIR/unsafe-not-inherited.rs:6:31 --> $DIR/unsafe-not-inherited.rs:8:31
| |
LL | unsafe {static BAR: u64 = FOO;} LL | unsafe {static BAR: u64 = FOO;}
| ------ ^^^ use of mutable static | ------ ^^^ use of mutable static
@ -9,7 +9,7 @@ LL | unsafe {static BAR: u64 = FOO;}
= note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
--> $DIR/unsafe-not-inherited.rs:18:13 --> $DIR/unsafe-not-inherited.rs:20:13
| |
LL | unsafe { LL | unsafe {
| ------ items do not inherit unsafety from separate enclosing items | ------ items do not inherit unsafety from separate enclosing items

View file

@ -1,3 +1,5 @@
// revisions: mirunsafeck thirunsafeck
// [thirunsafeck]compile-flags: -Z thir-unsafeck
#![allow(unused, dead_code)] #![allow(unused, dead_code)]
static mut FOO: u64 = 0; static mut FOO: u64 = 0;

View file

@ -0,0 +1,24 @@
error[E0133]: use of mutable static is unsafe and requires unsafe function or block
--> $DIR/unsafe-not-inherited.rs:8:31
|
LL | unsafe {static BAR: u64 = FOO;}
| ------ ^^^ use of mutable static
| |
| items do not inherit unsafety from separate enclosing items
|
= note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
error[E0133]: call to unsafe function `unsafe_call` is unsafe and requires unsafe function or block
--> $DIR/unsafe-not-inherited.rs:20:13
|
LL | unsafe {
| ------ items do not inherit unsafety from separate enclosing items
...
LL | unsafe_call();
| ^^^^^^^^^^^^^ call to unsafe function
|
= note: consult the function's documentation for information on how to avoid undefined behavior
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0133`.