Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 6b80b15

Browse files
authored
Rollup merge of rust-lang#97471 - estebank:prohibit-generics, r=cjgillot
Provide more context when denying invalid type params
2 parents 53ab3b2 + cd8cfbf commit 6b80b15

30 files changed

+998
-315
lines changed

compiler/rustc_typeck/src/astconv/mod.rs

Lines changed: 287 additions & 77 deletions
Large diffs are not rendered by default.

compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12281228
None
12291229
}
12301230
}),
1231+
|_| {},
12311232
);
12321233

12331234
if let Res::Local(hid) = res {

compiler/rustc_typeck/src/check/fn_ctxt/checks.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,13 +1564,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15641564
QPath::TypeRelative(ref qself, ref segment) => {
15651565
let ty = self.to_ty(qself);
15661566

1567-
let res = if let hir::TyKind::Path(QPath::Resolved(_, ref path)) = qself.kind {
1568-
path.res
1569-
} else {
1570-
Res::Err
1571-
};
15721567
let result = <dyn AstConv<'_>>::associated_path_to_ty(
1573-
self, hir_id, path_span, ty, res, segment, true,
1568+
self, hir_id, path_span, ty, qself, segment, true,
15741569
);
15751570
let ty = result.map(|(ty, _, _)| ty).unwrap_or_else(|_| self.tcx().ty_error());
15761571
let result = result.map(|(_, kind, def_id)| (kind, def_id));

src/test/ui/derives/issue-97343.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::fmt::Debug;
22

33
#[derive(Debug)]
4-
pub struct Irrelevant<Irrelevant> { //~ ERROR type arguments are not allowed for this type
4+
pub struct Irrelevant<Irrelevant> { //~ ERROR type arguments are not allowed on type parameter
55
irrelevant: Irrelevant,
66
}
77

src/test/ui/derives/issue-97343.stderr

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1-
error[E0109]: type arguments are not allowed for this type
1+
error[E0109]: type arguments are not allowed on type parameter `Irrelevant`
22
--> $DIR/issue-97343.rs:4:23
33
|
44
LL | #[derive(Debug)]
5-
| ----- in this derive macro expansion
5+
| -----
6+
| |
7+
| not allowed on this
8+
| in this derive macro expansion
69
LL | pub struct Irrelevant<Irrelevant> {
710
| ^^^^^^^^^^ type argument not allowed
811
|
12+
note: type parameter `Irrelevant` defined here
13+
--> $DIR/issue-97343.rs:4:23
14+
|
15+
LL | pub struct Irrelevant<Irrelevant> {
16+
| ^^^^^^^^^^
917
= note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
1018

1119
error: aborting due to previous error

src/test/ui/error-codes/E0109.stderr

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
error[E0109]: type arguments are not allowed for this type
1+
error[E0109]: type arguments are not allowed on this type
22
--> $DIR/E0109.rs:1:14
33
|
44
LL | type X = u32<i32>;
5-
| ^^^ type argument not allowed
5+
| --- ^^^ type argument not allowed
6+
| |
7+
| not allowed on this
8+
|
9+
help: primitive type `u32` doesn't have generic parameters
10+
|
11+
LL - type X = u32<i32>;
12+
LL + type X = u32;
13+
|
614

715
error: aborting due to previous error
816

src/test/ui/error-codes/E0110.stderr

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
error[E0109]: lifetime arguments are not allowed for this type
1+
error[E0109]: lifetime arguments are not allowed on this type
22
--> $DIR/E0110.rs:1:14
33
|
44
LL | type X = u32<'static>;
5-
| ^^^^^^^ lifetime argument not allowed
5+
| --- ^^^^^^^ lifetime argument not allowed
6+
| |
7+
| not allowed on this
8+
|
9+
help: primitive type `u32` doesn't have generic parameters
10+
|
11+
LL - type X = u32<'static>;
12+
LL + type X = u32;
13+
|
614

715
error: aborting due to previous error
816

src/test/ui/issues/issue-22706.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
fn is_copy<T: ::std::marker<i32>::Copy>() {}
2-
//~^ ERROR type arguments are not allowed for this type [E0109]
2+
//~^ ERROR type arguments are not allowed on module `marker` [E0109]
33
fn main() {}

src/test/ui/issues/issue-22706.stderr

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
error[E0109]: type arguments are not allowed for this type
1+
error[E0109]: type arguments are not allowed on module `marker`
22
--> $DIR/issue-22706.rs:1:29
33
|
44
LL | fn is_copy<T: ::std::marker<i32>::Copy>() {}
5-
| ^^^ type argument not allowed
5+
| ------ ^^^ type argument not allowed
6+
| |
7+
| not allowed on this
68

79
error: aborting due to previous error
810

src/test/ui/issues/issue-57924.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pub struct Gcm<E>(E);
33
impl<E> Gcm<E> {
44
pub fn crash(e: E) -> Self {
55
Self::<E>(e)
6-
//~^ ERROR type arguments are not allowed for this type
6+
//~^ ERROR type arguments are not allowed on self constructor
77
}
88
}
99

0 commit comments

Comments
 (0)