Skip to content

Commit 5242b6f

Browse files
committed
Auto merge of #130695 - GuillaumeGomez:rollup-7w2zou6, r=GuillaumeGomez
Rollup of 5 pull requests Successful merges: - #129545 (rustdoc: redesign toolbar and disclosure widgets) - #130658 (Fix docs of compare_bytes) - #130670 (delay uncapping the max_read_size in File::read_to_end) - #130680 (Call module_name_to_str instead of just unwrapping) - #130690 (interpret: remove outdated FIXME) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4ae36d9 + 1f96e55 commit 5242b6f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+555
-343
lines changed

compiler/rustc_codegen_llvm/src/back/lto.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ impl ThinLTOKeysMap {
844844
llvm::LLVMRustComputeLTOCacheKey(rust_str, module.identifier, data.0);
845845
})
846846
.expect("Invalid ThinLTO module key");
847-
(name.clone().into_string().unwrap(), key)
847+
(module_name_to_str(name).to_string(), key)
848848
})
849849
.collect();
850850
Self { keys }

compiler/rustc_const_eval/src/interpret/call.rs

-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
221221
}
222222

223223
// Fall back to exact equality.
224-
// FIXME: We are missing the rules for "repr(C) wrapping compatible types".
225224
Ok(caller == callee)
226225
}
227226

library/core/src/intrinsics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2733,7 +2733,7 @@ extern "rust-intrinsic" {
27332733

27342734
/// Lexicographically compare `[left, left + bytes)` and `[right, right + bytes)`
27352735
/// as unsigned bytes, returning negative if `left` is less, zero if all the
2736-
/// bytes match, or positive if `right` is greater.
2736+
/// bytes match, or positive if `left` is greater.
27372737
///
27382738
/// This underlies things like `<[u8]>::cmp`, and will usually lower to `memcmp`.
27392739
///

library/std/src/io/mod.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,7 @@ where
398398
// - avoid passing large buffers to readers that always initialize the free capacity if they perform short reads (#23815, #23820)
399399
// - pass large buffers to readers that do not initialize the spare capacity. this can amortize per-call overheads
400400
// - and finally pass not-too-small and not-too-large buffers to Windows read APIs because they manage to suffer from both problems
401-
// at the same time, i.e. small reads suffer from syscall overhead, all reads incur initialization cost
402-
// proportional to buffer size (#110650)
401+
// at the same time, i.e. small reads suffer from syscall overhead, all reads incur costs proportional to buffer size (#110650)
403402
//
404403
pub(crate) fn default_read_to_end<R: Read + ?Sized>(
405404
r: &mut R,
@@ -444,6 +443,8 @@ pub(crate) fn default_read_to_end<R: Read + ?Sized>(
444443
}
445444
}
446445

446+
let mut consecutive_short_reads = 0;
447+
447448
loop {
448449
if buf.len() == buf.capacity() && buf.capacity() == start_cap {
449450
// The buffer might be an exact fit. Let's read into a probe buffer
@@ -489,6 +490,12 @@ pub(crate) fn default_read_to_end<R: Read + ?Sized>(
489490
return Ok(buf.len() - start_len);
490491
}
491492

493+
if bytes_read < buf_len {
494+
consecutive_short_reads += 1;
495+
} else {
496+
consecutive_short_reads = 0;
497+
}
498+
492499
// store how much was initialized but not filled
493500
initialized = unfilled_but_initialized;
494501

@@ -503,7 +510,10 @@ pub(crate) fn default_read_to_end<R: Read + ?Sized>(
503510
// The reader is returning short reads but it doesn't call ensure_init().
504511
// In that case we no longer need to restrict read sizes to avoid
505512
// initialization costs.
506-
if !was_fully_initialized {
513+
// When reading from disk we usually don't get any short reads except at EOF.
514+
// So we wait for at least 2 short reads before uncapping the read buffer;
515+
// this helps with the Windows issue.
516+
if !was_fully_initialized && consecutive_short_reads > 1 {
507517
max_read_size = usize::MAX;
508518
}
509519

library/std/src/lib.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,17 @@
3232
//!
3333
//! Once you are familiar with the contents of the standard library you may
3434
//! begin to find the verbosity of the prose distracting. At this stage in your
35-
//! development you may want to press the `[-]` button near the top of the
36-
//! page to collapse it into a more skimmable view.
37-
//!
38-
//! While you are looking at that `[-]` button also notice the `source`
39-
//! link. Rust's API documentation comes with the source code and you are
40-
//! encouraged to read it. The standard library source is generally high
41-
//! quality and a peek behind the curtains is often enlightening.
35+
//! development you may want to press the <code>
36+
//! <svg width="0.75rem" height="0.75rem" viewBox="0 0 12 12"
37+
//! stroke="currentColor" fill="none">
38+
//! <path d="M2,2l4,4l4,-4M2,6l4,4l4,-4"/></svg> Summary</code> button near the
39+
//! top of the page to collapse it into a more skimmable view.
40+
//!
41+
//! While you are looking at the top of the page, also notice the
42+
//! <code>source</code> link. Rust's API documentation comes with the source
43+
//! code and you are encouraged to read it. The standard library source is
44+
//! generally high quality and a peek behind the curtains is
45+
//! often enlightening.
4246
//!
4347
//! # What is in the standard library documentation?
4448
//!

src/librustdoc/html/sources.rs

+27-8
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ pub(crate) fn render(cx: &mut Context<'_>, krate: &clean::Crate) -> Result<(), E
2626

2727
let dst = cx.dst.join("src").join(krate.name(cx.tcx()).as_str());
2828
cx.shared.ensure_dir(&dst)?;
29+
let crate_name = krate.name(cx.tcx());
30+
let crate_name = crate_name.as_str();
2931

30-
let mut collector = SourceCollector { dst, cx, emitted_local_sources: FxHashSet::default() };
32+
let mut collector =
33+
SourceCollector { dst, cx, emitted_local_sources: FxHashSet::default(), crate_name };
3134
collector.visit_crate(krate);
3235
Ok(())
3336
}
@@ -115,6 +118,8 @@ struct SourceCollector<'a, 'tcx> {
115118
/// Root destination to place all HTML output into
116119
dst: PathBuf,
117120
emitted_local_sources: FxHashSet<PathBuf>,
121+
122+
crate_name: &'a str,
118123
}
119124

120125
impl DocVisitor for SourceCollector<'_, '_> {
@@ -210,19 +215,22 @@ impl SourceCollector<'_, '_> {
210215
},
211216
);
212217

218+
let src_fname = p.file_name().expect("source has no filename").to_os_string();
219+
let mut fname = src_fname.clone();
220+
213221
let root_path = PathBuf::from("../../").join(root_path.into_inner());
214222
let mut root_path = root_path.to_string_lossy();
215223
if let Some(c) = root_path.as_bytes().last()
216224
&& *c != b'/'
217225
{
218226
root_path += "/";
219227
}
228+
let mut file_path = Path::new(&self.crate_name).join(&*cur.borrow());
229+
file_path.push(&fname);
230+
fname.push(".html");
220231
let mut cur = self.dst.join(cur.into_inner());
221232
shared.ensure_dir(&cur)?;
222233

223-
let src_fname = p.file_name().expect("source has no filename").to_os_string();
224-
let mut fname = src_fname.clone();
225-
fname.push(".html");
226234
cur.push(&fname);
227235

228236
let title = format!("{} - source", src_fname.to_string_lossy());
@@ -250,7 +258,7 @@ impl SourceCollector<'_, '_> {
250258
cx,
251259
&root_path,
252260
highlight::DecorationInfo::default(),
253-
SourceContext::Standalone,
261+
SourceContext::Standalone { file_path },
254262
)
255263
},
256264
&shared.style_files,
@@ -312,10 +320,11 @@ struct ScrapedSource<'a, Code: std::fmt::Display> {
312320
struct Source<Code: std::fmt::Display> {
313321
lines: RangeInclusive<usize>,
314322
code_html: Code,
323+
file_path: Option<(String, String)>,
315324
}
316325

317326
pub(crate) enum SourceContext<'a> {
318-
Standalone,
327+
Standalone { file_path: PathBuf },
319328
Embedded(ScrapedInfo<'a>),
320329
}
321330

@@ -344,9 +353,19 @@ pub(crate) fn print_src(
344353
});
345354
let lines = s.lines().count();
346355
match source_context {
347-
SourceContext::Standalone => {
348-
Source { lines: (1..=lines), code_html: code }.render_into(&mut writer).unwrap()
356+
SourceContext::Standalone { file_path } => Source {
357+
lines: (1..=lines),
358+
code_html: code,
359+
file_path: if let Some(file_name) = file_path.file_name()
360+
&& let Some(file_path) = file_path.parent()
361+
{
362+
Some((file_path.display().to_string(), file_name.display().to_string()))
363+
} else {
364+
None
365+
},
349366
}
367+
.render_into(&mut writer)
368+
.unwrap(),
350369
SourceContext::Embedded(info) => {
351370
let lines = (1 + info.offset)..=(lines + info.offset);
352371
ScrapedSource { info, lines, code_html: code }.render_into(&mut writer).unwrap();

src/librustdoc/html/static/css/noscript.css

+4-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ nav.sub {
6161
--copy-path-img-hover-filter: invert(35%);
6262
--code-example-button-color: #7f7f7f;
6363
--code-example-button-hover-color: #595959;
64+
--settings-menu-filter: invert(50%);
65+
--settings-menu-hover-filter: invert(35%);
6466
--codeblock-error-hover-color: rgb(255, 0, 0);
6567
--codeblock-error-color: rgba(255, 0, 0, .5);
6668
--codeblock-ignore-hover-color: rgb(255, 142, 0);
@@ -87,7 +89,6 @@ nav.sub {
8789
--search-tab-button-not-selected-background: #e6e6e6;
8890
--search-tab-button-selected-border-top-color: #0089ff;
8991
--search-tab-button-selected-background: #fff;
90-
--settings-menu-filter: none;
9192
--stab-background-color: #fff5d6;
9293
--stab-code-color: #000;
9394
--code-highlight-kw-color: #8959a8;
@@ -192,6 +193,8 @@ nav.sub {
192193
--search-tab-button-not-selected-background: #252525;
193194
--search-tab-button-selected-border-top-color: #0089ff;
194195
--search-tab-button-selected-background: #353535;
196+
--settings-menu-filter: invert(50%);
197+
--settings-menu-hover-filter: invert(65%);
195198
--stab-background-color: #314559;
196199
--stab-code-color: #e6e1cf;
197200
--code-highlight-kw-color: #ab8ac1;

0 commit comments

Comments
 (0)