Skip to content

Commit 42f7764

Browse files
committed
solve ICE by avoiding the case with ty::Error
1 parent 747a5d2 commit 42f7764

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed

compiler/rustc_typeck/src/astconv/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1681,6 +1681,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
16811681
// item is declared.
16821682
let bound = match (&qself_ty.kind(), qself_res) {
16831683
(_, Res::SelfTy(Some(_), Some((impl_def_id, _)))) => {
1684+
match qself_ty.kind() {
1685+
ty::Error(_) => return Err(ErrorReported),
1686+
_ => {}
1687+
}
16841688
// `Self` in an impl of a trait -- we have a concrete self type and a
16851689
// trait reference.
16861690
let trait_ref = match tcx.impl_trait_ref(impl_def_id) {

src/test/ui/binding/issue-85350.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Test the ICE of issue 85350
2+
3+
impl FnMut(&Context) for 'tcx {
4+
//~^ ERROR lifetime in trait object type must be followed by `+`
5+
//~| ERROR cannot find type `Context` in this scope [E0412]
6+
//~| ERROR `main` function not found in crate `issue_85350`
7+
//~| ERROR at least one trait is required for an object type
8+
//~| ERROR use of undeclared lifetime name `'tcx`
9+
//~| ERROR associated type bindings are not allowed here
10+
//~| WARNING trait objects without an explicit `dyn` are deprecated
11+
//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
12+
fn print () -> Self :: Output{ }
13+
//~^ ERROR method `print` is not a member of trait `FnMut`
14+
}
+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
error: lifetime in trait object type must be followed by `+`
2+
--> $DIR/issue-85350.rs:3:26
3+
|
4+
LL | impl FnMut(&Context) for 'tcx {
5+
| ^^^^
6+
7+
error[E0407]: method `print` is not a member of trait `FnMut`
8+
--> $DIR/issue-85350.rs:12:5
9+
|
10+
LL | fn print () -> Self :: Output{ }
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `FnMut`
12+
13+
error[E0412]: cannot find type `Context` in this scope
14+
--> $DIR/issue-85350.rs:3:13
15+
|
16+
LL | impl FnMut(&Context) for 'tcx {
17+
| ^^^^^^^ not found in this scope
18+
|
19+
help: consider importing this struct
20+
|
21+
LL | use std::task::Context;
22+
|
23+
24+
warning: trait objects without an explicit `dyn` are deprecated
25+
--> $DIR/issue-85350.rs:3:26
26+
|
27+
LL | impl FnMut(&Context) for 'tcx {
28+
| ^^^^ help: use `dyn`: `dyn 'tcx`
29+
|
30+
= note: `#[warn(bare_trait_objects)]` on by default
31+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
32+
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
33+
34+
error[E0601]: `main` function not found in crate `issue_85350`
35+
--> $DIR/issue-85350.rs:3:1
36+
|
37+
LL | / impl FnMut(&Context) for 'tcx {
38+
LL | |
39+
LL | |
40+
LL | |
41+
... |
42+
LL | |
43+
LL | | }
44+
| |_^ consider adding a `main` function to `$DIR/issue-85350.rs`
45+
46+
error[E0224]: at least one trait is required for an object type
47+
--> $DIR/issue-85350.rs:3:26
48+
|
49+
LL | impl FnMut(&Context) for 'tcx {
50+
| ^^^^
51+
52+
error[E0261]: use of undeclared lifetime name `'tcx`
53+
--> $DIR/issue-85350.rs:3:26
54+
|
55+
LL | impl FnMut(&Context) for 'tcx {
56+
| - ^^^^ undeclared lifetime
57+
| |
58+
| help: consider introducing lifetime `'tcx` here: `<'tcx>`
59+
|
60+
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes
61+
62+
error[E0229]: associated type bindings are not allowed here
63+
--> $DIR/issue-85350.rs:3:6
64+
|
65+
LL | impl FnMut(&Context) for 'tcx {
66+
| ^^^^^^^^^^^^^^^ associated type not allowed here
67+
68+
error: aborting due to 7 previous errors; 1 warning emitted
69+
70+
Some errors have detailed explanations: E0224, E0229, E0261, E0407, E0412, E0601.
71+
For more information about an error, try `rustc --explain E0224`.

0 commit comments

Comments
 (0)