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 14 pull requests #89548

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
cb4519e
os current_exe using same approach as linux to get always the full ab…
devnexen Jul 30, 2021
ce450f8
Use the 64b inner:monotonize() implementation not the 128b one for aa…
AGSaidi Sep 4, 2021
4f5563d
Added abs_diff for integer types.
orlp Sep 9, 2021
77e7f8a
Added psadbw support for u8::abs_diff.
orlp Sep 9, 2021
f83853e
refactor: VecDeques PairSlices fields to private
DeveloperC286 Sep 25, 2021
e18a8ef
Don't ignore impls for primitive types
hkmatsumoto Aug 28, 2021
e46fc9d
Encode json files with UTF-8
hkmatsumoto Sep 29, 2021
03cf07f
Update to the final LLVM 13.0.0 release
cuviper Oct 2, 2021
98dde56
haiku thread affinity build fix
devnexen Oct 2, 2021
fb0b1a5
Follow the diagnostic output style guide
hkmatsumoto Oct 3, 2021
a0cc9bb
Add a test to detect overlapping entries in overview tables
dns2utf8 Sep 10, 2021
677fb6b
Show how many tests are running in parallel
dns2utf8 Sep 11, 2021
e599e2d
Move from grid layout to table based layout because of browser limits…
dns2utf8 Sep 11, 2021
9626f2b
Fix extra `non_snake_case` warning for shorthand field bindings
FabianWolff Oct 2, 2021
6dd6e7c
Added tracking issue numbers for int_abs_diff.
orlp Oct 3, 2021
e34fd54
Deny `where` clauses on `auto` traits
FabianWolff Oct 3, 2021
fdd8a0d
Don't suggest replacing region with 'static in NLL
Aaron1011 Oct 3, 2021
ccd2be5
fix busted JavaScript in error index generator
notriddle Oct 4, 2021
eb1bb97
Rollup merge of #87631 - :solarish_upd_fs, r=joshtriplett
Manishearth Oct 5, 2021
8c4bec2
Rollup merge of #88234 - hkmatsumoto:rustdoc-impls-for-primitive, r=j…
Manishearth Oct 5, 2021
244e2c7
Rollup merge of #88651 - AGSaidi:monotonize-inner-64b-aarch64, r=dtolnay
Manishearth Oct 5, 2021
b837cbf
Rollup merge of #88780 - orlp:int-abs-diff, r=m-ou-se
Manishearth Oct 5, 2021
117270d
Rollup merge of #88816 - dns2utf8:rustdoc_test_gui_2k_constants, r=Gu…
Manishearth Oct 5, 2021
27eddab
Rollup merge of #89244 - DeveloperC286:pair_slices_fields_to_private,…
Manishearth Oct 5, 2021
4547b80
Rollup merge of #89364 - hkmatsumoto:encode-json-with-utf-8, r=Mark-S…
Manishearth Oct 5, 2021
21407e1
Rollup merge of #89456 - cuviper:llvm-13, r=nikic
Manishearth Oct 5, 2021
c81173c
Rollup merge of #89462 - devnexen:haiku_thread_aff_build_fix, r=nagisa
Manishearth Oct 5, 2021
ace4d36
Rollup merge of #89473 - FabianWolff:issue-89469, r=joshtriplett
Manishearth Oct 5, 2021
21cdcac
Rollup merge of #89482 - hkmatsumoto:patch-diagnostics, r=joshtriplett
Manishearth Oct 5, 2021
6b44c97
Rollup merge of #89494 - FabianWolff:issue-84075, r=davidtwco
Manishearth Oct 5, 2021
2c1c140
Rollup merge of #89504 - Aaron1011:rpit-nll-static, r=nikomatsakis
Manishearth Oct 5, 2021
efeb9af
Rollup merge of #89535 - notriddle:notriddle/error-index-generator-js…
Manishearth Oct 5, 2021
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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
[submodule "src/llvm-project"]
path = src/llvm-project
url = https://github.com/rust-lang/llvm-project.git
branch = rustc/13.0-2021-08-08
branch = rustc/13.0-2021-09-30
[submodule "src/doc/embedded-book"]
path = src/doc/embedded-book
url = https://github.com/rust-embedded/book.git
Expand Down
49 changes: 36 additions & 13 deletions compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,31 +683,53 @@ impl<'a> AstValidator<'a> {
}
}

fn emit_e0568(&self, span: Span, ident_span: Span) {
struct_span_err!(
self.session,
span,
E0568,
"auto traits cannot have super traits or lifetime bounds"
)
.span_label(ident_span, "auto trait cannot have super traits or lifetime bounds")
.span_suggestion(
span,
"remove the super traits or lifetime bounds",
String::new(),
Applicability::MachineApplicable,
)
.emit();
}

fn deny_super_traits(&self, bounds: &GenericBounds, ident_span: Span) {
if let [first @ last] | [first, .., last] = &bounds[..] {
let span = first.span().to(last.span());
struct_span_err!(self.session, span, E0568, "auto traits cannot have super traits")
.span_label(ident_span, "auto trait cannot have super traits")
.span_suggestion(
span,
"remove the super traits",
String::new(),
Applicability::MachineApplicable,
)
.emit();
if let [.., last] = &bounds[..] {
let span = ident_span.shrink_to_hi().to(last.span());
self.emit_e0568(span, ident_span);
}
}

fn deny_where_clause(&self, where_clause: &WhereClause, ident_span: Span) {
if !where_clause.predicates.is_empty() {
self.emit_e0568(where_clause.span, ident_span);
}
}

fn deny_items(&self, trait_items: &[P<AssocItem>], ident_span: Span) {
if !trait_items.is_empty() {
let spans: Vec<_> = trait_items.iter().map(|i| i.ident.span).collect();
let total_span = trait_items.first().unwrap().span.to(trait_items.last().unwrap().span);
struct_span_err!(
self.session,
spans,
E0380,
"auto traits cannot have methods or associated items"
"auto traits cannot have associated items"
)
.span_suggestion(
total_span,
"remove these associated items",
String::new(),
Applicability::MachineApplicable,
)
.span_label(ident_span, "auto trait cannot have items")
.span_label(ident_span, "auto trait cannot have associated items")
.emit();
}
}
Expand Down Expand Up @@ -1184,6 +1206,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
// Auto traits cannot have generics, super traits nor contain items.
self.deny_generic_params(generics, item.ident.span);
self.deny_super_traits(bounds, item.ident.span);
self.deny_where_clause(&generics.where_clause, item.ident.span);
self.deny_items(trait_items, item.ident.span);
}
self.no_questions_in_bounds(bounds, "supertraits", true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,7 @@ impl OutlivesSuggestionBuilder {
let outlived_fr_name = self.region_vid_to_name(mbcx, errci.outlived_fr);

if let (Some(fr_name), Some(outlived_fr_name)) = (fr_name, outlived_fr_name) {
if let RegionNameSource::Static = outlived_fr_name.source {
diag.help(&format!("consider replacing `{}` with `'static`", fr_name));
} else {
if !matches!(outlived_fr_name.source, RegionNameSource::Static) {
diag.help(&format!(
"consider adding the following bound: `{}: {}`",
fr_name, outlived_fr_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl NonConstOp for FnCallUnstable {
);

if ccx.is_const_stable_const_fn() {
err.help("Const-stable functions can only call other const-stable functions");
err.help("const-stable functions can only call other const-stable functions");
} else if ccx.tcx.sess.is_nightly_build() {
if let Some(feature) = feature {
err.help(&format!(
Expand Down
13 changes: 7 additions & 6 deletions compiler/rustc_lint/src/nonstandard_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,12 +437,13 @@ impl<'tcx> LateLintPass<'tcx> for NonSnakeCase {
if let hir::Node::Pat(parent_pat) = cx.tcx.hir().get(cx.tcx.hir().get_parent_node(hid))
{
if let PatKind::Struct(_, field_pats, _) = &parent_pat.kind {
for field in field_pats.iter() {
if field.ident != ident {
// Only check if a new name has been introduced, to avoid warning
// on both the struct definition and this pattern.
self.check_snake_case(cx, "variable", &ident);
}
if field_pats
.iter()
.any(|field| !field.is_shorthand && field.pat.hir_id == p.hir_id)
{
// Only check if a new name has been introduced, to avoid warning
// on both the struct definition and this pattern.
self.check_snake_case(cx, "variable", &ident);
}
return;
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub(super) fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: Ab
tcx.sess,
span,
E0781,
"the `\"C-cmse-nonsecure-call\"` ABI is only allowed on function pointers."
"the `\"C-cmse-nonsecure-call\"` ABI is only allowed on function pointers"
)
.emit()
}
Expand Down
8 changes: 4 additions & 4 deletions library/alloc/src/collections/vec_deque/pair_slices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ use super::VecDeque;
///
/// and the uneven remainder of either A or B is skipped.
pub struct PairSlices<'a, 'b, T> {
pub(crate) a0: &'a mut [T],
pub(crate) a1: &'a mut [T],
pub(crate) b0: &'b [T],
pub(crate) b1: &'b [T],
a0: &'a mut [T],
a1: &'a mut [T],
b0: &'b [T],
b1: &'b [T],
}

impl<'a, 'b, T> PairSlices<'a, 'b, T> {
Expand Down
40 changes: 40 additions & 0 deletions library/core/src/num/int_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2235,6 +2235,46 @@ macro_rules! int_impl {
}
}

/// Computes the absolute difference between `self` and `other`.
///
/// This function always returns the correct answer without overflow or
/// panics by returning an unsigned integer.
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// #![feature(int_abs_diff)]
#[doc = concat!("assert_eq!(100", stringify!($SelfT), ".abs_diff(80), 20", stringify!($UnsignedT), ");")]
#[doc = concat!("assert_eq!(100", stringify!($SelfT), ".abs_diff(110), 10", stringify!($UnsignedT), ");")]
#[doc = concat!("assert_eq!((-100", stringify!($SelfT), ").abs_diff(80), 180", stringify!($UnsignedT), ");")]
#[doc = concat!("assert_eq!((-100", stringify!($SelfT), ").abs_diff(-120), 20", stringify!($UnsignedT), ");")]
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.abs_diff(", stringify!($SelfT), "::MAX), ", stringify!($UnsignedT), "::MAX);")]
/// ```
#[unstable(feature = "int_abs_diff", issue = "89492")]
#[inline]
pub const fn abs_diff(self, other: Self) -> $UnsignedT {
if self < other {
// Converting a non-negative x from signed to unsigned by using
// `x as U` is left unchanged, but a negative x is converted
// to value x + 2^N. Thus if `s` and `o` are binary variables
// respectively indicating whether `self` and `other` are
// negative, we are computing the mathematical value:
//
// (other + o*2^N) - (self + s*2^N) mod 2^N
// other - self + (o-s)*2^N mod 2^N
// other - self mod 2^N
//
// Finally, taking the mod 2^N of the mathematical value of
// `other - self` does not change it as it already is
// in the range [0, 2^N).
(other as $UnsignedT).wrapping_sub(self as $UnsignedT)
} else {
(self as $UnsignedT).wrapping_sub(other as $UnsignedT)
}
}

/// Returns a number representing sign of `self`.
///
/// - `0` if the number is zero
Expand Down
27 changes: 27 additions & 0 deletions library/core/src/num/uint_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1490,6 +1490,33 @@ macro_rules! uint_impl {
(c, b | d)
}

/// Computes the absolute difference between `self` and `other`.
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// #![feature(int_abs_diff)]
#[doc = concat!("assert_eq!(100", stringify!($SelfT), ".abs_diff(80), 20", stringify!($SelfT), ");")]
#[doc = concat!("assert_eq!(100", stringify!($SelfT), ".abs_diff(110), 10", stringify!($SelfT), ");")]
/// ```
#[unstable(feature = "int_abs_diff", issue = "89492")]
#[inline]
pub const fn abs_diff(self, other: Self) -> Self {
if mem::size_of::<Self>() == 1 {
// Trick LLVM into generating the psadbw instruction when SSE2
// is available and this function is autovectorized for u8's.
(self as i32).wrapping_sub(other as i32).abs() as Self
} else {
if self < other {
other - self
} else {
self - other
}
}
}

/// Calculates the multiplication of `self` and `rhs`.
///
/// Returns a tuple of the multiplication along with a boolean
Expand Down
30 changes: 17 additions & 13 deletions library/std/src/sys/unix/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,20 +380,24 @@ pub fn current_exe() -> io::Result<PathBuf> {

#[cfg(any(target_os = "solaris", target_os = "illumos"))]
pub fn current_exe() -> io::Result<PathBuf> {
extern "C" {
fn getexecname() -> *const c_char;
}
unsafe {
let path = getexecname();
if path.is_null() {
Err(io::Error::last_os_error())
} else {
let filename = CStr::from_ptr(path).to_bytes();
let path = PathBuf::from(<OsStr as OsStrExt>::from_bytes(filename));
if let Ok(path) = crate::fs::read_link("/proc/self/path/a.out") {
Ok(path)
} else {
extern "C" {
fn getexecname() -> *const c_char;
}
unsafe {
let path = getexecname();
if path.is_null() {
Err(io::Error::last_os_error())
} else {
let filename = CStr::from_ptr(path).to_bytes();
let path = PathBuf::from(<OsStr as OsStrExt>::from_bytes(filename));

// Prepend a current working directory to the path if
// it doesn't contain an absolute pathname.
if filename[0] == b'/' { Ok(path) } else { getcwd().map(|cwd| cwd.join(path)) }
// Prepend a current working directory to the path if
// it doesn't contain an absolute pathname.
if filename[0] == b'/' { Ok(path) } else { getcwd().map(|cwd| cwd.join(path)) }
}
}
}
}
Expand Down
16 changes: 10 additions & 6 deletions library/std/src/sys/unix/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,14 +339,18 @@ pub fn available_concurrency() -> io::Result<NonZeroUsize> {

Ok(unsafe { NonZeroUsize::new_unchecked(cpus as usize) })
} else if #[cfg(target_os = "haiku")] {
let mut sinfo: libc::system_info = crate::mem::zeroed();
let res = libc::get_system_info(&mut sinfo);
// system_info cpu_count field gets the static data set at boot time with `smp_set_num_cpus`
// `get_system_info` calls then `smp_get_num_cpus`
unsafe {
let mut sinfo: libc::system_info = crate::mem::zeroed();
let res = libc::get_system_info(&mut sinfo);

if res != libc::B_OK {
return Err(io::Error::last_os_error());
}
if res != libc::B_OK {
return Err(io::Error::new_const(io::ErrorKind::NotFound, &"The number of hardware threads is not known for the target platform"));
}

Ok(unsafe { NonZeroUsize::new_unchecked(sinfo.cpu_count as usize) })
Ok(NonZeroUsize::new_unchecked(sinfo.cpu_count as usize))
}
} else {
// FIXME: implement on vxWorks, Redox, l4re
Err(io::Error::new_const(io::ErrorKind::Unsupported, &"Getting the number of hardware threads is not supported on the target platform"))
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/time/monotonic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub(super) fn monotonize(raw: time::Instant) -> time::Instant {
inner::monotonize(raw)
}

#[cfg(all(target_has_atomic = "64", not(target_has_atomic = "128")))]
#[cfg(any(all(target_has_atomic = "64", not(target_has_atomic = "128")), target_arch = "aarch64"))]
pub mod inner {
use crate::sync::atomic::AtomicU64;
use crate::sync::atomic::Ordering::*;
Expand Down Expand Up @@ -71,7 +71,7 @@ pub mod inner {
}
}

#[cfg(target_has_atomic = "128")]
#[cfg(all(target_has_atomic = "128", not(target_arch = "aarch64")))]
pub mod inner {
use crate::sync::atomic::AtomicU128;
use crate::sync::atomic::Ordering::*;
Expand Down
2 changes: 1 addition & 1 deletion src/etc/check_missing_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import sys
import json

crate = json.load(open(sys.argv[1]))
crate = json.load(open(sys.argv[1], encoding="utf-8"))


def get_local_item(item_id):
Expand Down
Loading