Skip to content

Commit

Permalink
Auto merge of rust-lang#89211 - workingjubilee:rollup-fj4eduk, r=work…
Browse files Browse the repository at this point in the history
…ingjubilee

Rollup of 7 pull requests

Successful merges:

 - rust-lang#88612 (Add a better error message for rust-lang#39364)
 - rust-lang#89023 (Resolve issue : Somewhat confusing error with extended_key_value_attributes)
 - rust-lang#89148 (Suggest `_` in turbofish if param will be inferred from fn argument)
 - rust-lang#89171 (Run `no_core` rustdoc tests only on Linux)
 - rust-lang#89176 (Change singular to plural)
 - rust-lang#89184 (Temporarily rename int_roundings functions to avoid conflicts)
 - rust-lang#89200 (Fix typo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Sep 24, 2021
2 parents 900cf5e + 1875cec commit 293b8f2
Show file tree
Hide file tree
Showing 16 changed files with 146 additions and 54 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! inference graph arose so that we can explain to the user what gave
//! rise to a particular error.
//!
//! The basis of the system are the "origin" types. An "origin" is the
//! The system is based around a set of "origin" types. An "origin" is the
//! reason that a constraint or inference variable arose. There are
//! different "origin" enums for different kinds of constraints/variables
//! (e.g., `TypeOrigin`, `RegionVariableOrigin`). An origin always has
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ rustc_queries! {
desc { "computing the inferred outlives predicates for items in this crate" }
}

/// Maps from an impl/trait `DefId to a list of the `DefId`s of its items.
/// Maps from an impl/trait `DefId` to a list of the `DefId`s of its items.
query associated_item_def_ids(key: DefId) -> &'tcx [DefId] {
desc { |tcx| "collecting associated items of `{}`", tcx.def_path_str(key) }
}
Expand Down
14 changes: 14 additions & 0 deletions compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1568,6 +1568,20 @@ impl<'a> Parser<'a> {

pub(super) fn parse_lit(&mut self) -> PResult<'a, Lit> {
self.parse_opt_lit().ok_or_else(|| {
if let token::Interpolated(inner) = &self.token.kind {
let expr = match inner.as_ref() {
token::NtExpr(expr) => Some(expr),
token::NtLiteral(expr) => Some(expr),
_ => None,
};
if let Some(expr) = expr {
if matches!(expr.kind, ExprKind::Err) {
self.diagnostic()
.delay_span_bug(self.token.span, &"invalid interpolated expression");
return self.diagnostic().struct_dummy();
}
}
}
let msg = format!("unexpected token: {}", super::token_descr(&self.token));
self.struct_span_err(self.token.span, &msg)
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::structured_errors::StructuredDiagnostic;
use rustc_errors::{pluralize, Applicability, DiagnosticBuilder, DiagnosticId};
use rustc_hir as hir;
use rustc_middle::hir::map::fn_sig;
use rustc_middle::middle::resolve_lifetime::LifetimeScopeForPath;
use rustc_middle::ty::{self as ty, TyCtxt};
use rustc_session::Session;
Expand Down Expand Up @@ -292,12 +293,30 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
&self,
num_params_to_take: usize,
) -> String {
let fn_sig = self.tcx.hir().get_if_local(self.def_id).and_then(|node| fn_sig(node));
let is_used_in_input = |def_id| {
fn_sig.map_or(false, |fn_sig| {
fn_sig.decl.inputs.iter().any(|ty| match ty.kind {
hir::TyKind::Path(hir::QPath::Resolved(
None,
hir::Path { res: hir::def::Res::Def(_, id), .. },
)) if *id == def_id => true,
_ => false,
})
})
};
self.gen_params
.params
.iter()
.skip(self.params_offset + self.num_provided_type_or_const_args())
.take(num_params_to_take)
.map(|param| param.name.to_string())
.map(|param| match param.kind {
// This is being infered from the item's inputs, no need to set it.
ty::GenericParamDefKind::Type { .. } if is_used_in_input(param.def_id) => {
"_".to_string()
}
_ => param.name.to_string(),
})
.collect::<Vec<_>>()
.join(", ")
}
Expand Down
38 changes: 19 additions & 19 deletions library/core/src/num/int_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1849,17 +1849,17 @@ macro_rules! int_impl {
#[doc = concat!("let a: ", stringify!($SelfT)," = 8;")]
/// let b = 3;
///
/// assert_eq!(a.div_floor(b), 2);
/// assert_eq!(a.div_floor(-b), -3);
/// assert_eq!((-a).div_floor(b), -3);
/// assert_eq!((-a).div_floor(-b), 2);
/// assert_eq!(a.unstable_div_floor(b), 2);
/// assert_eq!(a.unstable_div_floor(-b), -3);
/// assert_eq!((-a).unstable_div_floor(b), -3);
/// assert_eq!((-a).unstable_div_floor(-b), 2);
/// ```
#[unstable(feature = "int_roundings", issue = "88581")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
#[rustc_inherit_overflow_checks]
pub const fn div_floor(self, rhs: Self) -> Self {
pub const fn unstable_div_floor(self, rhs: Self) -> Self {
let d = self / rhs;
let r = self % rhs;
if (r > 0 && rhs < 0) || (r < 0 && rhs > 0) {
Expand All @@ -1884,17 +1884,17 @@ macro_rules! int_impl {
#[doc = concat!("let a: ", stringify!($SelfT)," = 8;")]
/// let b = 3;
///
/// assert_eq!(a.div_ceil(b), 3);
/// assert_eq!(a.div_ceil(-b), -2);
/// assert_eq!((-a).div_ceil(b), -2);
/// assert_eq!((-a).div_ceil(-b), 3);
/// assert_eq!(a.unstable_div_ceil(b), 3);
/// assert_eq!(a.unstable_div_ceil(-b), -2);
/// assert_eq!((-a).unstable_div_ceil(b), -2);
/// assert_eq!((-a).unstable_div_ceil(-b), 3);
/// ```
#[unstable(feature = "int_roundings", issue = "88581")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
#[rustc_inherit_overflow_checks]
pub const fn div_ceil(self, rhs: Self) -> Self {
pub const fn unstable_div_ceil(self, rhs: Self) -> Self {
let d = self / rhs;
let r = self % rhs;
if (r > 0 && rhs > 0) || (r < 0 && rhs < 0) {
Expand All @@ -1919,21 +1919,21 @@ macro_rules! int_impl {
///
/// ```
/// #![feature(int_roundings)]
#[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".next_multiple_of(8), 16);")]
#[doc = concat!("assert_eq!(23_", stringify!($SelfT), ".next_multiple_of(8), 24);")]
#[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".next_multiple_of(-8), 16);")]
#[doc = concat!("assert_eq!(23_", stringify!($SelfT), ".next_multiple_of(-8), 16);")]
#[doc = concat!("assert_eq!((-16_", stringify!($SelfT), ").next_multiple_of(8), -16);")]
#[doc = concat!("assert_eq!((-23_", stringify!($SelfT), ").next_multiple_of(8), -16);")]
#[doc = concat!("assert_eq!((-16_", stringify!($SelfT), ").next_multiple_of(-8), -16);")]
#[doc = concat!("assert_eq!((-23_", stringify!($SelfT), ").next_multiple_of(-8), -24);")]
#[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".unstable_next_multiple_of(8), 16);")]
#[doc = concat!("assert_eq!(23_", stringify!($SelfT), ".unstable_next_multiple_of(8), 24);")]
#[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".unstable_next_multiple_of(-8), 16);")]
#[doc = concat!("assert_eq!(23_", stringify!($SelfT), ".unstable_next_multiple_of(-8), 16);")]
#[doc = concat!("assert_eq!((-16_", stringify!($SelfT), ").unstable_next_multiple_of(8), -16);")]
#[doc = concat!("assert_eq!((-23_", stringify!($SelfT), ").unstable_next_multiple_of(8), -16);")]
#[doc = concat!("assert_eq!((-16_", stringify!($SelfT), ").unstable_next_multiple_of(-8), -16);")]
#[doc = concat!("assert_eq!((-23_", stringify!($SelfT), ").unstable_next_multiple_of(-8), -24);")]
/// ```
#[unstable(feature = "int_roundings", issue = "88581")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
#[rustc_inherit_overflow_checks]
pub const fn next_multiple_of(self, rhs: Self) -> Self {
pub const fn unstable_next_multiple_of(self, rhs: Self) -> Self {
// This would otherwise fail when calculating `r` when self == T::MIN.
if rhs == -1 {
return self;
Expand Down
14 changes: 7 additions & 7 deletions library/core/src/num/uint_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1859,12 +1859,12 @@ macro_rules! uint_impl {
///
/// ```
/// #![feature(int_roundings)]
#[doc = concat!("assert_eq!(7_", stringify!($SelfT), ".div_floor(4), 1);")]
#[doc = concat!("assert_eq!(7_", stringify!($SelfT), ".unstable_div_floor(4), 1);")]
/// ```
#[unstable(feature = "int_roundings", issue = "88581")]
#[inline(always)]
#[rustc_inherit_overflow_checks]
pub const fn div_floor(self, rhs: Self) -> Self {
pub const fn unstable_div_floor(self, rhs: Self) -> Self {
self / rhs
}

Expand All @@ -1880,12 +1880,12 @@ macro_rules! uint_impl {
///
/// ```
/// #![feature(int_roundings)]
#[doc = concat!("assert_eq!(7_", stringify!($SelfT), ".div_ceil(4), 2);")]
#[doc = concat!("assert_eq!(7_", stringify!($SelfT), ".unstable_div_ceil(4), 2);")]
/// ```
#[unstable(feature = "int_roundings", issue = "88581")]
#[inline]
#[rustc_inherit_overflow_checks]
pub const fn div_ceil(self, rhs: Self) -> Self {
pub const fn unstable_div_ceil(self, rhs: Self) -> Self {
let d = self / rhs;
let r = self % rhs;
if r > 0 && rhs > 0 {
Expand All @@ -1908,15 +1908,15 @@ macro_rules! uint_impl {
///
/// ```
/// #![feature(int_roundings)]
#[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".next_multiple_of(8), 16);")]
#[doc = concat!("assert_eq!(23_", stringify!($SelfT), ".next_multiple_of(8), 24);")]
#[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".unstable_next_multiple_of(8), 16);")]
#[doc = concat!("assert_eq!(23_", stringify!($SelfT), ".unstable_next_multiple_of(8), 24);")]
/// ```
#[unstable(feature = "int_roundings", issue = "88581")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
#[rustc_inherit_overflow_checks]
pub const fn next_multiple_of(self, rhs: Self) -> Self {
pub const fn unstable_next_multiple_of(self, rhs: Self) -> Self {
match self % rhs {
0 => self,
r => self + (rhs - r)
Expand Down
34 changes: 17 additions & 17 deletions library/core/tests/num/int_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,33 +294,33 @@ macro_rules! int_module {
fn test_div_floor() {
let a: $T = 8;
let b = 3;
assert_eq!(a.div_floor(b), 2);
assert_eq!(a.div_floor(-b), -3);
assert_eq!((-a).div_floor(b), -3);
assert_eq!((-a).div_floor(-b), 2);
assert_eq!(a.unstable_div_floor(b), 2);
assert_eq!(a.unstable_div_floor(-b), -3);
assert_eq!((-a).unstable_div_floor(b), -3);
assert_eq!((-a).unstable_div_floor(-b), 2);
}

#[test]
fn test_div_ceil() {
let a: $T = 8;
let b = 3;
assert_eq!(a.div_ceil(b), 3);
assert_eq!(a.div_ceil(-b), -2);
assert_eq!((-a).div_ceil(b), -2);
assert_eq!((-a).div_ceil(-b), 3);
assert_eq!(a.unstable_div_ceil(b), 3);
assert_eq!(a.unstable_div_ceil(-b), -2);
assert_eq!((-a).unstable_div_ceil(b), -2);
assert_eq!((-a).unstable_div_ceil(-b), 3);
}

#[test]
fn test_next_multiple_of() {
assert_eq!((16 as $T).next_multiple_of(8), 16);
assert_eq!((23 as $T).next_multiple_of(8), 24);
assert_eq!((16 as $T).next_multiple_of(-8), 16);
assert_eq!((23 as $T).next_multiple_of(-8), 16);
assert_eq!((-16 as $T).next_multiple_of(8), -16);
assert_eq!((-23 as $T).next_multiple_of(8), -16);
assert_eq!((-16 as $T).next_multiple_of(-8), -16);
assert_eq!((-23 as $T).next_multiple_of(-8), -24);
assert_eq!(MIN.next_multiple_of(-1), MIN);
assert_eq!((16 as $T).unstable_next_multiple_of(8), 16);
assert_eq!((23 as $T).unstable_next_multiple_of(8), 24);
assert_eq!((16 as $T).unstable_next_multiple_of(-8), 16);
assert_eq!((23 as $T).unstable_next_multiple_of(-8), 16);
assert_eq!((-16 as $T).unstable_next_multiple_of(8), -16);
assert_eq!((-23 as $T).unstable_next_multiple_of(8), -16);
assert_eq!((-16 as $T).unstable_next_multiple_of(-8), -16);
assert_eq!((-23 as $T).unstable_next_multiple_of(-8), -24);
assert_eq!(MIN.unstable_next_multiple_of(-1), MIN);
}

#[test]
Expand Down
10 changes: 5 additions & 5 deletions library/core/tests/num/uint_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,19 +208,19 @@ macro_rules! uint_module {

#[test]
fn test_div_floor() {
assert_eq!((8 as $T).div_floor(3), 2);
assert_eq!((8 as $T).unstable_div_floor(3), 2);
}

#[test]
fn test_div_ceil() {
assert_eq!((8 as $T).div_ceil(3), 3);
assert_eq!((8 as $T).unstable_div_ceil(3), 3);
}

#[test]
fn test_next_multiple_of() {
assert_eq!((16 as $T).next_multiple_of(8), 16);
assert_eq!((23 as $T).next_multiple_of(8), 24);
assert_eq!(MAX.next_multiple_of(1), MAX);
assert_eq!((16 as $T).unstable_next_multiple_of(8), 16);
assert_eq!((23 as $T).unstable_next_multiple_of(8), 24);
assert_eq!(MAX.unstable_next_multiple_of(1), MAX);
}

#[test]
Expand Down
6 changes: 5 additions & 1 deletion library/std/src/sync/mpsc/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,11 @@ impl<T> Packet<T> {
// Returns true if blocking should proceed.
fn decrement(&self, token: SignalToken) -> StartResult {
unsafe {
assert_eq!(self.to_wake.load(Ordering::SeqCst), 0);
assert_eq!(
self.to_wake.load(Ordering::SeqCst),
0,
"This is a known bug in the Rust standard library. See https://github.com/rust-lang/rust/issues/39364"
);
let ptr = token.cast_to_usize();
self.to_wake.store(ptr, Ordering::SeqCst);

Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc/cross-crate-primitive-doc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// aux-build:primitive-doc.rs
// compile-flags: --extern-html-root-url=primitive_doc=../ -Z unstable-options
// ignore-windows
// only-linux

#![feature(no_core)]
#![no_core]
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc/intra-doc/prim-methods-external-core.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// aux-build:my-core.rs
// build-aux-docs
// ignore-cross-compile
// ignore-windows
// only-linux

#![deny(broken_intra_doc_links)]
#![feature(no_core, lang_items)]
Expand Down
8 changes: 8 additions & 0 deletions src/test/ui/attributes/extented-attribute-macro-error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// normalize-stderr-test: "couldn't read.*" -> "couldn't read the file"

#![feature(extended_key_value_attributes)]
#![doc = include_str!("../not_existing_file.md")]
struct Documented {}
//~^^ ERROR couldn't read

fn main() {}
10 changes: 10 additions & 0 deletions src/test/ui/attributes/extented-attribute-macro-error.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: couldn't read the file
--> $DIR/extented-attribute-macro-error.rs:4:10
|
LL | #![doc = include_str!("../not_existing_file.md")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the macro `include_str` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// run-rustfix

fn two_type_params<A, B>(_: B) {}

fn main() {
two_type_params::<String, _>(100); //~ ERROR this function takes 2 generic arguments
two_type_params::<String, _>(100);
}
8 changes: 8 additions & 0 deletions src/test/ui/suggestions/missing-type-param-used-in-param.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// run-rustfix

fn two_type_params<A, B>(_: B) {}

fn main() {
two_type_params::<String>(100); //~ ERROR this function takes 2 generic arguments
two_type_params::<String, _>(100);
}
21 changes: 21 additions & 0 deletions src/test/ui/suggestions/missing-type-param-used-in-param.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
error[E0107]: this function takes 2 generic arguments but 1 generic argument was supplied
--> $DIR/missing-type-param-used-in-param.rs:6:5
|
LL | two_type_params::<String>(100);
| ^^^^^^^^^^^^^^^ ------ supplied 1 generic argument
| |
| expected 2 generic arguments
|
note: function defined here, with 2 generic parameters: `A`, `B`
--> $DIR/missing-type-param-used-in-param.rs:3:4
|
LL | fn two_type_params<A, B>(_: B) {}
| ^^^^^^^^^^^^^^^ - -
help: add missing generic argument
|
LL | two_type_params::<String, _>(100);
| +++

error: aborting due to previous error

For more information about this error, try `rustc --explain E0107`.

0 comments on commit 293b8f2

Please sign in to comment.