Skip to content

Commit 452cf4f

Browse files
committed
Auto merge of #103998 - Dylan-DPC:rollup-2nbmtc9, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - #103621 (Correctly resolve Inherent Associated Types) - #103660 (improve `filesearch::get_or_default_sysroot`) - #103866 (Remove some return-type diagnostic booleans from `FnCtxt`) - #103867 (Remove `has_errors` from `FnCtxt`) - #103994 (Specify that `break` cannot be used outside of loop *or* labeled block) - #103995 (Small round of typo fixes) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5b3e909 + 47e6304 commit 452cf4f

File tree

52 files changed

+300
-412
lines changed

Some content is hidden

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

52 files changed

+300
-412
lines changed

Cargo.lock

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3672,7 +3672,6 @@ dependencies = [
36723672
name = "rustc_interface"
36733673
version = "0.0.0"
36743674
dependencies = [
3675-
"libc",
36763675
"libloading",
36773676
"rustc-rayon",
36783677
"rustc-rayon-core",
@@ -3715,7 +3714,6 @@ dependencies = [
37153714
"rustc_ty_utils",
37163715
"smallvec",
37173716
"tracing",
3718-
"winapi",
37193717
]
37203718

37213719
[[package]]
@@ -4135,6 +4133,7 @@ name = "rustc_session"
41354133
version = "0.0.0"
41364134
dependencies = [
41374135
"getopts",
4136+
"libc",
41384137
"rustc_ast",
41394138
"rustc_data_structures",
41404139
"rustc_errors",
@@ -4146,7 +4145,9 @@ dependencies = [
41464145
"rustc_serialize",
41474146
"rustc_span",
41484147
"rustc_target",
4148+
"smallvec",
41494149
"tracing",
4150+
"winapi",
41504151
]
41514152

41524153
[[package]]

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,8 @@ fn link_sanitizer_runtime(sess: &Session, linker: &mut dyn Linker, name: &str) {
11231123
if path.exists() {
11241124
return session_tlib;
11251125
} else {
1126-
let default_sysroot = filesearch::get_or_default_sysroot();
1126+
let default_sysroot =
1127+
filesearch::get_or_default_sysroot().expect("Failed finding sysroot");
11271128
let default_tlib = filesearch::make_target_lib_path(
11281129
&default_sysroot,
11291130
sess.opts.target_triple.triple(),

compiler/rustc_error_messages/locales/en-US/passes.ftl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,14 @@ passes_break_inside_async_block =
451451
.async_block_label = enclosing `async` block
452452
453453
passes_outside_loop =
454-
`{$name}` outside of a loop
455-
.label = cannot `{$name}` outside of a loop
454+
`{$name}` outside of a loop{$is_break ->
455+
[true] {" or labeled block"}
456+
*[false] {""}
457+
}
458+
.label = cannot `{$name}` outside of a loop{$is_break ->
459+
[true] {" or labeled block"}
460+
*[false] {""}
461+
}
456462
457463
passes_unlabeled_in_labeled_block =
458464
unlabeled `{$cf_type}` inside of a labeled block

compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,6 +1910,20 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
19101910
}
19111911
}
19121912
}
1913+
1914+
// see if we can satisfy using an inherent associated type
1915+
for impl_ in tcx.inherent_impls(adt_def.did()) {
1916+
let assoc_ty = tcx.associated_items(impl_).find_by_name_and_kind(
1917+
tcx,
1918+
assoc_ident,
1919+
ty::AssocKind::Type,
1920+
*impl_,
1921+
);
1922+
if let Some(assoc_ty) = assoc_ty {
1923+
let ty = tcx.type_of(assoc_ty.def_id);
1924+
return Ok((ty, DefKind::AssocTy, assoc_ty.def_id));
1925+
}
1926+
}
19131927
}
19141928

19151929
// Find the type of the associated item, and the trait where the associated

compiler/rustc_hir_typeck/src/_match.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -491,11 +491,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
491491
..
492492
} = self.type_var_origin(expected)? else { return None; };
493493

494-
let sig = *self
495-
.typeck_results
496-
.borrow()
497-
.liberated_fn_sigs()
498-
.get(hir::HirId::make_owner(self.body_id.owner.def_id))?;
494+
let sig = self.body_fn_sig()?;
499495

500496
let substs = sig.output().walk().find_map(|arg| {
501497
if let ty::GenericArgKind::Type(ty) = arg.unpack()

compiler/rustc_hir_typeck/src/check.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,11 @@ pub(super) fn check_fn<'a, 'tcx>(
3131
fn_id: hir::HirId,
3232
body: &'tcx hir::Body<'tcx>,
3333
can_be_generator: Option<hir::Movability>,
34-
return_type_pre_known: bool,
3534
) -> (FnCtxt<'a, 'tcx>, Option<GeneratorTypes<'tcx>>) {
3635
// Create the function context. This is either derived from scratch or,
3736
// in the case of closures, based on the outer context.
3837
let mut fcx = FnCtxt::new(inherited, param_env, body.value.hir_id);
3938
fcx.ps.set(UnsafetyState::function(fn_sig.unsafety, fn_id));
40-
fcx.return_type_pre_known = return_type_pre_known;
4139

4240
let tcx = fcx.tcx;
4341
let hir = tcx.hir();
@@ -51,9 +49,6 @@ pub(super) fn check_fn<'a, 'tcx>(
5149
decl.output.span(),
5250
param_env,
5351
));
54-
// If we replaced declared_ret_ty with infer vars, then we must be inferring
55-
// an opaque type, so set a flag so we can improve diagnostics.
56-
fcx.return_type_has_opaque = ret_ty != declared_ret_ty;
5752

5853
fcx.ret_coercion = Some(RefCell::new(CoerceMany::new(ret_ty)));
5954

compiler/rustc_hir_typeck/src/closure.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
8383

8484
debug!(?bound_sig, ?liberated_sig);
8585

86-
let return_type_pre_known = !liberated_sig.output().is_ty_infer();
87-
8886
let generator_types = check_fn(
8987
self,
9088
self.param_env.without_const(),
@@ -93,7 +91,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
9391
expr.hir_id,
9492
body,
9593
gen,
96-
return_type_pre_known,
9794
)
9895
.1;
9996

compiler/rustc_hir_typeck/src/coercion.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1782,7 +1782,8 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
17821782
// may occur at the first return expression we see in the closure
17831783
// (if it conflicts with the declared return type). Skip adding a
17841784
// note in this case, since it would be incorrect.
1785-
&& !fcx.return_type_pre_known
1785+
&& let Some(fn_sig) = fcx.body_fn_sig()
1786+
&& fn_sig.output().is_ty_var()
17861787
{
17871788
err.span_note(
17881789
sp,

compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
220220

221221
// Hide the outer diverging and has_errors flags.
222222
let old_diverges = self.diverges.replace(Diverges::Maybe);
223-
let old_has_errors = self.has_errors.replace(false);
224223

225224
let ty = ensure_sufficient_stack(|| match &expr.kind {
226225
hir::ExprKind::Path(
@@ -259,7 +258,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
259258

260259
// Combine the diverging and has_error flags.
261260
self.diverges.set(self.diverges.get() | old_diverges);
262-
self.has_errors.set(self.has_errors.get() | old_has_errors);
263261

264262
debug!("type of {} is...", self.tcx.hir().node_to_string(expr.hir_id));
265263
debug!("... {:?}, expected is {:?}", ty, expected);
@@ -840,7 +838,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
840838
return_expr_ty,
841839
);
842840

843-
if self.return_type_has_opaque {
841+
if let Some(fn_sig) = self.body_fn_sig()
842+
&& fn_sig.output().has_opaque_types()
843+
{
844844
// Point any obligations that were registered due to opaque type
845845
// inference at the return expression.
846846
self.select_obligations_where_possible(false, |errors| {

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
143143
self.typeck_results.borrow_mut().node_types_mut().insert(id, ty);
144144

145145
if ty.references_error() {
146-
self.has_errors.set(true);
147146
self.set_tainted_by_errors();
148147
}
149148
}

0 commit comments

Comments
 (0)