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 702bd6d

Browse files
committedMar 8, 2024
Auto merge of #122140 - oli-obk:track_errors13, r=<try>
Run a single huge par_body_owners instead of many small ones after each other. This improves parallel rustc parallelism by avoiding the bottleneck after each individual `par_body_owners` (because it needs to wait for queries to finish, so if there is one long running one, a lot of cores will be idle while waiting for the single query). based on #121500
2 parents 74acabe + c531269 commit 702bd6d

33 files changed

+408
-432
lines changed
 

‎compiler/rustc_driver_impl/src/pretty.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,8 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
336336
ThirTree => {
337337
let tcx = ex.tcx();
338338
let mut out = String::new();
339-
if rustc_hir_analysis::check_crate(tcx).is_err() {
339+
rustc_hir_analysis::check_crate(tcx);
340+
if tcx.dcx().has_errors().is_some() {
340341
FatalError.raise();
341342
}
342343
debug!("pretty printing THIR tree");
@@ -348,7 +349,8 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
348349
ThirFlat => {
349350
let tcx = ex.tcx();
350351
let mut out = String::new();
351-
if rustc_hir_analysis::check_crate(tcx).is_err() {
352+
rustc_hir_analysis::check_crate(tcx);
353+
if tcx.dcx().has_errors().is_some() {
352354
FatalError.raise();
353355
}
354356
debug!("pretty printing THIR flat");

‎compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,20 @@ use rustc_hir::intravisit::{self, Visitor};
55
use rustc_hir::{self as hir, def, Expr, ImplItem, Item, Node, TraitItem};
66
use rustc_middle::hir::nested_filter;
77
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
8-
use rustc_span::{sym, ErrorGuaranteed, DUMMY_SP};
8+
use rustc_span::{sym, DUMMY_SP};
99

1010
use crate::errors::{TaitForwardCompat, TypeOf, UnconstrainedOpaqueType};
1111

12-
pub fn test_opaque_hidden_types(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
13-
let mut res = Ok(());
12+
pub fn test_opaque_hidden_types(tcx: TyCtxt<'_>) {
1413
if tcx.has_attr(CRATE_DEF_ID, sym::rustc_hidden_type_of_opaques) {
1514
for id in tcx.hir().items() {
1615
if matches!(tcx.def_kind(id.owner_id), DefKind::OpaqueTy) {
1716
let type_of = tcx.type_of(id.owner_id).instantiate_identity();
1817

19-
res = Err(tcx.dcx().emit_err(TypeOf { span: tcx.def_span(id.owner_id), type_of }));
18+
tcx.dcx().emit_err(TypeOf { span: tcx.def_span(id.owner_id), type_of });
2019
}
2120
}
2221
}
23-
res
2422
}
2523

2624
/// Checks "defining uses" of opaque `impl Trait` in associated types.

‎compiler/rustc_hir_analysis/src/lib.rs

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ mod outlives;
9898
pub mod structured_errors;
9999
mod variance;
100100

101-
use rustc_errors::ErrorGuaranteed;
102101
use rustc_hir as hir;
103102
use rustc_middle::middle;
104103
use rustc_middle::query::Providers;
@@ -156,11 +155,13 @@ pub fn provide(providers: &mut Providers) {
156155
hir_wf_check::provide(providers);
157156
}
158157

159-
pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
158+
pub fn check_crate(tcx: TyCtxt<'_>) {
160159
let _prof_timer = tcx.sess.timer("type_check_crate");
161160

162161
if tcx.features().rustc_attrs {
163-
tcx.sess.time("outlives_testing", || outlives::test::test_inferred_outlives(tcx))?;
162+
tcx.sess.time("outlives_testing", || outlives::test::test_inferred_outlives(tcx));
163+
tcx.sess.time("variance_testing", || variance::test::test_variance(tcx));
164+
collect::test_opaque_hidden_types(tcx);
164165
}
165166

166167
tcx.sess.time("coherence_checking", || {
@@ -176,14 +177,6 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
176177
let _ = tcx.ensure().crate_inherent_impls_overlap_check(());
177178
});
178179

179-
if tcx.features().rustc_attrs {
180-
tcx.sess.time("variance_testing", || variance::test::test_variance(tcx))?;
181-
}
182-
183-
if tcx.features().rustc_attrs {
184-
collect::test_opaque_hidden_types(tcx)?;
185-
}
186-
187180
// Make sure we evaluate all static and (non-associated) const items, even if unused.
188181
// If any of these fail to evaluate, we do not want this crate to pass compilation.
189182
tcx.hir().par_body_owners(|item_def_id| {
@@ -198,21 +191,6 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
198191
// Freeze definitions as we don't add new ones at this point. This improves performance by
199192
// allowing lock-free access to them.
200193
tcx.untracked().definitions.freeze();
201-
202-
// FIXME: Remove this when we implement creating `DefId`s
203-
// for anon constants during their parents' typeck.
204-
// Typeck all body owners in parallel will produce queries
205-
// cycle errors because it may typeck on anon constants directly.
206-
tcx.hir().par_body_owners(|item_def_id| {
207-
let def_kind = tcx.def_kind(item_def_id);
208-
if !matches!(def_kind, DefKind::AnonConst) {
209-
tcx.ensure().typeck(item_def_id);
210-
}
211-
});
212-
213-
tcx.ensure().check_unused_traits(());
214-
215-
Ok(())
216194
}
217195

218196
/// A quasi-deprecated helper used in rustdoc and clippy to get

‎compiler/rustc_hir_analysis/src/outlives/test.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use rustc_middle::ty::{self, TyCtxt};
2-
use rustc_span::{symbol::sym, ErrorGuaranteed};
2+
use rustc_span::symbol::sym;
33

4-
pub fn test_inferred_outlives(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
5-
let mut res = Ok(());
4+
pub fn test_inferred_outlives(tcx: TyCtxt<'_>) {
65
for id in tcx.hir().items() {
76
// For unit testing: check for a special "rustc_outlives"
87
// attribute and report an error with various results if found.
@@ -23,8 +22,7 @@ pub fn test_inferred_outlives(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
2322
for p in pred {
2423
err.note(p);
2524
}
26-
res = Err(err.emit());
25+
err.emit();
2726
}
2827
}
29-
res
3028
}

‎compiler/rustc_hir_analysis/src/variance/test.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,19 @@ use rustc_hir::def::DefKind;
22
use rustc_hir::def_id::CRATE_DEF_ID;
33
use rustc_middle::ty::TyCtxt;
44
use rustc_span::symbol::sym;
5-
use rustc_span::ErrorGuaranteed;
65

76
use crate::errors;
87

9-
pub fn test_variance(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
10-
let mut res = Ok(());
8+
pub fn test_variance(tcx: TyCtxt<'_>) {
119
if tcx.has_attr(CRATE_DEF_ID, sym::rustc_variance_of_opaques) {
1210
for id in tcx.hir().items() {
1311
if matches!(tcx.def_kind(id.owner_id), DefKind::OpaqueTy) {
1412
let variances_of = tcx.variances_of(id.owner_id);
1513

16-
res = Err(tcx.dcx().emit_err(errors::VariancesOf {
14+
tcx.dcx().emit_err(errors::VariancesOf {
1715
span: tcx.def_span(id.owner_id),
1816
variances_of: format!("{variances_of:?}"),
19-
}));
17+
});
2018
}
2119
}
2220
}
@@ -27,11 +25,10 @@ pub fn test_variance(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
2725
if tcx.has_attr(id.owner_id, sym::rustc_variance) {
2826
let variances_of = tcx.variances_of(id.owner_id);
2927

30-
res = Err(tcx.dcx().emit_err(errors::VariancesOf {
28+
tcx.dcx().emit_err(errors::VariancesOf {
3129
span: tcx.def_span(id.owner_id),
3230
variances_of: format!("{variances_of:?}"),
33-
}));
31+
});
3432
}
3533
}
36-
res
3734
}

‎compiler/rustc_interface/src/passes.rs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -734,19 +734,22 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
734734
});
735735

736736
// passes are timed inside typeck
737-
rustc_hir_analysis::check_crate(tcx)?;
737+
rustc_hir_analysis::check_crate(tcx);
738738

739-
sess.time("MIR_borrow_checking", || {
739+
sess.time("typeck_and_mir_analyses", || {
740740
tcx.hir().par_body_owners(|def_id| {
741+
let def_kind = tcx.def_kind(def_id);
742+
// FIXME: Remove this when we implement creating `DefId`s
743+
// for anon constants during their parents' typeck.
744+
// Typeck all body owners in parallel will produce queries
745+
// cycle errors because it may typeck on anon constants directly.
746+
if !matches!(def_kind, rustc_hir::def::DefKind::AnonConst) {
747+
tcx.ensure().typeck(def_id);
748+
}
741749
// Run unsafety check because it's responsible for stealing and
742750
// deallocating THIR.
743751
tcx.ensure().check_unsafety(def_id);
744-
tcx.ensure().mir_borrowck(def_id)
745-
});
746-
});
747-
748-
sess.time("MIR_effect_checking", || {
749-
for def_id in tcx.hir().body_owners() {
752+
tcx.ensure().mir_borrowck(def_id);
750753
if !tcx.sess.opts.unstable_opts.thir_unsafeck {
751754
rustc_mir_transform::check_unsafety::check_unsafety(tcx, def_id);
752755
}
@@ -761,16 +764,16 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
761764
tcx.ensure().mir_drops_elaborated_and_const_checked(def_id);
762765
tcx.ensure().unused_generic_params(ty::InstanceDef::Item(def_id.to_def_id()));
763766
}
764-
}
765-
});
766767

767-
tcx.hir().par_body_owners(|def_id| {
768-
if tcx.is_coroutine(def_id.to_def_id()) {
769-
tcx.ensure().mir_coroutine_witnesses(def_id);
770-
tcx.ensure().check_coroutine_obligations(def_id);
771-
}
768+
if tcx.is_coroutine(def_id.to_def_id()) {
769+
tcx.ensure().mir_coroutine_witnesses(def_id);
770+
tcx.ensure().check_coroutine_obligations(def_id);
771+
}
772+
})
772773
});
773774

775+
tcx.ensure().check_unused_traits(());
776+
774777
sess.time("layout_testing", || layout_test::test_layout(tcx));
775778
sess.time("abi_testing", || abi_test::test_abi(tcx));
776779

‎tests/ui/binop/issue-77910-1.stderr

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
error[E0381]: used binding `xs` isn't initialized
2+
--> $DIR/issue-77910-1.rs:3:5
3+
|
4+
LL | let xs;
5+
| -- binding declared here but left uninitialized
6+
LL | xs
7+
| ^^ `xs` used here but it isn't initialized
8+
|
9+
help: consider assigning a value
10+
|
11+
LL | let xs = todo!();
12+
| +++++++++
13+
114
error[E0369]: binary operation `==` cannot be applied to type `for<'a> fn(&'a i32) -> &'a i32 {foo}`
215
--> $DIR/issue-77910-1.rs:8:5
316
|
@@ -22,19 +35,6 @@ LL | assert_eq!(foo, y);
2235
= help: use parentheses to call this function: `foo(/* &i32 */)`
2336
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
2437

25-
error[E0381]: used binding `xs` isn't initialized
26-
--> $DIR/issue-77910-1.rs:3:5
27-
|
28-
LL | let xs;
29-
| -- binding declared here but left uninitialized
30-
LL | xs
31-
| ^^ `xs` used here but it isn't initialized
32-
|
33-
help: consider assigning a value
34-
|
35-
LL | let xs = todo!();
36-
| +++++++++
37-
3838
error: aborting due to 3 previous errors
3939

4040
Some errors have detailed explanations: E0277, E0369, E0381.

‎tests/ui/binop/issue-77910-2.stderr

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
error[E0369]: binary operation `==` cannot be applied to type `for<'a> fn(&'a i32) -> &'a i32 {foo}`
2-
--> $DIR/issue-77910-2.rs:7:12
3-
|
4-
LL | if foo == y {}
5-
| --- ^^ - _
6-
| |
7-
| for<'a> fn(&'a i32) -> &'a i32 {foo}
8-
|
9-
help: use parentheses to call this function
10-
|
11-
LL | if foo(/* &i32 */) == y {}
12-
| ++++++++++++
13-
141
error[E0381]: used binding `xs` isn't initialized
152
--> $DIR/issue-77910-2.rs:3:5
163
|
@@ -24,6 +11,19 @@ help: consider assigning a value
2411
LL | let xs = todo!();
2512
| +++++++++
2613

14+
error[E0369]: binary operation `==` cannot be applied to type `for<'a> fn(&'a i32) -> &'a i32 {foo}`
15+
--> $DIR/issue-77910-2.rs:7:12
16+
|
17+
LL | if foo == y {}
18+
| --- ^^ - _
19+
| |
20+
| for<'a> fn(&'a i32) -> &'a i32 {foo}
21+
|
22+
help: use parentheses to call this function
23+
|
24+
LL | if foo(/* &i32 */) == y {}
25+
| ++++++++++++
26+
2727
error: aborting due to 2 previous errors
2828

2929
Some errors have detailed explanations: E0369, E0381.

‎tests/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.stderr

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ help: use `addr_of_mut!` instead to create a raw pointer
1313
LL | c1(addr_of_mut!(Y));
1414
| ~~~~~~~~~~~~~~~
1515

16+
error[E0594]: cannot assign to `x`, as it is not declared as mutable
17+
--> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:9:46
18+
|
19+
LL | pub fn e(x: &'static mut isize) {
20+
| - help: consider changing this to be mutable: `mut x`
21+
LL | static mut Y: isize = 3;
22+
LL | let mut c1 = |y: &'static mut isize| x = y;
23+
| ^^^^^ cannot assign
24+
1625
warning: creating a mutable reference to mutable static is discouraged
1726
--> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:27:16
1827
|
@@ -27,29 +36,6 @@ help: use `addr_of_mut!` instead to create a raw pointer
2736
LL | c1(addr_of_mut!(Z));
2837
| ~~~~~~~~~~~~~~~
2938

30-
warning: creating a mutable reference to mutable static is discouraged
31-
--> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:64:37
32-
|
33-
LL | borrowck_closures_unique::e(&mut X);
34-
| ^^^^^^ mutable reference to mutable static
35-
|
36-
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
37-
= note: this will be a hard error in the 2024 edition
38-
= note: this mutable reference has lifetime `'static`, but if the static gets accessed (read or written) by any other means, or any other reference is created, then any further use of this mutable reference is Undefined Behavior
39-
help: use `addr_of_mut!` instead to create a raw pointer
40-
|
41-
LL | borrowck_closures_unique::e(addr_of_mut!(X));
42-
| ~~~~~~~~~~~~~~~
43-
44-
error[E0594]: cannot assign to `x`, as it is not declared as mutable
45-
--> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:9:46
46-
|
47-
LL | pub fn e(x: &'static mut isize) {
48-
| - help: consider changing this to be mutable: `mut x`
49-
LL | static mut Y: isize = 3;
50-
LL | let mut c1 = |y: &'static mut isize| x = y;
51-
| ^^^^^ cannot assign
52-
5339
error[E0594]: cannot assign to `x`, as it is not declared as mutable
5440
--> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:22:50
5541
|
@@ -95,6 +81,20 @@ LL | || {
9581
LL | &mut x.0;
9682
| ^^^^^^^^ cannot borrow as mutable
9783

84+
warning: creating a mutable reference to mutable static is discouraged
85+
--> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:64:37
86+
|
87+
LL | borrowck_closures_unique::e(&mut X);
88+
| ^^^^^^ mutable reference to mutable static
89+
|
90+
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
91+
= note: this will be a hard error in the 2024 edition
92+
= note: this mutable reference has lifetime `'static`, but if the static gets accessed (read or written) by any other means, or any other reference is created, then any further use of this mutable reference is Undefined Behavior
93+
help: use `addr_of_mut!` instead to create a raw pointer
94+
|
95+
LL | borrowck_closures_unique::e(addr_of_mut!(X));
96+
| ~~~~~~~~~~~~~~~
97+
9898
error: aborting due to 6 previous errors; 3 warnings emitted
9999

100100
Some errors have detailed explanations: E0594, E0596.

‎tests/ui/const-generics/generic_const_exprs/type_mismatch.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ LL | impl<const N: u64> Q for [u8; N] {}
2121
| |
2222
| unsatisfied trait bound introduced here
2323

24+
error[E0308]: mismatched types
25+
--> $DIR/type_mismatch.rs:8:31
26+
|
27+
LL | impl<const N: u64> Q for [u8; N] {}
28+
| ^ expected `usize`, found `u64`
29+
2430
error[E0308]: mismatched types
2531
--> $DIR/type_mismatch.rs:12:20
2632
|
@@ -29,12 +35,6 @@ LL | pub fn q_user() -> [u8; <[u8; 13] as Q>::ASSOC] {}
2935
| |
3036
| implicitly returns `()` as its body has no tail or `return` expression
3137

32-
error[E0308]: mismatched types
33-
--> $DIR/type_mismatch.rs:8:31
34-
|
35-
LL | impl<const N: u64> Q for [u8; N] {}
36-
| ^ expected `usize`, found `u64`
37-
3838
error: aborting due to 4 previous errors
3939

4040
Some errors have detailed explanations: E0046, E0308.

‎tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,6 @@ LL + #[derive(ConstParamTy)]
3434
LL | struct Foo(u8);
3535
|
3636

37-
error: unconstrained generic constant
38-
--> $DIR/unify-op-with-fn-call.rs:30:12
39-
|
40-
LL | bar2::<{ std::ops::Add::add(N, N) }>();
41-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
42-
|
43-
= help: try adding a `where` bound using this expression: `where [(); { std::ops::Add::add(N, N) }]:`
44-
4537
error[E0015]: cannot call non-const operator in constants
4638
--> $DIR/unify-op-with-fn-call.rs:20:39
4739
|
@@ -65,6 +57,14 @@ LL | bar::<{ std::ops::Add::add(N, N) }>();
6557
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
6658
= help: add `#![feature(effects)]` to the crate attributes to enable
6759

60+
error: unconstrained generic constant
61+
--> $DIR/unify-op-with-fn-call.rs:30:12
62+
|
63+
LL | bar2::<{ std::ops::Add::add(N, N) }>();
64+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
65+
|
66+
= help: try adding a `where` bound using this expression: `where [(); { std::ops::Add::add(N, N) }]:`
67+
6868
error[E0015]: cannot call non-const fn `<usize as Add>::add` in constants
6969
--> $DIR/unify-op-with-fn-call.rs:30:14
7070
|

‎tests/ui/const-generics/transmute-fail.stderr

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ LL | std::mem::transmute(v)
1616
= note: source type: `[[u32; H]; W]` (this type does not have a fixed size)
1717
= note: target type: `[[u32; W]; H]` (size can vary because of [u32; W])
1818

19+
error[E0308]: mismatched types
20+
--> $DIR/transmute-fail.rs:12:53
21+
|
22+
LL | fn bar<const W: bool, const H: usize>(v: [[u32; H]; W]) -> [[u32; W]; H] {
23+
| ^ expected `usize`, found `bool`
24+
25+
error[E0308]: mismatched types
26+
--> $DIR/transmute-fail.rs:12:67
27+
|
28+
LL | fn bar<const W: bool, const H: usize>(v: [[u32; H]; W]) -> [[u32; W]; H] {
29+
| ^ expected `usize`, found `bool`
30+
1931
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
2032
--> $DIR/transmute-fail.rs:23:5
2133
|
@@ -34,18 +46,6 @@ LL | std::mem::transmute(v)
3446
= note: source type: `[[[u32; 8888888]; 9999999]; 777777777]` (values of the type `[[u32; 8888888]; 9999999]` are too big for the current architecture)
3547
= note: target type: `[[[u32; 9999999]; 777777777]; 8888888]` (values of the type `[[u32; 9999999]; 777777777]` are too big for the current architecture)
3648

37-
error[E0308]: mismatched types
38-
--> $DIR/transmute-fail.rs:12:53
39-
|
40-
LL | fn bar<const W: bool, const H: usize>(v: [[u32; H]; W]) -> [[u32; W]; H] {
41-
| ^ expected `usize`, found `bool`
42-
43-
error[E0308]: mismatched types
44-
--> $DIR/transmute-fail.rs:12:67
45-
|
46-
LL | fn bar<const W: bool, const H: usize>(v: [[u32; H]; W]) -> [[u32; W]; H] {
47-
| ^ expected `usize`, found `bool`
48-
4949
error: aborting due to 6 previous errors
5050

5151
Some errors have detailed explanations: E0308, E0512.

‎tests/ui/const-generics/type_mismatch.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ note: required by a bound in `bar`
1010
LL | fn bar<const N: u8>() -> [u8; N] {}
1111
| ^^^^^^^^^^^ required by this bound in `bar`
1212

13+
error[E0308]: mismatched types
14+
--> $DIR/type_mismatch.rs:2:11
15+
|
16+
LL | bar::<N>()
17+
| ^ expected `u8`, found `usize`
18+
1319
error[E0308]: mismatched types
1420
--> $DIR/type_mismatch.rs:6:26
1521
|
@@ -18,12 +24,6 @@ LL | fn bar<const N: u8>() -> [u8; N] {}
1824
| |
1925
| implicitly returns `()` as its body has no tail or `return` expression
2026

21-
error[E0308]: mismatched types
22-
--> $DIR/type_mismatch.rs:2:11
23-
|
24-
LL | bar::<N>()
25-
| ^ expected `u8`, found `usize`
26-
2727
error[E0308]: mismatched types
2828
--> $DIR/type_mismatch.rs:6:31
2929
|

‎tests/ui/explicit-tail-calls/return-mismatches.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ LL | become _g1();
1616
= note: expected unit type `()`
1717
found type `!`
1818

19-
error[E0308]: mismatched types
20-
--> $DIR/return-mismatches.rs:21:5
21-
|
22-
LL | become _g2();
23-
| ^^^^^^^^^^^^ expected `u32`, found `u16`
24-
2519
warning: function cannot return without recursing
2620
--> $DIR/return-mismatches.rs:16:1
2721
|
@@ -33,6 +27,12 @@ LL | become _g1();
3327
= help: a `loop` may express intention better if this is on purpose
3428
= note: `#[warn(unconditional_recursion)]` on by default
3529

30+
error[E0308]: mismatched types
31+
--> $DIR/return-mismatches.rs:21:5
32+
|
33+
LL | become _g2();
34+
| ^^^^^^^^^^^^ expected `u32`, found `u16`
35+
3636
error: aborting due to 3 previous errors; 1 warning emitted
3737

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

‎tests/ui/expr/if/if-no-match-bindings.stderr

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
error[E0515]: cannot return reference to temporary value
2+
--> $DIR/if-no-match-bindings.rs:8:38
3+
|
4+
LL | fn b_mut_ref<'a>() -> &'a mut bool { &mut true }
5+
| ^^^^^----
6+
| | |
7+
| | temporary value created here
8+
| returns a reference to data owned by the current function
9+
110
error[E0308]: mismatched types
211
--> $DIR/if-no-match-bindings.rs:19:8
312
|
@@ -90,15 +99,6 @@ LL - while &mut true {}
9099
LL + while true {}
91100
|
92101

93-
error[E0515]: cannot return reference to temporary value
94-
--> $DIR/if-no-match-bindings.rs:8:38
95-
|
96-
LL | fn b_mut_ref<'a>() -> &'a mut bool { &mut true }
97-
| ^^^^^----
98-
| | |
99-
| | temporary value created here
100-
| returns a reference to data owned by the current function
101-
102102
error: aborting due to 9 previous errors
103103

104104
Some errors have detailed explanations: E0308, E0515.

‎tests/ui/generic-associated-types/issue-74684-2.stderr

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
error[E0597]: `a` does not live long enough
2+
--> $DIR/issue-74684-2.rs:13:25
3+
|
4+
LL | fn bug<'a, T: ?Sized + Fun<F<'a> = [u8]>>(t: Box<T>) -> &'static T::F<'a> {
5+
| -- lifetime `'a` defined here
6+
LL | let a = [0; 1];
7+
| - binding `a` declared here
8+
LL | let x = T::identity(&a);
9+
| ------------^^-
10+
| | |
11+
| | borrowed value does not live long enough
12+
| argument requires that `a` is borrowed for `'a`
13+
LL | todo!()
14+
LL | }
15+
| - `a` dropped here while still borrowed
16+
117
error[E0271]: type mismatch resolving `<{integer} as Fun>::F<'_> == [u8]`
218
--> $DIR/issue-74684-2.rs:21:9
319
|
@@ -17,22 +33,6 @@ note: required by a bound in `bug`
1733
LL | fn bug<'a, T: ?Sized + Fun<F<'a> = [u8]>>(t: Box<T>) -> &'static T::F<'a> {
1834
| ^^^^^^^^^^^^ required by this bound in `bug`
1935

20-
error[E0597]: `a` does not live long enough
21-
--> $DIR/issue-74684-2.rs:13:25
22-
|
23-
LL | fn bug<'a, T: ?Sized + Fun<F<'a> = [u8]>>(t: Box<T>) -> &'static T::F<'a> {
24-
| -- lifetime `'a` defined here
25-
LL | let a = [0; 1];
26-
| - binding `a` declared here
27-
LL | let x = T::identity(&a);
28-
| ------------^^-
29-
| | |
30-
| | borrowed value does not live long enough
31-
| argument requires that `a` is borrowed for `'a`
32-
LL | todo!()
33-
LL | }
34-
| - `a` dropped here while still borrowed
35-
3636
error: aborting due to 2 previous errors
3737

3838
Some errors have detailed explanations: E0271, E0597.

‎tests/ui/higher-ranked/trait-bounds/hrtb-higher-ranker-supertraits.stderr

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@ help: consider further restricting this bound
1818
LL | where F : Foo<'x> + for<'tcx> Foo<'tcx>
1919
| +++++++++++++++++++++
2020

21+
warning: function cannot return without recursing
22+
--> $DIR/hrtb-higher-ranker-supertraits.rs:21:1
23+
|
24+
LL | / fn want_foo_for_any_tcx<F>(f: &F)
25+
LL | | where F : for<'tcx> Foo<'tcx>
26+
| |_________________________________^ cannot return without recursing
27+
...
28+
LL | want_foo_for_any_tcx(f);
29+
| ----------------------- recursive call site
30+
|
31+
= help: a `loop` may express intention better if this is on purpose
32+
= note: `#[warn(unconditional_recursion)]` on by default
33+
2134
error[E0277]: the trait bound `for<'ccx> B: Bar<'ccx>` is not satisfied
2235
--> $DIR/hrtb-higher-ranker-supertraits.rs:35:26
2336
|
@@ -38,19 +51,6 @@ help: consider further restricting this bound
3851
LL | where B : Bar<'x> + for<'ccx> Bar<'ccx>
3952
| +++++++++++++++++++++
4053

41-
warning: function cannot return without recursing
42-
--> $DIR/hrtb-higher-ranker-supertraits.rs:21:1
43-
|
44-
LL | / fn want_foo_for_any_tcx<F>(f: &F)
45-
LL | | where F : for<'tcx> Foo<'tcx>
46-
| |_________________________________^ cannot return without recursing
47-
...
48-
LL | want_foo_for_any_tcx(f);
49-
| ----------------------- recursive call site
50-
|
51-
= help: a `loop` may express intention better if this is on purpose
52-
= note: `#[warn(unconditional_recursion)]` on by default
53-
5454
warning: function cannot return without recursing
5555
--> $DIR/hrtb-higher-ranker-supertraits.rs:38:1
5656
|

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
error[E0515]: cannot return value referencing local variable `r`
2+
--> $DIR/issue-11374.rs:20:5
3+
|
4+
LL | Container::wrap(&mut r as &mut dyn io::Read)
5+
| ^^^^^^^^^^^^^^^^------^^^^^^^^^^^^^^^^^^^^^^
6+
| | |
7+
| | `r` is borrowed here
8+
| returns a value referencing data owned by the current function
9+
110
error[E0308]: mismatched types
211
--> $DIR/issue-11374.rs:27:15
312
|
@@ -18,15 +27,6 @@ help: consider mutably borrowing here
1827
LL | c.read_to(&mut v);
1928
| ++++
2029

21-
error[E0515]: cannot return value referencing local variable `r`
22-
--> $DIR/issue-11374.rs:20:5
23-
|
24-
LL | Container::wrap(&mut r as &mut dyn io::Read)
25-
| ^^^^^^^^^^^^^^^^------^^^^^^^^^^^^^^^^^^^^^^
26-
| | |
27-
| | `r` is borrowed here
28-
| returns a value referencing data owned by the current function
29-
3030
error: aborting due to 2 previous errors
3131

3232
Some errors have detailed explanations: E0308, E0515.

‎tests/ui/kindck/kindck-impl-type-params.stderr

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ help: consider restricting type parameter `T`
7474
LL | fn g<T: std::marker::Copy>(val: T) {
7575
| +++++++++++++++++++
7676

77+
error: lifetime may not live long enough
78+
--> $DIR/kindck-impl-type-params.rs:30:13
79+
|
80+
LL | fn foo<'a>() {
81+
| -- lifetime `'a` defined here
82+
LL | let t: S<&'a isize> = S(marker::PhantomData);
83+
LL | let a = &t as &dyn Gettable<&'a isize>;
84+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
85+
7786
error[E0277]: the trait bound `String: Copy` is not satisfied
7887
--> $DIR/kindck-impl-type-params.rs:36:13
7988
|
@@ -111,15 +120,6 @@ LL + #[derive(Copy)]
111120
LL | struct Foo; // does not impl Copy
112121
|
113122

114-
error: lifetime may not live long enough
115-
--> $DIR/kindck-impl-type-params.rs:30:13
116-
|
117-
LL | fn foo<'a>() {
118-
| -- lifetime `'a` defined here
119-
LL | let t: S<&'a isize> = S(marker::PhantomData);
120-
LL | let a = &t as &dyn Gettable<&'a isize>;
121-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
122-
123123
error: aborting due to 7 previous errors
124124

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

‎tests/ui/kindck/kindck-send-object1.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ note: required by a bound in `assert_send`
1212
LL | fn assert_send<T:Send+'static>() { }
1313
| ^^^^ required by this bound in `assert_send`
1414

15+
error: lifetime may not live long enough
16+
--> $DIR/kindck-send-object1.rs:14:5
17+
|
18+
LL | fn test52<'a>() {
19+
| -- lifetime `'a` defined here
20+
LL | assert_send::<&'a (dyn Dummy + Sync)>();
21+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
22+
1523
error[E0277]: `(dyn Dummy + 'a)` cannot be sent between threads safely
1624
--> $DIR/kindck-send-object1.rs:29:19
1725
|
@@ -28,14 +36,6 @@ note: required by a bound in `assert_send`
2836
LL | fn assert_send<T:Send+'static>() { }
2937
| ^^^^ required by this bound in `assert_send`
3038

31-
error: lifetime may not live long enough
32-
--> $DIR/kindck-send-object1.rs:14:5
33-
|
34-
LL | fn test52<'a>() {
35-
| -- lifetime `'a` defined here
36-
LL | assert_send::<&'a (dyn Dummy + Sync)>();
37-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
38-
3939
error: aborting due to 3 previous errors
4040

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

‎tests/ui/lifetimes/issue-17728.stderr

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
error: lifetime may not live long enough
2+
--> $DIR/issue-17728.rs:15:28
3+
|
4+
LL | fn attemptTraverse(&self, room: &Room, directionStr: &str) -> Result<&Room, &str> {
5+
| - - let's call the lifetime of this reference `'1`
6+
| |
7+
| let's call the lifetime of this reference `'2`
8+
...
9+
LL | Some(entry) => Ok(entry),
10+
| ^^^^^^^^^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
11+
|
12+
help: consider introducing a named lifetime parameter
13+
|
14+
LL | fn attemptTraverse<'a>(&'a self, room: &'a Room, directionStr: &str) -> Result<&Room, &str> {
15+
| ++++ ++ ++
16+
117
error[E0308]: `match` arms have incompatible types
218
--> $DIR/issue-17728.rs:108:14
319
|
@@ -16,22 +32,6 @@ LL | | }
1632
= note: expected enum `RoomDirection`
1733
found enum `Option<_>`
1834

19-
error: lifetime may not live long enough
20-
--> $DIR/issue-17728.rs:15:28
21-
|
22-
LL | fn attemptTraverse(&self, room: &Room, directionStr: &str) -> Result<&Room, &str> {
23-
| - - let's call the lifetime of this reference `'1`
24-
| |
25-
| let's call the lifetime of this reference `'2`
26-
...
27-
LL | Some(entry) => Ok(entry),
28-
| ^^^^^^^^^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
29-
|
30-
help: consider introducing a named lifetime parameter
31-
|
32-
LL | fn attemptTraverse<'a>(&'a self, room: &'a Room, directionStr: &str) -> Result<&Room, &str> {
33-
| ++++ ++ ++
34-
3535
error: aborting due to 2 previous errors
3636

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

‎tests/ui/liveness/liveness-consts.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@ LL | b += 1;
4040
= help: maybe it is overwritten before being read?
4141
= note: `#[warn(unused_assignments)]` implied by `#[warn(unused)]`
4242

43-
warning: unused variable: `z`
44-
--> $DIR/liveness-consts.rs:60:13
45-
|
46-
LL | let z = 42;
47-
| ^ help: if this is intentional, prefix it with an underscore: `_z`
48-
4943
warning: value assigned to `t` is never read
5044
--> $DIR/liveness-consts.rs:42:9
5145
|
@@ -60,5 +54,11 @@ warning: unused variable: `w`
6054
LL | let w = 10;
6155
| ^ help: if this is intentional, prefix it with an underscore: `_w`
6256

57+
warning: unused variable: `z`
58+
--> $DIR/liveness-consts.rs:60:13
59+
|
60+
LL | let z = 42;
61+
| ^ help: if this is intentional, prefix it with an underscore: `_z`
62+
6363
warning: 8 warnings emitted
6464

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
warning: function cannot return without recursing
2+
--> $DIR/liveness-forgot-ret.rs:1:1
3+
|
4+
LL | fn god_exists(a: isize) -> bool { return god_exists(a); }
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------------- recursive call site
6+
| |
7+
| cannot return without recursing
8+
|
9+
= help: a `loop` may express intention better if this is on purpose
10+
= note: `#[warn(unconditional_recursion)]` on by default
11+
112
error[E0308]: mismatched types
213
--> $DIR/liveness-forgot-ret.rs:4:19
314
|
@@ -11,17 +22,6 @@ help: consider returning the local binding `a`
1122
LL | fn f(a: isize) -> isize { if god_exists(a) { return 5; }; a }
1223
| +
1324

14-
warning: function cannot return without recursing
15-
--> $DIR/liveness-forgot-ret.rs:1:1
16-
|
17-
LL | fn god_exists(a: isize) -> bool { return god_exists(a); }
18-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------------- recursive call site
19-
| |
20-
| cannot return without recursing
21-
|
22-
= help: a `loop` may express intention better if this is on purpose
23-
= note: `#[warn(unconditional_recursion)]` on by default
24-
2525
error: aborting due to 1 previous error; 1 warning emitted
2626

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

‎tests/ui/liveness/liveness-unused.stderr

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
warning: unreachable statement
2-
--> $DIR/liveness-unused.rs:92:9
3-
|
4-
LL | continue;
5-
| -------- any code following this expression is unreachable
6-
LL | drop(*x as i32);
7-
| ^^^^^^^^^^^^^^^^ unreachable statement
8-
|
9-
note: the lint level is defined here
10-
--> $DIR/liveness-unused.rs:1:9
11-
|
12-
LL | #![warn(unused)]
13-
| ^^^^^^
14-
= note: `#[warn(unreachable_code)]` implied by `#[warn(unused)]`
15-
161
error: unused variable: `x`
172
--> $DIR/liveness-unused.rs:8:7
183
|
@@ -90,6 +75,21 @@ error: unused variable: `x`
9075
LL | for (x, _) in [1, 2, 3].iter().enumerate() { }
9176
| ^ help: if this is intentional, prefix it with an underscore: `_x`
9277

78+
warning: unreachable statement
79+
--> $DIR/liveness-unused.rs:92:9
80+
|
81+
LL | continue;
82+
| -------- any code following this expression is unreachable
83+
LL | drop(*x as i32);
84+
| ^^^^^^^^^^^^^^^^ unreachable statement
85+
|
86+
note: the lint level is defined here
87+
--> $DIR/liveness-unused.rs:1:9
88+
|
89+
LL | #![warn(unused)]
90+
| ^^^^^^
91+
= note: `#[warn(unreachable_code)]` implied by `#[warn(unused)]`
92+
9393
error: unused variable: `x`
9494
--> $DIR/liveness-unused.rs:89:13
9595
|

‎tests/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
error[E0308]: mismatched types
2-
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:43
3-
|
4-
LL | let _: fn(&mut &isize, &mut &isize) = a;
5-
| ---------------------------- ^ one type is more general than the other
6-
| |
7-
| expected due to this
8-
|
9-
= note: expected fn pointer `for<'a, 'b, 'c, 'd> fn(&'a mut &'b _, &'c mut &'d _)`
10-
found fn item `for<'a, 'b> fn(&'a mut &_, &'b mut &_) {a::<'_, '_>}`
11-
121
error: lifetime may not live long enough
132
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:8:5
143
|
@@ -38,6 +27,17 @@ LL | a(x, y);
3827
= note: mutable references are invariant over their type parameter
3928
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
4029

30+
error[E0308]: mismatched types
31+
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:43
32+
|
33+
LL | let _: fn(&mut &isize, &mut &isize) = a;
34+
| ---------------------------- ^ one type is more general than the other
35+
| |
36+
| expected due to this
37+
|
38+
= note: expected fn pointer `for<'a, 'b, 'c, 'd> fn(&'a mut &'b _, &'c mut &'d _)`
39+
found fn item `for<'a, 'b> fn(&'a mut &_, &'b mut &_) {a::<'_, '_>}`
40+
4141
error: aborting due to 3 previous errors
4242

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

‎tests/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
error[E0308]: mismatched types
2-
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:56
3-
|
4-
LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a;
5-
| ----------------------------------------- ^ one type is more general than the other
6-
| |
7-
| expected due to this
8-
|
9-
= note: expected fn pointer `for<'a, 'b, 'c, 'd, 'e, 'f> fn(&'a mut &'b _, &'c mut &'d _, &'e mut &'f _)`
10-
found fn item `for<'a, 'b, 'c> fn(&'a mut &_, &'b mut &_, &'c mut &_) {a::<'_, '_, '_>}`
11-
121
error: lifetime may not live long enough
132
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:9:5
143
|
@@ -38,6 +27,17 @@ LL | a(x, y, z);
3827
= note: mutable references are invariant over their type parameter
3928
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
4029

30+
error[E0308]: mismatched types
31+
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:56
32+
|
33+
LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a;
34+
| ----------------------------------------- ^ one type is more general than the other
35+
| |
36+
| expected due to this
37+
|
38+
= note: expected fn pointer `for<'a, 'b, 'c, 'd, 'e, 'f> fn(&'a mut &'b _, &'c mut &'d _, &'e mut &'f _)`
39+
found fn item `for<'a, 'b, 'c> fn(&'a mut &_, &'b mut &_, &'c mut &_) {a::<'_, '_, '_>}`
40+
4141
error: aborting due to 3 previous errors
4242

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

‎tests/ui/regions/regions-lifetime-bounds-on-fns.stderr

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
error[E0308]: mismatched types
2-
--> $DIR/regions-lifetime-bounds-on-fns.rs:20:43
3-
|
4-
LL | let _: fn(&mut &isize, &mut &isize) = a;
5-
| ---------------------------- ^ one type is more general than the other
6-
| |
7-
| expected due to this
8-
|
9-
= note: expected fn pointer `for<'a, 'b, 'c, 'd> fn(&'a mut &'b _, &'c mut &'d _)`
10-
found fn item `for<'a, 'b> fn(&'a mut &_, &'b mut &_) {a::<'_, '_>}`
11-
121
error: lifetime may not live long enough
132
--> $DIR/regions-lifetime-bounds-on-fns.rs:8:5
143
|
@@ -38,6 +27,17 @@ LL | a(x, y);
3827
= note: mutable references are invariant over their type parameter
3928
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
4029

30+
error[E0308]: mismatched types
31+
--> $DIR/regions-lifetime-bounds-on-fns.rs:20:43
32+
|
33+
LL | let _: fn(&mut &isize, &mut &isize) = a;
34+
| ---------------------------- ^ one type is more general than the other
35+
| |
36+
| expected due to this
37+
|
38+
= note: expected fn pointer `for<'a, 'b, 'c, 'd> fn(&'a mut &'b _, &'c mut &'d _)`
39+
found fn item `for<'a, 'b> fn(&'a mut &_, &'b mut &_) {a::<'_, '_>}`
40+
4141
error: aborting due to 3 previous errors
4242

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

‎tests/ui/suggestions/issue-102892.stderr

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
error[E0507]: cannot move out of an `Arc`
2+
--> $DIR/issue-102892.rs:11:18
3+
|
4+
LL | let (a, b) = **arc; // suggests putting `&**arc` here; with that, fixed!
5+
| - - ^^^^^
6+
| | |
7+
| | ...and here
8+
| data moved here
9+
|
10+
= note: move occurs because these variables have types that don't implement the `Copy` trait
11+
help: consider removing the dereference here
12+
|
13+
LL - let (a, b) = **arc; // suggests putting `&**arc` here; with that, fixed!
14+
LL + let (a, b) = *arc; // suggests putting `&**arc` here; with that, fixed!
15+
|
16+
117
error[E0308]: mismatched types
218
--> $DIR/issue-102892.rs:16:26
319
|
@@ -52,22 +68,6 @@ help: alternatively, consider changing the type annotation
5268
LL | let (a, b): ((A, B), &A) = (&mut *mutation, &(**arc).0); // suggests putting `&**arc` here too
5369
| +
5470

55-
error[E0507]: cannot move out of an `Arc`
56-
--> $DIR/issue-102892.rs:11:18
57-
|
58-
LL | let (a, b) = **arc; // suggests putting `&**arc` here; with that, fixed!
59-
| - - ^^^^^
60-
| | |
61-
| | ...and here
62-
| data moved here
63-
|
64-
= note: move occurs because these variables have types that don't implement the `Copy` trait
65-
help: consider removing the dereference here
66-
|
67-
LL - let (a, b) = **arc; // suggests putting `&**arc` here; with that, fixed!
68-
LL + let (a, b) = *arc; // suggests putting `&**arc` here; with that, fixed!
69-
|
70-
7171
error: aborting due to 4 previous errors
7272

7373
Some errors have detailed explanations: E0308, E0507.

‎tests/ui/type-alias-impl-trait/variance.stderr

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,168 +1,168 @@
1-
error[E0657]: `impl Trait` can only capture lifetimes bound at the fn or impl level
2-
--> $DIR/variance.rs:14:36
3-
|
4-
LL | type NotCapturedLate<'a> = dyn for<'b> Iterator<Item = impl Sized>;
5-
| ^^
6-
7-
error[E0657]: `impl Trait` can only capture lifetimes bound at the fn or impl level
8-
--> $DIR/variance.rs:18:29
9-
|
10-
LL | type Captured<'a> = dyn for<'b> Iterator<Item = impl Sized + Captures<'a>>;
11-
| ^^
12-
13-
error: unconstrained opaque type
1+
error: [*, o]
142
--> $DIR/variance.rs:8:29
153
|
164
LL | type NotCapturedEarly<'a> = impl Sized;
175
| ^^^^^^^^^^
18-
|
19-
= note: `NotCapturedEarly` must be used in combination with a concrete type within the same module
206

21-
error: unconstrained opaque type
7+
error: [*, o]
228
--> $DIR/variance.rs:11:26
239
|
2410
LL | type CapturedEarly<'a> = impl Sized + Captures<'a>;
2511
| ^^^^^^^^^^^^^^^^^^^^^^^^^
26-
|
27-
= note: `CapturedEarly` must be used in combination with a concrete type within the same module
2812

29-
error: unconstrained opaque type
13+
error: [*, o, o]
3014
--> $DIR/variance.rs:14:56
3115
|
3216
LL | type NotCapturedLate<'a> = dyn for<'b> Iterator<Item = impl Sized>;
3317
| ^^^^^^^^^^
34-
|
35-
= note: `NotCapturedLate` must be used in combination with a concrete type within the same module
3618

37-
error: unconstrained opaque type
19+
error: [*, o, o]
3820
--> $DIR/variance.rs:18:49
3921
|
4022
LL | type Captured<'a> = dyn for<'b> Iterator<Item = impl Sized + Captures<'a>>;
4123
| ^^^^^^^^^^^^^^^^^^^^^^^^^
42-
|
43-
= note: `Captured` must be used in combination with a concrete type within the same module
4424

45-
error: unconstrained opaque type
25+
error: [*, *, o, o, o]
4626
--> $DIR/variance.rs:22:27
4727
|
4828
LL | type Bar<'a, 'b: 'b, T> = impl Sized;
4929
| ^^^^^^^^^^
50-
|
51-
= note: `Bar` must be used in combination with a concrete type within the same module
5230

53-
error: unconstrained opaque type
31+
error: [*, *, o, o]
5432
--> $DIR/variance.rs:34:32
5533
|
5634
LL | type ImplicitCapture<'a> = impl Sized;
5735
| ^^^^^^^^^^
58-
|
59-
= note: `ImplicitCapture` must be used in combination with a concrete type within the same impl
6036

61-
error: unconstrained opaque type
37+
error: [*, *, o, o]
6238
--> $DIR/variance.rs:37:42
6339
|
6440
LL | type ExplicitCaptureFromHeader<'a> = impl Sized + Captures<'i>;
6541
| ^^^^^^^^^^^^^^^^^^^^^^^^^
66-
|
67-
= note: `ExplicitCaptureFromHeader` must be used in combination with a concrete type within the same impl
6842

69-
error: unconstrained opaque type
43+
error: [*, *, o, o]
7044
--> $DIR/variance.rs:40:39
7145
|
7246
LL | type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>;
7347
| ^^^^^^^^^^^^^^^^^^^^^^^^^
74-
|
75-
= note: `ExplicitCaptureFromGat` must be used in combination with a concrete type within the same impl
7648

77-
error: unconstrained opaque type
49+
error: [*, *, o, o]
7850
--> $DIR/variance.rs:45:32
7951
|
8052
LL | type ImplicitCapture<'a> = impl Sized;
8153
| ^^^^^^^^^^
82-
|
83-
= note: `ImplicitCapture` must be used in combination with a concrete type within the same impl
8454

85-
error: unconstrained opaque type
55+
error: [*, *, o, o]
8656
--> $DIR/variance.rs:48:42
8757
|
8858
LL | type ExplicitCaptureFromHeader<'a> = impl Sized + Captures<'i>;
8959
| ^^^^^^^^^^^^^^^^^^^^^^^^^
90-
|
91-
= note: `ExplicitCaptureFromHeader` must be used in combination with a concrete type within the same impl
9260

93-
error: unconstrained opaque type
61+
error: [*, *, o, o]
9462
--> $DIR/variance.rs:51:39
9563
|
9664
LL | type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>;
9765
| ^^^^^^^^^^^^^^^^^^^^^^^^^
66+
67+
error[E0657]: `impl Trait` can only capture lifetimes bound at the fn or impl level
68+
--> $DIR/variance.rs:14:36
9869
|
99-
= note: `ExplicitCaptureFromGat` must be used in combination with a concrete type within the same impl
70+
LL | type NotCapturedLate<'a> = dyn for<'b> Iterator<Item = impl Sized>;
71+
| ^^
10072

101-
error: [*, o]
73+
error[E0657]: `impl Trait` can only capture lifetimes bound at the fn or impl level
74+
--> $DIR/variance.rs:18:29
75+
|
76+
LL | type Captured<'a> = dyn for<'b> Iterator<Item = impl Sized + Captures<'a>>;
77+
| ^^
78+
79+
error: unconstrained opaque type
10280
--> $DIR/variance.rs:8:29
10381
|
10482
LL | type NotCapturedEarly<'a> = impl Sized;
10583
| ^^^^^^^^^^
84+
|
85+
= note: `NotCapturedEarly` must be used in combination with a concrete type within the same module
10686

107-
error: [*, o]
87+
error: unconstrained opaque type
10888
--> $DIR/variance.rs:11:26
10989
|
11090
LL | type CapturedEarly<'a> = impl Sized + Captures<'a>;
11191
| ^^^^^^^^^^^^^^^^^^^^^^^^^
92+
|
93+
= note: `CapturedEarly` must be used in combination with a concrete type within the same module
11294

113-
error: [*, o, o]
95+
error: unconstrained opaque type
11496
--> $DIR/variance.rs:14:56
11597
|
11698
LL | type NotCapturedLate<'a> = dyn for<'b> Iterator<Item = impl Sized>;
11799
| ^^^^^^^^^^
100+
|
101+
= note: `NotCapturedLate` must be used in combination with a concrete type within the same module
118102

119-
error: [*, o, o]
103+
error: unconstrained opaque type
120104
--> $DIR/variance.rs:18:49
121105
|
122106
LL | type Captured<'a> = dyn for<'b> Iterator<Item = impl Sized + Captures<'a>>;
123107
| ^^^^^^^^^^^^^^^^^^^^^^^^^
108+
|
109+
= note: `Captured` must be used in combination with a concrete type within the same module
124110

125-
error: [*, *, o, o, o]
111+
error: unconstrained opaque type
126112
--> $DIR/variance.rs:22:27
127113
|
128114
LL | type Bar<'a, 'b: 'b, T> = impl Sized;
129115
| ^^^^^^^^^^
116+
|
117+
= note: `Bar` must be used in combination with a concrete type within the same module
130118

131-
error: [*, *, o, o]
119+
error: unconstrained opaque type
132120
--> $DIR/variance.rs:34:32
133121
|
134122
LL | type ImplicitCapture<'a> = impl Sized;
135123
| ^^^^^^^^^^
124+
|
125+
= note: `ImplicitCapture` must be used in combination with a concrete type within the same impl
136126

137-
error: [*, *, o, o]
127+
error: unconstrained opaque type
138128
--> $DIR/variance.rs:37:42
139129
|
140130
LL | type ExplicitCaptureFromHeader<'a> = impl Sized + Captures<'i>;
141131
| ^^^^^^^^^^^^^^^^^^^^^^^^^
132+
|
133+
= note: `ExplicitCaptureFromHeader` must be used in combination with a concrete type within the same impl
142134

143-
error: [*, *, o, o]
135+
error: unconstrained opaque type
144136
--> $DIR/variance.rs:40:39
145137
|
146138
LL | type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>;
147139
| ^^^^^^^^^^^^^^^^^^^^^^^^^
140+
|
141+
= note: `ExplicitCaptureFromGat` must be used in combination with a concrete type within the same impl
148142

149-
error: [*, *, o, o]
143+
error: unconstrained opaque type
150144
--> $DIR/variance.rs:45:32
151145
|
152146
LL | type ImplicitCapture<'a> = impl Sized;
153147
| ^^^^^^^^^^
148+
|
149+
= note: `ImplicitCapture` must be used in combination with a concrete type within the same impl
154150

155-
error: [*, *, o, o]
151+
error: unconstrained opaque type
156152
--> $DIR/variance.rs:48:42
157153
|
158154
LL | type ExplicitCaptureFromHeader<'a> = impl Sized + Captures<'i>;
159155
| ^^^^^^^^^^^^^^^^^^^^^^^^^
156+
|
157+
= note: `ExplicitCaptureFromHeader` must be used in combination with a concrete type within the same impl
160158

161-
error: [*, *, o, o]
159+
error: unconstrained opaque type
162160
--> $DIR/variance.rs:51:39
163161
|
164162
LL | type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>;
165163
| ^^^^^^^^^^^^^^^^^^^^^^^^^
164+
|
165+
= note: `ExplicitCaptureFromGat` must be used in combination with a concrete type within the same impl
166166

167167
error: aborting due to 24 previous errors
168168

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
error: [o]
2+
--> $DIR/variance-associated-consts.rs:13:1
3+
|
4+
LL | struct Foo<T: Trait> {
5+
| ^^^^^^^^^^^^^^^^^^^^
6+
17
error: unconstrained generic constant
28
--> $DIR/variance-associated-consts.rs:14:12
39
|
@@ -6,11 +12,5 @@ LL | field: [u8; <T as Trait>::Const]
612
|
713
= help: try adding a `where` bound using this expression: `where [(); <T as Trait>::Const]:`
814

9-
error: [o]
10-
--> $DIR/variance-associated-consts.rs:13:1
11-
|
12-
LL | struct Foo<T: Trait> {
13-
| ^^^^^^^^^^^^^^^^^^^^
14-
1515
error: aborting due to 2 previous errors
1616

‎tests/ui/variance/variance-regions-direct.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
error[E0392]: lifetime parameter `'a` is never used
2-
--> $DIR/variance-regions-direct.rs:52:14
3-
|
4-
LL | struct Test7<'a> {
5-
| ^^ unused lifetime parameter
6-
|
7-
= help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`
8-
91
error: [+, +, +]
102
--> $DIR/variance-regions-direct.rs:9:1
113
|
@@ -48,6 +40,14 @@ error: [-, +, o]
4840
LL | enum Test8<'a, 'b, 'c:'b> {
4941
| ^^^^^^^^^^^^^^^^^^^^^^^^^
5042

43+
error[E0392]: lifetime parameter `'a` is never used
44+
--> $DIR/variance-regions-direct.rs:52:14
45+
|
46+
LL | struct Test7<'a> {
47+
| ^^ unused lifetime parameter
48+
|
49+
= help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`
50+
5151
error: aborting due to 8 previous errors
5252

5353
For more information about this error, try `rustc --explain E0392`.
Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
error: [-, +, o, *]
2+
--> $DIR/variance-regions-indirect.rs:8:1
3+
|
4+
LL | enum Base<'a, 'b, 'c:'b, 'd> {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: [*, o, +, -]
8+
--> $DIR/variance-regions-indirect.rs:16:1
9+
|
10+
LL | struct Derived1<'w, 'x:'y, 'y, 'z> {
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
13+
error: [o, o, *]
14+
--> $DIR/variance-regions-indirect.rs:22:1
15+
|
16+
LL | struct Derived2<'a, 'b:'a, 'c> {
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18+
19+
error: [o, +, *]
20+
--> $DIR/variance-regions-indirect.rs:28:1
21+
|
22+
LL | struct Derived3<'a:'b, 'b, 'c> {
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24+
25+
error: [-, +, o]
26+
--> $DIR/variance-regions-indirect.rs:34:1
27+
|
28+
LL | struct Derived4<'a, 'b, 'c:'b> {
29+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
30+
131
error[E0392]: lifetime parameter `'d` is never used
232
--> $DIR/variance-regions-indirect.rs:8:26
333
|
@@ -30,36 +60,6 @@ LL | struct Derived3<'a:'b, 'b, 'c> {
3060
|
3161
= help: consider removing `'c`, referring to it in a field, or using a marker such as `PhantomData`
3262

33-
error: [-, +, o, *]
34-
--> $DIR/variance-regions-indirect.rs:8:1
35-
|
36-
LL | enum Base<'a, 'b, 'c:'b, 'd> {
37-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
38-
39-
error: [*, o, +, -]
40-
--> $DIR/variance-regions-indirect.rs:16:1
41-
|
42-
LL | struct Derived1<'w, 'x:'y, 'y, 'z> {
43-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44-
45-
error: [o, o, *]
46-
--> $DIR/variance-regions-indirect.rs:22:1
47-
|
48-
LL | struct Derived2<'a, 'b:'a, 'c> {
49-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
50-
51-
error: [o, +, *]
52-
--> $DIR/variance-regions-indirect.rs:28:1
53-
|
54-
LL | struct Derived3<'a:'b, 'b, 'c> {
55-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
56-
57-
error: [-, +, o]
58-
--> $DIR/variance-regions-indirect.rs:34:1
59-
|
60-
LL | struct Derived4<'a, 'b, 'c:'b> {
61-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
62-
6363
error: aborting due to 9 previous errors
6464

6565
For more information about this error, try `rustc --explain E0392`.
Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
error: [+, +]
2+
--> $DIR/variance-trait-bounds.rs:16:1
3+
|
4+
LL | struct TestStruct<U,T:Setter<U>> {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: [*, +]
8+
--> $DIR/variance-trait-bounds.rs:21:1
9+
|
10+
LL | enum TestEnum<U,T:Setter<U>> {
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
13+
error: [*, +]
14+
--> $DIR/variance-trait-bounds.rs:27:1
15+
|
16+
LL | struct TestContraStruct<U,T:Setter<U>> {
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18+
19+
error: [*, +]
20+
--> $DIR/variance-trait-bounds.rs:33:1
21+
|
22+
LL | struct TestBox<U,T:Getter<U>+Setter<U>> {
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24+
125
error[E0392]: type parameter `U` is never used
226
--> $DIR/variance-trait-bounds.rs:21:15
327
|
@@ -25,30 +49,6 @@ LL | struct TestBox<U,T:Getter<U>+Setter<U>> {
2549
= help: consider removing `U`, referring to it in a field, or using a marker such as `PhantomData`
2650
= help: if you intended `U` to be a const parameter, use `const U: /* Type */` instead
2751

28-
error: [+, +]
29-
--> $DIR/variance-trait-bounds.rs:16:1
30-
|
31-
LL | struct TestStruct<U,T:Setter<U>> {
32-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
33-
34-
error: [*, +]
35-
--> $DIR/variance-trait-bounds.rs:21:1
36-
|
37-
LL | enum TestEnum<U,T:Setter<U>> {
38-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
39-
40-
error: [*, +]
41-
--> $DIR/variance-trait-bounds.rs:27:1
42-
|
43-
LL | struct TestContraStruct<U,T:Setter<U>> {
44-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
45-
46-
error: [*, +]
47-
--> $DIR/variance-trait-bounds.rs:33:1
48-
|
49-
LL | struct TestBox<U,T:Getter<U>+Setter<U>> {
50-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
51-
5252
error: aborting due to 7 previous errors
5353

5454
For more information about this error, try `rustc --explain E0392`.

0 commit comments

Comments
 (0)
Please sign in to comment.