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 5 pull requests #124710

Closed
wants to merge 76 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
b07c1f7
Improve several `Read` implementations
a1phyr Mar 13, 2024
23211b6
`VecDeque::read_to_string`: avoid making the slices contiguous
a1phyr Mar 14, 2024
2e3ee23
Avoid panicking branch in `append_to_string`
a1phyr Apr 10, 2024
2681edf
josh rustc-pull: check that no new root commits get created
RalfJung Apr 27, 2024
39f7a46
fix: usage of `deprecated` version of `Node.js`
hamirmahal Apr 27, 2024
f5ceb4e
Auto merge of #3519 - hamirmahal:fix/usage-of-deprecated-version-of-n…
bors Apr 27, 2024
45d9394
Auto merge of #3520 - RalfJung:josh-check, r=RalfJung
bors Apr 27, 2024
ee47a8e
Add doc comment to `pack_generic`
eduardosm Apr 27, 2024
b3b1b49
Clarify behavior of AVX2 gather when dest and offsets have different …
eduardosm Apr 27, 2024
b261535
Do not implement x86 SIMD abs with host integers
eduardosm Apr 27, 2024
5c6f95c
Auto merge of #3521 - eduardosm:avx2-2, r=RalfJung
bors Apr 28, 2024
b5482aa
file descriptors: make write take &mut self
RalfJung Apr 28, 2024
bc8ea93
Auto merge of #3524 - RalfJung:fd-write, r=RalfJung
bors Apr 28, 2024
622f697
Use the interpreted program's TZ variable in localtime_r
saethlin Apr 27, 2024
9bed19e
Refactor UnixEnvVars::get so that it can be reused by getenv
saethlin Apr 28, 2024
7afef08
don't leak UnixEnvVars impl details into get_env_var
RalfJung Apr 29, 2024
1c7e827
Auto merge of #3523 - saethlin:localtime_r-env, r=RalfJung
bors Apr 29, 2024
1cf951e
Don’t print `Preparing a sysroot` when `-q`/`--quiet` is passed
narpfel May 1, 2024
4b42626
fix usage example for `--print-sysroot`
narpfel May 1, 2024
a2b3211
no longer strip `Preparing a sysroot` message from test output
narpfel May 1, 2024
b0bdbcc
Auto merge of #3531 - narpfel:quiet-sysroot, r=RalfJung
bors May 1, 2024
aa986f0
Tree Borrows: first apply transition, then check protector with new '…
RalfJung May 2, 2024
ca3defe
Auto merge of #3532 - RalfJung:tb-protectors, r=RalfJung
bors May 2, 2024
36caaa9
update host-float comments
RalfJung May 2, 2024
f6c0090
Auto merge of #3535 - RalfJung:host-float, r=RalfJung
bors May 2, 2024
56bb517
Add assign
tiif May 2, 2024
aeef180
Preparing for merge from rustc
May 3, 2024
1d453a7
Merge from rustc
May 3, 2024
b348e41
update comments and URL
RalfJung May 3, 2024
3c6d194
Auto merge of #3536 - tiif:add_rustbot_feat, r=RalfJung
bors May 3, 2024
cde5f68
update lockfile
RalfJung May 3, 2024
45c1a6c
Auto merge of #3537 - rust-lang:rustup-2024-05-03, r=RalfJung
bors May 3, 2024
413bac5
run clippy on a Windows host
RalfJung May 3, 2024
c9b350a
Auto merge of #3542 - RalfJung:clippy-win, r=RalfJung
bors May 3, 2024
01bfef9
Preparing for merge from rustc
RalfJung May 3, 2024
84adaac
Auto merge of #3544 - RalfJung:rustup, r=RalfJung
bors May 3, 2024
803201a
./miri run: support -v flag to print what it is doing
RalfJung May 3, 2024
fa10e6f
Auto merge of #3545 - RalfJung:miri-run, r=RalfJung
bors May 3, 2024
4dd8e0b
CI: no need to surround if: condition in expansion braces
RalfJung May 3, 2024
3e0d531
Auto merge of #3547 - RalfJung:ci, r=RalfJung
bors May 3, 2024
39ddcc6
make many-seeds a mode of ./miri run rather than a separate command
RalfJung May 3, 2024
20fcbaa
remove a hack that is no longer needed
RalfJung May 4, 2024
1961b8b
Auto merge of #3548 - RalfJung:many-seeds, r=RalfJung
bors May 4, 2024
f1de4c1
Use `unchecked_sub` in `split_at`
scottmcm May 4, 2024
4082c24
tls dtors: treat all unixes uniformly
RalfJung May 4, 2024
7df633d
Auto merge of #3550 - RalfJung:unix-tls, r=RalfJung
bors May 4, 2024
45670bf
macos: use getentropy from libc
RalfJung May 4, 2024
37bd816
Auto merge of #3551 - RalfJung:getentropy, r=RalfJung
bors May 4, 2024
459c6ce
Make file descriptors into refcount references
Luv-Ray May 4, 2024
da6a18e
speed up Windows runner: don't run GC_STRESS test
RalfJung May 4, 2024
4ea88d5
show time taken in run_tests_minimal
RalfJung May 4, 2024
d90acac
Auto merge of #3533 - Luv-Ray:file-descriptors-to-refcount-references…
bors May 4, 2024
e944afd
move available-parallelism tests into shims/ folder
RalfJung May 4, 2024
6b82ec2
rename integer test
RalfJung May 4, 2024
5648735
move intrinsics implementations and tests into dedicated folder
RalfJung May 4, 2024
f43e3e2
Fix ignored tests for formatting
Urgau May 4, 2024
c484fd2
fix grouping of target-specific LLVM shims
RalfJung May 4, 2024
d7ad3da
move some minimal targets over to the macOS runner, to even out CI times
RalfJung May 4, 2024
90fb25a
Auto merge of #3556 - RalfJung:intrinsics, r=RalfJung
bors May 4, 2024
a551b4d
Auto merge of #3552 - RalfJung:ci, r=RalfJung
bors May 4, 2024
ab2168b
update 'unsupported' message
RalfJung May 4, 2024
4529e67
freebsd: test std threadname and fs APIs
RalfJung May 4, 2024
86bd0a8
document unofficially supported OSes
RalfJung May 4, 2024
99c5151
make some tests not need output (so they work on wasm)
RalfJung May 4, 2024
58efad4
Auto merge of #3558 - RalfJung:unsupported, r=RalfJung
bors May 4, 2024
5748d79
Auto merge of #3554 - RalfJung:freebsd, r=RalfJung
bors May 4, 2024
8bffd88
add helper function to declare an extern static for a weak symbol
RalfJung May 4, 2024
1572c0d
Various improvements to entrypoint code
Noratrieb May 1, 2024
99f77ac
make statx a regular function (so we don't need to support the syscall)
RalfJung May 4, 2024
8dc063c
Auto merge of #3559 - RalfJung:weak-extern-static, r=RalfJung
bors May 4, 2024
dc0cc72
update lockfile
RalfJung May 4, 2024
76dc302
Rollup merge of #122441 - a1phyr:improve_read_impls, r=ChrisDenton
matthiaskrgr May 4, 2024
6a6462a
Rollup merge of #124584 - Nilstrieb:entrypointy, r=fee1-dead
matthiaskrgr May 4, 2024
f226a67
Rollup merge of #124699 - scottmcm:split_at_unchecked_should_use_unch…
matthiaskrgr May 4, 2024
2ab5f46
Rollup merge of #124704 - Urgau:fix-ignored-tests-fmt, r=GuillaumeGomez
matthiaskrgr May 4, 2024
ee62903
Rollup merge of #124709 - RalfJung:miri-sync, r=RalfJung
matthiaskrgr May 4, 2024
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
88 changes: 79 additions & 9 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,28 @@ dependencies = [
"windows-targets 0.52.4",
]

[[package]]
name = "chrono-tz"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93698b29de5e97ad0ae26447b344c482a7284c737d9ddc5f9e52b74a336671bb"
dependencies = [
"chrono",
"chrono-tz-build",
"phf 0.11.2",
]

[[package]]
name = "chrono-tz-build"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c088aee841df9c3041febbb73934cfc39708749bf96dc827e3359cd39ef11b1"
dependencies = [
"parse-zoneinfo",
"phf 0.11.2",
"phf_codegen 0.11.2",
]

[[package]]
name = "cipher"
version = "0.4.4"
Expand Down Expand Up @@ -2318,8 +2340,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a2629bb1404f3d34c2e921f21fd34ba00b206124c81f65c50b43b6aaefeb016"
dependencies = [
"log",
"phf",
"phf_codegen",
"phf 0.10.1",
"phf_codegen 0.10.0",
"string_cache",
"string_cache_codegen",
"tendril",
Expand Down Expand Up @@ -2480,6 +2502,7 @@ version = "0.1.0"
dependencies = [
"aes",
"chrono",
"chrono-tz",
"colored",
"ctrlc",
"directories",
Expand Down Expand Up @@ -2835,6 +2858,15 @@ dependencies = [
"windows-targets 0.48.5",
]

[[package]]
name = "parse-zoneinfo"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f2a05b18d44e2957b88f96ba460715e295bc1d7510468a2f3d3b44535d26c24"
dependencies = [
"regex",
]

[[package]]
name = "pathdiff"
version = "0.2.1"
Expand Down Expand Up @@ -2907,7 +2939,16 @@ version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259"
dependencies = [
"phf_shared",
"phf_shared 0.10.0",
]

[[package]]
name = "phf"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc"
dependencies = [
"phf_shared 0.11.2",
]

[[package]]
Expand All @@ -2916,8 +2957,18 @@ version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fb1c3a8bc4dd4e5cfce29b44ffc14bedd2ee294559a294e2a4d4c9e9a6a13cd"
dependencies = [
"phf_generator",
"phf_shared",
"phf_generator 0.10.0",
"phf_shared 0.10.0",
]

[[package]]
name = "phf_codegen"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8d39688d359e6b34654d328e262234662d16cc0f60ec8dcbe5e718709342a5a"
dependencies = [
"phf_generator 0.11.2",
"phf_shared 0.11.2",
]

[[package]]
Expand All @@ -2926,7 +2977,17 @@ version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6"
dependencies = [
"phf_shared",
"phf_shared 0.10.0",
"rand",
]

[[package]]
name = "phf_generator"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0"
dependencies = [
"phf_shared 0.11.2",
"rand",
]

Expand All @@ -2939,6 +3000,15 @@ dependencies = [
"siphasher",
]

[[package]]
name = "phf_shared"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b"
dependencies = [
"siphasher",
]

[[package]]
name = "pin-project-lite"
version = "0.2.14"
Expand Down Expand Up @@ -5285,7 +5355,7 @@ dependencies = [
"new_debug_unreachable",
"once_cell",
"parking_lot",
"phf_shared",
"phf_shared 0.10.0",
"precomputed-hash",
"serde",
]
Expand All @@ -5296,8 +5366,8 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6bb30289b722be4ff74a408c3cc27edeaad656e06cb1fe8fa9231fa59c728988"
dependencies = [
"phf_generator",
"phf_shared",
"phf_generator 0.10.0",
"phf_shared 0.10.0",
"proc-macro2",
"quote",
]
Expand Down
26 changes: 25 additions & 1 deletion compiler/rustc_ast/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,35 @@ use rustc_span::Symbol;

#[derive(Debug)]
pub enum EntryPointType {
/// This function is not an entrypoint.
None,
/// This is a function called `main` at the root level.
/// ```
/// fn main() {}
/// ```
MainNamed,
/// This is a function with the `#[rustc_main]` attribute.
/// Used by the testing harness to create the test entrypoint.
/// ```ignore (clashes with test entrypoint)
/// #[rustc_main]
/// fn main() {}
/// ```
RustcMainAttr,
/// This is a function with the `#[start]` attribute.
/// ```ignore (clashes with test entrypoint)
/// #[start]
/// fn main() {}
/// ```
Start,
OtherMain, // Not an entry point, but some other function named main
/// This function is **not** an entrypoint but simply named `main` (not at the root).
/// This is only used for diagnostics.
/// ```
/// #[allow(dead_code)]
/// mod meow {
/// fn main() {}
/// }
/// ```
OtherMain,
}

pub fn entry_point_type(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/test_harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ fn generate_test_harness(
///
/// By default this expands to
///
/// ```ignore UNSOLVED (I think I still need guidance for this one. Is it correct? Do we try to make it run? How do we nicely fill it out?)
/// ```ignore (messes with test internals)
/// #[rustc_main]
/// pub fn main() {
/// extern crate test;
Expand Down
6 changes: 0 additions & 6 deletions compiler/rustc_passes/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ passes_attr_crate_level =
passes_attr_only_in_functions =
`{$attr}` attribute can only be used on functions

passes_attr_only_on_main =
`{$attr}` attribute can only be used on `fn main()`

passes_attr_only_on_root_main =
`{$attr}` attribute can only be used on root `fn main()`

passes_both_ffi_const_and_pure =
`#[ffi_const]` function cannot be `#[ffi_pure]`

Expand Down
42 changes: 23 additions & 19 deletions compiler/rustc_passes/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ use crate::errors::{
struct EntryContext<'tcx> {
tcx: TyCtxt<'tcx>,

/// The function that has attribute named `main`.
attr_main_fn: Option<(LocalDefId, Span)>,
/// The function has the `#[rustc_main]` attribute.
rustc_main_fn: Option<(LocalDefId, Span)>,

/// The function that has the attribute 'start' on it.
/// The function that has the attribute `#[start]` on it.
start_fn: Option<(LocalDefId, Span)>,

/// The functions that one might think are `main` but aren't, e.g.
Expand All @@ -42,10 +42,10 @@ fn entry_fn(tcx: TyCtxt<'_>, (): ()) -> Option<(DefId, EntryFnType)> {
}

let mut ctxt =
EntryContext { tcx, attr_main_fn: None, start_fn: None, non_main_fns: Vec::new() };
EntryContext { tcx, rustc_main_fn: None, start_fn: None, non_main_fns: Vec::new() };

for id in tcx.hir().items() {
find_item(id, &mut ctxt);
check_and_search_item(id, &mut ctxt);
}

configure_main(tcx, &ctxt)
Expand All @@ -56,7 +56,16 @@ fn attr_span_by_symbol(ctxt: &EntryContext<'_>, id: ItemId, sym: Symbol) -> Opti
attr::find_by_name(attrs, sym).map(|attr| attr.span)
}

fn find_item(id: ItemId, ctxt: &mut EntryContext<'_>) {
fn check_and_search_item(id: ItemId, ctxt: &mut EntryContext<'_>) {
if !matches!(ctxt.tcx.def_kind(id.owner_id), DefKind::Fn) {
for attr in [sym::start, sym::rustc_main] {
if let Some(span) = attr_span_by_symbol(ctxt, id, attr) {
ctxt.tcx.dcx().emit_err(AttrOnlyInFunctions { span, attr });
}
}
return;
}

let at_root = ctxt.tcx.opt_local_parent(id.owner_id.def_id) == Some(CRATE_DEF_ID);

let attrs = ctxt.tcx.hir().attrs(id.hir_id());
Expand All @@ -65,26 +74,20 @@ fn find_item(id: ItemId, ctxt: &mut EntryContext<'_>) {
at_root,
ctxt.tcx.opt_item_name(id.owner_id.to_def_id()),
);

match entry_point_type {
EntryPointType::None => (),
_ if !matches!(ctxt.tcx.def_kind(id.owner_id), DefKind::Fn) => {
for attr in [sym::start, sym::rustc_main] {
if let Some(span) = attr_span_by_symbol(ctxt, id, attr) {
ctxt.tcx.dcx().emit_err(AttrOnlyInFunctions { span, attr });
}
}
}
EntryPointType::MainNamed => (),
EntryPointType::None => {}
EntryPointType::MainNamed => {}
EntryPointType::OtherMain => {
ctxt.non_main_fns.push(ctxt.tcx.def_span(id.owner_id));
}
EntryPointType::RustcMainAttr => {
if ctxt.attr_main_fn.is_none() {
ctxt.attr_main_fn = Some((id.owner_id.def_id, ctxt.tcx.def_span(id.owner_id)));
if ctxt.rustc_main_fn.is_none() {
ctxt.rustc_main_fn = Some((id.owner_id.def_id, ctxt.tcx.def_span(id.owner_id)));
} else {
ctxt.tcx.dcx().emit_err(MultipleRustcMain {
span: ctxt.tcx.def_span(id.owner_id.to_def_id()),
first: ctxt.attr_main_fn.unwrap().1,
first: ctxt.rustc_main_fn.unwrap().1,
additional: ctxt.tcx.def_span(id.owner_id.to_def_id()),
});
}
Expand All @@ -107,10 +110,11 @@ fn find_item(id: ItemId, ctxt: &mut EntryContext<'_>) {
fn configure_main(tcx: TyCtxt<'_>, visitor: &EntryContext<'_>) -> Option<(DefId, EntryFnType)> {
if let Some((def_id, _)) = visitor.start_fn {
Some((def_id.to_def_id(), EntryFnType::Start))
} else if let Some((local_def_id, _)) = visitor.attr_main_fn {
} else if let Some((local_def_id, _)) = visitor.rustc_main_fn {
let def_id = local_def_id.to_def_id();
Some((def_id, EntryFnType::Main { sigpipe: sigpipe(tcx) }))
} else {
// The actual resolution of main happens in the resolver, this here
if let Some(main_def) = tcx.resolutions(()).main_def
&& let Some(def_id) = main_def.opt_fn_def_id()
{
Expand Down
16 changes: 0 additions & 16 deletions compiler/rustc_passes/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1206,22 +1206,6 @@ pub struct NakedFunctionsMustUseNoreturn {
pub last_span: Span,
}

#[derive(Diagnostic)]
#[diag(passes_attr_only_on_main)]
pub struct AttrOnlyOnMain {
#[primary_span]
pub span: Span,
pub attr: Symbol,
}

#[derive(Diagnostic)]
#[diag(passes_attr_only_on_root_main)]
pub struct AttrOnlyOnRootMain {
#[primary_span]
pub span: Span,
pub attr: Symbol,
}

#[derive(Diagnostic)]
#[diag(passes_attr_only_in_functions)]
pub struct AttrOnlyInFunctions {
Expand Down
11 changes: 8 additions & 3 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use crate::cmp::Ordering::{self, Equal, Greater, Less};
use crate::fmt;
use crate::hint;
use crate::intrinsics::exact_div;
use crate::intrinsics::{exact_div, unchecked_sub};
use crate::mem::{self, SizedTypeProperties};
use crate::num::NonZero;
use crate::ops::{Bound, OneSidedRange, Range, RangeBounds};
Expand Down Expand Up @@ -1983,7 +1983,7 @@ impl<T> [T] {
);

// SAFETY: Caller has to check that `0 <= mid <= self.len()`
unsafe { (from_raw_parts(ptr, mid), from_raw_parts(ptr.add(mid), len - mid)) }
unsafe { (from_raw_parts(ptr, mid), from_raw_parts(ptr.add(mid), unchecked_sub(len, mid))) }
}

/// Divides one mutable slice into two at an index, without doing bounds checking.
Expand Down Expand Up @@ -2035,7 +2035,12 @@ impl<T> [T] {
//
// `[ptr; mid]` and `[mid; len]` are not overlapping, so returning a mutable reference
// is fine.
unsafe { (from_raw_parts_mut(ptr, mid), from_raw_parts_mut(ptr.add(mid), len - mid)) }
unsafe {
(
from_raw_parts_mut(ptr, mid),
from_raw_parts_mut(ptr.add(mid), unchecked_sub(len, mid)),
)
}
}

/// Divides one slice into two at an index, returning `None` if the slice is
Expand Down
21 changes: 21 additions & 0 deletions library/std/src/io/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,27 @@ where
self.pos += n as u64;
Ok(())
}

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
let content = self.remaining_slice();
let len = content.len();
buf.try_reserve(len)?;
buf.extend_from_slice(content);
self.pos += len as u64;

Ok(len)
}

fn read_to_string(&mut self, buf: &mut String) -> io::Result<usize> {
let content =
crate::str::from_utf8(self.remaining_slice()).map_err(|_| io::Error::INVALID_UTF8)?;
let len = content.len();
buf.try_reserve(len)?;
buf.push_str(content);
self.pos += len as u64;

Ok(len)
}
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
Loading
Loading