Skip to content

Commit

Permalink
Auto merge of rust-lang#118646 - matthiaskrgr:rollup-jnscl9z, r=matth…
Browse files Browse the repository at this point in the history
…iaskrgr

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
  • Loading branch information
bors committed Dec 5, 2023
2 parents 8a7b203 + d367db2 commit ec94480
Show file tree
Hide file tree
Showing 37 changed files with 163 additions and 154 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ If you wish to _contribute_ to the compiler, you should read
[CONTRIBUTING.md](CONTRIBUTING.md) instead.

<details>
<summary>Table of content</summary>
<summary>Table of Contents</summary>

- [Quick Start](#quick-start)
- [Installing from Source](#installing-from-source)
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]

Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_feature/src/removed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
25 changes: 25 additions & 0 deletions compiler/rustc_hir_analysis/src/astconv/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,31 @@ pub fn create_args_for_parent_generic_args<'tcx, 'a>(
match (args_iter.peek(), params.peek()) {
(Some(&arg), Some(&param)) => {
match (arg, &param.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(_),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]

Expand Down
7 changes: 7 additions & 0 deletions compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)))
Expand Down
6 changes: 0 additions & 6 deletions compiler/rustc_mir_build/src/thir/pattern/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
19 changes: 6 additions & 13 deletions compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
43 changes: 34 additions & 9 deletions compiler/rustc_parse/src/parser/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(&params)?;
(params, span_lo.to(self.prev_token.span))
} else {
(ThinVec::new(), self.prev_token.span.shrink_to_hi())
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_symbol_mangling/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]

Expand Down
13 changes: 7 additions & 6 deletions src/bootstrap/src/core/build_steps/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,12 +549,13 @@ impl Step for Vscode {
if config.dry_run() {
return;
}
t!(create_vscode_settings_maybe(&config));
while !t!(create_vscode_settings_maybe(&config)) {}
}
}

/// Create a `.vscode/settings.json` file for rustc development, or just print it
fn create_vscode_settings_maybe(config: &Config) -> io::Result<()> {
/// If this method should be re-called, it returns `false`.
fn create_vscode_settings_maybe(config: &Config) -> io::Result<bool> {
let (current_hash, historical_hashes) = SETTINGS_HASHES.split_last().unwrap();
let vscode_settings = config.src.join(".vscode").join("settings.json");
// If None, no settings.json exists
Expand All @@ -567,7 +568,7 @@ fn create_vscode_settings_maybe(config: &Config) -> io::Result<()> {
hasher.update(&current);
let hash = hex::encode(hasher.finalize().as_slice());
if hash == *current_hash {
return Ok(());
return Ok(true);
} else if historical_hashes.contains(&hash.as_str()) {
mismatched_settings = Some(true);
} else {
Expand All @@ -587,13 +588,13 @@ fn create_vscode_settings_maybe(config: &Config) -> io::Result<()> {
_ => (),
}
let should_create = match prompt_user(
"Would you like to create/update `settings.json`, or only print suggested settings?: [y/p/N]",
"Would you like to create/update settings.json? (Press 'p' to preview values): [y/N]",
)? {
Some(PromptResult::Yes) => true,
Some(PromptResult::Print) => false,
_ => {
println!("Ok, skipping settings!");
return Ok(());
return Ok(true);
}
};
if should_create {
Expand All @@ -620,5 +621,5 @@ fn create_vscode_settings_maybe(config: &Config) -> io::Result<()> {
} else {
println!("\n{RUST_ANALYZER_SETTINGS}");
}
Ok(())
Ok(should_create)
}
2 changes: 1 addition & 1 deletion src/doc/nomicon
Submodule nomicon updated 1 files
+19 −14 src/races.md
2 changes: 1 addition & 1 deletion src/doc/rust-by-example
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ fn short_item_info(
format!("Deprecating in {version}")
}
}
DeprecatedSince::Future => String::from("Deprecating in a future Rust version"),
DeprecatedSince::Future => String::from("Deprecating in a future version"),
DeprecatedSince::NonStandard(since) => {
format!("Deprecated since {}", Escape(since.as_str()))
}
Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc/deprecated-future-staged-api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct S1;
// @has deprecated_future_staged_api/index.html '//*[@class="stab deprecated"]' \
// 'Deprecation planned'
// @has deprecated_future_staged_api/struct.S2.html '//*[@class="stab deprecated"]' \
// 'Deprecating in a future Rust version: literally never'
// 'Deprecating in a future version: literally never'
#[deprecated(since = "TBD", note = "literally never")]
#[stable(feature = "deprecated_future_staged_api", since = "1.0.0")]
pub struct S2;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ LL | match 0usize {
|
= note: the matched value is of type `usize`
= note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ 0..=usize::MAX => {},
Expand All @@ -21,7 +20,6 @@ LL | match 0isize {
|
= note: the matched value is of type `isize`
= note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching
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
|
LL ~ isize::MIN..=isize::MAX => {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `=`
--> $DIR/trait-path-expected-token.rs:5:33
|
LL | fn f1<'a>(arg : Box<dyn X<Y = B = &'a ()>>) {}
| - ^ expected one of 7 possible tokens
| |
| maybe try to close unmatched angle bracket
| ^ expected one of 7 possible tokens

error: aborting due to 1 previous error

Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ error: expected one of `,`, `:`, or `>`, found `=`
--> $DIR/trait-path-expressions.rs:16:36
|
LL | fn f2<'a>(arg : Box<dyn X< { 1 } = 32 >>) {}
| - ^ expected one of `,`, `:`, or `>`
| |
| maybe try to close unmatched angle bracket
| ^ expected one of `,`, `:`, or `>`
|
help: you might have meant to end the type parameters here
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ error: expected one of `>`, a const expression, lifetime, or type, found `=`
--> $DIR/trait-path-missing-gen_arg.rs:11:30
|
LL | fn f1<'a>(arg : Box<dyn X< = 32 >>) {}
| - ^ expected one of `>`, a const expression, lifetime, or type
| |
| maybe try to close unmatched angle bracket
| ^ expected one of `>`, a const expression, lifetime, or type

error: aborting due to 2 previous errors

Loading

0 comments on commit ec94480

Please sign in to comment.