From bc7ea6f52eff4cac0f646f08b576edbf51319ec1 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Mon, 24 Aug 2020 20:02:02 +0800 Subject: [PATCH 01/29] Shorten liballoc doc intra link while readable --- library/alloc/src/vec.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/library/alloc/src/vec.rs b/library/alloc/src/vec.rs index 058a06e1326f8..3adeaf4103415 100644 --- a/library/alloc/src/vec.rs +++ b/library/alloc/src/vec.rs @@ -9,7 +9,7 @@ //! //! # Examples //! -//! You can explicitly create a [`Vec`] with [`new`]: +//! You can explicitly create a [`Vec`] with [`Vec::new`]: //! //! ``` //! let v: Vec = Vec::new(); @@ -50,8 +50,6 @@ //! v[1] = v[1] + 5; //! ``` //! -//! [`Vec`]: Vec -//! [`new`]: Vec::new //! [`push`]: Vec::push #![stable(feature = "rust1", since = "1.0.0")] From 8e0e179776bca98cb2f6910abf1dfb411ff13296 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Mon, 24 Aug 2020 22:32:59 +0800 Subject: [PATCH 02/29] Expand rustdoc theme chooser x padding --- src/librustdoc/html/static/rustdoc.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 346ceacc928c4..55dcaec8ae1e1 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -1290,7 +1290,7 @@ h4 > .notable-traits { #theme-choices > button { border: none; width: 100%; - padding: 4px; + padding: 4px 8px; text-align: center; background: rgba(0,0,0,0); } From f38eb93634b844ee8351501502f5331b04f063a5 Mon Sep 17 00:00:00 2001 From: jumbatm <30644300+jumbatm@users.noreply.github.com> Date: Tue, 25 Aug 2020 02:24:05 +1000 Subject: [PATCH 03/29] Fix clashing_extern_declarations false positive. Fixes a false positive for transparent newtype with a non-zero member. --- src/librustc_lint/builtin.rs | 32 +++++++++++++ src/librustc_lint/types.rs | 18 ++++--- src/test/ui/lint/clashing-extern-fn.rs | 56 ++++++++++++++++++++++ src/test/ui/lint/clashing-extern-fn.stderr | 4 +- 4 files changed, 101 insertions(+), 9 deletions(-) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index b337bf0a3f922..bfdf3e3b3956a 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -2162,6 +2162,38 @@ impl ClashingExternDeclarations { ckind: CItemKind, ) -> bool { debug!("structurally_same_type_impl(cx, a = {:?}, b = {:?})", a, b); + let tcx = cx.tcx; + + // Given a transparent newtype, reach through and grab the inner + // type unless the newtype makes the type non-null. + let non_transparent_ty = |ty: Ty<'tcx>| -> Ty<'tcx> { + let mut ty = ty; + loop { + if let ty::Adt(def, substs) = ty.kind { + let is_transparent = def.subst(tcx, substs).repr.transparent(); + let is_enum = def.is_enum(); + let is_non_null = crate::types::guaranteed_nonnull_optimization(tcx, &def); + debug!( + "non_transparent_ty({:?}) -- type is transparent? {}, type is enum? {}, type is non-null? {}", + ty, is_transparent, is_enum, is_non_null + ); + if is_transparent && !is_enum && !is_non_null { + ty = def + .non_enum_variant() + .transparent_newtype_field(tcx) + .unwrap() + .ty(tcx, substs); + continue; + } + } + debug!("non_transparent_ty -> {:?}", ty); + return ty; + } + }; + + let a = non_transparent_ty(a); + let b = non_transparent_ty(b); + if !seen_types.insert((a, b)) { // We've encountered a cycle. There's no point going any further -- the types are // structurally the same. diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 4ca5f23ebfe6c..849e8df1e5fdb 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -11,7 +11,7 @@ use rustc_index::vec::Idx; use rustc_middle::mir::interpret::{sign_extend, truncate}; use rustc_middle::ty::layout::{IntegerExt, SizeSkeleton}; use rustc_middle::ty::subst::SubstsRef; -use rustc_middle::ty::{self, AdtKind, Ty, TypeFoldable}; +use rustc_middle::ty::{self, AdtKind, Ty, TyCtxt, TypeFoldable}; use rustc_span::source_map; use rustc_span::symbol::sym; use rustc_span::{Span, DUMMY_SP}; @@ -527,22 +527,26 @@ enum FfiResult<'tcx> { FfiUnsafe { ty: Ty<'tcx>, reason: String, help: Option }, } +crate fn guaranteed_nonnull_optimization<'tcx>(tcx: TyCtxt<'tcx>, def: &ty::AdtDef) -> bool { + tcx.get_attrs(def.did) + .iter() + .any(|a| tcx.sess.check_name(a, sym::rustc_nonnull_optimization_guaranteed)) +} + /// Is type known to be non-null? -fn ty_is_known_nonnull<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, mode: CItemKind) -> bool { +crate fn ty_is_known_nonnull<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, mode: CItemKind) -> bool { let tcx = cx.tcx; match ty.kind { ty::FnPtr(_) => true, ty::Ref(..) => true, ty::Adt(def, _) if def.is_box() && matches!(mode, CItemKind::Definition) => true, ty::Adt(def, substs) if def.repr.transparent() && !def.is_union() => { - let guaranteed_nonnull_optimization = tcx - .get_attrs(def.did) - .iter() - .any(|a| tcx.sess.check_name(a, sym::rustc_nonnull_optimization_guaranteed)); + let marked_non_null = guaranteed_nonnull_optimization(tcx, &def); - if guaranteed_nonnull_optimization { + if marked_non_null { return true; } + for variant in &def.variants { if let Some(field) = variant.transparent_newtype_field(tcx) { if ty_is_known_nonnull(cx, field.ty(tcx, substs), mode) { diff --git a/src/test/ui/lint/clashing-extern-fn.rs b/src/test/ui/lint/clashing-extern-fn.rs index d6ac7ccccc77b..a2de01254477d 100644 --- a/src/test/ui/lint/clashing-extern-fn.rs +++ b/src/test/ui/lint/clashing-extern-fn.rs @@ -258,6 +258,62 @@ mod non_zero_and_non_null { } } +// See #75739 +mod non_zero_transparent { + mod a1 { + use std::num::NonZeroUsize; + extern "C" { + fn f1() -> NonZeroUsize; + } + } + + mod b1 { + #[repr(transparent)] + struct X(NonZeroUsize); + use std::num::NonZeroUsize; + extern "C" { + fn f1() -> X; + } + } + + mod a2 { + use std::num::NonZeroUsize; + extern "C" { + fn f2() -> NonZeroUsize; + } + } + + mod b2 { + #[repr(transparent)] + struct X1(NonZeroUsize); + + #[repr(transparent)] + struct X(X1); + + use std::num::NonZeroUsize; + extern "C" { + // Same case as above, but with two layers of newtyping. + fn f2() -> X; + } + } + + mod a3 { + #[repr(transparent)] + struct X(core::ptr::NonNull); + + use std::num::NonZeroUsize; + extern "C" { + fn f3() -> X; + } + } + + mod b3 { + extern "C" { + fn f3() -> core::ptr::NonNull; + } + } +} + mod null_optimised_enums { mod a { extern "C" { diff --git a/src/test/ui/lint/clashing-extern-fn.stderr b/src/test/ui/lint/clashing-extern-fn.stderr index cca0c4c59eb19..f2e53e4a3cc0e 100644 --- a/src/test/ui/lint/clashing-extern-fn.stderr +++ b/src/test/ui/lint/clashing-extern-fn.stderr @@ -166,7 +166,7 @@ LL | fn non_null_ptr() -> *const usize; found `unsafe extern "C" fn() -> *const usize` warning: `option_non_zero_usize_incorrect` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:281:13 + --> $DIR/clashing-extern-fn.rs:337:13 | LL | fn option_non_zero_usize_incorrect() -> usize; | ---------------------------------------------- `option_non_zero_usize_incorrect` previously declared here @@ -178,7 +178,7 @@ LL | fn option_non_zero_usize_incorrect() -> isize; found `unsafe extern "C" fn() -> isize` warning: `option_non_null_ptr_incorrect` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:283:13 + --> $DIR/clashing-extern-fn.rs:339:13 | LL | fn option_non_null_ptr_incorrect() -> *const usize; | --------------------------------------------------- `option_non_null_ptr_incorrect` previously declared here From 1831f652889eff1928c9f68dc6a1df8befefda88 Mon Sep 17 00:00:00 2001 From: Arkadiusz Piekarz Date: Mon, 24 Aug 2020 23:02:44 +0200 Subject: [PATCH 04/29] Fix typo in TLS Model in Unstable Book --- src/doc/unstable-book/src/compiler-flags/tls-model.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/unstable-book/src/compiler-flags/tls-model.md b/src/doc/unstable-book/src/compiler-flags/tls-model.md index 0aefaa7fb0177..cd625f3fd096c 100644 --- a/src/doc/unstable-book/src/compiler-flags/tls-model.md +++ b/src/doc/unstable-book/src/compiler-flags/tls-model.md @@ -22,4 +22,4 @@ The TLS data must not be in a library loaded after startup (via `dlopen`). but not in a shared library, and is accessed only from that executable. `rustc` and LLVM may use a more optimized model than specified if they know that we are producing -and executable rather than a library, or that the `static` item is private enough. +an executable rather than a library, or that the `static` item is private enough. From 671770ed852daf803e6a49fc9b622a4a2e478efb Mon Sep 17 00:00:00 2001 From: jumbatm <30644300+jumbatm@users.noreply.github.com> Date: Tue, 25 Aug 2020 14:00:24 +1000 Subject: [PATCH 05/29] Also handle transparent single-variant enums --- src/librustc_lint/builtin.rs | 20 +++++++++-------- src/test/ui/lint/clashing-extern-fn.rs | 25 +++++++++++++++++++--- src/test/ui/lint/clashing-extern-fn.stderr | 22 +++++++++---------- 3 files changed, 44 insertions(+), 23 deletions(-) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index bfdf3e3b3956a..f51d7662d058c 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -38,6 +38,7 @@ use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; use rustc_hir::{ForeignItemKind, GenericParamKind, PatKind}; use rustc_hir::{HirId, HirIdSet, Node}; +use rustc_index::vec::Idx; use rustc_middle::lint::LintDiagnosticBuilder; use rustc_middle::ty::subst::{GenericArgKind, Subst}; use rustc_middle::ty::{self, Ty, TyCtxt}; @@ -2171,18 +2172,19 @@ impl ClashingExternDeclarations { loop { if let ty::Adt(def, substs) = ty.kind { let is_transparent = def.subst(tcx, substs).repr.transparent(); - let is_enum = def.is_enum(); let is_non_null = crate::types::guaranteed_nonnull_optimization(tcx, &def); debug!( - "non_transparent_ty({:?}) -- type is transparent? {}, type is enum? {}, type is non-null? {}", - ty, is_transparent, is_enum, is_non_null + "non_transparent_ty({:?}) -- type is transparent? {}, type is non-null? {}", + ty, is_transparent, is_non_null ); - if is_transparent && !is_enum && !is_non_null { - ty = def - .non_enum_variant() - .transparent_newtype_field(tcx) - .unwrap() - .ty(tcx, substs); + if is_transparent && !is_non_null { + debug_assert!(def.variants.len() == 1); + let v = &def.variants[VariantIdx::new(0)]; + assert!( + v.fields.len() > 0, + "single-variant transparent structure with zero-sized field" + ); + ty = v.transparent_newtype_field(tcx).unwrap().ty(tcx, substs); continue; } } diff --git a/src/test/ui/lint/clashing-extern-fn.rs b/src/test/ui/lint/clashing-extern-fn.rs index a2de01254477d..79e3b4cbf70ef 100644 --- a/src/test/ui/lint/clashing-extern-fn.rs +++ b/src/test/ui/lint/clashing-extern-fn.rs @@ -182,7 +182,9 @@ mod same_sized_members_clash { y: f32, z: f32, } - extern "C" { fn origin() -> Point3; } + extern "C" { + fn origin() -> Point3; + } } mod b { #[repr(C)] @@ -191,8 +193,9 @@ mod same_sized_members_clash { y: i32, z: i32, // NOTE: Incorrectly redeclared as i32 } - extern "C" { fn origin() -> Point3; } - //~^ WARN `origin` redeclared with a different signature + extern "C" { + fn origin() -> Point3; //~ WARN `origin` redeclared with a different signature + } } } @@ -312,6 +315,22 @@ mod non_zero_transparent { fn f3() -> core::ptr::NonNull; } } + + mod a4 { + #[repr(transparent)] + enum E { + X(std::num::NonZeroUsize), + } + extern "C" { + fn f4() -> E; + } + } + + mod b4 { + extern "C" { + fn f4() -> std::num::NonZeroUsize; + } + } } mod null_optimised_enums { diff --git a/src/test/ui/lint/clashing-extern-fn.stderr b/src/test/ui/lint/clashing-extern-fn.stderr index f2e53e4a3cc0e..0a18f05ba2903 100644 --- a/src/test/ui/lint/clashing-extern-fn.stderr +++ b/src/test/ui/lint/clashing-extern-fn.stderr @@ -106,19 +106,19 @@ LL | fn draw_point(p: Point); found `unsafe extern "C" fn(sameish_members::b::Point)` warning: `origin` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:194:22 + --> $DIR/clashing-extern-fn.rs:197:13 | -LL | extern "C" { fn origin() -> Point3; } - | ---------------------- `origin` previously declared here +LL | fn origin() -> Point3; + | ---------------------- `origin` previously declared here ... -LL | extern "C" { fn origin() -> Point3; } - | ^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration +LL | fn origin() -> Point3; + | ^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration | = note: expected `unsafe extern "C" fn() -> same_sized_members_clash::a::Point3` found `unsafe extern "C" fn() -> same_sized_members_clash::b::Point3` warning: `transparent_incorrect` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:217:13 + --> $DIR/clashing-extern-fn.rs:220:13 | LL | fn transparent_incorrect() -> T; | -------------------------------- `transparent_incorrect` previously declared here @@ -130,7 +130,7 @@ LL | fn transparent_incorrect() -> isize; found `unsafe extern "C" fn() -> isize` warning: `missing_return_type` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:235:13 + --> $DIR/clashing-extern-fn.rs:238:13 | LL | fn missing_return_type() -> usize; | ---------------------------------- `missing_return_type` previously declared here @@ -142,7 +142,7 @@ LL | fn missing_return_type(); found `unsafe extern "C" fn()` warning: `non_zero_usize` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:253:13 + --> $DIR/clashing-extern-fn.rs:256:13 | LL | fn non_zero_usize() -> core::num::NonZeroUsize; | ----------------------------------------------- `non_zero_usize` previously declared here @@ -154,7 +154,7 @@ LL | fn non_zero_usize() -> usize; found `unsafe extern "C" fn() -> usize` warning: `non_null_ptr` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:255:13 + --> $DIR/clashing-extern-fn.rs:258:13 | LL | fn non_null_ptr() -> core::ptr::NonNull; | ----------------------------------------------- `non_null_ptr` previously declared here @@ -166,7 +166,7 @@ LL | fn non_null_ptr() -> *const usize; found `unsafe extern "C" fn() -> *const usize` warning: `option_non_zero_usize_incorrect` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:337:13 + --> $DIR/clashing-extern-fn.rs:356:13 | LL | fn option_non_zero_usize_incorrect() -> usize; | ---------------------------------------------- `option_non_zero_usize_incorrect` previously declared here @@ -178,7 +178,7 @@ LL | fn option_non_zero_usize_incorrect() -> isize; found `unsafe extern "C" fn() -> isize` warning: `option_non_null_ptr_incorrect` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:339:13 + --> $DIR/clashing-extern-fn.rs:358:13 | LL | fn option_non_null_ptr_incorrect() -> *const usize; | --------------------------------------------------- `option_non_null_ptr_incorrect` previously declared here From 2ea86af1eaed20227a6176995aa6c082f245924c Mon Sep 17 00:00:00 2001 From: jumbatm <30644300+jumbatm@users.noreply.github.com> Date: Tue, 25 Aug 2020 23:52:41 +1000 Subject: [PATCH 06/29] Use same name as attr. Co-authored-by: Bastian Kauschke --- src/librustc_lint/builtin.rs | 2 +- src/librustc_lint/types.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index f51d7662d058c..593d480270406 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -2172,7 +2172,7 @@ impl ClashingExternDeclarations { loop { if let ty::Adt(def, substs) = ty.kind { let is_transparent = def.subst(tcx, substs).repr.transparent(); - let is_non_null = crate::types::guaranteed_nonnull_optimization(tcx, &def); + let is_non_null = crate::types::nonnull_optimization_guaranteed(tcx, &def); debug!( "non_transparent_ty({:?}) -- type is transparent? {}, type is non-null? {}", ty, is_transparent, is_non_null diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 849e8df1e5fdb..35c462c24c8e8 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -527,7 +527,7 @@ enum FfiResult<'tcx> { FfiUnsafe { ty: Ty<'tcx>, reason: String, help: Option }, } -crate fn guaranteed_nonnull_optimization<'tcx>(tcx: TyCtxt<'tcx>, def: &ty::AdtDef) -> bool { +crate fn nonnull_optimization_guaranteed<'tcx>(tcx: TyCtxt<'tcx>, def: &ty::AdtDef) -> bool { tcx.get_attrs(def.did) .iter() .any(|a| tcx.sess.check_name(a, sym::rustc_nonnull_optimization_guaranteed)) @@ -541,7 +541,7 @@ crate fn ty_is_known_nonnull<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, mode: C ty::Ref(..) => true, ty::Adt(def, _) if def.is_box() && matches!(mode, CItemKind::Definition) => true, ty::Adt(def, substs) if def.repr.transparent() && !def.is_union() => { - let marked_non_null = guaranteed_nonnull_optimization(tcx, &def); + let marked_non_null = nonnull_optimization_guaranteed(tcx, &def); if marked_non_null { return true; From 352df40df53e0b559ecefcd5a4409ec43143c645 Mon Sep 17 00:00:00 2001 From: jumbatm <30644300+jumbatm@users.noreply.github.com> Date: Tue, 25 Aug 2020 23:41:13 +1000 Subject: [PATCH 07/29] Remove unnecessary assert. --- src/librustc_lint/builtin.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 593d480270406..f8d30ebb0b18f 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -2180,11 +2180,12 @@ impl ClashingExternDeclarations { if is_transparent && !is_non_null { debug_assert!(def.variants.len() == 1); let v = &def.variants[VariantIdx::new(0)]; - assert!( - v.fields.len() > 0, - "single-variant transparent structure with zero-sized field" - ); - ty = v.transparent_newtype_field(tcx).unwrap().ty(tcx, substs); + ty = v + .transparent_newtype_field(tcx) + .expect( + "single-variant transparent structure with zero-sized field", + ) + .ty(tcx, substs); continue; } } From a4090d28da2068692d262649e99bbb4e4e32ca67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Tue, 25 Aug 2020 17:58:58 +0200 Subject: [PATCH 08/29] Add test for issue #27130 --- src/test/codegen/issue-27130.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/test/codegen/issue-27130.rs diff --git a/src/test/codegen/issue-27130.rs b/src/test/codegen/issue-27130.rs new file mode 100644 index 0000000000000..466245aa1f456 --- /dev/null +++ b/src/test/codegen/issue-27130.rs @@ -0,0 +1,22 @@ +// compile-flags: -O +// min-llvm-version: 11.0 + +#![crate_type = "lib"] + +// CHECK-LABEL: @trim_in_place +#[no_mangle] +pub fn trim_in_place(a: &mut &[u8]) { + while a.first() == Some(&42) { + // CHECK-NOT: slice_index_order_fail + *a = &a[1..]; + } +} + +// CHECK-LABEL: @trim_in_place2 +#[no_mangle] +pub fn trim_in_place2(a: &mut &[u8]) { + while let Some(&42) = a.first() { + // CHECK-NOT: slice_index_order_fail + *a = &a[1..]; + } +} From 28798132aafd9623b6dc3ffc29ce73786569ede0 Mon Sep 17 00:00:00 2001 From: Alexis Bourget Date: Tue, 25 Aug 2020 22:46:12 +0200 Subject: [PATCH 09/29] Move to intra doc links for core::ptr::non_null --- library/core/src/ptr/non_null.rs | 36 ++++++++++++++------------------ 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index 294a3173d0cbf..87a59c873b197 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -34,8 +34,8 @@ use crate::slice::{self, SliceIndex}; /// it is your responsibility to ensure that `as_mut` is never called, and `as_ptr` /// is never used for mutation. /// -/// [`PhantomData`]: ../marker/struct.PhantomData.html -/// [`UnsafeCell`]: ../cell/struct.UnsafeCell.html +/// [`PhantomData`]: crate::marker::PhantomData +/// [`UnsafeCell`]: crate::cell::UnsafeCell #[stable(feature = "nonnull", since = "1.25.0")] #[repr(transparent)] #[rustc_layout_scalar_valid_range_start(1)] @@ -82,8 +82,8 @@ impl NonNull { /// /// For the mutable counterpart see [`as_uninit_mut`]. /// - /// [`as_ref`]: #method.as_ref - /// [`as_uninit_mut`]: #method.as_uninit_mut + /// [`as_ref`]: NonNull::as_ref + /// [`as_uninit_mut`]: NonNull::as_uninit_mut /// /// # Safety /// @@ -114,8 +114,8 @@ impl NonNull { /// /// For the shared counterpart see [`as_uninit_ref`]. /// - /// [`as_mut`]: #method.as_mut - /// [`as_uninit_ref`]: #method.as_uninit_ref + /// [`as_mut`]: NonNull::as_mut + /// [`as_uninit_ref`]: NonNull::as_uninit_ref /// /// # Safety /// @@ -181,8 +181,8 @@ impl NonNull { /// /// For the mutable counterpart see [`as_mut`]. /// - /// [`as_uninit_ref`]: #method.as_uninit_ref - /// [`as_mut`]: #method.as_mut + /// [`as_uninit_ref`]: NonNull::as_uninit_ref + /// [`as_mut`]: NonNull::as_mut /// /// # Safety /// @@ -217,8 +217,8 @@ impl NonNull { /// /// For the shared counterpart see [`as_ref`]. /// - /// [`as_uninit_mut`]: #method.as_uninit_mut - /// [`as_ref`]: #method.as_ref + /// [`as_uninit_mut`]: NonNull::as_uninit_mut + /// [`as_ref`]: NonNull::as_ref /// /// # Safety /// @@ -266,8 +266,6 @@ impl NonNull<[T]> { /// This function is safe, but dereferencing the return value is unsafe. /// See the documentation of [`slice::from_raw_parts`] for slice safety requirements. /// - /// [`slice::from_raw_parts`]: ../../std/slice/fn.from_raw_parts.html - /// /// # Examples /// /// ```rust @@ -357,8 +355,8 @@ impl NonNull<[T]> { /// /// For the mutable counterpart see [`as_uninit_slice_mut`]. /// - /// [`as_ref`]: #method.as_ref - /// [`as_uninit_slice_mut`]: #method.as_uninit_slice_mut + /// [`as_ref`]: NonNull::as_ref + /// [`as_uninit_slice_mut`]: NonNull::as_uninit_slice_mut /// /// # Safety /// @@ -386,10 +384,9 @@ impl NonNull<[T]> { /// /// This applies even if the result of this method is unused! /// - /// See also [`slice::from_raw_parts`][]. + /// See also [`slice::from_raw_parts`]. /// /// [valid]: crate::ptr#safety - /// [`NonNull::dangling()`]: NonNull::dangling /// [`pointer::offset`]: ../../std/primitive.pointer.html#method.offset #[inline] #[unstable(feature = "ptr_as_uninit", issue = "75402")] @@ -403,8 +400,8 @@ impl NonNull<[T]> { /// /// For the shared counterpart see [`as_uninit_slice`]. /// - /// [`as_mut`]: #method.as_mut - /// [`as_uninit_slice`]: #method.as_uninit_slice + /// [`as_mut`]: NonNull::as_mut + /// [`as_uninit_slice`]: NonNull::as_uninit_slice /// /// # Safety /// @@ -432,10 +429,9 @@ impl NonNull<[T]> { /// /// This applies even if the result of this method is unused! /// - /// See also [`slice::from_raw_parts_mut`][]. + /// See also [`slice::from_raw_parts_mut`]. /// /// [valid]: crate::ptr#safety - /// [`NonNull::dangling()`]: NonNull::dangling /// [`pointer::offset`]: ../../std/primitive.pointer.html#method.offset /// /// # Examples From a712fbd50bd7a579d4a46d426e9f8b1c627d4bc4 Mon Sep 17 00:00:00 2001 From: Surya Midatala Date: Sun, 23 Aug 2020 15:53:16 +0530 Subject: [PATCH 10/29] Move to intra-doc links for wasi/ext/fs.rs, os_str_bytes.rs, primitive_docs.rs & poison.rs --- library/std/src/primitive_docs.rs | 178 ++++++++------------- library/std/src/sys/wasi/ext/fs.rs | 27 +--- library/std/src/sys_common/os_str_bytes.rs | 12 -- library/std/src/sys_common/poison.rs | 26 ++- 4 files changed, 75 insertions(+), 168 deletions(-) diff --git a/library/std/src/primitive_docs.rs b/library/std/src/primitive_docs.rs index be7fd0dd6c447..392c89a6ecf63 100644 --- a/library/std/src/primitive_docs.rs +++ b/library/std/src/primitive_docs.rs @@ -20,10 +20,9 @@ /// assert!(!bool_val); /// ``` /// -/// [`assert!`]: macro.assert.html -/// [`BitAnd`]: ops/trait.BitAnd.html -/// [`BitOr`]: ops/trait.BitOr.html -/// [`Not`]: ops/trait.Not.html +/// [`BitAnd`]: ops::BitAnd +/// [`BitOr`]: ops::BitOr +/// [`Not`]: ops::Not /// /// # Examples /// @@ -46,7 +45,7 @@ /// } /// ``` /// -/// Also, since `bool` implements the [`Copy`](marker/trait.Copy.html) trait, we don't +/// Also, since `bool` implements the [`Copy`] trait, we don't /// have to worry about the move semantics (just like the integer and float primitives). /// /// Now an example of `bool` cast to integer type: @@ -100,8 +99,7 @@ mod prim_bool {} /// at all we know it can never produce a value which isn't a [`u32`]. This illustrates another /// behaviour of the `!` type - expressions with type `!` will coerce into any other type. /// -/// [`u32`]: primitive.str.html -/// [`exit`]: process/fn.exit.html +/// [`exit`]: crate::process::exit /// /// # `!` and generics /// @@ -185,14 +183,12 @@ mod prim_bool {} /// ever stops, it means that an error occurred. We don't even have to wrap the loop in an `Ok` /// because `!` coerces to `Result` automatically. /// -/// [`String::from_str`]: str/trait.FromStr.html#tymethod.from_str -/// [`Result`]: result/enum.Result.html -/// [`Result`]: result/enum.Result.html -/// [`Result`]: result/enum.Result.html -/// [`Ok`]: result/enum.Result.html#variant.Ok -/// [`String`]: string/struct.String.html -/// [`Err`]: result/enum.Result.html#variant.Err -/// [`FromStr`]: str/trait.FromStr.html +/// [`String::from_str`]: str::FromStr::from_str +/// [`Result`]: Result +/// [`Result`]: Result +/// [`Result`]: Result +/// [`String`]: string::String +/// [`FromStr`]: str::FromStr /// /// # `!` and traits /// @@ -233,11 +229,9 @@ mod prim_bool {} /// `impl` for this which simply panics, but the same is true for any type (we could `impl /// Default` for (eg.) [`File`] by just making [`default()`] panic.) /// -/// [`fmt::Result`]: fmt/type.Result.html -/// [`File`]: fs/struct.File.html -/// [`Debug`]: fmt/trait.Debug.html -/// [`Default`]: default/trait.Default.html -/// [`default()`]: default/trait.Default.html#tymethod.default +/// [`File`]: fs::File +/// [`Debug`]: fmt::Debug +/// [`default()`]: Default::default /// #[unstable(feature = "never_type", issue = "35121")] mod prim_never {} @@ -360,7 +354,7 @@ mod prim_unit {} // /// Raw, unsafe pointers, `*const T`, and `*mut T`. /// -/// *[See also the `std::ptr` module](ptr/index.html).* +/// *[See also the `std::ptr` module][`crate::ptr`].* /// /// Working with raw pointers in Rust is uncommon, typically limited to a few patterns. /// Raw pointers can be unaligned or [`null`]. However, when a raw pointer is @@ -439,13 +433,13 @@ mod prim_unit {} /// but C APIs hand out a lot of pointers generally, so are a common source /// of raw pointers in Rust. /// -/// [`null`]: ../std/ptr/fn.null.html -/// [`null_mut`]: ../std/ptr/fn.null_mut.html +/// [`null`]: ptr::null +/// [`null_mut`]: ptr::null_mut /// [`is_null`]: ../std/primitive.pointer.html#method.is_null /// [`offset`]: ../std/primitive.pointer.html#method.offset -/// [`into_raw`]: ../std/boxed/struct.Box.html#method.into_raw -/// [`drop`]: ../std/mem/fn.drop.html -/// [`write`]: ../std/ptr/fn.write.html +/// [`into_raw`]: Box::into_raw +/// [`drop`]: mem::drop +/// [`write`]: ptr::write #[stable(feature = "rust1", since = "1.0.0")] mod prim_pointer {} @@ -458,24 +452,24 @@ mod prim_pointer {} /// /// * A list with each element, i.e., `[x, y, z]`. /// * A repeat expression `[x; N]`, which produces an array with `N` copies of `x`. -/// The type of `x` must be [`Copy`][copy]. +/// The type of `x` must be [`Copy`]. /// /// Arrays of *any* size implement the following traits if the element type allows it: /// -/// - [`Debug`][debug] -/// - [`IntoIterator`][intoiterator] (implemented for `&[T; N]` and `&mut [T; N]`) -/// - [`PartialEq`][partialeq], [`PartialOrd`][partialord], [`Eq`][eq], [`Ord`][ord] -/// - [`Hash`][hash] -/// - [`AsRef`][asref], [`AsMut`][asmut] -/// - [`Borrow`][borrow], [`BorrowMut`][borrowmut] +/// - [`Debug`] +/// - [`IntoIterator`] (implemented for `&[T; N]` and `&mut [T; N]`) +/// - [`PartialEq`], [`PartialOrd`], [`Eq`], [`Ord`] +/// - [`Hash`] +/// - [`AsRef`], [`AsMut`] +/// - [`Borrow`], [`BorrowMut`] /// -/// Arrays of sizes from 0 to 32 (inclusive) implement [`Default`][default] trait +/// Arrays of sizes from 0 to 32 (inclusive) implement [`Default`] trait /// if the element type allows it. As a stopgap, trait implementations are /// statically generated up to size 32. /// -/// Arrays of *any* size are [`Copy`][copy] if the element type is [`Copy`][copy] -/// and [`Clone`][clone] if the element type is [`Clone`][clone]. This works -/// because [`Copy`][copy] and [`Clone`][clone] traits are specially known +/// Arrays of *any* size are [`Copy`] if the element type is [`Copy`] +/// and [`Clone`] if the element type is [`Clone`]. This works +/// because [`Copy`] and [`Clone`] traits are specially known /// to the compiler. /// /// Arrays coerce to [slices (`[T]`)][slice], so a slice method may be called on @@ -483,7 +477,7 @@ mod prim_pointer {} /// Slices have a dynamic size and do not coerce to arrays. /// /// You can move elements out of an array with a slice pattern. If you want -/// one element, see [`mem::replace`][replace]. +/// one element, see [`mem::replace`]. /// /// # Examples /// @@ -535,22 +529,10 @@ mod prim_pointer {} /// ``` /// /// [slice]: primitive.slice.html -/// [copy]: marker/trait.Copy.html -/// [clone]: clone/trait.Clone.html -/// [debug]: fmt/trait.Debug.html -/// [intoiterator]: iter/trait.IntoIterator.html -/// [partialeq]: cmp/trait.PartialEq.html -/// [partialord]: cmp/trait.PartialOrd.html -/// [eq]: cmp/trait.Eq.html -/// [ord]: cmp/trait.Ord.html -/// [hash]: hash/trait.Hash.html -/// [asref]: convert/trait.AsRef.html -/// [asmut]: convert/trait.AsMut.html -/// [borrow]: borrow/trait.Borrow.html -/// [borrowmut]: borrow/trait.BorrowMut.html -/// [default]: default/trait.Default.html -/// [replace]: mem/fn.replace.html -/// [`IntoIterator`]: iter/trait.IntoIterator.html +/// [`Debug`]: fmt::Debug +/// [`Hash`]: hash::Hash +/// [`Borrow`]: borrow::Borrow +/// [`BorrowMut`]: borrow::BorrowMut /// #[stable(feature = "rust1", since = "1.0.0")] mod prim_array {} @@ -563,7 +545,7 @@ mod prim_array {} /// means that elements are laid out so that every element is the same /// distance from its neighbors. /// -/// *[See also the `std::slice` module](slice/index.html).* +/// *[See also the `std::slice` module][`crate::slice`].* /// /// Slices are a view into a block of memory represented as a pointer and a /// length. @@ -608,7 +590,7 @@ mod prim_slice {} // /// String slices. /// -/// *[See also the `std::str` module](str/index.html).* +/// *[See also the `std::str` module][`crate::str`].* /// /// The `str` type, also called a 'string slice', is the most primitive string /// type. It is usually seen in its borrowed form, `&str`. It is also the type @@ -729,15 +711,8 @@ mod prim_str {} /// * [`Default`] /// * [`Hash`] /// -/// [`Clone`]: clone/trait.Clone.html -/// [`Copy`]: marker/trait.Copy.html -/// [`PartialEq`]: cmp/trait.PartialEq.html -/// [`Eq`]: cmp/trait.Eq.html -/// [`PartialOrd`]: cmp/trait.PartialOrd.html -/// [`Ord`]: cmp/trait.Ord.html -/// [`Debug`]: fmt/trait.Debug.html -/// [`Default`]: default/trait.Default.html -/// [`Hash`]: hash/trait.Hash.html +/// [`Debug`]: fmt::Debug +/// [`Hash`]: hash::Hash /// /// Due to a temporary restriction in Rust's type system, these traits are only /// implemented on tuples of arity 12 or less. In the future, this may change. @@ -810,7 +785,7 @@ mod prim_tuple {} /// /// For more information on floating point numbers, see [Wikipedia][wikipedia]. /// -/// *[See also the `std::f32::consts` module](f32/consts/index.html).* +/// *[See also the `std::f32::consts` module][`crate::f32::consts`].* /// /// [wikipedia]: https://en.wikipedia.org/wiki/Single-precision_floating-point_format #[stable(feature = "rust1", since = "1.0.0")] @@ -819,12 +794,12 @@ mod prim_f32 {} #[doc(primitive = "f64")] /// A 64-bit floating point type (specifically, the "binary64" type defined in IEEE 754-2008). /// -/// This type is very similar to [`f32`](primitive.f32.html), but has increased +/// This type is very similar to [`f32`], but has increased /// precision by using twice as many bits. Please see [the documentation for -/// `f32`](primitive.f32.html) or [Wikipedia on double precision +/// `f32`] or [Wikipedia on double precision /// values][wikipedia] for more information. /// -/// *[See also the `std::f64::consts` module](f64/consts/index.html).* +/// *[See also the `std::f64::consts` module][`crate::f64::consts`].* /// /// [wikipedia]: https://en.wikipedia.org/wiki/Double-precision_floating-point_format #[stable(feature = "rust1", since = "1.0.0")] @@ -945,9 +920,6 @@ mod prim_usize {} /// implicit reference-pointer coercion and raw pointer equality via [`ptr::eq`], while /// [`PartialEq`] compares values. /// -/// [`ptr::eq`]: ptr/fn.eq.html -/// [`PartialEq`]: cmp/trait.PartialEq.html -/// /// ``` /// use std::ptr; /// @@ -979,11 +951,9 @@ mod prim_usize {} /// * [`Borrow`] /// * [`Pointer`] /// -/// [`Copy`]: marker/trait.Copy.html -/// [`Clone`]: clone/trait.Clone.html -/// [`Deref`]: ops/trait.Deref.html -/// [`Borrow`]: borrow/trait.Borrow.html -/// [`Pointer`]: fmt/trait.Pointer.html +/// [`Deref`]: ops::Deref +/// [`Borrow`]: borrow::Borrow +/// [`Pointer`]: fmt::Pointer /// /// `&mut T` references get all of the above except `Copy` and `Clone` (to prevent creating /// multiple simultaneous mutable borrows), plus the following, regardless of the type of its @@ -992,8 +962,8 @@ mod prim_usize {} /// * [`DerefMut`] /// * [`BorrowMut`] /// -/// [`DerefMut`]: ops/trait.DerefMut.html -/// [`BorrowMut`]: borrow/trait.BorrowMut.html +/// [`DerefMut`]: ops::DerefMut +/// [`BorrowMut`]: borrow::BorrowMut /// /// The following traits are implemented on `&T` references if the underlying `T` also implements /// that trait: @@ -1008,18 +978,10 @@ mod prim_usize {} /// * [`Hash`] /// * [`ToSocketAddrs`] /// -/// [`std::fmt`]: fmt/index.html -/// [`fmt::Write`]: fmt/trait.Write.html -/// [`PartialOrd`]: cmp/trait.PartialOrd.html -/// [`Ord`]: cmp/trait.Ord.html -/// [`PartialEq`]: cmp/trait.PartialEq.html -/// [`Eq`]: cmp/trait.Eq.html -/// [`AsRef`]: convert/trait.AsRef.html -/// [`Fn`]: ops/trait.Fn.html -/// [`FnMut`]: ops/trait.FnMut.html -/// [`FnOnce`]: ops/trait.FnOnce.html -/// [`Hash`]: hash/trait.Hash.html -/// [`ToSocketAddrs`]: net/trait.ToSocketAddrs.html +/// [`std::fmt`]: fmt +/// ['Pointer`]: fmt::Pointer +/// [`Hash`]: hash::Hash +/// [`ToSocketAddrs`]: net::ToSocketAddrs /// /// `&mut T` references get all of the above except `ToSocketAddrs`, plus the following, if `T` /// implements that trait: @@ -1038,17 +1000,11 @@ mod prim_usize {} /// * [`Seek`] /// * [`BufRead`] /// -/// [`AsMut`]: convert/trait.AsMut.html -/// [`Iterator`]: iter/trait.Iterator.html -/// [`DoubleEndedIterator`]: iter/trait.DoubleEndedIterator.html -/// [`ExactSizeIterator`]: iter/trait.ExactSizeIterator.html -/// [`FusedIterator`]: iter/trait.FusedIterator.html -/// [`TrustedLen`]: iter/trait.TrustedLen.html -/// [`Send`]: marker/trait.Send.html -/// [`io::Write`]: io/trait.Write.html -/// [`Read`]: io/trait.Read.html -/// [`Seek`]: io/trait.Seek.html -/// [`BufRead`]: io/trait.BufRead.html +/// [`FusedIterator`]: iter::FusedIterator +/// [`TrustedLen`]: iter::TrustedLen +/// [`Seek`]: io::Seek +/// [`BufRead`]: io::BufRead +/// [`Read`]: io::Read /// /// Note that due to method call deref coercion, simply calling a trait method will act like they /// work on references as well as they do on owned values! The implementations described here are @@ -1063,9 +1019,9 @@ mod prim_ref {} /// /// *See also the traits [`Fn`], [`FnMut`], and [`FnOnce`].* /// -/// [`Fn`]: ops/trait.Fn.html -/// [`FnMut`]: ops/trait.FnMut.html -/// [`FnOnce`]: ops/trait.FnOnce.html +/// [`Fn`]: ops::Fn +/// [`FnMut`]: ops::FnMut +/// [`FnOnce`]: ops::FnOnce /// /// Function pointers are pointers that point to *code*, not data. They can be called /// just like functions. Like references, function pointers are, among other things, assumed to @@ -1177,14 +1133,8 @@ mod prim_ref {} /// * [`Pointer`] /// * [`Debug`] /// -/// [`Clone`]: clone/trait.Clone.html -/// [`PartialEq`]: cmp/trait.PartialEq.html -/// [`Eq`]: cmp/trait.Eq.html -/// [`PartialOrd`]: cmp/trait.PartialOrd.html -/// [`Ord`]: cmp/trait.Ord.html -/// [`Hash`]: hash/trait.Hash.html -/// [`Pointer`]: fmt/trait.Pointer.html -/// [`Debug`]: fmt/trait.Debug.html +/// [`Hash`]: hash::Hash +/// [`Pointer`]: fmt::Pointer /// /// Due to a temporary restriction in Rust's type system, these traits are only implemented on /// functions that take 12 arguments or less, with the `"Rust"` and `"C"` ABIs. In the future, this @@ -1193,7 +1143,5 @@ mod prim_ref {} /// In addition, function pointers of *any* signature, ABI, or safety are [`Copy`], and all *safe* /// function pointers implement [`Fn`], [`FnMut`], and [`FnOnce`]. This works because these traits /// are specially known to the compiler. -/// -/// [`Copy`]: marker/trait.Copy.html #[stable(feature = "rust1", since = "1.0.0")] mod prim_fn {} diff --git a/library/std/src/sys/wasi/ext/fs.rs b/library/std/src/sys/wasi/ext/fs.rs index f41c6626ccf12..501ad8ee7d6b3 100644 --- a/library/std/src/sys/wasi/ext/fs.rs +++ b/library/std/src/sys/wasi/ext/fs.rs @@ -9,8 +9,6 @@ use crate::sys::fs::osstr2str; use crate::sys_common::{AsInner, AsInnerMut, FromInner}; /// WASI-specific extensions to [`File`]. -/// -/// [`File`]: ../../../../std/fs/struct.File.html pub trait FileExt { /// Reads a number of bytes starting from a given offset. /// @@ -23,8 +21,6 @@ pub trait FileExt { /// /// Note that similar to [`File::read`], it is not an error to return with a /// short read. - /// - /// [`File::read`]: ../../../../std/fs/struct.File.html#method.read fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result { let bufs = &mut [IoSliceMut::new(buf)]; self.read_vectored_at(bufs, offset) @@ -41,8 +37,6 @@ pub trait FileExt { /// /// Note that similar to [`File::read_vectored`], it is not an error to /// return with a short read. - /// - /// [`File::read`]: ../../../../std/fs/struct.File.html#method.read_vectored fn read_vectored_at(&self, bufs: &mut [IoSliceMut<'_>], offset: u64) -> io::Result; /// Reads the exact number of byte required to fill `buf` from the given offset. @@ -54,8 +48,7 @@ pub trait FileExt { /// /// Similar to [`Read::read_exact`] but uses [`read_at`] instead of `read`. /// - /// [`Read::read_exact`]: ../../../../std/io/trait.Read.html#method.read_exact - /// [`read_at`]: #tymethod.read_at + /// [`read_at`]: FileExt::read_at /// /// # Errors /// @@ -73,9 +66,6 @@ pub trait FileExt { /// If this function returns an error, it is unspecified how many bytes it /// has read, but it will never read more than would be necessary to /// completely fill the buffer. - /// - /// [`ErrorKind::Interrupted`]: ../../../../std/io/enum.ErrorKind.html#variant.Interrupted - /// [`ErrorKind::UnexpectedEof`]: ../../../../std/io/enum.ErrorKind.html#variant.UnexpectedEof #[stable(feature = "rw_exact_all_at", since = "1.33.0")] fn read_exact_at(&self, mut buf: &mut [u8], mut offset: u64) -> io::Result<()> { while !buf.is_empty() { @@ -111,8 +101,6 @@ pub trait FileExt { /// /// Note that similar to [`File::write`], it is not an error to return a /// short write. - /// - /// [`File::write`]: ../../../../std/fs/struct.File.html#write.v fn write_at(&self, buf: &[u8], offset: u64) -> io::Result { let bufs = &[IoSlice::new(buf)]; self.write_vectored_at(bufs, offset) @@ -132,8 +120,6 @@ pub trait FileExt { /// /// Note that similar to [`File::write_vectored`], it is not an error to return a /// short write. - /// - /// [`File::write`]: ../../../../std/fs/struct.File.html#method.write_vectored fn write_vectored_at(&self, bufs: &[IoSlice<'_>], offset: u64) -> io::Result; /// Attempts to write an entire buffer starting from a given offset. @@ -155,8 +141,7 @@ pub trait FileExt { /// This function will return the first error of /// non-[`ErrorKind::Interrupted`] kind that [`write_at`] returns. /// - /// [`ErrorKind::Interrupted`]: ../../../../std/io/enum.ErrorKind.html#variant.Interrupted - /// [`write_at`]: #tymethod.write_at + /// [`write_at`]: FileExt::write_at #[stable(feature = "rw_exact_all_at", since = "1.33.0")] fn write_all_at(&self, mut buf: &[u8], mut offset: u64) -> io::Result<()> { while !buf.is_empty() { @@ -289,8 +274,6 @@ impl FileExt for fs::File { } /// WASI-specific extensions to [`fs::OpenOptions`]. -/// -/// [`fs::OpenOptions`]: ../../../../std/fs/struct.OpenOptions.html pub trait OpenOptionsExt { /// Pass custom `dirflags` argument to `path_open`. /// @@ -406,8 +389,6 @@ impl OpenOptionsExt for OpenOptions { } /// WASI-specific extensions to [`fs::Metadata`]. -/// -/// [`fs::Metadata`]: ../../../../std/fs/struct.Metadata.html pub trait MetadataExt { /// Returns the `st_dev` field of the internal `filestat_t` fn dev(&self) -> u64; @@ -448,8 +429,6 @@ impl MetadataExt for fs::Metadata { /// /// Adds support for special WASI file types such as block/character devices, /// pipes, and sockets. -/// -/// [`FileType`]: ../../../../std/fs/struct.FileType.html pub trait FileTypeExt { /// Returns `true` if this file type is a block device. fn is_block_device(&self) -> bool; @@ -477,8 +456,6 @@ impl FileTypeExt for fs::FileType { } /// WASI-specific extension methods for [`fs::DirEntry`]. -/// -/// [`fs::DirEntry`]: ../../../../std/fs/struct.DirEntry.html pub trait DirEntryExt { /// Returns the underlying `d_ino` field of the `dirent_t` fn ino(&self) -> u64; diff --git a/library/std/src/sys_common/os_str_bytes.rs b/library/std/src/sys_common/os_str_bytes.rs index 984c032e2a388..323165cda6bd5 100644 --- a/library/std/src/sys_common/os_str_bytes.rs +++ b/library/std/src/sys_common/os_str_bytes.rs @@ -232,23 +232,17 @@ impl Slice { } /// Platform-specific extensions to [`OsString`]. -/// -/// [`OsString`]: ../../../../std/ffi/struct.OsString.html #[stable(feature = "rust1", since = "1.0.0")] pub trait OsStringExt { /// Creates an [`OsString`] from a byte vector. /// /// See the module documentation for an example. - /// - /// [`OsString`]: ../../../ffi/struct.OsString.html #[stable(feature = "rust1", since = "1.0.0")] fn from_vec(vec: Vec) -> Self; /// Yields the underlying byte vector of this [`OsString`]. /// /// See the module documentation for an example. - /// - /// [`OsString`]: ../../../ffi/struct.OsString.html #[stable(feature = "rust1", since = "1.0.0")] fn into_vec(self) -> Vec; } @@ -264,23 +258,17 @@ impl OsStringExt for OsString { } /// Platform-specific extensions to [`OsStr`]. -/// -/// [`OsStr`]: ../../../../std/ffi/struct.OsStr.html #[stable(feature = "rust1", since = "1.0.0")] pub trait OsStrExt { #[stable(feature = "rust1", since = "1.0.0")] /// Creates an [`OsStr`] from a byte slice. /// /// See the module documentation for an example. - /// - /// [`OsStr`]: ../../../ffi/struct.OsStr.html fn from_bytes(slice: &[u8]) -> &Self; /// Gets the underlying byte view of the [`OsStr`] slice. /// /// See the module documentation for an example. - /// - /// [`OsStr`]: ../../../ffi/struct.OsStr.html #[stable(feature = "rust1", since = "1.0.0")] fn as_bytes(&self) -> &[u8]; } diff --git a/library/std/src/sys_common/poison.rs b/library/std/src/sys_common/poison.rs index 285851d631ae7..24ccc7fc11884 100644 --- a/library/std/src/sys_common/poison.rs +++ b/library/std/src/sys_common/poison.rs @@ -78,8 +78,8 @@ pub struct Guard { /// }; /// ``` /// -/// [`Mutex`]: ../../std/sync/struct.Mutex.html -/// [`RwLock`]: ../../std/sync/struct.RwLock.html +/// [`Mutex`]: crate::sync::Mutex +/// [`RwLock`]: crate::sync::RwLock #[stable(feature = "rust1", since = "1.0.0")] pub struct PoisonError { guard: T, @@ -89,12 +89,11 @@ pub struct PoisonError { /// can occur while trying to acquire a lock, from the [`try_lock`] method on a /// [`Mutex`] or the [`try_read`] and [`try_write`] methods on an [`RwLock`]. /// -/// [`Mutex`]: struct.Mutex.html -/// [`RwLock`]: struct.RwLock.html -/// [`TryLockResult`]: type.TryLockResult.html -/// [`try_lock`]: struct.Mutex.html#method.try_lock -/// [`try_read`]: struct.RwLock.html#method.try_read -/// [`try_write`]: struct.RwLock.html#method.try_write +/// [`Mutex`]: crate::sync::Mutex +/// [`RwLock`]: crate::sync::RwLock +/// [`try_lock`]: crate::sync::Mutex::try_lock +/// [`try_read`]: crate::sync::RwLock::try_read +/// [`try_write`]: crate::sync::RwLock::try_write #[stable(feature = "rust1", since = "1.0.0")] pub enum TryLockError { /// The lock could not be acquired because another thread failed while holding @@ -115,9 +114,7 @@ pub enum TryLockError { /// the associated guard, and it can be acquired through the [`into_inner`] /// method. /// -/// [`Ok`]: ../../std/result/enum.Result.html#variant.Ok -/// [`Err`]: ../../std/result/enum.Result.html#variant.Err -/// [`into_inner`]: ../../std/sync/struct.PoisonError.html#method.into_inner +/// [`into_inner`]: PoisonError::into_inner #[stable(feature = "rust1", since = "1.0.0")] pub type LockResult = Result>; @@ -126,9 +123,6 @@ pub type LockResult = Result>; /// For more information, see [`LockResult`]. A `TryLockResult` doesn't /// necessarily hold the associated guard in the [`Err`] type as the lock may not /// have been acquired for other reasons. -/// -/// [`LockResult`]: ../../std/sync/type.LockResult.html -/// [`Err`]: ../../std/result/enum.Result.html#variant.Err #[stable(feature = "rust1", since = "1.0.0")] pub type TryLockResult = Result>; @@ -159,8 +153,8 @@ impl PoisonError { /// /// This is generally created by methods like [`Mutex::lock`] or [`RwLock::read`]. /// - /// [`Mutex::lock`]: ../../std/sync/struct.Mutex.html#method.lock - /// [`RwLock::read`]: ../../std/sync/struct.RwLock.html#method.read + /// [`Mutex::lock`]: crate::sync::Mutex::lock + /// [`RwLock::read`]: crate::sync::RwLock::read #[stable(feature = "sync_poison", since = "1.2.0")] pub fn new(guard: T) -> PoisonError { PoisonError { guard } From b3437f36e0d2c8c172344e35fbe2a01ca10de4e2 Mon Sep 17 00:00:00 2001 From: Surya Midatala Date: Sun, 23 Aug 2020 16:27:24 +0530 Subject: [PATCH 11/29] Add missed links in primitive_docs.rs --- library/std/src/primitive_docs.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/std/src/primitive_docs.rs b/library/std/src/primitive_docs.rs index 392c89a6ecf63..297c831847491 100644 --- a/library/std/src/primitive_docs.rs +++ b/library/std/src/primitive_docs.rs @@ -642,8 +642,8 @@ mod prim_slice {} /// assert_eq!(s, Ok(story)); /// ``` /// -/// [`as_ptr`]: #method.as_ptr -/// [`len`]: #method.len +/// [`as_ptr`]: str::as_ptr +/// [`len`]: str::len /// /// Note: This example shows the internals of `&str`. `unsafe` should not be /// used to get a string slice under normal circumstances. Use `as_str` From f10ab9139125a4a791e40dc2e51b5a4b06c22ea9 Mon Sep 17 00:00:00 2001 From: Surya Midatala Date: Sun, 23 Aug 2020 21:13:14 +0530 Subject: [PATCH 12/29] Add suggestions from code review --- library/std/src/primitive_docs.rs | 12 ++++++------ library/std/src/sys_common/poison.rs | 17 ++++++----------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/library/std/src/primitive_docs.rs b/library/std/src/primitive_docs.rs index 297c831847491..0752ba0bfea3c 100644 --- a/library/std/src/primitive_docs.rs +++ b/library/std/src/primitive_docs.rs @@ -99,7 +99,7 @@ mod prim_bool {} /// at all we know it can never produce a value which isn't a [`u32`]. This illustrates another /// behaviour of the `!` type - expressions with type `!` will coerce into any other type. /// -/// [`exit`]: crate::process::exit +/// [`exit`]: process::exit /// /// # `!` and generics /// @@ -354,7 +354,7 @@ mod prim_unit {} // /// Raw, unsafe pointers, `*const T`, and `*mut T`. /// -/// *[See also the `std::ptr` module][`crate::ptr`].* +/// *[See also the `std::ptr` module][`ptr`].* /// /// Working with raw pointers in Rust is uncommon, typically limited to a few patterns. /// Raw pointers can be unaligned or [`null`]. However, when a raw pointer is @@ -545,7 +545,7 @@ mod prim_array {} /// means that elements are laid out so that every element is the same /// distance from its neighbors. /// -/// *[See also the `std::slice` module][`crate::slice`].* +/// *[See also the `std::slice` module][`slice`].* /// /// Slices are a view into a block of memory represented as a pointer and a /// length. @@ -590,7 +590,7 @@ mod prim_slice {} // /// String slices. /// -/// *[See also the `std::str` module][`crate::str`].* +/// *[See also the `std::str` module][`str`].* /// /// The `str` type, also called a 'string slice', is the most primitive string /// type. It is usually seen in its borrowed form, `&str`. It is also the type @@ -785,7 +785,7 @@ mod prim_tuple {} /// /// For more information on floating point numbers, see [Wikipedia][wikipedia]. /// -/// *[See also the `std::f32::consts` module][`crate::f32::consts`].* +/// *[See also the `std::f32::consts` module][`f32::consts`].* /// /// [wikipedia]: https://en.wikipedia.org/wiki/Single-precision_floating-point_format #[stable(feature = "rust1", since = "1.0.0")] @@ -799,7 +799,7 @@ mod prim_f32 {} /// `f32`] or [Wikipedia on double precision /// values][wikipedia] for more information. /// -/// *[See also the `std::f64::consts` module][`crate::f64::consts`].* +/// *[See also the `std::f64::consts` module][`f64::consts`].* /// /// [wikipedia]: https://en.wikipedia.org/wiki/Double-precision_floating-point_format #[stable(feature = "rust1", since = "1.0.0")] diff --git a/library/std/src/sys_common/poison.rs b/library/std/src/sys_common/poison.rs index 24ccc7fc11884..03119e9a3733e 100644 --- a/library/std/src/sys_common/poison.rs +++ b/library/std/src/sys_common/poison.rs @@ -3,6 +3,9 @@ use crate::fmt; use crate::sync::atomic::{AtomicBool, Ordering}; use crate::thread; +#[cfg(doc)] +use crate::sync::{Mutex, RwLock}; + pub struct Flag { failed: AtomicBool, } @@ -77,9 +80,6 @@ pub struct Guard { /// } /// }; /// ``` -/// -/// [`Mutex`]: crate::sync::Mutex -/// [`RwLock`]: crate::sync::RwLock #[stable(feature = "rust1", since = "1.0.0")] pub struct PoisonError { guard: T, @@ -89,11 +89,9 @@ pub struct PoisonError { /// can occur while trying to acquire a lock, from the [`try_lock`] method on a /// [`Mutex`] or the [`try_read`] and [`try_write`] methods on an [`RwLock`]. /// -/// [`Mutex`]: crate::sync::Mutex -/// [`RwLock`]: crate::sync::RwLock -/// [`try_lock`]: crate::sync::Mutex::try_lock -/// [`try_read`]: crate::sync::RwLock::try_read -/// [`try_write`]: crate::sync::RwLock::try_write +/// [`try_lock`]: Mutex::try_lock +/// [`try_read`]: RwLock::try_read +/// [`try_write`]: RwLock::try_write #[stable(feature = "rust1", since = "1.0.0")] pub enum TryLockError { /// The lock could not be acquired because another thread failed while holding @@ -152,9 +150,6 @@ impl PoisonError { /// Creates a `PoisonError`. /// /// This is generally created by methods like [`Mutex::lock`] or [`RwLock::read`]. - /// - /// [`Mutex::lock`]: crate::sync::Mutex::lock - /// [`RwLock::read`]: crate::sync::RwLock::read #[stable(feature = "sync_poison", since = "1.2.0")] pub fn new(guard: T) -> PoisonError { PoisonError { guard } From 621cbaafffd057e346049a1a0e9367444ff25d8d Mon Sep 17 00:00:00 2001 From: Surya Midatala Date: Sun, 23 Aug 2020 21:26:17 +0530 Subject: [PATCH 13/29] Use crate::mod to disambiguate links --- library/std/src/primitive_docs.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/std/src/primitive_docs.rs b/library/std/src/primitive_docs.rs index 0752ba0bfea3c..409de011ef831 100644 --- a/library/std/src/primitive_docs.rs +++ b/library/std/src/primitive_docs.rs @@ -545,7 +545,7 @@ mod prim_array {} /// means that elements are laid out so that every element is the same /// distance from its neighbors. /// -/// *[See also the `std::slice` module][`slice`].* +/// *[See also the `std::slice` module][`crate::slice`].* /// /// Slices are a view into a block of memory represented as a pointer and a /// length. @@ -590,7 +590,7 @@ mod prim_slice {} // /// String slices. /// -/// *[See also the `std::str` module][`str`].* +/// *[See also the `std::str` module][`crate::str`].* /// /// The `str` type, also called a 'string slice', is the most primitive string /// type. It is usually seen in its borrowed form, `&str`. It is also the type @@ -785,7 +785,7 @@ mod prim_tuple {} /// /// For more information on floating point numbers, see [Wikipedia][wikipedia]. /// -/// *[See also the `std::f32::consts` module][`f32::consts`].* +/// *[See also the `std::f32::consts` module][`crate::f32::consts`].* /// /// [wikipedia]: https://en.wikipedia.org/wiki/Single-precision_floating-point_format #[stable(feature = "rust1", since = "1.0.0")] @@ -799,7 +799,7 @@ mod prim_f32 {} /// `f32`] or [Wikipedia on double precision /// values][wikipedia] for more information. /// -/// *[See also the `std::f64::consts` module][`f64::consts`].* +/// *[See also the `std::f64::consts` module][`crate::f64::consts`].* /// /// [wikipedia]: https://en.wikipedia.org/wiki/Double-precision_floating-point_format #[stable(feature = "rust1", since = "1.0.0")] From 9b89d8a7a2bd432613ec5d401a2f4eacc629e1a6 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sun, 23 Aug 2020 18:35:03 -0400 Subject: [PATCH 14/29] Fix link to `f32` Co-authored-by: Oliver Middleton --- library/std/src/primitive_docs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/primitive_docs.rs b/library/std/src/primitive_docs.rs index 409de011ef831..d163e79e037e4 100644 --- a/library/std/src/primitive_docs.rs +++ b/library/std/src/primitive_docs.rs @@ -796,7 +796,7 @@ mod prim_f32 {} /// /// This type is very similar to [`f32`], but has increased /// precision by using twice as many bits. Please see [the documentation for -/// `f32`] or [Wikipedia on double precision +/// `f32`][`f32`] or [Wikipedia on double precision /// values][wikipedia] for more information. /// /// *[See also the `std::f64::consts` module][`crate::f64::consts`].* From 25c034c52e90969d53aba3351a204c6ae3473a0c Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sun, 23 Aug 2020 18:51:28 -0400 Subject: [PATCH 15/29] Use allow(unused_imports) instead of cfg(doc) for imports used only for intra-doc links --- library/std/src/sys_common/poison.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/sys_common/poison.rs b/library/std/src/sys_common/poison.rs index 03119e9a3733e..3f079da9098c7 100644 --- a/library/std/src/sys_common/poison.rs +++ b/library/std/src/sys_common/poison.rs @@ -3,7 +3,7 @@ use crate::fmt; use crate::sync::atomic::{AtomicBool, Ordering}; use crate::thread; -#[cfg(doc)] +#[allow(unused_imports)] // for intra-doc links use crate::sync::{Mutex, RwLock}; pub struct Flag { From 7569cf98f93949880aae66fe843c90490f0f5120 Mon Sep 17 00:00:00 2001 From: Surya Midatala Date: Wed, 26 Aug 2020 21:55:42 +0530 Subject: [PATCH 16/29] Merge conflict fix: disambiguate f32 -> prim@f32 and u32 -> prim@u32 --- library/std/src/primitive_docs.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/std/src/primitive_docs.rs b/library/std/src/primitive_docs.rs index d163e79e037e4..2339ca527bd83 100644 --- a/library/std/src/primitive_docs.rs +++ b/library/std/src/primitive_docs.rs @@ -99,6 +99,7 @@ mod prim_bool {} /// at all we know it can never produce a value which isn't a [`u32`]. This illustrates another /// behaviour of the `!` type - expressions with type `!` will coerce into any other type. /// +/// [`u32`]: prim@u32 /// [`exit`]: process::exit /// /// # `!` and generics @@ -801,6 +802,7 @@ mod prim_f32 {} /// /// *[See also the `std::f64::consts` module][`crate::f64::consts`].* /// +/// [`f32`]: prim@f32 /// [wikipedia]: https://en.wikipedia.org/wiki/Double-precision_floating-point_format #[stable(feature = "rust1", since = "1.0.0")] mod prim_f64 {} From 970e7793bfefd3d93034869ef8672affa02fff24 Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Thu, 27 Aug 2020 19:11:48 +0200 Subject: [PATCH 17/29] Add __fastfail for Windows on arm/aarch64 --- library/panic_abort/src/lib.rs | 15 +++++++++++++-- library/std/src/sys/windows/mod.rs | 16 +++++++++++++--- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/library/panic_abort/src/lib.rs b/library/panic_abort/src/lib.rs index ccc067a3c943d..7eece6768e99a 100644 --- a/library/panic_abort/src/lib.rs +++ b/library/panic_abort/src/lib.rs @@ -47,7 +47,7 @@ pub unsafe extern "C" fn __rust_start_panic(_payload: usize) -> u32 { } __rust_abort(); } - } else if #[cfg(all(windows, any(target_arch = "x86", target_arch = "x86_64")))] { + } else if #[cfg(windows)] { // On Windows, use the processor-specific __fastfail mechanism. In Windows 8 // and later, this will terminate the process immediately without running any // in-process exception handlers. In earlier versions of Windows, this @@ -59,7 +59,18 @@ pub unsafe extern "C" fn __rust_start_panic(_payload: usize) -> u32 { // // Note: this is the same implementation as in libstd's `abort_internal` unsafe fn abort() -> ! { - llvm_asm!("int $$0x29" :: "{ecx}"(7) ::: volatile); // 7 is FAST_FAIL_FATAL_APP_EXIT + const FAST_FAIL_FATAL_APP_EXIT: usize = 7; + cfg_if::cfg_if! { + if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { + llvm_asm!("int $$0x29" :: "{ecx}"(FAST_FAIL_FATAL_APP_EXIT) ::: volatile); + } else if #[cfg(target_arch = "arm")] { + llvm_asm!(".inst 0xDEFB" :: "{r0}"(FAST_FAIL_FATAL_APP_EXIT) ::: volatile); + } else if #[cfg(target_arch = "aarch64")] { + llvm_asm!(".inst 0xF003" :: "{x0}"(FAST_FAIL_FATAL_APP_EXIT) ::: volatile); + } else { + core::intrinsics::abort(); + } + } core::intrinsics::unreachable(); } } else { diff --git a/library/std/src/sys/windows/mod.rs b/library/std/src/sys/windows/mod.rs index a0d5a7471d8af..8fbd43ad5a58e 100644 --- a/library/std/src/sys/windows/mod.rs +++ b/library/std/src/sys/windows/mod.rs @@ -306,10 +306,20 @@ pub fn dur2timeout(dur: Duration) -> c::DWORD { /// that function for more information on `__fastfail` #[allow(unreachable_code)] pub fn abort_internal() -> ! { - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + const FAST_FAIL_FATAL_APP_EXIT: usize = 7; unsafe { - llvm_asm!("int $$0x29" :: "{ecx}"(7) ::: volatile); // 7 is FAST_FAIL_FATAL_APP_EXIT - crate::intrinsics::unreachable(); + cfg_if::cfg_if! { + if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { + llvm_asm!("int $$0x29" :: "{ecx}"(FAST_FAIL_FATAL_APP_EXIT) ::: volatile); + crate::intrinsics::unreachable(); + } else if #[cfg(target_arch = "arm")] { + llvm_asm!(".inst 0xDEFB" :: "{r0}"(FAST_FAIL_FATAL_APP_EXIT) ::: volatile); + crate::intrinsics::unreachable(); + } else if #[cfg(target_arch = "aarch64")] { + llvm_asm!(".inst 0xF003" :: "{x0}"(FAST_FAIL_FATAL_APP_EXIT) ::: volatile); + crate::intrinsics::unreachable(); + } + } } crate::intrinsics::abort(); } From f0722c06a7f684502c06dd687383a2c589c5564f Mon Sep 17 00:00:00 2001 From: Camelid <37223377+camelid@users.noreply.github.com> Date: Sun, 23 Aug 2020 14:48:37 -0700 Subject: [PATCH 18/29] Switch to intra-doc links in `core::hash` --- library/core/src/hash/mod.rs | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/library/core/src/hash/mod.rs b/library/core/src/hash/mod.rs index 6abe19dc155d1..f53ba98143842 100644 --- a/library/core/src/hash/mod.rs +++ b/library/core/src/hash/mod.rs @@ -39,8 +39,6 @@ //! If you need more control over how a value is hashed, you need to implement //! the [`Hash`] trait: //! -//! [`Hash`]: trait.Hash.html -//! //! ```rust //! use std::collections::hash_map::DefaultHasher; //! use std::hash::{Hash, Hasher}; @@ -149,11 +147,9 @@ mod sip; /// Thankfully, you won't need to worry about upholding this property when /// deriving both [`Eq`] and `Hash` with `#[derive(PartialEq, Eq, Hash)]`. /// -/// [`Eq`]: ../../std/cmp/trait.Eq.html -/// [`Hasher`]: trait.Hasher.html /// [`HashMap`]: ../../std/collections/struct.HashMap.html /// [`HashSet`]: ../../std/collections/struct.HashSet.html -/// [`hash`]: #tymethod.hash +/// [`hash`]: Hash::hash #[stable(feature = "rust1", since = "1.0.0")] pub trait Hash { /// Feeds this value into the given [`Hasher`]. @@ -168,8 +164,6 @@ pub trait Hash { /// 7920.hash(&mut hasher); /// println!("Hash is {:x}!", hasher.finish()); /// ``` - /// - /// [`Hasher`]: trait.Hasher.html #[stable(feature = "rust1", since = "1.0.0")] fn hash(&self, state: &mut H); @@ -186,8 +180,6 @@ pub trait Hash { /// Hash::hash_slice(&numbers, &mut hasher); /// println!("Hash is {:x}!", hasher.finish()); /// ``` - /// - /// [`Hasher`]: trait.Hasher.html #[stable(feature = "hash_slice", since = "1.3.0")] fn hash_slice(data: &[Self], state: &mut H) where @@ -239,10 +231,9 @@ pub use macros::Hash; /// println!("Hash is {:x}!", hasher.finish()); /// ``` /// -/// [`Hash`]: trait.Hash.html -/// [`finish`]: #tymethod.finish -/// [`write`]: #tymethod.write -/// [`write_u8`]: #method.write_u8 +/// [`finish`]: Hasher::finish +/// [`write`]: Hasher::write +/// [`write_u8`]: Hasher::write_u8 #[stable(feature = "rust1", since = "1.0.0")] pub trait Hasher { /// Returns the hash value for the values written so far. @@ -264,7 +255,7 @@ pub trait Hasher { /// println!("Hash is {:x}!", hasher.finish()); /// ``` /// - /// [`write`]: #tymethod.write + /// [`write`]: Hasher::write #[stable(feature = "rust1", since = "1.0.0")] fn finish(&self) -> u64; @@ -433,8 +424,7 @@ impl Hasher for &mut H { /// assert_eq!(hasher_1.finish(), hasher_2.finish()); /// ``` /// -/// [`build_hasher`]: #tymethod.build_hasher -/// [`Hasher`]: trait.Hasher.html +/// [`build_hasher`]: BuildHasher::build_hasher /// [`HashMap`]: ../../std/collections/struct.HashMap.html #[stable(since = "1.7.0", feature = "build_hasher")] pub trait BuildHasher { @@ -456,8 +446,6 @@ pub trait BuildHasher { /// let s = RandomState::new(); /// let new_s = s.build_hasher(); /// ``` - /// - /// [`Hasher`]: trait.Hasher.html #[stable(since = "1.7.0", feature = "build_hasher")] fn build_hasher(&self) -> Self::Hasher; } @@ -470,7 +458,7 @@ pub trait BuildHasher { /// defined. /// /// Any `BuildHasherDefault` is [zero-sized]. It can be created with -/// [`default`][method.Default]. When using `BuildHasherDefault` with [`HashMap`] or +/// [`default`][method.default]. When using `BuildHasherDefault` with [`HashMap`] or /// [`HashSet`], this doesn't need to be done, since they implement appropriate /// [`Default`] instances themselves. /// @@ -503,10 +491,7 @@ pub trait BuildHasher { /// let hash_map = HashMap::::default(); /// ``` /// -/// [`BuildHasher`]: trait.BuildHasher.html -/// [`Default`]: ../default/trait.Default.html -/// [method.default]: #method.default -/// [`Hasher`]: trait.Hasher.html +/// [method.default]: BuildHasherDefault::default /// [`HashMap`]: ../../std/collections/struct.HashMap.html /// [`HashSet`]: ../../std/collections/struct.HashSet.html /// [zero-sized]: https://doc.rust-lang.org/nomicon/exotic-sizes.html#zero-sized-types-zsts From 046556e94c641d2615bc9f7b11fba7a8573277ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Fri, 28 Aug 2020 01:16:20 +0200 Subject: [PATCH 19/29] Make sure the functions don't get merged --- src/test/codegen/issue-27130.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/codegen/issue-27130.rs b/src/test/codegen/issue-27130.rs index 466245aa1f456..7ae78782ff9d1 100644 --- a/src/test/codegen/issue-27130.rs +++ b/src/test/codegen/issue-27130.rs @@ -17,6 +17,6 @@ pub fn trim_in_place(a: &mut &[u8]) { pub fn trim_in_place2(a: &mut &[u8]) { while let Some(&42) = a.first() { // CHECK-NOT: slice_index_order_fail - *a = &a[1..]; + *a = &a[2..]; } } From 9cdcfe22887ae8df1e86c5dc7db908a50172118c Mon Sep 17 00:00:00 2001 From: ortem Date: Fri, 28 Aug 2020 09:29:45 +0300 Subject: [PATCH 20/29] Fix loading pretty-printers in rust-lldb script --- src/bootstrap/dist.rs | 1 + src/etc/lldb_commands | 1 - src/etc/rust-lldb | 5 ++++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index f0b2254be9ee9..d021feafbe416 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -647,6 +647,7 @@ impl Step for DebuggerScripts { cp_debugger_script("lldb_lookup.py"); cp_debugger_script("lldb_providers.py"); + cp_debugger_script("lldb_commands") } } } diff --git a/src/etc/lldb_commands b/src/etc/lldb_commands index f470c62d89927..979f2fa7ae828 100644 --- a/src/etc/lldb_commands +++ b/src/etc/lldb_commands @@ -1,4 +1,3 @@ -command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_lookup.py\" type synthetic add -l lldb_lookup.synthetic_lookup -x \".*\" --category Rust type summary add -F lldb_lookup.summary_lookup -e -x -h \"^(alloc::([a-z_]+::)+)String$\" --category Rust type summary add -F lldb_lookup.summary_lookup -e -x -h \"^&str$\" --category Rust diff --git a/src/etc/rust-lldb b/src/etc/rust-lldb index 28b32ef1ad532..bce72f1bad698 100755 --- a/src/etc/rust-lldb +++ b/src/etc/rust-lldb @@ -30,5 +30,8 @@ EOF fi fi +script_import="command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_lookup.py\"" +commands_file="$RUSTC_SYSROOT/lib/rustlib/etc/lldb_commands" + # Call LLDB with the commands added to the argument list -exec "$lldb" --source-before-file ./lldb_commands "$@" +exec "$lldb" --one-line-before-file "$script_import" --source-before-file "$commands_file" "$@" From 8bcc4d617869f190c9f7fc0c301e8328f719d85a Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Fri, 28 Aug 2020 11:22:16 +0200 Subject: [PATCH 21/29] Switch to asm! macro and use brk instruction on ARM --- library/panic_abort/src/lib.rs | 8 ++++---- library/std/src/sys/windows/mod.rs | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/library/panic_abort/src/lib.rs b/library/panic_abort/src/lib.rs index 7eece6768e99a..a09234e09ff9b 100644 --- a/library/panic_abort/src/lib.rs +++ b/library/panic_abort/src/lib.rs @@ -17,7 +17,7 @@ #![feature(panic_runtime)] #![feature(staged_api)] #![feature(rustc_attrs)] -#![feature(llvm_asm)] +#![feature(asm)] use core::any::Any; @@ -62,11 +62,11 @@ pub unsafe extern "C" fn __rust_start_panic(_payload: usize) -> u32 { const FAST_FAIL_FATAL_APP_EXIT: usize = 7; cfg_if::cfg_if! { if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { - llvm_asm!("int $$0x29" :: "{ecx}"(FAST_FAIL_FATAL_APP_EXIT) ::: volatile); + asm!("int $$0x29", in("ecx") FAST_FAIL_FATAL_APP_EXIT); } else if #[cfg(target_arch = "arm")] { - llvm_asm!(".inst 0xDEFB" :: "{r0}"(FAST_FAIL_FATAL_APP_EXIT) ::: volatile); + asm!("brk 0xDEFB", in("r0") FAST_FAIL_FATAL_APP_EXIT); } else if #[cfg(target_arch = "aarch64")] { - llvm_asm!(".inst 0xF003" :: "{x0}"(FAST_FAIL_FATAL_APP_EXIT) ::: volatile); + asm!("brk 0xF003", in("x0") FAST_FAIL_FATAL_APP_EXIT); } else { core::intrinsics::abort(); } diff --git a/library/std/src/sys/windows/mod.rs b/library/std/src/sys/windows/mod.rs index 8fbd43ad5a58e..03ddc3e646180 100644 --- a/library/std/src/sys/windows/mod.rs +++ b/library/std/src/sys/windows/mod.rs @@ -310,13 +310,13 @@ pub fn abort_internal() -> ! { unsafe { cfg_if::cfg_if! { if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { - llvm_asm!("int $$0x29" :: "{ecx}"(FAST_FAIL_FATAL_APP_EXIT) ::: volatile); + asm!("int $$0x29", in("ecx") FAST_FAIL_FATAL_APP_EXIT); crate::intrinsics::unreachable(); } else if #[cfg(target_arch = "arm")] { - llvm_asm!(".inst 0xDEFB" :: "{r0}"(FAST_FAIL_FATAL_APP_EXIT) ::: volatile); + asm!("brk 0xDEFB", in("r0") FAST_FAIL_FATAL_APP_EXIT); crate::intrinsics::unreachable(); } else if #[cfg(target_arch = "aarch64")] { - llvm_asm!(".inst 0xF003" :: "{x0}"(FAST_FAIL_FATAL_APP_EXIT) ::: volatile); + asm!("brk 0xF003", in("x0") FAST_FAIL_FATAL_APP_EXIT); crate::intrinsics::unreachable(); } } From 4b8ebbcc5af91decccf6153c7c0ab3075a3e391e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 28 Aug 2020 13:30:21 +0200 Subject: [PATCH 22/29] Clean up rustdoc front-end source code --- src/librustdoc/html/static/main.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 462a696dee6ef..baf32ab9cb2b6 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -1396,8 +1396,8 @@ function defocusSearchBar() { // "current" is used to know which tab we're looking into. var current = 0; onEachLazy(document.getElementById("results").childNodes, function(e) { - onEachLazy(e.getElementsByClassName("highlighted"), function(e) { - actives[current].push(e); + onEachLazy(e.getElementsByClassName("highlighted"), function(h_e) { + actives[current].push(h_e); }); current += 1; }); @@ -2113,8 +2113,12 @@ function defocusSearchBar() { } } + function getToggleAllDocsElement() { + return document.getElementById("toggle-all-docs"); + } + function toggleAllDocs(pageId, fromAutoCollapse) { - var innerToggle = document.getElementById("toggle-all-docs"); + var innerToggle = getToggleAllDocsElement(); if (!innerToggle) { return; } @@ -2307,11 +2311,6 @@ function defocusSearchBar() { } } - var toggles = document.getElementById("toggle-all-docs"); - if (toggles) { - toggles.onclick = toggleAllDocs; - } - function insertAfter(newNode, referenceNode) { referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); } @@ -2361,6 +2360,11 @@ function defocusSearchBar() { } (function() { + var toggles = document.getElementById("toggle-all-docs"); + if (toggles) { + toggles.onclick = toggleAllDocs; + } + var toggle = createSimpleToggle(false); var hideMethodDocs = getCurrentValue("rustdoc-auto-hide-method-docs") === "true"; var hideImplementors = getCurrentValue("rustdoc-auto-collapse-implementors") !== "false"; From 4bbed523208edf9521373498579ad63b22849a69 Mon Sep 17 00:00:00 2001 From: Denis Vasilik Date: Fri, 28 Aug 2020 17:24:47 +0200 Subject: [PATCH 23/29] Use intra-doc links --- library/core/src/sync/atomic.rs | 234 +------------------------------- 1 file changed, 7 insertions(+), 227 deletions(-) diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index f31a4a0b7518d..05c1120f9990e 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -10,18 +10,10 @@ //! Atomic types present operations that, when used correctly, synchronize //! updates between threads. //! -//! [`AtomicBool`]: struct.AtomicBool.html -//! [`AtomicIsize`]: struct.AtomicIsize.html -//! [`AtomicUsize`]: struct.AtomicUsize.html -//! [`AtomicI8`]: struct.AtomicI8.html -//! [`AtomicU16`]: struct.AtomicU16.html -//! //! Each method takes an [`Ordering`] which represents the strength of //! the memory barrier for that operation. These orderings are the //! same as the [C++20 atomic orderings][1]. For more information see the [nomicon][2]. //! -//! [`Ordering`]: enum.Ordering.html -//! //! [1]: https://en.cppreference.com/w/cpp/atomic/memory_order //! [2]: ../../../nomicon/atomics.html //! @@ -31,15 +23,12 @@ //! The most common way to share an atomic variable is to put it into an [`Arc`][arc] (an //! atomically-reference-counted shared pointer). //! -//! [`Sync`]: ../../marker/trait.Sync.html //! [arc]: ../../../std/sync/struct.Arc.html //! //! Atomic types may be stored in static variables, initialized using //! the constant initializers like [`AtomicBool::new`]. Atomic statics //! are often used for lazy global initialization. //! -//! [`AtomicBool::new`]: struct.AtomicBool.html#method.new -//! //! # Portability //! //! All atomic types in this module are guaranteed to be [lock-free] if they're @@ -212,8 +201,8 @@ unsafe impl Sync for AtomicPtr {} /// Atomic memory orderings /// /// Memory orderings specify the way atomic operations synchronize memory. -/// In its weakest [`Relaxed`][Ordering::Relaxed], only the memory directly touched by the -/// operation is synchronized. On the other hand, a store-load pair of [`SeqCst`][Ordering::SeqCst] +/// In its weakest [`Ordering::Relaxed`], only the memory directly touched by the +/// operation is synchronized. On the other hand, a store-load pair of [`Ordering::SeqCst`] /// operations synchronize other memory while additionally preserving a total order of such /// operations across all threads. /// @@ -223,8 +212,6 @@ unsafe impl Sync for AtomicPtr {} /// For more information see the [nomicon]. /// /// [nomicon]: ../../../nomicon/atomics.html -/// [Ordering::Relaxed]: #variant.Relaxed -/// [Ordering::SeqCst]: #variant.SeqCst #[stable(feature = "rust1", since = "1.0.0")] #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] #[non_exhaustive] @@ -248,9 +235,6 @@ pub enum Ordering { /// /// Corresponds to [`memory_order_release`] in C++20. /// - /// [`Release`]: #variant.Release - /// [`Acquire`]: #variant.Acquire - /// [`Relaxed`]: #variant.Relaxed /// [`memory_order_release`]: https://en.cppreference.com/w/cpp/atomic/memory_order#Release-Acquire_ordering #[stable(feature = "rust1", since = "1.0.0")] Release, @@ -266,9 +250,6 @@ pub enum Ordering { /// /// Corresponds to [`memory_order_acquire`] in C++20. /// - /// [`Acquire`]: #variant.Acquire - /// [`Release`]: #variant.Release - /// [`Relaxed`]: #variant.Relaxed /// [`memory_order_acquire`]: https://en.cppreference.com/w/cpp/atomic/memory_order#Release-Acquire_ordering #[stable(feature = "rust1", since = "1.0.0")] Acquire, @@ -284,9 +265,6 @@ pub enum Ordering { /// Corresponds to [`memory_order_acq_rel`] in C++20. /// /// [`memory_order_acq_rel`]: https://en.cppreference.com/w/cpp/atomic/memory_order#Release-Acquire_ordering - /// [`Acquire`]: #variant.Acquire - /// [`Release`]: #variant.Release - /// [`Relaxed`]: #variant.Relaxed #[stable(feature = "rust1", since = "1.0.0")] AcqRel, /// Like [`Acquire`]/[`Release`]/[`AcqRel`] (for load, store, and load-with-store @@ -296,16 +274,11 @@ pub enum Ordering { /// Corresponds to [`memory_order_seq_cst`] in C++20. /// /// [`memory_order_seq_cst`]: https://en.cppreference.com/w/cpp/atomic/memory_order#Sequentially-consistent_ordering - /// [`Acquire`]: #variant.Acquire - /// [`Release`]: #variant.Release - /// [`AcqRel`]: #variant.AcqRel #[stable(feature = "rust1", since = "1.0.0")] SeqCst, } /// An [`AtomicBool`] initialized to `false`. -/// -/// [`AtomicBool`]: struct.AtomicBool.html #[cfg(target_has_atomic_load_store = "8")] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_deprecated( @@ -386,13 +359,6 @@ impl AtomicBool { /// /// Panics if `order` is [`Release`] or [`AcqRel`]. /// - /// [`Ordering`]: enum.Ordering.html - /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed - /// [`Release`]: enum.Ordering.html#variant.Release - /// [`Acquire`]: enum.Ordering.html#variant.Acquire - /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel - /// [`SeqCst`]: enum.Ordering.html#variant.SeqCst - /// /// # Examples /// /// ``` @@ -419,13 +385,6 @@ impl AtomicBool { /// /// Panics if `order` is [`Acquire`] or [`AcqRel`]. /// - /// [`Ordering`]: enum.Ordering.html - /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed - /// [`Release`]: enum.Ordering.html#variant.Release - /// [`Acquire`]: enum.Ordering.html#variant.Acquire - /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel - /// [`SeqCst`]: enum.Ordering.html#variant.SeqCst - /// /// # Examples /// /// ``` @@ -456,11 +415,6 @@ impl AtomicBool { /// **Note:** This method is only available on platforms that support atomic /// operations on `u8`. /// - /// [`Ordering`]: enum.Ordering.html - /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed - /// [`Release`]: enum.Ordering.html#variant.Release - /// [`Acquire`]: enum.Ordering.html#variant.Acquire - /// /// # Examples /// /// ``` @@ -493,13 +447,6 @@ impl AtomicBool { /// **Note:** This method is only available on platforms that support atomic /// operations on `u8`. /// - /// [`Ordering`]: enum.Ordering.html - /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed - /// [`Release`]: enum.Ordering.html#variant.Release - /// [`Acquire`]: enum.Ordering.html#variant.Acquire - /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel - /// [`bool`]: ../../../std/primitive.bool.html - /// /// # Examples /// /// ``` @@ -540,11 +487,6 @@ impl AtomicBool { /// operations on `u8`. /// /// [`bool`]: ../../../std/primitive.bool.html - /// [`Ordering`]: enum.Ordering.html - /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed - /// [`Release`]: enum.Ordering.html#variant.Release - /// [`Acquire`]: enum.Ordering.html#variant.Acquire - /// [`SeqCst`]: enum.Ordering.html#variant.SeqCst /// /// # Examples /// @@ -587,7 +529,7 @@ impl AtomicBool { /// Stores a value into the [`bool`] if the current value is the same as the `current` value. /// - /// Unlike [`compare_exchange`], this function is allowed to spuriously fail even when the + /// Unlike [`AtomicBool::compare_exchange`], this function is allowed to spuriously fail even when the /// comparison succeeds, which can result in more efficient code on some platforms. The /// return value is a result indicating whether the new value was written and containing the /// previous value. @@ -604,12 +546,6 @@ impl AtomicBool { /// operations on `u8`. /// /// [`bool`]: ../../../std/primitive.bool.html - /// [`compare_exchange`]: #method.compare_exchange - /// [`Ordering`]: enum.Ordering.html - /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed - /// [`Release`]: enum.Ordering.html#variant.Release - /// [`Acquire`]: enum.Ordering.html#variant.Acquire - /// [`SeqCst`]: enum.Ordering.html#variant.SeqCst /// /// # Examples /// @@ -658,11 +594,6 @@ impl AtomicBool { /// [`Acquire`] makes the store part of this operation [`Relaxed`], and /// using [`Release`] makes the load part [`Relaxed`]. /// - /// [`Ordering`]: enum.Ordering.html - /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed - /// [`Release`]: enum.Ordering.html#variant.Release - /// [`Acquire`]: enum.Ordering.html#variant.Acquire - /// /// **Note:** This method is only available on platforms that support atomic /// operations on `u8`. /// @@ -706,11 +637,6 @@ impl AtomicBool { /// **Note:** This method is only available on platforms that support atomic /// operations on `u8`. /// - /// [`Ordering`]: enum.Ordering.html - /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed - /// [`Release`]: enum.Ordering.html#variant.Release - /// [`Acquire`]: enum.Ordering.html#variant.Acquire - /// /// # Examples /// /// ``` @@ -763,11 +689,6 @@ impl AtomicBool { /// **Note:** This method is only available on platforms that support atomic /// operations on `u8`. /// - /// [`Ordering`]: enum.Ordering.html - /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed - /// [`Release`]: enum.Ordering.html#variant.Release - /// [`Acquire`]: enum.Ordering.html#variant.Acquire - /// /// # Examples /// /// ``` @@ -808,11 +729,6 @@ impl AtomicBool { /// **Note:** This method is only available on platforms that support atomic /// operations on `u8`. /// - /// [`Ordering`]: enum.Ordering.html - /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed - /// [`Release`]: enum.Ordering.html#variant.Release - /// [`Acquire`]: enum.Ordering.html#variant.Acquire - /// /// # Examples /// /// ``` @@ -942,13 +858,6 @@ impl AtomicPtr { /// /// Panics if `order` is [`Release`] or [`AcqRel`]. /// - /// [`Ordering`]: enum.Ordering.html - /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed - /// [`Release`]: enum.Ordering.html#variant.Release - /// [`Acquire`]: enum.Ordering.html#variant.Acquire - /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel - /// [`SeqCst`]: enum.Ordering.html#variant.SeqCst - /// /// # Examples /// /// ``` @@ -975,13 +884,6 @@ impl AtomicPtr { /// /// Panics if `order` is [`Acquire`] or [`AcqRel`]. /// - /// [`Ordering`]: enum.Ordering.html - /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed - /// [`Release`]: enum.Ordering.html#variant.Release - /// [`Acquire`]: enum.Ordering.html#variant.Acquire - /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel - /// [`SeqCst`]: enum.Ordering.html#variant.SeqCst - /// /// # Examples /// /// ``` @@ -1013,11 +915,6 @@ impl AtomicPtr { /// **Note:** This method is only available on platforms that support atomic /// operations on pointers. /// - /// [`Ordering`]: enum.Ordering.html - /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed - /// [`Release`]: enum.Ordering.html#variant.Release - /// [`Acquire`]: enum.Ordering.html#variant.Acquire - /// /// # Examples /// /// ``` @@ -1052,12 +949,6 @@ impl AtomicPtr { /// **Note:** This method is only available on platforms that support atomic /// operations on pointers. /// - /// [`Ordering`]: enum.Ordering.html - /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed - /// [`Release`]: enum.Ordering.html#variant.Release - /// [`Acquire`]: enum.Ordering.html#variant.Acquire - /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel - /// /// # Examples /// /// ``` @@ -1096,12 +987,6 @@ impl AtomicPtr { /// **Note:** This method is only available on platforms that support atomic /// operations on pointers. /// - /// [`Ordering`]: enum.Ordering.html - /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed - /// [`Release`]: enum.Ordering.html#variant.Release - /// [`Acquire`]: enum.Ordering.html#variant.Acquire - /// [`SeqCst`]: enum.Ordering.html#variant.SeqCst - /// /// # Examples /// /// ``` @@ -1143,7 +1028,7 @@ impl AtomicPtr { /// Stores a value into the pointer if the current value is the same as the `current` value. /// - /// Unlike [`compare_exchange`], this function is allowed to spuriously fail even when the + /// Unlike [`AtomicPtr::compare_exchange`], this function is allowed to spuriously fail even when the /// comparison succeeds, which can result in more efficient code on some platforms. The /// return value is a result indicating whether the new value was written and containing the /// previous value. @@ -1159,13 +1044,6 @@ impl AtomicPtr { /// **Note:** This method is only available on platforms that support atomic /// operations on pointers. /// - /// [`compare_exchange`]: #method.compare_exchange - /// [`Ordering`]: enum.Ordering.html - /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed - /// [`Release`]: enum.Ordering.html#variant.Release - /// [`Acquire`]: enum.Ordering.html#variant.Acquire - /// [`SeqCst`]: enum.Ordering.html#variant.SeqCst - /// /// # Examples /// /// ``` @@ -1271,7 +1149,7 @@ macro_rules! atomic_int { #[doc = $int_ref] /// ). /// - /// [module-level documentation]: index.html + /// [module-level documentation]: crate::sync::atomic #[$stable] #[repr(C, align($align))] pub struct $atomic_type { @@ -1389,13 +1267,6 @@ Possible values are [`SeqCst`], [`Acquire`] and [`Relaxed`]. Panics if `order` is [`Release`] or [`AcqRel`]. -[`Ordering`]: enum.Ordering.html -[`Relaxed`]: enum.Ordering.html#variant.Relaxed -[`Release`]: enum.Ordering.html#variant.Release -[`Acquire`]: enum.Ordering.html#variant.Acquire -[`AcqRel`]: enum.Ordering.html#variant.AcqRel -[`SeqCst`]: enum.Ordering.html#variant.SeqCst - # Examples ``` @@ -1423,13 +1294,6 @@ assert_eq!(some_var.load(Ordering::Relaxed), 5); Panics if `order` is [`Acquire`] or [`AcqRel`]. -[`Ordering`]: enum.Ordering.html -[`Relaxed`]: enum.Ordering.html#variant.Relaxed -[`Release`]: enum.Ordering.html#variant.Release -[`Acquire`]: enum.Ordering.html#variant.Acquire -[`AcqRel`]: enum.Ordering.html#variant.AcqRel -[`SeqCst`]: enum.Ordering.html#variant.SeqCst - # Examples ``` @@ -1459,11 +1323,6 @@ using [`Release`] makes the load part [`Relaxed`]. **Note**: This method is only available on platforms that support atomic operations on [`", $s_int_type, "`](", $int_ref, "). -[`Ordering`]: enum.Ordering.html -[`Relaxed`]: enum.Ordering.html#variant.Relaxed -[`Release`]: enum.Ordering.html#variant.Release -[`Acquire`]: enum.Ordering.html#variant.Acquire - # Examples ``` @@ -1498,12 +1357,6 @@ happens, and using [`Release`] makes the load part [`Relaxed`]. **Note**: This method is only available on platforms that support atomic operations on [`", $s_int_type, "`](", $int_ref, "). -[`Ordering`]: enum.Ordering.html -[`Relaxed`]: enum.Ordering.html#variant.Relaxed -[`Release`]: enum.Ordering.html#variant.Release -[`Acquire`]: enum.Ordering.html#variant.Acquire -[`AcqRel`]: enum.Ordering.html#variant.AcqRel - # Examples ``` @@ -1553,12 +1406,6 @@ and must be equivalent to or weaker than the success ordering. **Note**: This method is only available on platforms that support atomic operations on [`", $s_int_type, "`](", $int_ref, "). -[`Ordering`]: enum.Ordering.html -[`Relaxed`]: enum.Ordering.html#variant.Relaxed -[`Release`]: enum.Ordering.html#variant.Release -[`Acquire`]: enum.Ordering.html#variant.Acquire -[`SeqCst`]: enum.Ordering.html#variant.SeqCst - # Examples ``` @@ -1595,7 +1442,7 @@ assert_eq!(some_var.load(Ordering::Relaxed), 10); concat!("Stores a value into the atomic integer if the current value is the same as the `current` value. -Unlike [`compare_exchange`], this function is allowed to spuriously fail even +Unlike [`", stringify!($atomic_type), "::compare_exchange`], this function is allowed to spuriously fail even when the comparison succeeds, which can result in more efficient code on some platforms. The return value is a result indicating whether the new value was written and containing the previous value. @@ -1608,13 +1455,6 @@ of this operation [`Relaxed`], and using [`Release`] makes the successful load [`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`] and must be equivalent to or weaker than the success ordering. -[`compare_exchange`]: #method.compare_exchange -[`Ordering`]: enum.Ordering.html -[`Relaxed`]: enum.Ordering.html#variant.Relaxed -[`Release`]: enum.Ordering.html#variant.Release -[`Acquire`]: enum.Ordering.html#variant.Acquire -[`SeqCst`]: enum.Ordering.html#variant.SeqCst - **Note**: This method is only available on platforms that support atomic operations on [`", $s_int_type, "`](", $int_ref, "). @@ -1662,11 +1502,6 @@ using [`Release`] makes the load part [`Relaxed`]. **Note**: This method is only available on platforms that support atomic operations on [`", $s_int_type, "`](", $int_ref, "). -[`Ordering`]: enum.Ordering.html -[`Relaxed`]: enum.Ordering.html#variant.Relaxed -[`Release`]: enum.Ordering.html#variant.Release -[`Acquire`]: enum.Ordering.html#variant.Acquire - # Examples ``` @@ -1698,11 +1533,6 @@ using [`Release`] makes the load part [`Relaxed`]. **Note**: This method is only available on platforms that support atomic operations on [`", $s_int_type, "`](", $int_ref, "). -[`Ordering`]: enum.Ordering.html -[`Relaxed`]: enum.Ordering.html#variant.Relaxed -[`Release`]: enum.Ordering.html#variant.Release -[`Acquire`]: enum.Ordering.html#variant.Acquire - # Examples ``` @@ -1737,11 +1567,6 @@ using [`Release`] makes the load part [`Relaxed`]. **Note**: This method is only available on platforms that support atomic operations on [`", $s_int_type, "`](", $int_ref, "). -[`Ordering`]: enum.Ordering.html -[`Relaxed`]: enum.Ordering.html#variant.Relaxed -[`Release`]: enum.Ordering.html#variant.Release -[`Acquire`]: enum.Ordering.html#variant.Acquire - # Examples ``` @@ -1776,11 +1601,6 @@ using [`Release`] makes the load part [`Relaxed`]. **Note**: This method is only available on platforms that support atomic operations on [`", $s_int_type, "`](", $int_ref, "). -[`Ordering`]: enum.Ordering.html -[`Relaxed`]: enum.Ordering.html#variant.Relaxed -[`Release`]: enum.Ordering.html#variant.Release -[`Acquire`]: enum.Ordering.html#variant.Acquire - # Examples ``` @@ -1816,11 +1636,6 @@ using [`Release`] makes the load part [`Relaxed`]. **Note**: This method is only available on platforms that support atomic operations on [`", $s_int_type, "`](", $int_ref, "). -[`Ordering`]: enum.Ordering.html -[`Relaxed`]: enum.Ordering.html#variant.Relaxed -[`Release`]: enum.Ordering.html#variant.Release -[`Acquire`]: enum.Ordering.html#variant.Acquire - # Examples ``` @@ -1855,11 +1670,6 @@ using [`Release`] makes the load part [`Relaxed`]. **Note**: This method is only available on platforms that support atomic operations on [`", $s_int_type, "`](", $int_ref, "). -[`Ordering`]: enum.Ordering.html -[`Relaxed`]: enum.Ordering.html#variant.Relaxed -[`Release`]: enum.Ordering.html#variant.Release -[`Acquire`]: enum.Ordering.html#variant.Acquire - # Examples ``` @@ -1890,7 +1700,7 @@ only once to the stored value. `fetch_update` takes two [`Ordering`] arguments to describe the memory ordering of this operation. The first describes the required ordering for when the operation finally succeeds while the second describes the required ordering for loads. These correspond to the success and failure orderings of -[`compare_exchange`] respectively. +[`", stringify!($atomic_type), "::compare_exchange`] respectively. Using [`Acquire`] as success ordering makes the store part of this operation [`Relaxed`], and using [`Release`] makes the final successful load @@ -1901,12 +1711,6 @@ and must be equivalent to or weaker than the success ordering. operations on [`", $s_int_type, "`](", $int_ref, "). [`bool`]: ../../../std/primitive.bool.html -[`compare_exchange`]: #method.compare_exchange -[`Ordering`]: enum.Ordering.html -[`Relaxed`]: enum.Ordering.html#variant.Relaxed -[`Release`]: enum.Ordering.html#variant.Release -[`Acquire`]: enum.Ordering.html#variant.Acquire -[`SeqCst`]: enum.Ordering.html#variant.SeqCst # Examples @@ -1954,11 +1758,6 @@ using [`Release`] makes the load part [`Relaxed`]. **Note**: This method is only available on platforms that support atomic operations on [`", $s_int_type, "`](", $int_ref, "). -[`Ordering`]: enum.Ordering.html -[`Relaxed`]: enum.Ordering.html#variant.Relaxed -[`Release`]: enum.Ordering.html#variant.Release -[`Acquire`]: enum.Ordering.html#variant.Acquire - # Examples ``` @@ -2004,11 +1803,6 @@ using [`Release`] makes the load part [`Relaxed`]. **Note**: This method is only available on platforms that support atomic operations on [`", $s_int_type, "`](", $int_ref, "). -[`Ordering`]: enum.Ordering.html -[`Relaxed`]: enum.Ordering.html#variant.Relaxed -[`Release`]: enum.Ordering.html#variant.Release -[`Acquire`]: enum.Ordering.html#variant.Acquire - # Examples ``` @@ -2660,13 +2454,6 @@ unsafe fn atomic_umin(dst: *mut T, val: T, order: Ordering) -> T { /// } /// } /// ``` -/// -/// [`Ordering`]: enum.Ordering.html -/// [`Acquire`]: enum.Ordering.html#variant.Acquire -/// [`SeqCst`]: enum.Ordering.html#variant.SeqCst -/// [`Release`]: enum.Ordering.html#variant.Release -/// [`AcqRel`]: enum.Ordering.html#variant.AcqRel -/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn fence(order: Ordering) { @@ -2747,13 +2534,6 @@ pub fn fence(order: Ordering) { /// } /// ``` /// -/// [`fence`]: fn.fence.html -/// [`Ordering`]: enum.Ordering.html -/// [`Acquire`]: enum.Ordering.html#variant.Acquire -/// [`SeqCst`]: enum.Ordering.html#variant.SeqCst -/// [`Release`]: enum.Ordering.html#variant.Release -/// [`AcqRel`]: enum.Ordering.html#variant.AcqRel -/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed /// [memory barriers]: https://www.kernel.org/doc/Documentation/memory-barriers.txt #[inline] #[stable(feature = "compiler_fences", since = "1.21.0")] From c7571e60402adac4bf1b1ffa67f963a4a3f7d8b9 Mon Sep 17 00:00:00 2001 From: Denis Vasilik Date: Fri, 28 Aug 2020 17:30:05 +0200 Subject: [PATCH 24/29] Use intra-doc links for bool --- library/core/src/sync/atomic.rs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index 05c1120f9990e..1aec7e1b5f871 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -144,8 +144,6 @@ pub fn spin_loop_hint() { /// /// **Note**: This type is only available on platforms that support atomic /// loads and stores of `u8`. -/// -/// [`bool`]: ../../../std/primitive.bool.html #[cfg(target_has_atomic_load_store = "8")] #[stable(feature = "rust1", since = "1.0.0")] #[repr(C, align(1))] @@ -312,8 +310,6 @@ impl AtomicBool { /// This is safe because the mutable reference guarantees that no other threads are /// concurrently accessing the atomic data. /// - /// [`bool`]: ../../../std/primitive.bool.html - /// /// # Examples /// /// ``` @@ -486,8 +482,6 @@ impl AtomicBool { /// **Note:** This method is only available on platforms that support atomic /// operations on `u8`. /// - /// [`bool`]: ../../../std/primitive.bool.html - /// /// # Examples /// /// ``` @@ -545,8 +539,6 @@ impl AtomicBool { /// **Note:** This method is only available on platforms that support atomic /// operations on `u8`. /// - /// [`bool`]: ../../../std/primitive.bool.html - /// /// # Examples /// /// ``` @@ -766,8 +758,6 @@ impl AtomicBool { /// use of the returned raw pointer requires an `unsafe` block and still has to uphold the same /// restriction: operations on it must be atomic. /// - /// [`bool`]: ../../../std/primitive.bool.html - /// /// # Examples /// /// ```ignore (extern-declaration) @@ -1710,8 +1700,6 @@ and must be equivalent to or weaker than the success ordering. **Note**: This method is only available on platforms that support atomic operations on [`", $s_int_type, "`](", $int_ref, "). -[`bool`]: ../../../std/primitive.bool.html - # Examples ```rust From 9e2228d2d07c77b8323a3f3e1bf82badddd7bfec Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Fri, 28 Aug 2020 17:40:56 +0200 Subject: [PATCH 25/29] Back to opcode for 32 bit ARM __fastfail --- library/panic_abort/src/lib.rs | 2 +- library/std/src/sys/windows/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/panic_abort/src/lib.rs b/library/panic_abort/src/lib.rs index a09234e09ff9b..a37bfa451732e 100644 --- a/library/panic_abort/src/lib.rs +++ b/library/panic_abort/src/lib.rs @@ -64,7 +64,7 @@ pub unsafe extern "C" fn __rust_start_panic(_payload: usize) -> u32 { if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { asm!("int $$0x29", in("ecx") FAST_FAIL_FATAL_APP_EXIT); } else if #[cfg(target_arch = "arm")] { - asm!("brk 0xDEFB", in("r0") FAST_FAIL_FATAL_APP_EXIT); + asm!(".inst 0xDEFB", in("r0") FAST_FAIL_FATAL_APP_EXIT); } else if #[cfg(target_arch = "aarch64")] { asm!("brk 0xF003", in("x0") FAST_FAIL_FATAL_APP_EXIT); } else { diff --git a/library/std/src/sys/windows/mod.rs b/library/std/src/sys/windows/mod.rs index 03ddc3e646180..d3b9a626a9e2e 100644 --- a/library/std/src/sys/windows/mod.rs +++ b/library/std/src/sys/windows/mod.rs @@ -313,7 +313,7 @@ pub fn abort_internal() -> ! { asm!("int $$0x29", in("ecx") FAST_FAIL_FATAL_APP_EXIT); crate::intrinsics::unreachable(); } else if #[cfg(target_arch = "arm")] { - asm!("brk 0xDEFB", in("r0") FAST_FAIL_FATAL_APP_EXIT); + asm!(".inst 0xDEFB", in("r0") FAST_FAIL_FATAL_APP_EXIT); crate::intrinsics::unreachable(); } else if #[cfg(target_arch = "aarch64")] { asm!("brk 0xF003", in("x0") FAST_FAIL_FATAL_APP_EXIT); From 6621895365ea70bcfaf09bb05e35d64c2f52e4c6 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 29 Aug 2020 11:38:15 +0200 Subject: [PATCH 26/29] Move retokenize hack to save_analysis --- Cargo.lock | 2 +- src/librustc_parse/lexer/mod.rs | 30 +------- src/librustc_save_analysis/Cargo.toml | 2 +- src/librustc_save_analysis/dump_visitor.rs | 6 +- src/librustc_save_analysis/span_utils.rs | 84 ++++++++-------------- 5 files changed, 36 insertions(+), 88 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 985dbb046d0c6..b86caf8b6477c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3918,8 +3918,8 @@ dependencies = [ "rustc_data_structures", "rustc_hir", "rustc_hir_pretty", + "rustc_lexer", "rustc_middle", - "rustc_parse", "rustc_session", "rustc_span", "serde_json", diff --git a/src/librustc_parse/lexer/mod.rs b/src/librustc_parse/lexer/mod.rs index 675cfa41f1048..fdcabe416731f 100644 --- a/src/librustc_parse/lexer/mod.rs +++ b/src/librustc_parse/lexer/mod.rs @@ -46,19 +46,10 @@ impl<'a> StringReader<'a> { source_file: Lrc, override_span: Option, ) -> Self { - // Make sure external source is loaded first, before accessing it. - // While this can't show up during normal parsing, `retokenize` may - // be called with a source file from an external crate. - sess.source_map().ensure_source_file_source_present(Lrc::clone(&source_file)); - - let src = if let Some(src) = &source_file.src { - Lrc::clone(&src) - } else if let Some(src) = source_file.external_src.borrow().get_source() { - Lrc::clone(&src) - } else { + let src = source_file.src.clone().unwrap_or_else(|| { sess.span_diagnostic .bug(&format!("cannot lex `source_file` without source: {}", source_file.name)); - }; + }); StringReader { sess, @@ -70,23 +61,6 @@ impl<'a> StringReader<'a> { } } - pub fn retokenize(sess: &'a ParseSess, mut span: Span) -> Self { - let begin = sess.source_map().lookup_byte_offset(span.lo()); - let end = sess.source_map().lookup_byte_offset(span.hi()); - - // Make the range zero-length if the span is invalid. - if begin.sf.start_pos != end.sf.start_pos { - span = span.shrink_to_lo(); - } - - let mut sr = StringReader::new(sess, begin.sf, None); - - // Seek the lexer to the right byte range. - sr.end_src_index = sr.src_index(span.hi()); - - sr - } - fn mk_sp(&self, lo: BytePos, hi: BytePos) -> Span { self.override_span.unwrap_or_else(|| Span::with_root_ctxt(lo, hi)) } diff --git a/src/librustc_save_analysis/Cargo.toml b/src/librustc_save_analysis/Cargo.toml index 3c2edc1fa5571..979a8da2a9f68 100644 --- a/src/librustc_save_analysis/Cargo.toml +++ b/src/librustc_save_analysis/Cargo.toml @@ -16,7 +16,7 @@ rustc_ast_pretty = { path = "../librustc_ast_pretty" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_hir = { path = "../librustc_hir" } rustc_hir_pretty = { path = "../librustc_hir_pretty" } -rustc_parse = { path = "../librustc_parse" } +rustc_lexer = { path = "../librustc_lexer" } serde_json = "1" rustc_session = { path = "../librustc_session" } rustc_span = { path = "../librustc_span" } diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 77aecefe5a2be..ce484858cbb66 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -14,7 +14,7 @@ //! recording the output. use rustc_ast as ast; -use rustc_ast::{token, walk_list}; +use rustc_ast::walk_list; use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; use rustc_hir::def::{DefKind as HirDefKind, Res}; @@ -1207,9 +1207,7 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> { // Otherwise it's a span with wrong macro expansion info, which // we don't want to track anyway, since it's probably macro-internal `use` - if let Some(sub_span) = - self.span.sub_span_of_token(item.span, token::BinOp(token::Star)) - { + if let Some(sub_span) = self.span.sub_span_of_star(item.span) { if !self.span.filter_generated(item.span) { let access = access_from!(self.save_ctxt, item, item.hir_id); let span = self.span_from_span(sub_span); diff --git a/src/librustc_save_analysis/span_utils.rs b/src/librustc_save_analysis/span_utils.rs index d5f992b0de05d..edcd492577374 100644 --- a/src/librustc_save_analysis/span_utils.rs +++ b/src/librustc_save_analysis/span_utils.rs @@ -1,6 +1,6 @@ use crate::generated_code; -use rustc_ast::token::{self, TokenKind}; -use rustc_parse::lexer::{self, StringReader}; +use rustc_data_structures::sync::Lrc; +use rustc_lexer::{tokenize, TokenKind}; use rustc_session::Session; use rustc_span::*; @@ -43,61 +43,37 @@ impl<'a> SpanUtils<'a> { } } - pub fn retokenise_span(&self, span: Span) -> StringReader<'a> { - lexer::StringReader::retokenize(&self.sess.parse_sess, span) - } - - pub fn sub_span_of_token(&self, span: Span, tok: TokenKind) -> Option { - let mut toks = self.retokenise_span(span); - loop { - let next = toks.next_token(); - if next == token::Eof { - return None; - } - if next == tok { - return Some(next.span); - } + /// Finds the span of `*` token withing the larger `span`. + pub fn sub_span_of_star(&self, mut span: Span) -> Option { + let begin = self.sess.source_map().lookup_byte_offset(span.lo()); + let end = self.sess.source_map().lookup_byte_offset(span.hi()); + // Make the range zero-length if the span is invalid. + if begin.sf.start_pos != end.sf.start_pos { + span = span.shrink_to_lo(); } - } - // // Return the name for a macro definition (identifier after first `!`) - // pub fn span_for_macro_def_name(&self, span: Span) -> Option { - // let mut toks = self.retokenise_span(span); - // loop { - // let ts = toks.real_token(); - // if ts == token::Eof { - // return None; - // } - // if ts == token::Not { - // let ts = toks.real_token(); - // if ts.kind.is_ident() { - // return Some(ts.sp); - // } else { - // return None; - // } - // } - // } - // } + let sf = Lrc::clone(&begin.sf); - // // Return the name for a macro use (identifier before first `!`). - // pub fn span_for_macro_use_name(&self, span:Span) -> Option { - // let mut toks = self.retokenise_span(span); - // let mut prev = toks.real_token(); - // loop { - // if prev == token::Eof { - // return None; - // } - // let ts = toks.real_token(); - // if ts == token::Not { - // if prev.kind.is_ident() { - // return Some(prev.sp); - // } else { - // return None; - // } - // } - // prev = ts; - // } - // } + self.sess.source_map().ensure_source_file_source_present(Lrc::clone(&sf)); + let src = + sf.src.clone().or_else(|| sf.external_src.borrow().get_source().map(Lrc::clone))?; + let to_index = |pos: BytePos| -> usize { (pos - sf.start_pos).0 as usize }; + let text = &src[to_index(span.lo())..to_index(span.hi())]; + let start_pos = { + let mut pos = 0; + tokenize(text) + .map(|token| { + let start = pos; + pos += token.len; + (start, token) + }) + .find(|(_pos, token)| token.kind == TokenKind::Star)? + .0 + }; + let lo = span.lo() + BytePos(start_pos as u32); + let hi = lo + BytePos(1); + Some(span.with_lo(lo).with_hi(hi)) + } /// Return true if the span is generated code, and /// it is not a subspan of the root callsite. From d931e974029a3475bd6712ca8d3bc9cb9dfe558f Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Sat, 29 Aug 2020 12:30:49 +0200 Subject: [PATCH 27/29] Explicitly look for 'thumb-mode' before using __fastfail on 'arm' --- library/panic_abort/src/lib.rs | 2 +- library/std/src/sys/windows/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/panic_abort/src/lib.rs b/library/panic_abort/src/lib.rs index a37bfa451732e..31058a2b0969b 100644 --- a/library/panic_abort/src/lib.rs +++ b/library/panic_abort/src/lib.rs @@ -63,7 +63,7 @@ pub unsafe extern "C" fn __rust_start_panic(_payload: usize) -> u32 { cfg_if::cfg_if! { if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { asm!("int $$0x29", in("ecx") FAST_FAIL_FATAL_APP_EXIT); - } else if #[cfg(target_arch = "arm")] { + } else if #[cfg(all(target_arch = "arm", target_feature = "thumb-mode"))] { asm!(".inst 0xDEFB", in("r0") FAST_FAIL_FATAL_APP_EXIT); } else if #[cfg(target_arch = "aarch64")] { asm!("brk 0xF003", in("x0") FAST_FAIL_FATAL_APP_EXIT); diff --git a/library/std/src/sys/windows/mod.rs b/library/std/src/sys/windows/mod.rs index d3b9a626a9e2e..8178e6806b9b3 100644 --- a/library/std/src/sys/windows/mod.rs +++ b/library/std/src/sys/windows/mod.rs @@ -312,7 +312,7 @@ pub fn abort_internal() -> ! { if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { asm!("int $$0x29", in("ecx") FAST_FAIL_FATAL_APP_EXIT); crate::intrinsics::unreachable(); - } else if #[cfg(target_arch = "arm")] { + } else if #[cfg(all(target_arch = "arm", target_feature = "thumb-mode"))] { asm!(".inst 0xDEFB", in("r0") FAST_FAIL_FATAL_APP_EXIT); crate::intrinsics::unreachable(); } else if #[cfg(target_arch = "aarch64")] { From 3a4ef0f57d70866bbbe5e9dd8f0710b8ee942cfa Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 29 Aug 2020 12:38:50 +0200 Subject: [PATCH 28/29] Use an id instead of a function --- src/librustdoc/html/static/main.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index baf32ab9cb2b6..53e9115800fce 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -92,6 +92,7 @@ function defocusSearchBar() { var disableShortcuts = getCurrentValue("rustdoc-disable-shortcuts") === "true"; var search_input = getSearchInput(); var searchTimeout = null; + var toggleAllDocsId = "toggle-all-docs"; // On the search screen, so you remain on the last tab you opened. // @@ -2113,12 +2114,8 @@ function defocusSearchBar() { } } - function getToggleAllDocsElement() { - return document.getElementById("toggle-all-docs"); - } - function toggleAllDocs(pageId, fromAutoCollapse) { - var innerToggle = getToggleAllDocsElement(); + var innerToggle = document.getElementById(toggleAllDocsId); if (!innerToggle) { return; } @@ -2360,7 +2357,7 @@ function defocusSearchBar() { } (function() { - var toggles = document.getElementById("toggle-all-docs"); + var toggles = document.getElementById(toggleAllDocsId); if (toggles) { toggles.onclick = toggleAllDocs; } From e6a2c8292b146ff4c6199aa6a60d739105bb9a54 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 27 Aug 2020 13:12:40 +0200 Subject: [PATCH 29/29] Allow --bess ing expect-tests in tools See #75773 and #75775 --- src/bootstrap/builder.rs | 5 +++++ src/bootstrap/test.rs | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 6446fa7550d53..54eb2e99b8ff8 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -1079,6 +1079,11 @@ impl<'a> Builder<'a> { }, ); + if self.config.cmd.bless() { + // Bless `expect!` tests. + cargo.env("UPDATE_EXPECT", "1"); + } + if !mode.is_tool() { cargo.env("RUSTC_FORCE_UNSTABLE", "1"); } diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index afa72b5d58c14..ac833a55d4c53 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -1754,11 +1754,6 @@ impl Step for Crate { cargo.arg("--quiet"); } - if builder.config.cmd.bless() { - // Bless `expect!` tests. - cargo.env("UPDATE_EXPECT", "1"); - } - if target.contains("emscripten") { cargo.env( format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)),