Skip to content

solve ICE of issue #85350 by avoiding the case with ty::Error #85477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions compiler/rustc_typeck/src/astconv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1681,6 +1681,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
// item is declared.
let bound = match (&qself_ty.kind(), qself_res) {
(_, Res::SelfTy(Some(_), Some((impl_def_id, _)))) => {
match qself_ty.kind() {
ty::Error(_) => return Err(ErrorReported),
_ => {}
}
// `Self` in an impl of a trait -- we have a concrete self type and a
// trait reference.
let trait_ref = match tcx.impl_trait_ref(impl_def_id) {
Expand Down
14 changes: 14 additions & 0 deletions src/test/ui/binding/issue-85350.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Test the ICE of issue 85350

impl FnMut(&Context) for 'tcx {
//~^ ERROR lifetime in trait object type must be followed by `+`
//~| ERROR cannot find type `Context` in this scope [E0412]
//~| ERROR `main` function not found in crate `issue_85350`
//~| ERROR at least one trait is required for an object type
//~| ERROR use of undeclared lifetime name `'tcx`
//~| ERROR associated type bindings are not allowed here
//~| WARNING trait objects without an explicit `dyn` are deprecated
//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
fn print () -> Self :: Output{ }
//~^ ERROR method `print` is not a member of trait `FnMut`
}
71 changes: 71 additions & 0 deletions src/test/ui/binding/issue-85350.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
error: lifetime in trait object type must be followed by `+`
--> $DIR/issue-85350.rs:3:26
|
LL | impl FnMut(&Context) for 'tcx {
| ^^^^

error[E0407]: method `print` is not a member of trait `FnMut`
--> $DIR/issue-85350.rs:12:5
|
LL | fn print () -> Self :: Output{ }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `FnMut`

error[E0412]: cannot find type `Context` in this scope
--> $DIR/issue-85350.rs:3:13
|
LL | impl FnMut(&Context) for 'tcx {
| ^^^^^^^ not found in this scope
|
help: consider importing this struct
|
LL | use std::task::Context;
|

warning: trait objects without an explicit `dyn` are deprecated
--> $DIR/issue-85350.rs:3:26
|
LL | impl FnMut(&Context) for 'tcx {
| ^^^^ help: use `dyn`: `dyn 'tcx`
|
= note: `#[warn(bare_trait_objects)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>

error[E0601]: `main` function not found in crate `issue_85350`
--> $DIR/issue-85350.rs:3:1
|
LL | / impl FnMut(&Context) for 'tcx {
LL | |
LL | |
LL | |
... |
LL | |
LL | | }
| |_^ consider adding a `main` function to `$DIR/issue-85350.rs`

error[E0224]: at least one trait is required for an object type
--> $DIR/issue-85350.rs:3:26
|
LL | impl FnMut(&Context) for 'tcx {
| ^^^^

error[E0261]: use of undeclared lifetime name `'tcx`
--> $DIR/issue-85350.rs:3:26
|
LL | impl FnMut(&Context) for 'tcx {
| - ^^^^ undeclared lifetime
| |
| help: consider introducing lifetime `'tcx` here: `<'tcx>`
|
= help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes

error[E0229]: associated type bindings are not allowed here
--> $DIR/issue-85350.rs:3:6
|
LL | impl FnMut(&Context) for 'tcx {
| ^^^^^^^^^^^^^^^ associated type not allowed here

error: aborting due to 7 previous errors; 1 warning emitted

Some errors have detailed explanations: E0224, E0229, E0261, E0407, E0412, E0601.
For more information about an error, try `rustc --explain E0224`.