Skip to content

Commit a40a100

Browse files
committed
Auto merge of #3294 - rust-lang:rustup-2024-02-11, r=saethlin
Automatic Rustup
2 parents 5a3a2d5 + 48bb2bf commit a40a100

File tree

171 files changed

+2273
-2644
lines changed

Some content is hidden

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

171 files changed

+2273
-2644
lines changed

compiler/rustc_ast/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#![feature(box_patterns)]
1616
#![feature(if_let_guard)]
1717
#![feature(let_chains)]
18-
#![feature(min_specialization)]
18+
#![cfg_attr(bootstrap, feature(min_specialization))]
1919
#![feature(negative_impls)]
2020
#![feature(stmt_expr_attributes)]
2121

compiler/rustc_ast_lowering/messages.ftl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ ast_lowering_arbitrary_expression_in_pattern =
88
99
ast_lowering_argument = argument
1010
11+
ast_lowering_assoc_ty_binding_in_dyn =
12+
associated type bounds are not allowed in `dyn` types
13+
.suggestion = use `impl Trait` to introduce a type instead
14+
1115
ast_lowering_assoc_ty_parentheses =
1216
parenthesized generic arguments cannot be used in associated type constraints
1317
@@ -100,9 +104,6 @@ ast_lowering_match_arm_with_no_body =
100104
`match` arm with no body
101105
.suggestion = add a body after the pattern
102106
103-
ast_lowering_misplaced_assoc_ty_binding =
104-
associated type bounds are only allowed in where clauses and function signatures, not in {$position}
105-
106107
ast_lowering_misplaced_double_dot =
107108
`..` patterns are not allowed here
108109
.note = only allowed in tuple, tuple struct, and slice patterns

compiler/rustc_ast_lowering/src/errors.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,12 @@ pub struct MisplacedImplTrait<'a> {
9494
}
9595

9696
#[derive(Diagnostic)]
97-
#[diag(ast_lowering_misplaced_assoc_ty_binding)]
98-
pub struct MisplacedAssocTyBinding<'a> {
97+
#[diag(ast_lowering_assoc_ty_binding_in_dyn)]
98+
pub struct MisplacedAssocTyBinding {
9999
#[primary_span]
100100
pub span: Span,
101-
pub position: DiagnosticArgFromDisplay<'a>,
101+
#[suggestion(code = " = impl", applicability = "maybe-incorrect", style = "verbose")]
102+
pub suggestion: Option<Span>,
102103
}
103104

104105
#[derive(Diagnostic, Clone, Copy)]

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 30 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ trait ResolverAstLoweringExt {
197197
fn get_label_res(&self, id: NodeId) -> Option<NodeId>;
198198
fn get_lifetime_res(&self, id: NodeId) -> Option<LifetimeRes>;
199199
fn take_extra_lifetime_params(&mut self, id: NodeId) -> Vec<(Ident, NodeId, LifetimeRes)>;
200-
fn remap_extra_lifetime_params(&mut self, from: NodeId, to: NodeId);
201200
}
202201

203202
impl ResolverAstLoweringExt for ResolverAstLowering {
@@ -256,11 +255,6 @@ impl ResolverAstLoweringExt for ResolverAstLowering {
256255
fn take_extra_lifetime_params(&mut self, id: NodeId) -> Vec<(Ident, NodeId, LifetimeRes)> {
257256
self.extra_lifetime_params_map.remove(&id).unwrap_or_default()
258257
}
259-
260-
fn remap_extra_lifetime_params(&mut self, from: NodeId, to: NodeId) {
261-
let lifetimes = self.extra_lifetime_params_map.remove(&from).unwrap_or_default();
262-
self.extra_lifetime_params_map.insert(to, lifetimes);
263-
}
264258
}
265259

266260
/// Context of `impl Trait` in code, which determines whether it is allowed in an HIR subtree,
@@ -1084,88 +1078,38 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
10841078
hir::TypeBindingKind::Equality { term }
10851079
}
10861080
AssocConstraintKind::Bound { bounds } => {
1087-
enum DesugarKind {
1088-
ImplTrait,
1089-
Error(ImplTraitPosition),
1090-
Bound,
1091-
}
1092-
1093-
// Piggy-back on the `impl Trait` context to figure out the correct behavior.
1094-
let desugar_kind = match itctx {
1095-
// in an argument, RPIT, or TAIT, if we are within a dyn type:
1096-
//
1097-
// fn foo(x: dyn Iterator<Item: Debug>)
1098-
//
1099-
// then desugar to:
1100-
//
1101-
// fn foo(x: dyn Iterator<Item = impl Debug>)
1102-
//
1103-
// This is because dyn traits must have all of their associated types specified.
1104-
ImplTraitContext::ReturnPositionOpaqueTy { .. }
1105-
| ImplTraitContext::TypeAliasesOpaqueTy { .. }
1106-
| ImplTraitContext::Universal
1107-
if self.is_in_dyn_type =>
1108-
{
1109-
DesugarKind::ImplTrait
1110-
}
1111-
1112-
ImplTraitContext::Disallowed(position) if self.is_in_dyn_type => {
1113-
DesugarKind::Error(position)
1114-
}
1115-
1116-
// We are in the parameter position, but not within a dyn type:
1117-
//
1118-
// fn foo(x: impl Iterator<Item: Debug>)
1119-
//
1120-
// so we leave it as is and this gets expanded in astconv to a bound like
1121-
// `<T as Iterator>::Item: Debug` where `T` is the type parameter for the
1122-
// `impl Iterator`.
1123-
_ => DesugarKind::Bound,
1124-
};
1125-
1126-
match desugar_kind {
1127-
DesugarKind::ImplTrait => {
1128-
// Desugar `AssocTy: Bounds` into `AssocTy = impl Bounds`. We do this by
1129-
// constructing the HIR for `impl bounds...` and then lowering that.
1130-
1131-
let impl_trait_node_id = self.next_node_id();
1132-
// Shift `impl Trait` lifetime captures from the associated type bound's
1133-
// node id to the opaque node id, so that the opaque can actually use
1134-
// these lifetime bounds.
1135-
self.resolver
1136-
.remap_extra_lifetime_params(constraint.id, impl_trait_node_id);
1137-
1138-
self.with_dyn_type_scope(false, |this| {
1139-
let node_id = this.next_node_id();
1140-
let ty = this.lower_ty(
1141-
&Ty {
1142-
id: node_id,
1143-
kind: TyKind::ImplTrait(impl_trait_node_id, bounds.clone()),
1144-
span: this.lower_span(constraint.span),
1145-
tokens: None,
1146-
},
1147-
itctx,
1148-
);
1081+
// Disallow ATB in dyn types
1082+
if self.is_in_dyn_type {
1083+
let suggestion = match itctx {
1084+
ImplTraitContext::ReturnPositionOpaqueTy { .. }
1085+
| ImplTraitContext::TypeAliasesOpaqueTy { .. }
1086+
| ImplTraitContext::Universal => {
1087+
let bound_end_span = constraint
1088+
.gen_args
1089+
.as_ref()
1090+
.map_or(constraint.ident.span, |args| args.span());
1091+
if bound_end_span.eq_ctxt(constraint.span) {
1092+
Some(self.tcx.sess.source_map().next_point(bound_end_span))
1093+
} else {
1094+
None
1095+
}
1096+
}
1097+
_ => None,
1098+
};
11491099

1150-
hir::TypeBindingKind::Equality { term: ty.into() }
1151-
})
1152-
}
1153-
DesugarKind::Bound => {
1154-
// Desugar `AssocTy: Bounds` into a type binding where the
1155-
// later desugars into a trait predicate.
1156-
let bounds = self.lower_param_bounds(bounds, itctx);
1100+
let guar = self.dcx().emit_err(errors::MisplacedAssocTyBinding {
1101+
span: constraint.span,
1102+
suggestion,
1103+
});
1104+
let err_ty =
1105+
&*self.arena.alloc(self.ty(constraint.span, hir::TyKind::Err(guar)));
1106+
hir::TypeBindingKind::Equality { term: err_ty.into() }
1107+
} else {
1108+
// Desugar `AssocTy: Bounds` into a type binding where the
1109+
// later desugars into a trait predicate.
1110+
let bounds = self.lower_param_bounds(bounds, itctx);
11571111

1158-
hir::TypeBindingKind::Constraint { bounds }
1159-
}
1160-
DesugarKind::Error(position) => {
1161-
let guar = self.dcx().emit_err(errors::MisplacedAssocTyBinding {
1162-
span: constraint.span,
1163-
position: DiagnosticArgFromDisplay(&position),
1164-
});
1165-
let err_ty =
1166-
&*self.arena.alloc(self.ty(constraint.span, hir::TyKind::Err(guar)));
1167-
hir::TypeBindingKind::Equality { term: err_ty.into() }
1168-
}
1112+
hir::TypeBindingKind::Constraint { bounds }
11691113
}
11701114
}
11711115
};

compiler/rustc_codegen_llvm/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#![feature(hash_raw_entry)]
1414
#![feature(iter_intersperse)]
1515
#![feature(let_chains)]
16-
#![feature(min_specialization)]
1716
#![feature(impl_trait_in_assoc_type)]
1817

1918
#[macro_use]

compiler/rustc_codegen_ssa/messages.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ codegen_ssa_no_module_named =
190190
191191
codegen_ssa_no_natvis_directory = error enumerating natvis directory: {$error}
192192
193+
codegen_ssa_no_saved_object_file = cached cgu {$cgu_name} should have an object file, but doesn't
194+
193195
codegen_ssa_processing_dymutil_failed = processing debug info with `dsymutil` failed: {$status}
194196
.note = {$output}
195197

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,9 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
913913

914914
let object = load_from_incr_comp_dir(
915915
cgcx.output_filenames.temp_path(OutputType::Object, Some(&module.name)),
916-
module.source.saved_files.get("o").expect("no saved object file in work product"),
916+
module.source.saved_files.get("o").unwrap_or_else(|| {
917+
cgcx.create_dcx().emit_fatal(errors::NoSavedObjectFile { cgu_name: &module.name })
918+
}),
917919
);
918920
let dwarf_object =
919921
module.source.saved_files.get("dwo").as_ref().and_then(|saved_dwarf_object_file| {

compiler/rustc_codegen_ssa/src/errors.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ pub struct NoNatvisDirectory {
121121
pub error: Error,
122122
}
123123

124+
#[derive(Diagnostic)]
125+
#[diag(codegen_ssa_no_saved_object_file)]
126+
pub struct NoSavedObjectFile<'a> {
127+
pub cgu_name: &'a str,
128+
}
129+
124130
#[derive(Diagnostic)]
125131
#[diag(codegen_ssa_copy_path_buf)]
126132
pub struct CopyPathBuf {

compiler/rustc_const_eval/messages.ftl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ const_eval_closure_non_const =
3030
cannot call non-const closure in {const_eval_const_context}s
3131
const_eval_consider_dereferencing =
3232
consider dereferencing here
33-
const_eval_const_accesses_static = constant accesses static
33+
34+
const_eval_const_accesses_mut_global =
35+
constant accesses mutable global memory
3436
3537
const_eval_const_context = {$kind ->
3638
[const] constant
@@ -319,12 +321,6 @@ const_eval_size_overflow =
319321
const_eval_stack_frame_limit_reached =
320322
reached the configured maximum number of stack frames
321323
322-
const_eval_static_access =
323-
{const_eval_const_context}s cannot refer to statics
324-
.help = consider extracting the value of the `static` to a `const`, and referring to that
325-
.teach_note = `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable.
326-
.teach_help = To fix this, the value can be extracted to a `const` and then used.
327-
328324
const_eval_thread_local_access =
329325
thread-local statics cannot be accessed at compile-time
330326
@@ -415,6 +411,10 @@ const_eval_upcast_mismatch =
415411
## (We'd love to sort this differently to make that more clear but tidy won't let us...)
416412
const_eval_validation_box_to_static = {$front_matter}: encountered a box pointing to a static variable in a constant
417413
const_eval_validation_box_to_uninhabited = {$front_matter}: encountered a box pointing to uninhabited type {$ty}
414+
415+
const_eval_validation_const_ref_to_extern = {$front_matter}: encountered reference to `extern` static in `const`
416+
const_eval_validation_const_ref_to_mutable = {$front_matter}: encountered reference to mutable memory in `const`
417+
418418
const_eval_validation_dangling_box_no_provenance = {$front_matter}: encountered a dangling box ({$pointer} has no provenance)
419419
const_eval_validation_dangling_box_out_of_bounds = {$front_matter}: encountered a dangling box (going beyond the bounds of its allocation)
420420
const_eval_validation_dangling_box_use_after_free = {$front_matter}: encountered a dangling box (use-after-free)

compiler/rustc_const_eval/src/const_eval/error.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::interpret::{ErrorHandled, InterpError, InterpErrorInfo, MachineStopTy
1717
/// The CTFE machine has some custom error kinds.
1818
#[derive(Clone, Debug)]
1919
pub enum ConstEvalErrKind {
20-
ConstAccessesStatic,
20+
ConstAccessesMutGlobal,
2121
ModifiedGlobal,
2222
AssertFailure(AssertKind<ConstInt>),
2323
Panic { msg: Symbol, line: u32, col: u32, file: Symbol },
@@ -28,7 +28,7 @@ impl MachineStopType for ConstEvalErrKind {
2828
use crate::fluent_generated::*;
2929
use ConstEvalErrKind::*;
3030
match self {
31-
ConstAccessesStatic => const_eval_const_accesses_static,
31+
ConstAccessesMutGlobal => const_eval_const_accesses_mut_global,
3232
ModifiedGlobal => const_eval_modified_global,
3333
Panic { .. } => const_eval_panic,
3434
AssertFailure(x) => x.diagnostic_message(),
@@ -37,7 +37,7 @@ impl MachineStopType for ConstEvalErrKind {
3737
fn add_args(self: Box<Self>, adder: &mut dyn FnMut(DiagnosticArgName, DiagnosticArgValue)) {
3838
use ConstEvalErrKind::*;
3939
match *self {
40-
ConstAccessesStatic | ModifiedGlobal => {}
40+
ConstAccessesMutGlobal | ModifiedGlobal => {}
4141
AssertFailure(kind) => kind.add_args(adder),
4242
Panic { msg, line, col, file } => {
4343
adder("msg".into(), msg.into_diagnostic_arg());

0 commit comments

Comments
 (0)