Skip to content

Commit 989b8f7

Browse files
committed
Auto merge of rust-lang#3783 - rust-lang:rustup-2024-08-02, r=RalfJung
Automatic Rustup
2 parents 9de5630 + fc260e1 commit 989b8f7

File tree

1,468 files changed

+22044
-12183
lines changed

Some content is hidden

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

1,468 files changed

+22044
-12183
lines changed

.git-blame-ignore-revs

+2
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ b2d2184edea578109a48ec3d8decbee5948e8f35
2323
# test directives migration
2424
6e48b96692d63a79a14563f27fe5185f122434f8
2525
ec2cc761bc7067712ecc7734502f703fe3b024c8
26+
# format use declarations
27+
84ac80f1921afc243d71fd0caaa4f2838c294102

.gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
[submodule "src/llvm-project"]
3434
path = src/llvm-project
3535
url = https://github.com/rust-lang/llvm-project.git
36-
branch = rustc/18.1-2024-05-19
36+
branch = rustc/19.1-2024-07-30
3737
shallow = true
3838
[submodule "src/doc/embedded-book"]
3939
path = src/doc/embedded-book

compiler/rustc_abi/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ impl Size {
516516
/// Truncates `value` to `self` bits and then sign-extends it to 128 bits
517517
/// (i.e., if it is negative, fill with 1's on the left).
518518
#[inline]
519-
pub fn sign_extend(self, value: u128) -> u128 {
519+
pub fn sign_extend(self, value: u128) -> i128 {
520520
let size = self.bits();
521521
if size == 0 {
522522
// Truncated until nothing is left.
@@ -526,7 +526,7 @@ impl Size {
526526
let shift = 128 - size;
527527
// Shift the unsigned value to the left, then shift back to the right as signed
528528
// (essentially fills with sign bit on the left).
529-
(((value << shift) as i128) >> shift) as u128
529+
((value << shift) as i128) >> shift
530530
}
531531

532532
/// Truncates `value` to `self` bits.
@@ -544,7 +544,7 @@ impl Size {
544544

545545
#[inline]
546546
pub fn signed_int_min(&self) -> i128 {
547-
self.sign_extend(1_u128 << (self.bits() - 1)) as i128
547+
self.sign_extend(1_u128 << (self.bits() - 1))
548548
}
549549

550550
#[inline]

compiler/rustc_ast_lowering/src/delegation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
//! HIR ty lowering.
3434
//!
3535
//! Similarly generics, predicates and header are set to the "default" values.
36-
//! In case of discrepancy with callee function the `NotSupportedDelegation` error will
36+
//! In case of discrepancy with callee function the `UnsupportedDelegation` error will
3737
//! also be emitted during HIR ty lowering.
3838
3939
use std::iter;

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+24-68
Original file line numberDiff line numberDiff line change
@@ -563,11 +563,11 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
563563
} = move_spans
564564
&& can_suggest_clone
565565
{
566-
self.suggest_cloning(err, ty, expr, None, Some(move_spans));
566+
self.suggest_cloning(err, ty, expr, Some(move_spans));
567567
} else if self.suggest_hoisting_call_outside_loop(err, expr) && can_suggest_clone {
568568
// The place where the type moves would be misleading to suggest clone.
569569
// #121466
570-
self.suggest_cloning(err, ty, expr, None, Some(move_spans));
570+
self.suggest_cloning(err, ty, expr, Some(move_spans));
571571
}
572572
}
573573

@@ -1229,8 +1229,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
12291229
&self,
12301230
err: &mut Diag<'_>,
12311231
ty: Ty<'tcx>,
1232-
mut expr: &'tcx hir::Expr<'tcx>,
1233-
mut other_expr: Option<&'tcx hir::Expr<'tcx>>,
1232+
expr: &'tcx hir::Expr<'tcx>,
12341233
use_spans: Option<UseSpans<'tcx>>,
12351234
) {
12361235
if let hir::ExprKind::Struct(_, _, Some(_)) = expr.kind {
@@ -1242,66 +1241,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
12421241
return;
12431242
}
12441243

1245-
if let Some(some_other_expr) = other_expr
1246-
&& let Some(parent_binop) =
1247-
self.infcx.tcx.hir().parent_iter(expr.hir_id).find_map(|n| {
1248-
if let (hir_id, hir::Node::Expr(e)) = n
1249-
&& let hir::ExprKind::AssignOp(_binop, target, _arg) = e.kind
1250-
&& target.hir_id == expr.hir_id
1251-
{
1252-
Some(hir_id)
1253-
} else {
1254-
None
1255-
}
1256-
})
1257-
&& let Some(other_parent_binop) =
1258-
self.infcx.tcx.hir().parent_iter(some_other_expr.hir_id).find_map(|n| {
1259-
if let (hir_id, hir::Node::Expr(expr)) = n
1260-
&& let hir::ExprKind::AssignOp(..) = expr.kind
1261-
{
1262-
Some(hir_id)
1263-
} else {
1264-
None
1265-
}
1266-
})
1267-
&& parent_binop == other_parent_binop
1268-
{
1269-
// Explicitly look for `expr += other_expr;` and avoid suggesting
1270-
// `expr.clone() += other_expr;`, instead suggesting `expr += other_expr.clone();`.
1271-
other_expr = Some(expr);
1272-
expr = some_other_expr;
1273-
}
1274-
'outer: {
1275-
if let ty::Ref(..) = ty.kind() {
1276-
// We check for either `let binding = foo(expr, other_expr);` or
1277-
// `foo(expr, other_expr);` and if so we don't suggest an incorrect
1278-
// `foo(expr, other_expr).clone()`
1279-
if let Some(other_expr) = other_expr
1280-
&& let Some(parent_let) =
1281-
self.infcx.tcx.hir().parent_iter(expr.hir_id).find_map(|n| {
1282-
if let (hir_id, hir::Node::LetStmt(_) | hir::Node::Stmt(_)) = n {
1283-
Some(hir_id)
1284-
} else {
1285-
None
1286-
}
1287-
})
1288-
&& let Some(other_parent_let) =
1289-
self.infcx.tcx.hir().parent_iter(other_expr.hir_id).find_map(|n| {
1290-
if let (hir_id, hir::Node::LetStmt(_) | hir::Node::Stmt(_)) = n {
1291-
Some(hir_id)
1292-
} else {
1293-
None
1294-
}
1295-
})
1296-
&& parent_let == other_parent_let
1297-
{
1298-
// Explicitly check that we don't have `foo(&*expr, other_expr)`, as cloning the
1299-
// result of `foo(...)` won't help.
1300-
break 'outer;
1301-
}
1302-
}
1303-
}
1304-
let ty = ty.peel_refs();
13051244
if self.implements_clone(ty) {
13061245
self.suggest_cloning_inner(err, ty, expr);
13071246
} else if let ty::Adt(def, args) = ty.kind()
@@ -1573,10 +1512,27 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
15731512
);
15741513
self.suggest_copy_for_type_in_cloned_ref(&mut err, place);
15751514
let typeck_results = self.infcx.tcx.typeck(self.mir_def_id());
1576-
if let Some(expr) = self.find_expr(borrow_span)
1577-
&& let Some(ty) = typeck_results.node_type_opt(expr.hir_id)
1578-
{
1579-
self.suggest_cloning(&mut err, ty, expr, self.find_expr(span), Some(move_spans));
1515+
if let Some(expr) = self.find_expr(borrow_span) {
1516+
// This is a borrow span, so we want to suggest cloning the referent.
1517+
if let hir::ExprKind::AddrOf(_, _, borrowed_expr) = expr.kind
1518+
&& let Some(ty) = typeck_results.expr_ty_opt(borrowed_expr)
1519+
{
1520+
self.suggest_cloning(&mut err, ty, borrowed_expr, Some(move_spans));
1521+
} else if typeck_results.expr_adjustments(expr).first().is_some_and(|adj| {
1522+
matches!(
1523+
adj.kind,
1524+
ty::adjustment::Adjust::Borrow(ty::adjustment::AutoBorrow::Ref(
1525+
_,
1526+
ty::adjustment::AutoBorrowMutability::Not
1527+
| ty::adjustment::AutoBorrowMutability::Mut {
1528+
allow_two_phase_borrow: ty::adjustment::AllowTwoPhase::No
1529+
}
1530+
))
1531+
)
1532+
}) && let Some(ty) = typeck_results.expr_ty_opt(expr)
1533+
{
1534+
self.suggest_cloning(&mut err, ty, expr, Some(move_spans));
1535+
}
15801536
}
15811537
self.buffer_error(err);
15821538
}

compiler/rustc_borrowck/src/diagnostics/move_errors.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -564,9 +564,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
564564

565565
fn add_move_hints(&self, error: GroupedMoveError<'tcx>, err: &mut Diag<'_>, span: Span) {
566566
match error {
567-
GroupedMoveError::MovesFromPlace {
568-
mut binds_to, move_from, span: other_span, ..
569-
} => {
567+
GroupedMoveError::MovesFromPlace { mut binds_to, move_from, .. } => {
570568
self.add_borrow_suggestions(err, span);
571569
if binds_to.is_empty() {
572570
let place_ty = move_from.ty(self.body, self.infcx.tcx).ty;
@@ -576,7 +574,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
576574
};
577575

578576
if let Some(expr) = self.find_expr(span) {
579-
self.suggest_cloning(err, place_ty, expr, self.find_expr(other_span), None);
577+
self.suggest_cloning(err, place_ty, expr, None);
580578
}
581579

582580
err.subdiagnostic(crate::session_diagnostics::TypeNoCopy::Label {
@@ -608,13 +606,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
608606
};
609607

610608
if let Some(expr) = self.find_expr(use_span) {
611-
self.suggest_cloning(
612-
err,
613-
place_ty,
614-
expr,
615-
self.find_expr(span),
616-
Some(use_spans),
617-
);
609+
self.suggest_cloning(err, place_ty, expr, Some(use_spans));
618610
}
619611

620612
err.subdiagnostic(crate::session_diagnostics::TypeNoCopy::Label {
@@ -739,7 +731,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
739731
let place_desc = &format!("`{}`", self.local_names[*local].unwrap());
740732

741733
if let Some(expr) = self.find_expr(binding_span) {
742-
self.suggest_cloning(err, bind_to.ty, expr, None, None);
734+
self.suggest_cloning(err, bind_to.ty, expr, None);
743735
}
744736

745737
err.subdiagnostic(crate::session_diagnostics::TypeNoCopy::Label {

compiler/rustc_builtin_macros/messages.ftl

-3
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ builtin_macros_derive_path_args_list = traits in `#[derive(...)]` don't accept a
115115
builtin_macros_derive_path_args_value = traits in `#[derive(...)]` don't accept values
116116
.suggestion = remove the value
117117
118-
builtin_macros_derive_unsafe_path = traits in `#[derive(...)]` don't accept `unsafe(...)`
119-
.suggestion = remove the `unsafe(...)`
120-
121118
builtin_macros_env_not_defined = environment variable `{$var}` not defined at compile time
122119
.cargo = Cargo sets build script variables at run time. Use `std::env::var({$var_expr})` instead
123120
.custom = use `std::env::var({$var_expr})` to read the variable at run time

compiler/rustc_builtin_macros/src/cfg.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use rustc_ast::token;
66
use rustc_ast::tokenstream::TokenStream;
77
use rustc_errors::PResult;
88
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult};
9+
use rustc_parse::parser::attr::AllowLeadingUnsafe;
910
use rustc_span::Span;
1011
use {rustc_ast as ast, rustc_attr as attr};
1112

@@ -42,7 +43,7 @@ fn parse_cfg<'a>(cx: &ExtCtxt<'a>, span: Span, tts: TokenStream) -> PResult<'a,
4243
return Err(cx.dcx().create_err(errors::RequiresCfgPattern { span }));
4344
}
4445

45-
let cfg = p.parse_meta_item()?;
46+
let cfg = p.parse_meta_item(AllowLeadingUnsafe::Yes)?;
4647

4748
let _ = p.eat(&token::Comma);
4849

compiler/rustc_builtin_macros/src/cfg_accessible.rs

+2
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ impl MultiItemModifier for Expander {
4747
) -> ExpandResult<Vec<Annotatable>, Annotatable> {
4848
let template = AttributeTemplate { list: Some("path"), ..Default::default() };
4949
validate_attr::check_builtin_meta_item(
50+
&ecx.ecfg.features,
5051
&ecx.sess.psess,
5152
meta_item,
5253
ast::AttrStyle::Outer,
5354
sym::cfg_accessible,
5455
template,
56+
true,
5557
);
5658

5759
let Some(path) = validate_input(ecx, meta_item) else {

compiler/rustc_builtin_macros/src/derive.rs

+3-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use rustc_ast as ast;
2-
use rustc_ast::{GenericParamKind, ItemKind, MetaItemKind, NestedMetaItem, Safety, StmtKind};
2+
use rustc_ast::{GenericParamKind, ItemKind, MetaItemKind, NestedMetaItem, StmtKind};
33
use rustc_expand::base::{
44
Annotatable, DeriveResolution, ExpandResult, ExtCtxt, Indeterminate, MultiItemModifier,
55
};
@@ -38,11 +38,13 @@ impl MultiItemModifier for Expander {
3838
let template =
3939
AttributeTemplate { list: Some("Trait1, Trait2, ..."), ..Default::default() };
4040
validate_attr::check_builtin_meta_item(
41+
features,
4142
&sess.psess,
4243
meta_item,
4344
ast::AttrStyle::Outer,
4445
sym::derive,
4546
template,
47+
true,
4648
);
4749

4850
let mut resolutions = match &meta_item.kind {
@@ -60,7 +62,6 @@ impl MultiItemModifier for Expander {
6062
// Reject `#[derive(Debug = "value", Debug(abc))]`, but recover the
6163
// paths.
6264
report_path_args(sess, meta);
63-
report_unsafe_args(sess, meta);
6465
meta.path.clone()
6566
})
6667
.map(|path| DeriveResolution {
@@ -160,13 +161,3 @@ fn report_path_args(sess: &Session, meta: &ast::MetaItem) {
160161
}
161162
}
162163
}
163-
164-
fn report_unsafe_args(sess: &Session, meta: &ast::MetaItem) {
165-
match meta.unsafety {
166-
Safety::Unsafe(span) => {
167-
sess.dcx().emit_err(errors::DeriveUnsafePath { span });
168-
}
169-
Safety::Default => {}
170-
Safety::Safe(_) => unreachable!(),
171-
}
172-
}

0 commit comments

Comments
 (0)