File tree 3 files changed +37
-1
lines changed
compiler/rustc_typeck/src
3 files changed +37
-1
lines changed Original file line number Diff line number Diff line change 1
1
use crate :: collect:: ItemCtxt ;
2
2
use rustc_hir as hir;
3
3
use rustc_hir:: intravisit:: { self , Visitor } ;
4
- use rustc_hir:: HirId ;
4
+ use rustc_hir:: { ForeignItem , ForeignItemKind , HirId } ;
5
5
use rustc_infer:: infer:: TyCtxtInferExt ;
6
6
use rustc_infer:: traits:: TraitEngine ;
7
7
use rustc_infer:: traits:: { ObligationCause , WellFormedLoc } ;
@@ -141,6 +141,9 @@ fn diagnostic_hir_wf_check<'tcx>(
141
141
ref item => bug ! ( "Unexpected item {:?}" , item) ,
142
142
} ,
143
143
hir:: Node :: Field ( field) => Some ( field. ty ) ,
144
+ hir:: Node :: ForeignItem ( ForeignItem {
145
+ kind : ForeignItemKind :: Static ( ty, _) , ..
146
+ } ) => Some ( * ty) ,
144
147
ref node => bug ! ( "Unexpected node {:?}" , node) ,
145
148
} ,
146
149
WellFormedLoc :: Param { function : _, param_idx } => {
Original file line number Diff line number Diff line change
1
+ // Regression test for the ICE described in #95665.
2
+ // Ensure that the expected error is output (and thus that there is no ICE)
3
+
4
+ pub trait Trait : { }
5
+
6
+ pub struct Struct < T : Trait > {
7
+ member : T ,
8
+ }
9
+
10
+ // uncomment and bug goes away
11
+ // impl Trait for u8 {}
12
+
13
+ extern "C" {
14
+ static VAR : Struct < u8 > ;
15
+ //~^ 14:17: 14:27: the trait bound `u8: Trait` is not satisfied [E0277]
16
+ }
17
+
18
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0277]: the trait bound `u8: Trait` is not satisfied
2
+ --> $DIR/issue-95665.rs:14:17
3
+ |
4
+ LL | static VAR: Struct<u8>;
5
+ | ^^^^^^^^^^ the trait `Trait` is not implemented for `u8`
6
+ |
7
+ note: required by a bound in `Struct`
8
+ --> $DIR/issue-95665.rs:6:22
9
+ |
10
+ LL | pub struct Struct<T: Trait> {
11
+ | ^^^^^ required by this bound in `Struct`
12
+
13
+ error: aborting due to previous error
14
+
15
+ For more information about this error, try `rustc --explain E0277`.
You can’t perform that action at this time.
0 commit comments