Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #87847

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions library/alloc/src/raw_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,7 @@ impl<T, A: Allocator> RawVec<T, A> {
// We have an allocated chunk of memory, so we can bypass runtime
// checks to get our current layout.
unsafe {
let align = mem::align_of::<T>();
let size = mem::size_of::<T>() * self.cap;
let layout = Layout::from_size_align_unchecked(size, align);
let layout = Layout::array::<T>(self.cap).unwrap_unchecked();
Some((self.ptr.cast().into(), layout))
}
}
Expand Down Expand Up @@ -404,7 +402,8 @@ impl<T, A: Allocator> RawVec<T, A> {

fn capacity_from_bytes(excess: usize) -> usize {
debug_assert_ne!(mem::size_of::<T>(), 0);
excess / mem::size_of::<T>()
let size_of_item = Layout::new::<T>().pad_to_align().size();
excess / size_of_item
}

fn set_ptr(&mut self, ptr: NonNull<[u8]>) {
Expand Down Expand Up @@ -468,13 +467,17 @@ impl<T, A: Allocator> RawVec<T, A> {
assert!(amount <= self.capacity(), "Tried to shrink to a larger capacity");

let (ptr, layout) = if let Some(mem) = self.current_memory() { mem } else { return Ok(()) };
let new_size = amount * mem::size_of::<T>();

let ptr = unsafe {
let new_layout = Layout::from_size_align_unchecked(new_size, layout.align());
self.alloc
.shrink(ptr, layout, new_layout)
.map_err(|_| AllocError { layout: new_layout, non_exhaustive: () })?
// `Layout::array` cannot overflow here because it would have
// owerflown earlier when capacity was larger.
let new_layout = Layout::array::<T>(amount).unwrap_unchecked();
// We avoid `map_err` here because it bloats the amount of LLVM IR
// generated.
match self.alloc.shrink(ptr, layout, new_layout) {
Ok(ptr) => ptr,
Err(_) => Err(AllocError { layout: new_layout, non_exhaustive: () })?,
}
};
self.set_ptr(ptr);
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3452,7 +3452,7 @@ pub trait Iterator {
self.map(f).is_sorted()
}

/// See [TrustedRandomAccess]
/// See [TrustedRandomAccess][super::super::TrustedRandomAccess]
// The unusual name is to avoid name collisions in method resolution
// see #76479.
#[inline]
Expand Down
2 changes: 2 additions & 0 deletions library/std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2039,6 +2039,8 @@ pub fn remove_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
///
/// The iterator will yield instances of [`io::Result`]`<`[`DirEntry`]`>`.
/// New errors may be encountered after an iterator is initially constructed.
/// Entries for the current and parent directories (typically `.` and `..`) are
/// skipped.
///
/// # Platform-specific behavior
///
Expand Down
3 changes: 3 additions & 0 deletions src/bootstrap/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ mod dist {
fail_fast: true,
doc_tests: DocTests::No,
bless: false,
force_rerun: false,
compare_mode: None,
rustfix_coverage: false,
pass: None,
Expand Down Expand Up @@ -527,6 +528,7 @@ mod dist {
fail_fast: true,
doc_tests: DocTests::No,
bless: false,
force_rerun: false,
compare_mode: None,
rustfix_coverage: false,
pass: None,
Expand Down Expand Up @@ -583,6 +585,7 @@ mod dist {
fail_fast: true,
doc_tests: DocTests::Yes,
bless: false,
force_rerun: false,
compare_mode: None,
rustfix_coverage: false,
pass: None,
Expand Down
10 changes: 10 additions & 0 deletions src/bootstrap/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ pub enum Subcommand {
paths: Vec<PathBuf>,
/// Whether to automatically update stderr/stdout files
bless: bool,
force_rerun: bool,
compare_mode: Option<String>,
pass: Option<String>,
run: Option<String>,
Expand Down Expand Up @@ -284,6 +285,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
opts.optflag("", "no-doc", "do not run doc tests");
opts.optflag("", "doc", "only run doc tests");
opts.optflag("", "bless", "update all stderr/stdout files of failing ui tests");
opts.optflag("", "force-rerun", "rerun tests even if the inputs are unchanged");
opts.optopt(
"",
"compare-mode",
Expand Down Expand Up @@ -558,6 +560,7 @@ Arguments:
"test" | "t" => Subcommand::Test {
paths,
bless: matches.opt_present("bless"),
force_rerun: matches.opt_present("force-rerun"),
compare_mode: matches.opt_str("compare-mode"),
pass: matches.opt_str("pass"),
run: matches.opt_str("run"),
Expand Down Expand Up @@ -726,6 +729,13 @@ impl Subcommand {
}
}

pub fn force_rerun(&self) -> bool {
match *self {
Subcommand::Test { force_rerun, .. } => force_rerun,
_ => false,
}
}

pub fn rustfix_coverage(&self) -> bool {
match *self {
Subcommand::Test { rustfix_coverage, .. } => rustfix_coverage,
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,10 @@ note: if you're sure you want to do this, please open an issue as to why. In the
cmd.arg("--bless");
}

if builder.config.cmd.force_rerun() {
cmd.arg("--force-rerun");
}

let compare_mode =
builder.config.cmd.compare_mode().or_else(|| {
if builder.config.test_compare_mode { self.compare_mode } else { None }
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1937,7 +1937,7 @@ crate enum Variant {
Struct(VariantStruct),
}

/// Small wrapper around [`rustc_span::Span]` that adds helper methods
/// Small wrapper around [`rustc_span::Span`] that adds helper methods
/// and enforces calling [`rustc_span::Span::source_callsite()`].
#[derive(Copy, Clone, Debug)]
crate struct Span(rustc_span::Span);
Expand Down
3 changes: 3 additions & 0 deletions src/tools/compiletest/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@ pub struct Config {
pub nodejs: Option<String>,
/// Path to a npm executable. Used for rustdoc GUI tests
pub npm: Option<String>,

/// Whether to rerun tests even if the inputs are unchanged.
pub force_rerun: bool,
}

impl Config {
Expand Down
19 changes: 12 additions & 7 deletions src/tools/compiletest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
"enable this to generate a Rustfix coverage file, which is saved in \
`./<build_base>/rustfix_missing_coverage.txt`",
)
.optflag("", "force-rerun", "rerun tests even if the inputs are unchanged")
.optflag("h", "help", "show this message")
.reqopt("", "channel", "current Rust channel", "CHANNEL");

Expand Down Expand Up @@ -289,6 +290,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
llvm_components: matches.opt_str("llvm-components").unwrap(),
nodejs: matches.opt_str("nodejs"),
npm: matches.opt_str("npm"),

force_rerun: matches.opt_present("force-rerun"),
}
}

Expand Down Expand Up @@ -644,13 +647,15 @@ fn make_test(config: &Config, testpaths: &TestPaths, inputs: &Stamp) -> Vec<test
let test_name = crate::make_test_name(config, testpaths, revision);
let mut desc = make_test_description(config, test_name, &test_path, src_file, cfg);
// Ignore tests that already run and are up to date with respect to inputs.
desc.ignore |= is_up_to_date(
config,
testpaths,
&early_props,
revision.map(|s| s.as_str()),
inputs,
);
if !config.force_rerun {
desc.ignore |= is_up_to_date(
config,
testpaths,
&early_props,
revision.map(|s| s.as_str()),
inputs,
);
}
test::TestDescAndFn { desc, testfn: make_test_closure(config, testpaths, revision) }
})
.collect()
Expand Down
2 changes: 1 addition & 1 deletion src/tools/linkchecker/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ enum FileEntry {
/// An HTML file.
///
/// This includes the contents of the HTML file, and an optional set of
/// HTML IDs. The IDs are used for checking fragments. The are computed
/// HTML IDs. The IDs are used for checking fragments. They are computed
/// as-needed. The source is discarded (replaced with an empty string)
/// after the file has been checked, to conserve on memory.
HtmlFile { source: Rc<String>, ids: RefCell<HashSet<String>> },
Expand Down