Skip to content

Commit ec94480

Browse files
committed
Auto merge of rust-lang#118646 - matthiaskrgr:rollup-jnscl9z, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang#117922 (Tweak unclosed generics errors) - rust-lang#118471 (Fix typos in README.md) - rust-lang#118594 (Remove mention of rust to make the error message generic.) - rust-lang#118598 (Remove the `precise_pointer_size_matching` feature gate) - rust-lang#118606 (Fix `x` not to quit after `x` prints `settings.json`) - rust-lang#118608 (Use default params until effects in desugaring) - rust-lang#118614 (Update books) - rust-lang#118637 (rustc_symbol_mangling,rustc_interface,rustc_driver_impl: Enforce `rustc::potential_query_instability` lint) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8a7b203 + d367db2 commit ec94480

37 files changed

+163
-154
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ If you wish to _contribute_ to the compiler, you should read
1212
[CONTRIBUTING.md](CONTRIBUTING.md) instead.
1313

1414
<details>
15-
<summary>Table of content</summary>
15+
<summary>Table of Contents</summary>
1616

1717
- [Quick Start](#quick-start)
1818
- [Installing from Source](#installing-from-source)

compiler/rustc_driver_impl/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#![feature(let_chains)]
1414
#![feature(panic_update_hook)]
1515
#![recursion_limit = "256"]
16-
#![allow(rustc::potential_query_instability)]
1716
#![deny(rustc::untranslatable_diagnostic)]
1817
#![deny(rustc::diagnostic_outside_of_impl)]
1918

compiler/rustc_feature/src/removed.rs

+3
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ declare_features! (
158158
/// Allows using `#[plugin_registrar]` on functions.
159159
(removed, plugin_registrar, "1.54.0", Some(29597), None,
160160
Some("plugins are no longer supported")),
161+
/// Allows exhaustive integer pattern matching with `usize::MAX`/`isize::MIN`/`isize::MAX`.
162+
(removed, precise_pointer_size_matching, "1.32.0", Some(56354), None,
163+
Some("removed in favor of half-open ranges")),
161164
(removed, proc_macro_expr, "1.27.0", Some(54727), None,
162165
Some("subsumed by `#![feature(proc_macro_hygiene)]`")),
163166
(removed, proc_macro_gen, "1.27.0", Some(54727), None,

compiler/rustc_feature/src/unstable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -543,8 +543,6 @@ declare_features! (
543543
(unstable, offset_of_enum, "1.75.0", Some(106655), None),
544544
/// Allows using `#[optimize(X)]`.
545545
(unstable, optimize_attribute, "1.34.0", Some(54882), None),
546-
/// Allows exhaustive integer pattern matching on `usize` and `isize`.
547-
(unstable, precise_pointer_size_matching, "1.32.0", Some(56354), None),
548546
/// Allows macro attributes on expressions, statements and non-inline modules.
549547
(unstable, proc_macro_hygiene, "1.30.0", Some(54727), None),
550548
/// Allows `&raw const $place_expr` and `&raw mut $place_expr` expressions.

compiler/rustc_hir_analysis/src/astconv/generics.rs

+25
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,31 @@ pub fn create_args_for_parent_generic_args<'tcx, 'a>(
243243
match (args_iter.peek(), params.peek()) {
244244
(Some(&arg), Some(&param)) => {
245245
match (arg, &param.kind, arg_count.explicit_late_bound) {
246+
(
247+
GenericArg::Const(hir::ConstArg {
248+
is_desugared_from_effects: true,
249+
..
250+
}),
251+
GenericParamDefKind::Const { is_host_effect: false, .. }
252+
| GenericParamDefKind::Type { .. }
253+
| GenericParamDefKind::Lifetime,
254+
_,
255+
) => {
256+
// SPECIAL CASE FOR DESUGARED EFFECT PARAMS
257+
// This comes from the following example:
258+
//
259+
// ```
260+
// #[const_trait]
261+
// pub trait PartialEq<Rhs: ?Sized = Self> {}
262+
// impl const PartialEq for () {}
263+
// ```
264+
//
265+
// Since this is a const impl, we need to insert `<false>` at the end of
266+
// `PartialEq`'s generics, but this errors since `Rhs` isn't specified.
267+
// To work around this, we infer all arguments until we reach the host param.
268+
args.push(ctx.inferred_kind(Some(&args), param, infer_args));
269+
params.next();
270+
}
246271
(GenericArg::Lifetime(_), GenericParamDefKind::Lifetime, _)
247272
| (
248273
GenericArg::Type(_) | GenericArg::Infer(_),

compiler/rustc_interface/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#![feature(let_chains)]
77
#![feature(try_blocks)]
88
#![recursion_limit = "256"]
9-
#![allow(rustc::potential_query_instability)]
109
#![deny(rustc::untranslatable_diagnostic)]
1110
#![deny(rustc::diagnostic_outside_of_impl)]
1211

compiler/rustc_interface/src/passes.rs

+7
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@ fn early_lint_checks(tcx: TyCtxt<'_>, (): ()) {
306306

307307
// Gate identifiers containing invalid Unicode codepoints that were recovered during lexing.
308308
sess.parse_sess.bad_unicode_identifiers.with_lock(|identifiers| {
309+
// We will soon sort, so the initial order does not matter.
310+
#[allow(rustc::potential_query_instability)]
309311
let mut identifiers: Vec<_> = identifiers.drain().collect();
310312
identifiers.sort_by_key(|&(key, _)| key);
311313
for (ident, mut spans) in identifiers.into_iter() {
@@ -431,6 +433,9 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
431433
escape_dep_filename(&file.prefer_local().to_string())
432434
};
433435

436+
// The entries will be used to declare dependencies beween files in a
437+
// Makefile-like output, so the iteration order does not matter.
438+
#[allow(rustc::potential_query_instability)]
434439
let extra_tracked_files =
435440
file_depinfo.iter().map(|path_sym| normalize_path(PathBuf::from(path_sym.as_str())));
436441
files.extend(extra_tracked_files);
@@ -486,6 +491,8 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
486491
// Emit special comments with information about accessed environment variables.
487492
let env_depinfo = sess.parse_sess.env_depinfo.borrow();
488493
if !env_depinfo.is_empty() {
494+
// We will soon sort, so the initial order does not matter.
495+
#[allow(rustc::potential_query_instability)]
489496
let mut envs: Vec<_> = env_depinfo
490497
.iter()
491498
.map(|(k, v)| (escape_dep_env(*k), v.map(escape_dep_env)))

compiler/rustc_mir_build/src/thir/pattern/check_match.rs

-6
Original file line numberDiff line numberDiff line change
@@ -867,12 +867,6 @@ fn report_non_exhaustive_match<'p, 'tcx>(
867867
exhaustively",
868868
));
869869
}
870-
if cx.tcx.sess.is_nightly_build() {
871-
err.help(format!(
872-
"add `#![feature(precise_pointer_size_matching)]` to the crate attributes to \
873-
enable precise `{ty}` matching",
874-
));
875-
}
876870
} else if ty == cx.tcx.types.str_ {
877871
err.note("`&str` cannot be matched exhaustively, so a wildcard `_` is necessary");
878872
} else if cx.is_foreign_non_exhaustive_enum(ty) {

compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs

+6-13
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,7 @@ impl IntRange {
326326
/// `NegInfinity..PosInfinity`. In other words, as far as `IntRange` is concerned, there are
327327
/// values before `isize::MIN` and after `usize::MAX`/`isize::MAX`.
328328
/// This is to avoid e.g. `0..(u32::MAX as usize)` from being exhaustive on one architecture and
329-
/// not others. See discussions around the `precise_pointer_size_matching` feature for more
330-
/// details.
329+
/// not others. This was decided in <https://github.com/rust-lang/rfcs/pull/2591>.
331330
///
332331
/// These infinities affect splitting subtly: it is possible to get `NegInfinity..0` and
333332
/// `usize::MAX+1..PosInfinity` in the output. Diagnostics must be careful to handle these
@@ -380,7 +379,7 @@ impl IntRange {
380379
/// Whether the range denotes the fictitious values before `isize::MIN` or after
381380
/// `usize::MAX`/`isize::MAX` (see doc of [`IntRange::split`] for why these exist).
382381
pub(crate) fn is_beyond_boundaries<'tcx>(&self, ty: Ty<'tcx>, tcx: TyCtxt<'tcx>) -> bool {
383-
ty.is_ptr_sized_integral() && !tcx.features().precise_pointer_size_matching && {
382+
ty.is_ptr_sized_integral() && {
384383
// The two invalid ranges are `NegInfinity..isize::MIN` (represented as
385384
// `NegInfinity..0`), and `{u,i}size::MAX+1..PosInfinity`. `to_diagnostic_pat_range_bdy`
386385
// converts `MAX+1` to `PosInfinity`, and we couldn't have `PosInfinity` in `self.lo`
@@ -941,11 +940,8 @@ impl ConstructorSet {
941940
}
942941
}
943942
&ty::Int(ity) => {
944-
let range = if ty.is_ptr_sized_integral()
945-
&& !cx.tcx.features().precise_pointer_size_matching
946-
{
947-
// The min/max values of `isize` are not allowed to be observed unless the
948-
// `precise_pointer_size_matching` feature is enabled.
943+
let range = if ty.is_ptr_sized_integral() {
944+
// The min/max values of `isize` are not allowed to be observed.
949945
IntRange { lo: NegInfinity, hi: PosInfinity }
950946
} else {
951947
let bits = Integer::from_int_ty(&cx.tcx, ity).size().bits() as u128;
@@ -956,11 +952,8 @@ impl ConstructorSet {
956952
Self::Integers { range_1: range, range_2: None }
957953
}
958954
&ty::Uint(uty) => {
959-
let range = if ty.is_ptr_sized_integral()
960-
&& !cx.tcx.features().precise_pointer_size_matching
961-
{
962-
// The max value of `usize` is not allowed to be observed unless the
963-
// `precise_pointer_size_matching` feature is enabled.
955+
let range = if ty.is_ptr_sized_integral() {
956+
// The max value of `usize` is not allowed to be observed.
964957
let lo = MaybeInfiniteInt::new_finite(cx.tcx, ty, 0);
965958
IntRange { lo, hi: PosInfinity }
966959
} else {

compiler/rustc_parse/src/parser/diagnostics.rs

+34-9
Original file line numberDiff line numberDiff line change
@@ -673,15 +673,6 @@ impl<'a> Parser<'a> {
673673
);
674674
}
675675

676-
// Add suggestion for a missing closing angle bracket if '>' is included in expected_tokens
677-
// there are unclosed angle brackets
678-
if self.unmatched_angle_bracket_count > 0
679-
&& self.token.kind == TokenKind::Eq
680-
&& expected.iter().any(|tok| matches!(tok, TokenType::Token(TokenKind::Gt)))
681-
{
682-
err.span_label(self.prev_token.span, "maybe try to close unmatched angle bracket");
683-
}
684-
685676
let sp = if self.token == token::Eof {
686677
// This is EOF; don't want to point at the following char, but rather the last token.
687678
self.prev_token.span
@@ -811,6 +802,7 @@ impl<'a> Parser<'a> {
811802
}
812803
err.emit();
813804
}
805+
814806
fn check_too_many_raw_str_terminators(&mut self, err: &mut Diagnostic) -> bool {
815807
let sm = self.sess.source_map();
816808
match (&self.prev_token.kind, &self.token.kind) {
@@ -1986,6 +1978,39 @@ impl<'a> Parser<'a> {
19861978
}
19871979
}
19881980

1981+
/// When trying to close a generics list and encountering code like
1982+
/// ```text
1983+
/// impl<S: Into<std::borrow::Cow<'static, str>> From<S> for Canonical {}
1984+
/// // ^ missing > here
1985+
/// ```
1986+
/// we provide a structured suggestion on the error from `expect_gt`.
1987+
pub(super) fn expect_gt_or_maybe_suggest_closing_generics(
1988+
&mut self,
1989+
params: &[ast::GenericParam],
1990+
) -> PResult<'a, ()> {
1991+
let Err(mut err) = self.expect_gt() else {
1992+
return Ok(());
1993+
};
1994+
// Attempt to find places where a missing `>` might belong.
1995+
if let [.., ast::GenericParam { bounds, .. }] = params
1996+
&& let Some(poly) = bounds
1997+
.iter()
1998+
.filter_map(|bound| match bound {
1999+
ast::GenericBound::Trait(poly, _) => Some(poly),
2000+
_ => None,
2001+
})
2002+
.last()
2003+
{
2004+
err.span_suggestion_verbose(
2005+
poly.span.shrink_to_hi(),
2006+
"you might have meant to end the type parameters here",
2007+
">",
2008+
Applicability::MaybeIncorrect,
2009+
);
2010+
}
2011+
Err(err)
2012+
}
2013+
19892014
pub(super) fn recover_seq_parse_error(
19902015
&mut self,
19912016
delim: Delimiter,

compiler/rustc_parse/src/parser/generics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ impl<'a> Parser<'a> {
279279
let span_lo = self.token.span;
280280
let (params, span) = if self.eat_lt() {
281281
let params = self.parse_generic_params()?;
282-
self.expect_gt()?;
282+
self.expect_gt_or_maybe_suggest_closing_generics(&params)?;
283283
(params, span_lo.to(self.prev_token.span))
284284
} else {
285285
(ThinVec::new(), self.prev_token.span.shrink_to_hi())

compiler/rustc_symbol_mangling/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393
#![allow(internal_features)]
9494
#![feature(never_type)]
9595
#![recursion_limit = "256"]
96-
#![allow(rustc::potential_query_instability)]
9796
#![deny(rustc::untranslatable_diagnostic)]
9897
#![deny(rustc::diagnostic_outside_of_impl)]
9998

src/bootstrap/src/core/build_steps/setup.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -549,12 +549,13 @@ impl Step for Vscode {
549549
if config.dry_run() {
550550
return;
551551
}
552-
t!(create_vscode_settings_maybe(&config));
552+
while !t!(create_vscode_settings_maybe(&config)) {}
553553
}
554554
}
555555

556556
/// Create a `.vscode/settings.json` file for rustc development, or just print it
557-
fn create_vscode_settings_maybe(config: &Config) -> io::Result<()> {
557+
/// If this method should be re-called, it returns `false`.
558+
fn create_vscode_settings_maybe(config: &Config) -> io::Result<bool> {
558559
let (current_hash, historical_hashes) = SETTINGS_HASHES.split_last().unwrap();
559560
let vscode_settings = config.src.join(".vscode").join("settings.json");
560561
// If None, no settings.json exists
@@ -567,7 +568,7 @@ fn create_vscode_settings_maybe(config: &Config) -> io::Result<()> {
567568
hasher.update(&current);
568569
let hash = hex::encode(hasher.finalize().as_slice());
569570
if hash == *current_hash {
570-
return Ok(());
571+
return Ok(true);
571572
} else if historical_hashes.contains(&hash.as_str()) {
572573
mismatched_settings = Some(true);
573574
} else {
@@ -587,13 +588,13 @@ fn create_vscode_settings_maybe(config: &Config) -> io::Result<()> {
587588
_ => (),
588589
}
589590
let should_create = match prompt_user(
590-
"Would you like to create/update `settings.json`, or only print suggested settings?: [y/p/N]",
591+
"Would you like to create/update settings.json? (Press 'p' to preview values): [y/N]",
591592
)? {
592593
Some(PromptResult::Yes) => true,
593594
Some(PromptResult::Print) => false,
594595
_ => {
595596
println!("Ok, skipping settings!");
596-
return Ok(());
597+
return Ok(true);
597598
}
598599
};
599600
if should_create {
@@ -620,5 +621,5 @@ fn create_vscode_settings_maybe(config: &Config) -> io::Result<()> {
620621
} else {
621622
println!("\n{RUST_ANALYZER_SETTINGS}");
622623
}
623-
Ok(())
624+
Ok(should_create)
624625
}

src/doc/nomicon

src/librustdoc/html/render/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ fn short_item_info(
673673
format!("Deprecating in {version}")
674674
}
675675
}
676-
DeprecatedSince::Future => String::from("Deprecating in a future Rust version"),
676+
DeprecatedSince::Future => String::from("Deprecating in a future version"),
677677
DeprecatedSince::NonStandard(since) => {
678678
format!("Deprecated since {}", Escape(since.as_str()))
679679
}

tests/rustdoc/deprecated-future-staged-api.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub struct S1;
1212
// @has deprecated_future_staged_api/index.html '//*[@class="stab deprecated"]' \
1313
// 'Deprecation planned'
1414
// @has deprecated_future_staged_api/struct.S2.html '//*[@class="stab deprecated"]' \
15-
// 'Deprecating in a future Rust version: literally never'
15+
// 'Deprecating in a future version: literally never'
1616
#[deprecated(since = "TBD", note = "literally never")]
1717
#[stable(feature = "deprecated_future_staged_api", since = "1.0.0")]
1818
pub struct S2;

tests/ui/feature-gates/feature-gate-precise_pointer_size_matching.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ LL | match 0usize {
66
|
77
= note: the matched value is of type `usize`
88
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
9-
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching
109
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
1110
|
1211
LL ~ 0..=usize::MAX => {},
@@ -21,7 +20,6 @@ LL | match 0isize {
2120
|
2221
= note: the matched value is of type `isize`
2322
= note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
24-
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching
2523
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
2624
|
2725
LL ~ isize::MIN..=isize::MAX => {},

tests/ui/generic-associated-types/parse/trait-path-expected-token.stderr

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `=`
22
--> $DIR/trait-path-expected-token.rs:5:33
33
|
44
LL | fn f1<'a>(arg : Box<dyn X<Y = B = &'a ()>>) {}
5-
| - ^ expected one of 7 possible tokens
6-
| |
7-
| maybe try to close unmatched angle bracket
5+
| ^ expected one of 7 possible tokens
86

97
error: aborting due to 1 previous error
108

tests/ui/generic-associated-types/parse/trait-path-expressions.stderr

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ error: expected one of `,`, `:`, or `>`, found `=`
1010
--> $DIR/trait-path-expressions.rs:16:36
1111
|
1212
LL | fn f2<'a>(arg : Box<dyn X< { 1 } = 32 >>) {}
13-
| - ^ expected one of `,`, `:`, or `>`
14-
| |
15-
| maybe try to close unmatched angle bracket
13+
| ^ expected one of `,`, `:`, or `>`
1614
|
1715
help: you might have meant to end the type parameters here
1816
|

tests/ui/generic-associated-types/parse/trait-path-missing-gen_arg.stderr

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ error: expected one of `>`, a const expression, lifetime, or type, found `=`
88
--> $DIR/trait-path-missing-gen_arg.rs:11:30
99
|
1010
LL | fn f1<'a>(arg : Box<dyn X< = 32 >>) {}
11-
| - ^ expected one of `>`, a const expression, lifetime, or type
12-
| |
13-
| maybe try to close unmatched angle bracket
11+
| ^ expected one of `>`, a const expression, lifetime, or type
1412

1513
error: aborting due to 2 previous errors
1614

0 commit comments

Comments
 (0)