Auto merge of #118646 - matthiaskrgr:rollup-jnscl9z, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #117922 (Tweak unclosed generics errors) - #118471 (Fix typos in README.md) - #118594 (Remove mention of rust to make the error message generic.) - #118598 (Remove the `precise_pointer_size_matching` feature gate) - #118606 (Fix `x` not to quit after `x` prints `settings.json`) - #118608 (Use default params until effects in desugaring) - #118614 (Update books) - #118637 (rustc_symbol_mangling,rustc_interface,rustc_driver_impl: Enforce `rustc::potential_query_instability` lint) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
ec94480d98
37 changed files with 163 additions and 154 deletions
|
@ -13,7 +13,6 @@
|
|||
#![feature(let_chains)]
|
||||
#![feature(panic_update_hook)]
|
||||
#![recursion_limit = "256"]
|
||||
#![allow(rustc::potential_query_instability)]
|
||||
#![deny(rustc::untranslatable_diagnostic)]
|
||||
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||
|
||||
|
|
|
@ -158,6 +158,9 @@ declare_features! (
|
|||
/// Allows using `#[plugin_registrar]` on functions.
|
||||
(removed, plugin_registrar, "1.54.0", Some(29597), None,
|
||||
Some("plugins are no longer supported")),
|
||||
/// Allows exhaustive integer pattern matching with `usize::MAX`/`isize::MIN`/`isize::MAX`.
|
||||
(removed, precise_pointer_size_matching, "1.32.0", Some(56354), None,
|
||||
Some("removed in favor of half-open ranges")),
|
||||
(removed, proc_macro_expr, "1.27.0", Some(54727), None,
|
||||
Some("subsumed by `#![feature(proc_macro_hygiene)]`")),
|
||||
(removed, proc_macro_gen, "1.27.0", Some(54727), None,
|
||||
|
|
|
@ -543,8 +543,6 @@ declare_features! (
|
|||
(unstable, offset_of_enum, "1.75.0", Some(106655), None),
|
||||
/// Allows using `#[optimize(X)]`.
|
||||
(unstable, optimize_attribute, "1.34.0", Some(54882), None),
|
||||
/// Allows exhaustive integer pattern matching on `usize` and `isize`.
|
||||
(unstable, precise_pointer_size_matching, "1.32.0", Some(56354), None),
|
||||
/// Allows macro attributes on expressions, statements and non-inline modules.
|
||||
(unstable, proc_macro_hygiene, "1.30.0", Some(54727), None),
|
||||
/// Allows `&raw const $place_expr` and `&raw mut $place_expr` expressions.
|
||||
|
|
|
@ -243,6 +243,31 @@ pub fn create_args_for_parent_generic_args<'tcx, 'a>(
|
|||
match (args_iter.peek(), params.peek()) {
|
||||
(Some(&arg), Some(¶m)) => {
|
||||
match (arg, ¶m.kind, arg_count.explicit_late_bound) {
|
||||
(
|
||||
GenericArg::Const(hir::ConstArg {
|
||||
is_desugared_from_effects: true,
|
||||
..
|
||||
}),
|
||||
GenericParamDefKind::Const { is_host_effect: false, .. }
|
||||
| GenericParamDefKind::Type { .. }
|
||||
| GenericParamDefKind::Lifetime,
|
||||
_,
|
||||
) => {
|
||||
// SPECIAL CASE FOR DESUGARED EFFECT PARAMS
|
||||
// This comes from the following example:
|
||||
//
|
||||
// ```
|
||||
// #[const_trait]
|
||||
// pub trait PartialEq<Rhs: ?Sized = Self> {}
|
||||
// impl const PartialEq for () {}
|
||||
// ```
|
||||
//
|
||||
// Since this is a const impl, we need to insert `<false>` at the end of
|
||||
// `PartialEq`'s generics, but this errors since `Rhs` isn't specified.
|
||||
// To work around this, we infer all arguments until we reach the host param.
|
||||
args.push(ctx.inferred_kind(Some(&args), param, infer_args));
|
||||
params.next();
|
||||
}
|
||||
(GenericArg::Lifetime(_), GenericParamDefKind::Lifetime, _)
|
||||
| (
|
||||
GenericArg::Type(_) | GenericArg::Infer(_),
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#![feature(let_chains)]
|
||||
#![feature(try_blocks)]
|
||||
#![recursion_limit = "256"]
|
||||
#![allow(rustc::potential_query_instability)]
|
||||
#![deny(rustc::untranslatable_diagnostic)]
|
||||
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||
|
||||
|
|
|
@ -306,6 +306,8 @@ fn early_lint_checks(tcx: TyCtxt<'_>, (): ()) {
|
|||
|
||||
// Gate identifiers containing invalid Unicode codepoints that were recovered during lexing.
|
||||
sess.parse_sess.bad_unicode_identifiers.with_lock(|identifiers| {
|
||||
// We will soon sort, so the initial order does not matter.
|
||||
#[allow(rustc::potential_query_instability)]
|
||||
let mut identifiers: Vec<_> = identifiers.drain().collect();
|
||||
identifiers.sort_by_key(|&(key, _)| key);
|
||||
for (ident, mut spans) in identifiers.into_iter() {
|
||||
|
@ -431,6 +433,9 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
|
|||
escape_dep_filename(&file.prefer_local().to_string())
|
||||
};
|
||||
|
||||
// The entries will be used to declare dependencies beween files in a
|
||||
// Makefile-like output, so the iteration order does not matter.
|
||||
#[allow(rustc::potential_query_instability)]
|
||||
let extra_tracked_files =
|
||||
file_depinfo.iter().map(|path_sym| normalize_path(PathBuf::from(path_sym.as_str())));
|
||||
files.extend(extra_tracked_files);
|
||||
|
@ -486,6 +491,8 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
|
|||
// Emit special comments with information about accessed environment variables.
|
||||
let env_depinfo = sess.parse_sess.env_depinfo.borrow();
|
||||
if !env_depinfo.is_empty() {
|
||||
// We will soon sort, so the initial order does not matter.
|
||||
#[allow(rustc::potential_query_instability)]
|
||||
let mut envs: Vec<_> = env_depinfo
|
||||
.iter()
|
||||
.map(|(k, v)| (escape_dep_env(*k), v.map(escape_dep_env)))
|
||||
|
|
|
@ -867,12 +867,6 @@ fn report_non_exhaustive_match<'p, 'tcx>(
|
|||
exhaustively",
|
||||
));
|
||||
}
|
||||
if cx.tcx.sess.is_nightly_build() {
|
||||
err.help(format!(
|
||||
"add `#![feature(precise_pointer_size_matching)]` to the crate attributes to \
|
||||
enable precise `{ty}` matching",
|
||||
));
|
||||
}
|
||||
} else if ty == cx.tcx.types.str_ {
|
||||
err.note("`&str` cannot be matched exhaustively, so a wildcard `_` is necessary");
|
||||
} else if cx.is_foreign_non_exhaustive_enum(ty) {
|
||||
|
|
|
@ -326,8 +326,7 @@ impl IntRange {
|
|||
/// `NegInfinity..PosInfinity`. In other words, as far as `IntRange` is concerned, there are
|
||||
/// values before `isize::MIN` and after `usize::MAX`/`isize::MAX`.
|
||||
/// This is to avoid e.g. `0..(u32::MAX as usize)` from being exhaustive on one architecture and
|
||||
/// not others. See discussions around the `precise_pointer_size_matching` feature for more
|
||||
/// details.
|
||||
/// not others. This was decided in <https://github.com/rust-lang/rfcs/pull/2591>.
|
||||
///
|
||||
/// These infinities affect splitting subtly: it is possible to get `NegInfinity..0` and
|
||||
/// `usize::MAX+1..PosInfinity` in the output. Diagnostics must be careful to handle these
|
||||
|
@ -380,7 +379,7 @@ impl IntRange {
|
|||
/// Whether the range denotes the fictitious values before `isize::MIN` or after
|
||||
/// `usize::MAX`/`isize::MAX` (see doc of [`IntRange::split`] for why these exist).
|
||||
pub(crate) fn is_beyond_boundaries<'tcx>(&self, ty: Ty<'tcx>, tcx: TyCtxt<'tcx>) -> bool {
|
||||
ty.is_ptr_sized_integral() && !tcx.features().precise_pointer_size_matching && {
|
||||
ty.is_ptr_sized_integral() && {
|
||||
// The two invalid ranges are `NegInfinity..isize::MIN` (represented as
|
||||
// `NegInfinity..0`), and `{u,i}size::MAX+1..PosInfinity`. `to_diagnostic_pat_range_bdy`
|
||||
// converts `MAX+1` to `PosInfinity`, and we couldn't have `PosInfinity` in `self.lo`
|
||||
|
@ -941,11 +940,8 @@ impl ConstructorSet {
|
|||
}
|
||||
}
|
||||
&ty::Int(ity) => {
|
||||
let range = if ty.is_ptr_sized_integral()
|
||||
&& !cx.tcx.features().precise_pointer_size_matching
|
||||
{
|
||||
// The min/max values of `isize` are not allowed to be observed unless the
|
||||
// `precise_pointer_size_matching` feature is enabled.
|
||||
let range = if ty.is_ptr_sized_integral() {
|
||||
// The min/max values of `isize` are not allowed to be observed.
|
||||
IntRange { lo: NegInfinity, hi: PosInfinity }
|
||||
} else {
|
||||
let bits = Integer::from_int_ty(&cx.tcx, ity).size().bits() as u128;
|
||||
|
@ -956,11 +952,8 @@ impl ConstructorSet {
|
|||
Self::Integers { range_1: range, range_2: None }
|
||||
}
|
||||
&ty::Uint(uty) => {
|
||||
let range = if ty.is_ptr_sized_integral()
|
||||
&& !cx.tcx.features().precise_pointer_size_matching
|
||||
{
|
||||
// The max value of `usize` is not allowed to be observed unless the
|
||||
// `precise_pointer_size_matching` feature is enabled.
|
||||
let range = if ty.is_ptr_sized_integral() {
|
||||
// The max value of `usize` is not allowed to be observed.
|
||||
let lo = MaybeInfiniteInt::new_finite(cx.tcx, ty, 0);
|
||||
IntRange { lo, hi: PosInfinity }
|
||||
} else {
|
||||
|
|
|
@ -673,15 +673,6 @@ impl<'a> Parser<'a> {
|
|||
);
|
||||
}
|
||||
|
||||
// Add suggestion for a missing closing angle bracket if '>' is included in expected_tokens
|
||||
// there are unclosed angle brackets
|
||||
if self.unmatched_angle_bracket_count > 0
|
||||
&& self.token.kind == TokenKind::Eq
|
||||
&& expected.iter().any(|tok| matches!(tok, TokenType::Token(TokenKind::Gt)))
|
||||
{
|
||||
err.span_label(self.prev_token.span, "maybe try to close unmatched angle bracket");
|
||||
}
|
||||
|
||||
let sp = if self.token == token::Eof {
|
||||
// This is EOF; don't want to point at the following char, but rather the last token.
|
||||
self.prev_token.span
|
||||
|
@ -811,6 +802,7 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
err.emit();
|
||||
}
|
||||
|
||||
fn check_too_many_raw_str_terminators(&mut self, err: &mut Diagnostic) -> bool {
|
||||
let sm = self.sess.source_map();
|
||||
match (&self.prev_token.kind, &self.token.kind) {
|
||||
|
@ -1986,6 +1978,39 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// When trying to close a generics list and encountering code like
|
||||
/// ```text
|
||||
/// impl<S: Into<std::borrow::Cow<'static, str>> From<S> for Canonical {}
|
||||
/// // ^ missing > here
|
||||
/// ```
|
||||
/// we provide a structured suggestion on the error from `expect_gt`.
|
||||
pub(super) fn expect_gt_or_maybe_suggest_closing_generics(
|
||||
&mut self,
|
||||
params: &[ast::GenericParam],
|
||||
) -> PResult<'a, ()> {
|
||||
let Err(mut err) = self.expect_gt() else {
|
||||
return Ok(());
|
||||
};
|
||||
// Attempt to find places where a missing `>` might belong.
|
||||
if let [.., ast::GenericParam { bounds, .. }] = params
|
||||
&& let Some(poly) = bounds
|
||||
.iter()
|
||||
.filter_map(|bound| match bound {
|
||||
ast::GenericBound::Trait(poly, _) => Some(poly),
|
||||
_ => None,
|
||||
})
|
||||
.last()
|
||||
{
|
||||
err.span_suggestion_verbose(
|
||||
poly.span.shrink_to_hi(),
|
||||
"you might have meant to end the type parameters here",
|
||||
">",
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
}
|
||||
Err(err)
|
||||
}
|
||||
|
||||
pub(super) fn recover_seq_parse_error(
|
||||
&mut self,
|
||||
delim: Delimiter,
|
||||
|
|
|
@ -279,7 +279,7 @@ impl<'a> Parser<'a> {
|
|||
let span_lo = self.token.span;
|
||||
let (params, span) = if self.eat_lt() {
|
||||
let params = self.parse_generic_params()?;
|
||||
self.expect_gt()?;
|
||||
self.expect_gt_or_maybe_suggest_closing_generics(¶ms)?;
|
||||
(params, span_lo.to(self.prev_token.span))
|
||||
} else {
|
||||
(ThinVec::new(), self.prev_token.span.shrink_to_hi())
|
||||
|
|
|
@ -93,7 +93,6 @@
|
|||
#![allow(internal_features)]
|
||||
#![feature(never_type)]
|
||||
#![recursion_limit = "256"]
|
||||
#![allow(rustc::potential_query_instability)]
|
||||
#![deny(rustc::untranslatable_diagnostic)]
|
||||
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue