Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5ffa8f6

Browse files
committedJun 28, 2022
Auto merge of #98222 - cjgillot:single-wf, r=michaelwoerister
Only keep a single query for well-formed checking There are currently 3 queries to perform wf checks on different item-likes. This complexity is not required. This PR replaces the query by: - one query per item; - one query to invoke it for a whole module. This allows to remove HIR `ParItemLikeVisitor`.
2 parents 7f08d04 + f446bbc commit 5ffa8f6

30 files changed

+241
-442
lines changed
 

‎compiler/rustc_hir/src/intravisit.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
//! example generator inference, and possibly also HIR borrowck.
6666
6767
use crate::hir::*;
68-
use crate::itemlikevisit::ParItemLikeVisitor;
6968
use rustc_ast::walk_list;
7069
use rustc_ast::{Attribute, Label};
7170
use rustc_span::symbol::{Ident, Symbol};
@@ -76,29 +75,6 @@ pub trait IntoVisitor<'hir> {
7675
fn into_visitor(&self) -> Self::Visitor;
7776
}
7877

79-
pub struct ParDeepVisitor<V>(pub V);
80-
81-
impl<'hir, V> ParItemLikeVisitor<'hir> for ParDeepVisitor<V>
82-
where
83-
V: IntoVisitor<'hir>,
84-
{
85-
fn visit_item(&self, item: &'hir Item<'hir>) {
86-
self.0.into_visitor().visit_item(item);
87-
}
88-
89-
fn visit_trait_item(&self, trait_item: &'hir TraitItem<'hir>) {
90-
self.0.into_visitor().visit_trait_item(trait_item);
91-
}
92-
93-
fn visit_impl_item(&self, impl_item: &'hir ImplItem<'hir>) {
94-
self.0.into_visitor().visit_impl_item(impl_item);
95-
}
96-
97-
fn visit_foreign_item(&self, foreign_item: &'hir ForeignItem<'hir>) {
98-
self.0.into_visitor().visit_foreign_item(foreign_item);
99-
}
100-
}
101-
10278
#[derive(Copy, Clone, Debug)]
10379
pub enum FnKind<'a> {
10480
/// `#[xxx] pub async/const/extern "Abi" fn foo()`

‎compiler/rustc_hir/src/itemlikevisit.rs

Lines changed: 0 additions & 9 deletions
This file was deleted.

‎compiler/rustc_hir/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ pub use rustc_span::def_id;
2727
mod hir;
2828
pub mod hir_id;
2929
pub mod intravisit;
30-
pub mod itemlikevisit;
3130
pub mod lang_items;
3231
pub mod pat_util;
3332
mod stable_hash_impls;

‎compiler/rustc_middle/src/hir/map/mod.rs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -612,23 +612,6 @@ impl<'hir> Map<'hir> {
612612
}
613613
}
614614

615-
/// A parallel version of `visit_all_item_likes`.
616-
pub fn par_visit_all_item_likes<V>(self, visitor: &V)
617-
where
618-
V: itemlikevisit::ParItemLikeVisitor<'hir> + Sync + Send,
619-
{
620-
let krate = self.krate();
621-
par_for_each_in(&krate.owners.raw, |owner| match owner.map(OwnerInfo::node) {
622-
MaybeOwner::Owner(OwnerNode::Item(item)) => visitor.visit_item(item),
623-
MaybeOwner::Owner(OwnerNode::ForeignItem(item)) => visitor.visit_foreign_item(item),
624-
MaybeOwner::Owner(OwnerNode::ImplItem(item)) => visitor.visit_impl_item(item),
625-
MaybeOwner::Owner(OwnerNode::TraitItem(item)) => visitor.visit_trait_item(item),
626-
MaybeOwner::Owner(OwnerNode::Crate(_))
627-
| MaybeOwner::NonOwner(_)
628-
| MaybeOwner::Phantom => {}
629-
})
630-
}
631-
632615
/// If you don't care about nesting, you should use the
633616
/// `tcx.hir_module_items()` query or `module_items()` instead.
634617
/// Please see notes in `deep_visit_all_item_likes`.
@@ -867,6 +850,10 @@ impl<'hir> Map<'hir> {
867850
)
868851
}
869852

853+
pub fn expect_owner(self, id: LocalDefId) -> OwnerNode<'hir> {
854+
self.tcx.hir_owner(id).unwrap_or_else(|| bug!("expected owner for {:?}", id)).node
855+
}
856+
870857
pub fn expect_item(self, id: LocalDefId) -> &'hir Item<'hir> {
871858
match self.tcx.hir_owner(id) {
872859
Some(Owner { node: OwnerNode::Item(item), .. }) => item,

‎compiler/rustc_middle/src/hir/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use crate::ty::query::Providers;
1010
use crate::ty::{DefIdTree, ImplSubject, TyCtxt};
1111
use rustc_data_structures::fingerprint::Fingerprint;
1212
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
13+
use rustc_data_structures::sync::{par_for_each_in, Send, Sync};
1314
use rustc_hir::def_id::{DefId, LocalDefId};
1415
use rustc_hir::*;
1516
use rustc_query_system::ich::StableHashingContext;
@@ -61,6 +62,22 @@ impl ModuleItems {
6162
pub fn foreign_items(&self) -> impl Iterator<Item = ForeignItemId> + '_ {
6263
self.foreign_items.iter().copied()
6364
}
65+
66+
pub fn par_items(&self, f: impl Fn(ItemId) + Send + Sync) {
67+
par_for_each_in(&self.items[..], |&id| f(id))
68+
}
69+
70+
pub fn par_trait_items(&self, f: impl Fn(TraitItemId) + Send + Sync) {
71+
par_for_each_in(&self.trait_items[..], |&id| f(id))
72+
}
73+
74+
pub fn par_impl_items(&self, f: impl Fn(ImplItemId) + Send + Sync) {
75+
par_for_each_in(&self.impl_items[..], |&id| f(id))
76+
}
77+
78+
pub fn par_foreign_items(&self, f: impl Fn(ForeignItemId) + Send + Sync) {
79+
par_for_each_in(&self.foreign_items[..], |&id| f(id))
80+
}
6481
}
6582

6683
impl<'tcx> TyCtxt<'tcx> {

‎compiler/rustc_middle/src/query/mod.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,10 @@ rustc_queries! {
826826
desc { |tcx| "checking that impls are well-formed in {}", describe_as_module(key, tcx) }
827827
}
828828

829+
query check_mod_type_wf(key: LocalDefId) -> () {
830+
desc { |tcx| "checking that types are well-formed in {}", describe_as_module(key, tcx) }
831+
}
832+
829833
query collect_mod_item_types(key: LocalDefId) -> () {
830834
desc { |tcx| "collecting item types in {}", describe_as_module(key, tcx) }
831835
}
@@ -1399,13 +1403,7 @@ rustc_queries! {
13991403
separate_provide_extern
14001404
}
14011405

1402-
query check_item_well_formed(key: LocalDefId) -> () {
1403-
desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key.to_def_id()) }
1404-
}
1405-
query check_trait_item_well_formed(key: LocalDefId) -> () {
1406-
desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key.to_def_id()) }
1407-
}
1408-
query check_impl_item_well_formed(key: LocalDefId) -> () {
1406+
query check_well_formed(key: LocalDefId) -> () {
14091407
desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key.to_def_id()) }
14101408
}
14111409

‎compiler/rustc_typeck/src/check/check.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ use rustc_ty_utils::representability::{self, Representability};
3232
use std::iter;
3333
use std::ops::ControlFlow;
3434

35-
pub fn check_wf_new(tcx: TyCtxt<'_>) {
36-
let visit = wfcheck::CheckTypeWellFormedVisitor::new(tcx);
37-
tcx.hir().par_visit_all_item_likes(&visit);
38-
}
39-
4035
pub(super) fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: Abi) {
4136
match tcx.sess.target.is_abi_supported(abi) {
4237
Some(true) => (),
@@ -754,7 +749,7 @@ fn check_opaque_meets_bounds<'tcx>(
754749
});
755750
}
756751

757-
pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) {
752+
fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) {
758753
debug!(
759754
"check_item_type(it.def_id={:?}, it.name={})",
760755
id.def_id,
@@ -1543,12 +1538,6 @@ pub(super) fn check_mod_item_types(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
15431538
}
15441539
}
15451540

1546-
pub(super) use wfcheck::check_item_well_formed;
1547-
1548-
pub(super) use wfcheck::check_trait_item as check_trait_item_well_formed;
1549-
1550-
pub(super) use wfcheck::check_impl_item as check_impl_item_well_formed;
1551-
15521541
fn async_opaque_type_cycle_error(tcx: TyCtxt<'_>, span: Span) -> ErrorGuaranteed {
15531542
struct_span_err!(tcx.sess, span, E0733, "recursion in an `async fn` requires boxing")
15541543
.span_label(span, "recursive `async fn`")

‎compiler/rustc_typeck/src/check/mod.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,7 @@ mod upvar;
9393
mod wfcheck;
9494
pub mod writeback;
9595

96-
use check::{
97-
check_abi, check_fn, check_impl_item_well_formed, check_item_well_formed, check_mod_item_types,
98-
check_trait_item_well_formed,
99-
};
100-
pub use check::{check_item_type, check_wf_new};
96+
use check::{check_abi, check_fn, check_mod_item_types};
10197
pub use diverges::Diverges;
10298
pub use expectation::Expectation;
10399
pub use fn_ctxt::*;
@@ -245,6 +241,7 @@ impl<'tcx> EnclosingBreakables<'tcx> {
245241

246242
pub fn provide(providers: &mut Providers) {
247243
method::provide(providers);
244+
wfcheck::provide(providers);
248245
*providers = Providers {
249246
typeck_item_bodies,
250247
typeck_const_arg,
@@ -253,9 +250,6 @@ pub fn provide(providers: &mut Providers) {
253250
has_typeck_results,
254251
adt_destructor,
255252
used_trait_imports,
256-
check_item_well_formed,
257-
check_trait_item_well_formed,
258-
check_impl_item_well_formed,
259253
check_mod_item_types,
260254
region_scope_tree,
261255
..*providers

‎compiler/rustc_typeck/src/check/wfcheck.rs

Lines changed: 57 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,18 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
77
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed};
88
use rustc_hir as hir;
99
use rustc_hir::def_id::{DefId, LocalDefId};
10-
use rustc_hir::intravisit as hir_visit;
11-
use rustc_hir::intravisit::Visitor;
12-
use rustc_hir::itemlikevisit::ParItemLikeVisitor;
1310
use rustc_hir::lang_items::LangItem;
1411
use rustc_hir::ItemKind;
1512
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
1613
use rustc_infer::infer::outlives::obligations::TypeOutlives;
1714
use rustc_infer::infer::region_constraints::GenericKind;
1815
use rustc_infer::infer::{self, InferCtxt, TyCtxtInferExt};
19-
use rustc_middle::hir::nested_filter;
16+
use rustc_middle::ty::query::Providers;
2017
use rustc_middle::ty::subst::{GenericArgKind, InternalSubsts, Subst};
2118
use rustc_middle::ty::trait_def::TraitSpecializationKind;
2219
use rustc_middle::ty::{
23-
self, AdtKind, EarlyBinder, GenericParamDefKind, ToPredicate, Ty, TyCtxt, TypeFoldable,
24-
TypeSuperFoldable, TypeVisitor,
20+
self, AdtKind, DefIdTree, EarlyBinder, GenericParamDefKind, ToPredicate, Ty, TyCtxt,
21+
TypeFoldable, TypeSuperFoldable, TypeVisitor,
2522
};
2623
use rustc_session::parse::feature_err;
2724
use rustc_span::symbol::{sym, Ident, Symbol};
@@ -70,6 +67,23 @@ impl<'tcx> CheckWfFcxBuilder<'tcx> {
7067
}
7168
}
7269

70+
fn check_well_formed(tcx: TyCtxt<'_>, def_id: LocalDefId) {
71+
let node = tcx.hir().expect_owner(def_id);
72+
match node {
73+
hir::OwnerNode::Crate(_) => {}
74+
hir::OwnerNode::Item(item) => check_item(tcx, item),
75+
hir::OwnerNode::TraitItem(item) => check_trait_item(tcx, item),
76+
hir::OwnerNode::ImplItem(item) => check_impl_item(tcx, item),
77+
hir::OwnerNode::ForeignItem(item) => check_foreign_item(tcx, item),
78+
}
79+
80+
if let Some(generics) = node.generics() {
81+
for param in generics.params {
82+
check_param_wf(tcx, param)
83+
}
84+
}
85+
}
86+
7387
/// Checks that the field types (in a struct def'n) or argument types (in an enum def'n) are
7488
/// well-formed, meaning that they do not require any constraints not declared in the struct
7589
/// definition itself. For example, this definition would be illegal:
@@ -84,8 +98,8 @@ impl<'tcx> CheckWfFcxBuilder<'tcx> {
8498
/// not included it frequently leads to confusing errors in fn bodies. So it's better to check
8599
/// the types first.
86100
#[instrument(skip(tcx), level = "debug")]
87-
pub fn check_item_well_formed(tcx: TyCtxt<'_>, def_id: LocalDefId) {
88-
let item = tcx.hir().expect_item(def_id);
101+
fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) {
102+
let def_id = item.def_id;
89103

90104
debug!(
91105
?item.def_id,
@@ -156,20 +170,6 @@ pub fn check_item_well_formed(tcx: TyCtxt<'_>, def_id: LocalDefId) {
156170
hir::ItemKind::Const(ty, ..) => {
157171
check_item_type(tcx, item.def_id, ty.span, false);
158172
}
159-
hir::ItemKind::ForeignMod { items, .. } => {
160-
for it in items.iter() {
161-
let it = tcx.hir().foreign_item(it.id);
162-
match it.kind {
163-
hir::ForeignItemKind::Fn(decl, ..) => {
164-
check_item_fn(tcx, it.def_id, it.ident, it.span, decl)
165-
}
166-
hir::ForeignItemKind::Static(ty, ..) => {
167-
check_item_type(tcx, it.def_id, ty.span, true)
168-
}
169-
hir::ForeignItemKind::Type => (),
170-
}
171-
}
172-
}
173173
hir::ItemKind::Struct(ref struct_def, ref ast_generics) => {
174174
check_type_defn(tcx, item, false, |fcx| vec![fcx.non_enum_variant(struct_def)]);
175175

@@ -191,13 +191,31 @@ pub fn check_item_well_formed(tcx: TyCtxt<'_>, def_id: LocalDefId) {
191191
hir::ItemKind::TraitAlias(..) => {
192192
check_trait(tcx, item);
193193
}
194+
// `ForeignItem`s are handled separately.
195+
hir::ItemKind::ForeignMod { .. } => {}
194196
_ => {}
195197
}
196198
}
197199

198-
pub fn check_trait_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
199-
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
200-
let trait_item = tcx.hir().expect_trait_item(def_id);
200+
fn check_foreign_item(tcx: TyCtxt<'_>, item: &hir::ForeignItem<'_>) {
201+
let def_id = item.def_id;
202+
203+
debug!(
204+
?item.def_id,
205+
item.name = ? tcx.def_path_str(def_id.to_def_id())
206+
);
207+
208+
match item.kind {
209+
hir::ForeignItemKind::Fn(decl, ..) => {
210+
check_item_fn(tcx, item.def_id, item.ident, item.span, decl)
211+
}
212+
hir::ForeignItemKind::Static(ty, ..) => check_item_type(tcx, item.def_id, ty.span, true),
213+
hir::ForeignItemKind::Type => (),
214+
}
215+
}
216+
217+
fn check_trait_item(tcx: TyCtxt<'_>, trait_item: &hir::TraitItem<'_>) {
218+
let def_id = trait_item.def_id;
201219

202220
let (method_sig, span) = match trait_item.kind {
203221
hir::TraitItemKind::Fn(ref sig, _) => (Some(sig), trait_item.span),
@@ -207,7 +225,7 @@ pub fn check_trait_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
207225
check_object_unsafe_self_trait_by_name(tcx, trait_item);
208226
check_associated_item(tcx, trait_item.def_id, span, method_sig);
209227

210-
let encl_trait_def_id = tcx.hir().get_parent_item(hir_id);
228+
let encl_trait_def_id = tcx.local_parent(def_id);
211229
let encl_trait = tcx.hir().expect_item(encl_trait_def_id);
212230
let encl_trait_def_id = encl_trait.def_id.to_def_id();
213231
let fn_lang_item_name = if Some(encl_trait_def_id) == tcx.lang_items().fn_trait() {
@@ -764,8 +782,8 @@ fn check_object_unsafe_self_trait_by_name(tcx: TyCtxt<'_>, item: &hir::TraitItem
764782
}
765783
}
766784

767-
pub fn check_impl_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
768-
let impl_item = tcx.hir().expect_impl_item(def_id);
785+
fn check_impl_item(tcx: TyCtxt<'_>, impl_item: &hir::ImplItem<'_>) {
786+
let def_id = impl_item.def_id;
769787

770788
let (method_sig, span) = match impl_item.kind {
771789
hir::ImplItemKind::Fn(ref sig, _) => (Some(sig), impl_item.span),
@@ -774,7 +792,7 @@ pub fn check_impl_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
774792
_ => (None, impl_item.span),
775793
};
776794

777-
check_associated_item(tcx, impl_item.def_id, span, method_sig);
795+
check_associated_item(tcx, def_id, span, method_sig);
778796
}
779797

780798
fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) {
@@ -1822,67 +1840,12 @@ fn check_false_global_bounds(fcx: &FnCtxt<'_, '_>, mut span: Span, id: hir::HirI
18221840
fcx.select_all_obligations_or_error();
18231841
}
18241842

1825-
#[derive(Clone, Copy)]
1826-
pub struct CheckTypeWellFormedVisitor<'tcx> {
1827-
tcx: TyCtxt<'tcx>,
1828-
}
1829-
1830-
impl<'tcx> CheckTypeWellFormedVisitor<'tcx> {
1831-
pub fn new(tcx: TyCtxt<'tcx>) -> CheckTypeWellFormedVisitor<'tcx> {
1832-
CheckTypeWellFormedVisitor { tcx }
1833-
}
1834-
}
1835-
1836-
impl<'tcx> ParItemLikeVisitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> {
1837-
fn visit_item(&self, i: &'tcx hir::Item<'tcx>) {
1838-
Visitor::visit_item(&mut self.clone(), i);
1839-
}
1840-
1841-
fn visit_trait_item(&self, trait_item: &'tcx hir::TraitItem<'tcx>) {
1842-
Visitor::visit_trait_item(&mut self.clone(), trait_item);
1843-
}
1844-
1845-
fn visit_impl_item(&self, impl_item: &'tcx hir::ImplItem<'tcx>) {
1846-
Visitor::visit_impl_item(&mut self.clone(), impl_item);
1847-
}
1848-
1849-
fn visit_foreign_item(&self, foreign_item: &'tcx hir::ForeignItem<'tcx>) {
1850-
Visitor::visit_foreign_item(&mut self.clone(), foreign_item)
1851-
}
1852-
}
1853-
1854-
impl<'tcx> Visitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> {
1855-
type NestedFilter = nested_filter::OnlyBodies;
1856-
1857-
fn nested_visit_map(&mut self) -> Self::Map {
1858-
self.tcx.hir()
1859-
}
1860-
1861-
#[instrument(skip(self, i), level = "debug")]
1862-
fn visit_item(&mut self, i: &'tcx hir::Item<'tcx>) {
1863-
trace!(?i);
1864-
self.tcx.ensure().check_item_well_formed(i.def_id);
1865-
hir_visit::walk_item(self, i);
1866-
}
1867-
1868-
#[instrument(skip(self, trait_item), level = "debug")]
1869-
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) {
1870-
trace!(?trait_item);
1871-
self.tcx.ensure().check_trait_item_well_formed(trait_item.def_id);
1872-
hir_visit::walk_trait_item(self, trait_item);
1873-
}
1874-
1875-
#[instrument(skip(self, impl_item), level = "debug")]
1876-
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem<'tcx>) {
1877-
trace!(?impl_item);
1878-
self.tcx.ensure().check_impl_item_well_formed(impl_item.def_id);
1879-
hir_visit::walk_impl_item(self, impl_item);
1880-
}
1881-
1882-
fn visit_generic_param(&mut self, p: &'tcx hir::GenericParam<'tcx>) {
1883-
check_param_wf(self.tcx, p);
1884-
hir_visit::walk_generic_param(self, p);
1885-
}
1843+
fn check_mod_type_wf(tcx: TyCtxt<'_>, module: LocalDefId) {
1844+
let items = tcx.hir_module_items(module);
1845+
items.par_items(|item| tcx.ensure().check_well_formed(item.def_id));
1846+
items.par_impl_items(|item| tcx.ensure().check_well_formed(item.def_id));
1847+
items.par_trait_items(|item| tcx.ensure().check_well_formed(item.def_id));
1848+
items.par_foreign_items(|item| tcx.ensure().check_well_formed(item.def_id));
18861849
}
18871850

18881851
///////////////////////////////////////////////////////////////////////////
@@ -1967,3 +1930,7 @@ fn error_392(
19671930
err.span_label(span, "unused parameter");
19681931
err
19691932
}
1933+
1934+
pub fn provide(providers: &mut Providers) {
1935+
*providers = Providers { check_mod_type_wf, check_well_formed, ..*providers };
1936+
}

‎compiler/rustc_typeck/src/impl_wf_check.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,6 @@ mod min_specialization;
5454
/// impl<'a> Trait<Foo> for Bar { type X = &'a i32; }
5555
/// // ^ 'a is unused and appears in assoc type, error
5656
/// ```
57-
pub fn impl_wf_check(tcx: TyCtxt<'_>) {
58-
// We will tag this as part of the WF check -- logically, it is,
59-
// but it's one that we must perform earlier than the rest of
60-
// WfCheck.
61-
tcx.hir().for_each_module(|module| tcx.ensure().check_mod_impl_wf(module))
62-
}
63-
6457
fn check_mod_impl_wf(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
6558
let min_specialization = tcx.features().min_specialization;
6659
let module = tcx.hir_module_items(module_def_id);

‎compiler/rustc_typeck/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,9 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
509509
}
510510

511511
tcx.sess.track_errors(|| {
512-
tcx.sess.time("impl_wf_inference", || impl_wf_check::impl_wf_check(tcx));
512+
tcx.sess.time("impl_wf_inference", || {
513+
tcx.hir().for_each_module(|module| tcx.ensure().check_mod_impl_wf(module))
514+
});
513515
})?;
514516

515517
tcx.sess.track_errors(|| {
@@ -531,7 +533,9 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
531533
}
532534

533535
tcx.sess.track_errors(|| {
534-
tcx.sess.time("wf_checking", || check::check_wf_new(tcx));
536+
tcx.sess.time("wf_checking", || {
537+
tcx.hir().par_for_each_module(|module| tcx.ensure().check_mod_type_wf(module))
538+
});
535539
})?;
536540

537541
// NOTE: This is copy/pasted in librustdoc/core.rs and should be kept in sync.

‎src/test/ui/associated-item/issue-48027.stderr

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
error[E0283]: type annotations needed
2-
--> $DIR/issue-48027.rs:3:32
3-
|
4-
LL | fn return_n(&self) -> [u8; Bar::X];
5-
| ^^^^^^
6-
| |
7-
| cannot infer type
8-
| help: use the fully qualified path to an implementation: `<Type as Bar>::X`
9-
|
10-
= note: cannot satisfy `_: Bar`
11-
= note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
12-
131
error[E0038]: the trait `Bar` cannot be made into an object
142
--> $DIR/issue-48027.rs:6:6
153
|
@@ -25,6 +13,18 @@ LL | const X: usize;
2513
| ^ ...because it contains this associated `const`
2614
= help: consider moving `X` to another trait
2715

16+
error[E0283]: type annotations needed
17+
--> $DIR/issue-48027.rs:3:32
18+
|
19+
LL | fn return_n(&self) -> [u8; Bar::X];
20+
| ^^^^^^
21+
| |
22+
| cannot infer type
23+
| help: use the fully qualified path to an implementation: `<Type as Bar>::X`
24+
|
25+
= note: cannot satisfy `_: Bar`
26+
= note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
27+
2828
error: aborting due to 2 previous errors
2929

3030
Some errors have detailed explanations: E0038, E0283.
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
error[E0277]: the trait bound `(T, U): Get` is not satisfied
2+
--> $DIR/associated-types-no-suitable-supertrait.rs:22:40
3+
|
4+
LL | fn uhoh<U:Get>(&self, foo: U, bar: <(T, U) as Get>::Value) {}
5+
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `(T, U)`
6+
17
error[E0277]: the trait bound `Self: Get` is not satisfied
28
--> $DIR/associated-types-no-suitable-supertrait.rs:17:40
39
|
@@ -9,12 +15,6 @@ help: consider further restricting `Self`
915
LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) where Self: Get {}
1016
| +++++++++++++++
1117

12-
error[E0277]: the trait bound `(T, U): Get` is not satisfied
13-
--> $DIR/associated-types-no-suitable-supertrait.rs:22:40
14-
|
15-
LL | fn uhoh<U:Get>(&self, foo: U, bar: <(T, U) as Get>::Value) {}
16-
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `(T, U)`
17-
1818
error: aborting due to 2 previous errors
1919

2020
For more information about this error, try `rustc --explain E0277`.

‎src/test/ui/associated-types/hr-associated-type-bound-2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ impl X<'_> for u32 //~ overflow evaluating the requirement `for<'b> u32: X<'b>`
1212
where
1313
for<'b> <Self as X<'b>>::U: Clone,
1414
{
15-
type U = str; //~ overflow evaluating the requirement `for<'b> u32: X<'b>`
15+
type U = str;
1616
}
1717

1818
fn main() {

‎src/test/ui/associated-types/hr-associated-type-bound-2.stderr

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,6 @@ LL | impl X<'_> for u32
1818
= note: 128 redundant requirements hidden
1919
= note: required because of the requirements on the impl of `for<'b> X<'b>` for `u32`
2020

21-
error[E0275]: overflow evaluating the requirement `for<'b> u32: X<'b>`
22-
--> $DIR/hr-associated-type-bound-2.rs:15:5
23-
|
24-
LL | type U = str;
25-
| ^^^^^^^^^^^^^
26-
|
27-
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`hr_associated_type_bound_2`)
28-
note: required because of the requirements on the impl of `for<'b> X<'b>` for `u32`
29-
--> $DIR/hr-associated-type-bound-2.rs:11:6
30-
|
31-
LL | impl X<'_> for u32
32-
| ^^^^^ ^^^
33-
= note: 128 redundant requirements hidden
34-
= note: required because of the requirements on the impl of `for<'b> X<'b>` for `u32`
35-
36-
error: aborting due to 2 previous errors
21+
error: aborting due to previous error
3722

3823
For more information about this error, try `rustc --explain E0275`.

‎src/test/ui/associated-types/hr-associated-type-bound-param-2.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ LL | for<'b> <T as Z<'b, u16>>::W: Clone,
1515
| ^^^^^ required by this bound in `Z`
1616

1717
error[E0277]: the trait bound `str: Clone` is not satisfied
18-
--> $DIR/hr-associated-type-bound-param-2.rs:3:8
18+
--> $DIR/hr-associated-type-bound-param-2.rs:15:14
1919
|
20-
LL | T: Z<'a, u16>,
21-
| ^^^^^^^^^^ the trait `Clone` is not implemented for `str`
20+
LL | type W = str;
21+
| ^^^ the trait `Clone` is not implemented for `str`
2222
|
2323
= help: the trait `Clone` is implemented for `String`
2424
note: required by a bound in `Z`
@@ -31,10 +31,10 @@ LL | for<'b> <T as Z<'b, u16>>::W: Clone,
3131
| ^^^^^ required by this bound in `Z`
3232

3333
error[E0277]: the trait bound `str: Clone` is not satisfied
34-
--> $DIR/hr-associated-type-bound-param-2.rs:15:14
34+
--> $DIR/hr-associated-type-bound-param-2.rs:3:8
3535
|
36-
LL | type W = str;
37-
| ^^^ the trait `Clone` is not implemented for `str`
36+
LL | T: Z<'a, u16>,
37+
| ^^^^^^^^^^ the trait `Clone` is not implemented for `str`
3838
|
3939
= help: the trait `Clone` is implemented for `String`
4040
note: required by a bound in `Z`

‎src/test/ui/associated-types/impl-wf-cycle-1.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,14 @@ trait Grault {
1313
}
1414

1515
impl<T: Grault> Grault for (T,)
16+
//~^ ERROR overflow evaluating the requirement `<(T,) as Grault>::A == _`
1617
where
1718
Self::A: Baz,
1819
Self::B: Fiz,
1920
{
2021
type A = ();
21-
//~^ ERROR overflow evaluating the requirement `<(T,) as Grault>::A == _`
2222
type B = bool;
23-
//~^ ERROR overflow evaluating the requirement `<(T,) as Grault>::A == _`
2423
}
25-
//~^^^^^^^^^^ ERROR overflow evaluating the requirement `<(T,) as Grault>::A == _`
2624

2725
fn main() {
2826
let x: <(_,) as Grault>::A = ();

‎src/test/ui/associated-types/impl-wf-cycle-1.stderr

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _`
22
--> $DIR/impl-wf-cycle-1.rs:15:1
33
|
44
LL | / impl<T: Grault> Grault for (T,)
5+
LL | |
56
LL | | where
67
LL | | Self::A: Baz,
7-
LL | | Self::B: Fiz,
88
... |
9-
LL | |
9+
LL | | type B = bool;
1010
LL | | }
1111
| |_^
1212
|
@@ -18,34 +18,6 @@ LL | impl<T: Grault> Grault for (T,)
1818
= note: 1 redundant requirement hidden
1919
= note: required because of the requirements on the impl of `Grault` for `(T,)`
2020

21-
error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _`
22-
--> $DIR/impl-wf-cycle-1.rs:20:5
23-
|
24-
LL | type A = ();
25-
| ^^^^^^^^^^^^
26-
|
27-
note: required because of the requirements on the impl of `Grault` for `(T,)`
28-
--> $DIR/impl-wf-cycle-1.rs:15:17
29-
|
30-
LL | impl<T: Grault> Grault for (T,)
31-
| ^^^^^^ ^^^^
32-
= note: 1 redundant requirement hidden
33-
= note: required because of the requirements on the impl of `Grault` for `(T,)`
34-
35-
error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _`
36-
--> $DIR/impl-wf-cycle-1.rs:22:5
37-
|
38-
LL | type B = bool;
39-
| ^^^^^^^^^^^^^^
40-
|
41-
note: required because of the requirements on the impl of `Grault` for `(T,)`
42-
--> $DIR/impl-wf-cycle-1.rs:15:17
43-
|
44-
LL | impl<T: Grault> Grault for (T,)
45-
| ^^^^^^ ^^^^
46-
= note: 1 redundant requirement hidden
47-
= note: required because of the requirements on the impl of `Grault` for `(T,)`
48-
49-
error: aborting due to 3 previous errors
21+
error: aborting due to previous error
5022

5123
For more information about this error, try `rustc --explain E0275`.

‎src/test/ui/associated-types/impl-wf-cycle-2.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ trait Grault {
55
}
66

77
impl<T: Grault> Grault for (T,)
8+
//~^ ERROR overflow evaluating the requirement `<(T,) as Grault>::A == _`
89
where
910
Self::A: Copy,
1011
{
1112
type A = ();
12-
//~^ ERROR overflow evaluating the requirement `<(T,) as Grault>::A == _`
1313
}
14-
//~^^^^^^^ ERROR overflow evaluating the requirement `<(T,) as Grault>::A == _`
1514

1615
fn main() {}

‎src/test/ui/associated-types/impl-wf-cycle-2.stderr

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _`
22
--> $DIR/impl-wf-cycle-2.rs:7:1
33
|
44
LL | / impl<T: Grault> Grault for (T,)
5+
LL | |
56
LL | | where
67
LL | | Self::A: Copy,
78
LL | | {
89
LL | | type A = ();
9-
LL | |
1010
LL | | }
1111
| |_^
1212
|
@@ -16,18 +16,6 @@ note: required because of the requirements on the impl of `Grault` for `(T,)`
1616
LL | impl<T: Grault> Grault for (T,)
1717
| ^^^^^^ ^^^^
1818

19-
error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _`
20-
--> $DIR/impl-wf-cycle-2.rs:11:5
21-
|
22-
LL | type A = ();
23-
| ^^^^^^^^^^^^
24-
|
25-
note: required because of the requirements on the impl of `Grault` for `(T,)`
26-
--> $DIR/impl-wf-cycle-2.rs:7:17
27-
|
28-
LL | impl<T: Grault> Grault for (T,)
29-
| ^^^^^^ ^^^^
30-
31-
error: aborting due to 2 previous errors
19+
error: aborting due to previous error
3220

3321
For more information about this error, try `rustc --explain E0275`.

‎src/test/ui/associated-types/issue-59324.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ help: consider further restricting this bound
4646
LL | pub trait ThriftService<Bug: NotFoo + Foo>:
4747
| +++++
4848

49+
error[E0277]: the trait bound `(): Foo` is not satisfied
50+
--> $DIR/issue-59324.rs:23:29
51+
|
52+
LL | fn with_factory<H>(factory: dyn ThriftService<()>) {}
53+
| ^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `()`
54+
4955
error[E0277]: the trait bound `Bug: Foo` is not satisfied
5056
--> $DIR/issue-59324.rs:19:10
5157
|
@@ -57,12 +63,6 @@ help: consider further restricting this bound
5763
LL | pub trait ThriftService<Bug: NotFoo + Foo>:
5864
| +++++
5965

60-
error[E0277]: the trait bound `(): Foo` is not satisfied
61-
--> $DIR/issue-59324.rs:23:29
62-
|
63-
LL | fn with_factory<H>(factory: dyn ThriftService<()>) {}
64-
| ^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `()`
65-
6666
error: aborting due to 5 previous errors
6767

6868
For more information about this error, try `rustc --explain E0277`.

‎src/test/ui/const-generics/const-param-elided-lifetime.min.stderr

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,6 @@ LL | impl<const N: &u8> A<N> {
4646
= note: the only supported types are integers, `bool` and `char`
4747
= help: more complex types are supported with `#![feature(adt_const_params)]`
4848

49-
error: `&'static u8` is forbidden as the type of a const generic parameter
50-
--> $DIR/const-param-elided-lifetime.rs:17:21
51-
|
52-
LL | fn foo<const M: &u8>(&self) {}
53-
| ^^^
54-
|
55-
= note: the only supported types are integers, `bool` and `char`
56-
= help: more complex types are supported with `#![feature(adt_const_params)]`
57-
5849
error: `&'static u8` is forbidden as the type of a const generic parameter
5950
--> $DIR/const-param-elided-lifetime.rs:22:15
6051
|
@@ -73,6 +64,15 @@ LL | fn bar<const N: &u8>() {}
7364
= note: the only supported types are integers, `bool` and `char`
7465
= help: more complex types are supported with `#![feature(adt_const_params)]`
7566

67+
error: `&'static u8` is forbidden as the type of a const generic parameter
68+
--> $DIR/const-param-elided-lifetime.rs:17:21
69+
|
70+
LL | fn foo<const M: &u8>(&self) {}
71+
| ^^^
72+
|
73+
= note: the only supported types are integers, `bool` and `char`
74+
= help: more complex types are supported with `#![feature(adt_const_params)]`
75+
7676
error: aborting due to 10 previous errors
7777

7878
For more information about this error, try `rustc --explain E0637`.

‎src/test/ui/feature-gates/feature-gate-arbitrary-self-types.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
error[E0658]: `Ptr<Self>` cannot be used as the type of `self` without the `arbitrary_self_types` feature
2-
--> $DIR/feature-gate-arbitrary-self-types.rs:16:18
3-
|
4-
LL | fn foo(self: Ptr<Self>);
5-
| ^^^^^^^^^
6-
|
7-
= note: see issue #44874 <https://github.com/rust-lang/rust/issues/44874> for more information
8-
= help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable
9-
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
10-
111
error[E0658]: `Ptr<Bar>` cannot be used as the type of `self` without the `arbitrary_self_types` feature
122
--> $DIR/feature-gate-arbitrary-self-types.rs:22:18
133
|
@@ -28,6 +18,16 @@ LL | fn bar(self: Box<Ptr<Self>>) {}
2818
= help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable
2919
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
3020

21+
error[E0658]: `Ptr<Self>` cannot be used as the type of `self` without the `arbitrary_self_types` feature
22+
--> $DIR/feature-gate-arbitrary-self-types.rs:16:18
23+
|
24+
LL | fn foo(self: Ptr<Self>);
25+
| ^^^^^^^^^
26+
|
27+
= note: see issue #44874 <https://github.com/rust-lang/rust/issues/44874> for more information
28+
= help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable
29+
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
30+
3131
error: aborting due to 3 previous errors
3232

3333
For more information about this error, try `rustc --explain E0658`.

‎src/test/ui/feature-gates/feature-gate-arbitrary_self_types-raw-pointer.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ LL | fn foo(self: *const Self) {}
88
= help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable
99
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
1010

11-
error[E0658]: `*const Self` cannot be used as the type of `self` without the `arbitrary_self_types` feature
12-
--> $DIR/feature-gate-arbitrary_self_types-raw-pointer.rs:9:18
11+
error[E0658]: `*const ()` cannot be used as the type of `self` without the `arbitrary_self_types` feature
12+
--> $DIR/feature-gate-arbitrary_self_types-raw-pointer.rs:14:18
1313
|
14-
LL | fn bar(self: *const Self);
14+
LL | fn bar(self: *const Self) {}
1515
| ^^^^^^^^^^^
1616
|
1717
= note: see issue #44874 <https://github.com/rust-lang/rust/issues/44874> for more information
1818
= help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable
1919
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
2020

21-
error[E0658]: `*const ()` cannot be used as the type of `self` without the `arbitrary_self_types` feature
22-
--> $DIR/feature-gate-arbitrary_self_types-raw-pointer.rs:14:18
21+
error[E0658]: `*const Self` cannot be used as the type of `self` without the `arbitrary_self_types` feature
22+
--> $DIR/feature-gate-arbitrary_self_types-raw-pointer.rs:9:18
2323
|
24-
LL | fn bar(self: *const Self) {}
24+
LL | fn bar(self: *const Self);
2525
| ^^^^^^^^^^^
2626
|
2727
= note: see issue #44874 <https://github.com/rust-lang/rust/issues/44874> for more information

‎src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89118.stderr

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,44 +19,44 @@ LL | Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>,
1919
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `StackContext`
2020

2121
error[E0277]: the trait bound `for<'a> &'a (): BufferMut` is not satisfied
22-
--> $DIR/issue-89118.rs:22:20
22+
--> $DIR/issue-89118.rs:29:9
2323
|
24-
LL | type Handler = Ctx<C::Dispatcher>;
25-
| ^^^^^^^^^^^^^^^^^^ the trait `for<'a> BufferMut` is not implemented for `&'a ()`
24+
LL | impl<C> EthernetWorker<C> {}
25+
| ^^^^^^^^^^^^^^^^^ the trait `for<'a> BufferMut` is not implemented for `&'a ()`
2626
|
2727
note: required because of the requirements on the impl of `for<'a> BufferUdpStateContext<&'a ()>` for `Ctx<()>`
2828
--> $DIR/issue-89118.rs:5:23
2929
|
3030
LL | impl<B: BufferMut, C> BufferUdpStateContext<B> for C {}
3131
| ^^^^^^^^^^^^^^^^^^^^^^^^ ^
32-
note: required by a bound in `StackContext`
33-
--> $DIR/issue-89118.rs:9:14
32+
note: required by a bound in `EthernetWorker`
33+
--> $DIR/issue-89118.rs:28:14
3434
|
35-
LL | trait StackContext
36-
| ------------ required by a bound in this
35+
LL | struct EthernetWorker<C>(C)
36+
| -------------- required by a bound in this
3737
LL | where
38-
LL | Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>,
39-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `StackContext`
38+
LL | Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>;
39+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `EthernetWorker`
4040

4141
error[E0277]: the trait bound `for<'a> &'a (): BufferMut` is not satisfied
42-
--> $DIR/issue-89118.rs:29:9
42+
--> $DIR/issue-89118.rs:22:20
4343
|
44-
LL | impl<C> EthernetWorker<C> {}
45-
| ^^^^^^^^^^^^^^^^^ the trait `for<'a> BufferMut` is not implemented for `&'a ()`
44+
LL | type Handler = Ctx<C::Dispatcher>;
45+
| ^^^^^^^^^^^^^^^^^^ the trait `for<'a> BufferMut` is not implemented for `&'a ()`
4646
|
4747
note: required because of the requirements on the impl of `for<'a> BufferUdpStateContext<&'a ()>` for `Ctx<()>`
4848
--> $DIR/issue-89118.rs:5:23
4949
|
5050
LL | impl<B: BufferMut, C> BufferUdpStateContext<B> for C {}
5151
| ^^^^^^^^^^^^^^^^^^^^^^^^ ^
52-
note: required by a bound in `EthernetWorker`
53-
--> $DIR/issue-89118.rs:28:14
52+
note: required by a bound in `StackContext`
53+
--> $DIR/issue-89118.rs:9:14
5454
|
55-
LL | struct EthernetWorker<C>(C)
56-
| -------------- required by a bound in this
55+
LL | trait StackContext
56+
| ------------ required by a bound in this
5757
LL | where
58-
LL | Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>;
59-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `EthernetWorker`
58+
LL | Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>,
59+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `StackContext`
6060

6161
error: aborting due to 3 previous errors
6262

‎src/test/ui/issues/issue-20413.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
trait Foo {
2-
fn answer(self);
2+
fn answer(self);
33
}
44

55
struct NoData<T>;
66
//~^ ERROR: parameter `T` is never used
77

88
impl<T> Foo for T where NoData<T>: Foo {
99
//~^ ERROR: overflow evaluating the requirement
10-
//~| ERROR: overflow evaluating the requirement
1110
fn answer(self) {
1211
let val: NoData<T> = NoData;
1312
}
1413
}
1514

1615
trait Bar {
17-
fn answer(self);
16+
fn answer(self);
1817
}
1918

2019
trait Baz {
21-
fn answer(self);
20+
fn answer(self);
2221
}
2322

2423
struct AlmostNoData<T>(Option<T>);
@@ -27,15 +26,13 @@ struct EvenLessData<T>(Option<T>);
2726

2827
impl<T> Bar for T where EvenLessData<T>: Baz {
2928
//~^ ERROR: overflow evaluating the requirement
30-
//~| ERROR: overflow evaluating the requirement
3129
fn answer(self) {
3230
let val: EvenLessData<T> = EvenLessData(None);
3331
}
3432
}
3533

3634
impl<T> Baz for T where AlmostNoData<T>: Bar {
3735
//~^ ERROR: overflow evaluating the requirement
38-
//~| ERROR: overflow evaluating the requirement
3936
fn answer(self) {
4037
let val: NoData<T> = AlmostNoData(None);
4138
}

‎src/test/ui/issues/issue-20413.stderr

Lines changed: 7 additions & 62 deletions
Large diffs are not rendered by default.

‎src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,28 @@ help: consider adding an explicit lifetime bound...
99
LL | struct Foo<T: 'static> {
1010
| +++++++++
1111

12+
error[E0309]: the parameter type `K` may not live long enough
13+
--> $DIR/lifetime-doesnt-live-long-enough.rs:41:33
14+
|
15+
LL | fn generic_in_parent<'a, L: X<&'a Nested<K>>>() {
16+
| ^^^^^^^^^^^^^^^^ ...so that the reference type `&'a Nested<K>` does not outlive the data it points at
17+
|
18+
help: consider adding an explicit lifetime bound...
19+
|
20+
LL | impl<K: 'a> Nested<K> {
21+
| ++++
22+
23+
error[E0309]: the parameter type `M` may not live long enough
24+
--> $DIR/lifetime-doesnt-live-long-enough.rs:44:36
25+
|
26+
LL | fn generic_in_child<'a, 'b, L: X<&'a Nested<M>>, M: 'b>() {
27+
| ^^^^^^^^^^^^^^^^ ...so that the reference type `&'a Nested<M>` does not outlive the data it points at
28+
|
29+
help: consider adding an explicit lifetime bound...
30+
|
31+
LL | fn generic_in_child<'a, 'b, L: X<&'a Nested<M>>, M: 'b + 'a>() {
32+
| ++++
33+
1234
error[E0309]: the parameter type `K` may not live long enough
1335
--> $DIR/lifetime-doesnt-live-long-enough.rs:24:19
1436
|
@@ -40,28 +62,6 @@ help: consider adding an explicit lifetime bound...
4062
LL | fn baz<'a, L: 'a, M: X<&'a Nested<L>>>() {
4163
| ++++
4264

43-
error[E0309]: the parameter type `K` may not live long enough
44-
--> $DIR/lifetime-doesnt-live-long-enough.rs:41:33
45-
|
46-
LL | fn generic_in_parent<'a, L: X<&'a Nested<K>>>() {
47-
| ^^^^^^^^^^^^^^^^ ...so that the reference type `&'a Nested<K>` does not outlive the data it points at
48-
|
49-
help: consider adding an explicit lifetime bound...
50-
|
51-
LL | impl<K: 'a> Nested<K> {
52-
| ++++
53-
54-
error[E0309]: the parameter type `M` may not live long enough
55-
--> $DIR/lifetime-doesnt-live-long-enough.rs:44:36
56-
|
57-
LL | fn generic_in_child<'a, 'b, L: X<&'a Nested<M>>, M: 'b>() {
58-
| ^^^^^^^^^^^^^^^^ ...so that the reference type `&'a Nested<M>` does not outlive the data it points at
59-
|
60-
help: consider adding an explicit lifetime bound...
61-
|
62-
LL | fn generic_in_child<'a, 'b, L: X<&'a Nested<M>>, M: 'b + 'a>() {
63-
| ++++
64-
6565
error: aborting due to 6 previous errors
6666

6767
Some errors have detailed explanations: E0309, E0310.

‎src/test/ui/suggestions/adt-param-with-implicit-sized-bound.stderr

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
error[E0277]: the size for values of type `T` cannot be known at compilation time
2+
--> $DIR/adt-param-with-implicit-sized-bound.rs:25:9
3+
|
4+
LL | struct Struct5<T: ?Sized>{
5+
| - this type parameter needs to be `std::marker::Sized`
6+
LL | _t: X<T>,
7+
| ^^^^ doesn't have a size known at compile-time
8+
|
9+
note: required by a bound in `X`
10+
--> $DIR/adt-param-with-implicit-sized-bound.rs:18:10
11+
|
12+
LL | struct X<T>(T);
13+
| ^ required by this bound in `X`
14+
help: you could relax the implicit `Sized` bound on `T` if it were used through indirection like `&T` or `Box<T>`
15+
--> $DIR/adt-param-with-implicit-sized-bound.rs:18:10
16+
|
17+
LL | struct X<T>(T);
18+
| ^ - ...if indirection were used here: `Box<T>`
19+
| |
20+
| this could be changed to `T: ?Sized`...
21+
help: consider removing the `?Sized` bound to make the type parameter `Sized`
22+
|
23+
LL - struct Struct5<T: ?Sized>{
24+
LL + struct Struct5<T>{
25+
|
26+
127
error[E0277]: the size for values of type `Self` cannot be known at compilation time
228
--> $DIR/adt-param-with-implicit-sized-bound.rs:2:19
329
|
@@ -81,32 +107,6 @@ help: consider relaxing the implicit `Sized` restriction
81107
LL | struct Struct4<T: ?Sized>{
82108
| ++++++++
83109

84-
error[E0277]: the size for values of type `T` cannot be known at compilation time
85-
--> $DIR/adt-param-with-implicit-sized-bound.rs:25:9
86-
|
87-
LL | struct Struct5<T: ?Sized>{
88-
| - this type parameter needs to be `std::marker::Sized`
89-
LL | _t: X<T>,
90-
| ^^^^ doesn't have a size known at compile-time
91-
|
92-
note: required by a bound in `X`
93-
--> $DIR/adt-param-with-implicit-sized-bound.rs:18:10
94-
|
95-
LL | struct X<T>(T);
96-
| ^ required by this bound in `X`
97-
help: you could relax the implicit `Sized` bound on `T` if it were used through indirection like `&T` or `Box<T>`
98-
--> $DIR/adt-param-with-implicit-sized-bound.rs:18:10
99-
|
100-
LL | struct X<T>(T);
101-
| ^ - ...if indirection were used here: `Box<T>`
102-
| |
103-
| this could be changed to `T: ?Sized`...
104-
help: consider removing the `?Sized` bound to make the type parameter `Sized`
105-
|
106-
LL - struct Struct5<T: ?Sized>{
107-
LL + struct Struct5<T>{
108-
|
109-
110110
error: aborting due to 5 previous errors
111111

112112
For more information about this error, try `rustc --explain E0277`.

‎src/test/ui/suggestions/object-unsafe-trait-should-use-where-sized.stderr

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
error[E0307]: invalid `self` parameter type: ()
2-
--> $DIR/object-unsafe-trait-should-use-where-sized.rs:6:18
3-
|
4-
LL | fn bar(self: ()) {}
5-
| ^^
6-
|
7-
= note: type of `self` must be `Self` or a type that dereferences to it
8-
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
9-
101
error[E0038]: the trait `Trait` cannot be made into an object
112
--> $DIR/object-unsafe-trait-should-use-where-sized.rs:9:12
123
|
@@ -35,6 +26,15 @@ help: consider changing method `bar`'s `self` parameter to be `&self`
3526
LL | fn bar(self: &Self) {}
3627
| ~~~~~
3728

29+
error[E0307]: invalid `self` parameter type: ()
30+
--> $DIR/object-unsafe-trait-should-use-where-sized.rs:6:18
31+
|
32+
LL | fn bar(self: ()) {}
33+
| ^^
34+
|
35+
= note: type of `self` must be `Self` or a type that dereferences to it
36+
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
37+
3838
error: aborting due to 2 previous errors
3939

4040
Some errors have detailed explanations: E0038, E0307.

0 commit comments

Comments
 (0)
Please sign in to comment.