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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 25 additions & 0 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 7 additions & 0 deletions
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

Lines changed: 0 additions & 6 deletions
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

Lines changed: 6 additions & 13 deletions
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

Lines changed: 34 additions & 9 deletions
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,

0 commit comments

Comments
 (0)