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 fd9ef69

Browse files
committedOct 20, 2023
Avoid a track_errors by bubbling up most errors from check_well_formed
1 parent 7849162 commit fd9ef69

33 files changed

+337
-305
lines changed
 

‎compiler/rustc_data_structures/src/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub use worker_local::{Registry, WorkerLocal};
5454
mod parallel;
5555
#[cfg(parallel_compiler)]
5656
pub use parallel::scope;
57-
pub use parallel::{join, par_for_each_in, par_map, parallel_guard};
57+
pub use parallel::{join, par_for_each_in, par_map, parallel_guard, try_par_for_each_in};
5858

5959
pub use std::sync::atomic::Ordering;
6060
pub use std::sync::atomic::Ordering::SeqCst;

‎compiler/rustc_data_structures/src/sync/parallel.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ mod disabled {
7777
})
7878
}
7979

80+
pub fn try_par_for_each_in<T: IntoIterator, E: Copy>(
81+
t: T,
82+
mut for_each: impl FnMut(T::Item) -> Result<(), E>,
83+
) -> Result<(), E> {
84+
parallel_guard(|guard| {
85+
t.into_iter().fold(Ok(()), |ret, i| guard.run(|| for_each(i)).unwrap_or(ret).and(ret))
86+
})
87+
}
88+
8089
pub fn par_map<T: IntoIterator, R, C: FromIterator<R>>(
8190
t: T,
8291
mut map: impl FnMut(<<T as IntoIterator>::IntoIter as Iterator>::Item) -> R,
@@ -167,6 +176,26 @@ mod enabled {
167176
});
168177
}
169178

179+
pub fn try_par_for_each_in<
180+
T: IntoIterator + IntoParallelIterator<Item = <T as IntoIterator>::Item>,
181+
E: Copy + Send,
182+
>(
183+
t: T,
184+
for_each: impl Fn(<T as IntoIterator>::Item) -> Result<(), E> + DynSync + DynSend,
185+
) -> Result<(), E> {
186+
parallel_guard(|guard| {
187+
if mode::is_dyn_thread_safe() {
188+
let for_each = FromDyn::from(for_each);
189+
t.into_par_iter()
190+
.fold_with(Ok(()), |ret, i| guard.run(|| for_each(i)).unwrap_or(ret).and(ret))
191+
.reduce(|| Ok(()), |a, b| a.and(b))
192+
} else {
193+
t.into_iter()
194+
.fold(Ok(()), |ret, i| guard.run(|| for_each(i)).unwrap_or(ret).and(ret))
195+
}
196+
})
197+
}
198+
170199
pub fn par_map<
171200
I,
172201
T: IntoIterator<Item = I> + IntoParallelIterator<Item = I>,

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

Lines changed: 124 additions & 106 deletions
Large diffs are not rendered by default.

‎compiler/rustc_hir_analysis/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,8 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
205205
})?;
206206
}
207207

208-
tcx.sess.track_errors(|| {
209-
tcx.sess.time("wf_checking", || {
210-
tcx.hir().par_for_each_module(|module| tcx.ensure().check_mod_type_wf(module))
211-
});
208+
tcx.sess.time("wf_checking", || {
209+
tcx.hir().try_par_for_each_module(|module| tcx.check_mod_type_wf(module))
212210
})?;
213211

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

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_ast as ast;
66
use rustc_data_structures::fingerprint::Fingerprint;
77
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
88
use rustc_data_structures::svh::Svh;
9-
use rustc_data_structures::sync::{par_for_each_in, DynSend, DynSync};
9+
use rustc_data_structures::sync::{par_for_each_in, try_par_for_each_in, DynSend, DynSync};
1010
use rustc_hir::def::{DefKind, Res};
1111
use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId, LOCAL_CRATE};
1212
use rustc_hir::definitions::{DefKey, DefPath, DefPathData, DefPathHash};
@@ -16,7 +16,7 @@ use rustc_index::Idx;
1616
use rustc_middle::hir::nested_filter;
1717
use rustc_span::def_id::StableCrateId;
1818
use rustc_span::symbol::{kw, sym, Ident, Symbol};
19-
use rustc_span::Span;
19+
use rustc_span::{ErrorGuaranteed, Span};
2020
use rustc_target::spec::abi::Abi;
2121

2222
#[inline]
@@ -632,6 +632,17 @@ impl<'hir> Map<'hir> {
632632
})
633633
}
634634

635+
#[inline]
636+
pub fn try_par_for_each_module(
637+
self,
638+
f: impl Fn(LocalModDefId) -> Result<(), ErrorGuaranteed> + DynSend + DynSync,
639+
) -> Result<(), ErrorGuaranteed> {
640+
let crate_items = self.tcx.hir_crate_items(());
641+
try_par_for_each_in(&crate_items.submodules[..], |module| {
642+
f(LocalModDefId::new_unchecked(module.def_id))
643+
})
644+
}
645+
635646
/// Returns an iterator for the nodes in the ancestor tree of the `current_id`
636647
/// until the crate root is reached. Prefer this over your own loop using `parent_id`.
637648
#[inline]

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

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ pub mod place;
99
use crate::query::Providers;
1010
use crate::ty::{EarlyBinder, ImplSubject, TyCtxt};
1111
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
12-
use rustc_data_structures::sync::{par_for_each_in, DynSend, DynSync};
12+
use rustc_data_structures::sync::{try_par_for_each_in, DynSend, DynSync};
1313
use rustc_hir::def::DefKind;
1414
use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId};
1515
use rustc_hir::*;
1616
use rustc_query_system::ich::StableHashingContext;
17-
use rustc_span::{ExpnId, DUMMY_SP};
17+
use rustc_span::{ErrorGuaranteed, ExpnId, DUMMY_SP};
1818

1919
/// Top-level HIR node for current owner. This only contains the node for which
2020
/// `HirId::local_id == 0`, and excludes bodies.
@@ -78,20 +78,32 @@ impl ModuleItems {
7878
self.owners().map(|id| id.def_id)
7979
}
8080

81-
pub fn par_items(&self, f: impl Fn(ItemId) + DynSend + DynSync) {
82-
par_for_each_in(&self.items[..], |&id| f(id))
81+
pub fn par_items(
82+
&self,
83+
f: impl Fn(ItemId) -> Result<(), ErrorGuaranteed> + DynSend + DynSync,
84+
) -> Result<(), ErrorGuaranteed> {
85+
try_par_for_each_in(&self.items[..], |&id| f(id))
8386
}
8487

85-
pub fn par_trait_items(&self, f: impl Fn(TraitItemId) + DynSend + DynSync) {
86-
par_for_each_in(&self.trait_items[..], |&id| f(id))
88+
pub fn par_trait_items(
89+
&self,
90+
f: impl Fn(TraitItemId) -> Result<(), ErrorGuaranteed> + DynSend + DynSync,
91+
) -> Result<(), ErrorGuaranteed> {
92+
try_par_for_each_in(&self.trait_items[..], |&id| f(id))
8793
}
8894

89-
pub fn par_impl_items(&self, f: impl Fn(ImplItemId) + DynSend + DynSync) {
90-
par_for_each_in(&self.impl_items[..], |&id| f(id))
95+
pub fn par_impl_items(
96+
&self,
97+
f: impl Fn(ImplItemId) -> Result<(), ErrorGuaranteed> + DynSend + DynSync,
98+
) -> Result<(), ErrorGuaranteed> {
99+
try_par_for_each_in(&self.impl_items[..], |&id| f(id))
91100
}
92101

93-
pub fn par_foreign_items(&self, f: impl Fn(ForeignItemId) + DynSend + DynSync) {
94-
par_for_each_in(&self.foreign_items[..], |&id| f(id))
102+
pub fn par_foreign_items(
103+
&self,
104+
f: impl Fn(ForeignItemId) -> Result<(), ErrorGuaranteed> + DynSend + DynSync,
105+
) -> Result<(), ErrorGuaranteed> {
106+
try_par_for_each_in(&self.foreign_items[..], |&id| f(id))
95107
}
96108
}
97109

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ rustc_queries! {
965965
desc { |tcx| "checking that impls are well-formed in {}", describe_as_module(key, tcx) }
966966
}
967967

968-
query check_mod_type_wf(key: LocalModDefId) -> () {
968+
query check_mod_type_wf(key: LocalModDefId) -> Result<(), ErrorGuaranteed> {
969969
desc { |tcx| "checking that types are well-formed in {}", describe_as_module(key, tcx) }
970970
}
971971

@@ -1499,7 +1499,7 @@ rustc_queries! {
14991499
feedable
15001500
}
15011501

1502-
query check_well_formed(key: hir::OwnerId) -> () {
1502+
query check_well_formed(key: hir::OwnerId) -> Result<(), ErrorGuaranteed> {
15031503
desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key) }
15041504
}
15051505

‎src/tools/clippy/tests/ui/crashes/ice-6252.stderr

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,6 @@ help: you might be missing a type parameter
2424
LL | impl<N, M, VAL> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
2525
| +++++
2626

27-
error[E0046]: not all trait items implemented, missing: `VAL`
28-
--> $DIR/ice-6252.rs:11:1
29-
|
30-
LL | const VAL: T;
31-
| ------------ `VAL` from trait
32-
...
33-
LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
34-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `VAL` in implementation
35-
36-
error: aborting due to 3 previous errors
27+
error: aborting due to 2 previous errors
3728

38-
Some errors have detailed explanations: E0046, E0412.
39-
For more information about an error, try `rustc --explain E0046`.
29+
For more information about this error, try `rustc --explain E0412`.

‎tests/ui/associated-consts/issue-105330.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,10 @@ impl TraitWAssocConst for impl Demo { //~ ERROR E0404
99
}
1010

1111
fn foo<A: TraitWAssocConst<A=32>>() { //~ ERROR E0658
12-
foo::<Demo>()(); //~ ERROR E0271
13-
//~^ ERROR E0618
14-
//~| ERROR E0277
12+
foo::<Demo>()();
1513
}
1614

17-
fn main<A: TraitWAssocConst<A=32>>() { //~ ERROR E0131
15+
fn main<A: TraitWAssocConst<A=32>>() {
1816
//~^ ERROR E0658
19-
foo::<Demo>(); //~ ERROR E0277
20-
//~^ ERROR E0271
17+
foo::<Demo>();
2118
}

‎tests/ui/associated-consts/issue-105330.stderr

Lines changed: 4 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ LL | fn foo<A: TraitWAssocConst<A=32>>() {
2525
= help: add `#![feature(associated_const_equality)]` to the crate attributes to enable
2626

2727
error[E0658]: associated const equality is incomplete
28-
--> $DIR/issue-105330.rs:17:29
28+
--> $DIR/issue-105330.rs:15:29
2929
|
3030
LL | fn main<A: TraitWAssocConst<A=32>>() {
3131
| ^^^^
@@ -39,85 +39,7 @@ error[E0562]: `impl Trait` only allowed in function and inherent method argument
3939
LL | impl TraitWAssocConst for impl Demo {
4040
| ^^^^^^^^^
4141

42-
error[E0131]: `main` function is not allowed to have generic parameters
43-
--> $DIR/issue-105330.rs:17:8
44-
|
45-
LL | fn main<A: TraitWAssocConst<A=32>>() {
46-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `main` cannot have generic parameters
47-
48-
error[E0277]: the trait bound `Demo: TraitWAssocConst` is not satisfied
49-
--> $DIR/issue-105330.rs:12:11
50-
|
51-
LL | foo::<Demo>()();
52-
| ^^^^ the trait `TraitWAssocConst` is not implemented for `Demo`
53-
|
54-
help: this trait has no implementations, consider adding one
55-
--> $DIR/issue-105330.rs:1:1
56-
|
57-
LL | pub trait TraitWAssocConst {
58-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
59-
note: required by a bound in `foo`
60-
--> $DIR/issue-105330.rs:11:11
61-
|
62-
LL | fn foo<A: TraitWAssocConst<A=32>>() {
63-
| ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `foo`
64-
65-
error[E0271]: type mismatch resolving `<Demo as TraitWAssocConst>::A == 32`
66-
--> $DIR/issue-105330.rs:12:11
67-
|
68-
LL | foo::<Demo>()();
69-
| ^^^^ expected `32`, found `<Demo as TraitWAssocConst>::A`
70-
|
71-
= note: expected constant `32`
72-
found constant `<Demo as TraitWAssocConst>::A`
73-
note: required by a bound in `foo`
74-
--> $DIR/issue-105330.rs:11:28
75-
|
76-
LL | fn foo<A: TraitWAssocConst<A=32>>() {
77-
| ^^^^ required by this bound in `foo`
78-
79-
error[E0618]: expected function, found `()`
80-
--> $DIR/issue-105330.rs:12:5
81-
|
82-
LL | fn foo<A: TraitWAssocConst<A=32>>() {
83-
| ----------------------------------- `foo::<Demo>` defined here returns `()`
84-
LL | foo::<Demo>()();
85-
| ^^^^^^^^^^^^^--
86-
| |
87-
| call expression requires function
88-
89-
error[E0277]: the trait bound `Demo: TraitWAssocConst` is not satisfied
90-
--> $DIR/issue-105330.rs:19:11
91-
|
92-
LL | foo::<Demo>();
93-
| ^^^^ the trait `TraitWAssocConst` is not implemented for `Demo`
94-
|
95-
help: this trait has no implementations, consider adding one
96-
--> $DIR/issue-105330.rs:1:1
97-
|
98-
LL | pub trait TraitWAssocConst {
99-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
100-
note: required by a bound in `foo`
101-
--> $DIR/issue-105330.rs:11:11
102-
|
103-
LL | fn foo<A: TraitWAssocConst<A=32>>() {
104-
| ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `foo`
105-
106-
error[E0271]: type mismatch resolving `<Demo as TraitWAssocConst>::A == 32`
107-
--> $DIR/issue-105330.rs:19:11
108-
|
109-
LL | foo::<Demo>();
110-
| ^^^^ expected `32`, found `<Demo as TraitWAssocConst>::A`
111-
|
112-
= note: expected constant `32`
113-
found constant `<Demo as TraitWAssocConst>::A`
114-
note: required by a bound in `foo`
115-
--> $DIR/issue-105330.rs:11:28
116-
|
117-
LL | fn foo<A: TraitWAssocConst<A=32>>() {
118-
| ^^^^ required by this bound in `foo`
119-
120-
error: aborting due to 11 previous errors
42+
error: aborting due to 5 previous errors
12143

122-
Some errors have detailed explanations: E0131, E0271, E0277, E0404, E0562, E0618, E0658.
123-
For more information about an error, try `rustc --explain E0131`.
44+
Some errors have detailed explanations: E0404, E0562, E0658.
45+
For more information about an error, try `rustc --explain E0404`.

‎tests/ui/associated-consts/issue-58022.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ impl Bar<[u8]> {
1111
const SIZE: usize = 32;
1212

1313
fn new(slice: &[u8; Self::SIZE]) -> Self {
14+
//~^ ERROR: the size for values of type `[u8]` cannot be known at compilation time
1415
Foo(Box::new(*slice))
1516
//~^ ERROR: expected function, tuple struct or tuple variant, found trait `Foo`
1617
}

‎tests/ui/associated-consts/issue-58022.stderr

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,27 @@ LL |
77
LL | fn new(slice: &[u8; Foo::SIZE]) -> Self;
88
| ^^^^^^^^^ cannot refer to the associated constant of trait
99

10+
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
11+
--> $DIR/issue-58022.rs:13:41
12+
|
13+
LL | fn new(slice: &[u8; Self::SIZE]) -> Self {
14+
| ^^^^ doesn't have a size known at compile-time
15+
|
16+
= help: within `Bar<[u8]>`, the trait `Sized` is not implemented for `[u8]`
17+
note: required because it appears within the type `Bar<[u8]>`
18+
--> $DIR/issue-58022.rs:8:12
19+
|
20+
LL | pub struct Bar<T: ?Sized>(T);
21+
| ^^^
22+
= note: the return type of a function must have a statically known size
23+
1024
error[E0423]: expected function, tuple struct or tuple variant, found trait `Foo`
11-
--> $DIR/issue-58022.rs:14:9
25+
--> $DIR/issue-58022.rs:15:9
1226
|
1327
LL | Foo(Box::new(*slice))
1428
| ^^^ not a function, tuple struct or tuple variant
1529

16-
error: aborting due to 2 previous errors
30+
error: aborting due to 3 previous errors
1731

18-
Some errors have detailed explanations: E0423, E0790.
19-
For more information about an error, try `rustc --explain E0423`.
32+
Some errors have detailed explanations: E0277, E0423, E0790.
33+
For more information about an error, try `rustc --explain E0277`.

‎tests/ui/async-await/issue-66312.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ trait Test<T> {
66

77
async fn f() {
88
let x = Some(2);
9-
if x.is_some() {
9+
if x.is_some() { //~ ERROR mismatched types
1010
println!("Some");
1111
}
1212
}

‎tests/ui/async-await/issue-66312.stderr

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ LL | fn is_some(self: T);
77
= note: type of `self` must be `Self` or a type that dereferences to it
88
= 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`)
99

10-
error: aborting due to previous error
10+
error[E0308]: mismatched types
11+
--> $DIR/issue-66312.rs:9:8
12+
|
13+
LL | if x.is_some() {
14+
| ^^^^^^^^^^^ expected `bool`, found `()`
15+
16+
error: aborting due to 2 previous errors
1117

12-
For more information about this error, try `rustc --explain E0307`.
18+
Some errors have detailed explanations: E0307, E0308.
19+
For more information about an error, try `rustc --explain E0307`.

‎tests/ui/const-generics/generic_arg_infer/infer-arg-test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn bad_infer_fn<_>() {}
1515

1616

1717
fn main() {
18-
let a: All<_, _, _>;
18+
let a: All<_, _, _>; //~ ERROR struct takes 2 generic arguments but 3
1919
all_fn();
2020
let v: [u8; _];
2121
let v: [u8; 10] = [0; _];

‎tests/ui/const-generics/generic_arg_infer/infer-arg-test.stderr

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@ LL | struct BadInfer<_>;
1919
= help: consider removing `_`, referring to it in a field, or using a marker such as `PhantomData`
2020
= help: if you intended `_` to be a const parameter, use `const _: usize` instead
2121

22-
error: aborting due to 3 previous errors
22+
error[E0107]: struct takes 2 generic arguments but 3 generic arguments were supplied
23+
--> $DIR/infer-arg-test.rs:18:10
24+
|
25+
LL | let a: All<_, _, _>;
26+
| ^^^ - help: remove this generic argument
27+
| |
28+
| expected 2 generic arguments
29+
|
30+
note: struct defined here, with 2 generic parameters: `T`, `N`
31+
--> $DIR/infer-arg-test.rs:3:8
32+
|
33+
LL | struct All<'a, T, const N: usize> {
34+
| ^^^ - --------------
35+
36+
error: aborting due to 4 previous errors
2337

24-
For more information about this error, try `rustc --explain E0392`.
38+
Some errors have detailed explanations: E0107, E0392.
39+
For more information about an error, try `rustc --explain E0107`.

‎tests/ui/consts/issue-39974.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const LENGTH: f64 = 2;
2+
//~^ ERROR mismatched types
23

34
struct Thing {
45
f: [[f64; 2]; LENGTH],

‎tests/ui/consts/issue-39974.stderr

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
error[E0308]: mismatched types
2-
--> $DIR/issue-39974.rs:4:19
2+
--> $DIR/issue-39974.rs:5:19
33
|
44
LL | f: [[f64; 2]; LENGTH],
55
| ^^^^^^ expected `usize`, found `f64`
66

7-
error: aborting due to previous error
7+
error[E0308]: mismatched types
8+
--> $DIR/issue-39974.rs:1:21
9+
|
10+
LL | const LENGTH: f64 = 2;
11+
| ^
12+
| |
13+
| expected `f64`, found integer
14+
| help: use a float literal: `2.0`
15+
16+
error: aborting due to 2 previous errors
817

918
For more information about this error, try `rustc --explain E0308`.

‎tests/ui/generic-associated-types/issue-86787.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ where
2222
type T = Either<Left::T, Right::T>;
2323
type TRef<'a> = Either<&'a Left::T, &'a Right::T>
2424
where
25-
<Left as HasChildrenOf>::T: 'a,
26-
<Right as HasChildrenOf>::T: 'a;
25+
<Left as HasChildrenOf>::T: 'a, //~ ERROR impl has stricter requirements than trait
26+
<Right as HasChildrenOf>::T: 'a; //~ ERROR impl has stricter requirements than trait
2727

2828
fn ref_children<'a>(&'a self) -> Vec<Self::TRef<'a>> {
2929
todo!()

‎tests/ui/generic-associated-types/issue-86787.stderr

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,24 @@ LL | type TRef<'a>;
99
= note: this bound is currently required to ensure that impls have maximum flexibility
1010
= note: we are soliciting feedback, see issue #87479 <https://github.com/rust-lang/rust/issues/87479> for more information
1111

12-
error: aborting due to previous error
12+
error[E0276]: impl has stricter requirements than trait
13+
--> $DIR/issue-86787.rs:25:37
14+
|
15+
LL | type TRef<'a>;
16+
| ------------- definition of `TRef` from trait
17+
...
18+
LL | <Left as HasChildrenOf>::T: 'a,
19+
| ^^ impl has extra requirement `<Left as HasChildrenOf>::T: 'a`
20+
21+
error[E0276]: impl has stricter requirements than trait
22+
--> $DIR/issue-86787.rs:26:38
23+
|
24+
LL | type TRef<'a>;
25+
| ------------- definition of `TRef` from trait
26+
...
27+
LL | <Right as HasChildrenOf>::T: 'a;
28+
| ^^ impl has extra requirement `<Right as HasChildrenOf>::T: 'a`
29+
30+
error: aborting due to 3 previous errors
1331

32+
For more information about this error, try `rustc --explain E0276`.

‎tests/ui/inference/issue-107090.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use std::marker::PhantomData;
22
struct Foo<'a, 'b, T>(PhantomData<(&'a (), &'b (), T)>)
33
where
44
Foo<'short, 'out, T>: Convert<'a, 'b>;
5-
//~^ ERROR use of undeclared lifetime name
6-
//~| ERROR use of undeclared lifetime name `'out`
5+
//~^ ERROR use of undeclared lifetime name
6+
//~| ERROR use of undeclared lifetime name `'out`
77

88
trait Convert<'a, 'b>: Sized {
99
fn cast(&'a self) -> &'b Self;
@@ -19,7 +19,7 @@ impl<'long: 'short, 'short, T> Convert<'long, 'b> for Foo<'short, 'out, T> {
1919

2020
fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ Foo<'short, 'out, T>) -> &'out T {
2121
//~^ ERROR use of undeclared lifetime name
22-
sadness.cast() //~ ERROR mismatched types
22+
sadness.cast()
2323
}
2424

2525
fn main() {}

‎tests/ui/inference/issue-107090.stderr

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,6 @@ LL | fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ Foo<'short,
6666
| |
6767
| help: consider introducing lifetime `'short` here: `'short,`
6868

69-
error[E0308]: mismatched types
70-
--> $DIR/issue-107090.rs:22:5
71-
|
72-
LL | fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ Foo<'short, 'out, T>) -> &'out T {
73-
| - expected this type parameter ------- expected `&'out T` because of return type
74-
LL |
75-
LL | sadness.cast()
76-
| ^^^^^^^^^^^^^^ expected `&T`, found `&Foo<'_, '_, T>`
77-
|
78-
= note: expected reference `&'out T`
79-
found reference `&Foo<'_, '_, T>`
80-
81-
error: aborting due to 7 previous errors
69+
error: aborting due to 6 previous errors
8270

83-
Some errors have detailed explanations: E0261, E0308.
84-
For more information about an error, try `rustc --explain E0261`.
71+
For more information about this error, try `rustc --explain E0261`.

‎tests/ui/infinite/infinite-struct.stderr

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
2222
LL | x: Bar<Box<Foo>>,
2323
| ++++ +
2424

25-
error: aborting due to 2 previous errors
25+
error: reached the recursion limit finding the struct tail for `Take`
26+
|
27+
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
28+
29+
error: aborting due to 3 previous errors
2630

2731
For more information about this error, try `rustc --explain E0072`.

‎tests/ui/issues/issue-77919.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ struct Multiply<N, M> {
1010
}
1111
impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
1212
//~^ ERROR cannot find type `VAL` in this scope
13-
//~| ERROR not all trait items implemented, missing: `VAL`

‎tests/ui/issues/issue-77919.stderr

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,6 @@ help: you might be missing a type parameter
2020
LL | impl<N, M, VAL> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
2121
| +++++
2222

23-
error[E0046]: not all trait items implemented, missing: `VAL`
24-
--> $DIR/issue-77919.rs:11:1
25-
|
26-
LL | const VAL: T;
27-
| ------------ `VAL` from trait
28-
...
29-
LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
30-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `VAL` in implementation
31-
32-
error: aborting due to 3 previous errors
23+
error: aborting due to 2 previous errors
3324

34-
Some errors have detailed explanations: E0046, E0412.
35-
For more information about an error, try `rustc --explain E0046`.
25+
For more information about this error, try `rustc --explain E0412`.

‎tests/ui/layout/cannot-transmute-unnormalizable-type.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ struct Other {
1616

1717
fn main() {
1818
unsafe {
19+
// FIXME(oli-obk): make this report a transmute error again.
1920
std::mem::transmute::<Option<()>, Option<&Other>>(None);
20-
//~^ ERROR cannot transmute between types of different sizes, or dependently-sized types
21+
//^ ERROR cannot transmute between types of different sizes, or dependently-sized types
2122
}
2223
}

‎tests/ui/layout/cannot-transmute-unnormalizable-type.stderr

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,6 @@ error[E0412]: cannot find type `Missing` in this scope
44
LL | Missing: Trait,
55
| ^^^^^^^ not found in this scope
66

7-
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
8-
--> $DIR/cannot-transmute-unnormalizable-type.rs:19:9
9-
|
10-
LL | std::mem::transmute::<Option<()>, Option<&Other>>(None);
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12-
|
13-
= note: source type: `Option<()>` (8 bits)
14-
= note: target type: `Option<&Other>` (unable to determine layout for `Other` because `<() as Trait>::RefTarget` cannot be normalized)
15-
16-
error: aborting due to 2 previous errors
7+
error: aborting due to previous error
178

18-
Some errors have detailed explanations: E0412, E0512.
19-
For more information about an error, try `rustc --explain E0412`.
9+
For more information about this error, try `rustc --explain E0412`.

‎tests/ui/parser/variadic-ffi-nested-syntactic-fail.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@ fn f2<'a>(x: u8, y: Vec<&'a ...>) {}
55
//~^ ERROR C-variadic type `...` may not be nested inside another type
66

77
fn main() {
8-
let _recovery_witness: () = 0; //~ ERROR mismatched types
8+
// While this is an error, wf-checks happen before typeck, and if any wf-checks
9+
// encountered errors, we do not continue to typeck, even if the items are
10+
// unrelated.
11+
// FIXME(oli-obk): make this report a type mismatch again.
12+
let _recovery_witness: () = 0;
913
}

‎tests/ui/parser/variadic-ffi-nested-syntactic-fail.stderr

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,6 @@ error[E0743]: C-variadic type `...` may not be nested inside another type
1010
LL | fn f2<'a>(x: u8, y: Vec<&'a ...>) {}
1111
| ^^^
1212

13-
error[E0308]: mismatched types
14-
--> $DIR/variadic-ffi-nested-syntactic-fail.rs:8:33
15-
|
16-
LL | let _recovery_witness: () = 0;
17-
| -- ^ expected `()`, found integer
18-
| |
19-
| expected due to this
20-
21-
error: aborting due to 3 previous errors
13+
error: aborting due to 2 previous errors
2214

23-
Some errors have detailed explanations: E0308, E0743.
24-
For more information about an error, try `rustc --explain E0308`.
15+
For more information about this error, try `rustc --explain E0743`.

‎tests/ui/self/self_type_keyword.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ pub fn main() {
2222
//~^ ERROR cannot find macro `Self` in this scope
2323
Foo { Self } => (),
2424
//~^ ERROR expected identifier, found keyword `Self`
25+
//~| ERROR mismatched types
26+
//~| ERROR `Foo` does not have a field named `Self`
2527
}
2628
}
2729

‎tests/ui/self/self_type_keyword.stderr

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@ LL | Foo { Self } => (),
3131
| ^^^^ expected identifier, found keyword
3232

3333
error: expected identifier, found keyword `Self`
34-
--> $DIR/self_type_keyword.rs:29:26
34+
--> $DIR/self_type_keyword.rs:31:26
3535
|
3636
LL | extern crate core as Self;
3737
| ^^^^ expected identifier, found keyword
3838

3939
error: expected identifier, found keyword `Self`
40-
--> $DIR/self_type_keyword.rs:34:32
40+
--> $DIR/self_type_keyword.rs:36:32
4141
|
4242
LL | use std::option::Option as Self;
4343
| ^^^^ expected identifier, found keyword
4444

4545
error: expected identifier, found keyword `Self`
46-
--> $DIR/self_type_keyword.rs:39:11
46+
--> $DIR/self_type_keyword.rs:41:11
4747
|
4848
LL | trait Self {}
4949
| ^^^^ expected identifier, found keyword
@@ -80,7 +80,22 @@ LL | struct Bar<'Self>;
8080
|
8181
= help: consider removing `'Self`, referring to it in a field, or using a marker such as `PhantomData`
8282

83-
error: aborting due to 12 previous errors
83+
error[E0308]: mismatched types
84+
--> $DIR/self_type_keyword.rs:23:9
85+
|
86+
LL | match 15 {
87+
| -- this expression has type `{integer}`
88+
...
89+
LL | Foo { Self } => (),
90+
| ^^^^^^^^^^^^ expected integer, found `Foo`
91+
92+
error[E0026]: struct `Foo` does not have a field named `Self`
93+
--> $DIR/self_type_keyword.rs:23:15
94+
|
95+
LL | Foo { Self } => (),
96+
| ^^^^ struct `Foo` does not have this field
97+
98+
error: aborting due to 14 previous errors
8499

85-
Some errors have detailed explanations: E0392, E0531.
86-
For more information about an error, try `rustc --explain E0392`.
100+
Some errors have detailed explanations: E0026, E0308, E0392, E0531.
101+
For more information about an error, try `rustc --explain E0026`.

‎tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
trait Trait {
8-
fn func<const N: u32>() -> [ (); N ];
8+
fn func<const N: u32>() -> [ (); N ]; //~ ERROR mismatched types
99
}
1010

1111
struct S {}

‎tests/ui/typeck/issue-114918/const-in-impl-fn-return-type.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ error[E0308]: mismatched types
44
LL | fn func<const N: u32>() -> [ (); { () }] {
55
| ^^ expected `usize`, found `()`
66

7-
error: aborting due to previous error
7+
error[E0308]: mismatched types
8+
--> $DIR/const-in-impl-fn-return-type.rs:8:38
9+
|
10+
LL | fn func<const N: u32>() -> [ (); N ];
11+
| ^ expected `usize`, found `u32`
12+
13+
error: aborting due to 2 previous errors
814

915
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)
Please sign in to comment.