@@ -12,11 +12,11 @@ use rustc_ast::ptr::P;
1212use rustc_ast:: token;
1313use rustc_ast:: tokenstream:: TokenStream ;
1414use rustc_ast:: visit:: { self , AssocCtxt , Visitor } ;
15- use rustc_ast:: { AstLike , AttrItem , Block , Inline , ItemKind , LitKind , MacArgs } ;
15+ use rustc_ast:: { AstLike , Block , Inline , ItemKind , MacArgs } ;
1616use rustc_ast:: { MacCallStmt , MacStmtStyle , MetaItemKind , ModKind , NestedMetaItem } ;
1717use rustc_ast:: { NodeId , PatKind , Path , StmtKind , Unsafe } ;
1818use rustc_ast_pretty:: pprust;
19- use rustc_attr:: { self as attr , is_builtin_attr} ;
19+ use rustc_attr:: is_builtin_attr;
2020use rustc_data_structures:: map_in_place:: MapInPlace ;
2121use rustc_data_structures:: stack:: ensure_sufficient_stack;
2222use rustc_data_structures:: sync:: Lrc ;
@@ -28,15 +28,14 @@ use rustc_session::lint::builtin::UNUSED_DOC_COMMENTS;
2828use rustc_session:: lint:: BuiltinLintDiagnostics ;
2929use rustc_session:: parse:: { feature_err, ParseSess } ;
3030use rustc_session:: Limit ;
31- use rustc_span:: symbol:: { sym, Ident , Symbol } ;
32- use rustc_span:: { ExpnId , FileName , Span , DUMMY_SP } ;
31+ use rustc_span:: symbol:: { sym, Ident } ;
32+ use rustc_span:: { ExpnId , FileName , Span } ;
3333
3434use smallvec:: { smallvec, SmallVec } ;
35- use std:: io:: ErrorKind ;
3635use std:: ops:: DerefMut ;
3736use std:: path:: PathBuf ;
3837use std:: rc:: Rc ;
39- use std:: { iter, mem, slice } ;
38+ use std:: { iter, mem} ;
4039
4140macro_rules! ast_fragments {
4241 (
@@ -1524,139 +1523,6 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
15241523 noop_flat_map_generic_param ( param, self )
15251524 }
15261525
1527- fn visit_attribute ( & mut self , at : & mut ast:: Attribute ) {
1528- // turn `#[doc(include="filename")]` attributes into `#[doc(include(file="filename",
1529- // contents="file contents")]` attributes
1530- if !self . cx . sess . check_name ( at, sym:: doc) {
1531- return noop_visit_attribute ( at, self ) ;
1532- }
1533-
1534- if let Some ( list) = at. meta_item_list ( ) {
1535- if !list. iter ( ) . any ( |it| it. has_name ( sym:: include) ) {
1536- return noop_visit_attribute ( at, self ) ;
1537- }
1538-
1539- let mut items = vec ! [ ] ;
1540-
1541- for mut it in list {
1542- if !it. has_name ( sym:: include) {
1543- items. push ( {
1544- noop_visit_meta_list_item ( & mut it, self ) ;
1545- it
1546- } ) ;
1547- continue ;
1548- }
1549-
1550- if let Some ( file) = it. value_str ( ) {
1551- let err_count = self . cx . sess . parse_sess . span_diagnostic . err_count ( ) ;
1552- self . check_attributes ( slice:: from_ref ( at) ) ;
1553- if self . cx . sess . parse_sess . span_diagnostic . err_count ( ) > err_count {
1554- // avoid loading the file if they haven't enabled the feature
1555- return noop_visit_attribute ( at, self ) ;
1556- }
1557-
1558- let filename = match self . cx . resolve_path ( & * file. as_str ( ) , it. span ( ) ) {
1559- Ok ( filename) => filename,
1560- Err ( mut err) => {
1561- err. emit ( ) ;
1562- continue ;
1563- }
1564- } ;
1565-
1566- match self . cx . source_map ( ) . load_file ( & filename) {
1567- Ok ( source_file) => {
1568- let src = source_file
1569- . src
1570- . as_ref ( )
1571- . expect ( "freshly loaded file should have a source" ) ;
1572- let src_interned = Symbol :: intern ( src. as_str ( ) ) ;
1573-
1574- let include_info = vec ! [
1575- ast:: NestedMetaItem :: MetaItem ( attr:: mk_name_value_item_str(
1576- Ident :: with_dummy_span( sym:: file) ,
1577- file,
1578- DUMMY_SP ,
1579- ) ) ,
1580- ast:: NestedMetaItem :: MetaItem ( attr:: mk_name_value_item_str(
1581- Ident :: with_dummy_span( sym:: contents) ,
1582- src_interned,
1583- DUMMY_SP ,
1584- ) ) ,
1585- ] ;
1586-
1587- let include_ident = Ident :: with_dummy_span ( sym:: include) ;
1588- let item = attr:: mk_list_item ( include_ident, include_info) ;
1589- items. push ( ast:: NestedMetaItem :: MetaItem ( item) ) ;
1590- }
1591- Err ( e) => {
1592- let lit_span = it. name_value_literal_span ( ) . unwrap ( ) ;
1593-
1594- if e. kind ( ) == ErrorKind :: InvalidData {
1595- self . cx
1596- . struct_span_err (
1597- lit_span,
1598- & format ! ( "{} wasn't a utf-8 file" , filename. display( ) ) ,
1599- )
1600- . span_label ( lit_span, "contains invalid utf-8" )
1601- . emit ( ) ;
1602- } else {
1603- let mut err = self . cx . struct_span_err (
1604- lit_span,
1605- & format ! ( "couldn't read {}: {}" , filename. display( ) , e) ,
1606- ) ;
1607- err. span_label ( lit_span, "couldn't read file" ) ;
1608-
1609- err. emit ( ) ;
1610- }
1611- }
1612- }
1613- } else {
1614- let mut err = self
1615- . cx
1616- . struct_span_err ( it. span ( ) , "expected path to external documentation" ) ;
1617-
1618- // Check if the user erroneously used `doc(include(...))` syntax.
1619- let literal = it. meta_item_list ( ) . and_then ( |list| {
1620- if list. len ( ) == 1 {
1621- list[ 0 ] . literal ( ) . map ( |literal| & literal. kind )
1622- } else {
1623- None
1624- }
1625- } ) ;
1626-
1627- let ( path, applicability) = match & literal {
1628- Some ( LitKind :: Str ( path, ..) ) => {
1629- ( path. to_string ( ) , Applicability :: MachineApplicable )
1630- }
1631- _ => ( String :: from ( "<path>" ) , Applicability :: HasPlaceholders ) ,
1632- } ;
1633-
1634- err. span_suggestion (
1635- it. span ( ) ,
1636- "provide a file path with `=`" ,
1637- format ! ( "include = \" {}\" " , path) ,
1638- applicability,
1639- ) ;
1640-
1641- err. emit ( ) ;
1642- }
1643- }
1644-
1645- let meta = attr:: mk_list_item ( Ident :: with_dummy_span ( sym:: doc) , items) ;
1646- * at = ast:: Attribute {
1647- kind : ast:: AttrKind :: Normal (
1648- AttrItem { path : meta. path , args : meta. kind . mac_args ( meta. span ) , tokens : None } ,
1649- None ,
1650- ) ,
1651- span : at. span ,
1652- id : at. id ,
1653- style : at. style ,
1654- } ;
1655- } else {
1656- noop_visit_attribute ( at, self )
1657- }
1658- }
1659-
16601526 fn visit_id ( & mut self , id : & mut ast:: NodeId ) {
16611527 if self . monotonic {
16621528 debug_assert_eq ! ( * id, ast:: DUMMY_NODE_ID ) ;
0 commit comments