Skip to content

Rollup of 9 pull requests #114869

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

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
971427e
Fix #114608
g0djan Aug 8, 2023
591b547
Point out expectation even if we have RegionsInsufficientlyPolymorphic
compiler-errors Aug 9, 2023
b75351e
Optimized implementations of max, min, and clamp for bool
danflapjax Aug 11, 2023
dc9b61d
Improve code readability by moving fmt args directly into the string
GuillaumeGomez Aug 14, 2023
c3889d1
Fix typos in unstable-book
xzmeng Aug 14, 2023
f8bda18
Fix typos in rustc doc platform netbsd
xzmeng Aug 14, 2023
1b6cf74
Fix typos in rustc doc platform aarch64-unknown-teeos
xzmeng Aug 14, 2023
29a1e46
Fix typos in rustc doc codegen-options
xzmeng Aug 14, 2023
aa6c02d
Fix typos in rustc doc platform loongarch-linux
xzmeng Aug 14, 2023
fe6d541
Fix typos in rustc doc platform x86_64h-apple-darwin
xzmeng Aug 14, 2023
fb07077
add missing feature(error_in_core)
RalfJung Aug 15, 2023
9f21e6d
Use more named format args
GuillaumeGomez Aug 15, 2023
a826cdb
Migrate GUI colors test to original CSS color format
GuillaumeGomez Aug 15, 2023
a741a5a
Document Default for ExitStatus
ijackson Aug 7, 2023
e1e6c00
fix typo: affect -> effect
RalfJung Aug 15, 2023
5692c94
Rollup merge of #114588 - ijackson:exit-status-default-2, r=m-ou-se
GuillaumeGomez Aug 15, 2023
3a88030
Rollup merge of #114619 - g0djan:godjan/fix_#114608, r=m-ou-se
GuillaumeGomez Aug 15, 2023
8f1369e
Rollup merge of #114644 - compiler-errors:lt-err, r=wesleywiser
GuillaumeGomez Aug 15, 2023
1f28a76
Rollup merge of #114721 - danflapjax:bool-ord-optimization, r=cuviper
GuillaumeGomez Aug 15, 2023
ffabd64
Rollup merge of #114822 - GuillaumeGomez:code-readability-improvement…
GuillaumeGomez Aug 15, 2023
4915a3e
Rollup merge of #114826 - xzmeng:fix-typos, r=JohnTitor
GuillaumeGomez Aug 15, 2023
27e92e3
Rollup merge of #114837 - RalfJung:error_in_core, r=cuviper
GuillaumeGomez Aug 15, 2023
1261a7f
Rollup merge of #114853 - GuillaumeGomez:migrate-gui-test-color-33, r…
GuillaumeGomez Aug 15, 2023
8ebf823
Rollup merge of #114861 - RalfJung:no-effect, r=wesleywiser
GuillaumeGomez Aug 15, 2023
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
5 changes: 1 addition & 4 deletions compiler/rustc_hir_typeck/src/coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1650,10 +1650,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {

augment_error(&mut err);

let is_insufficiently_polymorphic =
matches!(coercion_error, TypeError::RegionsInsufficientlyPolymorphic(..));

if !is_insufficiently_polymorphic && let Some(expr) = expression {
if let Some(expr) = expression {
fcx.emit_coerce_suggestions(
&mut err,
expr,
Expand Down
24 changes: 8 additions & 16 deletions compiler/rustc_hir_typeck/src/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

self.annotate_expected_due_to_let_ty(err, expr, error);

// FIXME(#73154): For now, we do leak check when coercing function
// pointers in typeck, instead of only during borrowck. This can lead
// to these `RegionsInsufficientlyPolymorphic` errors that aren't helpful.
if matches!(error, Some(TypeError::RegionsInsufficientlyPolymorphic(..))) {
return;
}

if self.is_destruct_assignment_desugaring(expr) {
return;
}
Expand Down Expand Up @@ -263,22 +270,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let expr_ty = self.resolve_vars_if_possible(checked_ty);
let mut err = self.err_ctxt().report_mismatched_types(&cause, expected, expr_ty, e);

let is_insufficiently_polymorphic =
matches!(e, TypeError::RegionsInsufficientlyPolymorphic(..));

// FIXME(#73154): For now, we do leak check when coercing function
// pointers in typeck, instead of only during borrowck. This can lead
// to these `RegionsInsufficientlyPolymorphic` errors that aren't helpful.
if !is_insufficiently_polymorphic {
self.emit_coerce_suggestions(
&mut err,
expr,
expr_ty,
expected,
expected_ty_expr,
Some(e),
);
}
self.emit_coerce_suggestions(&mut err, expr, expr_ty, expected, expected_ty_expr, Some(e));

(expected, Some(err))
}
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1927,7 +1927,12 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
true
};

if should_suggest_fixes {
// FIXME(#73154): For now, we do leak check when coercing function
// pointers in typeck, instead of only during borrowck. This can lead
// to these `RegionsInsufficientlyPolymorphic` errors that aren't helpful.
if should_suggest_fixes
&& !matches!(terr, TypeError::RegionsInsufficientlyPolymorphic(..))
{
self.suggest_tuple_pattern(cause, &exp_found, diag);
self.suggest_accessing_field_where_appropriate(cause, &exp_found, diag);
self.suggest_await_on_expect_found(cause, span, &exp_found, diag);
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

// To run alloc tests without x.py without ending up with two copies of alloc, Miri needs to be
// able to "empty" this crate. See <https://github.com/rust-lang/miri-test-libstd/issues/4>.
// rustc itself never sets the feature, so this line has no affect there.
// rustc itself never sets the feature, so this line has no effect there.
#![cfg(any(not(feature = "miri-test-libstd"), test, doctest))]
//
#![allow(unused_attributes)]
Expand Down
16 changes: 16 additions & 0 deletions library/core/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,22 @@ mod impls {
_ => unsafe { unreachable_unchecked() },
}
}

#[inline]
fn min(self, other: bool) -> bool {
self & other
}

#[inline]
fn max(self, other: bool) -> bool {
self | other
}

#[inline]
fn clamp(self, min: bool, max: bool) -> bool {
assert!(min <= max);
self.max(min).min(max)
}
}

ord_impl! { char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
Expand Down
10 changes: 10 additions & 0 deletions library/core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ pub trait Error: Debug + Display {
///
/// ```rust
/// #![feature(error_generic_member_access)]
/// #![feature(error_in_core)]
/// use core::fmt;
/// use core::error::{request_ref, Request};
///
Expand Down Expand Up @@ -360,6 +361,7 @@ impl dyn Error {
///
/// ```rust
/// # #![feature(error_generic_member_access)]
/// # #![feature(error_in_core)]
/// use std::error::Error;
/// use core::error::request_value;
///
Expand All @@ -383,6 +385,7 @@ where
///
/// ```rust
/// # #![feature(error_generic_member_access)]
/// # #![feature(error_in_core)]
/// use core::error::Error;
/// use core::error::request_ref;
///
Expand Down Expand Up @@ -454,6 +457,7 @@ where
///
/// ```
/// #![feature(error_generic_member_access)]
/// #![feature(error_in_core)]
/// use core::fmt;
/// use core::error::Request;
/// use core::error::request_ref;
Expand Down Expand Up @@ -524,6 +528,7 @@ impl<'a> Request<'a> {
///
/// ```rust
/// #![feature(error_generic_member_access)]
/// #![feature(error_in_core)]
///
/// use core::error::Request;
///
Expand Down Expand Up @@ -558,6 +563,7 @@ impl<'a> Request<'a> {
///
/// ```rust
/// #![feature(error_generic_member_access)]
/// #![feature(error_in_core)]
///
/// use core::error::Request;
///
Expand Down Expand Up @@ -593,6 +599,7 @@ impl<'a> Request<'a> {
///
/// ```rust
/// #![feature(error_generic_member_access)]
/// #![feature(error_in_core)]
///
/// use core::error::Request;
///
Expand Down Expand Up @@ -625,6 +632,7 @@ impl<'a> Request<'a> {
///
/// ```rust
/// #![feature(error_generic_member_access)]
/// #![feature(error_in_core)]
///
/// use core::error::Request;
///
Expand Down Expand Up @@ -691,6 +699,7 @@ impl<'a> Request<'a> {
///
/// ```rust
/// #![feature(error_generic_member_access)]
/// #![feature(error_in_core)]
///
/// use core::error::Request;
/// use core::error::request_value;
Expand Down Expand Up @@ -778,6 +787,7 @@ impl<'a> Request<'a> {
///
/// ```rust
/// #![feature(error_generic_member_access)]
/// #![feature(error_in_core)]
///
/// use core::error::Request;
/// use core::error::request_ref;
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#![cfg(not(test))]
// To run core tests without x.py without ending up with two copies of core, Miri needs to be
// able to "empty" this crate. See <https://github.com/rust-lang/miri-test-libstd/issues/4>.
// rustc itself never sets the feature, so this line has no affect there.
// rustc itself never sets the feature, so this line has no effect there.
#![cfg(any(not(feature = "miri-test-libstd"), test, doctest))]
#![stable(feature = "core", since = "1.6.0")]
#![doc(
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@

// To run std tests without x.py without ending up with two copies of std, Miri needs to be
// able to "empty" this crate. See <https://github.com/rust-lang/miri-test-libstd/issues/4>.
// rustc itself never sets the feature, so this line has no affect there.
// rustc itself never sets the feature, so this line has no effect there.
#![cfg(any(not(feature = "miri-test-libstd"), test, doctest))]
// miri-test-libstd also prefers to make std use the sysroot versions of the dependencies.
#![cfg_attr(feature = "miri-test-libstd", feature(rustc_private))]
Expand Down
11 changes: 10 additions & 1 deletion library/std/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1530,10 +1530,19 @@ impl From<fs::File> for Stdio {
// vs `_exit`. Naming of Unix system calls is not standardised across Unices, so terminology is a
// matter of convention and tradition. For clarity we usually speak of `exit`, even when we might
// mean an underlying system call such as `_exit`.
#[derive(PartialEq, Eq, Clone, Copy, Debug, Default)]
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
#[stable(feature = "process", since = "1.0.0")]
pub struct ExitStatus(imp::ExitStatus);

/// The default value is one which indicates successful completion.
#[stable(feature = "process-exitcode-default", since = "CURRENT_RUSTC_VERSION")]
impl Default for ExitStatus {
fn default() -> Self {
// Ideally this would be done by ExitCode::default().into() but that is complicated.
ExitStatus::from_inner(imp::ExitStatus::default())
}
}

/// Allows extension traits within `std`.
#[unstable(feature = "sealed", issue = "none")]
impl crate::sealed::Sealed for ExitStatus {}
Expand Down
6 changes: 3 additions & 3 deletions library/std/src/sys/wasi/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ cfg_if::cfg_if! {
// https://github.com/WebAssembly/wasi-libc/blob/a6f871343313220b76009827ed0153586361c0d5/libc-top-half/musl/include/alltypes.h.in#L108
#[repr(C)]
union pthread_attr_union {
__i: [ffi::c_int; if mem::size_of::<ffi::c_int>() == 8 { 14 } else { 9 }],
__vi: [ffi::c_int; if mem::size_of::<ffi::c_int>() == 8 { 14 } else { 9 }],
__s: [ffi::c_ulong; if mem::size_of::<ffi::c_int>() == 8 { 7 } else { 9 }],
__i: [ffi::c_int; if mem::size_of::<ffi::c_long>() == 8 { 14 } else { 9 }],
__vi: [ffi::c_int; if mem::size_of::<ffi::c_long>() == 8 { 14 } else { 9 }],
__s: [ffi::c_ulong; if mem::size_of::<ffi::c_long>() == 8 { 7 } else { 9 }],
}

#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustc/src/codegen-options/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ See the [Symbol Mangling] chapter for details on symbol mangling and the manglin
This instructs `rustc` to generate code specifically for a particular processor.

You can run `rustc --print target-cpus` to see the valid options to pass
and the default target CPU for the current buid target.
and the default target CPU for the current build target.
Each target has a default base CPU. Special values include:

* `native` can be passed to use the processor of the host machine.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ It's very small that there is no RwLock, no network, no stdin, and no file syste
Some abbreviation:
| Abbreviation | The full text | Description |
| ---- | ---- | ---- |
| TEE | Trusted Execution Environment | ARM TrustZone devide the system into two worlds/modes -- the secure world/mode and the normal world/mode. TEE is in the secure world/mode. |
| TEE | Trusted Execution Environment | ARM TrustZone divides the system into two worlds/modes -- the secure world/mode and the normal world/mode. TEE is in the secure world/mode. |
| REE | Rich Execution Environment | The normal world. for example, Linux for Android phone is in REE side. |
| TA | Trusted Application | The app run in TEE side system. |
| CA | Client Application | The progress run in REE side system. |
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustc/src/platform-support/loongarch-linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ CXX_loongarch64_unknown_linux_gnu=/TOOLCHAIN_PATH/bin/loongarch64-unknown-linux-
AR_loongarch64_unknown_linux_gnu=/TOOLCHAIN_PATH/bin/loongarch64-unknown-linux-gnu-gcc-ar \
CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_GNUN_LINKER=/TOOLCHAIN_PATH/bin/loongarch64-unknown-linux-gnu-gcc \
# SET TARGET SYSTEM LIBRARY PATH
CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_GNUN_RUNNER="qemu-loongarch64 -L /TOOLCHAIN_PATH/TARGET_LIBRAY_PATH" \
CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_GNUN_RUNNER="qemu-loongarch64 -L /TOOLCHAIN_PATH/TARGET_LIBRARY_PATH" \
cargo run --target loongarch64-unknown-linux-gnu --release
```
Tested on x86 architecture, other architectures not tested.
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustc/src/platform-support/netbsd.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ The Rust testsuite could presumably be run natively.

For the systems where the maintainer can build natively, the rust
compiler itself is re-built natively. This involves the rust compiler
being re-built with the newly self-built rust compiler, so excercises
being re-built with the newly self-built rust compiler, so exercises
the result quite extensively.

Additionally, for some systems we build `librsvg`, and for the more
Expand Down
4 changes: 2 additions & 2 deletions src/doc/rustc/src/platform-support/x86_64h-apple-darwin.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ will fail to load on machines that do not support this.

It should support the full standard library (`std` and `alloc` either with
default or user-defined allocators). This target is probably most useful when
targetted via cross-compilation (including from `x86_64-apple-darwin`), but if
targeted via cross-compilation (including from `x86_64-apple-darwin`), but if
built manually, the host tools work.

It is similar to `x86_64-apple-darwin` in nearly all respects, although the
Expand Down Expand Up @@ -49,7 +49,7 @@ suite seems to work.

Cross-compilation to this target from Apple hosts should generally work without
much configuration, so long as XCode and the CommandLineTools are installed.
Targetting it from non-Apple hosts is difficult, but no moreso than targetting
Targeting it from non-Apple hosts is difficult, but no more so than targeting
`x86_64-apple-darwin`.

When compiling C code for this target, either the "`x86_64h-apple-macosx*`" LLVM
Expand Down
2 changes: 1 addition & 1 deletion src/doc/unstable-book/src/compiler-flags/path-options.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `--print` Options

The behavior of the `--print` flag can be modified by optionally be specifiying a filepath
The behavior of the `--print` flag can be modified by optionally be specifying a filepath
for each requested information kind, in the format `--print KIND=PATH`, just like for
`--emit`. When a path is specified, information will be written there instead of to stdout.

Expand Down
18 changes: 9 additions & 9 deletions src/librustdoc/clean/auto_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ where
let tcx = self.cx.tcx;
let trait_ref = ty::Binder::dummy(ty::TraitRef::new(tcx, trait_def_id, [ty]));
if !self.cx.generated_synthetics.insert((ty, trait_def_id)) {
debug!("get_auto_trait_impl_for({:?}): already generated, aborting", trait_ref);
debug!("get_auto_trait_impl_for({trait_ref:?}): already generated, aborting");
return None;
}

Expand Down Expand Up @@ -140,7 +140,7 @@ where
let ty = tcx.type_of(item_def_id).instantiate_identity();
let f = auto_trait::AutoTraitFinder::new(tcx);

debug!("get_auto_trait_impls({:?})", ty);
debug!("get_auto_trait_impls({ty:?})");
let auto_traits: Vec<_> = self.cx.auto_traits.to_vec();
let mut auto_traits: Vec<Item> = auto_traits
.into_iter()
Expand All @@ -163,9 +163,9 @@ where
fn get_lifetime(region: Region<'_>, names_map: &FxHashMap<Symbol, Lifetime>) -> Lifetime {
region_name(region)
.map(|name| {
names_map.get(&name).unwrap_or_else(|| {
panic!("Missing lifetime with name {:?} for {:?}", name.as_str(), region)
})
names_map
.get(&name)
.unwrap_or_else(|| panic!("Missing lifetime with name {name:?} for {region:?}"))
})
.unwrap_or(&Lifetime::statik())
.clone()
Expand Down Expand Up @@ -372,7 +372,7 @@ where

let output = output.as_ref().cloned().map(Box::new);
if old_output.is_some() && old_output != output {
panic!("Output mismatch for {:?} {:?} {:?}", ty, old_output, output);
panic!("Output mismatch for {ty:?} {old_output:?} {output:?}");
}

let new_params = GenericArgs::Parenthesized { inputs: old_input, output };
Expand Down Expand Up @@ -462,7 +462,7 @@ where
);
let mut generic_params = raw_generics.params;

debug!("param_env_to_generics({:?}): generic_params={:?}", item_def_id, generic_params);
debug!("param_env_to_generics({item_def_id:?}): generic_params={generic_params:?}");

let mut has_sized = FxHashSet::default();
let mut ty_to_bounds: FxHashMap<_, FxHashSet<_>> = Default::default();
Expand Down Expand Up @@ -623,7 +623,7 @@ where
// loop
ty_to_traits.entry(ty.clone()).or_default().insert(trait_.clone());
}
_ => panic!("Unexpected LHS {:?} for {:?}", lhs, item_def_id),
_ => panic!("Unexpected LHS {lhs:?} for {item_def_id:?}"),
}
}
};
Expand Down Expand Up @@ -710,7 +710,7 @@ where
/// involved (impls rarely have more than a few bounds) means that it
/// shouldn't matter in practice.
fn unstable_debug_sort<T: Debug>(&self, vec: &mut [T]) {
vec.sort_by_cached_key(|x| format!("{:?}", x))
vec.sort_by_cached_key(|x| format!("{x:?}"))
}

fn is_fn_trait(&self, path: &Path) -> bool {
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/clean/blanket_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
let param_env = cx.tcx.param_env(item_def_id);
let ty = cx.tcx.type_of(item_def_id);

trace!("get_blanket_impls({:?})", ty);
trace!("get_blanket_impls({ty:?})");
let mut impls = Vec::new();
for trait_def_id in cx.tcx.all_traits() {
if !cx.cache.effective_visibilities.is_reachable(cx.tcx, trait_def_id)
Expand Down Expand Up @@ -72,7 +72,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
.into_iter()
.chain(Some(ty::Binder::dummy(impl_trait_ref).to_predicate(infcx.tcx)));
for predicate in predicates {
debug!("testing predicate {:?}", predicate);
debug!("testing predicate {predicate:?}");
let obligation = traits::Obligation::new(
infcx.tcx,
traits::ObligationCause::dummy(),
Expand Down
Loading