File tree Expand file tree Collapse file tree 6 files changed +84
-2
lines changed Expand file tree Collapse file tree 6 files changed +84
-2
lines changed Original file line number Diff line number Diff line change 465465 var res = buildHrefAndPath ( obj ) ;
466466 obj . displayPath = pathSplitter ( res [ 0 ] ) ;
467467 obj . fullPath = obj . displayPath + obj . name ;
468+ if ( obj . ty === TY_KEYWORD ) {
469+ // To be sure than it isn't considered as duplicate with items.
470+ obj . fullPath += '|k' ;
471+ }
468472 obj . href = res [ 1 ] ;
469473 out . push ( obj ) ;
470474 if ( out . length >= MAX_RESULTS ) {
781785 case "fn" :
782786 return ( name == "method" || name == "tymethod" ) ;
783787 case "type" :
784- return ( name == "primitive" ) ;
788+ return ( name == "primitive" || name == "keyword" ) ;
785789 }
786790
787791 // No match
Original file line number Diff line number Diff line change 1+ // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ #[ doc( keyword = "fn" ) ]
12+ //
13+ /// The `fn` keyword.
14+ ///
15+ /// The `fn` keyword is used to declare a function.
16+ ///
17+ /// Example:
18+ ///
19+ /// ```rust
20+ /// fn some_function() {
21+ /// // code goes in here
22+ /// }
23+ /// ```
24+ ///
25+ /// For more information about functions, take a look at the [Rust Book][book].
26+ ///
27+ /// [book]: https://doc.rust-lang.org/book/second-edition/ch03-03-how-functions-work.html
28+ mod fn_keyword { }
Original file line number Diff line number Diff line change @@ -547,3 +547,8 @@ pub use stdsimd::arch;
547547// the rustdoc documentation for primitive types. Using `include!`
548548// because rustdoc only looks for these modules at the crate level.
549549include ! ( "primitive_docs.rs" ) ;
550+
551+ // Include a number of private modules that exist solely to provide
552+ // the rustdoc documentation for the existing keywords. Using `include!`
553+ // because rustdoc only looks for these modules at the crate level.
554+ include ! ( "keyword_docs.rs" ) ;
Original file line number Diff line number Diff line change 1+ // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ // ignore-order
12+
13+ const QUERY = 'fn' ;
14+
15+ const EXPECTED = {
16+ 'others' : [
17+ { 'path' : 'std' , 'name' : 'fn' , ty : 15 } , // 15 is for primitive types
18+ { 'path' : 'std' , 'name' : 'fn' , ty : 21 } , // 21 is for keywords
19+ ] ,
20+ } ;
Original file line number Diff line number Diff line change 1+ // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ // should-fail
12+
13+ const QUERY = 'fn' ;
14+
15+ const EXPECTED = {
16+ 'others' : [
17+ { 'path' : 'std' , 'name' : 'fn' , ty : 14 } ,
18+ ] ,
19+ } ;
Original file line number Diff line number Diff line change @@ -164,6 +164,7 @@ function loadContent(content) {
164164 m . _compile ( content , "tmp.js" ) ;
165165 m . exports . ignore_order = content . indexOf ( "\n// ignore-order\n" ) !== - 1 ;
166166 m . exports . exact_check = content . indexOf ( "\n// exact-check\n" ) !== - 1 ;
167+ m . exports . should_fail = content . indexOf ( "\n// should-fail\n" ) !== - 1 ;
167168 return m . exports ;
168169}
169170
@@ -259,6 +260,7 @@ function main(argv) {
259260 const query = loadedFile . QUERY ;
260261 const ignore_order = loadedFile . ignore_order ;
261262 const exact_check = loadedFile . exact_check ;
263+ const should_fail = loadedFile . should_fail ;
262264 var results = loaded . execSearch ( loaded . getQuery ( query ) , index ) ;
263265 process . stdout . write ( 'Checking "' + file + '" ... ' ) ;
264266 var error_text = [ ] ;
@@ -289,7 +291,11 @@ function main(argv) {
289291 }
290292 }
291293 }
292- if ( error_text . length !== 0 ) {
294+ if ( error_text . length === 0 && should_fail === true ) {
295+ errors += 1 ;
296+ console . error ( "FAILED" ) ;
297+ console . error ( "==> Test was supposed to fail but all items were found..." ) ;
298+ } else if ( error_text . length !== 0 && should_fail === false ) {
293299 errors += 1 ;
294300 console . error ( "FAILED" ) ;
295301 console . error ( error_text . join ( "\n" ) ) ;
You can’t perform that action at this time.
0 commit comments