Skip to content

Commit cc01bbe

Browse files
authored
Rollup merge of rust-lang#82259 - osa1:issue82156, r=petrochenkov
Fix popping singleton paths in when generating E0433 Fixes rust-lang#82156 --- This was introduced with rust-lang#72923, so pinging `@Patryk27` for reviews.
2 parents c244546 + 9889e44 commit cc01bbe

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

compiler/rustc_resolve/src/late.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -1801,7 +1801,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
18011801
crate_lint: CrateLint,
18021802
) -> PartialRes {
18031803
tracing::debug!(
1804-
"smart_resolve_path_fragment(id={:?},qself={:?},path={:?}",
1804+
"smart_resolve_path_fragment(id={:?}, qself={:?}, path={:?})",
18051805
id,
18061806
qself,
18071807
path
@@ -1841,11 +1841,10 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
18411841

18421842
// Before we start looking for candidates, we have to get our hands
18431843
// on the type user is trying to perform invocation on; basically:
1844-
// we're transforming `HashMap::new` into just `HashMap`
1845-
let path = if let Some((_, path)) = path.split_last() {
1846-
path
1847-
} else {
1848-
return Some(parent_err);
1844+
// we're transforming `HashMap::new` into just `HashMap`.
1845+
let path = match path.split_last() {
1846+
Some((_, path)) if !path.is_empty() => path,
1847+
_ => return Some(parent_err),
18491848
};
18501849

18511850
let (mut err, candidates) =

src/test/ui/resolve/issue-82156.rs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
super(); //~ ERROR failed to resolve: there are too many leading `super` keywords
3+
}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0433]: failed to resolve: there are too many leading `super` keywords
2+
--> $DIR/issue-82156.rs:2:5
3+
|
4+
LL | super();
5+
| ^^^^^ there are too many leading `super` keywords
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0433`.

0 commit comments

Comments
 (0)