File tree Expand file tree Collapse file tree 4 files changed +59
-3
lines changed
compiler/rustc_middle/src Expand file tree Collapse file tree 4 files changed +59
-3
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,7 @@ impl<'tcx> TyCtxt<'tcx> {
133133 /// If calling repeatedly and iterating over parents, prefer [`Map::parent_iter`].
134134 pub fn parent_hir_id ( self , hir_id : HirId ) -> HirId {
135135 let HirId { owner, local_id } = hir_id;
136+ info ! ( ?owner, ?local_id) ;
136137 if local_id == ItemLocalId :: from_u32 ( 0 ) {
137138 self . hir_owner_parent ( owner)
138139 } else {
Original file line number Diff line number Diff line change @@ -2251,9 +2251,15 @@ impl<'tcx> TyCtxt<'tcx> {
22512251 /// Find the crate root and the appropriate span where `use` and outer attributes can be
22522252 /// inserted at.
22532253 pub fn crate_level_attribute_injection_span ( self , hir_id : HirId ) -> Option < Span > {
2254- for ( _hir_id, node) in self . hir ( ) . parent_iter ( hir_id) {
2255- if let hir:: Node :: Crate ( m) = node {
2256- return Some ( m. spans . inject_use_span . shrink_to_lo ( ) ) ;
2254+ for ( _hir_id, node) in
2255+ [ ( hir_id, self . hir_node ( hir_id) ) ] . into_iter ( ) . chain ( self . hir ( ) . parent_iter ( hir_id) )
2256+ {
2257+ match node {
2258+ hir:: Node :: Synthetic => return None ,
2259+ hir:: Node :: Crate ( m) => {
2260+ return Some ( m. spans . inject_use_span . shrink_to_lo ( ) ) ;
2261+ }
2262+ _ => { }
22572263 }
22582264 }
22592265 None
Original file line number Diff line number Diff line change 1+ pub trait Foo < ' a > {
2+ type Assoc ;
3+
4+ fn demo ( ) -> impl Foo
5+ //~^ ERROR missing lifetime specifier
6+ //~| ERROR the trait bound `String: Copy` is not satisfied
7+ where
8+ String : Copy ;
9+ //~^ ERROR the trait bound `String: Copy` is not satisfied
10+ }
11+
12+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error[E0106]: missing lifetime specifier
2+ --> $DIR/dont-panic-by-accessing-parent-hir-of-synthetic.rs:4:23
3+ |
4+ LL | fn demo() -> impl Foo
5+ | ^^^ expected named lifetime parameter
6+ |
7+ = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
8+ help: consider using the `'a` lifetime
9+ |
10+ LL | fn demo() -> impl Foo<'a>
11+ | ++++
12+
13+ error[E0277]: the trait bound `String: Copy` is not satisfied
14+ --> $DIR/dont-panic-by-accessing-parent-hir-of-synthetic.rs:8:9
15+ |
16+ LL | String: Copy;
17+ | ^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
18+ |
19+ = help: see issue #48214
20+ help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
21+ |
22+ LL + #![feature(trivial_bounds)]
23+ |
24+
25+ error[E0277]: the trait bound `String: Copy` is not satisfied
26+ --> $DIR/dont-panic-by-accessing-parent-hir-of-synthetic.rs:4:18
27+ |
28+ LL | fn demo() -> impl Foo
29+ | ^^^^^^^^ the trait `Copy` is not implemented for `String`
30+ |
31+ = help: see issue #48214
32+ = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
33+
34+ error: aborting due to 3 previous errors
35+
36+ Some errors have detailed explanations: E0106, E0277.
37+ For more information about an error, try `rustc --explain E0106`.
You can’t perform that action at this time.
0 commit comments