Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1d6754d

Browse files
committedMar 16, 2021
Auto merge of #83199 - JohnTitor:rollup-zrfk94a, r=JohnTitor
Rollup of 10 pull requests Successful merges: - #81822 (Added `try_exists()` method to `std::path::Path`) - #83072 (Update `Vec` docs) - #83077 (rustdoc: reduce GC work during search) - #83091 (Constify `copy` related functions) - #83156 (Fall-back to sans-serif if Arial is not available) - #83157 (No background for code in portability snippets) - #83160 (Deprecate RustcEncodable and RustcDecodable.) - #83162 (Specify *.woff2 files as binary) - #83172 (More informative diagnotic from `x.py test` attempt atop beta checkout) - #83196 (Use delay_span_bug instead of panic in layout_scalar_valid_range) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents f24ce9b + ec07427 commit 1d6754d

File tree

21 files changed

+196
-110
lines changed

21 files changed

+196
-110
lines changed
 

‎.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*.mir linguist-language=Rust
99
src/etc/installer/gfx/* binary
1010
*.woff binary
11+
*.woff2 binary
1112
src/vendor/** -text
1213
Cargo.lock linguist-generated=false
1314

‎compiler/rustc_middle/src/ty/context.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -1091,13 +1091,16 @@ impl<'tcx> TyCtxt<'tcx> {
10911091
None => return Bound::Unbounded,
10921092
};
10931093
debug!("layout_scalar_valid_range: attr={:?}", attr);
1094-
for meta in attr.meta_item_list().expect("rustc_layout_scalar_valid_range takes args") {
1095-
match meta.literal().expect("attribute takes lit").kind {
1096-
ast::LitKind::Int(a, _) => return Bound::Included(a),
1097-
_ => span_bug!(attr.span, "rustc_layout_scalar_valid_range expects int arg"),
1098-
}
1094+
if let Some(
1095+
&[ast::NestedMetaItem::Literal(ast::Lit { kind: ast::LitKind::Int(a, _), .. })],
1096+
) = attr.meta_item_list().as_deref()
1097+
{
1098+
Bound::Included(a)
1099+
} else {
1100+
self.sess
1101+
.delay_span_bug(attr.span, "invalid rustc_layout_scalar_valid_range attribute");
1102+
Bound::Unbounded
10991103
}
1100-
span_bug!(attr.span, "no arguments to `rustc_layout_scalar_valid_range` attribute");
11011104
};
11021105
(
11031106
get(sym::rustc_layout_scalar_valid_range_start),

‎library/alloc/src/vec/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ use self::spec_extend::SpecExtend;
126126

127127
mod spec_extend;
128128

129-
/// A contiguous growable array type, written `Vec<T>` but pronounced 'vector'.
129+
/// A contiguous growable array type, written as `Vec<T>` and pronounced 'vector'.
130130
///
131131
/// # Examples
132132
///
@@ -215,7 +215,7 @@ mod spec_extend;
215215
///
216216
/// # Slicing
217217
///
218-
/// A `Vec` can be mutable. Slices, on the other hand, are read-only objects.
218+
/// A `Vec` can be mutable. On the other hand, slices are read-only objects.
219219
/// To get a [slice][prim@slice], use [`&`]. Example:
220220
///
221221
/// ```
@@ -352,7 +352,7 @@ mod spec_extend;
352352
/// not break, however: using `unsafe` code to write to the excess capacity,
353353
/// and then increasing the length to match, is always valid.
354354
///
355-
/// `Vec` does not currently guarantee the order in which elements are dropped.
355+
/// Currently, `Vec` does not guarantee the order in which elements are dropped.
356356
/// The order has changed in the past and may change again.
357357
///
358358
/// [`get`]: ../../std/vec/struct.Vec.html#method.get

‎library/core/src/intrinsics.rs

-12
Original file line numberDiff line numberDiff line change
@@ -1902,18 +1902,6 @@ pub(crate) fn is_aligned_and_not_null<T>(ptr: *const T) -> bool {
19021902
!ptr.is_null() && ptr as usize % mem::align_of::<T>() == 0
19031903
}
19041904

1905-
/// Checks whether the regions of memory starting at `src` and `dst` of size
1906-
/// `count * size_of::<T>()` do *not* overlap.
1907-
pub(crate) fn is_nonoverlapping<T>(src: *const T, dst: *const T, count: usize) -> bool {
1908-
let src_usize = src as usize;
1909-
let dst_usize = dst as usize;
1910-
let size = mem::size_of::<T>().checked_mul(count).unwrap();
1911-
let diff = if src_usize > dst_usize { src_usize - dst_usize } else { dst_usize - src_usize };
1912-
// If the absolute distance between the ptrs is at least as big as the size of the buffer,
1913-
// they do not overlap.
1914-
diff >= size
1915-
}
1916-
19171905
/// Sets `count * size_of::<T>()` bytes of memory starting at `dst` to
19181906
/// `val`.
19191907
///

‎library/core/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
#![feature(const_slice_from_raw_parts)]
9999
#![feature(const_slice_ptr_len)]
100100
#![feature(const_size_of_val)]
101+
#![feature(const_swap)]
101102
#![feature(const_align_of_val)]
102103
#![feature(const_type_id)]
103104
#![feature(const_type_name)]

‎library/core/src/macros/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1468,6 +1468,10 @@ pub(crate) mod builtin {
14681468
#[rustc_builtin_macro]
14691469
#[stable(feature = "rust1", since = "1.0.0")]
14701470
#[allow_internal_unstable(core_intrinsics, libstd_sys_internals)]
1471+
#[rustc_deprecated(
1472+
since = "1.52.0",
1473+
reason = "rustc-serialize is deprecated and no longer supported"
1474+
)]
14711475
pub macro RustcDecodable($item:item) {
14721476
/* compiler built-in */
14731477
}
@@ -1476,6 +1480,10 @@ pub(crate) mod builtin {
14761480
#[rustc_builtin_macro]
14771481
#[stable(feature = "rust1", since = "1.0.0")]
14781482
#[allow_internal_unstable(core_intrinsics)]
1483+
#[rustc_deprecated(
1484+
since = "1.52.0",
1485+
reason = "rustc-serialize is deprecated and no longer supported"
1486+
)]
14791487
pub macro RustcEncodable($item:item) {
14801488
/* compiler built-in */
14811489
}

‎library/core/src/mem/mod.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,8 @@ pub unsafe fn uninitialized<T>() -> T {
682682
/// ```
683683
#[inline]
684684
#[stable(feature = "rust1", since = "1.0.0")]
685-
pub fn swap<T>(x: &mut T, y: &mut T) {
685+
#[rustc_const_unstable(feature = "const_swap", issue = "83163")]
686+
pub const fn swap<T>(x: &mut T, y: &mut T) {
686687
// SAFETY: the raw pointers have been created from safe mutable references satisfying all the
687688
// constraints on `ptr::swap_nonoverlapping_one`
688689
unsafe {
@@ -812,7 +813,8 @@ pub fn take<T: Default>(dest: &mut T) -> T {
812813
#[inline]
813814
#[stable(feature = "rust1", since = "1.0.0")]
814815
#[must_use = "if you don't need the old value, you can just assign the new value directly"]
815-
pub fn replace<T>(dest: &mut T, src: T) -> T {
816+
#[rustc_const_unstable(feature = "const_replace", issue = "83164")]
817+
pub const fn replace<T>(dest: &mut T, src: T) -> T {
816818
// SAFETY: We read from `dest` but directly write `src` into it afterwards,
817819
// such that the old value is not duplicated. Nothing is dropped and
818820
// nothing here can panic.
@@ -931,7 +933,8 @@ pub fn drop<T>(_x: T) {}
931933
/// ```
932934
#[inline]
933935
#[stable(feature = "rust1", since = "1.0.0")]
934-
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
936+
#[rustc_const_unstable(feature = "const_transmute_copy", issue = "83165")]
937+
pub const unsafe fn transmute_copy<T, U>(src: &T) -> U {
935938
// If U has a higher alignment requirement, src may not be suitably aligned.
936939
if align_of::<U>() > align_of::<T>() {
937940
// SAFETY: `src` is a reference which is guaranteed to be valid for reads.

‎library/core/src/prelude/v1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub use crate::{
6161
};
6262

6363
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
64-
#[allow(deprecated)]
64+
#[allow(deprecated, deprecated_in_future)]
6565
#[doc(no_inline)]
6666
pub use crate::macros::builtin::{
6767
bench, global_allocator, test, test_case, RustcDecodable, RustcEncodable,

‎library/core/src/ptr/const_ptr.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -819,9 +819,10 @@ impl<T: ?Sized> *const T {
819819
/// See [`ptr::copy`] for safety concerns and examples.
820820
///
821821
/// [`ptr::copy`]: crate::ptr::copy()
822+
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
822823
#[stable(feature = "pointer_methods", since = "1.26.0")]
823824
#[inline]
824-
pub unsafe fn copy_to(self, dest: *mut T, count: usize)
825+
pub const unsafe fn copy_to(self, dest: *mut T, count: usize)
825826
where
826827
T: Sized,
827828
{
@@ -837,9 +838,10 @@ impl<T: ?Sized> *const T {
837838
/// See [`ptr::copy_nonoverlapping`] for safety concerns and examples.
838839
///
839840
/// [`ptr::copy_nonoverlapping`]: crate::ptr::copy_nonoverlapping()
841+
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
840842
#[stable(feature = "pointer_methods", since = "1.26.0")]
841843
#[inline]
842-
pub unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize)
844+
pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize)
843845
where
844846
T: Sized,
845847
{

‎library/core/src/ptr/mod.rs

+11-15
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
use crate::cmp::Ordering;
6868
use crate::fmt;
6969
use crate::hash;
70-
use crate::intrinsics::{self, abort, is_aligned_and_not_null, is_nonoverlapping};
70+
use crate::intrinsics::{self, abort, is_aligned_and_not_null};
7171
use crate::mem::{self, MaybeUninit};
7272

7373
#[stable(feature = "rust1", since = "1.0.0")]
@@ -394,7 +394,8 @@ pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T] {
394394
/// ```
395395
#[inline]
396396
#[stable(feature = "rust1", since = "1.0.0")]
397-
pub unsafe fn swap<T>(x: *mut T, y: *mut T) {
397+
#[rustc_const_unstable(feature = "const_swap", issue = "83163")]
398+
pub const unsafe fn swap<T>(x: *mut T, y: *mut T) {
398399
// Give ourselves some scratch space to work with.
399400
// We do not have to worry about drops: `MaybeUninit` does nothing when dropped.
400401
let mut tmp = MaybeUninit::<T>::uninit();
@@ -451,16 +452,8 @@ pub unsafe fn swap<T>(x: *mut T, y: *mut T) {
451452
/// ```
452453
#[inline]
453454
#[stable(feature = "swap_nonoverlapping", since = "1.27.0")]
454-
pub unsafe fn swap_nonoverlapping<T>(x: *mut T, y: *mut T, count: usize) {
455-
if cfg!(debug_assertions)
456-
&& !(is_aligned_and_not_null(x)
457-
&& is_aligned_and_not_null(y)
458-
&& is_nonoverlapping(x, y, count))
459-
{
460-
// Not panicking to keep codegen impact smaller.
461-
abort();
462-
}
463-
455+
#[rustc_const_unstable(feature = "const_swap", issue = "83163")]
456+
pub const unsafe fn swap_nonoverlapping<T>(x: *mut T, y: *mut T, count: usize) {
464457
let x = x as *mut u8;
465458
let y = y as *mut u8;
466459
let len = mem::size_of::<T>() * count;
@@ -470,7 +463,8 @@ pub unsafe fn swap_nonoverlapping<T>(x: *mut T, y: *mut T, count: usize) {
470463
}
471464

472465
#[inline]
473-
pub(crate) unsafe fn swap_nonoverlapping_one<T>(x: *mut T, y: *mut T) {
466+
#[rustc_const_unstable(feature = "const_swap", issue = "83163")]
467+
pub(crate) const unsafe fn swap_nonoverlapping_one<T>(x: *mut T, y: *mut T) {
474468
// For types smaller than the block optimization below,
475469
// just swap directly to avoid pessimizing codegen.
476470
if mem::size_of::<T>() < 32 {
@@ -488,7 +482,8 @@ pub(crate) unsafe fn swap_nonoverlapping_one<T>(x: *mut T, y: *mut T) {
488482
}
489483

490484
#[inline]
491-
unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) {
485+
#[rustc_const_unstable(feature = "const_swap", issue = "83163")]
486+
const unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) {
492487
// The approach here is to utilize simd to swap x & y efficiently. Testing reveals
493488
// that swapping either 32 bytes or 64 bytes at a time is most efficient for Intel
494489
// Haswell E processors. LLVM is more able to optimize if we give a struct a
@@ -589,7 +584,8 @@ unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) {
589584
/// ```
590585
#[inline]
591586
#[stable(feature = "rust1", since = "1.0.0")]
592-
pub unsafe fn replace<T>(dst: *mut T, mut src: T) -> T {
587+
#[rustc_const_unstable(feature = "const_replace", issue = "83164")]
588+
pub const unsafe fn replace<T>(dst: *mut T, mut src: T) -> T {
593589
// SAFETY: the caller must guarantee that `dst` is valid to be
594590
// cast to a mutable reference (valid for writes, aligned, initialized),
595591
// and cannot overlap `src` since `dst` must point to a distinct

‎library/core/src/ptr/mut_ptr.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -926,9 +926,10 @@ impl<T: ?Sized> *mut T {
926926
/// See [`ptr::copy`] for safety concerns and examples.
927927
///
928928
/// [`ptr::copy`]: crate::ptr::copy()
929+
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
929930
#[stable(feature = "pointer_methods", since = "1.26.0")]
930931
#[inline]
931-
pub unsafe fn copy_to(self, dest: *mut T, count: usize)
932+
pub const unsafe fn copy_to(self, dest: *mut T, count: usize)
932933
where
933934
T: Sized,
934935
{
@@ -944,9 +945,10 @@ impl<T: ?Sized> *mut T {
944945
/// See [`ptr::copy_nonoverlapping`] for safety concerns and examples.
945946
///
946947
/// [`ptr::copy_nonoverlapping`]: crate::ptr::copy_nonoverlapping()
948+
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
947949
#[stable(feature = "pointer_methods", since = "1.26.0")]
948950
#[inline]
949-
pub unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize)
951+
pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize)
950952
where
951953
T: Sized,
952954
{
@@ -962,9 +964,10 @@ impl<T: ?Sized> *mut T {
962964
/// See [`ptr::copy`] for safety concerns and examples.
963965
///
964966
/// [`ptr::copy`]: crate::ptr::copy()
967+
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
965968
#[stable(feature = "pointer_methods", since = "1.26.0")]
966969
#[inline]
967-
pub unsafe fn copy_from(self, src: *const T, count: usize)
970+
pub const unsafe fn copy_from(self, src: *const T, count: usize)
968971
where
969972
T: Sized,
970973
{
@@ -980,9 +983,10 @@ impl<T: ?Sized> *mut T {
980983
/// See [`ptr::copy_nonoverlapping`] for safety concerns and examples.
981984
///
982985
/// [`ptr::copy_nonoverlapping`]: crate::ptr::copy_nonoverlapping()
986+
#[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
983987
#[stable(feature = "pointer_methods", since = "1.26.0")]
984988
#[inline]
985-
pub unsafe fn copy_from_nonoverlapping(self, src: *const T, count: usize)
989+
pub const unsafe fn copy_from_nonoverlapping(self, src: *const T, count: usize)
986990
where
987991
T: Sized,
988992
{

‎library/std/src/path.rs

+30
Original file line numberDiff line numberDiff line change
@@ -2472,6 +2472,36 @@ impl Path {
24722472
fs::metadata(self).is_ok()
24732473
}
24742474

2475+
/// Returns `Ok(true)` if the path points at an existing entity.
2476+
///
2477+
/// This function will traverse symbolic links to query information about the
2478+
/// destination file. In case of broken symbolic links this will return `Ok(false)`.
2479+
///
2480+
/// As opposed to the `exists()` method, this one doesn't silently ignore errors
2481+
/// unrelated to the path not existing. (E.g. it will return `Err(_)` in case of permission
2482+
/// denied on some of the parent directories.)
2483+
///
2484+
/// # Examples
2485+
///
2486+
/// ```no_run
2487+
/// #![feature(path_try_exists)]
2488+
///
2489+
/// use std::path::Path;
2490+
/// assert!(!Path::new("does_not_exist.txt").try_exists().expect("Can't check existence of file does_not_exist.txt"));
2491+
/// assert!(Path::new("/root/secret_file.txt").try_exists().is_err());
2492+
/// ```
2493+
// FIXME: stabilization should modify documentation of `exists()` to recommend this method
2494+
// instead.
2495+
#[unstable(feature = "path_try_exists", issue = "83186")]
2496+
#[inline]
2497+
pub fn try_exists(&self) -> io::Result<bool> {
2498+
match fs::metadata(self) {
2499+
Ok(_) => Ok(true),
2500+
Err(error) if error.kind() == io::ErrorKind::NotFound => Ok(false),
2501+
Err(error) => Err(error),
2502+
}
2503+
}
2504+
24752505
/// Returns `true` if the path exists on disk and is pointing at a regular file.
24762506
///
24772507
/// This function will traverse symbolic links to query information about the

‎library/std/src/prelude/v1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub use core::prelude::v1::{
4848
// FIXME: Attribute and internal derive macros are not documented because for them rustdoc generates
4949
// dead links which fail link checker testing.
5050
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
51-
#[allow(deprecated)]
51+
#[allow(deprecated, deprecated_in_future)]
5252
#[doc(hidden)]
5353
pub use core::prelude::v1::{
5454
bench, global_allocator, test, test_case, RustcDecodable, RustcEncodable,

‎src/bootstrap/test.rs

+13
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,19 @@ impl Step for Tidy {
791791

792792
if builder.config.channel == "dev" || builder.config.channel == "nightly" {
793793
builder.info("fmt check");
794+
if builder.config.initial_rustfmt.is_none() {
795+
let inferred_rustfmt_dir = builder.config.initial_rustc.parent().unwrap();
796+
eprintln!(
797+
"\
798+
error: no `rustfmt` binary found in {PATH}
799+
info: `rust.channel` is currently set to \"{CHAN}\"
800+
help: if you are testing a beta branch, set `rust.channel` to \"beta\" in the `config.toml` file
801+
help: to skip test's attempt to check tidiness, pass `--exclude src/tools/tidy` to `x.py test`",
802+
PATH = inferred_rustfmt_dir.display(),
803+
CHAN = builder.config.channel,
804+
);
805+
std::process::exit(1);
806+
}
794807
crate::format::format(&builder.build, !builder.config.cmd.bless());
795808
}
796809
}

‎src/librustdoc/html/static/main.js

+78-49
Original file line numberDiff line numberDiff line change
@@ -833,39 +833,52 @@ function defocusSearchBar() {
833833
};
834834
}
835835

836-
function getObjectFromId(id) {
836+
function getObjectNameFromId(id) {
837837
if (typeof id === "number") {
838-
return searchIndex[id];
838+
return searchIndex[id].name;
839839
}
840-
return {'name': id};
840+
return id;
841841
}
842842

843843
function checkGenerics(obj, val) {
844844
// The names match, but we need to be sure that all generics kinda
845845
// match as well.
846+
var tmp_lev, elem_name;
846847
if (val.generics.length > 0) {
847848
if (obj.length > GENERICS_DATA &&
848849
obj[GENERICS_DATA].length >= val.generics.length) {
849-
var elems = obj[GENERICS_DATA].slice(0);
850+
var elems = Object.create(null);
851+
var elength = object[GENERICS_DATA].length;
852+
for (var x = 0; x < elength; ++x) {
853+
elems[getObjectNameFromId(obj[GENERICS_DATA][x])] += 1;
854+
}
850855
var total = 0;
851856
var done = 0;
852857
// We need to find the type that matches the most to remove it in order
853858
// to move forward.
854859
var vlength = val.generics.length;
855-
for (var y = 0; y < vlength; ++y) {
856-
var lev = { pos: -1, lev: MAX_LEV_DISTANCE + 1};
857-
var firstGeneric = getObjectFromId(val.generics[y]).name;
858-
for (var x = 0, elength = elems.length; x < elength; ++x) {
859-
var tmp_lev = levenshtein(getObjectFromId(elems[x]).name,
860-
firstGeneric);
861-
if (tmp_lev < lev.lev) {
862-
lev.lev = tmp_lev;
863-
lev.pos = x;
860+
for (x = 0; x < vlength; ++x) {
861+
var lev = MAX_LEV_DISTANCE + 1;
862+
var firstGeneric = getObjectNameFromId(val.generics[x]);
863+
var match = null;
864+
if (elems[firstGeneric]) {
865+
match = firstGeneric;
866+
lev = 0;
867+
} else {
868+
for (elem_name in elems) {
869+
tmp_lev = levenshtein(elem_name, firstGeneric);
870+
if (tmp_lev < lev) {
871+
lev = tmp_lev;
872+
match = elem_name;
873+
}
864874
}
865875
}
866-
if (lev.pos !== -1) {
867-
elems.splice(lev.pos, 1);
868-
total += lev.lev;
876+
if (match !== null) {
877+
elems[match] -= 1;
878+
if (elems[match] == 0) {
879+
delete elems[match];
880+
}
881+
total += lev;
869882
done += 1;
870883
} else {
871884
return MAX_LEV_DISTANCE + 1;
@@ -880,25 +893,27 @@ function defocusSearchBar() {
880893
// Check for type name and type generics (if any).
881894
function checkType(obj, val, literalSearch) {
882895
var lev_distance = MAX_LEV_DISTANCE + 1;
883-
var len, x, y, e_len, firstGeneric;
896+
var len, x, firstGeneric;
884897
if (obj[NAME] === val.name) {
885898
if (literalSearch === true) {
886899
if (val.generics && val.generics.length !== 0) {
887900
if (obj.length > GENERICS_DATA &&
888901
obj[GENERICS_DATA].length >= val.generics.length) {
889-
var elems = obj[GENERICS_DATA].slice(0);
890-
var allFound = true;
902+
var elems = Object.create(null);
903+
len = obj[GENERICS_DATA].length;
904+
for (x = 0; x < len; ++x) {
905+
elems[getObjectNameFromId(obj[GENERICS_DATA][x])] += 1;
906+
}
891907

908+
var allFound = true;
892909
len = val.generics.length;
893-
for (y = 0; allFound === true && y < len; ++y) {
894-
allFound = false;
895-
firstGeneric = getObjectFromId(val.generics[y]).name;
896-
e_len = elems.length;
897-
for (x = 0; allFound === false && x < e_len; ++x) {
898-
allFound = getObjectFromId(elems[x]).name === firstGeneric;
899-
}
900-
if (allFound === true) {
901-
elems.splice(x - 1, 1);
910+
for (x = 0; x < len; ++x) {
911+
firstGeneric = getObjectNameFromId(val.generics[x]);
912+
if (elems[firstGeneric]) {
913+
elems[firstGeneric] -= 1;
914+
} else {
915+
allFound = false;
916+
break;
902917
}
903918
}
904919
if (allFound === true) {
@@ -1066,13 +1081,6 @@ function defocusSearchBar() {
10661081
return false;
10671082
}
10681083

1069-
function generateId(ty) {
1070-
if (ty.parent && ty.parent.name) {
1071-
return itemTypes[ty.ty] + ty.path + ty.parent.name + ty.name;
1072-
}
1073-
return itemTypes[ty.ty] + ty.path + ty.name;
1074-
}
1075-
10761084
function createAliasFromItem(item) {
10771085
return {
10781086
crate: item.crate,
@@ -1158,7 +1166,7 @@ function defocusSearchBar() {
11581166
in_args = findArg(searchIndex[i], val, true, typeFilter);
11591167
returned = checkReturned(searchIndex[i], val, true, typeFilter);
11601168
ty = searchIndex[i];
1161-
fullId = generateId(ty);
1169+
fullId = ty.id;
11621170

11631171
if (searchWords[i] === val.name
11641172
&& typePassesFilter(typeFilter, searchIndex[i].ty)
@@ -1208,7 +1216,7 @@ function defocusSearchBar() {
12081216
if (!type) {
12091217
continue;
12101218
}
1211-
fullId = generateId(ty);
1219+
fullId = ty.id;
12121220

12131221
returned = checkReturned(ty, output, true, NO_TYPE_FILTER);
12141222
if (output.name === "*" || returned === true) {
@@ -1292,15 +1300,15 @@ function defocusSearchBar() {
12921300
var index = -1;
12931301
// we want lev results to go lower than others
12941302
lev = MAX_LEV_DISTANCE + 1;
1295-
fullId = generateId(ty);
1303+
fullId = ty.id;
12961304

12971305
if (searchWords[j].indexOf(split[i]) > -1 ||
12981306
searchWords[j].indexOf(val) > -1 ||
1299-
searchWords[j].replace(/_/g, "").indexOf(val) > -1)
1307+
ty.normalizedName.indexOf(val) > -1)
13001308
{
13011309
// filter type: ... queries
13021310
if (typePassesFilter(typeFilter, ty.ty) && results[fullId] === undefined) {
1303-
index = searchWords[j].replace(/_/g, "").indexOf(val);
1311+
index = ty.normalizedName.indexOf(val);
13041312
}
13051313
}
13061314
if ((lev = levenshtein(searchWords[j], val)) <= MAX_LEV_DISTANCE) {
@@ -1828,23 +1836,35 @@ function defocusSearchBar() {
18281836
function buildIndex(rawSearchIndex) {
18291837
searchIndex = [];
18301838
var searchWords = [];
1831-
var i;
1839+
var i, word;
18321840
var currentIndex = 0;
1841+
var id = 0;
18331842

18341843
for (var crate in rawSearchIndex) {
18351844
if (!hasOwnProperty(rawSearchIndex, crate)) { continue; }
18361845

18371846
var crateSize = 0;
18381847

18391848
searchWords.push(crate);
1840-
searchIndex.push({
1849+
var normalizedName = crate.indexOf("_") === -1
1850+
? crate
1851+
: crate.replace(/_/g, "");
1852+
// This object should have exactly the same set of fields as the "row"
1853+
// object defined below. Your JavaScript runtime will thank you.
1854+
// https://mathiasbynens.be/notes/shapes-ics
1855+
var crateRow = {
18411856
crate: crate,
18421857
ty: 1, // == ExternCrate
18431858
name: crate,
18441859
path: "",
18451860
desc: rawSearchIndex[crate].doc,
1861+
parent: undefined,
18461862
type: null,
1847-
});
1863+
id: id,
1864+
normalizedName: normalizedName,
1865+
};
1866+
id += 1;
1867+
searchIndex.push(crateRow);
18481868
currentIndex += 1;
18491869

18501870
// an array of (Number) item types
@@ -1882,6 +1902,18 @@ function defocusSearchBar() {
18821902
len = itemTypes.length;
18831903
var lastPath = "";
18841904
for (i = 0; i < len; ++i) {
1905+
// This object should have exactly the same set of fields as the "crateRow"
1906+
// object defined above.
1907+
if (typeof itemNames[i] === "string") {
1908+
word = itemNames[i].toLowerCase();
1909+
searchWords.push(word);
1910+
} else {
1911+
word = "";
1912+
searchWords.push("");
1913+
}
1914+
var normalizedName = word.indexOf("_") === -1
1915+
? word
1916+
: word.replace(/_/g, "");
18851917
var row = {
18861918
crate: crate,
18871919
ty: itemTypes[i],
@@ -1890,14 +1922,11 @@ function defocusSearchBar() {
18901922
desc: itemDescs[i],
18911923
parent: itemParentIdxs[i] > 0 ? paths[itemParentIdxs[i] - 1] : undefined,
18921924
type: itemFunctionSearchTypes[i],
1925+
id: id,
1926+
normalizedName: normalizedName,
18931927
};
1928+
id += 1;
18941929
searchIndex.push(row);
1895-
if (typeof row.name === "string") {
1896-
var word = row.name.toLowerCase();
1897-
searchWords.push(word);
1898-
} else {
1899-
searchWords.push("");
1900-
}
19011930
lastPath = row.path;
19021931
crateSize += 1;
19031932
}

‎src/librustdoc/html/static/rustdoc.css

+5-4
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,12 @@ h1, h2, h3, h4,
136136
#source-sidebar, #sidebar-toggle,
137137
/* This selector is for the items listed in the "all items" page. */
138138
#main > ul.docblock > li > a {
139-
font-family: "Fira Sans", Arial;
139+
font-family: "Fira Sans", Arial, sans-serif;
140140
}
141141

142142
.content ul.crate a.crate {
143-
font: 16px/1.6 "Fira Sans";
143+
font-size: 16px/1.6;
144+
font-family: "Fira Sans", Arial, sans-serif;
144145
}
145146

146147
ol, ul {
@@ -482,7 +483,7 @@ h4 > code, h3 > code, .invisible > code {
482483
}
483484
#main > .since {
484485
top: inherit;
485-
font-family: "Fira Sans", Arial;
486+
font-family: "Fira Sans", Arial, sans-serif;
486487
}
487488

488489
.content table:not(.table-display) {
@@ -1301,7 +1302,7 @@ h4 > .notable-traits {
13011302

13021303
.help-button {
13031304
right: 30px;
1304-
font-family: "Fira Sans", Arial;
1305+
font-family: "Fira Sans", Arial, sans-serif;
13051306
text-align: center;
13061307
font-size: 17px;
13071308
}

‎src/librustdoc/html/static/themes/ayu.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ a {
266266

267267
.stab.portability > code {
268268
color: #e6e1cf;
269-
background-color: transparent;
269+
background: none;
270270
}
271271

272272
#help > div {

‎src/librustdoc/html/static/themes/dark.css

+1-4
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,7 @@ a.test-arrow {
222222
.stab.unstable { background: #FFF5D6; border-color: #FFC600; color: #2f2f2f; }
223223
.stab.deprecated { background: #F3DFFF; border-color: #7F0087; color: #2f2f2f; }
224224
.stab.portability { background: #C4ECFF; border-color: #7BA5DB; color: #2f2f2f; }
225-
226-
.stab.portability > code {
227-
color: #ddd;
228-
}
225+
.stab.portability > code { background: none; }
229226

230227
#help > div {
231228
background: #4d4d4d;

‎src/librustdoc/html/static/themes/light.css

+1-4
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,7 @@ a.test-arrow {
220220
.stab.unstable { background: #FFF5D6; border-color: #FFC600; }
221221
.stab.deprecated { background: #F3DFFF; border-color: #7F0087; }
222222
.stab.portability { background: #C4ECFF; border-color: #7BA5DB; }
223-
224-
.stab.portability > code {
225-
color: #000;
226-
}
223+
.stab.portability > code { background: none; }
227224

228225
#help > div {
229226
background: #e9e9e9;

‎src/test/ui/invalid/invalid_rustc_layout_scalar_valid_range.rs

+7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ enum E {
1515
Y = 14,
1616
}
1717

18+
#[rustc_layout_scalar_valid_range_start(rustc_layout_scalar_valid_range_start)] //~ ERROR
19+
struct NonZero<T>(T);
20+
21+
fn not_field() -> impl Send {
22+
NonZero(false)
23+
}
24+
1825
fn main() {
1926
let _ = A(0);
2027
let _ = B(0);

‎src/test/ui/invalid/invalid_rustc_layout_scalar_valid_range.stderr

+7-1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,11 @@ LL | | Y = 14,
2727
LL | | }
2828
| |_- not a struct
2929

30-
error: aborting due to 4 previous errors
30+
error: expected exactly one integer literal argument
31+
--> $DIR/invalid_rustc_layout_scalar_valid_range.rs:18:1
32+
|
33+
LL | #[rustc_layout_scalar_valid_range_start(rustc_layout_scalar_valid_range_start)]
34+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
35+
36+
error: aborting due to 5 previous errors
3137

0 commit comments

Comments
 (0)
Please sign in to comment.