@@ -1659,11 +1659,14 @@ fn check_opaque_for_inheriting_lifetimes(tcx: TyCtxt<'tcx>, def_id: DefId, span:
16591659 _ => unreachable ! ( ) ,
16601660 } ;
16611661
1662- tcx. sess . span_err ( span, & format ! (
1662+ tcx. sess . span_err (
1663+ span,
1664+ & format ! (
16631665 "`{}` return type cannot contain a projection or `Self` that references lifetimes from \
16641666 a parent scope",
16651667 if is_async { "async fn" } else { "impl Trait" } ,
1666- ) ) ;
1668+ ) ,
1669+ ) ;
16671670 }
16681671}
16691672
@@ -1841,8 +1844,8 @@ fn maybe_check_static_with_link_section(tcx: TyCtxt<'_>, id: DefId, span: Span)
18411844 Ok ( ConstValue :: ByRef { alloc, .. } ) => {
18421845 if alloc. relocations ( ) . len ( ) != 0 {
18431846 let msg = "statics with a custom `#[link_section]` must be a \
1844- simple list of bytes on the wasm target with no \
1845- extra levels of indirection such as references";
1847+ simple list of bytes on the wasm target with no \
1848+ extra levels of indirection such as references";
18461849 tcx. sess . span_err ( span, msg) ;
18471850 }
18481851 }
@@ -1971,6 +1974,24 @@ fn check_impl_items_against_trait<'tcx>(
19711974 return ;
19721975 }
19731976
1977+ // Negative impls are not expected to have any items
1978+ match tcx. impl_polarity ( impl_id) {
1979+ ty:: ImplPolarity :: Reservation | ty:: ImplPolarity :: Positive => { }
1980+ ty:: ImplPolarity :: Negative => {
1981+ if !impl_item_refs. is_empty ( ) {
1982+ let first_item_span = tcx. hir ( ) . impl_item ( impl_item_refs[ 0 ] . id ) . span ;
1983+ struct_span_err ! (
1984+ tcx. sess,
1985+ first_item_span,
1986+ E0749 ,
1987+ "negative impls cannot have any items"
1988+ )
1989+ . emit ( ) ;
1990+ }
1991+ return ;
1992+ }
1993+ }
1994+
19741995 // Locate trait definition and items
19751996 let trait_def = tcx. trait_def ( impl_trait_ref. def_id ) ;
19761997
@@ -2010,7 +2031,7 @@ fn check_impl_items_against_trait<'tcx>(
20102031 impl_item. span,
20112032 E0323 ,
20122033 "item `{}` is an associated const, \
2013- which doesn't match its trait `{}`",
2034+ which doesn't match its trait `{}`",
20142035 ty_impl_item. ident,
20152036 impl_trait_ref. print_only_trait_path( )
20162037 ) ;
@@ -3554,7 +3575,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
35543575 let adjusted_ty = autoderef. unambiguous_final_ty ( self ) ;
35553576 debug ! (
35563577 "try_index_step(expr={:?}, base_expr={:?}, adjusted_ty={:?}, \
3557- index_ty={:?})",
3578+ index_ty={:?})",
35583579 expr, base_expr, adjusted_ty, index_ty
35593580 ) ;
35603581
@@ -4705,7 +4726,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
47054726 err. span_label (
47064727 fn_span,
47074728 "implicitly returns `()` as its body has no tail or `return` \
4708- expression",
4729+ expression",
47094730 ) ;
47104731 }
47114732 } ,
@@ -5577,11 +5598,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
55775598 match self . at ( & self . misc ( span) , self . param_env ) . sup ( impl_ty, self_ty) {
55785599 Ok ( ok) => self . register_infer_ok_obligations ( ok) ,
55795600 Err ( _) => {
5580- self . tcx . sess . delay_span_bug ( span, & format ! (
5601+ self . tcx . sess . delay_span_bug (
5602+ span,
5603+ & format ! (
55815604 "instantiate_value_path: (UFCS) {:?} was a subtype of {:?} but now is not?" ,
55825605 self_ty,
55835606 impl_ty,
5584- ) ) ;
5607+ ) ,
5608+ ) ;
55855609 }
55865610 }
55875611 }
@@ -5767,7 +5791,7 @@ fn fatally_break_rust(sess: &Session) {
57675791 handler. note_without_error ( "the compiler expectedly panicked. this is a feature." ) ;
57685792 handler. note_without_error (
57695793 "we would appreciate a joke overview: \
5770- https://github.com/rust-lang/rust/issues/43162#issuecomment-320764675",
5794+ https://github.com/rust-lang/rust/issues/43162#issuecomment-320764675",
57715795 ) ;
57725796 handler. note_without_error ( & format ! (
57735797 "rustc {} running on {}" ,
0 commit comments