Skip to content

Commit 18c787f

Browse files
Fix up partial res of segment in primitive resolution hack
1 parent 2196aff commit 18c787f

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

compiler/rustc_resolve/src/late.rs

+5
Original file line numberDiff line numberDiff line change
@@ -4598,6 +4598,11 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
45984598
}
45994599
};
46004600

4601+
// Fix up partial res of segment from `resolve_path` call.
4602+
if let Some(id) = path[0].id {
4603+
self.r.partial_res_map.insert(id, PartialRes::new(Res::PrimTy(prim)));
4604+
}
4605+
46014606
PartialRes::with_unresolved_segments(Res::PrimTy(prim), path.len() - 1)
46024607
}
46034608
PathResult::Module(ModuleOrUniformRoot::Module(module)) => {

tests/ui/resolve/auxiliary/empty.rs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Intentionally empty.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@ aux-build: empty.rs
2+
3+
extern crate empty as usize;
4+
5+
fn foo() -> usize<()> { 0 }
6+
//~^ ERROR type arguments are not allowed on builtin type `usize`
7+
8+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0109]: type arguments are not allowed on builtin type `usize`
2+
--> $DIR/prim-crate-partial-res.rs:5:19
3+
|
4+
LL | fn foo() -> usize<()> { 0 }
5+
| ----- ^^ type argument not allowed
6+
| |
7+
| not allowed on builtin type `usize`
8+
|
9+
help: primitive type `usize` doesn't have generic parameters
10+
|
11+
LL - fn foo() -> usize<()> { 0 }
12+
LL + fn foo() -> usize { 0 }
13+
|
14+
15+
error: aborting due to 1 previous error
16+
17+
For more information about this error, try `rustc --explain E0109`.

0 commit comments

Comments
 (0)