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 5ac0b2d

Browse files
committedMar 14, 2024
Auto merge of #122347 - oli-obk:track_errors13, r=compiler-errors
Revert "Auto merge of #122140 - oli-obk:track_errors13, r=davidtwco" This reverts commit 65cd843, reversing changes made to d255c6a. reverts #122140 It was a large regression in wall time due to trashing CPU caches
2 parents c7fed9f + 96d24f2 commit 5ac0b2d

33 files changed

+443
-419
lines changed
 

‎compiler/rustc_driver_impl/src/pretty.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,7 @@ 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-
rustc_hir_analysis::check_crate(tcx);
340-
if tcx.dcx().has_errors().is_some() {
339+
if rustc_hir_analysis::check_crate(tcx).is_err() {
341340
FatalError.raise();
342341
}
343342
debug!("pretty printing THIR tree");
@@ -349,8 +348,7 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
349348
ThirFlat => {
350349
let tcx = ex.tcx();
351350
let mut out = String::new();
352-
rustc_hir_analysis::check_crate(tcx);
353-
if tcx.dcx().has_errors().is_some() {
351+
if rustc_hir_analysis::check_crate(tcx).is_err() {
354352
FatalError.raise();
355353
}
356354
debug!("pretty printing THIR flat");

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@ 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, DUMMY_SP};
8+
use rustc_span::{sym, ErrorGuaranteed, DUMMY_SP};
99

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

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

18-
tcx.dcx().emit_err(TypeOf { span: tcx.def_span(id.owner_id), type_of });
19+
res = Err(tcx.dcx().emit_err(TypeOf { span: tcx.def_span(id.owner_id), type_of }));
1920
}
2021
}
2122
}
23+
res
2224
}
2325

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

‎compiler/rustc_hir_analysis/src/lib.rs

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

101+
use rustc_errors::ErrorGuaranteed;
101102
use rustc_hir as hir;
102103
use rustc_middle::middle;
103104
use rustc_middle::query::Providers;
@@ -155,13 +156,11 @@ pub fn provide(providers: &mut Providers) {
155156
hir_wf_check::provide(providers);
156157
}
157158

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

161162
if tcx.features().rustc_attrs {
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);
163+
tcx.sess.time("outlives_testing", || outlives::test::test_inferred_outlives(tcx))?;
165164
}
166165

167166
tcx.sess.time("coherence_checking", || {
@@ -177,6 +176,14 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
177176
let _ = tcx.ensure().crate_inherent_impls_overlap_check(());
178177
});
179178

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+
180187
// Make sure we evaluate all static and (non-associated) const items, even if unused.
181188
// If any of these fail to evaluate, we do not want this crate to pass compilation.
182189
tcx.hir().par_body_owners(|item_def_id| {
@@ -191,6 +198,21 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
191198
// Freeze definitions as we don't add new ones at this point. This improves performance by
192199
// allowing lock-free access to them.
193200
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(())
194216
}
195217

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

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

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

4-
pub fn test_inferred_outlives(tcx: TyCtxt<'_>) {
4+
pub fn test_inferred_outlives(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
5+
let mut res = Ok(());
56
for id in tcx.hir().items() {
67
// For unit testing: check for a special "rustc_outlives"
78
// attribute and report an error with various results if found.
@@ -22,7 +23,8 @@ pub fn test_inferred_outlives(tcx: TyCtxt<'_>) {
2223
for p in pred {
2324
err.note(p);
2425
}
25-
err.emit();
26+
res = Err(err.emit());
2627
}
2728
}
29+
res
2830
}

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,21 @@ 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;
56

67
use crate::errors;
78

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

14-
tcx.dcx().emit_err(errors::VariancesOf {
16+
res = Err(tcx.dcx().emit_err(errors::VariancesOf {
1517
span: tcx.def_span(id.owner_id),
1618
variances_of: format!("{variances_of:?}"),
17-
});
19+
}));
1820
}
1921
}
2022
}
@@ -25,10 +27,11 @@ pub fn test_variance(tcx: TyCtxt<'_>) {
2527
if tcx.has_attr(id.owner_id, sym::rustc_variance) {
2628
let variances_of = tcx.variances_of(id.owner_id);
2729

28-
tcx.dcx().emit_err(errors::VariancesOf {
30+
res = Err(tcx.dcx().emit_err(errors::VariancesOf {
2931
span: tcx.def_span(id.owner_id),
3032
variances_of: format!("{variances_of:?}"),
31-
});
33+
}));
3234
}
3335
}
36+
res
3437
}

‎compiler/rustc_interface/src/passes.rs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -734,22 +734,19 @@ 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("typeck_and_mir_analyses", || {
739+
sess.time("MIR_borrow_checking", || {
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-
}
749741
// Run unsafety check because it's responsible for stealing and
750742
// deallocating THIR.
751743
tcx.ensure().check_unsafety(def_id);
752-
tcx.ensure().mir_borrowck(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() {
753750
if !tcx.sess.opts.unstable_opts.thir_unsafeck {
754751
rustc_mir_transform::check_unsafety::check_unsafety(tcx, def_id);
755752
}
@@ -764,15 +761,15 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
764761
tcx.ensure().mir_drops_elaborated_and_const_checked(def_id);
765762
tcx.ensure().unused_generic_params(ty::InstanceDef::Item(def_id.to_def_id()));
766763
}
767-
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-
})
764+
}
773765
});
774766

775-
tcx.ensure().check_unused_traits(());
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+
}
772+
});
776773

777774
sess.time("layout_testing", || layout_test::test_layout(tcx));
778775
sess.time("abi_testing", || abi_test::test_abi(tcx));

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
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-
141
error[E0369]: binary operation `==` cannot be applied to type `for<'a> fn(&'a i32) -> &'a i32 {foo}`
152
--> $DIR/issue-77910-1.rs:8:5
163
|
@@ -35,6 +22,19 @@ LL | assert_eq!(foo, y);
3522
= help: use parentheses to call this function: `foo(/* &i32 */)`
3623
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
3724

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[E0381]: used binding `xs` isn't initialized
2-
--> $DIR/issue-77910-2.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-
141
error[E0369]: binary operation `==` cannot be applied to type `for<'a> fn(&'a i32) -> &'a i32 {foo}`
152
--> $DIR/issue-77910-2.rs:7:12
163
|
@@ -24,6 +11,19 @@ help: use parentheses to call this function
2411
LL | if foo(/* &i32 */) == y {}
2512
| ++++++++++++
2613

14+
error[E0381]: used binding `xs` isn't initialized
15+
--> $DIR/issue-77910-2.rs:3:5
16+
|
17+
LL | let xs;
18+
| -- binding declared here but left uninitialized
19+
LL | xs
20+
| ^^ `xs` used here but it isn't initialized
21+
|
22+
help: consider assigning a value
23+
|
24+
LL | let xs = todo!();
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,15 +13,6 @@ 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-
2516
warning: creating a mutable reference to mutable static is discouraged
2617
--> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:27:16
2718
|
@@ -36,6 +27,29 @@ help: use `addr_of_mut!` instead to create a raw pointer
3627
LL | c1(addr_of_mut!(Z));
3728
| ~~~~~~~~~~~~~~~
3829

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+
3953
error[E0594]: cannot assign to `x`, as it is not declared as mutable
4054
--> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:22:50
4155
|
@@ -81,20 +95,6 @@ LL | || {
8195
LL | &mut x.0;
8296
| ^^^^^^^^ cannot borrow as mutable
8397

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,12 +21,6 @@ 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-
3024
error[E0308]: mismatched types
3125
--> $DIR/type_mismatch.rs:12:20
3226
|
@@ -35,6 +29,12 @@ LL | pub fn q_user() -> [u8; <[u8; 13] as Q>::ASSOC] {}
3529
| |
3630
| implicitly returns `()` as its body has no tail or `return` expression
3731

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,6 +34,14 @@ 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+
3745
error[E0015]: cannot call non-const operator in constants
3846
--> $DIR/unify-op-with-fn-call.rs:20:39
3947
|
@@ -57,14 +65,6 @@ LL | bar::<{ std::ops::Add::add(N, N) }>();
5765
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
5866
= help: add `#![feature(effects)]` to the crate attributes to enable
5967

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,18 +16,6 @@ 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-
3119
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
3220
--> $DIR/transmute-fail.rs:23:5
3321
|
@@ -46,6 +34,18 @@ LL | std::mem::transmute(v)
4634
= note: source type: `[[[u32; 8888888]; 9999999]; 777777777]` (values of the type `[[u32; 8888888]; 9999999]` are too big for the current architecture)
4735
= note: target type: `[[[u32; 9999999]; 777777777]; 8888888]` (values of the type `[[u32; 9999999]; 777777777]` are too big for the current architecture)
4836

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,12 +10,6 @@ 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-
1913
error[E0308]: mismatched types
2014
--> $DIR/type_mismatch.rs:6:26
2115
|
@@ -24,6 +18,12 @@ LL | fn bar<const N: u8>() -> [u8; N] {}
2418
| |
2519
| implicitly returns `()` as its body has no tail or `return` expression
2620

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,6 +16,12 @@ 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+
1925
warning: function cannot return without recursing
2026
--> $DIR/return-mismatches.rs:16:1
2127
|
@@ -27,12 +33,6 @@ LL | become _g1();
2733
= help: a `loop` may express intention better if this is on purpose
2834
= note: `#[warn(unconditional_recursion)]` on by default
2935

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,12 +1,3 @@
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-
101
error[E0308]: mismatched types
112
--> $DIR/if-no-match-bindings.rs:19:8
123
|
@@ -99,6 +90,15 @@ LL - while &mut true {}
9990
LL + while true {}
10091
|
10192

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,19 +1,3 @@
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-
171
error[E0271]: type mismatch resolving `<{integer} as Fun>::F<'_> == [u8]`
182
--> $DIR/issue-74684-2.rs:21:9
193
|
@@ -33,6 +17,22 @@ note: required by a bound in `bug`
3317
LL | fn bug<'a, T: ?Sized + Fun<F<'a> = [u8]>>(t: Box<T>) -> &'static T::F<'a> {
3418
| ^^^^^^^^^^^^ required by this bound in `bug`
3519

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,19 +18,6 @@ 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-
3421
error[E0277]: the trait bound `for<'ccx> B: Bar<'ccx>` is not satisfied
3522
--> $DIR/hrtb-higher-ranker-supertraits.rs:35:26
3623
|
@@ -51,6 +38,19 @@ help: consider further restricting this bound
5138
LL | where B : Bar<'x> + for<'ccx> Bar<'ccx>
5239
| +++++++++++++++++++++
5340

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,12 +1,3 @@
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-
101
error[E0308]: mismatched types
112
--> $DIR/issue-11374.rs:27:15
123
|
@@ -27,6 +18,15 @@ help: consider mutably borrowing here
2718
LL | c.read_to(&mut v);
2819
| ++++
2920

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,15 +74,6 @@ 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-
8677
error[E0277]: the trait bound `String: Copy` is not satisfied
8778
--> $DIR/kindck-impl-type-params.rs:36:13
8879
|
@@ -120,6 +111,15 @@ LL + #[derive(Copy)]
120111
LL | struct Foo; // does not impl Copy
121112
|
122113

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,14 +12,6 @@ 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-
2315
error[E0277]: `(dyn Dummy + 'a)` cannot be sent between threads safely
2416
--> $DIR/kindck-send-object1.rs:29:19
2517
|
@@ -36,6 +28,14 @@ note: required by a bound in `assert_send`
3628
LL | fn assert_send<T:Send+'static>() { }
3729
| ^^^^ required by this bound in `assert_send`
3830

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,19 +1,3 @@
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-
171
error[E0308]: `match` arms have incompatible types
182
--> $DIR/issue-17728.rs:108:14
193
|
@@ -32,6 +16,22 @@ LL | | }
3216
= note: expected enum `RoomDirection`
3317
found enum `Option<_>`
3418

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,6 +40,12 @@ 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+
4349
warning: value assigned to `t` is never read
4450
--> $DIR/liveness-consts.rs:42:9
4551
|
@@ -54,11 +60,5 @@ warning: unused variable: `w`
5460
LL | let w = 10;
5561
| ^ help: if this is intentional, prefix it with an underscore: `_w`
5662

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,14 +1,3 @@
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-
121
error[E0308]: mismatched types
132
--> $DIR/liveness-forgot-ret.rs:4:19
143
|
@@ -22,6 +11,17 @@ help: consider returning the local binding `a`
2211
LL | fn f(a: isize) -> isize { if god_exists(a) { return 5; }; a }
2312
| +
2413

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,3 +1,18 @@
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+
116
error: unused variable: `x`
217
--> $DIR/liveness-unused.rs:8:7
318
|
@@ -75,21 +90,6 @@ error: unused variable: `x`
7590
LL | for (x, _) in [1, 2, 3].iter().enumerate() { }
7691
| ^ help: if this is intentional, prefix it with an underscore: `_x`
7792

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,3 +1,14 @@
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+
112
error: lifetime may not live long enough
213
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:8:5
314
|
@@ -27,17 +38,6 @@ LL | a(x, y);
2738
= note: mutable references are invariant over their type parameter
2839
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
2940

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,3 +1,14 @@
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+
112
error: lifetime may not live long enough
213
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:9:5
314
|
@@ -27,17 +38,6 @@ LL | a(x, y, z);
2738
= note: mutable references are invariant over their type parameter
2839
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
2940

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,3 +1,14 @@
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+
112
error: lifetime may not live long enough
213
--> $DIR/regions-lifetime-bounds-on-fns.rs:8:5
314
|
@@ -27,17 +38,6 @@ LL | a(x, y);
2738
= note: mutable references are invariant over their type parameter
2839
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
2940

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,19 +1,3 @@
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-
171
error[E0308]: mismatched types
182
--> $DIR/issue-102892.rs:16:26
193
|
@@ -68,6 +52,22 @@ help: alternatively, consider changing the type annotation
6852
LL | let (a, b): ((A, B), &A) = (&mut *mutation, &(**arc).0); // suggests putting `&**arc` here too
6953
| +
7054

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: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,3 @@
1-
error: [*, o]
2-
--> $DIR/variance.rs:8:29
3-
|
4-
LL | type NotCapturedEarly<'a> = impl Sized;
5-
| ^^^^^^^^^^
6-
7-
error: [*, o]
8-
--> $DIR/variance.rs:11:26
9-
|
10-
LL | type CapturedEarly<'a> = impl Sized + Captures<'a>;
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
12-
13-
error: [*, o, o]
14-
--> $DIR/variance.rs:14:56
15-
|
16-
LL | type NotCapturedLate<'a> = dyn for<'b> Iterator<Item = impl Sized>;
17-
| ^^^^^^^^^^
18-
19-
error: [*, o, o]
20-
--> $DIR/variance.rs:18:49
21-
|
22-
LL | type Captured<'a> = dyn for<'b> Iterator<Item = impl Sized + Captures<'a>>;
23-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
24-
25-
error: [*, *, o, o, o]
26-
--> $DIR/variance.rs:22:27
27-
|
28-
LL | type Bar<'a, 'b: 'b, T> = impl Sized;
29-
| ^^^^^^^^^^
30-
31-
error: [*, *, o, o]
32-
--> $DIR/variance.rs:34:32
33-
|
34-
LL | type ImplicitCapture<'a> = impl Sized;
35-
| ^^^^^^^^^^
36-
37-
error: [*, *, o, o]
38-
--> $DIR/variance.rs:37:42
39-
|
40-
LL | type ExplicitCaptureFromHeader<'a> = impl Sized + Captures<'i>;
41-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
42-
43-
error: [*, *, o, o]
44-
--> $DIR/variance.rs:40:39
45-
|
46-
LL | type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>;
47-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
48-
49-
error: [*, *, o, o]
50-
--> $DIR/variance.rs:45:32
51-
|
52-
LL | type ImplicitCapture<'a> = impl Sized;
53-
| ^^^^^^^^^^
54-
55-
error: [*, *, o, o]
56-
--> $DIR/variance.rs:48:42
57-
|
58-
LL | type ExplicitCaptureFromHeader<'a> = impl Sized + Captures<'i>;
59-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
60-
61-
error: [*, *, o, o]
62-
--> $DIR/variance.rs:51:39
63-
|
64-
LL | type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>;
65-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
66-
671
error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from `dyn` type
682
--> $DIR/variance.rs:14:56
693
|
@@ -176,6 +110,72 @@ LL | type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>;
176110
|
177111
= note: `ExplicitCaptureFromGat` must be used in combination with a concrete type within the same impl
178112

113+
error: [*, o]
114+
--> $DIR/variance.rs:8:29
115+
|
116+
LL | type NotCapturedEarly<'a> = impl Sized;
117+
| ^^^^^^^^^^
118+
119+
error: [*, o]
120+
--> $DIR/variance.rs:11:26
121+
|
122+
LL | type CapturedEarly<'a> = impl Sized + Captures<'a>;
123+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
124+
125+
error: [*, o, o]
126+
--> $DIR/variance.rs:14:56
127+
|
128+
LL | type NotCapturedLate<'a> = dyn for<'b> Iterator<Item = impl Sized>;
129+
| ^^^^^^^^^^
130+
131+
error: [*, o, o]
132+
--> $DIR/variance.rs:18:49
133+
|
134+
LL | type Captured<'a> = dyn for<'b> Iterator<Item = impl Sized + Captures<'a>>;
135+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
136+
137+
error: [*, *, o, o, o]
138+
--> $DIR/variance.rs:22:27
139+
|
140+
LL | type Bar<'a, 'b: 'b, T> = impl Sized;
141+
| ^^^^^^^^^^
142+
143+
error: [*, *, o, o]
144+
--> $DIR/variance.rs:34:32
145+
|
146+
LL | type ImplicitCapture<'a> = impl Sized;
147+
| ^^^^^^^^^^
148+
149+
error: [*, *, o, o]
150+
--> $DIR/variance.rs:37:42
151+
|
152+
LL | type ExplicitCaptureFromHeader<'a> = impl Sized + Captures<'i>;
153+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
154+
155+
error: [*, *, o, o]
156+
--> $DIR/variance.rs:40:39
157+
|
158+
LL | type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>;
159+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
160+
161+
error: [*, *, o, o]
162+
--> $DIR/variance.rs:45:32
163+
|
164+
LL | type ImplicitCapture<'a> = impl Sized;
165+
| ^^^^^^^^^^
166+
167+
error: [*, *, o, o]
168+
--> $DIR/variance.rs:48:42
169+
|
170+
LL | type ExplicitCaptureFromHeader<'a> = impl Sized + Captures<'i>;
171+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
172+
173+
error: [*, *, o, o]
174+
--> $DIR/variance.rs:51:39
175+
|
176+
LL | type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>;
177+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
178+
179179
error: aborting due to 24 previous errors
180180

181181
For more information about this error, try `rustc --explain E0657`.
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
error: [o]
2-
--> $DIR/variance-associated-consts.rs:13:1
3-
|
4-
LL | struct Foo<T: Trait> {
5-
| ^^^^^^^^^^^^^^^^^^^^
6-
71
error: unconstrained generic constant
82
--> $DIR/variance-associated-consts.rs:14:12
93
|
@@ -12,5 +6,11 @@ LL | field: [u8; <T as Trait>::Const]
126
|
137
= help: try adding a `where` bound using this expression: `where [(); <T as Trait>::Const]:`
148

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,3 +1,11 @@
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+
19
error: [+, +, +]
210
--> $DIR/variance-regions-direct.rs:9:1
311
|
@@ -40,14 +48,6 @@ error: [-, +, o]
4048
LL | enum Test8<'a, 'b, 'c:'b> {
4149
| ^^^^^^^^^^^^^^^^^^^^^^^^^
4250

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,33 +1,3 @@
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-
311
error[E0392]: lifetime parameter `'d` is never used
322
--> $DIR/variance-regions-indirect.rs:8:26
333
|
@@ -60,6 +30,36 @@ LL | struct Derived3<'a:'b, 'b, 'c> {
6030
|
6131
= help: consider removing `'c`, referring to it in a field, or using a marker such as `PhantomData`
6232

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,27 +1,3 @@
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-
251
error[E0392]: type parameter `U` is never used
262
--> $DIR/variance-trait-bounds.rs:21:15
273
|
@@ -49,6 +25,30 @@ LL | struct TestBox<U,T:Getter<U>+Setter<U>> {
4925
= help: consider removing `U`, referring to it in a field, or using a marker such as `PhantomData`
5026
= help: if you intended `U` to be a const parameter, use `const U: /* Type */` instead
5127

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.