Skip to content

Commit b7912d3

Browse files
committed
Auto merge of rust-lang#3187 - RalfJung:rustup, r=RalfJung
Rustup
2 parents 44aceb5 + 34a8680 commit b7912d3

File tree

5,902 files changed

+7654
-6351
lines changed

Some content is hidden

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

5,902 files changed

+7654
-6351
lines changed

Cargo.lock

+6-6
Original file line numberDiff line numberDiff line change
@@ -5767,9 +5767,9 @@ dependencies = [
57675767

57685768
[[package]]
57695769
name = "unicase"
5770-
version = "2.6.0"
5770+
version = "2.7.0"
57715771
source = "registry+https://github.com/rust-lang/crates.io-index"
5772-
checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
5772+
checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89"
57735773
dependencies = [
57745774
"version_check",
57755775
]
@@ -6072,9 +6072,9 @@ dependencies = [
60726072

60736073
[[package]]
60746074
name = "windows-bindgen"
6075-
version = "0.51.1"
6075+
version = "0.52.0"
60766076
source = "registry+https://github.com/rust-lang/crates.io-index"
6077-
checksum = "bc1f16b778125675feee0d15d6dd9f6af0e3ac52b3233d63a10aa39230c1cd75"
6077+
checksum = "970efb0b6849eb8a87a898f586af7cc167567b070014c7434514c0bde0ca341c"
60786078
dependencies = [
60796079
"proc-macro2",
60806080
"rayon",
@@ -6084,9 +6084,9 @@ dependencies = [
60846084

60856085
[[package]]
60866086
name = "windows-metadata"
6087-
version = "0.51.1"
6087+
version = "0.52.0"
60886088
source = "registry+https://github.com/rust-lang/crates.io-index"
6089-
checksum = "753135d996f9da437c0b31dbde3032489a61708361929bcc07d4fba0b161000e"
6089+
checksum = "218fd59201e26acdbb894fa2b302d1de84bf3eec7d0eb894ac8e9c5a854ee4ef"
60906090

60916091
[[package]]
60926092
name = "windows-sys"

compiler/rustc_ast/src/ast.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ pub enum TraitBoundModifier {
301301
Maybe,
302302

303303
/// `~const Trait`
304-
MaybeConst,
304+
MaybeConst(Span),
305305

306306
/// `~const !Trait`
307307
//
@@ -317,8 +317,7 @@ pub enum TraitBoundModifier {
317317
impl TraitBoundModifier {
318318
pub fn to_constness(self) -> Const {
319319
match self {
320-
// FIXME(effects) span
321-
Self::MaybeConst => Const::Yes(DUMMY_SP),
320+
Self::MaybeConst(span) => Const::Yes(span),
322321
_ => Const::No,
323322
}
324323
}
@@ -3155,7 +3154,7 @@ mod size_asserts {
31553154
static_assert_size!(ForeignItem, 96);
31563155
static_assert_size!(ForeignItemKind, 24);
31573156
static_assert_size!(GenericArg, 24);
3158-
static_assert_size!(GenericBound, 56);
3157+
static_assert_size!(GenericBound, 64);
31593158
static_assert_size!(Generics, 40);
31603159
static_assert_size!(Impl, 136);
31613160
static_assert_size!(Item, 136);

compiler/rustc_ast_lowering/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13691369
GenericBound::Trait(
13701370
ty,
13711371
modifier @ (TraitBoundModifier::None
1372-
| TraitBoundModifier::MaybeConst
1372+
| TraitBoundModifier::MaybeConst(_)
13731373
| TraitBoundModifier::Negative),
13741374
) => {
13751375
Some(this.lower_poly_trait_ref(ty, itctx, modifier.to_constness()))
@@ -2227,7 +2227,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
22272227
fn lower_trait_bound_modifier(&mut self, f: TraitBoundModifier) -> hir::TraitBoundModifier {
22282228
match f {
22292229
TraitBoundModifier::None => hir::TraitBoundModifier::None,
2230-
TraitBoundModifier::MaybeConst => hir::TraitBoundModifier::MaybeConst,
2230+
TraitBoundModifier::MaybeConst(_) => hir::TraitBoundModifier::MaybeConst,
22312231

22322232
TraitBoundModifier::Negative => {
22332233
if self.tcx.features().negative_bounds {

compiler/rustc_ast_passes/src/ast_validation.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
12031203
(BoundKind::TraitObject, TraitBoundModifier::Maybe) => {
12041204
self.err_handler().emit_err(errors::OptionalTraitObject { span: poly.span });
12051205
}
1206-
(_, TraitBoundModifier::MaybeConst)
1206+
(_, &TraitBoundModifier::MaybeConst(span))
12071207
if let Some(reason) = &self.disallow_tilde_const =>
12081208
{
12091209
let reason = match reason {
@@ -1224,8 +1224,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
12241224
}
12251225
DisallowTildeConstContext::Item => errors::TildeConstReason::Item,
12261226
};
1227-
self.err_handler()
1228-
.emit_err(errors::TildeConstDisallowed { span: bound.span(), reason });
1227+
self.err_handler().emit_err(errors::TildeConstDisallowed { span, reason });
12291228
}
12301229
(_, TraitBoundModifier::MaybeConstMaybe) => {
12311230
self.err_handler().emit_err(errors::OptionalConstExclusive {

compiler/rustc_ast_pretty/src/pprust/state.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1515,7 +1515,7 @@ impl<'a> State<'a> {
15151515
TraitBoundModifier::Maybe => {
15161516
self.word("?");
15171517
}
1518-
TraitBoundModifier::MaybeConst => {
1518+
TraitBoundModifier::MaybeConst(_) => {
15191519
self.word_space("~const");
15201520
}
15211521
TraitBoundModifier::MaybeConstNegative => {

compiler/rustc_builtin_macros/src/deriving/default.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -127,18 +127,17 @@ fn extract_default_variant<'a>(
127127
[first, rest @ ..] => {
128128
let suggs = default_variants
129129
.iter()
130-
.map(|variant| {
131-
let spans = default_variants
130+
.filter_map(|variant| {
131+
let keep = attr::find_by_name(&variant.attrs, kw::Default)?.span;
132+
let spans: Vec<Span> = default_variants
132133
.iter()
133-
.filter_map(|v| {
134-
if v.span == variant.span {
135-
None
136-
} else {
137-
Some(attr::find_by_name(&v.attrs, kw::Default)?.span)
138-
}
134+
.flat_map(|v| {
135+
attr::filter_by_name(&v.attrs, kw::Default)
136+
.filter_map(|attr| (attr.span != keep).then_some(attr.span))
139137
})
140138
.collect();
141-
errors::MultipleDefaultsSugg { spans, ident: variant.ident }
139+
(!spans.is_empty())
140+
.then_some(errors::MultipleDefaultsSugg { spans, ident: variant.ident })
142141
})
143142
.collect();
144143
cx.emit_err(errors::MultipleDefaults {

compiler/rustc_codegen_cranelift/build_system/tests.rs

+9
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[
100100
TestCase::build_bin_and_run("aot.issue-72793", "example/issue-72793.rs", &[]),
101101
TestCase::build_bin("aot.issue-59326", "example/issue-59326.rs"),
102102
TestCase::build_bin_and_run("aot.neon", "example/neon.rs", &[]),
103+
TestCase::custom("aot.gen_block_iterate", &|runner| {
104+
runner.run_rustc([
105+
"example/gen_block_iterate.rs",
106+
"--edition",
107+
"2024",
108+
"-Zunstable-options",
109+
]);
110+
runner.run_out_command("gen_block_iterate", &[]);
111+
}),
103112
];
104113

105114
pub(crate) static RAND_REPO: GitRepo = GitRepo::github(

compiler/rustc_codegen_cranelift/config.txt

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ aot.mod_bench
4343
aot.issue-72793
4444
aot.issue-59326
4545
aot.neon
46+
aot.gen_block_iterate
4647

4748
testsuite.extended_sysroot
4849
test.rust-random/rand
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copied from https://github.com/rust-lang/rust/blob/46455dc65069387f2dc46612f13fd45452ab301a/tests/ui/coroutine/gen_block_iterate.rs
2+
// revisions: next old
3+
//compile-flags: --edition 2024 -Zunstable-options
4+
//[next] compile-flags: -Ztrait-solver=next
5+
// run-pass
6+
#![feature(gen_blocks)]
7+
8+
fn foo() -> impl Iterator<Item = u32> {
9+
gen { yield 42; for x in 3..6 { yield x } }
10+
}
11+
12+
fn moved() -> impl Iterator<Item = u32> {
13+
let mut x = "foo".to_string();
14+
gen move {
15+
yield 42;
16+
if x == "foo" { return }
17+
x.clear();
18+
for x in 3..6 { yield x }
19+
}
20+
}
21+
22+
fn main() {
23+
let mut iter = foo();
24+
assert_eq!(iter.next(), Some(42));
25+
assert_eq!(iter.next(), Some(3));
26+
assert_eq!(iter.next(), Some(4));
27+
assert_eq!(iter.next(), Some(5));
28+
assert_eq!(iter.next(), None);
29+
// `gen` blocks are fused
30+
assert_eq!(iter.next(), None);
31+
32+
let mut iter = moved();
33+
assert_eq!(iter.next(), Some(42));
34+
assert_eq!(iter.next(), None);
35+
36+
}

compiler/rustc_codegen_cranelift/rustfmt.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
ignore = ["y.rs"]
1+
ignore = [
2+
"y.rs",
3+
"example/gen_block_iterate.rs", # uses edition 2024
4+
]
25

36
# Matches rustfmt.toml of rustc
47
version = "Two"

compiler/rustc_const_eval/src/interpret/memory.rs

+11
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,17 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
501501
}
502502
}
503503

504+
impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
505+
/// This function is used by Miri's provenance GC to remove unreachable entries from the dead_alloc_map.
506+
pub fn remove_unreachable_allocs(&mut self, reachable_allocs: &FxHashSet<AllocId>) {
507+
// Unlike all the other GC helpers where we check if an `AllocId` is found in the interpreter or
508+
// is live, here all the IDs in the map are for dead allocations so we don't
509+
// need to check for liveness.
510+
#[allow(rustc::potential_query_instability)] // Only used from Miri, not queries.
511+
self.memory.dead_alloc_map.retain(|id, _| reachable_allocs.contains(id));
512+
}
513+
}
514+
504515
/// Allocation accessors
505516
impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
506517
/// Helper function to obtain a global (tcx) allocation.

compiler/rustc_data_structures/src/sync/worker_local.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use parking_lot::Mutex;
22
use std::cell::Cell;
33
use std::cell::OnceCell;
4+
use std::num::NonZeroUsize;
45
use std::ops::Deref;
56
use std::ptr;
67
use std::sync::Arc;
@@ -30,7 +31,7 @@ impl RegistryId {
3031
}
3132

3233
struct RegistryData {
33-
thread_limit: usize,
34+
thread_limit: NonZeroUsize,
3435
threads: Mutex<usize>,
3536
}
3637

@@ -60,7 +61,7 @@ thread_local! {
6061

6162
impl Registry {
6263
/// Creates a registry which can hold up to `thread_limit` threads.
63-
pub fn new(thread_limit: usize) -> Self {
64+
pub fn new(thread_limit: NonZeroUsize) -> Self {
6465
Registry(Arc::new(RegistryData { thread_limit, threads: Mutex::new(0) }))
6566
}
6667

@@ -73,7 +74,7 @@ impl Registry {
7374
/// Panics if the thread limit is hit or if the thread already has an associated registry.
7475
pub fn register(&self) {
7576
let mut threads = self.0.threads.lock();
76-
if *threads < self.0.thread_limit {
77+
if *threads < self.0.thread_limit.get() {
7778
REGISTRY.with(|registry| {
7879
if registry.get().is_some() {
7980
drop(threads);
@@ -126,7 +127,9 @@ impl<T> WorkerLocal<T> {
126127
{
127128
let registry = Registry::current();
128129
WorkerLocal {
129-
locals: (0..registry.0.thread_limit).map(|i| CacheAligned(initial(i))).collect(),
130+
locals: (0..registry.0.thread_limit.get())
131+
.map(|i| CacheAligned(initial(i)))
132+
.collect(),
130133
registry,
131134
}
132135
}

compiler/rustc_errors/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1465,7 +1465,7 @@ impl HandlerInner {
14651465
};
14661466
let errors = match self.deduplicated_err_count {
14671467
0 => Cow::from(""),
1468-
1 => Cow::from("aborting due to previous error"),
1468+
1 => Cow::from("aborting due to 1 previous error"),
14691469
count => Cow::from(format!("aborting due to {count} previous errors")),
14701470
};
14711471
if self.treat_err_as_bug() {

compiler/rustc_expand/src/build.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc_ast::{self as ast, AttrVec, BlockCheckMode, Expr, LocalKind, PatKind,
44
use rustc_ast::{attr, token, util::literal};
55
use rustc_span::source_map::Spanned;
66
use rustc_span::symbol::{kw, sym, Ident, Symbol};
7-
use rustc_span::Span;
7+
use rustc_span::{Span, DUMMY_SP};
88
use thin_vec::{thin_vec, ThinVec};
99

1010
impl<'a> ExtCtxt<'a> {
@@ -135,7 +135,7 @@ impl<'a> ExtCtxt<'a> {
135135
ast::GenericBound::Trait(
136136
self.poly_trait_ref(path.span, path),
137137
if is_const {
138-
ast::TraitBoundModifier::MaybeConst
138+
ast::TraitBoundModifier::MaybeConst(DUMMY_SP)
139139
} else {
140140
ast::TraitBoundModifier::None
141141
},

compiler/rustc_feature/src/unstable.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ declare_features! (
160160
// no-tracking-issue-start
161161

162162
/// Allows using the `unadjusted` ABI; perma-unstable.
163-
(unstable, abi_unadjusted, "1.16.0", None, None),
163+
(internal, abi_unadjusted, "1.16.0", None, None),
164164
/// Allows using the `vectorcall` ABI.
165165
(unstable, abi_vectorcall, "1.7.0", None, None),
166166
/// Allows using `#![needs_allocator]`, an implementation detail of `#[global_allocator]`.
@@ -456,6 +456,8 @@ declare_features! (
456456
(unstable, ffi_returns_twice, "1.34.0", Some(58314), None),
457457
/// Allows using `#[repr(align(...))]` on function items
458458
(unstable, fn_align, "1.53.0", Some(82232), None),
459+
/// Support delegating implementation of functions to other already implemented functions.
460+
(incomplete, fn_delegation, "CURRENT_RUSTC_VERSION", Some(118212), None),
459461
/// Allows defining gen blocks and `gen fn`.
460462
(unstable, gen_blocks, "1.75.0", Some(117078), None),
461463
/// Infer generic args for both consts and types.

compiler/rustc_hir_typeck/src/expr.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -526,14 +526,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
526526
_ => self.instantiate_value_path(segs, opt_ty, res, expr.span, expr.hir_id).0,
527527
};
528528

529-
if let ty::FnDef(did, callee_args) = *ty.kind() {
529+
if let ty::FnDef(did, _) = *ty.kind() {
530530
let fn_sig = ty.fn_sig(tcx);
531531

532-
// HACK: whenever we get a FnDef in a non-const context, enforce effects to get the
533-
// default `host = true` to avoid inference errors later.
534-
if tcx.hir().body_const_context(self.body_id).is_none() {
535-
self.enforce_context_effects(expr.hir_id, qpath.span(), did, callee_args);
536-
}
537532
if tcx.fn_sig(did).skip_binder().abi() == RustIntrinsic
538533
&& tcx.item_name(did) == sym::transmute
539534
{
@@ -1932,7 +1927,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
19321927
/// 8 | foo::Foo {};
19331928
/// | ^^^^^^^^ missing `you_can_use_this_field`
19341929
///
1935-
/// error: aborting due to previous error
1930+
/// error: aborting due to 1 previous error
19361931
/// ```
19371932
fn report_missing_fields(
19381933
&self,
@@ -2049,7 +2044,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
20492044
/// 8 | foo::Foo {};
20502045
/// | ^^^^^^^^
20512046
///
2052-
/// error: aborting due to previous error
2047+
/// error: aborting due to 1 previous error
20532048
/// ```
20542049
fn report_private_fields(
20552050
&self,

compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use crate::infer::canonical::{
99
Canonical, CanonicalTyVarKind, CanonicalVarInfo, CanonicalVarKind, OriginalQueryValues,
1010
};
1111
use crate::infer::InferCtxt;
12-
use rustc_middle::ty::flags::FlagComputation;
1312
use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
1413
use rustc_middle::ty::GenericArg;
1514
use rustc_middle::ty::{self, BoundVar, InferConst, List, Ty, TyCtxt, TypeFlags, TypeVisitableExt};
@@ -550,8 +549,11 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
550549
_ => {}
551550
}
552551

553-
let flags = FlagComputation::for_const(ct);
554-
if flags.intersects(self.needs_canonical_flags) { ct.super_fold_with(self) } else { ct }
552+
if ct.flags().intersects(self.needs_canonical_flags) {
553+
ct.super_fold_with(self)
554+
} else {
555+
ct
556+
}
555557
}
556558
}
557559

compiler/rustc_interface/src/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce() -> R + Send, R: Send>(
107107
use rustc_query_impl::QueryCtxt;
108108
use rustc_query_system::query::{deadlock, QueryContext};
109109

110-
let registry = sync::Registry::new(threads);
110+
let registry = sync::Registry::new(std::num::NonZeroUsize::new(threads).unwrap());
111111

112112
if !sync::is_dyn_thread_safe() {
113113
return run_in_thread_with_globals(edition, || {

compiler/rustc_lint/messages.ftl

+2-1
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,9 @@ lint_requested_level = requested on the command line with `{$level} {$lint_name}
491491
lint_span_use_eq_ctxt = use `.eq_ctxt()` instead of `.ctxt() == .ctxt()`
492492
493493
lint_supertrait_as_deref_target = this `Deref` implementation is covered by an implicit supertrait coercion
494+
.label = `{$self_ty}` implements `Deref<Target = dyn {$target_principal}>` which conflicts with supertrait `{$supertrait_principal}`
495+
.label2 = target type is a supertrait of `{$self_ty}`
494496
.help = consider removing this implementation or replacing it with a method instead
495-
.label = target type is a supertrait of `{$t}`
496497
497498
lint_suspicious_double_ref_clone =
498499
using `.clone()` on a double reference, which returns `{$ty}` instead of cloning the inner type

0 commit comments

Comments
 (0)