Skip to content

Commit 46fb648

Browse files
committed
Auto merge of #126461 - matthiaskrgr:rollup-tepitxf, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #125293 (Place tail expression behind terminating scope) - #125722 (Indicate in `non_local_defs` lint that the macro needs to change) - #126192 (Various Redox OS fixes and add i686 Redox OS target) - #126285 (`UniqueRc`: support allocators and `T: ?Sized`.) - #126352 (ci: Update centos:7 to use vault repos) - #126399 (extend the check for LLVM build) r? `@ghost` `@rustbot` modify labels: rollup
2 parents bfa098e + 206f486 commit 46fb648

38 files changed

+611
-75
lines changed

compiler/rustc_ast_lowering/src/expr.rs

+35-19
Original file line numberDiff line numberDiff line change
@@ -1716,24 +1716,28 @@ impl<'hir> LoweringContext<'_, 'hir> {
17161716
// `mut iter => { ... }`
17171717
let iter_arm = self.arm(iter_pat, loop_expr);
17181718

1719-
let into_iter_expr = match loop_kind {
1719+
let match_expr = match loop_kind {
17201720
ForLoopKind::For => {
17211721
// `::std::iter::IntoIterator::into_iter(<head>)`
1722-
self.expr_call_lang_item_fn(
1722+
let into_iter_expr = self.expr_call_lang_item_fn(
17231723
head_span,
17241724
hir::LangItem::IntoIterIntoIter,
17251725
arena_vec![self; head],
1726-
)
1726+
);
1727+
1728+
self.arena.alloc(self.expr_match(
1729+
for_span,
1730+
into_iter_expr,
1731+
arena_vec![self; iter_arm],
1732+
hir::MatchSource::ForLoopDesugar,
1733+
))
17271734
}
1728-
// ` unsafe { Pin::new_unchecked(&mut into_async_iter(<head>)) }`
1735+
// `match into_async_iter(<head>) { ref mut iter => match unsafe { Pin::new_unchecked(iter) } { ... } }`
17291736
ForLoopKind::ForAwait => {
1730-
// `::core::async_iter::IntoAsyncIterator::into_async_iter(<head>)`
1731-
let iter = self.expr_call_lang_item_fn(
1732-
head_span,
1733-
hir::LangItem::IntoAsyncIterIntoIter,
1734-
arena_vec![self; head],
1735-
);
1736-
let iter = self.expr_mut_addr_of(head_span, iter);
1737+
let iter_ident = iter;
1738+
let (async_iter_pat, async_iter_pat_id) =
1739+
self.pat_ident_binding_mode(head_span, iter_ident, hir::BindingMode::REF_MUT);
1740+
let iter = self.expr_ident_mut(head_span, iter_ident, async_iter_pat_id);
17371741
// `Pin::new_unchecked(...)`
17381742
let iter = self.arena.alloc(self.expr_call_lang_item_fn_mut(
17391743
head_span,
@@ -1742,17 +1746,29 @@ impl<'hir> LoweringContext<'_, 'hir> {
17421746
));
17431747
// `unsafe { ... }`
17441748
let iter = self.arena.alloc(self.expr_unsafe(iter));
1745-
iter
1749+
let inner_match_expr = self.arena.alloc(self.expr_match(
1750+
for_span,
1751+
iter,
1752+
arena_vec![self; iter_arm],
1753+
hir::MatchSource::ForLoopDesugar,
1754+
));
1755+
1756+
// `::core::async_iter::IntoAsyncIterator::into_async_iter(<head>)`
1757+
let iter = self.expr_call_lang_item_fn(
1758+
head_span,
1759+
hir::LangItem::IntoAsyncIterIntoIter,
1760+
arena_vec![self; head],
1761+
);
1762+
let iter_arm = self.arm(async_iter_pat, inner_match_expr);
1763+
self.arena.alloc(self.expr_match(
1764+
for_span,
1765+
iter,
1766+
arena_vec![self; iter_arm],
1767+
hir::MatchSource::ForLoopDesugar,
1768+
))
17461769
}
17471770
};
17481771

1749-
let match_expr = self.arena.alloc(self.expr_match(
1750-
for_span,
1751-
into_iter_expr,
1752-
arena_vec![self; iter_arm],
1753-
hir::MatchSource::ForLoopDesugar,
1754-
));
1755-
17561772
// This is effectively `{ let _result = ...; _result }`.
17571773
// The construct was introduced in #21984 and is necessary to make sure that
17581774
// temporaries in the `head` expression are dropped and do not leak to the

compiler/rustc_data_structures/src/flock.rs

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ cfg_match! {
99
mod linux;
1010
use linux as imp;
1111
}
12+
cfg(target_os = "redox") => {
13+
mod linux;
14+
use linux as imp;
15+
}
1216
cfg(unix) => {
1317
mod unix;
1418
use unix as imp;

compiler/rustc_feature/src/unstable.rs

+2
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,8 @@ declare_features! (
586586
(incomplete, return_type_notation, "1.70.0", Some(109417)),
587587
/// Allows `extern "rust-cold"`.
588588
(unstable, rust_cold_cc, "1.63.0", Some(97544)),
589+
/// Shortern the tail expression lifetime
590+
(unstable, shorter_tail_lifetimes, "1.79.0", Some(123739)),
589591
/// Allows the use of SIMD types in functions declared in `extern` blocks.
590592
(unstable, simd_ffi, "1.0.0", Some(27731)),
591593
/// Allows specialization of implementations (RFC 1210).

compiler/rustc_hir_analysis/src/check/region.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
//!
77
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/borrow_check.html
88
9-
use rustc_ast::visit::visit_opt;
109
use rustc_data_structures::fx::FxHashSet;
1110
use rustc_hir as hir;
1211
use rustc_hir::def_id::DefId;
@@ -168,7 +167,14 @@ fn resolve_block<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, blk: &'tcx h
168167
hir::StmtKind::Expr(..) | hir::StmtKind::Semi(..) => visitor.visit_stmt(statement),
169168
}
170169
}
171-
visit_opt!(visitor, visit_expr, &blk.expr);
170+
if let Some(tail_expr) = blk.expr {
171+
if visitor.tcx.features().shorter_tail_lifetimes
172+
&& blk.span.edition().at_least_rust_2024()
173+
{
174+
visitor.terminating_scopes.insert(tail_expr.hir_id.local_id);
175+
}
176+
visitor.visit_expr(tail_expr);
177+
}
172178
}
173179

174180
visitor.cx = prev_cx;

compiler/rustc_lint/messages.ftl

+1
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@ lint_non_local_definitions_impl = non-local `impl` definition, `impl` blocks sho
550550
.bounds = `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
551551
.exception = items in an anonymous const item (`const _: () = {"{"} ... {"}"}`) are treated as in the same scope as the anonymous const's declaration
552552
.const_anon = use a const-anon item to suppress this lint
553+
.macro_to_change = the {$macro_kind} `{$macro_to_change}` defines the non-local `impl`, and may need to be changed
553554
554555
lint_non_local_definitions_impl_move_help =
555556
move the `impl` block outside of this {$body_kind_descr} {$depth ->

compiler/rustc_lint/src/lints.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -1362,6 +1362,7 @@ pub enum NonLocalDefinitionsDiag {
13621362
has_trait: bool,
13631363
self_ty_str: String,
13641364
of_trait_str: Option<String>,
1365+
macro_to_change: Option<(String, &'static str)>,
13651366
},
13661367
MacroRules {
13671368
depth: u32,
@@ -1387,6 +1388,7 @@ impl<'a> LintDiagnostic<'a, ()> for NonLocalDefinitionsDiag {
13871388
has_trait,
13881389
self_ty_str,
13891390
of_trait_str,
1391+
macro_to_change,
13901392
} => {
13911393
diag.primary_message(fluent::lint_non_local_definitions_impl);
13921394
diag.arg("depth", depth);
@@ -1397,6 +1399,15 @@ impl<'a> LintDiagnostic<'a, ()> for NonLocalDefinitionsDiag {
13971399
diag.arg("of_trait_str", of_trait_str);
13981400
}
13991401

1402+
if let Some((macro_to_change, macro_kind)) = macro_to_change {
1403+
diag.arg("macro_to_change", macro_to_change);
1404+
diag.arg("macro_kind", macro_kind);
1405+
diag.note(fluent::lint_macro_to_change);
1406+
}
1407+
if let Some(cargo_update) = cargo_update {
1408+
diag.subdiagnostic(&diag.dcx, cargo_update);
1409+
}
1410+
14001411
if has_trait {
14011412
diag.note(fluent::lint_bounds);
14021413
diag.note(fluent::lint_with_trait);
@@ -1422,9 +1433,6 @@ impl<'a> LintDiagnostic<'a, ()> for NonLocalDefinitionsDiag {
14221433
);
14231434
}
14241435

1425-
if let Some(cargo_update) = cargo_update {
1426-
diag.subdiagnostic(&diag.dcx, cargo_update);
1427-
}
14281436
if let Some(const_anon) = const_anon {
14291437
diag.note(fluent::lint_exception);
14301438
if let Some(const_anon) = const_anon {

compiler/rustc_lint/src/non_local_def.rs

+8
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,13 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions {
258258
Some((cx.tcx.def_span(parent), may_move))
259259
};
260260

261+
let macro_to_change =
262+
if let ExpnKind::Macro(kind, name) = item.span.ctxt().outer_expn_data().kind {
263+
Some((name.to_string(), kind.descr()))
264+
} else {
265+
None
266+
};
267+
261268
cx.emit_span_lint(
262269
NON_LOCAL_DEFINITIONS,
263270
ms,
@@ -274,6 +281,7 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions {
274281
move_to,
275282
may_remove,
276283
has_trait: impl_.of_trait.is_some(),
284+
macro_to_change,
277285
},
278286
)
279287
}

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1677,6 +1677,7 @@ symbols! {
16771677
shadow_call_stack,
16781678
shl,
16791679
shl_assign,
1680+
shorter_tail_lifetimes,
16801681
should_panic,
16811682
shr,
16821683
shr_assign,

compiler/rustc_target/src/spec/base/redox.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::spec::{cvs, RelroLevel, TargetOptions};
1+
use crate::spec::{cvs, Cc, LinkerFlavor, Lld, RelroLevel, TargetOptions};
22

33
pub fn opts() -> TargetOptions {
44
TargetOptions {
@@ -12,6 +12,8 @@ pub fn opts() -> TargetOptions {
1212
has_thread_local: true,
1313
crt_static_default: true,
1414
crt_static_respected: true,
15+
crt_static_allows_dylibs: true,
16+
late_link_args: TargetOptions::link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-lgcc"]),
1517
..Default::default()
1618
}
1719
}

compiler/rustc_target/src/spec/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1647,6 +1647,7 @@ supported_targets! {
16471647
("x86_64-unknown-l4re-uclibc", x86_64_unknown_l4re_uclibc),
16481648

16491649
("aarch64-unknown-redox", aarch64_unknown_redox),
1650+
("i686-unknown-redox", i686_unknown_redox),
16501651
("x86_64-unknown-redox", x86_64_unknown_redox),
16511652

16521653
("i386-apple-ios", i386_apple_ios),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target};
2+
3+
pub fn target() -> Target {
4+
let mut base = base::redox::opts();
5+
base.cpu = "pentiumpro".into();
6+
base.plt_by_default = false;
7+
base.max_atomic_width = Some(64);
8+
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
9+
// don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
10+
base.stack_probes = StackProbeType::Call;
11+
12+
Target {
13+
llvm_target: "i686-unknown-redox".into(),
14+
metadata: crate::spec::TargetMetadata {
15+
description: None,
16+
tier: None,
17+
host_tools: None,
18+
std: None,
19+
},
20+
pointer_width: 32,
21+
data_layout:
22+
"e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:128-f64:32:64-f80:32-n8:16:32-S128"
23+
.into(),
24+
arch: "x86".into(),
25+
options: base,
26+
}
27+
}

0 commit comments

Comments
 (0)