Skip to content

Commit 20ffea6

Browse files
committed
Auto merge of rust-lang#100416 - Dylan-DPC:rollup-m344lh1, r=Dylan-DPC
Rollup of 11 pull requests Successful merges: - rust-lang#92744 (Check if enum from foreign crate has any non exhaustive variants when attempting a cast) - rust-lang#99110 (Determine match_has_guard from candidates instead of looking up thir table again) - rust-lang#100184 (Stabilize ptr_const_cast) - rust-lang#100192 ( Remove duplicated temporaries creating during box derefs elaboration) - rust-lang#100232 (Do not consider method call receiver as an argument in AST.) - rust-lang#100287 (linux: Use `pthread_setname_np` instead of `prctl`) - rust-lang#100351 (Use `&mut Diagnostic` instead of `&mut DiagnosticBuilder` unless needed) - rust-lang#100370 (Remove more Clean trait implementations) - rust-lang#100391 (Improve size assertions) - rust-lang#100398 (Improve `-Zhir-stats`) - rust-lang#100403 (Improve error messages when running rustdoc GUI tests) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents aeb5067 + f583bf6 commit 20ffea6

File tree

59 files changed

+952
-472
lines changed

Some content is hidden

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

59 files changed

+952
-472
lines changed

compiler/rustc_arena/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#![feature(rustc_attrs)]
2020
#![cfg_attr(test, feature(test))]
2121
#![feature(strict_provenance)]
22-
#![feature(ptr_const_cast)]
2322

2423
use smallvec::SmallVec;
2524

compiler/rustc_ast/src/ast.rs

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,14 +1338,13 @@ pub enum ExprKind {
13381338
///
13391339
/// The `PathSegment` represents the method name and its generic arguments
13401340
/// (within the angle brackets).
1341-
/// The first element of the vector of an `Expr` is the expression that evaluates
1342-
/// to the object on which the method is being called on (the receiver),
1343-
/// and the remaining elements are the rest of the arguments.
1344-
/// Thus, `x.foo::<Bar, Baz>(a, b, c, d)` is represented as
1345-
/// `ExprKind::MethodCall(PathSegment { foo, [Bar, Baz] }, [x, a, b, c, d])`.
1341+
/// The standalone `Expr` is the receiver expression.
1342+
/// The vector of `Expr` is the arguments.
1343+
/// `x.foo::<Bar, Baz>(a, b, c, d)` is represented as
1344+
/// `ExprKind::MethodCall(PathSegment { foo, [Bar, Baz] }, x, [a, b, c, d])`.
13461345
/// This `Span` is the span of the function, without the dot and receiver
13471346
/// (e.g. `foo(a, b)` in `x.foo(a, b)`
1348-
MethodCall(PathSegment, Vec<P<Expr>>, Span),
1347+
MethodCall(PathSegment, P<Expr>, Vec<P<Expr>>, Span),
13491348
/// A tuple (e.g., `(a, b, c, d)`).
13501349
Tup(Vec<P<Expr>>),
13511350
/// A binary operation (e.g., `a + b`, `a * b`).
@@ -3030,22 +3029,25 @@ pub type ForeignItem = Item<ForeignItemKind>;
30303029
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
30313030
mod size_asserts {
30323031
use super::*;
3032+
use rustc_data_structures::static_assert_size;
30333033
// These are in alphabetical order, which is easy to maintain.
3034-
rustc_data_structures::static_assert_size!(AssocItemKind, 72);
3035-
rustc_data_structures::static_assert_size!(Attribute, 152);
3036-
rustc_data_structures::static_assert_size!(Block, 48);
3037-
rustc_data_structures::static_assert_size!(Expr, 104);
3038-
rustc_data_structures::static_assert_size!(Fn, 192);
3039-
rustc_data_structures::static_assert_size!(ForeignItemKind, 72);
3040-
rustc_data_structures::static_assert_size!(GenericBound, 88);
3041-
rustc_data_structures::static_assert_size!(Generics, 72);
3042-
rustc_data_structures::static_assert_size!(Impl, 200);
3043-
rustc_data_structures::static_assert_size!(Item, 200);
3044-
rustc_data_structures::static_assert_size!(ItemKind, 112);
3045-
rustc_data_structures::static_assert_size!(Lit, 48);
3046-
rustc_data_structures::static_assert_size!(Pat, 120);
3047-
rustc_data_structures::static_assert_size!(Path, 40);
3048-
rustc_data_structures::static_assert_size!(PathSegment, 24);
3049-
rustc_data_structures::static_assert_size!(Stmt, 32);
3050-
rustc_data_structures::static_assert_size!(Ty, 96);
3034+
static_assert_size!(AssocItem, 160);
3035+
static_assert_size!(AssocItemKind, 72);
3036+
static_assert_size!(Attribute, 152);
3037+
static_assert_size!(Block, 48);
3038+
static_assert_size!(Expr, 104);
3039+
static_assert_size!(Fn, 192);
3040+
static_assert_size!(ForeignItem, 160);
3041+
static_assert_size!(ForeignItemKind, 72);
3042+
static_assert_size!(GenericBound, 88);
3043+
static_assert_size!(Generics, 72);
3044+
static_assert_size!(Impl, 200);
3045+
static_assert_size!(Item, 200);
3046+
static_assert_size!(ItemKind, 112);
3047+
static_assert_size!(Lit, 48);
3048+
static_assert_size!(Pat, 120);
3049+
static_assert_size!(Path, 40);
3050+
static_assert_size!(PathSegment, 24);
3051+
static_assert_size!(Stmt, 32);
3052+
static_assert_size!(Ty, 96);
30513053
}

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1302,10 +1302,11 @@ pub fn noop_visit_expr<T: MutVisitor>(
13021302
vis.visit_expr(f);
13031303
visit_exprs(args, vis);
13041304
}
1305-
ExprKind::MethodCall(PathSegment { ident, id, args }, exprs, span) => {
1305+
ExprKind::MethodCall(PathSegment { ident, id, args }, receiver, exprs, span) => {
13061306
vis.visit_ident(ident);
13071307
vis.visit_id(id);
13081308
visit_opt(args, |args| vis.visit_generic_args(args));
1309+
vis.visit_expr(receiver);
13091310
visit_exprs(exprs, vis);
13101311
vis.visit_span(span);
13111312
}

compiler/rustc_ast/src/util/parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,9 @@ pub fn contains_exterior_struct_lit(value: &ast::Expr) -> bool {
396396
contains_exterior_struct_lit(&x)
397397
}
398398

399-
ast::ExprKind::MethodCall(.., ref exprs, _) => {
399+
ast::ExprKind::MethodCall(_, ref receiver, _, _) => {
400400
// X { y: 1 }.bar(...)
401-
contains_exterior_struct_lit(&exprs[0])
401+
contains_exterior_struct_lit(&receiver)
402402
}
403403

404404
_ => false,

compiler/rustc_ast/src/visit.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,8 +813,9 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
813813
visitor.visit_expr(callee_expression);
814814
walk_list!(visitor, visit_expr, arguments);
815815
}
816-
ExprKind::MethodCall(ref segment, ref arguments, _span) => {
816+
ExprKind::MethodCall(ref segment, ref receiver, ref arguments, _span) => {
817817
visitor.visit_path_segment(expression.span, segment);
818+
visitor.visit_expr(receiver);
818819
walk_list!(visitor, visit_expr, arguments);
819820
}
820821
ExprKind::Binary(_, ref left_expression, ref right_expression) => {

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,17 @@ impl<'hir> LoweringContext<'_, 'hir> {
6262
hir::ExprKind::Call(f, self.lower_exprs(args))
6363
}
6464
}
65-
ExprKind::MethodCall(ref seg, ref args, span) => {
65+
ExprKind::MethodCall(ref seg, ref receiver, ref args, span) => {
6666
let hir_seg = self.arena.alloc(self.lower_path_segment(
6767
e.span,
6868
seg,
6969
ParamMode::Optional,
7070
ParenthesizedGenericArgs::Err,
7171
ImplTraitContext::Disallowed(ImplTraitPosition::Path),
7272
));
73-
let args = self.lower_exprs(args);
73+
let args = self.arena.alloc_from_iter(
74+
[&*receiver].into_iter().chain(args.iter()).map(|x| self.lower_expr_mut(x)),
75+
);
7476
hir::ExprKind::MethodCall(hir_seg, args, self.lower_span(span))
7577
}
7678
ExprKind::Binary(binop, ref lhs, ref rhs) => {

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ use rustc_ast::walk_list;
1313
use rustc_ast::*;
1414
use rustc_ast_pretty::pprust::{self, State};
1515
use rustc_data_structures::fx::FxHashMap;
16-
use rustc_errors::{
17-
error_code, pluralize, struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed,
18-
};
16+
use rustc_errors::{error_code, pluralize, struct_span_err, Applicability, Diagnostic};
1917
use rustc_parse::validate_attr;
2018
use rustc_session::lint::builtin::{
2119
DEPRECATED_WHERE_CLAUSE_LOCATION, MISSING_ABI, PATTERNS_IN_FNS_WITHOUT_BODY,
@@ -477,7 +475,7 @@ impl<'a> AstValidator<'a> {
477475
ctx: &str,
478476
msg: &str,
479477
sugg: &str,
480-
help: impl FnOnce(&mut DiagnosticBuilder<'_, ErrorGuaranteed>),
478+
help: impl FnOnce(&mut Diagnostic),
481479
) {
482480
let source_map = self.session.source_map();
483481
let end = source_map.end_point(sp);
@@ -1196,7 +1194,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
11961194
let msg = "free function without a body";
11971195
let ext = sig.header.ext;
11981196

1199-
let f = |e: &mut DiagnosticBuilder<'_, _>| {
1197+
let f = |e: &mut Diagnostic| {
12001198
if let Extern::Implicit(start_span) | Extern::Explicit(_, start_span) = &ext
12011199
{
12021200
let start_suggestion = if let Extern::Explicit(abi, _) = ext {

compiler/rustc_ast_pretty/src/pprust/state/expr.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,13 @@ impl<'a> State<'a> {
193193
self.print_call_post(args)
194194
}
195195

196-
fn print_expr_method_call(&mut self, segment: &ast::PathSegment, args: &[P<ast::Expr>]) {
197-
let base_args = &args[1..];
198-
self.print_expr_maybe_paren(&args[0], parser::PREC_POSTFIX);
196+
fn print_expr_method_call(
197+
&mut self,
198+
segment: &ast::PathSegment,
199+
receiver: &ast::Expr,
200+
base_args: &[P<ast::Expr>],
201+
) {
202+
self.print_expr_maybe_paren(receiver, parser::PREC_POSTFIX);
199203
self.word(".");
200204
self.print_ident(segment.ident);
201205
if let Some(ref args) = segment.args {
@@ -303,8 +307,8 @@ impl<'a> State<'a> {
303307
ast::ExprKind::Call(ref func, ref args) => {
304308
self.print_expr_call(func, &args);
305309
}
306-
ast::ExprKind::MethodCall(ref segment, ref args, _) => {
307-
self.print_expr_method_call(segment, &args);
310+
ast::ExprKind::MethodCall(ref segment, ref receiver, ref args, _) => {
311+
self.print_expr_method_call(segment, &receiver, &args);
308312
}
309313
ast::ExprKind::Binary(op, ref lhs, ref rhs) => {
310314
self.print_expr_binary(op, lhs, rhs);

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
451451

452452
fn suggest_borrow_fn_like(
453453
&self,
454-
err: &mut DiagnosticBuilder<'tcx, ErrorGuaranteed>,
454+
err: &mut Diagnostic,
455455
ty: Ty<'tcx>,
456456
move_sites: &[MoveSite],
457457
value_name: &str,
@@ -526,12 +526,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
526526
true
527527
}
528528

529-
fn suggest_adding_copy_bounds(
530-
&self,
531-
err: &mut DiagnosticBuilder<'tcx, ErrorGuaranteed>,
532-
ty: Ty<'tcx>,
533-
span: Span,
534-
) {
529+
fn suggest_adding_copy_bounds(&self, err: &mut Diagnostic, ty: Ty<'tcx>, span: Span) {
535530
let tcx = self.infcx.tcx;
536531
let generics = tcx.generics_of(self.mir_def_id());
537532

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
783783

784784
fn maybe_suggest_constrain_dyn_trait_impl(
785785
&self,
786-
diag: &mut DiagnosticBuilder<'tcx, ErrorGuaranteed>,
786+
diag: &mut Diagnostic,
787787
f: Region<'tcx>,
788788
o: Region<'tcx>,
789789
category: &ConstraintCategory<'tcx>,

0 commit comments

Comments
 (0)