From a8b5d4b7f113975e35b1924af608989e0cd620cd Mon Sep 17 00:00:00 2001 From: Xiretza Date: Sat, 10 Dec 2022 09:27:07 +0100 Subject: [PATCH 01/16] libcore: make result type of iter::from_generator concrete This allows for propagating trait impls on the iterator type. --- .../core/src/iter/sources/from_generator.rs | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/library/core/src/iter/sources/from_generator.rs b/library/core/src/iter/sources/from_generator.rs index 8e7cbd34a4f66..a974d3c892d00 100644 --- a/library/core/src/iter/sources/from_generator.rs +++ b/library/core/src/iter/sources/from_generator.rs @@ -1,3 +1,4 @@ +use crate::fmt; use crate::ops::{Generator, GeneratorState}; use crate::pin::Pin; @@ -23,14 +24,20 @@ use crate::pin::Pin; /// ``` #[inline] #[unstable(feature = "iter_from_generator", issue = "43122", reason = "generators are unstable")] -pub fn from_generator + Unpin>( - generator: G, -) -> impl Iterator { +pub fn from_generator + Unpin>(generator: G) -> FromGenerator { FromGenerator(generator) } -struct FromGenerator(G); +/// An iterator over the values yielded by an underlying generator. +/// +/// This `struct` is created by the [`iter::from_generator()`] function. See its documentation for +/// more. +/// +/// [`iter::from_generator()`]: from_generator +#[unstable(feature = "iter_from_generator", issue = "43122", reason = "generators are unstable")] +pub struct FromGenerator(G); +#[unstable(feature = "iter_from_generator", issue = "43122", reason = "generators are unstable")] impl + Unpin> Iterator for FromGenerator { type Item = G::Yield; @@ -41,3 +48,10 @@ impl + Unpin> Iterator for FromGenerator { } } } + +#[unstable(feature = "iter_from_generator", issue = "43122", reason = "generators are unstable")] +impl fmt::Debug for FromGenerator { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("FromGenerator").finish() + } +} From 17a0740ebb1798ee29fc39c1ec025f0949144541 Mon Sep 17 00:00:00 2001 From: Xiretza Date: Sat, 10 Dec 2022 09:03:14 +0100 Subject: [PATCH 02/16] libcore: make result of iter::from_generator Clone This is currently only relevant with #![feature(generator_clone)]. --- library/core/src/iter/sources/from_generator.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/core/src/iter/sources/from_generator.rs b/library/core/src/iter/sources/from_generator.rs index a974d3c892d00..4cbe731b222f9 100644 --- a/library/core/src/iter/sources/from_generator.rs +++ b/library/core/src/iter/sources/from_generator.rs @@ -35,6 +35,7 @@ pub fn from_generator + Unpin>(generator: G) -> FromGe /// /// [`iter::from_generator()`]: from_generator #[unstable(feature = "iter_from_generator", issue = "43122", reason = "generators are unstable")] +#[derive(Clone)] pub struct FromGenerator(G); #[unstable(feature = "iter_from_generator", issue = "43122", reason = "generators are unstable")] From 753e57672296e13c534f87b6e2672a73fff4965c Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Wed, 11 Jan 2023 17:05:15 +0000 Subject: [PATCH 03/16] Fix up stat test in libc-fs-with-isolation The test relied on Error::last_os_error() coming from the stat call on the passed file, but there is no guarantee this will be the case. Instead extract errno from the error returned by the routine. Patch de facto written by joboet. Co-authored-by: joboet --- .../miri/tests/pass-dep/shims/libc-fs-with-isolation.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tools/miri/tests/pass-dep/shims/libc-fs-with-isolation.rs b/src/tools/miri/tests/pass-dep/shims/libc-fs-with-isolation.rs index f1838cf64f7fe..d6d19a3fe8159 100644 --- a/src/tools/miri/tests/pass-dep/shims/libc-fs-with-isolation.rs +++ b/src/tools/miri/tests/pass-dep/shims/libc-fs-with-isolation.rs @@ -22,7 +22,8 @@ fn main() { } // test `stat` - assert_eq!(fs::metadata("foo.txt").unwrap_err().kind(), ErrorKind::PermissionDenied); + let err = fs::metadata("foo.txt").unwrap_err(); + assert_eq!(err.kind(), ErrorKind::PermissionDenied); // check that it is the right kind of `PermissionDenied` - assert_eq!(Error::last_os_error().raw_os_error(), Some(libc::EACCES)); + assert_eq!(err.raw_os_error(), Some(libc::EACCES)); } From b49aa8d53e2e1424f5d9997734cfd71b2ae647b4 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Tue, 10 Jan 2023 02:08:07 +0000 Subject: [PATCH 04/16] Stop probing for statx unless necessary As is the current toy program: fn main() -> std::io::Result<()> { use std::fs; let metadata = fs::metadata("foo.txt")?; assert!(!metadata.is_dir()); Ok(()) } ... observed under strace will issue: [snip] statx(0, NULL, AT_STATX_SYNC_AS_STAT, STATX_ALL, NULL) = -1 EFAULT (Bad address) statx(AT_FDCWD, "foo.txt", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=0, ...}) = 0 While statx is not necessarily always present, checking for it can be delayed to the first error condition. Said condition may very well never happen, in which case the check got avoided altogether. Note this is still suboptimal as there still will be programs issuing it, but bulk of the problem is removed. Tested by forbidding the syscall for the binary and observing it correctly falls back to newfstatat. While here tidy up the commentary, in particular by denoting some problems with the current approach. --- library/std/src/sys/unix/fs.rs | 68 ++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 27 deletions(-) diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs index aea0c26ee8b60..0e7d23a5c7c9d 100644 --- a/library/std/src/sys/unix/fs.rs +++ b/library/std/src/sys/unix/fs.rs @@ -149,12 +149,13 @@ cfg_has_statx! {{ ) -> Option> { use crate::sync::atomic::{AtomicU8, Ordering}; - // Linux kernel prior to 4.11 or glibc prior to glibc 2.28 don't support `statx` - // We store the availability in global to avoid unnecessary syscalls. - // 0: Unknown - // 1: Not available - // 2: Available - static STATX_STATE: AtomicU8 = AtomicU8::new(0); + // Linux kernel prior to 4.11 or glibc prior to glibc 2.28 don't support `statx`. + // We check for it on first failure and remember availability to avoid having to + // do it again. + #[repr(u8)] + enum STATX_STATE{ Unknown = 0, Present, Unavailable } + static STATX_SAVED_STATE: AtomicU8 = AtomicU8::new(STATX_STATE::Unknown as u8); + syscall! { fn statx( fd: c_int, @@ -165,31 +166,44 @@ cfg_has_statx! {{ ) -> c_int } - match STATX_STATE.load(Ordering::Relaxed) { - 0 => { - // It is a trick to call `statx` with null pointers to check if the syscall - // is available. According to the manual, it is expected to fail with EFAULT. - // We do this mainly for performance, since it is nearly hundreds times - // faster than a normal successful call. - let err = cvt(statx(0, ptr::null(), 0, libc::STATX_ALL, ptr::null_mut())) - .err() - .and_then(|e| e.raw_os_error()); - // We don't check `err == Some(libc::ENOSYS)` because the syscall may be limited - // and returns `EPERM`. Listing all possible errors seems not a good idea. - // See: https://github.com/rust-lang/rust/issues/65662 - if err != Some(libc::EFAULT) { - STATX_STATE.store(1, Ordering::Relaxed); - return None; - } - STATX_STATE.store(2, Ordering::Relaxed); - } - 1 => return None, - _ => {} + if STATX_SAVED_STATE.load(Ordering::Relaxed) == STATX_STATE::Unavailable as u8 { + return None; } let mut buf: libc::statx = mem::zeroed(); if let Err(err) = cvt(statx(fd, path, flags, mask, &mut buf)) { - return Some(Err(err)); + if STATX_SAVED_STATE.load(Ordering::Relaxed) == STATX_STATE::Present as u8 { + return Some(Err(err)); + } + + // Availability not checked yet. + // + // First try the cheap way. + if err.raw_os_error() == Some(libc::ENOSYS) { + STATX_SAVED_STATE.store(STATX_STATE::Unavailable as u8, Ordering::Relaxed); + return None; + } + + // Error other than `ENOSYS` is not a good enough indicator -- it is + // known that `EPERM` can be returned as a result of using seccomp to + // block the syscall. + // Availability is checked by performing a call which expects `EFAULT` + // if the syscall is usable. + // See: https://github.com/rust-lang/rust/issues/65662 + // FIXME this can probably just do the call if `EPERM` was received, but + // previous iteration of the code checked it for all errors and for now + // this is retained. + // FIXME what about transient conditions like `ENOMEM`? + let err2 = cvt(statx(0, ptr::null(), 0, libc::STATX_ALL, ptr::null_mut())) + .err() + .and_then(|e| e.raw_os_error()); + if err2 == Some(libc::EFAULT) { + STATX_SAVED_STATE.store(STATX_STATE::Present as u8, Ordering::Relaxed); + return Some(Err(err)); + } else { + STATX_SAVED_STATE.store(STATX_STATE::Unavailable as u8, Ordering::Relaxed); + return None; + } } // We cannot fill `stat64` exhaustively because of private padding fields. From 60cc7783dabeb349c7eacb100f2a454b4546bfca Mon Sep 17 00:00:00 2001 From: klensy Date: Thu, 12 Jan 2023 19:47:53 +0300 Subject: [PATCH 05/16] evade clones --- src/librustdoc/html/render/mod.rs | 4 ++-- src/librustdoc/html/render/print_item.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 8bccf68029aa3..03a960da75fb8 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -2769,8 +2769,8 @@ fn collect_paths_for_type(first_ty: clean::Type, cache: &Cache) -> Vec { let mut work = VecDeque::new(); let mut process_path = |did: DefId| { - let get_extern = || cache.external_paths.get(&did).map(|s| s.0.clone()); - let fqp = cache.exact_paths.get(&did).cloned().or_else(get_extern); + let get_extern = || cache.external_paths.get(&did).map(|s| &s.0); + let fqp = cache.exact_paths.get(&did).or_else(get_extern); if let Some(path) = fqp { out.push(join_with_double_colon(&path)); diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index c16d6477fc379..73cb135bbf8c1 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -1027,8 +1027,8 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean: .chain(std::iter::once("implementors")) .collect(); if let Some(did) = it.item_id.as_def_id() && - let get_extern = { || cache.external_paths.get(&did).map(|s| s.0.clone()) } && - let Some(fqp) = cache.exact_paths.get(&did).cloned().or_else(get_extern) { + let get_extern = { || cache.external_paths.get(&did).map(|s| &s.0) } && + let Some(fqp) = cache.exact_paths.get(&did).or_else(get_extern) { js_src_path.extend(fqp[..fqp.len() - 1].iter().copied()); js_src_path.push_fmt(format_args!("{}.{}.js", it.type_(), fqp.last().unwrap())); } else { From 4e1258c6b6f67df77157c7aea0f800854da99294 Mon Sep 17 00:00:00 2001 From: klensy Date: Fri, 13 Jan 2023 15:39:16 +0300 Subject: [PATCH 06/16] IndexItem.name String -> Symbol --- src/librustdoc/formats/cache.rs | 9 +++++---- src/librustdoc/html/render/mod.rs | 2 +- src/librustdoc/html/render/search_index.rs | 8 ++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs index d027fb6e8763c..3149c22b8e55f 100644 --- a/src/librustdoc/formats/cache.rs +++ b/src/librustdoc/formats/cache.rs @@ -242,7 +242,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { } // Index this method for searching later on. - if let Some(ref s) = item.name.or_else(|| { + if let Some(s) = item.name.or_else(|| { if item.is_stripped() { None } else if let clean::ImportItem(ref i) = *item.kind && @@ -317,14 +317,15 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { short_markdown_summary(x.as_str(), &item.link_names(self.cache)) }); let ty = item.type_(); - let name = s.to_string(); - if ty != ItemType::StructField || u16::from_str_radix(&name, 10).is_err() { + if ty != ItemType::StructField + || u16::from_str_radix(s.as_str(), 10).is_err() + { // In case this is a field from a tuple struct, we don't add it into // the search index because its name is something like "0", which is // not useful for rustdoc search. self.cache.search_index.push(IndexItem { ty, - name, + name: s, path: join_with_double_colon(path), desc, parent, diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 03a960da75fb8..8d018d45c106e 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -100,7 +100,7 @@ pub(crate) fn ensure_trailing_slash(v: &str) -> impl fmt::Display + '_ { #[derive(Debug)] pub(crate) struct IndexItem { pub(crate) ty: ItemType, - pub(crate) name: String, + pub(crate) name: Symbol, pub(crate) path: String, pub(crate) desc: String, pub(crate) parent: Option, diff --git a/src/librustdoc/html/render/search_index.rs b/src/librustdoc/html/render/search_index.rs index bc74d9cf96974..b0ae0dae0d6d5 100644 --- a/src/librustdoc/html/render/search_index.rs +++ b/src/librustdoc/html/render/search_index.rs @@ -35,7 +35,7 @@ pub(crate) fn build_index<'tcx>( .map_or_else(String::new, |s| short_markdown_summary(&s, &item.link_names(cache))); cache.search_index.push(IndexItem { ty: item.type_(), - name: item.name.unwrap().to_string(), + name: item.name.unwrap(), path: join_with_double_colon(&fqp[..fqp.len() - 1]), desc, parent: Some(parent), @@ -58,8 +58,8 @@ pub(crate) fn build_index<'tcx>( // Sort search index items. This improves the compressibility of the search index. cache.search_index.sort_unstable_by(|k1, k2| { // `sort_unstable_by_key` produces lifetime errors - let k1 = (&k1.path, &k1.name, &k1.ty, &k1.parent); - let k2 = (&k2.path, &k2.name, &k2.ty, &k2.parent); + let k1 = (&k1.path, k1.name.as_str(), &k1.ty, &k1.parent); + let k2 = (&k2.path, k2.name.as_str(), &k2.ty, &k2.parent); std::cmp::Ord::cmp(&k1, &k2) }); @@ -240,7 +240,7 @@ pub(crate) fn build_index<'tcx>( )?; crate_data.serialize_field( "n", - &self.items.iter().map(|item| &item.name).collect::>(), + &self.items.iter().map(|item| item.name.as_str()).collect::>(), )?; crate_data.serialize_field( "q", From cda6efeeb8d6e6155b776c7fedd32cfeeb37233e Mon Sep 17 00:00:00 2001 From: klensy Date: Fri, 13 Jan 2023 17:33:07 +0300 Subject: [PATCH 07/16] generate_macro_def_id_path: don't eagerly stringify Symbols --- src/librustdoc/html/format.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 5ad24bf268133..83fde5fd7205d 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -569,7 +569,7 @@ fn generate_macro_def_id_path( root_path: Option<&str>, ) -> Result<(String, ItemType, Vec), HrefError> { let tcx = cx.shared.tcx; - let crate_name = tcx.crate_name(def_id.krate).to_string(); + let crate_name = tcx.crate_name(def_id.krate); let cache = cx.cache(); let fqp: Vec = tcx @@ -584,7 +584,7 @@ fn generate_macro_def_id_path( } }) .collect(); - let mut relative = fqp.iter().map(|elem| elem.to_string()); + let mut relative = fqp.iter().copied(); let cstore = CStore::from_tcx(tcx); // We need this to prevent a `panic` when this function is used from intra doc links... if !cstore.has_crate_data(def_id.krate) { @@ -602,9 +602,9 @@ fn generate_macro_def_id_path( }; let mut path = if is_macro_2 { - once(crate_name.clone()).chain(relative).collect() + once(crate_name).chain(relative).collect() } else { - vec![crate_name.clone(), relative.next_back().unwrap()] + vec![crate_name, relative.next_back().unwrap()] }; if path.len() < 2 { // The minimum we can have is the crate name followed by the macro name. If shorter, then @@ -614,17 +614,22 @@ fn generate_macro_def_id_path( } if let Some(last) = path.last_mut() { - *last = format!("macro.{}.html", last); + *last = Symbol::intern(&format!("macro.{}.html", last.as_str())); } let url = match cache.extern_locations[&def_id.krate] { ExternalLocation::Remote(ref s) => { // `ExternalLocation::Remote` always end with a `/`. - format!("{}{}", s, path.join("/")) + format!("{}{}", s, path.iter().map(|p| p.as_str()).join("/")) } ExternalLocation::Local => { // `root_path` always end with a `/`. - format!("{}{}/{}", root_path.unwrap_or(""), crate_name, path.join("/")) + format!( + "{}{}/{}", + root_path.unwrap_or(""), + crate_name, + path.iter().map(|p| p.as_str()).join("/") + ) } ExternalLocation::Unknown => { debug!("crate {} not in cache when linkifying macros", crate_name); From 81b637b6f2b410e81fb47919c8b3817979ec7073 Mon Sep 17 00:00:00 2001 From: klensy Date: Fri, 13 Jan 2023 17:54:16 +0300 Subject: [PATCH 08/16] fmt_type: don't alloc const String, use &str instead --- src/librustdoc/html/format.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 83fde5fd7205d..006076baf7257 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -1055,7 +1055,7 @@ fn fmt_type<'cx>( _ => String::new(), }; let m = mutability.print_with_space(); - let amp = if f.alternate() { "&".to_string() } else { "&".to_string() }; + let amp = if f.alternate() { "&" } else { "&" }; match **ty { clean::DynTrait(ref bounds, ref trait_lt) if bounds.len() > 1 || trait_lt.is_some() => From ffb2e843196060820130134a0815eccf198b487f Mon Sep 17 00:00:00 2001 From: klensy Date: Fri, 13 Jan 2023 18:05:16 +0300 Subject: [PATCH 09/16] Playground.crate_name String -> Symbol --- src/librustdoc/html/markdown.rs | 6 +++--- src/librustdoc/html/render/context.rs | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index aeaee524fd453..4ff67fe1551dd 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -30,7 +30,7 @@ use rustc_hir::def_id::DefId; use rustc_hir::HirId; use rustc_middle::ty::TyCtxt; use rustc_span::edition::Edition; -use rustc_span::Span; +use rustc_span::{Span, Symbol}; use once_cell::sync::Lazy; use std::borrow::Cow; @@ -198,7 +198,7 @@ fn slugify(c: char) -> Option { #[derive(Clone, Debug)] pub struct Playground { - pub crate_name: Option, + pub crate_name: Option, pub url: String, } @@ -290,7 +290,7 @@ impl<'a, I: Iterator>> Iterator for CodeBlocks<'_, 'a, I> { .map(|l| map_line(l).for_code()) .intersperse("\n".into()) .collect::(); - let krate = krate.as_ref().map(|s| &**s); + let krate = krate.as_ref().map(|s| s.as_str()); let (test, _, _) = doctest::make_test(&test, krate, false, &Default::default(), edition, None); let channel = if test.contains("#![feature(") { "&version=nightly" } else { "" }; diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index c8899ee62b5f9..9f266568769c0 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -464,8 +464,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { // If user passed in `--playground-url` arg, we fill in crate name here let mut playground = None; if let Some(url) = playground_url { - playground = - Some(markdown::Playground { crate_name: Some(krate.name(tcx).to_string()), url }); + playground = Some(markdown::Playground { crate_name: Some(krate.name(tcx)), url }); } let mut layout = layout::Layout { logo: String::new(), @@ -491,7 +490,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { } (sym::html_playground_url, Some(s)) => { playground = Some(markdown::Playground { - crate_name: Some(krate.name(tcx).to_string()), + crate_name: Some(krate.name(tcx)), url: s.to_string(), }); } From 8998bd35ed2ebd5889f7726e971e95e642c3fdca Mon Sep 17 00:00:00 2001 From: klensy Date: Fri, 13 Jan 2023 18:27:30 +0300 Subject: [PATCH 10/16] CrateData: don't allocate String when Serialize, &str is enough --- src/librustdoc/html/render/search_index.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/render/search_index.rs b/src/librustdoc/html/render/search_index.rs index b0ae0dae0d6d5..c64349f413cee 100644 --- a/src/librustdoc/html/render/search_index.rs +++ b/src/librustdoc/html/render/search_index.rs @@ -299,7 +299,7 @@ pub(crate) fn build_index<'tcx>( )?; crate_data.serialize_field( "p", - &self.paths.iter().map(|(it, s)| (it, s.to_string())).collect::>(), + &self.paths.iter().map(|(it, s)| (it, s.as_str())).collect::>(), )?; if has_aliases { crate_data.serialize_field("a", &self.aliases)?; From 5314ed5627f99a1956c792cd493493c0edf23a93 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Fri, 13 Jan 2023 15:42:29 -0700 Subject: [PATCH 11/16] rustdoc: remove `docblock` class from notable trait popover This commit builds on b72de9be74dd5ac1d8b23d5ece03a7690274a14c, which removes the `docblock` class from the All Items page, and 9457380ac902db3febf92077c5b645db55998ad4, which removes the `docblock` class from the item decl. Fixes #92974 --- src/librustdoc/html/render/mod.rs | 2 +- src/librustdoc/html/static/css/rustdoc.css | 8 ++++++-- src/librustdoc/html/static/js/main.js | 2 +- .../rustdoc/doc-notable_trait-slice.bare_fn_matches.html | 2 +- tests/rustdoc/doc-notable_trait.bare-fn.html | 2 +- tests/rustdoc/doc-notable_trait.some-struct-new.html | 2 +- tests/rustdoc/doc-notable_trait.wrap-me.html | 2 +- tests/rustdoc/spotlight-from-dependency.odd.html | 2 +- 8 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 8bccf68029aa3..a3a89ae5c1541 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -1343,7 +1343,7 @@ fn notable_traits_decl(ty: &clean::Type, cx: &Context<'_>) -> (String, String) { write!( &mut out, "

Notable traits for {}

\ -
",
+                     
",
                         impl_.for_.print(cx)
                     );
                 }
diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css
index b2fa6e82acce2..b7d324f8fa946 100644
--- a/src/librustdoc/html/static/css/rustdoc.css
+++ b/src/librustdoc/html/static/css/rustdoc.css
@@ -1214,11 +1214,11 @@ a.test-arrow:hover {
 	content: "\00a0";
 }
 
-.notable .docblock {
+.notable .content {
 	margin: 0.25em 0.5em;
 }
 
-.notable .docblock pre, .notable .docblock code {
+.notable .content pre, .notable .content code {
 	background: transparent;
 	margin: 0;
 	padding: 0;
@@ -1226,6 +1226,10 @@ a.test-arrow:hover {
 	white-space: pre-wrap;
 }
 
+.notable .content > h3:first-child {
+	margin: 0 0 5px 0;
+}
+
 .search-failed {
 	text-align: center;
 	margin-top: 20px;
diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js
index 51aee8e7c8992..98f3156328973 100644
--- a/src/librustdoc/html/static/js/main.js
+++ b/src/librustdoc/html/static/js/main.js
@@ -847,7 +847,7 @@ function loadCss(cssUrl) {
         window.hideAllModals(false);
         const ty = e.getAttribute("data-ty");
         const wrapper = document.createElement("div");
-        wrapper.innerHTML = "
" + window.NOTABLE_TRAITS[ty] + "
"; + wrapper.innerHTML = "
" + window.NOTABLE_TRAITS[ty] + "
"; wrapper.className = "notable popover"; const focusCatcher = document.createElement("div"); focusCatcher.setAttribute("tabindex", "0"); diff --git a/tests/rustdoc/doc-notable_trait-slice.bare_fn_matches.html b/tests/rustdoc/doc-notable_trait-slice.bare_fn_matches.html index f2ec8320a0525..46be00a080482 100644 --- a/tests/rustdoc/doc-notable_trait-slice.bare_fn_matches.html +++ b/tests/rustdoc/doc-notable_trait-slice.bare_fn_matches.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/tests/rustdoc/doc-notable_trait.bare-fn.html b/tests/rustdoc/doc-notable_trait.bare-fn.html index b426a4d7a8b7b..f592e3b375c02 100644 --- a/tests/rustdoc/doc-notable_trait.bare-fn.html +++ b/tests/rustdoc/doc-notable_trait.bare-fn.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/tests/rustdoc/doc-notable_trait.some-struct-new.html b/tests/rustdoc/doc-notable_trait.some-struct-new.html index 4f8063807e67d..384be66895400 100644 --- a/tests/rustdoc/doc-notable_trait.some-struct-new.html +++ b/tests/rustdoc/doc-notable_trait.some-struct-new.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/tests/rustdoc/doc-notable_trait.wrap-me.html b/tests/rustdoc/doc-notable_trait.wrap-me.html index bed2a38b24a2b..0cc1ee10fd335 100644 --- a/tests/rustdoc/doc-notable_trait.wrap-me.html +++ b/tests/rustdoc/doc-notable_trait.wrap-me.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/tests/rustdoc/spotlight-from-dependency.odd.html b/tests/rustdoc/spotlight-from-dependency.odd.html index 1d02c13ebfb3c..5f54b7522ae38 100644 --- a/tests/rustdoc/spotlight-from-dependency.odd.html +++ b/tests/rustdoc/spotlight-from-dependency.odd.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file From ea13023b367d56ac3a8fcb72c9bbe636cf9ae1e7 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Sat, 14 Jan 2023 11:44:25 +0000 Subject: [PATCH 12/16] Allocate one less vec in `parser/expr.rs` --- compiler/rustc_parse/src/parser/expr.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index dd2b03988c3e8..9995b21486170 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1471,9 +1471,8 @@ impl<'a> Parser<'a> { } else if self.eat(&token::Comma) { // Vector with two or more elements. let sep = SeqSep::trailing_allowed(token::Comma); - let (remaining_exprs, _) = self.parse_seq_to_end(close, sep, |p| p.parse_expr())?; - let mut exprs = vec![first_expr]; - exprs.extend(remaining_exprs); + let (mut exprs, _) = self.parse_seq_to_end(close, sep, |p| p.parse_expr())?; + exprs.insert(0, first_expr); ExprKind::Array(exprs) } else { // Vector with one element From 6821adb65145463ffe51e044cbe37ea823059222 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Fri, 13 Jan 2023 01:27:58 +0100 Subject: [PATCH 13/16] Deprioritize fulfillment errors that come from expansions. --- .../src/traits/error_reporting/mod.rs | 8 +++++--- .../cannot-infer-partial-try-return.stderr | 2 -- .../inference/question-mark-type-infer.stderr | 9 +++++++-- tests/ui/issues/issue-69455.stderr | 18 ++++++++++-------- .../cannot_infer_local_or_vec_in_tuples.stderr | 2 +- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index 0c7ffb056cc02..c75842d18c629 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -453,9 +453,11 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { } } - for (error, suppressed) in iter::zip(errors, is_suppressed) { - if !suppressed { - self.report_fulfillment_error(error, body_id); + for from_expansion in [false, true] { + for (error, suppressed) in iter::zip(errors, &is_suppressed) { + if !suppressed && error.obligation.cause.span.from_expansion() == from_expansion { + self.report_fulfillment_error(error, body_id); + } } } diff --git a/tests/ui/inference/cannot-infer-partial-try-return.stderr b/tests/ui/inference/cannot-infer-partial-try-return.stderr index 2a56aaa44fef2..888c321bc479b 100644 --- a/tests/ui/inference/cannot-infer-partial-try-return.stderr +++ b/tests/ui/inference/cannot-infer-partial-try-return.stderr @@ -1,8 +1,6 @@ error[E0282]: type annotations needed --> $DIR/cannot-infer-partial-try-return.rs:20:9 | -LL | infallible()?; - | ------------- type must be known at this point LL | Ok(()) | ^^ cannot infer type of the type parameter `E` declared on the enum `Result` | diff --git a/tests/ui/inference/question-mark-type-infer.stderr b/tests/ui/inference/question-mark-type-infer.stderr index 9b822714f828a..a9cb7e5257c83 100644 --- a/tests/ui/inference/question-mark-type-infer.stderr +++ b/tests/ui/inference/question-mark-type-infer.stderr @@ -1,8 +1,13 @@ error[E0282]: type annotations needed - --> $DIR/question-mark-type-infer.rs:10:30 + --> $DIR/question-mark-type-infer.rs:10:21 | LL | l.iter().map(f).collect()? - | ^ cannot infer type + | ^^^^^^^ cannot infer type of the type parameter `B` declared on the associated function `collect` + | +help: consider specifying the generic argument + | +LL | l.iter().map(f).collect::>()? + | ++++++++++ error: aborting due to previous error diff --git a/tests/ui/issues/issue-69455.stderr b/tests/ui/issues/issue-69455.stderr index 9d11cf19ea77c..fc343bb54aace 100644 --- a/tests/ui/issues/issue-69455.stderr +++ b/tests/ui/issues/issue-69455.stderr @@ -1,14 +1,16 @@ -error[E0282]: type annotations needed - --> $DIR/issue-69455.rs:29:20 +error[E0284]: type annotations needed + --> $DIR/issue-69455.rs:29:41 | LL | println!("{}", 23u64.test(xs.iter().sum())); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the associated function `new_display` + | ---- ^^^ cannot infer type of the type parameter `S` declared on the associated function `sum` + | | + | type must be known at this point | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: cannot satisfy `>::Output == _` help: consider specifying the generic argument | -LL | println!("{}", 23u64.test(xs.iter().sum())::); - | +++++ +LL | println!("{}", 23u64.test(xs.iter().sum::())); + | +++++ error[E0283]: type annotations needed --> $DIR/issue-69455.rs:29:41 @@ -33,5 +35,5 @@ LL | println!("{}", 23u64.test(xs.iter().sum::())); error: aborting due to 2 previous errors -Some errors have detailed explanations: E0282, E0283. -For more information about an error, try `rustc --explain E0282`. +Some errors have detailed explanations: E0283, E0284. +For more information about an error, try `rustc --explain E0283`. diff --git a/tests/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr b/tests/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr index be60cda68b9f0..e544b36951548 100644 --- a/tests/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr +++ b/tests/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr @@ -2,7 +2,7 @@ error[E0282]: type annotations needed for `(Vec,)` --> $DIR/cannot_infer_local_or_vec_in_tuples.rs:2:9 | LL | let (x, ) = (vec![], ); - | ^^^^^ + | ^^^^^ ---------- type must be known at this point | help: consider giving this pattern a type, where the type for type parameter `T` is specified | From 4f64de83bc5731946c9acdd4f572e24bfbaef4b9 Mon Sep 17 00:00:00 2001 From: clubby789 Date: Sat, 7 Jan 2023 15:41:32 +0000 Subject: [PATCH 14/16] Fix `unused_braces` on generic const expr macro call --- compiler/rustc_lint/src/unused.rs | 1 + tests/ui/const-generics/unused_braces.fixed | 7 +++++++ tests/ui/const-generics/unused_braces.rs | 7 +++++++ tests/ui/const-generics/unused_braces.stderr | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index ac2b32b44e6a1..f2ee9ab1a1987 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -1105,6 +1105,7 @@ impl UnusedDelimLint for UnusedBraces { || matches!(expr.kind, ast::ExprKind::Lit(_))) && !cx.sess().source_map().is_multiline(value.span) && value.attrs.is_empty() + && !expr.span.from_expansion() && !value.span.from_expansion() && !inner.span.from_expansion() { diff --git a/tests/ui/const-generics/unused_braces.fixed b/tests/ui/const-generics/unused_braces.fixed index d080c210e6bd2..4c1926387b926 100644 --- a/tests/ui/const-generics/unused_braces.fixed +++ b/tests/ui/const-generics/unused_braces.fixed @@ -2,10 +2,17 @@ // run-rustfix #![warn(unused_braces)] +macro_rules! make_1 { + () => { + 1 + } +} + struct A; fn main() { let _: A<7>; // ok let _: A<7>; //~ WARN unnecessary braces let _: A<{ 3 + 5 }>; // ok + let _: A<{make_1!()}>; // ok } diff --git a/tests/ui/const-generics/unused_braces.rs b/tests/ui/const-generics/unused_braces.rs index 47f0f8c1c96c9..e9f15b4018079 100644 --- a/tests/ui/const-generics/unused_braces.rs +++ b/tests/ui/const-generics/unused_braces.rs @@ -2,10 +2,17 @@ // run-rustfix #![warn(unused_braces)] +macro_rules! make_1 { + () => { + 1 + } +} + struct A; fn main() { let _: A<7>; // ok let _: A<{ 7 }>; //~ WARN unnecessary braces let _: A<{ 3 + 5 }>; // ok + let _: A<{make_1!()}>; // ok } diff --git a/tests/ui/const-generics/unused_braces.stderr b/tests/ui/const-generics/unused_braces.stderr index 553a3a0f88eba..2c8031c430020 100644 --- a/tests/ui/const-generics/unused_braces.stderr +++ b/tests/ui/const-generics/unused_braces.stderr @@ -1,5 +1,5 @@ warning: unnecessary braces around const expression - --> $DIR/unused_braces.rs:9:14 + --> $DIR/unused_braces.rs:15:14 | LL | let _: A<{ 7 }>; | ^^ ^^ From 0b35f448f8e9f39ed6fc1c494eeb331afba513bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Vennberg?= Date: Sat, 14 Jan 2023 16:33:11 +0100 Subject: [PATCH 15/16] Remove various double spaces in source comments. --- library/alloc/src/alloc.rs | 4 ++-- library/alloc/src/rc.rs | 2 +- library/alloc/src/sync.rs | 8 ++++---- library/alloc/src/vec/into_iter.rs | 6 +++--- library/alloc/src/vec/is_zero.rs | 2 +- library/alloc/src/vec/mod.rs | 4 ++-- library/alloc/tests/vec.rs | 2 +- library/core/src/array/iter.rs | 6 +++--- library/core/src/iter/range.rs | 2 +- library/core/src/num/int_macros.rs | 4 ++-- library/core/src/ptr/mod.rs | 2 +- library/core/src/slice/iter.rs | 4 ++-- library/core/src/slice/iter/macros.rs | 2 +- library/core/src/slice/mod.rs | 4 ++-- library/core/src/slice/sort.rs | 6 +++--- library/core/tests/slice.rs | 2 +- library/std/src/io/buffered/tests.rs | 4 ++-- library/std/src/os/fd/owned.rs | 2 +- library/std/src/panicking.rs | 4 ++-- library/std/src/path.rs | 2 +- library/std/src/sys/itron/thread.rs | 2 +- library/std/src/sys/unix/fs.rs | 4 ++-- library/std/src/sys/unix/kernel_copy.rs | 2 +- .../std/src/sys/unix/process/process_fuchsia.rs | 10 +++++----- library/std/src/sys/unix/process/process_unix.rs | 6 +++--- .../src/sys/unix/process/process_unix/tests.rs | 6 +++--- .../std/src/sys/unix/process/process_vxworks.rs | 6 +++--- library/std/src/sys/unix/thread.rs | 16 ++++++++-------- library/std/src/sys/windows/os.rs | 2 +- library/std/src/sys/windows/thread.rs | 2 +- library/test/src/lib.rs | 2 +- library/test/src/term/terminfo/searcher.rs | 2 +- 32 files changed, 66 insertions(+), 66 deletions(-) diff --git a/library/alloc/src/alloc.rs b/library/alloc/src/alloc.rs index fe6de1cf879b2..3a797bd5ecaa8 100644 --- a/library/alloc/src/alloc.rs +++ b/library/alloc/src/alloc.rs @@ -20,7 +20,7 @@ use core::marker::Destruct; mod tests; extern "Rust" { - // These are the magic symbols to call the global allocator. rustc generates + // These are the magic symbols to call the global allocator. rustc generates // them to call `__rg_alloc` etc. if there is a `#[global_allocator]` attribute // (the code expanding that attribute macro generates those functions), or to call // the default implementations in std (`__rdl_alloc` etc. in `library/std/src/alloc.rs`) @@ -353,7 +353,7 @@ pub(crate) const unsafe fn box_free !; diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index c1d853ed65216..c9aa23fc4af1f 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -2179,7 +2179,7 @@ pub struct Weak { // This is a `NonNull` to allow optimizing the size of this type in enums, // but it is not necessarily a valid pointer. // `Weak::new` sets this to `usize::MAX` so that it doesn’t need - // to allocate space on the heap. That's not a value a real pointer + // to allocate space on the heap. That's not a value a real pointer // will ever have because RcBox has alignment at least 2. // This is only possible when `T: Sized`; unsized `T` never dangle. ptr: NonNull>, diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index d833d4d1dfbd3..bab7f5f53657a 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -295,7 +295,7 @@ pub struct Weak { // This is a `NonNull` to allow optimizing the size of this type in enums, // but it is not necessarily a valid pointer. // `Weak::new` sets this to `usize::MAX` so that it doesn’t need - // to allocate space on the heap. That's not a value a real pointer + // to allocate space on the heap. That's not a value a real pointer // will ever have because RcBox has alignment at least 2. // This is only possible when `T: Sized`; unsized `T` never dangle. ptr: NonNull>, @@ -1656,7 +1656,7 @@ impl Arc { // // The acquire label here ensures a happens-before relationship with any // writes to `strong` (in particular in `Weak::upgrade`) prior to decrements - // of the `weak` count (via `Weak::drop`, which uses release). If the upgraded + // of the `weak` count (via `Weak::drop`, which uses release). If the upgraded // weak ref was never dropped, the CAS here will fail so we do not care to synchronize. if self.inner().weak.compare_exchange(1, usize::MAX, Acquire, Relaxed).is_ok() { // This needs to be an `Acquire` to synchronize with the decrement of the `strong` @@ -1712,7 +1712,7 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Arc { } // This fence is needed to prevent reordering of use of the data and - // deletion of the data. Because it is marked `Release`, the decreasing + // deletion of the data. Because it is marked `Release`, the decreasing // of the reference count synchronizes with this `Acquire` fence. This // means that use of the data happens before decreasing the reference // count, which happens before this fence, which happens before the @@ -2172,7 +2172,7 @@ impl Clone for Weak { } else { return Weak { ptr: self.ptr }; }; - // See comments in Arc::clone() for why this is relaxed. This can use a + // See comments in Arc::clone() for why this is relaxed. This can use a // fetch_add (ignoring the lock) because the weak count is only locked // where are *no other* weak pointers in existence. (So we can't be // running this code in that case). diff --git a/library/alloc/src/vec/into_iter.rs b/library/alloc/src/vec/into_iter.rs index b207b3210f1aa..37966007eb7e4 100644 --- a/library/alloc/src/vec/into_iter.rs +++ b/library/alloc/src/vec/into_iter.rs @@ -40,7 +40,7 @@ pub struct IntoIter< // to avoid dropping the allocator twice we need to wrap it into ManuallyDrop pub(super) alloc: ManuallyDrop, pub(super) ptr: *const T, - pub(super) end: *const T, // If T is a ZST, this is actually ptr+len. This encoding is picked so that + pub(super) end: *const T, // If T is a ZST, this is actually ptr+len. This encoding is picked so that // ptr == end is a quick test for the Iterator being empty, that works // for both ZST and non-ZST. } @@ -146,9 +146,9 @@ impl IntoIter { let mut this = ManuallyDrop::new(self); // SAFETY: This allocation originally came from a `Vec`, so it passes - // all those checks. We have `this.buf` ≤ `this.ptr` ≤ `this.end`, + // all those checks. We have `this.buf` ≤ `this.ptr` ≤ `this.end`, // so the `sub_ptr`s below cannot wrap, and will produce a well-formed - // range. `end` ≤ `buf + cap`, so the range will be in-bounds. + // range. `end` ≤ `buf + cap`, so the range will be in-bounds. // Taking `alloc` is ok because nothing else is going to look at it, // since our `Drop` impl isn't going to run so there's no more code. unsafe { diff --git a/library/alloc/src/vec/is_zero.rs b/library/alloc/src/vec/is_zero.rs index 8e652d676dc01..26120270c0cb0 100644 --- a/library/alloc/src/vec/is_zero.rs +++ b/library/alloc/src/vec/is_zero.rs @@ -57,7 +57,7 @@ unsafe impl IsZero for [T; N] { #[inline] fn is_zero(&self) -> bool { // Because this is generated as a runtime check, it's not obvious that - // it's worth doing if the array is really long. The threshold here + // it's worth doing if the array is really long. The threshold here // is largely arbitrary, but was picked because as of 2022-07-01 LLVM // fails to const-fold the check in `vec![[1; 32]; n]` // See https://github.com/rust-lang/rust/pull/97581#issuecomment-1166628022 diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 36cfac8ee9e17..36b0b3c9e7cc0 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -2429,7 +2429,7 @@ impl Vec { self.reserve(range.len()); // SAFETY: - // - `slice::range` guarantees that the given range is valid for indexing self + // - `slice::range` guarantees that the given range is valid for indexing self unsafe { self.spec_extend_from_within(range); } @@ -2686,7 +2686,7 @@ impl Clone for Vec { // HACK(japaric): with cfg(test) the inherent `[T]::to_vec` method, which is // required for this method definition, is not available. Instead use the - // `slice::to_vec` function which is only available with cfg(test) + // `slice::to_vec` function which is only available with cfg(test) // NB see the slice::hack module in slice.rs for more information #[cfg(test)] fn clone(&self) -> Self { diff --git a/library/alloc/tests/vec.rs b/library/alloc/tests/vec.rs index 87adcead8f62d..2f07c2911a502 100644 --- a/library/alloc/tests/vec.rs +++ b/library/alloc/tests/vec.rs @@ -1849,7 +1849,7 @@ fn test_stable_pointers() { } // Test that, if we reserved enough space, adding and removing elements does not - // invalidate references into the vector (such as `v0`). This test also + // invalidate references into the vector (such as `v0`). This test also // runs in Miri, which would detect such problems. // Note that this test does *not* constitute a stable guarantee that all these functions do not // reallocate! Only what is explicitly documented at diff --git a/library/core/src/array/iter.rs b/library/core/src/array/iter.rs index b91c630183d4f..8259c087d22e4 100644 --- a/library/core/src/array/iter.rs +++ b/library/core/src/array/iter.rs @@ -109,8 +109,8 @@ impl IntoIter { /// use std::array::IntoIter; /// use std::mem::MaybeUninit; /// - /// # // Hi! Thanks for reading the code. This is restricted to `Copy` because - /// # // otherwise it could leak. A fully-general version this would need a drop + /// # // Hi! Thanks for reading the code. This is restricted to `Copy` because + /// # // otherwise it could leak. A fully-general version this would need a drop /// # // guard to handle panics from the iterator, but this works for an example. /// fn next_chunk( /// it: &mut impl Iterator, @@ -211,7 +211,7 @@ impl IntoIter { let initialized = 0..0; // SAFETY: We're telling it that none of the elements are initialized, - // which is trivially true. And ∀N: usize, 0 <= N. + // which is trivially true. And ∀N: usize, 0 <= N. unsafe { Self::new_unchecked(buffer, initialized) } } diff --git a/library/core/src/iter/range.rs b/library/core/src/iter/range.rs index ac7b389b15b4d..b5739f2f3c0b0 100644 --- a/library/core/src/iter/range.rs +++ b/library/core/src/iter/range.rs @@ -756,7 +756,7 @@ impl Iterator for ops::Range { where Self: TrustedRandomAccessNoCoerce, { - // SAFETY: The TrustedRandomAccess contract requires that callers only pass an index + // SAFETY: The TrustedRandomAccess contract requires that callers only pass an index // that is in bounds. // Additionally Self: TrustedRandomAccess is only implemented for Copy types // which means even repeated reads of the same index would be safe. diff --git a/library/core/src/num/int_macros.rs b/library/core/src/num/int_macros.rs index 21518a3f55180..7071a656d613d 100644 --- a/library/core/src/num/int_macros.rs +++ b/library/core/src/num/int_macros.rs @@ -1538,7 +1538,7 @@ macro_rules! int_impl { /// /// ``` /// #![feature(bigint_helper_methods)] - /// // Only the most significant word is signed. + /// // Only the most significant word is signed. /// // #[doc = concat!("// 10 MAX (a = 10 × 2^", stringify!($BITS), " + 2^", stringify!($BITS), " - 1)")] #[doc = concat!("// + -5 9 (b = -5 × 2^", stringify!($BITS), " + 9)")] @@ -1646,7 +1646,7 @@ macro_rules! int_impl { /// /// ``` /// #![feature(bigint_helper_methods)] - /// // Only the most significant word is signed. + /// // Only the most significant word is signed. /// // #[doc = concat!("// 6 8 (a = 6 × 2^", stringify!($BITS), " + 8)")] #[doc = concat!("// - -5 9 (b = -5 × 2^", stringify!($BITS), " + 9)")] diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index 5f30029eaa07d..1ad9af1549a47 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -1701,7 +1701,7 @@ pub(crate) const unsafe fn align_offset(p: *const T, a: usize) -> usiz // offset is not a multiple of `stride`, the input pointer was misaligned and no pointer // offset will be able to produce a `p` aligned to the specified `a`. // - // The naive `-p (mod a)` equation inhibits LLVM's ability to select instructions + // The naive `-p (mod a)` equation inhibits LLVM's ability to select instructions // like `lea`. We compute `(round_up_to_next_alignment(p, a) - p)` instead. This // redistributes operations around the load-bearing, but pessimizing `and` instruction // sufficiently for LLVM to be able to utilize the various optimizations it knows about. diff --git a/library/core/src/slice/iter.rs b/library/core/src/slice/iter.rs index 06228976719f5..c3e7f2eb302ca 100644 --- a/library/core/src/slice/iter.rs +++ b/library/core/src/slice/iter.rs @@ -65,7 +65,7 @@ fn size_from_ptr(_: *const T) -> usize { #[must_use = "iterators are lazy and do nothing unless consumed"] pub struct Iter<'a, T: 'a> { ptr: NonNull, - end: *const T, // If T is a ZST, this is actually ptr+len. This encoding is picked so that + end: *const T, // If T is a ZST, this is actually ptr+len. This encoding is picked so that // ptr == end is a quick test for the Iterator being empty, that works // for both ZST and non-ZST. _marker: PhantomData<&'a T>, @@ -186,7 +186,7 @@ impl AsRef<[T]> for Iter<'_, T> { #[must_use = "iterators are lazy and do nothing unless consumed"] pub struct IterMut<'a, T: 'a> { ptr: NonNull, - end: *mut T, // If T is a ZST, this is actually ptr+len. This encoding is picked so that + end: *mut T, // If T is a ZST, this is actually ptr+len. This encoding is picked so that // ptr == end is a quick test for the Iterator being empty, that works // for both ZST and non-ZST. _marker: PhantomData<&'a mut T>, diff --git a/library/core/src/slice/iter/macros.rs b/library/core/src/slice/iter/macros.rs index ce51d48e3e551..55af4cb61dcc0 100644 --- a/library/core/src/slice/iter/macros.rs +++ b/library/core/src/slice/iter/macros.rs @@ -23,7 +23,7 @@ macro_rules! len { $self.end.addr().wrapping_sub(start.as_ptr().addr()) } else { // We know that `start <= end`, so can do better than `offset_from`, - // which needs to deal in signed. By setting appropriate flags here + // which needs to deal in signed. By setting appropriate flags here // we can tell LLVM this, which helps it remove bounds checks. // SAFETY: By the type invariant, `start <= end` let diff = unsafe { unchecked_sub($self.end.addr(), start.as_ptr().addr()) }; diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 2995cf0c6443f..caca2d0031d33 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -703,7 +703,7 @@ impl [T] { // Because this function is first compiled in isolation, // this check tells LLVM that the indexing below is - // in-bounds. Then after inlining -- once the actual + // in-bounds. Then after inlining -- once the actual // lengths of the slices are known -- it's removed. let (a, b) = (&mut a[..n], &mut b[..n]); @@ -2476,7 +2476,7 @@ impl [T] { let mid = left + size / 2; // SAFETY: the while condition means `size` is strictly positive, so - // `size/2 < size`. Thus `left + size/2 < left + size`, which + // `size/2 < size`. Thus `left + size/2 < left + size`, which // coupled with the `left + size <= self.len()` invariant means // we have `left + size/2 < self.len()`, and this is in-bounds. let cmp = f(unsafe { self.get_unchecked(mid) }); diff --git a/library/core/src/slice/sort.rs b/library/core/src/slice/sort.rs index b8c0c3fd94932..4d2fcd917849c 100644 --- a/library/core/src/slice/sort.rs +++ b/library/core/src/slice/sort.rs @@ -18,9 +18,9 @@ struct CopyOnDrop { impl Drop for CopyOnDrop { fn drop(&mut self) { - // SAFETY: This is a helper class. - // Please refer to its usage for correctness. - // Namely, one must be sure that `src` and `dst` does not overlap as required by `ptr::copy_nonoverlapping`. + // SAFETY: This is a helper class. + // Please refer to its usage for correctness. + // Namely, one must be sure that `src` and `dst` does not overlap as required by `ptr::copy_nonoverlapping`. unsafe { ptr::copy_nonoverlapping(self.src, self.dest, 1); } diff --git a/library/core/tests/slice.rs b/library/core/tests/slice.rs index fd35d96c3fef8..39559cdbb5ea9 100644 --- a/library/core/tests/slice.rs +++ b/library/core/tests/slice.rs @@ -1488,7 +1488,7 @@ mod slice_index { // optional: // // one or more similar inputs for which data[input] succeeds, - // and the corresponding output as an array. This helps validate + // and the corresponding output as an array. This helps validate // "critical points" where an input range straddles the boundary // between valid and invalid. // (such as the input `len..len`, which is just barely valid) diff --git a/library/std/src/io/buffered/tests.rs b/library/std/src/io/buffered/tests.rs index f4e688eb926cc..4c1b7d57684dd 100644 --- a/library/std/src/io/buffered/tests.rs +++ b/library/std/src/io/buffered/tests.rs @@ -288,8 +288,8 @@ fn test_buffered_reader_seek_underflow_discard_buffer_between_seeks() { let mut reader = BufReader::with_capacity(5, ErrAfterFirstSeekReader { first_seek: true }); assert_eq!(reader.fill_buf().ok(), Some(&[0, 0, 0, 0, 0][..])); - // The following seek will require two underlying seeks. The first will - // succeed but the second will fail. This should still invalidate the + // The following seek will require two underlying seeks. The first will + // succeed but the second will fail. This should still invalidate the // buffer. assert!(reader.seek(SeekFrom::Current(i64::MIN)).is_err()); assert_eq!(reader.buffer().len(), 0); diff --git a/library/std/src/os/fd/owned.rs b/library/std/src/os/fd/owned.rs index c16518577f7c4..c41e093a7e5c6 100644 --- a/library/std/src/os/fd/owned.rs +++ b/library/std/src/os/fd/owned.rs @@ -100,7 +100,7 @@ impl BorrowedFd<'_> { // For ESP-IDF, F_DUPFD is used instead, because the CLOEXEC semantics // will never be supported, as this is a bare metal framework with - // no capabilities for multi-process execution. While F_DUPFD is also + // no capabilities for multi-process execution. While F_DUPFD is also // not supported yet, it might be (currently it returns ENOSYS). #[cfg(target_os = "espidf")] let cmd = libc::F_DUPFD; diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs index b30dd8eecd84c..b0db3112e22fd 100644 --- a/library/std/src/panicking.rs +++ b/library/std/src/panicking.rs @@ -306,11 +306,11 @@ pub mod panic_count { // and after increase and decrease, but not necessarily during their execution. // // Additionally, the top bit of GLOBAL_PANIC_COUNT (GLOBAL_ALWAYS_ABORT_FLAG) - // records whether panic::always_abort() has been called. This can only be + // records whether panic::always_abort() has been called. This can only be // set, never cleared. // panic::always_abort() is usually called to prevent memory allocations done by // the panic handling in the child created by `libc::fork`. - // Memory allocations performed in a child created with `libc::fork` are undefined + // Memory allocations performed in a child created with `libc::fork` are undefined // behavior in most operating systems. // Accessing LOCAL_PANIC_COUNT in a child created by `libc::fork` would lead to a memory // allocation. Only GLOBAL_PANIC_COUNT can be accessed in this situation. This is diff --git a/library/std/src/path.rs b/library/std/src/path.rs index a2dcee0e2bdb2..c3593264e520b 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -607,7 +607,7 @@ pub struct Components<'a> { // true if path *physically* has a root separator; for most Windows // prefixes, it may have a "logical" root separator for the purposes of - // normalization, e.g., \\server\share == \\server\share\. + // normalization, e.g., \\server\share == \\server\share\. has_physical_root: bool, // The iterator is double-ended, and these two states keep track of what has diff --git a/library/std/src/sys/itron/thread.rs b/library/std/src/sys/itron/thread.rs index 535703be33f06..19350b83fab88 100644 --- a/library/std/src/sys/itron/thread.rs +++ b/library/std/src/sys/itron/thread.rs @@ -294,7 +294,7 @@ impl Drop for Thread { // Terminate and delete the task // Safety: `self.task` still represents a task we own (because // this method or `join_inner` is called only once for - // each `Thread`). The task indicated that it's safe to + // each `Thread`). The task indicated that it's safe to // delete by entering the `FINISHED` state. unsafe { terminate_and_delete_task(self.task) }; diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs index aea0c26ee8b60..3a43a007171bd 100644 --- a/library/std/src/sys/unix/fs.rs +++ b/library/std/src/sys/unix/fs.rs @@ -600,13 +600,13 @@ impl Iterator for ReadDir { loop { // As of POSIX.1-2017, readdir() is not required to be thread safe; only // readdir_r() is. However, readdir_r() cannot correctly handle platforms - // with unlimited or variable NAME_MAX. Many modern platforms guarantee + // with unlimited or variable NAME_MAX. Many modern platforms guarantee // thread safety for readdir() as long an individual DIR* is not accessed // concurrently, which is sufficient for Rust. super::os::set_errno(0); let entry_ptr = readdir64(self.inner.dirp.0); if entry_ptr.is_null() { - // We either encountered an error, or reached the end. Either way, + // We either encountered an error, or reached the end. Either way, // the next call to next() should return None. self.end_of_stream = true; diff --git a/library/std/src/sys/unix/kernel_copy.rs b/library/std/src/sys/unix/kernel_copy.rs index 0f7107122b7e8..73b9bef7e2ac9 100644 --- a/library/std/src/sys/unix/kernel_copy.rs +++ b/library/std/src/sys/unix/kernel_copy.rs @@ -587,7 +587,7 @@ pub(super) fn copy_regular_files(reader: RawFd, writer: RawFd, max_len: u64) -> // - copy_file_range file is immutable or syscall is blocked by seccomp¹ (EPERM) // - copy_file_range cannot be used with pipes or device nodes (EINVAL) // - the writer fd was opened with O_APPEND (EBADF²) - // and no bytes were written successfully yet. (All these errnos should + // and no bytes were written successfully yet. (All these errnos should // not be returned if something was already written, but they happen in // the wild, see #91152.) // diff --git a/library/std/src/sys/unix/process/process_fuchsia.rs b/library/std/src/sys/unix/process/process_fuchsia.rs index 4c99d758c93a3..d4c7e58b34d2e 100644 --- a/library/std/src/sys/unix/process/process_fuchsia.rs +++ b/library/std/src/sys/unix/process/process_fuchsia.rs @@ -262,7 +262,7 @@ impl ExitStatus { // available on Fuchsia. // // It does not appear that Fuchsia is Unix-like enough to implement ExitStatus (or indeed many - // other things from std::os::unix) properly. This veneer is always going to be a bodge. So + // other things from std::os::unix) properly. This veneer is always going to be a bodge. So // while I don't know if these implementations are actually correct, I think they will do for // now at least. pub fn core_dumped(&self) -> bool { @@ -277,9 +277,9 @@ impl ExitStatus { pub fn into_raw(&self) -> c_int { // We don't know what someone who calls into_raw() will do with this value, but it should - // have the conventional Unix representation. Despite the fact that this is not + // have the conventional Unix representation. Despite the fact that this is not // standardised in SuS or POSIX, all Unix systems encode the signal and exit status the - // same way. (Ie the WIFEXITED, WEXITSTATUS etc. macros have identical behaviour on every + // same way. (Ie the WIFEXITED, WEXITSTATUS etc. macros have identical behaviour on every // Unix.) // // The caller of `std::os::unix::into_raw` is probably wanting a Unix exit status, and may @@ -287,14 +287,14 @@ impl ExitStatus { // different Unix variant. // // The other view would be to say that the caller on Fuchsia ought to know that `into_raw` - // will give a raw Fuchsia status (whatever that is - I don't know, personally). That is + // will give a raw Fuchsia status (whatever that is - I don't know, personally). That is // not possible here because we must return a c_int because that's what Unix (including // SuS and POSIX) say a wait status is, but Fuchsia apparently uses a u64, so it won't // necessarily fit. // // It seems to me that the right answer would be to provide std::os::fuchsia with its // own ExitStatusExt, rather that trying to provide a not very convincing imitation of - // Unix. Ie, std::os::unix::process:ExitStatusExt ought not to exist on Fuchsia. But + // Unix. Ie, std::os::unix::process:ExitStatusExt ought not to exist on Fuchsia. But // fixing this up that is beyond the scope of my efforts now. let exit_status_as_if_unix: u8 = self.0.try_into().expect("Fuchsia process return code bigger than 8 bits, but std::os::unix::ExitStatusExt::into_raw() was called to try to convert the value into a traditional Unix-style wait status, which cannot represent values greater than 255."); let wait_status_as_if_unix = (exit_status_as_if_unix as c_int) << 8; diff --git a/library/std/src/sys/unix/process/process_unix.rs b/library/std/src/sys/unix/process/process_unix.rs index 39d1c8b1d8ebc..c2c4aa1c9dfce 100644 --- a/library/std/src/sys/unix/process/process_unix.rs +++ b/library/std/src/sys/unix/process/process_unix.rs @@ -666,11 +666,11 @@ impl ExitStatus { } pub fn exit_ok(&self) -> Result<(), ExitStatusError> { - // This assumes that WIFEXITED(status) && WEXITSTATUS==0 corresponds to status==0. This is + // This assumes that WIFEXITED(status) && WEXITSTATUS==0 corresponds to status==0. This is // true on all actual versions of Unix, is widely assumed, and is specified in SuS - // https://pubs.opengroup.org/onlinepubs/9699919799/functions/wait.html . If it is not + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/wait.html. If it is not // true for a platform pretending to be Unix, the tests (our doctests, and also - // procsss_unix/tests.rs) will spot it. `ExitStatusError::code` assumes this too. + // procsss_unix/tests.rs) will spot it. `ExitStatusError::code` assumes this too. match NonZero_c_int::try_from(self.0) { /* was nonzero */ Ok(failure) => Err(ExitStatusError(failure)), /* was zero, couldn't convert */ Err(_) => Ok(()), diff --git a/library/std/src/sys/unix/process/process_unix/tests.rs b/library/std/src/sys/unix/process/process_unix/tests.rs index 4c87f633a2609..e5e1f956bc351 100644 --- a/library/std/src/sys/unix/process/process_unix/tests.rs +++ b/library/std/src/sys/unix/process/process_unix/tests.rs @@ -19,17 +19,17 @@ fn exitstatus_display_tests() { t(0x00000, "exit status: 0"); t(0x0ff00, "exit status: 255"); - // On MacOS, 0x0137f is WIFCONTINUED, not WIFSTOPPED. Probably *BSD is similar. + // On MacOS, 0x0137f is WIFCONTINUED, not WIFSTOPPED. Probably *BSD is similar. // https://github.com/rust-lang/rust/pull/82749#issuecomment-790525956 // The purpose of this test is to test our string formatting, not our understanding of the wait - // status magic numbers. So restrict these to Linux. + // status magic numbers. So restrict these to Linux. if cfg!(target_os = "linux") { t(0x0137f, "stopped (not terminated) by signal: 19 (SIGSTOP)"); t(0x0ffff, "continued (WIFCONTINUED)"); } // Testing "unrecognised wait status" is hard because the wait.h macros typically - // assume that the value came from wait and isn't mad. With the glibc I have here + // assume that the value came from wait and isn't mad. With the glibc I have here // this works: if cfg!(all(target_os = "linux", target_env = "gnu")) { t(0x000ff, "unrecognised wait status: 255 0xff"); diff --git a/library/std/src/sys/unix/process/process_vxworks.rs b/library/std/src/sys/unix/process/process_vxworks.rs index f549d37c30116..569a4b149125d 100644 --- a/library/std/src/sys/unix/process/process_vxworks.rs +++ b/library/std/src/sys/unix/process/process_vxworks.rs @@ -195,11 +195,11 @@ impl ExitStatus { } pub fn exit_ok(&self) -> Result<(), ExitStatusError> { - // This assumes that WIFEXITED(status) && WEXITSTATUS==0 corresponds to status==0. This is + // This assumes that WIFEXITED(status) && WEXITSTATUS==0 corresponds to status==0. This is // true on all actual versions of Unix, is widely assumed, and is specified in SuS - // https://pubs.opengroup.org/onlinepubs/9699919799/functions/wait.html . If it is not + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/wait.html. If it is not // true for a platform pretending to be Unix, the tests (our doctests, and also - // procsss_unix/tests.rs) will spot it. `ExitStatusError::code` assumes this too. + // procsss_unix/tests.rs) will spot it. `ExitStatusError::code` assumes this too. match NonZero_c_int::try_from(self.0) { Ok(failure) => Err(ExitStatusError(failure)), Err(_) => Ok(()), diff --git a/library/std/src/sys/unix/thread.rs b/library/std/src/sys/unix/thread.rs index b251949bda207..2a1830d060edc 100644 --- a/library/std/src/sys/unix/thread.rs +++ b/library/std/src/sys/unix/thread.rs @@ -73,7 +73,7 @@ impl Thread { n => { assert_eq!(n, libc::EINVAL); // EINVAL means |stack_size| is either too small or not a - // multiple of the system page size. Because it's definitely + // multiple of the system page size. Because it's definitely // >= PTHREAD_STACK_MIN, it must be an alignment issue. // Round up to the nearest page and try again. let page_size = os::page_size(); @@ -755,10 +755,10 @@ pub mod guard { if cfg!(all(target_os = "linux", not(target_env = "musl"))) { // Linux doesn't allocate the whole stack right away, and // the kernel has its own stack-guard mechanism to fault - // when growing too close to an existing mapping. If we map + // when growing too close to an existing mapping. If we map // our own guard, then the kernel starts enforcing a rather // large gap above that, rendering much of the possible - // stack space useless. See #43052. + // stack space useless. See #43052. // // Instead, we'll just note where we expect rlimit to start // faulting, so our handler can report "stack overflow", and @@ -774,14 +774,14 @@ pub mod guard { None } else if cfg!(target_os = "freebsd") { // FreeBSD's stack autogrows, and optionally includes a guard page - // at the bottom. If we try to remap the bottom of the stack - // ourselves, FreeBSD's guard page moves upwards. So we'll just use + // at the bottom. If we try to remap the bottom of the stack + // ourselves, FreeBSD's guard page moves upwards. So we'll just use // the builtin guard page. let stackptr = get_stack_start_aligned()?; let guardaddr = stackptr.addr(); // Technically the number of guard pages is tunable and controlled // by the security.bsd.stack_guard_page sysctl, but there are - // few reasons to change it from the default. The default value has + // few reasons to change it from the default. The default value has // been 1 ever since FreeBSD 11.1 and 10.4. const GUARD_PAGES: usize = 1; let guard = guardaddr..guardaddr + GUARD_PAGES * page_size; @@ -877,9 +877,9 @@ pub mod guard { } else if cfg!(all(target_os = "linux", any(target_env = "gnu", target_env = "uclibc"))) { // glibc used to include the guard area within the stack, as noted in the BUGS - // section of `man pthread_attr_getguardsize`. This has been corrected starting + // section of `man pthread_attr_getguardsize`. This has been corrected starting // with glibc 2.27, and in some distro backports, so the guard is now placed at the - // end (below) the stack. There's no easy way for us to know which we have at + // end (below) the stack. There's no easy way for us to know which we have at // runtime, so we'll just match any fault in the range right above or below the // stack base to call that fault a stack overflow. Some(stackaddr - guardsize..stackaddr + guardsize) diff --git a/library/std/src/sys/windows/os.rs b/library/std/src/sys/windows/os.rs index 352337ba32237..d7adeb266ed93 100644 --- a/library/std/src/sys/windows/os.rs +++ b/library/std/src/sys/windows/os.rs @@ -157,7 +157,7 @@ impl<'a> Iterator for SplitPaths<'a> { // Double quotes are used as a way of introducing literal semicolons // (since c:\some;dir is a valid Windows path). Double quotes are not // themselves permitted in path names, so there is no way to escape a - // double quote. Quoted regions can appear in arbitrary locations, so + // double quote. Quoted regions can appear in arbitrary locations, so // // c:\foo;c:\som"e;di"r;c:\bar // diff --git a/library/std/src/sys/windows/thread.rs b/library/std/src/sys/windows/thread.rs index c5c9e97e646fb..1cb576c95947a 100644 --- a/library/std/src/sys/windows/thread.rs +++ b/library/std/src/sys/windows/thread.rs @@ -26,7 +26,7 @@ impl Thread { // FIXME On UNIX, we guard against stack sizes that are too small but // that's because pthreads enforces that stacks are at least - // PTHREAD_STACK_MIN bytes big. Windows has no such lower limit, it's + // PTHREAD_STACK_MIN bytes big. Windows has no such lower limit, it's // just that below a certain threshold you can't do anything useful. // That threshold is application and architecture-specific, however. let ret = c::CreateThread( diff --git a/library/test/src/lib.rs b/library/test/src/lib.rs index 30dc4ff855315..69fb529d7f563 100644 --- a/library/test/src/lib.rs +++ b/library/test/src/lib.rs @@ -116,7 +116,7 @@ pub fn test_main(args: &[String], tests: Vec, options: Option Option { } } else { // Found nothing in TERMINFO_DIRS, use the default paths: - // According to /etc/terminfo/README, after looking at + // According to /etc/terminfo/README, after looking at // ~/.terminfo, ncurses will search /etc/terminfo, then // /lib/terminfo, and eventually /usr/share/terminfo. // On Haiku the database can be found at /boot/system/data/terminfo From 2fea03f5e69481606257a1d4dfeae2c717991e48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Vennberg?= Date: Sat, 14 Jan 2023 18:26:38 +0100 Subject: [PATCH 16/16] Fix some missed double spaces. --- library/core/src/num/dec2flt/fpu.rs | 2 +- library/core/src/pin.rs | 4 ++-- library/core/src/slice/mod.rs | 2 +- library/std/src/fs.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/library/core/src/num/dec2flt/fpu.rs b/library/core/src/num/dec2flt/fpu.rs index ec5fa45fdaddd..3806977f70ee4 100644 --- a/library/core/src/num/dec2flt/fpu.rs +++ b/library/core/src/num/dec2flt/fpu.rs @@ -26,7 +26,7 @@ mod fpu_precision { /// Developer's Manual (Volume 1). /// /// The only field which is relevant for the following code is PC, Precision Control. This - /// field determines the precision of the operations performed by the FPU. It can be set to: + /// field determines the precision of the operations performed by the FPU. It can be set to: /// - 0b00, single precision i.e., 32-bits /// - 0b10, double precision i.e., 64-bits /// - 0b11, double extended precision i.e., 80-bits (default state) diff --git a/library/core/src/pin.rs b/library/core/src/pin.rs index 2eb29d4f9c574..ec0c9984841e6 100644 --- a/library/core/src/pin.rs +++ b/library/core/src/pin.rs @@ -753,7 +753,7 @@ impl Pin

{ impl<'a, T: ?Sized> Pin<&'a T> { /// Constructs a new pin by mapping the interior value. /// - /// For example, if you wanted to get a `Pin` of a field of something, + /// For example, if you wanted to get a `Pin` of a field of something, /// you could use this to get access to that field in one line of code. /// However, there are several gotchas with these "pinning projections"; /// see the [`pin` module] documentation for further details on that topic. @@ -856,7 +856,7 @@ impl<'a, T: ?Sized> Pin<&'a mut T> { /// Construct a new pin by mapping the interior value. /// - /// For example, if you wanted to get a `Pin` of a field of something, + /// For example, if you wanted to get a `Pin` of a field of something, /// you could use this to get access to that field in one line of code. /// However, there are several gotchas with these "pinning projections"; /// see the [`pin` module] documentation for further details on that topic. diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index caca2d0031d33..df7fe2bf76dcd 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -1248,7 +1248,7 @@ impl [T] { ArrayChunksMut::new(self) } - /// Returns an iterator over overlapping windows of `N` elements of a slice, + /// Returns an iterator over overlapping windows of `N` elements of a slice, /// starting at the beginning of the slice. /// /// This is the const generic equivalent of [`windows`]. diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 5c5ef0b1125a0..286ad68fd13e8 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -1512,7 +1512,7 @@ impl FileType { } /// Tests whether this file type represents a regular file. - /// The result is mutually exclusive to the results of + /// The result is mutually exclusive to the results of /// [`is_dir`] and [`is_symlink`]; only zero or one of these /// tests may pass. ///