Skip to content

Commit 05124f1

Browse files
committed
Auto merge of rust-lang#126412 - matthiaskrgr:rollup-91065bw, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#121216 (Always emit `native-static-libs` note, even if it is empty) - rust-lang#122613 (Don't build a broken/untested profiler runtime on mingw targets) - rust-lang#123962 (change method resolution to constrain hidden types instead of rejecting method candidates) - rust-lang#126320 (Avoid ICES after reporting errors on erroneous patterns) - rust-lang#126343 (Remove some msys2 utils) - rust-lang#126351 (std::unix::fs::link using direct linkat call for Solaris.) - rust-lang#126399 (extend the check for LLVM build) Failed merges: - rust-lang#126388 (const-eval: make lint scope computation consistent) r? `@ghost` `@rustbot` modify labels: rollup
2 parents f158600 + 1521dc8 commit 05124f1

File tree

79 files changed

+1184
-321
lines changed

Some content is hidden

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

79 files changed

+1184
-321
lines changed

.github/workflows/ci.yml

-2
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ jobs:
9595
path-type: inherit
9696
install: >
9797
make
98-
dos2unix
99-
diffutils
10098
10199
- name: disable git crlf conversion
102100
run: git config --global core.autocrlf false

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2888,7 +2888,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
28882888
..
28892889
} = explanation
28902890
{
2891-
if let Some(diag) = self.try_report_cannot_return_reference_to_local(
2891+
if let Err(diag) = self.try_report_cannot_return_reference_to_local(
28922892
borrow,
28932893
borrow_span,
28942894
span,
@@ -3075,7 +3075,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
30753075
if let BorrowExplanation::MustBeValidFor { category, span, from_closure: false, .. } =
30763076
explanation
30773077
{
3078-
if let Some(diag) = self.try_report_cannot_return_reference_to_local(
3078+
if let Err(diag) = self.try_report_cannot_return_reference_to_local(
30793079
borrow,
30803080
proper_span,
30813081
span,
@@ -3237,11 +3237,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
32373237
return_span: Span,
32383238
category: ConstraintCategory<'tcx>,
32393239
opt_place_desc: Option<&String>,
3240-
) -> Option<Diag<'tcx>> {
3240+
) -> Result<(), Diag<'tcx>> {
32413241
let return_kind = match category {
32423242
ConstraintCategory::Return(_) => "return",
32433243
ConstraintCategory::Yield => "yield",
3244-
_ => return None,
3244+
_ => return Ok(()),
32453245
};
32463246

32473247
// FIXME use a better heuristic than Spans
@@ -3317,7 +3317,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
33173317
}
33183318
}
33193319

3320-
Some(err)
3320+
Err(err)
33213321
}
33223322

33233323
#[instrument(level = "debug", skip(self))]

compiler/rustc_codegen_ssa/src/back/link.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -1561,17 +1561,13 @@ fn print_native_static_libs(
15611561
match out {
15621562
OutFileName::Real(path) => {
15631563
out.overwrite(&lib_args.join(" "), sess);
1564-
if !lib_args.is_empty() {
1565-
sess.dcx().emit_note(errors::StaticLibraryNativeArtifactsToFile { path });
1566-
}
1564+
sess.dcx().emit_note(errors::StaticLibraryNativeArtifactsToFile { path });
15671565
}
15681566
OutFileName::Stdout => {
1569-
if !lib_args.is_empty() {
1570-
sess.dcx().emit_note(errors::StaticLibraryNativeArtifacts);
1571-
// Prefix for greppability
1572-
// Note: This must not be translated as tools are allowed to depend on this exact string.
1573-
sess.dcx().note(format!("native-static-libs: {}", &lib_args.join(" ")));
1574-
}
1567+
sess.dcx().emit_note(errors::StaticLibraryNativeArtifacts);
1568+
// Prefix for greppability
1569+
// Note: This must not be translated as tools are allowed to depend on this exact string.
1570+
sess.dcx().note(format!("native-static-libs: {}", &lib_args.join(" ")));
15751571
}
15761572
}
15771573
}

compiler/rustc_hir_typeck/src/callee.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
628628
return;
629629
};
630630

631-
let pick = self.confirm_method(
631+
let pick = self.confirm_method_for_diagnostic(
632632
call_expr.span,
633633
callee_expr,
634634
call_expr,

compiler/rustc_hir_typeck/src/demand.rs

+28-29
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc_errors::{Applicability, Diag};
44
use rustc_hir as hir;
55
use rustc_hir::def::Res;
66
use rustc_hir::intravisit::Visitor;
7-
use rustc_infer::infer::{DefineOpaqueTypes, InferOk};
7+
use rustc_infer::infer::DefineOpaqueTypes;
88
use rustc_middle::bug;
99
use rustc_middle::ty::adjustment::AllowTwoPhase;
1010
use rustc_middle::ty::error::{ExpectedFound, TypeError};
@@ -166,7 +166,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
166166
/// Requires that the two types unify, and prints an error message if
167167
/// they don't.
168168
pub fn demand_suptype(&self, sp: Span, expected: Ty<'tcx>, actual: Ty<'tcx>) {
169-
if let Some(e) = self.demand_suptype_diag(sp, expected, actual) {
169+
if let Err(e) = self.demand_suptype_diag(sp, expected, actual) {
170170
e.emit();
171171
}
172172
}
@@ -176,7 +176,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
176176
sp: Span,
177177
expected: Ty<'tcx>,
178178
actual: Ty<'tcx>,
179-
) -> Option<Diag<'tcx>> {
179+
) -> Result<(), Diag<'tcx>> {
180180
self.demand_suptype_with_origin(&self.misc(sp), expected, actual)
181181
}
182182

@@ -186,18 +186,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
186186
cause: &ObligationCause<'tcx>,
187187
expected: Ty<'tcx>,
188188
actual: Ty<'tcx>,
189-
) -> Option<Diag<'tcx>> {
190-
match self.at(cause, self.param_env).sup(DefineOpaqueTypes::Yes, expected, actual) {
191-
Ok(InferOk { obligations, value: () }) => {
192-
self.register_predicates(obligations);
193-
None
194-
}
195-
Err(e) => Some(self.err_ctxt().report_mismatched_types(cause, expected, actual, e)),
196-
}
189+
) -> Result<(), Diag<'tcx>> {
190+
self.at(cause, self.param_env)
191+
.sup(DefineOpaqueTypes::Yes, expected, actual)
192+
.map(|infer_ok| self.register_infer_ok_obligations(infer_ok))
193+
.map_err(|e| self.err_ctxt().report_mismatched_types(cause, expected, actual, e))
197194
}
198195

199196
pub fn demand_eqtype(&self, sp: Span, expected: Ty<'tcx>, actual: Ty<'tcx>) {
200-
if let Some(err) = self.demand_eqtype_diag(sp, expected, actual) {
197+
if let Err(err) = self.demand_eqtype_diag(sp, expected, actual) {
201198
err.emit();
202199
}
203200
}
@@ -207,7 +204,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
207204
sp: Span,
208205
expected: Ty<'tcx>,
209206
actual: Ty<'tcx>,
210-
) -> Option<Diag<'tcx>> {
207+
) -> Result<(), Diag<'tcx>> {
211208
self.demand_eqtype_with_origin(&self.misc(sp), expected, actual)
212209
}
213210

@@ -216,14 +213,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
216213
cause: &ObligationCause<'tcx>,
217214
expected: Ty<'tcx>,
218215
actual: Ty<'tcx>,
219-
) -> Option<Diag<'tcx>> {
220-
match self.at(cause, self.param_env).eq(DefineOpaqueTypes::Yes, expected, actual) {
221-
Ok(InferOk { obligations, value: () }) => {
222-
self.register_predicates(obligations);
223-
None
224-
}
225-
Err(e) => Some(self.err_ctxt().report_mismatched_types(cause, expected, actual, e)),
226-
}
216+
) -> Result<(), Diag<'tcx>> {
217+
self.at(cause, self.param_env)
218+
.eq(DefineOpaqueTypes::Yes, expected, actual)
219+
.map(|infer_ok| self.register_infer_ok_obligations(infer_ok))
220+
.map_err(|e| self.err_ctxt().report_mismatched_types(cause, expected, actual, e))
227221
}
228222

229223
pub fn demand_coerce(
@@ -234,12 +228,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
234228
expected_ty_expr: Option<&'tcx hir::Expr<'tcx>>,
235229
allow_two_phase: AllowTwoPhase,
236230
) -> Ty<'tcx> {
237-
let (ty, err) =
238-
self.demand_coerce_diag(expr, checked_ty, expected, expected_ty_expr, allow_two_phase);
239-
if let Some(err) = err {
240-
err.emit();
231+
match self.demand_coerce_diag(expr, checked_ty, expected, expected_ty_expr, allow_two_phase)
232+
{
233+
Ok(ty) => ty,
234+
Err(err) => {
235+
err.emit();
236+
// Return the original type instead of an error type here, otherwise the type of `x` in
237+
// `let x: u32 = ();` will be a type error, causing all subsequent usages of `x` to not
238+
// report errors, even though `x` is definitely `u32`.
239+
expected
240+
}
241241
}
242-
ty
243242
}
244243

245244
/// Checks that the type of `expr` can be coerced to `expected`.
@@ -254,11 +253,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
254253
expected: Ty<'tcx>,
255254
mut expected_ty_expr: Option<&'tcx hir::Expr<'tcx>>,
256255
allow_two_phase: AllowTwoPhase,
257-
) -> (Ty<'tcx>, Option<Diag<'tcx>>) {
256+
) -> Result<Ty<'tcx>, Diag<'tcx>> {
258257
let expected = self.resolve_vars_with_obligations(expected);
259258

260259
let e = match self.coerce(expr, checked_ty, expected, allow_two_phase, None) {
261-
Ok(ty) => return (ty, None),
260+
Ok(ty) => return Ok(ty),
262261
Err(e) => e,
263262
};
264263

@@ -275,7 +274,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
275274

276275
self.emit_coerce_suggestions(&mut err, expr, expr_ty, expected, expected_ty_expr, Some(e));
277276

278-
(expected, Some(err))
277+
Err(err)
279278
}
280279

281280
/// Notes the point at which a variable is constrained to some type incompatible

compiler/rustc_hir_typeck/src/expr.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
8787
ty = adj_ty;
8888
}
8989

90-
if let Some(mut err) = self.demand_suptype_diag(expr.span, expected_ty, ty) {
90+
if let Err(mut err) = self.demand_suptype_diag(expr.span, expected_ty, ty) {
9191
let _ = self.emit_type_mismatch_suggestions(
9292
&mut err,
9393
expr.peel_drop_temps(),
@@ -1132,7 +1132,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11321132
// say that the user intended to write `lhs == rhs` instead of `lhs = rhs`.
11331133
// The likely cause of this is `if foo = bar { .. }`.
11341134
let actual_ty = self.tcx.types.unit;
1135-
let mut err = self.demand_suptype_diag(expr.span, expected_ty, actual_ty).unwrap();
1135+
let mut err = self.demand_suptype_diag(expr.span, expected_ty, actual_ty).unwrap_err();
11361136
let lhs_ty = self.check_expr(lhs);
11371137
let rhs_ty = self.check_expr(rhs);
11381138
let refs_can_coerce = |lhs: Ty<'tcx>, rhs: Ty<'tcx>| {
@@ -1236,7 +1236,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12361236
// This is (basically) inlined `check_expr_coercible_to_type`, but we want
12371237
// to suggest an additional fixup here in `suggest_deref_binop`.
12381238
let rhs_ty = self.check_expr_with_hint(rhs, lhs_ty);
1239-
if let (_, Some(mut diag)) =
1239+
if let Err(mut diag) =
12401240
self.demand_coerce_diag(rhs, rhs_ty, lhs_ty, Some(lhs), AllowTwoPhase::No)
12411241
{
12421242
suggest_deref_binop(&mut diag, rhs_ty);
@@ -1738,10 +1738,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
17381738
// Make sure to give a type to the field even if there's
17391739
// an error, so we can continue type-checking.
17401740
let ty = self.check_expr_with_hint(field.expr, field_type);
1741-
let (_, diag) =
1742-
self.demand_coerce_diag(field.expr, ty, field_type, None, AllowTwoPhase::No);
1741+
let diag = self.demand_coerce_diag(field.expr, ty, field_type, None, AllowTwoPhase::No);
17431742

1744-
if let Some(diag) = diag {
1743+
if let Err(diag) = diag {
17451744
if idx == hir_fields.len() - 1 {
17461745
if remaining_fields.is_empty() {
17471746
self.suggest_fru_from_range_and_emit(field, variant, args, diag);

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14181418
let impl_ty = self.normalize(span, tcx.type_of(impl_def_id).instantiate(tcx, args));
14191419
let self_ty = self.normalize(span, self_ty);
14201420
match self.at(&self.misc(span), self.param_env).eq(
1421-
DefineOpaqueTypes::No,
1421+
DefineOpaqueTypes::Yes,
14221422
impl_ty,
14231423
self_ty,
14241424
) {

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1578,7 +1578,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15781578
// type of the place it is referencing, and not some
15791579
// supertype thereof.
15801580
let init_ty = self.check_expr_with_needs(init, Needs::maybe_mut_place(m));
1581-
if let Some(mut diag) = self.demand_eqtype_diag(init.span, local_ty, init_ty) {
1581+
if let Err(mut diag) = self.demand_eqtype_diag(init.span, local_ty, init_ty) {
15821582
self.emit_type_mismatch_suggestions(
15831583
&mut diag,
15841584
init.peel_drop_temps(),
@@ -1624,7 +1624,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16241624
let previous_diverges = self.diverges.get();
16251625
let else_ty = self.check_block_with_expected(blk, NoExpectation);
16261626
let cause = self.cause(blk.span, ObligationCauseCode::LetElse);
1627-
if let Some(err) = self.demand_eqtype_with_origin(&cause, self.tcx.types.never, else_ty)
1627+
if let Err(err) = self.demand_eqtype_with_origin(&cause, self.tcx.types.never, else_ty)
16281628
{
16291629
err.emit();
16301630
}

compiler/rustc_hir_typeck/src/method/confirm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
497497
args,
498498
})),
499499
);
500-
match self.at(&cause, self.param_env).sup(DefineOpaqueTypes::No, method_self_ty, self_ty) {
500+
match self.at(&cause, self.param_env).sup(DefineOpaqueTypes::Yes, method_self_ty, self_ty) {
501501
Ok(InferOk { obligations, value: () }) => {
502502
self.register_predicates(obligations);
503503
}

0 commit comments

Comments
 (0)