Skip to content

Commit d7dcadc

Browse files
committed
Auto merge of #112817 - compiler-errors:rollup-0eqomra, r=compiler-errors
Rollup of 8 pull requests Successful merges: - #112232 (Better error for non const `PartialEq` call generated by `match`) - #112499 (Fix python linting errors) - #112596 (Suggest correct signature on missing fn returning RPITIT/AFIT) - #112606 (Alter `Display` for `Ipv6Addr` for IPv4-compatible addresses) - #112781 (Don't consider TAIT normalizable to hidden ty if it would result in impossible item bounds) - #112787 (Add gha problem matcher) - #112799 (Clean up "doc(hidden)" check) - #112803 (Format the examples directory of cg_clif) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 14803bd + 0ca3252 commit d7dcadc

File tree

75 files changed

+462
-190
lines changed

Some content is hidden

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

75 files changed

+462
-190
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_infer::traits::ObligationCause;
1414
use rustc_middle::hir::nested_filter::OnlyBodies;
1515
use rustc_middle::mir::tcx::PlaceTy;
1616
use rustc_middle::mir::{
17-
self, AggregateKind, BindingForm, BorrowKind, ClearCrossCrate, ConstraintCategory,
17+
self, AggregateKind, BindingForm, BorrowKind, CallSource, ClearCrossCrate, ConstraintCategory,
1818
FakeReadCause, LocalDecl, LocalInfo, LocalKind, Location, Operand, Place, PlaceRef,
1919
ProjectionElem, Rvalue, Statement, StatementKind, Terminator, TerminatorKind, VarBindingForm,
2020
};
@@ -2579,7 +2579,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
25792579
fn explain_deref_coercion(&mut self, loan: &BorrowData<'tcx>, err: &mut Diagnostic) {
25802580
let tcx = self.infcx.tcx;
25812581
if let (
2582-
Some(Terminator { kind: TerminatorKind::Call { from_hir_call: false, .. }, .. }),
2582+
Some(Terminator {
2583+
kind: TerminatorKind::Call { call_source: CallSource::OverloadedOperator, .. },
2584+
..
2585+
}),
25832586
Some((method_did, method_substs)),
25842587
) = (
25852588
&self.body[loan.reserve_location.block].terminator,

compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use rustc_hir::intravisit::Visitor;
66
use rustc_index::IndexSlice;
77
use rustc_infer::infer::NllRegionVariableOrigin;
88
use rustc_middle::mir::{
9-
Body, CastKind, ConstraintCategory, FakeReadCause, Local, LocalInfo, Location, Operand, Place,
10-
Rvalue, Statement, StatementKind, TerminatorKind,
9+
Body, CallSource, CastKind, ConstraintCategory, FakeReadCause, Local, LocalInfo, Location,
10+
Operand, Place, Rvalue, Statement, StatementKind, TerminatorKind,
1111
};
1212
use rustc_middle::ty::adjustment::PointerCast;
1313
use rustc_middle::ty::{self, RegionVid, TyCtxt};
@@ -494,7 +494,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
494494
} else if self.was_captured_by_trait_object(borrow) {
495495
LaterUseKind::TraitCapture
496496
} else if location.statement_index == block.statements.len() {
497-
if let TerminatorKind::Call { func, from_hir_call: true, .. } =
497+
if let TerminatorKind::Call { func, call_source: CallSource::Normal, .. } =
498498
&block.terminator().kind
499499
{
500500
// Just point to the function, to reduce the chance of overlapping spans.

compiler/rustc_borrowck/src/diagnostics/mod.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ use rustc_index::IndexSlice;
1313
use rustc_infer::infer::LateBoundRegionConversionTime;
1414
use rustc_middle::mir::tcx::PlaceTy;
1515
use rustc_middle::mir::{
16-
AggregateKind, Constant, FakeReadCause, Local, LocalInfo, LocalKind, Location, Operand, Place,
17-
PlaceRef, ProjectionElem, Rvalue, Statement, StatementKind, Terminator, TerminatorKind,
16+
AggregateKind, CallSource, Constant, FakeReadCause, Local, LocalInfo, LocalKind, Location,
17+
Operand, Place, PlaceRef, ProjectionElem, Rvalue, Statement, StatementKind, Terminator,
18+
TerminatorKind,
1819
};
1920
use rustc_middle::ty::print::Print;
2021
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
@@ -414,7 +415,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
414415
if !is_terminator {
415416
continue;
416417
} else if let Some(Terminator {
417-
kind: TerminatorKind::Call { func, from_hir_call: false, .. },
418+
kind:
419+
TerminatorKind::Call {
420+
func,
421+
call_source: CallSource::OverloadedOperator,
422+
..
423+
},
418424
..
419425
}) = &bbd.terminator
420426
{
@@ -839,7 +845,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
839845
debug!("move_spans: target_temp = {:?}", target_temp);
840846

841847
if let Some(Terminator {
842-
kind: TerminatorKind::Call { fn_span, from_hir_call, .. }, ..
848+
kind: TerminatorKind::Call { fn_span, call_source, .. }, ..
843849
}) = &self.body[location.block].terminator
844850
{
845851
let Some((method_did, method_substs)) =
@@ -859,7 +865,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
859865
method_did,
860866
method_substs,
861867
*fn_span,
862-
*from_hir_call,
868+
call_source.from_hir_call(),
863869
Some(self.infcx.tcx.fn_arg_names(method_did)[0]),
864870
);
865871

compiler/rustc_borrowck/src/invalidation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
128128
destination,
129129
target: _,
130130
unwind: _,
131-
from_hir_call: _,
131+
call_source: _,
132132
fn_span: _,
133133
} => {
134134
self.consume_operand(location, func);

compiler/rustc_borrowck/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ impl<'cx, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx, R> for MirBorro
710710
destination,
711711
target: _,
712712
unwind: _,
713-
from_hir_call: _,
713+
call_source: _,
714714
fn_span: _,
715715
} => {
716716
self.consume_operand(loc, (func, span), flow_state);

compiler/rustc_borrowck/src/type_check/mod.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
10651065
)?;
10661066

10671067
ocx.infcx.add_item_bounds_for_hidden_type(
1068-
opaque_type_key,
1068+
opaque_type_key.def_id.to_def_id(),
1069+
opaque_type_key.substs,
10691070
cause,
10701071
param_env,
10711072
hidden_ty.ty,
@@ -1370,7 +1371,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
13701371
}
13711372
// FIXME: check the values
13721373
}
1373-
TerminatorKind::Call { func, args, destination, from_hir_call, target, .. } => {
1374+
TerminatorKind::Call { func, args, destination, call_source, target, .. } => {
13741375
self.check_operand(func, term_location);
13751376
for arg in args {
13761377
self.check_operand(arg, term_location);
@@ -1446,7 +1447,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
14461447
.add_element(region_vid, term_location);
14471448
}
14481449

1449-
self.check_call_inputs(body, term, &sig, args, term_location, *from_hir_call);
1450+
self.check_call_inputs(body, term, &sig, args, term_location, *call_source);
14501451
}
14511452
TerminatorKind::Assert { cond, msg, .. } => {
14521453
self.check_operand(cond, term_location);
@@ -1573,7 +1574,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
15731574
sig: &ty::FnSig<'tcx>,
15741575
args: &[Operand<'tcx>],
15751576
term_location: Location,
1576-
from_hir_call: bool,
1577+
call_source: CallSource,
15771578
) {
15781579
debug!("check_call_inputs({:?}, {:?})", sig, args);
15791580
if args.len() < sig.inputs().len() || (args.len() > sig.inputs().len() && !sig.c_variadic) {
@@ -1591,7 +1592,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
15911592
let op_arg_ty = op_arg.ty(body, self.tcx());
15921593

15931594
let op_arg_ty = self.normalize(op_arg_ty, term_location);
1594-
let category = if from_hir_call {
1595+
let category = if call_source.from_hir_call() {
15951596
ConstraintCategory::CallArgument(self.infcx.tcx.erase_regions(func_ty))
15961597
} else {
15971598
ConstraintCategory::Boring

compiler/rustc_codegen_cranelift/src/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
421421
target,
422422
fn_span,
423423
unwind: _,
424-
from_hir_call: _,
424+
call_source: _,
425425
} => {
426426
fx.tcx.prof.generic_activity("codegen call").run(|| {
427427
crate::abi::codegen_terminator_call(

compiler/rustc_codegen_gcc/tools/generate_intrinsics.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import re
44
import sys
55
import subprocess
6-
from os import walk
76

87

98
def run_command(command, cwd=None):
@@ -180,7 +179,7 @@ def update_intrinsics(llvm_path, llvmint, llvmint2):
180179
intrinsics[arch].sort(key=lambda x: (x[0], x[2]))
181180
out.write(' // {}\n'.format(arch))
182181
for entry in intrinsics[arch]:
183-
if entry[2] == True: # if it is a duplicate
182+
if entry[2] is True: # if it is a duplicate
184183
out.write(' // [DUPLICATE]: "{}" => "{}",\n'.format(entry[0], entry[1]))
185184
elif "_round_mask" in entry[1]:
186185
out.write(' // [INVALID CONVERSION]: "{}" => "{}",\n'.format(entry[0], entry[1]))

compiler/rustc_codegen_ssa/src/mir/block.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
12801280
destination,
12811281
target,
12821282
unwind,
1283-
from_hir_call: _,
1283+
call_source: _,
12841284
fn_span,
12851285
} => self.codegen_call_terminator(
12861286
helper,

compiler/rustc_const_eval/messages.ftl

+3
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ const_eval_long_running =
210210
.label = the const evaluator is currently interpreting this expression
211211
.help = the constant being evaluated
212212
213+
const_eval_match_eq_non_const = cannot match on `{$ty}` in {const_eval_const_context}s
214+
.note = `{$ty}` cannot be compared in compile-time, and therefore cannot be used in `match`es
215+
213216
const_eval_max_num_nodes_in_const = maximum number of nodes exceeded in constant {$global_const_id}
214217
215218
const_eval_memory_access_test = memory access failed

compiler/rustc_const_eval/src/errors.rs

+12
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,18 @@ pub struct RawBytesNote {
271271
pub bytes: String,
272272
}
273273

274+
// FIXME(fee1-dead) do not use stringly typed `ConstContext`
275+
276+
#[derive(Diagnostic)]
277+
#[diag(const_eval_match_eq_non_const, code = "E0015")]
278+
#[note]
279+
pub struct NonConstMatchEq<'tcx> {
280+
#[primary_span]
281+
pub span: Span,
282+
pub ty: Ty<'tcx>,
283+
pub kind: ConstContext,
284+
}
285+
274286
#[derive(Diagnostic)]
275287
#[diag(const_eval_for_loop_into_iter_non_const, code = "E0015")]
276288
pub struct NonConstForLoopIntoIter<'tcx> {

compiler/rustc_const_eval/src/interpret/terminator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
6262
destination,
6363
target,
6464
unwind,
65-
from_hir_call: _,
65+
call_source: _,
6666
fn_span: _,
6767
} => {
6868
let old_stack = self.frame_idx();

compiler/rustc_const_eval/src/transform/check_consts/check.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
702702
self.super_terminator(terminator, location);
703703

704704
match &terminator.kind {
705-
TerminatorKind::Call { func, args, fn_span, from_hir_call, .. } => {
705+
TerminatorKind::Call { func, args, fn_span, call_source, .. } => {
706706
let ConstCx { tcx, body, param_env, .. } = *self.ccx;
707707
let caller = self.def_id();
708708

@@ -755,7 +755,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
755755
callee,
756756
substs,
757757
span: *fn_span,
758-
from_hir_call: *from_hir_call,
758+
call_source: *call_source,
759759
feature: Some(sym::const_trait_impl),
760760
});
761761
return;
@@ -797,7 +797,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
797797
callee,
798798
substs,
799799
span: *fn_span,
800-
from_hir_call: *from_hir_call,
800+
call_source: *call_source,
801801
feature: None,
802802
});
803803

@@ -823,7 +823,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
823823
callee,
824824
substs,
825825
span: *fn_span,
826-
from_hir_call: *from_hir_call,
826+
call_source: *call_source,
827827
feature: None,
828828
});
829829
return;
@@ -866,7 +866,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
866866
callee,
867867
substs,
868868
span: *fn_span,
869-
from_hir_call: *from_hir_call,
869+
call_source: *call_source,
870870
feature: None,
871871
});
872872
return;
@@ -926,7 +926,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
926926
callee,
927927
substs,
928928
span: *fn_span,
929-
from_hir_call: *from_hir_call,
929+
call_source: *call_source,
930930
feature: None,
931931
});
932932
return;

0 commit comments

Comments
 (0)