From 37ca2eb8c269f48d5a6001394db57ab1c08c4312 Mon Sep 17 00:00:00 2001 From: cameron Date: Sun, 28 Nov 2021 21:46:53 +0000 Subject: [PATCH 1/7] suggest cast char -> int --- compiler/rustc_typeck/src/check/demand.rs | 12 +++++ src/test/ui/cast/cast-int-to-char.rs | 9 ++++ src/test/ui/cast/cast-int-to-char.stderr | 53 +++++++++++++++++++ .../ui/match/match-type-err-first-arm.stderr | 5 ++ src/test/ui/proc-macro/macro-brackets.stderr | 5 ++ 5 files changed, 84 insertions(+) create mode 100644 src/test/ui/cast/cast-int-to-char.rs create mode 100644 src/test/ui/cast/cast-int-to-char.stderr diff --git a/compiler/rustc_typeck/src/check/demand.rs b/compiler/rustc_typeck/src/check/demand.rs index ece2d7b4f3793..7b50132f5ff32 100644 --- a/compiler/rustc_typeck/src/check/demand.rs +++ b/compiler/rustc_typeck/src/check/demand.rs @@ -1173,6 +1173,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } true } + ( + &ty::Uint(ty::UintTy::U32 | ty::UintTy::U64 | ty::UintTy::U128) + | &ty::Int(ty::IntTy::I32 | ty::IntTy::I64 | ty::IntTy::I128), + &ty::Char, + ) => { + err.multipart_suggestion_verbose( + &format!("{}, since a `char` always occupies 4 bytes", cast_msg,), + cast_suggestion, + Applicability::MachineApplicable, + ); + true + } _ => false, } } diff --git a/src/test/ui/cast/cast-int-to-char.rs b/src/test/ui/cast/cast-int-to-char.rs new file mode 100644 index 0000000000000..379956968bd56 --- /dev/null +++ b/src/test/ui/cast/cast-int-to-char.rs @@ -0,0 +1,9 @@ +fn foo(_t: T) {} + +fn main() { + foo::('0'); //~ ERROR + foo::('0'); //~ ERROR + foo::('0'); //~ ERROR + foo::('0'); //~ ERROR + foo::(0u32); //~ ERROR +} diff --git a/src/test/ui/cast/cast-int-to-char.stderr b/src/test/ui/cast/cast-int-to-char.stderr new file mode 100644 index 0000000000000..55b9462db8df8 --- /dev/null +++ b/src/test/ui/cast/cast-int-to-char.stderr @@ -0,0 +1,53 @@ +error[E0308]: mismatched types + --> $DIR/cast-int-to-char.rs:4:16 + | +LL | foo::('0'); + | ^^^ expected `u32`, found `char` + | +help: you can cast a `char` to a `u32`, since a `char` always occupies 4 bytes + | +LL | foo::('0' as u32); + | ++++++ + +error[E0308]: mismatched types + --> $DIR/cast-int-to-char.rs:5:16 + | +LL | foo::('0'); + | ^^^ expected `i32`, found `char` + | +help: you can cast a `char` to an `i32`, since a `char` always occupies 4 bytes + | +LL | foo::('0' as i32); + | ++++++ + +error[E0308]: mismatched types + --> $DIR/cast-int-to-char.rs:6:16 + | +LL | foo::('0'); + | ^^^ expected `u64`, found `char` + | +help: you can cast a `char` to a `u64`, since a `char` always occupies 4 bytes + | +LL | foo::('0' as u64); + | ++++++ + +error[E0308]: mismatched types + --> $DIR/cast-int-to-char.rs:7:16 + | +LL | foo::('0'); + | ^^^ expected `i64`, found `char` + | +help: you can cast a `char` to an `i64`, since a `char` always occupies 4 bytes + | +LL | foo::('0' as i64); + | ++++++ + +error[E0308]: mismatched types + --> $DIR/cast-int-to-char.rs:8:17 + | +LL | foo::(0u32); + | ^^^^ expected `char`, found `u32` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/match/match-type-err-first-arm.stderr b/src/test/ui/match/match-type-err-first-arm.stderr index fd489afa84db4..1cfe7ce1ed726 100644 --- a/src/test/ui/match/match-type-err-first-arm.stderr +++ b/src/test/ui/match/match-type-err-first-arm.stderr @@ -6,6 +6,11 @@ LL | fn test_func1(n: i32) -> i32 { LL | match n { LL | 12 => 'b', | ^^^ expected `i32`, found `char` + | +help: you can cast a `char` to an `i32`, since a `char` always occupies 4 bytes + | +LL | 12 => 'b' as i32, + | ++++++ error[E0308]: `match` arms have incompatible types --> $DIR/match-type-err-first-arm.rs:18:14 diff --git a/src/test/ui/proc-macro/macro-brackets.stderr b/src/test/ui/proc-macro/macro-brackets.stderr index 9aaf612eb54a1..d3516375291b9 100644 --- a/src/test/ui/proc-macro/macro-brackets.stderr +++ b/src/test/ui/proc-macro/macro-brackets.stderr @@ -3,6 +3,11 @@ error[E0308]: mismatched types | LL | id![static X: u32 = 'a';]; | ^^^ expected `u32`, found `char` + | +help: you can cast a `char` to a `u32`, since a `char` always occupies 4 bytes + | +LL | id![static X: u32 = 'a' as u32;]; + | ++++++ error: aborting due to previous error From b9b4f549a45ccd6d5b5806153154c86e71e34bde Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Sun, 28 Nov 2021 23:10:37 +0100 Subject: [PATCH 2/7] Add a suggestion if `macro_rules` is misspelled --- compiler/rustc_parse/src/parser/item.rs | 29 ++++++++++++++++--- .../ui/parser/misspelled-macro-rules.fixed | 13 +++++++++ src/test/ui/parser/misspelled-macro-rules.rs | 13 +++++++++ .../ui/parser/misspelled-macro-rules.stderr | 10 +++++++ 4 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 src/test/ui/parser/misspelled-macro-rules.fixed create mode 100644 src/test/ui/parser/misspelled-macro-rules.rs create mode 100644 src/test/ui/parser/misspelled-macro-rules.stderr diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 24a8df49ac7ee..aa572eaf162cf 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -15,6 +15,7 @@ use rustc_ast::{MacArgs, MacCall, MacDelimiter}; use rustc_ast_pretty::pprust; use rustc_errors::{struct_span_err, Applicability, PResult, StashKey}; use rustc_span::edition::{Edition, LATEST_STABLE_EDITION}; +use rustc_span::lev_distance::lev_distance; use rustc_span::source_map::{self, Span}; use rustc_span::symbol::{kw, sym, Ident, Symbol}; @@ -407,10 +408,30 @@ impl<'a> Parser<'a> { fn parse_item_macro(&mut self, vis: &Visibility) -> PResult<'a, MacCall> { let path = self.parse_path(PathStyle::Mod)?; // `foo::bar` self.expect(&token::Not)?; // `!` - let args = self.parse_mac_args()?; // `( .. )` or `[ .. ]` (followed by `;`), or `{ .. }`. - self.eat_semi_for_macro_if_needed(&args); - self.complain_if_pub_macro(vis, false); - Ok(MacCall { path, args, prior_type_ascription: self.last_type_ascription }) + match self.parse_mac_args() { + // `( .. )` or `[ .. ]` (followed by `;`), or `{ .. }`. + Ok(args) => { + self.eat_semi_for_macro_if_needed(&args); + self.complain_if_pub_macro(vis, false); + Ok(MacCall { path, args, prior_type_ascription: self.last_type_ascription }) + } + + Err(mut err) => { + // Maybe the user misspelled `macro_rules` (issue #91227) + if self.token.is_ident() + && path.segments.len() == 1 + && lev_distance("macro_rules", &path.segments[0].ident.to_string()) <= 3 + { + err.span_suggestion( + path.span, + "perhaps you meant to define a macro", + "macro_rules".to_string(), + Applicability::MachineApplicable, + ); + } + Err(err) + } + } } /// Recover if we parsed attributes and expected an item but there was none. diff --git a/src/test/ui/parser/misspelled-macro-rules.fixed b/src/test/ui/parser/misspelled-macro-rules.fixed new file mode 100644 index 0000000000000..62be913d85f05 --- /dev/null +++ b/src/test/ui/parser/misspelled-macro-rules.fixed @@ -0,0 +1,13 @@ +// Regression test for issue #91227. + +// run-rustfix + +#![allow(unused_macros)] + +macro_rules! thing { +//~^ ERROR: expected one of +//~| HELP: perhaps you meant to define a macro + () => {} +} + +fn main() {} diff --git a/src/test/ui/parser/misspelled-macro-rules.rs b/src/test/ui/parser/misspelled-macro-rules.rs new file mode 100644 index 0000000000000..4290e6e5e4cb9 --- /dev/null +++ b/src/test/ui/parser/misspelled-macro-rules.rs @@ -0,0 +1,13 @@ +// Regression test for issue #91227. + +// run-rustfix + +#![allow(unused_macros)] + +marco_rules! thing { +//~^ ERROR: expected one of +//~| HELP: perhaps you meant to define a macro + () => {} +} + +fn main() {} diff --git a/src/test/ui/parser/misspelled-macro-rules.stderr b/src/test/ui/parser/misspelled-macro-rules.stderr new file mode 100644 index 0000000000000..56df712381920 --- /dev/null +++ b/src/test/ui/parser/misspelled-macro-rules.stderr @@ -0,0 +1,10 @@ +error: expected one of `(`, `[`, or `{`, found `thing` + --> $DIR/misspelled-macro-rules.rs:7:14 + | +LL | marco_rules! thing { + | ----------- ^^^^^ expected one of `(`, `[`, or `{` + | | + | help: perhaps you meant to define a macro: `macro_rules` + +error: aborting due to previous error + From e1ff02bb818fc85b0820bc989cd7fa64dd1e4300 Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Sat, 4 Dec 2021 11:19:33 -0800 Subject: [PATCH 3/7] Make rustdoc headings black, and markdown blue --- src/librustdoc/html/render/print_item.rs | 2 +- src/librustdoc/html/static/css/themes/ayu.css | 2 +- src/librustdoc/html/static/css/themes/dark.css | 2 +- src/librustdoc/html/static/css/themes/light.css | 2 +- src/test/rustdoc-gui/headers-color.goml | 15 ++++++++++++--- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index e139ac8581e72..1691de93bdda2 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -296,7 +296,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl let (short, name) = item_ty_to_strs(myty.unwrap()); write!( w, - "

\ + "

\ {name}\

\n{}", ITEM_TABLE_OPEN, diff --git a/src/librustdoc/html/static/css/themes/ayu.css b/src/librustdoc/html/static/css/themes/ayu.css index 13e8dc85a243c..532bc0e351dbd 100644 --- a/src/librustdoc/html/static/css/themes/ayu.css +++ b/src/librustdoc/html/static/css/themes/ayu.css @@ -219,7 +219,7 @@ a { a.srclink, a#toggle-all-docs, a.anchor, -.section-header a, +.small-section-header a, #source-sidebar a, pre.rust a, .sidebar a, diff --git a/src/librustdoc/html/static/css/themes/dark.css b/src/librustdoc/html/static/css/themes/dark.css index 8caf8a05d507f..56ed8a2006d09 100644 --- a/src/librustdoc/html/static/css/themes/dark.css +++ b/src/librustdoc/html/static/css/themes/dark.css @@ -181,7 +181,7 @@ a { a.srclink, a#toggle-all-docs, a.anchor, -.section-header a, +.small-section-header a, #source-sidebar a, pre.rust a, .sidebar a, diff --git a/src/librustdoc/html/static/css/themes/light.css b/src/librustdoc/html/static/css/themes/light.css index fec71674e634f..d63614191822e 100644 --- a/src/librustdoc/html/static/css/themes/light.css +++ b/src/librustdoc/html/static/css/themes/light.css @@ -176,7 +176,7 @@ a { a.srclink, a#toggle-all-docs, a.anchor, -.section-header a, +.small-section-header a, #source-sidebar a, pre.rust a, .sidebar a, diff --git a/src/test/rustdoc-gui/headers-color.goml b/src/test/rustdoc-gui/headers-color.goml index 7002812bb62c4..03b10e3f78d43 100644 --- a/src/test/rustdoc-gui/headers-color.goml +++ b/src/test/rustdoc-gui/headers-color.goml @@ -18,7 +18,10 @@ goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use assert-css: ("#method\.must_use", {"color": "rgb(197, 197, 197)", "background-color": "rgba(255, 236, 164, 0.06)"}, ALL) goto: file://|DOC_PATH|/test_docs/index.html -assert-css: (".section-header a", {"color": "rgb(197, 197, 197)"}, ALL) +assert-css: (".small-section-header a", {"color": "rgb(197, 197, 197)"}, ALL) + +goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html +assert-css: (".section-header a", {"color": "rgb(57, 175, 215)"}, ALL) // Dark theme local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"} @@ -34,7 +37,10 @@ goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use assert-css: ("#method\.must_use", {"color": "rgb(221, 221, 221)", "background-color": "rgb(73, 74, 61)"}, ALL) goto: file://|DOC_PATH|/test_docs/index.html -assert-css: (".section-header a", {"color": "rgb(221, 221, 221)"}, ALL) +assert-css: (".small-section-header a", {"color": "rgb(221, 221, 221)"}, ALL) + +goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html +assert-css: (".section-header a", {"color": "rgb(210, 153, 29)"}, ALL) // Light theme local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} @@ -52,4 +58,7 @@ goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use assert-css: ("#method\.must_use", {"color": "rgb(0, 0, 0)", "background-color": "rgb(253, 255, 211)"}, ALL) goto: file://|DOC_PATH|/test_docs/index.html -assert-css: (".section-header a", {"color": "rgb(0, 0, 0)"}, ALL) +assert-css: (".small-section-header a", {"color": "rgb(0, 0, 0)"}, ALL) + +goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html +assert-css: (".section-header a", {"color": "rgb(56, 115, 173)"}, ALL) From abb8893576d97d13a8d28a84b35b10b1f1ae9e32 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 5 Dec 2021 12:35:09 -0800 Subject: [PATCH 4/7] Pretty print break and continue without redundant space --- compiler/rustc_ast_pretty/src/pprust/state.rs | 8 +++----- compiler/rustc_hir_pretty/src/lib.rs | 8 +++----- src/test/pretty/ast-stmt-expr-attr.rs | 4 ++-- src/test/pretty/hir-pretty-loop.pp | 2 +- src/test/pretty/stmt_expr_attributes.rs | 5 ++--- 5 files changed, 11 insertions(+), 16 deletions(-) diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index 593dca1b405d8..092a1f9fa08cd 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -2127,22 +2127,20 @@ impl<'a> State<'a> { ast::ExprKind::Path(Some(ref qself), ref path) => self.print_qpath(path, qself, true), ast::ExprKind::Break(opt_label, ref opt_expr) => { self.s.word("break"); - self.s.space(); if let Some(label) = opt_label { - self.print_ident(label.ident); self.s.space(); + self.print_ident(label.ident); } if let Some(ref expr) = *opt_expr { - self.print_expr_maybe_paren(expr, parser::PREC_JUMP); self.s.space(); + self.print_expr_maybe_paren(expr, parser::PREC_JUMP); } } ast::ExprKind::Continue(opt_label) => { self.s.word("continue"); - self.s.space(); if let Some(label) = opt_label { + self.s.space(); self.print_ident(label.ident); - self.s.space() } } ast::ExprKind::Ret(ref result) => { diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index 449430a7d28ef..dced4cccdbfdc 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -1600,22 +1600,20 @@ impl<'a> State<'a> { hir::ExprKind::Path(ref qpath) => self.print_qpath(qpath, true), hir::ExprKind::Break(destination, ref opt_expr) => { self.s.word("break"); - self.s.space(); if let Some(label) = destination.label { - self.print_ident(label.ident); self.s.space(); + self.print_ident(label.ident); } if let Some(ref expr) = *opt_expr { - self.print_expr_maybe_paren(expr, parser::PREC_JUMP); self.s.space(); + self.print_expr_maybe_paren(expr, parser::PREC_JUMP); } } hir::ExprKind::Continue(destination) => { self.s.word("continue"); - self.s.space(); if let Some(label) = destination.label { + self.s.space(); self.print_ident(label.ident); - self.s.space() } } hir::ExprKind::Ret(ref result) => { diff --git a/src/test/pretty/ast-stmt-expr-attr.rs b/src/test/pretty/ast-stmt-expr-attr.rs index c80bce2d140b9..e32f5ca24ea0f 100644 --- a/src/test/pretty/ast-stmt-expr-attr.rs +++ b/src/test/pretty/ast-stmt-expr-attr.rs @@ -110,8 +110,8 @@ fn syntax() { let _ = #[attr] &mut 0; let _ = #[attr] &#[attr] 0; let _ = #[attr] &mut #[attr] 0; - let _ = #[attr] break ; - let _ = #[attr] continue ; + let _ = #[attr] break; + let _ = #[attr] continue; let _ = #[attr] return; let _ = #[attr] foo!(); let _ = #[attr] foo!(#! [attr]); diff --git a/src/test/pretty/hir-pretty-loop.pp b/src/test/pretty/hir-pretty-loop.pp index 19b3a1775cf36..9b10fd86c4778 100644 --- a/src/test/pretty/hir-pretty-loop.pp +++ b/src/test/pretty/hir-pretty-loop.pp @@ -6,4 +6,4 @@ // pretty-mode:hir // pp-exact:hir-pretty-loop.pp -pub fn foo() { loop { break ; } } +pub fn foo() { loop { break; } } diff --git a/src/test/pretty/stmt_expr_attributes.rs b/src/test/pretty/stmt_expr_attributes.rs index 12204c8cd30ed..01533cd8107b0 100644 --- a/src/test/pretty/stmt_expr_attributes.rs +++ b/src/test/pretty/stmt_expr_attributes.rs @@ -229,9 +229,8 @@ fn _11() { let _ = #[rustc_dummy] &mut 0; let _ = #[rustc_dummy] &#[rustc_dummy] 0; let _ = #[rustc_dummy] &mut #[rustc_dummy] 0; - // FIXME: pp bug, extra space after keyword? - while false { let _ = #[rustc_dummy] continue ; } - while true { let _ = #[rustc_dummy] break ; } + while false { let _ = #[rustc_dummy] continue; } + while true { let _ = #[rustc_dummy] break; } || #[rustc_dummy] return; let _ = #[rustc_dummy] expr_mac!(); let _ = #[rustc_dummy] expr_mac![]; From 3cbe0f1b48dfdb7866f45a1d683b1391ed4d0508 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Tue, 7 Dec 2021 00:00:00 +0000 Subject: [PATCH 5/7] Add test for packed drops in generators --- .../ui/packed/packed-struct-drop-aligned.rs | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/test/ui/packed/packed-struct-drop-aligned.rs b/src/test/ui/packed/packed-struct-drop-aligned.rs index fab3bbedac667..b95cdbbbaad3b 100644 --- a/src/test/ui/packed/packed-struct-drop-aligned.rs +++ b/src/test/ui/packed/packed-struct-drop-aligned.rs @@ -1,6 +1,10 @@ // run-pass +#![feature(generators)] +#![feature(generator_trait)] use std::cell::Cell; use std::mem; +use std::ops::Generator; +use std::pin::Pin; struct Aligned<'a> { drop_count: &'a Cell @@ -19,15 +23,35 @@ impl<'a> Drop for Aligned<'a> { } } +#[repr(transparent)] +struct NotCopy(u8); + #[repr(packed)] -struct Packed<'a>(u8, Aligned<'a>); +struct Packed<'a>(NotCopy, Aligned<'a>); fn main() { let drop_count = &Cell::new(0); { - let mut p = Packed(0, Aligned { drop_count }); + let mut p = Packed(NotCopy(0), Aligned { drop_count }); p.1 = Aligned { drop_count }; assert_eq!(drop_count.get(), 1); } assert_eq!(drop_count.get(), 2); + + let drop_count = &Cell::new(0); + let mut g = || { + let mut p = Packed(NotCopy(0), Aligned { drop_count }); + let _ = &p; + p.1 = Aligned { drop_count }; + assert_eq!(drop_count.get(), 1); + // Test that a generator drop function moves a value from a packed + // struct to a separate local before dropping it. We move out the + // first field to generate and open drop for the second field. + drop(p.0); + yield; + }; + Pin::new(&mut g).resume(()); + assert_eq!(drop_count.get(), 1); + drop(g); + assert_eq!(drop_count.get(), 2); } From d3167a22e005d9655a4b4f4e9ccada96abd810ed Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 8 Dec 2021 10:53:12 -0500 Subject: [PATCH 6/7] update Miri --- src/tools/miri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri b/src/tools/miri index 81e59e6b92cf1..dadcbebfbd017 160000 --- a/src/tools/miri +++ b/src/tools/miri @@ -1 +1 @@ -Subproject commit 81e59e6b92cf1729aabbbbf09b81a81a03775d64 +Subproject commit dadcbebfbd017aac2358cf652a4bd71a91694edc From edd881474b7e517f7239549babc8acaf7ddfd61e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 8 Dec 2021 17:31:56 +0100 Subject: [PATCH 7/7] Fix indent of itemTypes in search.js --- src/librustdoc/html/static/js/search.js | 54 +++++++++++++------------ 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index c2ea54abd2ea8..7c55d10836c45 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -4,32 +4,34 @@ (function() { // This mapping table should match the discriminants of // `rustdoc::html::item_type::ItemType` type in Rust. -var itemTypes = ["mod", - "externcrate", - "import", - "struct", - "enum", - "fn", - "type", - "static", - "trait", - "impl", - "tymethod", - "method", - "structfield", - "variant", - "macro", - "primitive", - "associatedtype", - "constant", - "associatedconstant", - "union", - "foreigntype", - "keyword", - "existential", - "attr", - "derive", - "traitalias"]; +var itemTypes = [ + "mod", + "externcrate", + "import", + "struct", + "enum", + "fn", + "type", + "static", + "trait", + "impl", + "tymethod", + "method", + "structfield", + "variant", + "macro", + "primitive", + "associatedtype", + "constant", + "associatedconstant", + "union", + "foreigntype", + "keyword", + "existential", + "attr", + "derive", + "traitalias", +]; // used for special search precedence var TY_PRIMITIVE = itemTypes.indexOf("primitive");