Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 10 pull requests #126458

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4174600
place explicit lifetime bound after generic param
bvanjoi May 8, 2024
48d3425
Remove some msys2 utils
ChrisDenton Jun 12, 2024
c81ffab
std::unix::fs::link using direct linkat call for Solaris and macOs.
devnexen Jun 12, 2024
1243213
Remove some unnecessary crate dependencies.
nnethercote Jun 13, 2024
2733b8a
Avoid follow-up errors on erroneous patterns
oli-obk Jun 11, 2024
a621701
Replace some `Option<Diag>` with `Result<(), Diag>`
oli-obk Jun 12, 2024
ece3e3e
Replace some `Option<Diag>` with `Result<(), Diag>`
oli-obk Jun 12, 2024
e8d6170
Replace some `Option<Diag>` with `Result<(), Diag>`
oli-obk Jun 12, 2024
7566307
Replace a `bool` with a `Result<(), ErrorGuaranteed>`
oli-obk Jun 12, 2024
b28221e
Use diagnostic method for diagnostics
oli-obk Apr 15, 2024
c75f728
Add some tests
oli-obk Apr 15, 2024
9cf60ee
Method resolution constrains hidden types instead of rejecting method…
oli-obk Apr 15, 2024
9314831
Implement `CompletedProcess::assert_stdout_contains` and improve erro…
GuillaumeGomez Jun 13, 2024
96f9fe5
Migrate `run-make/allow-non-lint-warnings-cmdline` to `rmake.rs`
GuillaumeGomez Jun 13, 2024
eca8d20
Make `run-make/allow-non-lint-warnings-cmdline` into a ui test
GuillaumeGomez Jun 13, 2024
9bff230
Allow to bless diff tests
GuillaumeGomez Jun 11, 2024
be7b587
Migrate `run-make/const_fn_mir` to `rmake.rs`
GuillaumeGomez Jun 11, 2024
5f4111f
Update run-make-support/diff to new `fs_wrapper` API
GuillaumeGomez Jun 13, 2024
14014ab
Update fuchsia commit, and SDK to 21.20240610.2.1
erickt Jun 10, 2024
efbfcdd
Fill out missing Windows support information
ChrisDenton Jun 14, 2024
160b200
Rollup merge of #123962 - oli-obk:define_opaque_types5, r=lcnr
matthiaskrgr Jun 14, 2024
130c1a8
Rollup merge of #124884 - bvanjoi:fix-124785, r=estebank
matthiaskrgr Jun 14, 2024
158d2c1
Rollup merge of #126244 - erickt:bump, r=Kobzol
matthiaskrgr Jun 14, 2024
44e618d
Rollup merge of #126270 - GuillaumeGomez:migrate-run-make-const_fn_mi…
matthiaskrgr Jun 14, 2024
5725958
Rollup merge of #126320 - oli-obk:pat_ice, r=lcnr
matthiaskrgr Jun 14, 2024
db08f37
Rollup merge of #126343 - ChrisDenton:remove-utils, r=Kobzol
matthiaskrgr Jun 14, 2024
e435692
Rollup merge of #126351 - devnexen:to_sol11_upd, r=ChrisDenton
matthiaskrgr Jun 14, 2024
2e70bd2
Rollup merge of #126368 - nnethercote:rm-more-unused-crate-deps, r=ja…
matthiaskrgr Jun 14, 2024
8dc46d8
Rollup merge of #126386 - GuillaumeGomez:migrate-run-make-allow-non-l…
matthiaskrgr Jun 14, 2024
03068ec
Rollup merge of #126449 - ChrisDenton:windows-std-support, r=workingj…
matthiaskrgr Jun 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ jobs:
path-type: inherit
install: >
make
dos2unix
diffutils
- name: disable git crlf conversion
run: git config --global core.autocrlf false
Expand Down
1 change: 0 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4205,7 +4205,6 @@ dependencies = [
"rustc_middle",
"rustc_span",
"rustc_target",
"rustc_type_ir",
"smallvec",
"tracing",
]
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2888,7 +2888,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
..
} = explanation
{
if let Some(diag) = self.try_report_cannot_return_reference_to_local(
if let Err(diag) = self.try_report_cannot_return_reference_to_local(
borrow,
borrow_span,
span,
Expand Down Expand Up @@ -3075,7 +3075,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
if let BorrowExplanation::MustBeValidFor { category, span, from_closure: false, .. } =
explanation
{
if let Some(diag) = self.try_report_cannot_return_reference_to_local(
if let Err(diag) = self.try_report_cannot_return_reference_to_local(
borrow,
proper_span,
span,
Expand Down Expand Up @@ -3237,11 +3237,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
return_span: Span,
category: ConstraintCategory<'tcx>,
opt_place_desc: Option<&String>,
) -> Option<Diag<'tcx>> {
) -> Result<(), Diag<'tcx>> {
let return_kind = match category {
ConstraintCategory::Return(_) => "return",
ConstraintCategory::Yield => "yield",
_ => return None,
_ => return Ok(()),
};

// FIXME use a better heuristic than Spans
Expand Down Expand Up @@ -3317,7 +3317,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
}
}

Some(err)
Err(err)
}

#[instrument(level = "debug", skip(self))]
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_data_structures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ elsa = "=1.7.1"
ena = "0.14.3"
indexmap = { version = "2.0.0" }
jobserver_crate = { version = "0.1.28", package = "jobserver" }
libc = "0.2"
measureme = "11"
rustc-hash = "1.1.0"
rustc-rayon = { version = "0.5.0", optional = true }
Expand Down Expand Up @@ -41,6 +40,11 @@ features = [
"Win32_System_Threading",
]

[target.'cfg(unix)'.dependencies]
# tidy-alphabetical-start
libc = "0.2"
# tidy-alphabetical-end

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
# tidy-alphabetical-start
memmap2 = "0.2.1"
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
return;
};

let pick = self.confirm_method(
let pick = self.confirm_method_for_diagnostic(
call_expr.span,
callee_expr,
call_expr,
Expand Down
57 changes: 28 additions & 29 deletions compiler/rustc_hir_typeck/src/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rustc_errors::{Applicability, Diag};
use rustc_hir as hir;
use rustc_hir::def::Res;
use rustc_hir::intravisit::Visitor;
use rustc_infer::infer::{DefineOpaqueTypes, InferOk};
use rustc_infer::infer::DefineOpaqueTypes;
use rustc_middle::bug;
use rustc_middle::ty::adjustment::AllowTwoPhase;
use rustc_middle::ty::error::{ExpectedFound, TypeError};
Expand Down Expand Up @@ -166,7 +166,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// Requires that the two types unify, and prints an error message if
/// they don't.
pub fn demand_suptype(&self, sp: Span, expected: Ty<'tcx>, actual: Ty<'tcx>) {
if let Some(e) = self.demand_suptype_diag(sp, expected, actual) {
if let Err(e) = self.demand_suptype_diag(sp, expected, actual) {
e.emit();
}
}
Expand All @@ -176,7 +176,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
sp: Span,
expected: Ty<'tcx>,
actual: Ty<'tcx>,
) -> Option<Diag<'tcx>> {
) -> Result<(), Diag<'tcx>> {
self.demand_suptype_with_origin(&self.misc(sp), expected, actual)
}

Expand All @@ -186,18 +186,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
cause: &ObligationCause<'tcx>,
expected: Ty<'tcx>,
actual: Ty<'tcx>,
) -> Option<Diag<'tcx>> {
match self.at(cause, self.param_env).sup(DefineOpaqueTypes::Yes, expected, actual) {
Ok(InferOk { obligations, value: () }) => {
self.register_predicates(obligations);
None
}
Err(e) => Some(self.err_ctxt().report_mismatched_types(cause, expected, actual, e)),
}
) -> Result<(), Diag<'tcx>> {
self.at(cause, self.param_env)
.sup(DefineOpaqueTypes::Yes, expected, actual)
.map(|infer_ok| self.register_infer_ok_obligations(infer_ok))
.map_err(|e| self.err_ctxt().report_mismatched_types(cause, expected, actual, e))
}

pub fn demand_eqtype(&self, sp: Span, expected: Ty<'tcx>, actual: Ty<'tcx>) {
if let Some(err) = self.demand_eqtype_diag(sp, expected, actual) {
if let Err(err) = self.demand_eqtype_diag(sp, expected, actual) {
err.emit();
}
}
Expand All @@ -207,7 +204,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
sp: Span,
expected: Ty<'tcx>,
actual: Ty<'tcx>,
) -> Option<Diag<'tcx>> {
) -> Result<(), Diag<'tcx>> {
self.demand_eqtype_with_origin(&self.misc(sp), expected, actual)
}

Expand All @@ -216,14 +213,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
cause: &ObligationCause<'tcx>,
expected: Ty<'tcx>,
actual: Ty<'tcx>,
) -> Option<Diag<'tcx>> {
match self.at(cause, self.param_env).eq(DefineOpaqueTypes::Yes, expected, actual) {
Ok(InferOk { obligations, value: () }) => {
self.register_predicates(obligations);
None
}
Err(e) => Some(self.err_ctxt().report_mismatched_types(cause, expected, actual, e)),
}
) -> Result<(), Diag<'tcx>> {
self.at(cause, self.param_env)
.eq(DefineOpaqueTypes::Yes, expected, actual)
.map(|infer_ok| self.register_infer_ok_obligations(infer_ok))
.map_err(|e| self.err_ctxt().report_mismatched_types(cause, expected, actual, e))
}

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

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

let e = match self.coerce(expr, checked_ty, expected, allow_two_phase, None) {
Ok(ty) => return (ty, None),
Ok(ty) => return Ok(ty),
Err(e) => e,
};

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

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

(expected, Some(err))
Err(err)
}

/// Notes the point at which a variable is constrained to some type incompatible
Expand Down
11 changes: 5 additions & 6 deletions compiler/rustc_hir_typeck/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
ty = adj_ty;
}

if let Some(mut err) = self.demand_suptype_diag(expr.span, expected_ty, ty) {
if let Err(mut err) = self.demand_suptype_diag(expr.span, expected_ty, ty) {
let _ = self.emit_type_mismatch_suggestions(
&mut err,
expr.peel_drop_temps(),
Expand Down Expand Up @@ -1132,7 +1132,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// say that the user intended to write `lhs == rhs` instead of `lhs = rhs`.
// The likely cause of this is `if foo = bar { .. }`.
let actual_ty = self.tcx.types.unit;
let mut err = self.demand_suptype_diag(expr.span, expected_ty, actual_ty).unwrap();
let mut err = self.demand_suptype_diag(expr.span, expected_ty, actual_ty).unwrap_err();
let lhs_ty = self.check_expr(lhs);
let rhs_ty = self.check_expr(rhs);
let refs_can_coerce = |lhs: Ty<'tcx>, rhs: Ty<'tcx>| {
Expand Down Expand Up @@ -1236,7 +1236,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// This is (basically) inlined `check_expr_coercible_to_type`, but we want
// to suggest an additional fixup here in `suggest_deref_binop`.
let rhs_ty = self.check_expr_with_hint(rhs, lhs_ty);
if let (_, Some(mut diag)) =
if let Err(mut diag) =
self.demand_coerce_diag(rhs, rhs_ty, lhs_ty, Some(lhs), AllowTwoPhase::No)
{
suggest_deref_binop(&mut diag, rhs_ty);
Expand Down Expand Up @@ -1738,10 +1738,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Make sure to give a type to the field even if there's
// an error, so we can continue type-checking.
let ty = self.check_expr_with_hint(field.expr, field_type);
let (_, diag) =
self.demand_coerce_diag(field.expr, ty, field_type, None, AllowTwoPhase::No);
let diag = self.demand_coerce_diag(field.expr, ty, field_type, None, AllowTwoPhase::No);

if let Some(diag) = diag {
if let Err(diag) = diag {
if idx == hir_fields.len() - 1 {
if remaining_fields.is_empty() {
self.suggest_fru_from_range_and_emit(field, variant, args, diag);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let impl_ty = self.normalize(span, tcx.type_of(impl_def_id).instantiate(tcx, args));
let self_ty = self.normalize(span, self_ty);
match self.at(&self.misc(span), self.param_env).eq(
DefineOpaqueTypes::No,
DefineOpaqueTypes::Yes,
impl_ty,
self_ty,
) {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1578,7 +1578,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// type of the place it is referencing, and not some
// supertype thereof.
let init_ty = self.check_expr_with_needs(init, Needs::maybe_mut_place(m));
if let Some(mut diag) = self.demand_eqtype_diag(init.span, local_ty, init_ty) {
if let Err(mut diag) = self.demand_eqtype_diag(init.span, local_ty, init_ty) {
self.emit_type_mismatch_suggestions(
&mut diag,
init.peel_drop_temps(),
Expand Down Expand Up @@ -1624,7 +1624,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let previous_diverges = self.diverges.get();
let else_ty = self.check_block_with_expected(blk, NoExpectation);
let cause = self.cause(blk.span, ObligationCauseCode::LetElse);
if let Some(err) = self.demand_eqtype_with_origin(&cause, self.tcx.types.never, else_ty)
if let Err(err) = self.demand_eqtype_with_origin(&cause, self.tcx.types.never, else_ty)
{
err.emit();
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/method/confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
args,
})),
);
match self.at(&cause, self.param_env).sup(DefineOpaqueTypes::No, method_self_ty, self_ty) {
match self.at(&cause, self.param_env).sup(DefineOpaqueTypes::Yes, method_self_ty, self_ty) {
Ok(InferOk { obligations, value: () }) => {
self.register_predicates(obligations);
}
Expand Down
Loading
Loading