Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b33fc4e

Browse files
committedJun 24, 2024
Auto merge of rust-lang#126912 - matthiaskrgr:rollup-z5klm95, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - rust-lang#124460 (Show notice about "never used" of Debug for enum) - rust-lang#125740 (transmute size check: properly account for alignment) - rust-lang#126413 (compiletest: make the crash test error message abit more informative) - rust-lang#126618 (Mark assoc tys live only if the corresponding trait is live) - rust-lang#126673 (Ensure we don't accidentally succeed when we want to report an error) - rust-lang#126804 (On short error format, append primary span label to message) - rust-lang#126868 (not use offset when there is not ends with brace) - rust-lang#126893 (Eliminate the distinction between PREC_POSTFIX and PREC_PAREN precedence level) - rust-lang#126899 (Suggest inline const blocks for array initialization) - rust-lang#126909 (add `@kobzol` to bootstrap team for triagebot) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5a3e2a4 + 0659ab6 commit b33fc4e

Some content is hidden

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

42 files changed

+380
-192
lines changed
 

‎compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::method::probe::{IsSuggestion, Mode, ProbeScope};
99
use core::cmp::min;
1010
use core::iter;
1111
use hir::def_id::LocalDefId;
12-
use rustc_ast::util::parser::{ExprPrecedence, PREC_POSTFIX};
12+
use rustc_ast::util::parser::{ExprPrecedence, PREC_UNAMBIGUOUS};
1313
use rustc_data_structures::packed::Pu128;
1414
use rustc_errors::{Applicability, Diag, MultiSpan};
1515
use rustc_hir as hir;
@@ -1329,7 +1329,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13291329
{
13301330
let span = expr.span.find_oldest_ancestor_in_same_ctxt();
13311331

1332-
let mut sugg = if expr.precedence().order() >= PREC_POSTFIX {
1332+
let mut sugg = if expr.precedence().order() >= PREC_UNAMBIGUOUS {
13331333
vec![(span.shrink_to_hi(), ".into()".to_owned())]
13341334
} else {
13351335
vec![
@@ -2868,7 +2868,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
28682868
"change the type of the numeric literal from `{checked_ty}` to `{expected_ty}`",
28692869
);
28702870

2871-
let close_paren = if expr.precedence().order() < PREC_POSTFIX {
2871+
let close_paren = if expr.precedence().order() < PREC_UNAMBIGUOUS {
28722872
sugg.push((expr.span.shrink_to_lo(), "(".to_string()));
28732873
")"
28742874
} else {
@@ -2893,7 +2893,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
28932893
let len = src.trim_end_matches(&checked_ty.to_string()).len();
28942894
expr.span.with_lo(expr.span.lo() + BytePos(len as u32))
28952895
},
2896-
if expr.precedence().order() < PREC_POSTFIX {
2896+
if expr.precedence().order() < PREC_UNAMBIGUOUS {
28972897
// Readd `)`
28982898
format!("{expected_ty})")
28992899
} else {

‎compiler/rustc_hir_typeck/src/intrinsicck.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
7373
// Special-case transmuting from `typeof(function)` and
7474
// `Option<typeof(function)>` to present a clearer error.
7575
let from = unpack_option_like(tcx, from);
76-
if let (&ty::FnDef(..), SizeSkeleton::Known(size_to)) = (from.kind(), sk_to)
76+
if let (&ty::FnDef(..), SizeSkeleton::Known(size_to, _)) = (from.kind(), sk_to)
7777
&& size_to == Pointer(dl.instruction_address_space).size(&tcx)
7878
{
7979
struct_span_code_err!(tcx.dcx(), span, E0591, "can't transmute zero-sized type")
@@ -88,7 +88,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
8888
// Try to display a sensible error with as much information as possible.
8989
let skeleton_string = |ty: Ty<'tcx>, sk: Result<_, &_>| match sk {
9090
Ok(SizeSkeleton::Pointer { tail, .. }) => format!("pointer to `{tail}`"),
91-
Ok(SizeSkeleton::Known(size)) => {
91+
Ok(SizeSkeleton::Known(size, _)) => {
9292
if let Some(v) = u128::from(size.bytes()).checked_mul(8) {
9393
format!("{v} bits")
9494
} else {
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.