Skip to content
Draft
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
21 changes: 15 additions & 6 deletions gcc/rust/typecheck/rust-hir-type-check-base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,14 @@ TypeCheckBase::resolve_generic_params (
{
if (is_foreign && abi != Rust::ABI::INTRINSIC)
{
rust_error_at (generic_param->get_locus (), ErrorCode::E0044,
"foreign items may not have const parameters");
}
rich_location r(line_table, generic_param->get_locus());
rust_error_at(r, ErrorCode::E0044,
"foreign items may not have const parameters");

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you should be using a rich_location type error for something like this

rust_inform(
generic_param->get_locus(),
"replace the const parameters with concrete types");
}

auto &param
= static_cast<HIR::ConstGenericParam &> (*generic_param);
Expand Down Expand Up @@ -627,9 +632,13 @@ TypeCheckBase::resolve_generic_params (
{
if (is_foreign && abi != Rust::ABI::INTRINSIC)
{
rust_error_at (generic_param->get_locus (), ErrorCode::E0044,
"foreign items may not have type parameters");
}
rich_location r(line_table, generic_param->get_locus());
rust_error_at(r, ErrorCode::E0044,
"foreign items may not have type parameters");

rust_inform(generic_param->get_locus(),
"replace the type parameters with concrete types");
}

auto param_type = TypeResolveGenericParam::Resolve (
*generic_param, false /*resolve_trait_bounds*/);
Expand Down
8 changes: 8 additions & 0 deletions gcc/testsuite/rust/compile/issue-3526.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// { dg-options "-w" }
// { dg-excess-errors "Noisy error reporting" }
extern "C" {
fn some_func<T>(x: T); // { dg-error "foreign items may not have type parameters" }

Check failure on line 4 in gcc/testsuite/rust/compile/issue-3526.rs

View workflow job for this annotation

GitHub Actions / build-alpine-32bit-and-check-alpine-32bit

Test failure (FAIL)

(test for errors, line 4)

Check failure on line 4 in gcc/testsuite/rust/compile/issue-3526.rs

View workflow job for this annotation

GitHub Actions / build-and-check-ubuntu-64bit-glibcxx

Test failure (FAIL)

(test for errors, line 4)

Check failure on line 4 in gcc/testsuite/rust/compile/issue-3526.rs

View workflow job for this annotation

GitHub Actions / build-and-check-asan

Test failure (FAIL)

(test for errors, line 4)

Check failure on line 4 in gcc/testsuite/rust/compile/issue-3526.rs

View workflow job for this annotation

GitHub Actions / build-and-check-ubuntu-64bit

Test failure (FAIL)

(test for errors, line 4)

Check failure on line 4 in gcc/testsuite/rust/compile/issue-3526.rs

View workflow job for this annotation

GitHub Actions / build-and-check-ubuntu-32bit

Test failure (FAIL)

(test for errors, line 4)

Check failure on line 4 in gcc/testsuite/rust/compile/issue-3526.rs

View workflow job for this annotation

GitHub Actions / build-and-check-gcc-5

Test failure (FAIL)

(test for errors, line 4)

Check failure on line 4 in gcc/testsuite/rust/compile/issue-3526.rs

View workflow job for this annotation

GitHub Actions / build-and-check-gcc-5

Test failure (FAIL)

(test for errors, line 4)
// { dg-message "replace the type parameters" "" { target *-*-* } .-1 }

Check failure on line 5 in gcc/testsuite/rust/compile/issue-3526.rs

View workflow job for this annotation

GitHub Actions / build-alpine-32bit-and-check-alpine-32bit

Test failure (FAIL)

at line 5 (test for warnings, line 4)

Check failure on line 5 in gcc/testsuite/rust/compile/issue-3526.rs

View workflow job for this annotation

GitHub Actions / build-and-check-ubuntu-64bit-glibcxx

Test failure (FAIL)

at line 5 (test for warnings, line 4)

Check failure on line 5 in gcc/testsuite/rust/compile/issue-3526.rs

View workflow job for this annotation

GitHub Actions / build-and-check-asan

Test failure (FAIL)

at line 5 (test for warnings, line 4)

Check failure on line 5 in gcc/testsuite/rust/compile/issue-3526.rs

View workflow job for this annotation

GitHub Actions / build-and-check-ubuntu-64bit

Test failure (FAIL)

at line 5 (test for warnings, line 4)

Check failure on line 5 in gcc/testsuite/rust/compile/issue-3526.rs

View workflow job for this annotation

GitHub Actions / build-and-check-ubuntu-32bit

Test failure (FAIL)

at line 5 (test for warnings, line 4)

Check failure on line 5 in gcc/testsuite/rust/compile/issue-3526.rs

View workflow job for this annotation

GitHub Actions / build-and-check-gcc-5

Test failure (FAIL)

at line 5 (test for warnings, line 4)

Check failure on line 5 in gcc/testsuite/rust/compile/issue-3526.rs

View workflow job for this annotation

GitHub Actions / build-and-check-gcc-5

Test failure (FAIL)

at line 5 (test for warnings, line 4)
}

fn main() {}
Loading