Skip to content

Commit c631490

Browse files
Rollup merge of rust-lang#153752 - TKanX:bugfix/delegation-non-fn-ice, r=petrochenkov
fix(delegation): Filter Out Module Segments in Generic Args Inheritance ### Summary: > rust-lang#153421 (merged not so long ago) fixed those issues by adding check that child segment resolves only to `Fn` or `AssocFn`, they should not produce ICEs on `main` now. @aerooneqq ~~Fixes ICE when delegating to a module or crate root inside a trait impl.~~ ~~Filters `DefKind::Mod` in `get_segment`, returning `None` for such segments so compilation fails gracefully with the pre-existing _E0423_ error from the resolver.~~ > > So this PR superseded by rust-lang#153421? Should I close this? > > Adding tests for the fixed issues is still good. @rustbot author @petrochenkov Adds regression tests for rust-lang#153743 and rust-lang#153744. rust-lang#153421 already fixed the root cause; this PR adds test coverage. Closes rust-lang#153743 Closes rust-lang#153744 r? @dingxiangfei2009 cc @matthiaskrgr
2 parents 935805e + f1f5709 commit c631490

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Regression test for #153743 and #153744.
2+
// Delegation to a module or crate root inside a trait impl
3+
// should emit a resolution error, not ICE.
4+
5+
#![feature(fn_delegation)]
6+
#![allow(incomplete_features)]
7+
8+
trait Trait {
9+
fn bar();
10+
fn bar2();
11+
}
12+
13+
impl Trait for () {
14+
reuse std::path::<> as bar;
15+
//~^ ERROR expected function, found module `std::path`
16+
reuse core::<> as bar2;
17+
//~^ ERROR expected function, found crate `core`
18+
}
19+
20+
fn main() {}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0423]: expected function, found module `std::path`
2+
--> $DIR/ice-non-fn-target-in-trait-impl.rs:14:11
3+
|
4+
LL | reuse std::path::<> as bar;
5+
| ^^^^^^^^^^^^^ not a function
6+
7+
error[E0423]: expected function, found crate `core`
8+
--> $DIR/ice-non-fn-target-in-trait-impl.rs:16:11
9+
|
10+
LL | reuse core::<> as bar2;
11+
| ^^^^^^^^ not a function
12+
13+
error: aborting due to 2 previous errors
14+
15+
For more information about this error, try `rustc --explain E0423`.

0 commit comments

Comments
 (0)