Skip to content

Rollup of 8 pull requests #118646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Dec 5, 2023
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
b80d074
Fix typo in README.md
filenine Nov 30, 2023
605381a
Capitalize ToC in README.md
filenine Nov 30, 2023
4e99db9
Tweak unclosed generics errors
estebank Nov 15, 2023
5e470db
Remove the `precise_pointer_size_matching` feature gate
Nadrieril Dec 4, 2023
e6a14c0
Use default params until effects in desugaring
fee1-dead Dec 4, 2023
8fb7117
Update books
rustbot Dec 4, 2023
0e3e16c
rustc_driver_impl: Address all `rustc::potential_query_instability` l…
Enselic Dec 5, 2023
ae2427d
rustc_interface: Address all `rustc::potential_query_instability` lints
Enselic Dec 5, 2023
d7d867d
rustc_symbol_mangling: Address all `rustc::potential_query_instabilit…
Enselic Dec 5, 2023
1b50304
Remove mention of rust to make the error message generic.
hdost Dec 4, 2023
15a8e9d
Fix x not to quit when x prints settings.json
long-long-float Dec 4, 2023
2d01eee
Rollup merge of #117922 - estebank:unclosed-generics, r=b-naber
matthiaskrgr Dec 5, 2023
30b4cef
Rollup merge of #118471 - filenine:fix-typos, r=workingjubilee
matthiaskrgr Dec 5, 2023
fddda14
Rollup merge of #118594 - hdost:patch-1, r=fmease
matthiaskrgr Dec 5, 2023
81b6263
Rollup merge of #118598 - Nadrieril:remove_precise_pointer_size_match…
matthiaskrgr Dec 5, 2023
a260acc
Rollup merge of #118606 - long-long-float:x-do-not-quit-when-x-prints…
matthiaskrgr Dec 5, 2023
c6c0c65
Rollup merge of #118608 - fee1-dead-contrib:backdoor-in-askconv, r=co…
matthiaskrgr Dec 5, 2023
4b40b1b
Rollup merge of #118614 - rustbot:docs-update, r=ehuss
matthiaskrgr Dec 5, 2023
d367db2
Rollup merge of #118637 - Enselic:query-instability-2, r=cjgillot
matthiaskrgr Dec 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)
1 change: 0 additions & 1 deletion compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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)]

3 changes: 3 additions & 0 deletions compiler/rustc_feature/src/removed.rs
Original file line number Diff line number Diff line change
@@ -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,
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
@@ -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.
25 changes: 25 additions & 0 deletions compiler/rustc_hir_analysis/src/astconv/generics.rs
Original file line number Diff line number Diff line change
@@ -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(_),
1 change: 0 additions & 1 deletion compiler/rustc_interface/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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)]

7 changes: 7 additions & 0 deletions compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
@@ -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)))
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
@@ -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) {
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
@@ -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 {
43 changes: 34 additions & 9 deletions compiler/rustc_parse/src/parser/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -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,
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/generics.rs
Original file line number Diff line number Diff line change
@@ -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())
1 change: 0 additions & 1 deletion compiler/rustc_symbol_mangling/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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)]

13 changes: 7 additions & 6 deletions src/bootstrap/src/core/build_steps/setup.rs
Original file line number Diff line number Diff line change
@@ -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
@@ -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 {
@@ -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 {
@@ -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
@@ -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()))
}
2 changes: 1 addition & 1 deletion tests/rustdoc/deprecated-future-staged-api.rs
Original file line number Diff line number Diff line change
@@ -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
@@ -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 => {},
@@ -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 => {},
Original file line number Diff line number Diff line change
@@ -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
@@ -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
|
Original file line number Diff line number Diff line change
@@ -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