Skip to content

Commit 1f12ac8

Browse files
committed
Auto merge of rust-lang#89984 - matthiaskrgr:rollup-ikmyhmx, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#89738 (ty::pretty: prevent infinite recursion for `extern crate` paths.) - rust-lang#89888 (Make `llvm.download-ci-llvm="if-available"` work for tier 2 targets with host tools) - rust-lang#89945 (Remove a mention to `copy_from_slice` from `clone_from_slice` doc) - rust-lang#89946 (Fix an ICE with TAITs and Future) - rust-lang#89963 (Some "parenthesis" and "parentheses" fixes) - rust-lang#89975 (Add a regression test for rust-lang#85921) - rust-lang#89977 (Make Result::as_mut const) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8db8f48 + f044a84 commit 1f12ac8

File tree

46 files changed

+343
-122
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+343
-122
lines changed

compiler/rustc_ast/src/util/parser.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -357,13 +357,13 @@ impl ExprPrecedence {
357357
}
358358
}
359359

360-
/// In `let p = e`, operators with precedence `<=` this one requires parenthesis in `e`.
360+
/// In `let p = e`, operators with precedence `<=` this one requires parentheses in `e`.
361361
pub fn prec_let_scrutinee_needs_par() -> usize {
362362
AssocOp::LAnd.precedence()
363363
}
364364

365365
/// Suppose we have `let _ = e` and the `order` of `e`.
366-
/// Is the `order` such that `e` in `let _ = e` needs parenthesis when it is on the RHS?
366+
/// Is the `order` such that `e` in `let _ = e` needs parentheses when it is on the RHS?
367367
///
368368
/// Conversely, suppose that we have `(let _ = a) OP b` and `order` is that of `OP`.
369369
/// Can we print this as `let _ = a OP b`?

compiler/rustc_ast_passes/src/ast_validation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl<'a> AstValidator<'a> {
113113
if sess.opts.unstable_features.is_nightly_build() {
114114
sess.struct_span_err(expr.span, "`let` expressions are not supported here")
115115
.note("only supported directly in conditions of `if`- and `while`-expressions")
116-
.note("as well as when nested within `&&` and parenthesis in those conditions")
116+
.note("as well as when nested within `&&` and parentheses in those conditions")
117117
.emit();
118118
} else {
119119
sess.struct_span_err(expr.span, "expected expression, found statement (`let`)")

compiler/rustc_ast_pretty/src/pprust/state.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1675,7 +1675,7 @@ impl<'a> State<'a> {
16751675
self.print_expr_cond_paren(expr, Self::cond_needs_par(expr))
16761676
}
16771677

1678-
// Does `expr` need parenthesis when printed in a condition position?
1678+
// Does `expr` need parentheses when printed in a condition position?
16791679
//
16801680
// These cases need parens due to the parse error observed in #26461: `if return {}`
16811681
// parses as the erroneous construct `if (return {})`, not `if (return) {}`.

compiler/rustc_hir_pretty/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ impl<'a> State<'a> {
11681168
self.print_expr_cond_paren(expr, Self::cond_needs_par(expr) || npals())
11691169
}
11701170

1171-
// Does `expr` need parenthesis when printed in a condition position?
1171+
// Does `expr` need parentheses when printed in a condition position?
11721172
//
11731173
// These cases need parens due to the parse error observed in #26461: `if return {}`
11741174
// parses as the erroneous construct `if (return {})`, not `if (return) {}`.

compiler/rustc_lint/src/unused.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ declare_lint! {
670670
///
671671
/// ### Explanation
672672
///
673-
/// The parenthesis are not needed, and should be removed. This is the
673+
/// The parentheses are not needed, and should be removed. This is the
674674
/// preferred style for writing these expressions.
675675
pub(super) UNUSED_PARENS,
676676
Warn,

compiler/rustc_middle/src/ty/error.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -769,11 +769,16 @@ fn foo(&self) -> Self::T { String::new() }
769769
) -> bool {
770770
let assoc = self.associated_item(proj_ty.item_def_id);
771771
if let ty::Opaque(def_id, _) = *proj_ty.self_ty().kind() {
772-
let opaque_local_def_id = def_id.expect_local();
773-
let opaque_hir_id = self.hir().local_def_id_to_hir_id(opaque_local_def_id);
774-
let opaque_hir_ty = match &self.hir().expect_item(opaque_hir_id).kind {
775-
hir::ItemKind::OpaqueTy(opaque_hir_ty) => opaque_hir_ty,
776-
_ => bug!("The HirId comes from a `ty::Opaque`"),
772+
let opaque_local_def_id = def_id.as_local();
773+
let opaque_hir_ty = if let Some(opaque_local_def_id) = opaque_local_def_id {
774+
let hir = self.hir();
775+
let opaque_hir_id = hir.local_def_id_to_hir_id(opaque_local_def_id);
776+
match &hir.expect_item(opaque_hir_id).kind {
777+
hir::ItemKind::OpaqueTy(opaque_hir_ty) => opaque_hir_ty,
778+
_ => bug!("The HirId comes from a `ty::Opaque`"),
779+
}
780+
} else {
781+
return false;
777782
};
778783

779784
let (trait_ref, assoc_substs) = proj_ty.trait_ref_and_own_substs(self);

compiler/rustc_middle/src/ty/print/pretty.rs

+18-10
Original file line numberDiff line numberDiff line change
@@ -350,18 +350,26 @@ pub trait PrettyPrinter<'tcx>:
350350
match self.tcx().extern_crate(def_id) {
351351
Some(&ExternCrate { src, dependency_of, span, .. }) => match (src, dependency_of) {
352352
(ExternCrateSource::Extern(def_id), LOCAL_CRATE) => {
353-
debug!("try_print_visible_def_path: def_id={:?}", def_id);
354-
return Ok((
355-
if !span.is_dummy() {
356-
self.print_def_path(def_id, &[])?
357-
} else {
358-
self.path_crate(cnum)?
359-
},
360-
true,
361-
));
353+
// NOTE(eddyb) the only reason `span` might be dummy,
354+
// that we're aware of, is that it's the `std`/`core`
355+
// `extern crate` injected by default.
356+
// FIXME(eddyb) find something better to key this on,
357+
// or avoid ending up with `ExternCrateSource::Extern`,
358+
// for the injected `std`/`core`.
359+
if span.is_dummy() {
360+
return Ok((self.path_crate(cnum)?, true));
361+
}
362+
363+
// Disable `try_print_trimmed_def_path` behavior within
364+
// the `print_def_path` call, to avoid infinite recursion
365+
// in cases where the `extern crate foo` has non-trivial
366+
// parents, e.g. it's nested in `impl foo::Trait for Bar`
367+
// (see also issues #55779 and #87932).
368+
self = with_no_visible_paths(|| self.print_def_path(def_id, &[]))?;
369+
370+
return Ok((self, true));
362371
}
363372
(ExternCrateSource::Path, LOCAL_CRATE) => {
364-
debug!("try_print_visible_def_path: def_id={:?}", def_id);
365373
return Ok((self.path_crate(cnum)?, true));
366374
}
367375
_ => {}

compiler/rustc_parse/src/parser/diagnostics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1342,10 +1342,10 @@ impl<'a> Parser<'a> {
13421342

13431343
self.struct_span_err(
13441344
MultiSpan::from_spans(vec![begin_par_sp, self.prev_token.span]),
1345-
"unexpected parenthesis surrounding `for` loop head",
1345+
"unexpected parentheses surrounding `for` loop head",
13461346
)
13471347
.multipart_suggestion(
1348-
"remove parenthesis in `for` loop",
1348+
"remove parentheses in `for` loop",
13491349
vec![(begin_par_sp, String::new()), (self.prev_token.span, String::new())],
13501350
// With e.g. `for (x) in y)` this would replace `(x) in y)`
13511351
// with `x) in y)` which is syntactically invalid.

compiler/rustc_parse/src/parser/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ impl<'a> Parser<'a> {
12581258
/// Parses `pub`, `pub(crate)` and `pub(in path)` plus shortcuts `crate` for `pub(crate)`,
12591259
/// `pub(self)` for `pub(in self)` and `pub(super)` for `pub(in super)`.
12601260
/// If the following element can't be a tuple (i.e., it's a function definition), then
1261-
/// it's not a tuple struct field), and the contents within the parentheses isn't valid,
1261+
/// it's not a tuple struct field), and the contents within the parentheses aren't valid,
12621262
/// so emit a proper diagnostic.
12631263
// Public for rustfmt usage.
12641264
pub fn parse_visibility(&mut self, fbt: FollowedByType) -> PResult<'a, Visibility> {

compiler/rustc_parse/src/parser/stmt.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ impl<'a> Parser<'a> {
328328
),
329329
)
330330
.multipart_suggestion(
331-
"wrap the expression in parenthesis",
331+
"wrap the expression in parentheses",
332332
suggs,
333333
Applicability::MachineApplicable,
334334
)
@@ -349,7 +349,7 @@ impl<'a> Parser<'a> {
349349
"right curly brace `}` before `else` in a `let...else` statement not allowed",
350350
)
351351
.multipart_suggestion(
352-
"try wrapping the expression in parenthesis",
352+
"try wrapping the expression in parentheses",
353353
suggs,
354354
Applicability::MachineApplicable,
355355
)

compiler/rustc_parse/src/parser/ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ impl<'a> Parser<'a> {
430430
}
431431

432432
// Parses the `typeof(EXPR)`.
433-
// To avoid ambiguity, the type is surrounded by parenthesis.
433+
// To avoid ambiguity, the type is surrounded by parentheses.
434434
fn parse_typeof_ty(&mut self) -> PResult<'a, TyKind> {
435435
self.expect(&token::OpenDelim(token::Paren))?;
436436
let expr = self.parse_anon_const_expr()?;

compiler/rustc_resolve/src/late/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1552,7 +1552,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
15521552
matches!(source, PathSource::TupleStruct(..)) || source.is_call();
15531553
if suggest_only_tuple_variants {
15541554
// Suggest only tuple variants regardless of whether they have fields and do not
1555-
// suggest path with added parenthesis.
1555+
// suggest path with added parentheses.
15561556
let mut suggestable_variants = variants
15571557
.iter()
15581558
.filter(|(.., kind)| *kind == CtorKind::Fn)

compiler/rustc_typeck/src/check/callee.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
300300
let end = callee_span.shrink_to_hi();
301301
err.multipart_suggestion(
302302
"if you meant to create this closure and immediately call it, surround the \
303-
closure with parenthesis",
303+
closure with parentheses",
304304
vec![(start, "(".to_string()), (end, ")".to_string())],
305305
Applicability::MaybeIncorrect,
306306
);
@@ -383,7 +383,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
383383
call_expr.span,
384384
&format!(
385385
"`{}` is a unit variant, you need to write it \
386-
without the parenthesis",
386+
without the parentheses",
387387
path
388388
),
389389
path.to_string(),

compiler/rustc_typeck/src/check/op.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
492492
other_ty: Ty<'tcx>,
493493
op: hir::BinOp,
494494
is_assign: IsAssign,
495-
) -> bool /* did we suggest to call a function because of missing parenthesis? */ {
495+
) -> bool /* did we suggest to call a function because of missing parentheses? */ {
496496
err.span_label(span, ty.to_string());
497497
if let FnDef(def_id, _) = *ty.kind() {
498498
let source_map = self.tcx.sess.source_map();

library/core/src/result.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,8 @@ impl<T, E> Result<T, E> {
729729
/// ```
730730
#[inline]
731731
#[stable(feature = "rust1", since = "1.0.0")]
732-
pub fn as_mut(&mut self) -> Result<&mut T, &mut E> {
732+
#[rustc_const_unstable(feature = "const_result", issue = "82814")]
733+
pub const fn as_mut(&mut self) -> Result<&mut T, &mut E> {
733734
match *self {
734735
Ok(ref mut x) => Ok(x),
735736
Err(ref mut x) => Err(x),

library/core/src/slice/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -2953,9 +2953,6 @@ impl<T> [T] {
29532953
///
29542954
/// The length of `src` must be the same as `self`.
29552955
///
2956-
/// If `T` implements `Copy`, it can be more performant to use
2957-
/// [`copy_from_slice`].
2958-
///
29592956
/// # Panics
29602957
///
29612958
/// This function will panic if the two slices have different lengths.

library/core/tests/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
#![feature(once_cell)]
6666
#![feature(unsized_tuple_coercion)]
6767
#![feature(const_option)]
68+
#![feature(const_result)]
6869
#![feature(integer_atomics)]
6970
#![feature(int_roundings)]
7071
#![feature(slice_group_by)]

library/core/tests/result.rs

+23
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,29 @@ fn result_const() {
352352
assert!(!IS_ERR)
353353
}
354354

355+
#[test]
356+
const fn result_const_mut() {
357+
let mut result: Result<usize, bool> = Ok(32);
358+
359+
{
360+
let as_mut = result.as_mut();
361+
match as_mut {
362+
Ok(v) => *v = 42,
363+
Err(_) => unreachable!(),
364+
}
365+
}
366+
367+
let mut result_err: Result<usize, bool> = Err(false);
368+
369+
{
370+
let as_mut = result_err.as_mut();
371+
match as_mut {
372+
Ok(_) => unreachable!(),
373+
Err(v) => *v = true,
374+
}
375+
}
376+
}
377+
355378
#[test]
356379
fn result_opt_conversions() {
357380
#[derive(Copy, Clone, Debug, PartialEq)]

src/bootstrap/bootstrap.py

+23-2
Original file line numberDiff line numberDiff line change
@@ -492,10 +492,11 @@ def download_toolchain(self, stage0=True, rustc_channel=None):
492492

493493
def downloading_llvm(self):
494494
opt = self.get_toml('download-ci-llvm', 'llvm')
495-
# This is currently all tier 1 targets (since others may not have CI
496-
# artifacts)
495+
# This is currently all tier 1 targets and tier 2 targets with host tools
496+
# (since others may not have CI artifacts)
497497
# https://doc.rust-lang.org/rustc/platform-support.html#tier-1
498498
supported_platforms = [
499+
# tier 1
499500
"aarch64-unknown-linux-gnu",
500501
"i686-pc-windows-gnu",
501502
"i686-pc-windows-msvc",
@@ -504,6 +505,26 @@ def downloading_llvm(self):
504505
"x86_64-apple-darwin",
505506
"x86_64-pc-windows-gnu",
506507
"x86_64-pc-windows-msvc",
508+
# tier 2 with host tools
509+
"aarch64-apple-darwin",
510+
"aarch64-pc-windows-msvc",
511+
"aarch64-unknown-linux-musl",
512+
"arm-unknown-linux-gnueabi",
513+
"arm-unknown-linux-gnueabihf",
514+
"armv7-unknown-linux-gnueabihf",
515+
"mips-unknown-linux-gnu",
516+
"mips64-unknown-linux-gnuabi64",
517+
"mips64el-unknown-linux-gnuabi64",
518+
"mipsel-unknown-linux-gnu",
519+
"powerpc-unknown-linux-gnu",
520+
"powerpc64-unknown-linux-gnu",
521+
"powerpc64le-unknown-linux-gnu",
522+
"riscv64gc-unknown-linux-gnu",
523+
"s390x-unknown-linux-gnu",
524+
"x86_64-unknown-freebsd",
525+
"x86_64-unknown-illumos",
526+
"x86_64-unknown-linux-musl",
527+
"x86_64-unknown-netbsd",
507528
]
508529
return opt == "true" \
509530
or (opt == "if-available" and self.build in supported_platforms)

src/bootstrap/config.rs

+23-1
Original file line numberDiff line numberDiff line change
@@ -765,10 +765,12 @@ impl Config {
765765
config.llvm_from_ci = match llvm.download_ci_llvm {
766766
Some(StringOrBool::String(s)) => {
767767
assert!(s == "if-available", "unknown option `{}` for download-ci-llvm", s);
768-
// This is currently all tier 1 targets (since others may not have CI artifacts)
768+
// This is currently all tier 1 targets and tier 2 targets with host tools
769+
// (since others may not have CI artifacts)
769770
// https://doc.rust-lang.org/rustc/platform-support.html#tier-1
770771
// FIXME: this is duplicated in bootstrap.py
771772
let supported_platforms = [
773+
// tier 1
772774
"aarch64-unknown-linux-gnu",
773775
"i686-pc-windows-gnu",
774776
"i686-pc-windows-msvc",
@@ -777,6 +779,26 @@ impl Config {
777779
"x86_64-apple-darwin",
778780
"x86_64-pc-windows-gnu",
779781
"x86_64-pc-windows-msvc",
782+
// tier 2 with host tools
783+
"aarch64-apple-darwin",
784+
"aarch64-pc-windows-msvc",
785+
"aarch64-unknown-linux-musl",
786+
"arm-unknown-linux-gnueabi",
787+
"arm-unknown-linux-gnueabihf",
788+
"armv7-unknown-linux-gnueabihf",
789+
"mips-unknown-linux-gnu",
790+
"mips64-unknown-linux-gnuabi64",
791+
"mips64el-unknown-linux-gnuabi64",
792+
"mipsel-unknown-linux-gnu",
793+
"powerpc-unknown-linux-gnu",
794+
"powerpc64-unknown-linux-gnu",
795+
"powerpc64le-unknown-linux-gnu",
796+
"riscv64gc-unknown-linux-gnu",
797+
"s390x-unknown-linux-gnu",
798+
"x86_64-unknown-freebsd",
799+
"x86_64-unknown-illumos",
800+
"x86_64-unknown-linux-musl",
801+
"x86_64-unknown-netbsd",
780802
];
781803
supported_platforms.contains(&&*config.build.triple)
782804
}

src/librustdoc/clean/auto_trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
576576
rhs,
577577
});
578578
continue; // If something other than a Fn ends up
579-
// with parenthesis, leave it alone
579+
// with parentheses, leave it alone
580580
}
581581
}
582582

src/test/ui/empty/empty-struct-unit-expr.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ LL | let e4 = E::Empty4();
2020
| |
2121
| call expression requires function
2222
|
23-
help: `E::Empty4` is a unit variant, you need to write it without the parenthesis
23+
help: `E::Empty4` is a unit variant, you need to write it without the parentheses
2424
|
2525
LL | let e4 = E::Empty4;
2626
| ~~~~~~~~~
@@ -41,7 +41,7 @@ LL | let xe4 = XE::XEmpty4();
4141
| |
4242
| call expression requires function
4343
|
44-
help: `XE::XEmpty4` is a unit variant, you need to write it without the parenthesis
44+
help: `XE::XEmpty4` is a unit variant, you need to write it without the parentheses
4545
|
4646
LL | let xe4 = XE::XEmpty4;
4747
| ~~~~~~~~~~~

src/test/ui/error-codes/E0618.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | X::Entry();
99
| |
1010
| call expression requires function
1111
|
12-
help: `X::Entry` is a unit variant, you need to write it without the parenthesis
12+
help: `X::Entry` is a unit variant, you need to write it without the parentheses
1313
|
1414
LL | X::Entry;
1515
| ~~~~~~~~
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// check-pass
2+
3+
#![feature(generic_associated_types)]
4+
5+
trait Trait {
6+
type Assoc<'a>;
7+
8+
fn with_assoc(f: impl FnOnce(Self::Assoc<'_>));
9+
}
10+
11+
impl Trait for () {
12+
type Assoc<'a> = i32;
13+
14+
fn with_assoc(f: impl FnOnce(Self::Assoc<'_>)) {
15+
f(5i32)
16+
}
17+
}
18+
19+
fn main() {}

0 commit comments

Comments
 (0)