From 654cb84852a0485146f95bbebe14ac75b7ee111a Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 7 Apr 2018 14:04:03 +0200 Subject: [PATCH] Add specific never search --- src/librustdoc/html/static/main.js | 7 ++++++- src/test/rustdoc-js/never.js | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/test/rustdoc-js/never.js diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 2546a9410a9..fd8bd52cfab 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -1062,6 +1062,11 @@ type = matches[1].replace(/^const$/, 'constant'); query = query.substring(matches[0].length); } + // In case we just get a '!' as input, we can assume that the user is looking for the + // `Never` primitive type. + if (raw === '!') { + query = 'Never'; + } return { raw: raw, @@ -1369,7 +1374,7 @@ function search(e) { var params = getQueryStringParams(); - var query = getQuery(document.getElementsByClassName('search-input')[0].value); + var query = getQuery(document.getElementsByClassName('search-input')[0].value.trim()); if (e) { e.preventDefault(); diff --git a/src/test/rustdoc-js/never.js b/src/test/rustdoc-js/never.js new file mode 100644 index 00000000000..d9e1ca5f760 --- /dev/null +++ b/src/test/rustdoc-js/never.js @@ -0,0 +1,17 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const QUERY = '!'; + +const EXPECTED = { + 'others': [ + { 'path': 'std', 'name': 'never' }, + ], +};