Skip to content

Rollup of 9 pull requests #141066

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

Merged
merged 64 commits into from
May 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
80758c3
add rdg push git config entry for git protocol pushers
tshepang May 1, 2025
6e966d7
avoid duplicating commands
tshepang May 6, 2025
046bfb3
Preparing for merge from rustc
invalid-email-address May 8, 2025
659f0b6
Merge from rustc
invalid-email-address May 8, 2025
b2de3f4
Merge pull request #2374 from rust-lang/rustc-pull
tshepang May 8, 2025
47cd0e7
Fix minor typo in serialization.md
smanilov May 8, 2025
f52e1be
Merge pull request #2375 from smanilov/patch-4
tshepang May 8, 2025
b6c2a42
std: Make consistence between `From` and `Into`
xizheyin May 8, 2025
4101d90
std: Explain prefer `TryInto` over `TryFrom` when specifying traits b…
xizheyin May 8, 2025
d87763d
Remark test naming exception
smanilov May 8, 2025
f31bf4a
Merge pull request #2323 from smanilov/patch-2
BoxyUwU May 8, 2025
a07c71d
Fix minor typo in installation.md
smanilov May 8, 2025
079e0b4
Merge pull request #2377 from smanilov/patch-6
tshepang May 8, 2025
9eac7a3
move (and remove) impl Trait tests
lcnr May 9, 2025
3052683
Fix minor typo in rustdoc-internals.md
smanilov May 8, 2025
6831638
Merge pull request #2376 from smanilov/patch-5
tshepang May 9, 2025
0533ff7
more moved tests
lcnr May 9, 2025
90ec9da
Merge pull request #2369 from rust-lang/tshepang-patch-1
tshepang May 10, 2025
c1de624
link to chapter referred to
tshepang May 10, 2025
8c6c97d
use the right case
tshepang May 10, 2025
4e684a9
make more clear what is meant
tshepang May 10, 2025
9f07c1e
make more readable
tshepang May 10, 2025
2efa4e6
sembr
tshepang May 10, 2025
eb6749c
is a question
tshepang May 10, 2025
a82a329
fix broken links
tshepang May 10, 2025
5d8e19f
reduce clutter when reading source
tshepang May 10, 2025
7b9d7fc
sembr
tshepang May 10, 2025
f1d1ebc
last updated a year ago
tshepang May 10, 2025
52e4b4a
add missing word
tshepang May 10, 2025
927343e
no point versioning these
tshepang May 10, 2025
a9d6551
bump edition
tshepang May 10, 2025
63b3bf9
"cargo fmt"
tshepang May 10, 2025
58fa975
we are a collective
tshepang May 10, 2025
5a406be
noise
tshepang May 10, 2025
aeea472
Remove `stable` attribute from wasi fs (read_exact|write_all)_at
paolobarbolini May 10, 2025
2a0c72e
Remove obsolete reference to `unsized_tuple_coercion`
Zalathar May 12, 2025
53572cf
Merge pull request #2382 from Zalathar/no-tuple-unsize
JohnTitor May 12, 2025
436c363
Remove n.b. about parser refactoring
smanilov May 9, 2025
e983642
Merge pull request #2378 from smanilov/patch-7
jieyouxu May 12, 2025
b255ae2
remove dangling references
tshepang May 12, 2025
b9f4350
fix doc for UnixStream
mlowicki May 14, 2025
1267333
Improve ternary operator recovery
jamie-osec May 14, 2025
754b06f
Migrate to modern datetime API
emmanuel-ferdman May 14, 2025
e0b6363
wire up startupinfo methods
federico-terzi May 14, 2025
032f738
Merge pull request #2383 from rust-lang/tshepang-unused
tshepang May 14, 2025
b805dcb
Merge pull request #2380 from rust-lang/tshepang-crate-cleaning
tshepang May 14, 2025
30b54ad
Merge pull request #2379 from rust-lang/tshepang-which-chapter
tshepang May 14, 2025
05e7ce9
Merge pull request #2373 from rust-lang/tshepang-patch-2
tshepang May 14, 2025
3e051af
Add some negative test coverage for malformed `-Clink-self-contained`…
jieyouxu May 14, 2025
a716f1a
Add some negative test coverage for `-Zlinker-features` flag
jieyouxu May 14, 2025
5e3aa16
avoid upstream pull conflict
tshepang May 15, 2025
d016ed8
Merge pull request #2387 from rust-lang/tshepang-avoid-conflict
tshepang May 15, 2025
4adff2f
Preparing for merge from rustc
invalid-email-address May 15, 2025
1fd536c
Merge from rustc
invalid-email-address May 15, 2025
a3ce646
Merge pull request #2388 from rust-lang/rustc-pull
tshepang May 15, 2025
315296b
Rollup merge of #140791 - xizheyin:issue-140761, r=ibraheemdev
matthiaskrgr May 16, 2025
e4929b5
Rollup merge of #140834 - lcnr:apit-folder, r=compiler-errors
matthiaskrgr May 16, 2025
370cd22
Rollup merge of #140910 - paolobarbolini:wasi-fs-incorrect-stabilizat…
matthiaskrgr May 16, 2025
3237d4d
Rollup merge of #140984 - mlowicki:patch-2, r=ibraheemdev
matthiaskrgr May 16, 2025
953905f
Rollup merge of #140997 - jieyouxu:link-flags-negative-tests, r=lqd
matthiaskrgr May 16, 2025
e53b9f8
Rollup merge of #141003 - clubby789:ternary-improve, r=compiler-errors
matthiaskrgr May 16, 2025
9808b07
Rollup merge of #141009 - emmanuel-ferdman:master, r=marcoieni
matthiaskrgr May 16, 2025
03912f4
Rollup merge of #141013 - federico-terzi:feat/command_startupinfo_win…
matthiaskrgr May 16, 2025
5ce27f5
Rollup merge of #141026 - tshepang:rust-push, r=jieyouxu
matthiaskrgr May 16, 2025
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
3 changes: 2 additions & 1 deletion compiler/rustc_parse/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,6 @@ parse_switch_ref_box_order = switch the order of `ref` and `box`
.suggestion = swap them

parse_ternary_operator = Rust has no ternary operator
.help = use an `if-else` expression instead

parse_tilde_is_not_unary_operator = `~` cannot be used as a unary operator
.suggestion = use `!` to perform bitwise not
Expand Down Expand Up @@ -963,6 +962,8 @@ parse_use_empty_block_not_semi = expected { "`{}`" }, found `;`
parse_use_eq_instead = unexpected `==`
.suggestion = try using `=` instead

parse_use_if_else = use an `if-else` expression instead

parse_use_let_not_auto = write `let` instead of `auto` to introduce a new variable
parse_use_let_not_var = write `let` instead of `var` to introduce a new variable

Expand Down
20 changes: 19 additions & 1 deletion compiler/rustc_parse/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,10 +436,28 @@ pub(crate) enum IfExpressionMissingThenBlockSub {

#[derive(Diagnostic)]
#[diag(parse_ternary_operator)]
#[help]
pub(crate) struct TernaryOperator {
#[primary_span]
pub span: Span,
/// If we have a span for the condition expression, suggest the if/else
#[subdiagnostic]
pub sugg: Option<TernaryOperatorSuggestion>,
/// Otherwise, just print the suggestion message
#[help(parse_use_if_else)]
pub no_sugg: bool,
}

#[derive(Subdiagnostic, Copy, Clone)]
#[multipart_suggestion(parse_use_if_else, applicability = "maybe-incorrect", style = "verbose")]
pub(crate) struct TernaryOperatorSuggestion {
#[suggestion_part(code = "if ")]
pub before_cond: Span,
#[suggestion_part(code = "{{")]
pub question: Span,
#[suggestion_part(code = "}} else {{")]
pub colon: Span,
#[suggestion_part(code = " }}")]
pub end: Span,
}

#[derive(Subdiagnostic)]
Expand Down
34 changes: 25 additions & 9 deletions compiler/rustc_parse/src/parser/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ use crate::errors::{
IncorrectSemicolon, IncorrectUseOfAwait, IncorrectUseOfUse, PatternMethodParamWithoutBody,
QuestionMarkInType, QuestionMarkInTypeSugg, SelfParamNotFirst, StructLiteralBodyWithoutPath,
StructLiteralBodyWithoutPathSugg, SuggAddMissingLetStmt, SuggEscapeIdentifier, SuggRemoveComma,
TernaryOperator, UnexpectedConstInGenericParam, UnexpectedConstParamDeclaration,
UnexpectedConstParamDeclarationSugg, UnmatchedAngleBrackets, UseEqInstead, WrapType,
TernaryOperator, TernaryOperatorSuggestion, UnexpectedConstInGenericParam,
UnexpectedConstParamDeclaration, UnexpectedConstParamDeclarationSugg, UnmatchedAngleBrackets,
UseEqInstead, WrapType,
};
use crate::parser::attr::InnerAttrPolicy;
use crate::{exp, fluent_generated as fluent};
Expand Down Expand Up @@ -497,7 +498,7 @@ impl<'a> Parser<'a> {
// If the user is trying to write a ternary expression, recover it and
// return an Err to prevent a cascade of irrelevant diagnostics.
if self.prev_token == token::Question
&& let Err(e) = self.maybe_recover_from_ternary_operator()
&& let Err(e) = self.maybe_recover_from_ternary_operator(None)
{
return Err(e);
}
Expand Down Expand Up @@ -1602,12 +1603,18 @@ impl<'a> Parser<'a> {
/// Rust has no ternary operator (`cond ? then : else`). Parse it and try
/// to recover from it if `then` and `else` are valid expressions. Returns
/// an err if this appears to be a ternary expression.
pub(super) fn maybe_recover_from_ternary_operator(&mut self) -> PResult<'a, ()> {
/// If we have the span of the condition, we can provide a better error span
/// and code suggestion.
pub(super) fn maybe_recover_from_ternary_operator(
&mut self,
cond: Option<Span>,
) -> PResult<'a, ()> {
if self.prev_token != token::Question {
return PResult::Ok(());
}

let lo = self.prev_token.span.lo();
let question = self.prev_token.span;
let lo = cond.unwrap_or(question).lo();
let snapshot = self.create_snapshot_for_diagnostic();

if match self.parse_expr() {
Expand All @@ -1620,11 +1627,20 @@ impl<'a> Parser<'a> {
}
} {
if self.eat_noexpect(&token::Colon) {
let colon = self.prev_token.span;
match self.parse_expr() {
Ok(_) => {
return Err(self
.dcx()
.create_err(TernaryOperator { span: self.token.span.with_lo(lo) }));
Ok(expr) => {
let sugg = cond.map(|cond| TernaryOperatorSuggestion {
before_cond: cond.shrink_to_lo(),
question,
colon,
end: expr.span.shrink_to_hi(),
});
return Err(self.dcx().create_err(TernaryOperator {
span: self.prev_token.span.with_lo(lo),
sugg,
no_sugg: sugg.is_none(),
}));
}
Err(err) => {
err.cancel();
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_parse/src/parser/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,12 @@ impl<'a> Parser<'a> {
{
// Just check for errors and recover; do not eat semicolon yet.

let expect_result = self.expect_one_of(&[], &[exp!(Semi), exp!(CloseBrace)]);
let expect_result =
if let Err(e) = self.maybe_recover_from_ternary_operator(Some(expr.span)) {
Err(e)
} else {
self.expect_one_of(&[], &[exp!(Semi), exp!(CloseBrace)])
};

// Try to both emit a better diagnostic, and avoid further errors by replacing
// the `expr` with `ExprKind::Err`.
Expand Down
10 changes: 8 additions & 2 deletions library/core/src/convert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,8 @@ pub trait Into<T>: Sized {
/// orphaning rules.
/// See [`Into`] for more details.
///
/// Prefer using [`Into`] over using `From` when specifying trait bounds on a generic function.
/// This way, types that directly implement [`Into`] can be used as arguments as well.
/// Prefer using [`Into`] over [`From`] when specifying trait bounds on a generic function
/// to ensure that types that only implement [`Into`] can be used as well.
///
/// The `From` trait is also very useful when performing error handling. When constructing a function
/// that is capable of failing, the return type will generally be of the form `Result<T, E>`.
Expand Down Expand Up @@ -597,6 +597,9 @@ pub trait From<T>: Sized {
/// standard library. For more information on this, see the
/// documentation for [`Into`].
///
/// Prefer using [`TryInto`] over [`TryFrom`] when specifying trait bounds on a generic function
/// to ensure that types that only implement [`TryInto`] can be used as well.
///
/// # Implementing `TryInto`
///
/// This suffers the same restrictions and reasoning as implementing
Expand Down Expand Up @@ -636,6 +639,9 @@ pub trait TryInto<T>: Sized {
/// When the [`!`] type is stabilized [`Infallible`] and [`!`] will be
/// equivalent.
///
/// Prefer using [`TryInto`] over [`TryFrom`] when specifying trait bounds on a generic function
/// to ensure that types that only implement [`TryInto`] can be used as well.
///
/// `TryFrom<T>` can be implemented as follows:
///
/// ```
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/os/unix/net/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,11 @@ impl UnixStream {
///
/// ```no_run
/// use std::io;
/// use std::net::UdpSocket;
/// use std::os::unix::net::UnixStream;
/// use std::time::Duration;
///
/// fn main() -> std::io::Result<()> {
/// let socket = UdpSocket::bind("127.0.0.1:34254")?;
/// let socket = UnixStream::connect("/tmp/sock")?;
/// let result = socket.set_write_timeout(Some(Duration::new(0, 0)));
/// let err = result.unwrap_err();
/// assert_eq!(err.kind(), io::ErrorKind::InvalidInput);
Expand Down
2 changes: 0 additions & 2 deletions library/std/src/os/wasi/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ pub trait FileExt {
/// If this function returns an error, it is unspecified how many bytes it
/// has read, but it will never read more than would be necessary to
/// completely fill the buffer.
#[stable(feature = "rw_exact_all_at", since = "1.33.0")]
fn read_exact_at(&self, mut buf: &mut [u8], mut offset: u64) -> io::Result<()> {
while !buf.is_empty() {
match self.read_at(buf, offset) {
Expand Down Expand Up @@ -144,7 +143,6 @@ pub trait FileExt {
/// non-[`io::ErrorKind::Interrupted`] kind that [`write_at`] returns.
///
/// [`write_at`]: FileExt::write_at
#[stable(feature = "rw_exact_all_at", since = "1.33.0")]
fn write_all_at(&self, mut buf: &[u8], mut offset: u64) -> io::Result<()> {
while !buf.is_empty() {
match self.write_at(buf, offset) {
Expand Down
36 changes: 36 additions & 0 deletions library/std/src/os/windows/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,27 @@ pub trait CommandExt: Sealed {
&mut self,
attribute_list: &ProcThreadAttributeList<'_>,
) -> io::Result<process::Child>;

/// When true, sets the `STARTF_RUNFULLSCREEN` flag on the [STARTUPINFO][1] struct before passing it to `CreateProcess`.
///
/// [1]: https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/ns-processthreadsapi-startupinfoa
#[unstable(feature = "windows_process_extensions_startupinfo", issue = "141010")]
fn startupinfo_fullscreen(&mut self, enabled: bool) -> &mut process::Command;

/// When true, sets the `STARTF_UNTRUSTEDSOURCE` flag on the [STARTUPINFO][1] struct before passing it to `CreateProcess`.
///
/// [1]: https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/ns-processthreadsapi-startupinfoa
#[unstable(feature = "windows_process_extensions_startupinfo", issue = "141010")]
fn startupinfo_untrusted_source(&mut self, enabled: bool) -> &mut process::Command;

/// When specified, sets the following flags on the [STARTUPINFO][1] struct before passing it to `CreateProcess`:
/// - If `Some(true)`, sets `STARTF_FORCEONFEEDBACK`
/// - If `Some(false)`, sets `STARTF_FORCEOFFFEEDBACK`
/// - If `None`, does not set any flags
///
/// [1]: https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/ns-processthreadsapi-startupinfoa
#[unstable(feature = "windows_process_extensions_startupinfo", issue = "141010")]
fn startupinfo_force_feedback(&mut self, enabled: Option<bool>) -> &mut process::Command;
}

#[stable(feature = "windows_process_extensions", since = "1.16.0")]
Expand Down Expand Up @@ -385,6 +406,21 @@ impl CommandExt for process::Command {
.spawn_with_attributes(sys::process::Stdio::Inherit, true, Some(attribute_list))
.map(process::Child::from_inner)
}

fn startupinfo_fullscreen(&mut self, enabled: bool) -> &mut process::Command {
self.as_inner_mut().startupinfo_fullscreen(enabled);
self
}

fn startupinfo_untrusted_source(&mut self, enabled: bool) -> &mut process::Command {
self.as_inner_mut().startupinfo_untrusted_source(enabled);
self
}

fn startupinfo_force_feedback(&mut self, enabled: Option<bool>) -> &mut process::Command {
self.as_inner_mut().startupinfo_force_feedback(enabled);
self
}
}

#[unstable(feature = "windows_process_extensions_main_thread_handle", issue = "96723")]
Expand Down
36 changes: 36 additions & 0 deletions library/std/src/sys/process/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ pub struct Command {
stdout: Option<Stdio>,
stderr: Option<Stdio>,
force_quotes_enabled: bool,
startupinfo_fullscreen: bool,
startupinfo_untrusted_source: bool,
startupinfo_force_feedback: Option<bool>,
}

pub enum Stdio {
Expand Down Expand Up @@ -186,6 +189,9 @@ impl Command {
stdout: None,
stderr: None,
force_quotes_enabled: false,
startupinfo_fullscreen: false,
startupinfo_untrusted_source: false,
startupinfo_force_feedback: None,
}
}

Expand Down Expand Up @@ -222,6 +228,18 @@ impl Command {
self.args.push(Arg::Raw(command_str_to_append.to_os_string()))
}

pub fn startupinfo_fullscreen(&mut self, enabled: bool) {
self.startupinfo_fullscreen = enabled;
}

pub fn startupinfo_untrusted_source(&mut self, enabled: bool) {
self.startupinfo_untrusted_source = enabled;
}

pub fn startupinfo_force_feedback(&mut self, enabled: Option<bool>) {
self.startupinfo_force_feedback = enabled;
}

pub fn get_program(&self) -> &OsStr {
&self.program
}
Expand Down Expand Up @@ -343,6 +361,24 @@ impl Command {
si.wShowWindow = cmd_show;
}

if self.startupinfo_fullscreen {
si.dwFlags |= c::STARTF_RUNFULLSCREEN;
}

if self.startupinfo_untrusted_source {
si.dwFlags |= c::STARTF_UNTRUSTEDSOURCE;
}

match self.startupinfo_force_feedback {
Some(true) => {
si.dwFlags |= c::STARTF_FORCEONFEEDBACK;
}
Some(false) => {
si.dwFlags |= c::STARTF_FORCEOFFFEEDBACK;
}
None => {}
}

let si_ptr: *mut c::STARTUPINFOW;

let mut si_ex;
Expand Down
2 changes: 1 addition & 1 deletion src/ci/cpu-usage-over-time.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def idle_since(self, prev):
while True:
time.sleep(1)
next_state = State()
now = datetime.datetime.utcnow().isoformat()
now = datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None).isoformat()
idle = next_state.idle_since(cur_state)
print("%s,%s" % (now, idle))
sys.stdout.flush()
Expand Down
10 changes: 10 additions & 0 deletions src/doc/rustc-dev-guide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ Older versions of `josh-proxy` may not round trip commits losslessly so it is im
3) Push the branch to your fork and create a PR into `rustc-dev-guide`
### Push changes from this repository into `rust-lang/rust`
NOTE: If you use Git protocol to push to your fork of `rust-lang/rust`,
ensure that you have this entry in your Git config,
else the 2 steps that follow would prompt for a username and password:
```
[url "[email protected]:"]
insteadOf = "https://github.com/"
```
1) Run the push command to create a branch named `<branch-name>` in a `rustc` fork under the `<gh-username>` account
```
cargo run --manifest-path josh-sync/Cargo.toml rustc-push <branch-name> <gh-username>
Expand Down
Loading
Loading