Skip to content

Fix up partial res of segment in primitive resolution hack #139127

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

Merged
merged 1 commit into from
Apr 14, 2025
Merged
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
5 changes: 5 additions & 0 deletions compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4598,6 +4598,11 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
}
};

// Fix up partial res of segment from `resolve_path` call.
if let Some(id) = path[0].id {
self.r.partial_res_map.insert(id, PartialRes::new(Res::PrimTy(prim)));
}

PartialRes::with_unresolved_segments(Res::PrimTy(prim), path.len() - 1)
}
PathResult::Module(ModuleOrUniformRoot::Module(module)) => {
Expand Down
1 change: 1 addition & 0 deletions tests/ui/resolve/auxiliary/empty.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Intentionally empty.
8 changes: 8 additions & 0 deletions tests/ui/resolve/prim-crate-partial-res.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//@ aux-build: empty.rs

extern crate empty as usize;

fn foo() -> usize<()> { 0 }
//~^ ERROR type arguments are not allowed on builtin type `usize`

fn main() {}
17 changes: 17 additions & 0 deletions tests/ui/resolve/prim-crate-partial-res.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
error[E0109]: type arguments are not allowed on builtin type `usize`
--> $DIR/prim-crate-partial-res.rs:5:19
|
LL | fn foo() -> usize<()> { 0 }
| ----- ^^ type argument not allowed
| |
| not allowed on builtin type `usize`
|
help: primitive type `usize` doesn't have generic parameters
|
LL - fn foo() -> usize<()> { 0 }
LL + fn foo() -> usize { 0 }
|

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0109`.
Loading