Skip to content

Commit 8859fde

Browse files
committed
Auto merge of rust-lang#109497 - matthiaskrgr:rollup-6txuxm0, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - rust-lang#109373 (Set LLVM `LLVM_UNREACHABLE_OPTIMIZE` to `OFF`) - rust-lang#109392 (Custom MIR: Allow optional RET type annotation) - rust-lang#109394 (adapt tests/codegen/vec-shrink-panik for LLVM 17) - rust-lang#109412 (rustdoc: Add GUI test for "Auto-hide item contents for large items" setting) - rust-lang#109452 (Ignore the vendor directory for tidy tests.) - rust-lang#109457 (Remove comment about reusing rib allocations) - rust-lang#109461 (rustdoc: remove redundant `.content` prefix from span/a colors) - rust-lang#109477 (`HirId` to `LocalDefId` cleanup) - rust-lang#109489 (More general captures) - rust-lang#109494 (Do not feed param_env for RPITITs impl side) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents a266f11 + 6244b94 commit 8859fde

File tree

21 files changed

+153
-54
lines changed

21 files changed

+153
-54
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str
424424
.filter_map(|s| {
425425
let enable_disable = match s.chars().next() {
426426
None => return None,
427-
Some(c @ '+' | c @ '-') => c,
427+
Some(c @ ('+' | '-')) => c,
428428
Some(_) => {
429429
if diagnostics {
430430
sess.emit_warning(UnknownCTargetFeaturePrefix { feature: s });

compiler/rustc_hir_analysis/src/collect.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ fn infer_return_ty_for_fn_sig<'tcx>(
12081208
fn_sig,
12091209
Applicability::MachineApplicable,
12101210
);
1211-
} else if let Some(sugg) = suggest_impl_trait(tcx, ret_ty, ty.span, hir_id, def_id) {
1211+
} else if let Some(sugg) = suggest_impl_trait(tcx, ret_ty, ty.span, def_id) {
12121212
diag.span_suggestion(
12131213
ty.span,
12141214
"replace with an appropriate return type",
@@ -1240,12 +1240,10 @@ fn infer_return_ty_for_fn_sig<'tcx>(
12401240
}
12411241
}
12421242

1243-
// FIXME(vincenzopalazzo): remove the hir item when the refactoring is stable
12441243
fn suggest_impl_trait<'tcx>(
12451244
tcx: TyCtxt<'tcx>,
12461245
ret_ty: Ty<'tcx>,
12471246
span: Span,
1248-
_hir_id: hir::HirId,
12491247
def_id: LocalDefId,
12501248
) -> Option<String> {
12511249
let format_as_assoc: fn(_, _, _, _, _) -> _ =

compiler/rustc_hir_typeck/src/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
231231

232232
let ty = ensure_sufficient_stack(|| match &expr.kind {
233233
hir::ExprKind::Path(
234-
qpath @ hir::QPath::Resolved(..) | qpath @ hir::QPath::TypeRelative(..),
234+
qpath @ (hir::QPath::Resolved(..) | hir::QPath::TypeRelative(..)),
235235
) => self.check_expr_path(qpath, expr, args),
236236
_ => self.check_expr_kind(expr, expected),
237237
});

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
165165
&self,
166166
ty: Ty<'tcx>,
167167
) -> Option<(DefIdOrName, Ty<'tcx>, Vec<Ty<'tcx>>)> {
168-
let body_hir_id = self.tcx.hir().local_def_id_to_hir_id(self.body_id);
169-
self.err_ctxt().extract_callable_info(body_hir_id, self.param_env, ty)
168+
self.err_ctxt().extract_callable_info(self.body_id, self.param_env, ty)
170169
}
171170

172171
pub fn suggest_two_fn_call(

compiler/rustc_middle/src/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2525,7 +2525,7 @@ impl<'tcx> TyCtxt<'tcx> {
25252525
ident
25262526
}
25272527

2528-
// FIXME(vincenzoapalzzo): move the HirId to a LocalDefId
2528+
// FIXME(vincenzopalazzo): move the HirId to a LocalDefId
25292529
pub fn adjust_ident_and_get_scope(
25302530
self,
25312531
mut ident: Ident,

compiler/rustc_resolve/src/late.rs

-1
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,6 @@ struct LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
590590
parent_scope: ParentScope<'a>,
591591

592592
/// The current set of local scopes for types and values.
593-
/// FIXME #4948: Reuse ribs to avoid allocation.
594593
ribs: PerNS<Vec<Rib<'a>>>,
595594

596595
/// Previous poped `rib`, only used for diagnostic.

compiler/rustc_resolve/src/macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
703703
PathResult::NonModule(path_res) if let Some(res) = path_res.full_res() => {
704704
check_consistency(self, &path, path_span, kind, initial_res, res)
705705
}
706-
path_res @ PathResult::NonModule(..) | path_res @ PathResult::Failed { .. } => {
706+
path_res @ (PathResult::NonModule(..) | PathResult::Failed { .. }) => {
707707
let mut suggestion = None;
708708
let (span, label) = if let PathResult::Failed { span, label, .. } = path_res {
709709
// try to suggest if it's not a macro, maybe a function

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ pub trait TypeErrCtxtExt<'tcx> {
212212

213213
fn extract_callable_info(
214214
&self,
215-
hir_id: HirId,
215+
body_id: LocalDefId,
216216
param_env: ty::ParamEnv<'tcx>,
217217
found: Ty<'tcx>,
218218
) -> Option<(DefIdOrName, Ty<'tcx>, Vec<Ty<'tcx>>)>;
@@ -909,9 +909,8 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
909909
trait_pred.self_ty(),
910910
);
911911

912-
let body_hir_id = self.tcx.hir().local_def_id_to_hir_id(obligation.cause.body_id);
913912
let Some((def_id_or_name, output, inputs)) = self.extract_callable_info(
914-
body_hir_id,
913+
obligation.cause.body_id,
915914
obligation.param_env,
916915
self_ty,
917916
) else { return false; };
@@ -1113,10 +1112,9 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
11131112
/// Extracts information about a callable type for diagnostics. This is a
11141113
/// heuristic -- it doesn't necessarily mean that a type is always callable,
11151114
/// because the callable type must also be well-formed to be called.
1116-
// FIXME(vincenzopalazzo): move the HirId to a LocalDefId
11171115
fn extract_callable_info(
11181116
&self,
1119-
hir_id: HirId,
1117+
body_id: LocalDefId,
11201118
param_env: ty::ParamEnv<'tcx>,
11211119
found: Ty<'tcx>,
11221120
) -> Option<(DefIdOrName, Ty<'tcx>, Vec<Ty<'tcx>>)> {
@@ -1168,7 +1166,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
11681166
})
11691167
}
11701168
ty::Param(param) => {
1171-
let generics = self.tcx.generics_of(hir_id.owner.to_def_id());
1169+
let generics = self.tcx.generics_of(body_id);
11721170
let name = if generics.count() > param.index as usize
11731171
&& let def = generics.param_at(param.index as usize, self.tcx)
11741172
&& matches!(def.kind, ty::GenericParamDefKind::Type { .. })

compiler/rustc_ty_utils/src/assoc.rs

-4
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,6 @@ fn associated_type_for_impl_trait_in_impl(
386386
opt_rpitit_info: Some(ImplTraitInTraitData::Impl { fn_def_id: impl_fn_def_id.to_def_id() }),
387387
});
388388

389-
// Copy param_env of the containing function. The synthesized associated type doesn't have
390-
// extra predicates to assume.
391-
impl_assoc_ty.param_env(tcx.param_env(impl_fn_def_id));
392-
393389
// Copy visility of the containing function.
394390
impl_assoc_ty.visibility(tcx.visibility(impl_fn_def_id));
395391

compiler/rustc_ty_utils/src/ty.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> {
130130
// FIXME(-Zlower-impl-trait-in-trait-to-assoc-ty): I don't like this, we should
131131
// at least be making sure that the generics in RPITITs and their parent fn don't
132132
// get out of alignment, or else we do actually need to substitute these predicates.
133-
if let Some(ImplTraitInTraitData::Trait { fn_def_id, .. }) = tcx.opt_rpitit_info(def_id) {
133+
if let Some(ImplTraitInTraitData::Trait { fn_def_id, .. })
134+
| Some(ImplTraitInTraitData::Impl { fn_def_id, .. }) = tcx.opt_rpitit_info(def_id)
135+
{
134136
predicates = tcx.predicates_of(fn_def_id).instantiate_identity(tcx).predicates;
135137
}
136138

library/core/src/intrinsics/mir.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
//!
5050
//! The input to the [`mir!`] macro is:
5151
//!
52+
//! - An optional return type annotation in the form of `type RET = ...;`. This may be required
53+
//! if the compiler cannot infer the type of RET.
5254
//! - A possibly empty list of local declarations. Locals can also be declared inline on
5355
//! assignments via `let`. Type inference generally works. Shadowing does not.
5456
//! - A list of basic blocks. The first of these is the start block and is where execution begins.
@@ -124,6 +126,18 @@
124126
//! }
125127
//! )
126128
//! }
129+
//!
130+
//! #[custom_mir(dialect = "runtime", phase = "optimized")]
131+
//! fn annotated_return_type() -> (i32, bool) {
132+
//! mir!(
133+
//! type RET = (i32, bool);
134+
//! {
135+
//! RET.0 = 1;
136+
//! RET.1 = true;
137+
//! Return()
138+
//! }
139+
//! )
140+
//! }
127141
//! ```
128142
//!
129143
//! We can also set off compilation failures that happen in sufficiently late stages of the
@@ -342,6 +356,7 @@ define!(
342356
#[rustc_macro_transparency = "transparent"]
343357
pub macro mir {
344358
(
359+
$(type RET = $ret_ty:ty ;)?
345360
$(let $local_decl:ident $(: $local_decl_ty:ty)? ;)*
346361

347362
{
@@ -362,7 +377,7 @@ pub macro mir {
362377
{
363378
// Now all locals
364379
#[allow(non_snake_case)]
365-
let RET;
380+
let RET $(: $ret_ty)?;
366381
$(
367382
let $local_decl $(: $local_decl_ty)? ;
368383
)*

src/bootstrap/download-ci-llvm-stamp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Change this file to make users of the `download-ci-llvm` configuration download
22
a new version of LLVM from CI, even if the LLVM submodule hasn’t changed.
33

4-
Last change is for: https://github.com/rust-lang/rust/pull/104748
4+
Last change is for: https://github.com/rust-lang/rust/pull/109373

src/bootstrap/native.rs

+1
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ impl Step for Llvm {
309309
cfg.out_dir(&out_dir)
310310
.profile(profile)
311311
.define("LLVM_ENABLE_ASSERTIONS", assertions)
312+
.define("LLVM_UNREACHABLE_OPTIMIZE", "OFF")
312313
.define("LLVM_ENABLE_PLUGINS", plugins)
313314
.define("LLVM_TARGETS_TO_BUILD", llvm_targets)
314315
.define("LLVM_EXPERIMENTAL_TARGETS_TO_BUILD", llvm_exp_targets)
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.14.4
1+
0.14.5

src/librustdoc/html/static/css/rustdoc.css

+21-21
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ ul.all-items {
217217
a.anchor,
218218
.small-section-header a,
219219
#source-sidebar a,
220-
pre.rust a,
220+
.rust a,
221221
.sidebar h2 a,
222222
.sidebar h3 a,
223223
.mobile-topbar h2 a,
@@ -228,43 +228,43 @@ h1 a,
228228
color: var(--main-color);
229229
}
230230

231-
.content span.enum, .content a.enum,
232-
.content span.struct, .content a.struct,
233-
.content span.union, .content a.union,
234-
.content span.primitive, .content a.primitive,
235-
.content span.type, .content a.type,
236-
.content span.foreigntype, .content a.foreigntype {
231+
span.enum, a.enum,
232+
span.struct, a.struct,
233+
span.union, a.union,
234+
span.primitive, a.primitive,
235+
span.type, a.type,
236+
span.foreigntype, a.foreigntype {
237237
color: var(--type-link-color);
238238
}
239239

240-
.content span.trait, .content a.trait,
241-
.content span.traitalias, .content a.traitalias {
240+
span.trait, a.trait,
241+
span.traitalias, a.traitalias {
242242
color: var(--trait-link-color);
243243
}
244244

245-
.content span.associatedtype, .content a.associatedtype,
246-
.content span.constant, .content a.constant,
247-
.content span.static, .content a.static {
245+
span.associatedtype, a.associatedtype,
246+
span.constant, a.constant,
247+
span.static, a.static {
248248
color: var(--assoc-item-link-color);
249249
}
250250

251-
.content span.fn, .content a.fn,
252-
.content span.method, .content a.method,
253-
.content span.tymethod, .content a.tymethod {
251+
span.fn, a.fn,
252+
span.method, a.method,
253+
span.tymethod, a.tymethod {
254254
color: var(--function-link-color);
255255
}
256256

257-
.content span.attr, .content a.attr,
258-
.content span.derive, .content a.derive,
259-
.content span.macro, .content a.macro {
257+
span.attr, a.attr,
258+
span.derive, a.derive,
259+
span.macro, a.macro {
260260
color: var(--macro-link-color);
261261
}
262262

263-
.content span.mod, .content a.mod {
263+
span.mod, a.mod {
264264
color: var(--mod-link-color);
265265
}
266266

267-
.content span.keyword, .content a.keyword {
267+
span.keyword, a.keyword {
268268
color: var(--keyword-link-color);
269269
}
270270

@@ -713,7 +713,7 @@ h2.small-section-header > .anchor {
713713
}
714714

715715
.main-heading a:hover,
716-
.example-wrap > pre.rust a:hover,
716+
.example-wrap > .rust a:hover,
717717
.all-items a:hover,
718718
.docblock a:not(.test-arrow):not(.scrape-help):not(.tooltip):hover,
719719
.docblock-short a:not(.test-arrow):not(.scrape-help):not(.tooltip):hover,

src/tools/tidy/src/walk.rs

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub fn filter_dirs(path: &Path) -> bool {
2929
// Filter RLS output directories
3030
"target/rls",
3131
"src/bootstrap/target",
32+
"vendor",
3233
];
3334
skip.iter().any(|p| path.ends_with(p))
3435
}

tests/codegen/vec-shrink-panik.rs

+14-9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// revisions: old new
2+
// LLVM 17 realizes double panic is not possible and doesn't generate calls
3+
// to panic_cannot_unwind.
4+
// [old]ignore-llvm-version: 17 - 99
5+
// [new]min-llvm-version: 17
16
// compile-flags: -O
27
// ignore-debug: the debug assertions get in the way
38
#![crate_type = "lib"]
@@ -18,11 +23,11 @@ pub fn shrink_to_fit(vec: &mut Vec<u32>) {
1823
pub fn issue71861(vec: Vec<u32>) -> Box<[u32]> {
1924
// CHECK-NOT: panic
2025

21-
// Call to panic_cannot_unwind in case of double-panic is expected,
22-
// but other panics are not.
26+
// Call to panic_cannot_unwind in case of double-panic is expected
27+
// on LLVM 16 and older, but other panics are not.
2328
// CHECK: cleanup
24-
// CHECK-NEXT: ; call core::panicking::panic_cannot_unwind
25-
// CHECK-NEXT: panic_cannot_unwind
29+
// old-NEXT: ; call core::panicking::panic_cannot_unwind
30+
// old-NEXT: panic_cannot_unwind
2631

2732
// CHECK-NOT: panic
2833
vec.into_boxed_slice()
@@ -34,14 +39,14 @@ pub fn issue75636<'a>(iter: &[&'a str]) -> Box<[&'a str]> {
3439
// CHECK-NOT: panic
3540

3641
// Call to panic_cannot_unwind in case of double-panic is expected,
37-
// but other panics are not.
42+
// on LLVM 16 and older, but other panics are not.
3843
// CHECK: cleanup
39-
// CHECK-NEXT: ; call core::panicking::panic_cannot_unwind
40-
// CHECK-NEXT: panic_cannot_unwind
44+
// old-NEXT: ; call core::panicking::panic_cannot_unwind
45+
// old-NEXT: panic_cannot_unwind
4146

4247
// CHECK-NOT: panic
4348
iter.iter().copied().collect()
4449
}
4550

46-
// CHECK: ; core::panicking::panic_cannot_unwind
47-
// CHECK: declare void @{{.*}}panic_cannot_unwind
51+
// old: ; core::panicking::panic_cannot_unwind
52+
// old: declare void @{{.*}}panic_cannot_unwind
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#![feature(custom_mir, core_intrinsics)]
2+
3+
extern crate core;
4+
use core::intrinsics::mir::*;
5+
6+
// EMIT_MIR composite_return.tuple.built.after.mir
7+
#[custom_mir(dialect = "runtime", phase = "optimized")]
8+
fn tuple() -> (i32, bool) {
9+
mir!(
10+
type RET = (i32, bool);
11+
{
12+
RET.0 = 1;
13+
RET.1 = true;
14+
Return()
15+
}
16+
)
17+
}
18+
19+
fn main() {
20+
assert_eq!(tuple(), (1, true));
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// MIR for `tuple` after built
2+
3+
fn tuple() -> (i32, bool) {
4+
let mut _0: (i32, bool); // return place in scope 0 at $DIR/composite_return.rs:+0:15: +0:26
5+
6+
bb0: {
7+
(_0.0: i32) = const 1_i32; // scope 0 at $DIR/composite_return.rs:+4:13: +4:22
8+
(_0.1: bool) = const true; // scope 0 at $DIR/composite_return.rs:+5:13: +5:25
9+
return; // scope 0 at $DIR/composite_return.rs:+6:13: +6:21
10+
}
11+
}

0 commit comments

Comments
 (0)