Skip to content

Commit 293b8f2

Browse files
committed
Auto merge of #89211 - workingjubilee:rollup-fj4eduk, r=workingjubilee
Rollup of 7 pull requests Successful merges: - #88612 (Add a better error message for #39364) - #89023 (Resolve issue : Somewhat confusing error with extended_key_value_attributes) - #89148 (Suggest `_` in turbofish if param will be inferred from fn argument) - #89171 (Run `no_core` rustdoc tests only on Linux) - #89176 (Change singular to plural) - #89184 (Temporarily rename int_roundings functions to avoid conflicts) - #89200 (Fix typo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 900cf5e + 1875cec commit 293b8f2

File tree

16 files changed

+146
-54
lines changed

16 files changed

+146
-54
lines changed

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//! inference graph arose so that we can explain to the user what gave
88
//! rise to a particular error.
99
//!
10-
//! The basis of the system are the "origin" types. An "origin" is the
10+
//! The system is based around a set of "origin" types. An "origin" is the
1111
//! reason that a constraint or inference variable arose. There are
1212
//! different "origin" enums for different kinds of constraints/variables
1313
//! (e.g., `TypeOrigin`, `RegionVariableOrigin`). An origin always has

compiler/rustc_middle/src/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ rustc_queries! {
599599
desc { "computing the inferred outlives predicates for items in this crate" }
600600
}
601601

602-
/// Maps from an impl/trait `DefId to a list of the `DefId`s of its items.
602+
/// Maps from an impl/trait `DefId` to a list of the `DefId`s of its items.
603603
query associated_item_def_ids(key: DefId) -> &'tcx [DefId] {
604604
desc { |tcx| "collecting associated items of `{}`", tcx.def_path_str(key) }
605605
}

compiler/rustc_parse/src/parser/expr.rs

+14
Original file line numberDiff line numberDiff line change
@@ -1568,6 +1568,20 @@ impl<'a> Parser<'a> {
15681568

15691569
pub(super) fn parse_lit(&mut self) -> PResult<'a, Lit> {
15701570
self.parse_opt_lit().ok_or_else(|| {
1571+
if let token::Interpolated(inner) = &self.token.kind {
1572+
let expr = match inner.as_ref() {
1573+
token::NtExpr(expr) => Some(expr),
1574+
token::NtLiteral(expr) => Some(expr),
1575+
_ => None,
1576+
};
1577+
if let Some(expr) = expr {
1578+
if matches!(expr.kind, ExprKind::Err) {
1579+
self.diagnostic()
1580+
.delay_span_bug(self.token.span, &"invalid interpolated expression");
1581+
return self.diagnostic().struct_dummy();
1582+
}
1583+
}
1584+
}
15711585
let msg = format!("unexpected token: {}", super::token_descr(&self.token));
15721586
self.struct_span_err(self.token.span, &msg)
15731587
})

compiler/rustc_typeck/src/structured_errors/wrong_number_of_generic_args.rs

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::structured_errors::StructuredDiagnostic;
22
use rustc_errors::{pluralize, Applicability, DiagnosticBuilder, DiagnosticId};
33
use rustc_hir as hir;
4+
use rustc_middle::hir::map::fn_sig;
45
use rustc_middle::middle::resolve_lifetime::LifetimeScopeForPath;
56
use rustc_middle::ty::{self as ty, TyCtxt};
67
use rustc_session::Session;
@@ -292,12 +293,30 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
292293
&self,
293294
num_params_to_take: usize,
294295
) -> String {
296+
let fn_sig = self.tcx.hir().get_if_local(self.def_id).and_then(|node| fn_sig(node));
297+
let is_used_in_input = |def_id| {
298+
fn_sig.map_or(false, |fn_sig| {
299+
fn_sig.decl.inputs.iter().any(|ty| match ty.kind {
300+
hir::TyKind::Path(hir::QPath::Resolved(
301+
None,
302+
hir::Path { res: hir::def::Res::Def(_, id), .. },
303+
)) if *id == def_id => true,
304+
_ => false,
305+
})
306+
})
307+
};
295308
self.gen_params
296309
.params
297310
.iter()
298311
.skip(self.params_offset + self.num_provided_type_or_const_args())
299312
.take(num_params_to_take)
300-
.map(|param| param.name.to_string())
313+
.map(|param| match param.kind {
314+
// This is being infered from the item's inputs, no need to set it.
315+
ty::GenericParamDefKind::Type { .. } if is_used_in_input(param.def_id) => {
316+
"_".to_string()
317+
}
318+
_ => param.name.to_string(),
319+
})
301320
.collect::<Vec<_>>()
302321
.join(", ")
303322
}

library/core/src/num/int_macros.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -1849,17 +1849,17 @@ macro_rules! int_impl {
18491849
#[doc = concat!("let a: ", stringify!($SelfT)," = 8;")]
18501850
/// let b = 3;
18511851
///
1852-
/// assert_eq!(a.div_floor(b), 2);
1853-
/// assert_eq!(a.div_floor(-b), -3);
1854-
/// assert_eq!((-a).div_floor(b), -3);
1855-
/// assert_eq!((-a).div_floor(-b), 2);
1852+
/// assert_eq!(a.unstable_div_floor(b), 2);
1853+
/// assert_eq!(a.unstable_div_floor(-b), -3);
1854+
/// assert_eq!((-a).unstable_div_floor(b), -3);
1855+
/// assert_eq!((-a).unstable_div_floor(-b), 2);
18561856
/// ```
18571857
#[unstable(feature = "int_roundings", issue = "88581")]
18581858
#[must_use = "this returns the result of the operation, \
18591859
without modifying the original"]
18601860
#[inline]
18611861
#[rustc_inherit_overflow_checks]
1862-
pub const fn div_floor(self, rhs: Self) -> Self {
1862+
pub const fn unstable_div_floor(self, rhs: Self) -> Self {
18631863
let d = self / rhs;
18641864
let r = self % rhs;
18651865
if (r > 0 && rhs < 0) || (r < 0 && rhs > 0) {
@@ -1884,17 +1884,17 @@ macro_rules! int_impl {
18841884
#[doc = concat!("let a: ", stringify!($SelfT)," = 8;")]
18851885
/// let b = 3;
18861886
///
1887-
/// assert_eq!(a.div_ceil(b), 3);
1888-
/// assert_eq!(a.div_ceil(-b), -2);
1889-
/// assert_eq!((-a).div_ceil(b), -2);
1890-
/// assert_eq!((-a).div_ceil(-b), 3);
1887+
/// assert_eq!(a.unstable_div_ceil(b), 3);
1888+
/// assert_eq!(a.unstable_div_ceil(-b), -2);
1889+
/// assert_eq!((-a).unstable_div_ceil(b), -2);
1890+
/// assert_eq!((-a).unstable_div_ceil(-b), 3);
18911891
/// ```
18921892
#[unstable(feature = "int_roundings", issue = "88581")]
18931893
#[must_use = "this returns the result of the operation, \
18941894
without modifying the original"]
18951895
#[inline]
18961896
#[rustc_inherit_overflow_checks]
1897-
pub const fn div_ceil(self, rhs: Self) -> Self {
1897+
pub const fn unstable_div_ceil(self, rhs: Self) -> Self {
18981898
let d = self / rhs;
18991899
let r = self % rhs;
19001900
if (r > 0 && rhs > 0) || (r < 0 && rhs < 0) {
@@ -1919,21 +1919,21 @@ macro_rules! int_impl {
19191919
///
19201920
/// ```
19211921
/// #![feature(int_roundings)]
1922-
#[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".next_multiple_of(8), 16);")]
1923-
#[doc = concat!("assert_eq!(23_", stringify!($SelfT), ".next_multiple_of(8), 24);")]
1924-
#[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".next_multiple_of(-8), 16);")]
1925-
#[doc = concat!("assert_eq!(23_", stringify!($SelfT), ".next_multiple_of(-8), 16);")]
1926-
#[doc = concat!("assert_eq!((-16_", stringify!($SelfT), ").next_multiple_of(8), -16);")]
1927-
#[doc = concat!("assert_eq!((-23_", stringify!($SelfT), ").next_multiple_of(8), -16);")]
1928-
#[doc = concat!("assert_eq!((-16_", stringify!($SelfT), ").next_multiple_of(-8), -16);")]
1929-
#[doc = concat!("assert_eq!((-23_", stringify!($SelfT), ").next_multiple_of(-8), -24);")]
1922+
#[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".unstable_next_multiple_of(8), 16);")]
1923+
#[doc = concat!("assert_eq!(23_", stringify!($SelfT), ".unstable_next_multiple_of(8), 24);")]
1924+
#[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".unstable_next_multiple_of(-8), 16);")]
1925+
#[doc = concat!("assert_eq!(23_", stringify!($SelfT), ".unstable_next_multiple_of(-8), 16);")]
1926+
#[doc = concat!("assert_eq!((-16_", stringify!($SelfT), ").unstable_next_multiple_of(8), -16);")]
1927+
#[doc = concat!("assert_eq!((-23_", stringify!($SelfT), ").unstable_next_multiple_of(8), -16);")]
1928+
#[doc = concat!("assert_eq!((-16_", stringify!($SelfT), ").unstable_next_multiple_of(-8), -16);")]
1929+
#[doc = concat!("assert_eq!((-23_", stringify!($SelfT), ").unstable_next_multiple_of(-8), -24);")]
19301930
/// ```
19311931
#[unstable(feature = "int_roundings", issue = "88581")]
19321932
#[must_use = "this returns the result of the operation, \
19331933
without modifying the original"]
19341934
#[inline]
19351935
#[rustc_inherit_overflow_checks]
1936-
pub const fn next_multiple_of(self, rhs: Self) -> Self {
1936+
pub const fn unstable_next_multiple_of(self, rhs: Self) -> Self {
19371937
// This would otherwise fail when calculating `r` when self == T::MIN.
19381938
if rhs == -1 {
19391939
return self;

library/core/src/num/uint_macros.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1859,12 +1859,12 @@ macro_rules! uint_impl {
18591859
///
18601860
/// ```
18611861
/// #![feature(int_roundings)]
1862-
#[doc = concat!("assert_eq!(7_", stringify!($SelfT), ".div_floor(4), 1);")]
1862+
#[doc = concat!("assert_eq!(7_", stringify!($SelfT), ".unstable_div_floor(4), 1);")]
18631863
/// ```
18641864
#[unstable(feature = "int_roundings", issue = "88581")]
18651865
#[inline(always)]
18661866
#[rustc_inherit_overflow_checks]
1867-
pub const fn div_floor(self, rhs: Self) -> Self {
1867+
pub const fn unstable_div_floor(self, rhs: Self) -> Self {
18681868
self / rhs
18691869
}
18701870

@@ -1880,12 +1880,12 @@ macro_rules! uint_impl {
18801880
///
18811881
/// ```
18821882
/// #![feature(int_roundings)]
1883-
#[doc = concat!("assert_eq!(7_", stringify!($SelfT), ".div_ceil(4), 2);")]
1883+
#[doc = concat!("assert_eq!(7_", stringify!($SelfT), ".unstable_div_ceil(4), 2);")]
18841884
/// ```
18851885
#[unstable(feature = "int_roundings", issue = "88581")]
18861886
#[inline]
18871887
#[rustc_inherit_overflow_checks]
1888-
pub const fn div_ceil(self, rhs: Self) -> Self {
1888+
pub const fn unstable_div_ceil(self, rhs: Self) -> Self {
18891889
let d = self / rhs;
18901890
let r = self % rhs;
18911891
if r > 0 && rhs > 0 {
@@ -1908,15 +1908,15 @@ macro_rules! uint_impl {
19081908
///
19091909
/// ```
19101910
/// #![feature(int_roundings)]
1911-
#[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".next_multiple_of(8), 16);")]
1912-
#[doc = concat!("assert_eq!(23_", stringify!($SelfT), ".next_multiple_of(8), 24);")]
1911+
#[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".unstable_next_multiple_of(8), 16);")]
1912+
#[doc = concat!("assert_eq!(23_", stringify!($SelfT), ".unstable_next_multiple_of(8), 24);")]
19131913
/// ```
19141914
#[unstable(feature = "int_roundings", issue = "88581")]
19151915
#[must_use = "this returns the result of the operation, \
19161916
without modifying the original"]
19171917
#[inline]
19181918
#[rustc_inherit_overflow_checks]
1919-
pub const fn next_multiple_of(self, rhs: Self) -> Self {
1919+
pub const fn unstable_next_multiple_of(self, rhs: Self) -> Self {
19201920
match self % rhs {
19211921
0 => self,
19221922
r => self + (rhs - r)

library/core/tests/num/int_macros.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -294,33 +294,33 @@ macro_rules! int_module {
294294
fn test_div_floor() {
295295
let a: $T = 8;
296296
let b = 3;
297-
assert_eq!(a.div_floor(b), 2);
298-
assert_eq!(a.div_floor(-b), -3);
299-
assert_eq!((-a).div_floor(b), -3);
300-
assert_eq!((-a).div_floor(-b), 2);
297+
assert_eq!(a.unstable_div_floor(b), 2);
298+
assert_eq!(a.unstable_div_floor(-b), -3);
299+
assert_eq!((-a).unstable_div_floor(b), -3);
300+
assert_eq!((-a).unstable_div_floor(-b), 2);
301301
}
302302

303303
#[test]
304304
fn test_div_ceil() {
305305
let a: $T = 8;
306306
let b = 3;
307-
assert_eq!(a.div_ceil(b), 3);
308-
assert_eq!(a.div_ceil(-b), -2);
309-
assert_eq!((-a).div_ceil(b), -2);
310-
assert_eq!((-a).div_ceil(-b), 3);
307+
assert_eq!(a.unstable_div_ceil(b), 3);
308+
assert_eq!(a.unstable_div_ceil(-b), -2);
309+
assert_eq!((-a).unstable_div_ceil(b), -2);
310+
assert_eq!((-a).unstable_div_ceil(-b), 3);
311311
}
312312

313313
#[test]
314314
fn test_next_multiple_of() {
315-
assert_eq!((16 as $T).next_multiple_of(8), 16);
316-
assert_eq!((23 as $T).next_multiple_of(8), 24);
317-
assert_eq!((16 as $T).next_multiple_of(-8), 16);
318-
assert_eq!((23 as $T).next_multiple_of(-8), 16);
319-
assert_eq!((-16 as $T).next_multiple_of(8), -16);
320-
assert_eq!((-23 as $T).next_multiple_of(8), -16);
321-
assert_eq!((-16 as $T).next_multiple_of(-8), -16);
322-
assert_eq!((-23 as $T).next_multiple_of(-8), -24);
323-
assert_eq!(MIN.next_multiple_of(-1), MIN);
315+
assert_eq!((16 as $T).unstable_next_multiple_of(8), 16);
316+
assert_eq!((23 as $T).unstable_next_multiple_of(8), 24);
317+
assert_eq!((16 as $T).unstable_next_multiple_of(-8), 16);
318+
assert_eq!((23 as $T).unstable_next_multiple_of(-8), 16);
319+
assert_eq!((-16 as $T).unstable_next_multiple_of(8), -16);
320+
assert_eq!((-23 as $T).unstable_next_multiple_of(8), -16);
321+
assert_eq!((-16 as $T).unstable_next_multiple_of(-8), -16);
322+
assert_eq!((-23 as $T).unstable_next_multiple_of(-8), -24);
323+
assert_eq!(MIN.unstable_next_multiple_of(-1), MIN);
324324
}
325325

326326
#[test]

library/core/tests/num/uint_macros.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -208,19 +208,19 @@ macro_rules! uint_module {
208208

209209
#[test]
210210
fn test_div_floor() {
211-
assert_eq!((8 as $T).div_floor(3), 2);
211+
assert_eq!((8 as $T).unstable_div_floor(3), 2);
212212
}
213213

214214
#[test]
215215
fn test_div_ceil() {
216-
assert_eq!((8 as $T).div_ceil(3), 3);
216+
assert_eq!((8 as $T).unstable_div_ceil(3), 3);
217217
}
218218

219219
#[test]
220220
fn test_next_multiple_of() {
221-
assert_eq!((16 as $T).next_multiple_of(8), 16);
222-
assert_eq!((23 as $T).next_multiple_of(8), 24);
223-
assert_eq!(MAX.next_multiple_of(1), MAX);
221+
assert_eq!((16 as $T).unstable_next_multiple_of(8), 16);
222+
assert_eq!((23 as $T).unstable_next_multiple_of(8), 24);
223+
assert_eq!(MAX.unstable_next_multiple_of(1), MAX);
224224
}
225225

226226
#[test]

library/std/src/sync/mpsc/shared.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,11 @@ impl<T> Packet<T> {
248248
// Returns true if blocking should proceed.
249249
fn decrement(&self, token: SignalToken) -> StartResult {
250250
unsafe {
251-
assert_eq!(self.to_wake.load(Ordering::SeqCst), 0);
251+
assert_eq!(
252+
self.to_wake.load(Ordering::SeqCst),
253+
0,
254+
"This is a known bug in the Rust standard library. See https://github.com/rust-lang/rust/issues/39364"
255+
);
252256
let ptr = token.cast_to_usize();
253257
self.to_wake.store(ptr, Ordering::SeqCst);
254258

src/test/rustdoc/cross-crate-primitive-doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// aux-build:primitive-doc.rs
22
// compile-flags: --extern-html-root-url=primitive_doc=../ -Z unstable-options
3-
// ignore-windows
3+
// only-linux
44

55
#![feature(no_core)]
66
#![no_core]

src/test/rustdoc/intra-doc/prim-methods-external-core.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// aux-build:my-core.rs
22
// build-aux-docs
33
// ignore-cross-compile
4-
// ignore-windows
4+
// only-linux
55

66
#![deny(broken_intra_doc_links)]
77
#![feature(no_core, lang_items)]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// normalize-stderr-test: "couldn't read.*" -> "couldn't read the file"
2+
3+
#![feature(extended_key_value_attributes)]
4+
#![doc = include_str!("../not_existing_file.md")]
5+
struct Documented {}
6+
//~^^ ERROR couldn't read
7+
8+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: couldn't read the file
2+
--> $DIR/extented-attribute-macro-error.rs:4:10
3+
|
4+
LL | #![doc = include_str!("../not_existing_file.md")]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: this error originates in the macro `include_str` (in Nightly builds, run with -Z macro-backtrace for more info)
8+
9+
error: aborting due to previous error
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// run-rustfix
2+
3+
fn two_type_params<A, B>(_: B) {}
4+
5+
fn main() {
6+
two_type_params::<String, _>(100); //~ ERROR this function takes 2 generic arguments
7+
two_type_params::<String, _>(100);
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// run-rustfix
2+
3+
fn two_type_params<A, B>(_: B) {}
4+
5+
fn main() {
6+
two_type_params::<String>(100); //~ ERROR this function takes 2 generic arguments
7+
two_type_params::<String, _>(100);
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0107]: this function takes 2 generic arguments but 1 generic argument was supplied
2+
--> $DIR/missing-type-param-used-in-param.rs:6:5
3+
|
4+
LL | two_type_params::<String>(100);
5+
| ^^^^^^^^^^^^^^^ ------ supplied 1 generic argument
6+
| |
7+
| expected 2 generic arguments
8+
|
9+
note: function defined here, with 2 generic parameters: `A`, `B`
10+
--> $DIR/missing-type-param-used-in-param.rs:3:4
11+
|
12+
LL | fn two_type_params<A, B>(_: B) {}
13+
| ^^^^^^^^^^^^^^^ - -
14+
help: add missing generic argument
15+
|
16+
LL | two_type_params::<String, _>(100);
17+
| +++
18+
19+
error: aborting due to previous error
20+
21+
For more information about this error, try `rustc --explain E0107`.

0 commit comments

Comments
 (0)