Skip to content

Commit aff2080

Browse files
committed
Auto merge of #26985 - Manishearth:rollup, r=Manishearth
- Successful merges: #26881, #26967, #26973, #26974, #26976, #26979 - Failed merges:
2 parents 88c1105 + aad7cb8 commit aff2080

File tree

5 files changed

+66
-67
lines changed

5 files changed

+66
-67
lines changed

src/libcore/option.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
//! // The division was valid
4747
//! Some(x) => println!("Result: {}", x),
4848
//! // The division was invalid
49-
//! None => println!("Cannot divide by 0")
49+
//! None => println!("Cannot divide by 0"),
5050
//! }
5151
//! ```
5252
//!
@@ -75,7 +75,7 @@
7575
//! fn check_optional(optional: &Option<Box<i32>>) {
7676
//! match *optional {
7777
//! Some(ref p) => println!("have value {}", p),
78-
//! None => println!("have no value")
78+
//! None => println!("have no value"),
7979
//! }
8080
//! }
8181
//! ```
@@ -95,13 +95,13 @@
9595
//! // Take a reference to the contained string
9696
//! match msg {
9797
//! Some(ref m) => println!("{}", *m),
98-
//! None => ()
98+
//! None => (),
9999
//! }
100100
//!
101101
//! // Remove the contained string, destroying the Option
102102
//! let unwrapped_msg = match msg {
103103
//! Some(m) => m,
104-
//! None => "default message"
104+
//! None => "default message",
105105
//! };
106106
//! ```
107107
//!
@@ -137,7 +137,7 @@
137137
//!
138138
//! match name_of_biggest_animal {
139139
//! Some(name) => println!("the biggest animal is {}", name),
140-
//! None => println!("there are no animals :(")
140+
//! None => println!("there are no animals :("),
141141
//! }
142142
//! ```
143143
@@ -198,7 +198,7 @@ impl<T> Option<T> {
198198
pub fn is_some(&self) -> bool {
199199
match *self {
200200
Some(_) => true,
201-
None => false
201+
None => false,
202202
}
203203
}
204204

@@ -244,7 +244,7 @@ impl<T> Option<T> {
244244
pub fn as_ref<'r>(&'r self) -> Option<&'r T> {
245245
match *self {
246246
Some(ref x) => Some(x),
247-
None => None
247+
None => None,
248248
}
249249
}
250250

@@ -265,7 +265,7 @@ impl<T> Option<T> {
265265
pub fn as_mut<'r>(&'r mut self) -> Option<&'r mut T> {
266266
match *self {
267267
Some(ref mut x) => Some(x),
268-
None => None
268+
None => None,
269269
}
270270
}
271271

@@ -376,7 +376,7 @@ impl<T> Option<T> {
376376
pub fn unwrap_or(self, def: T) -> T {
377377
match self {
378378
Some(x) => x,
379-
None => def
379+
None => def,
380380
}
381381
}
382382

@@ -394,7 +394,7 @@ impl<T> Option<T> {
394394
pub fn unwrap_or_else<F: FnOnce() -> T>(self, f: F) -> T {
395395
match self {
396396
Some(x) => x,
397-
None => f()
397+
None => f(),
398398
}
399399
}
400400

@@ -420,7 +420,7 @@ impl<T> Option<T> {
420420
pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Option<U> {
421421
match self {
422422
Some(x) => Some(f(x)),
423-
None => None
423+
None => None,
424424
}
425425
}
426426

@@ -464,7 +464,7 @@ impl<T> Option<T> {
464464
pub fn map_or_else<U, D: FnOnce() -> U, F: FnOnce(T) -> U>(self, default: D, f: F) -> U {
465465
match self {
466466
Some(t) => f(t),
467-
None => default()
467+
None => default(),
468468
}
469469
}
470470

@@ -637,7 +637,7 @@ impl<T> Option<T> {
637637
pub fn or(self, optb: Option<T>) -> Option<T> {
638638
match self {
639639
Some(_) => self,
640-
None => optb
640+
None => optb,
641641
}
642642
}
643643

@@ -659,7 +659,7 @@ impl<T> Option<T> {
659659
pub fn or_else<F: FnOnce() -> Option<T>>(self, f: F) -> Option<T> {
660660
match self {
661661
Some(_) => self,
662-
None => f()
662+
None => f(),
663663
}
664664
}
665665

@@ -736,7 +736,7 @@ impl<T: Default> Option<T> {
736736
pub fn unwrap_or_default(self) -> T {
737737
match self {
738738
Some(x) => x,
739-
None => Default::default()
739+
None => Default::default(),
740740
}
741741
}
742742
}

src/librustc/diagnostics.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -791,8 +791,7 @@ trait Foo {
791791
fn bar(&self);
792792
}
793793
794-
// we now declare a function which takes an object with Foo trait implemented
795-
// as parameter
794+
// we now declare a function which takes an object implementing the Foo trait
796795
fn some_func<T: Foo>(foo: T) {
797796
foo.bar();
798797
}
@@ -1006,7 +1005,7 @@ a compile-time constant.
10061005

10071006
E0308: r##"
10081007
This error occurs when the compiler was unable to infer the concrete type of a
1009-
variable. This error can occur for several cases, the most common of which is a
1008+
variable. It can occur for several cases, the most common of which is a
10101009
mismatch in the expected type that the compiler inferred for a variable's
10111010
initializing expression, and the actual type explicitly assigned to the
10121011
variable.

src/librustdoc/html/static/main.js

+48-44
Original file line numberDiff line numberDiff line change
@@ -76,62 +76,65 @@
7676
highlightSourceLines(null);
7777
$(window).on('hashchange', highlightSourceLines);
7878

79-
// Helper function for Keyboard events,
80-
// Get's the char from the keypress event
79+
// Gets the human-readable string for the virtual-key code of the
80+
// given KeyboardEvent, ev.
8181
//
82-
// This method is used because e.wich === x is not
83-
// compatible with non-english keyboard layouts
82+
// This function is meant as a polyfill for KeyboardEvent#key,
83+
// since it is not supported in Trident. We also test for
84+
// KeyboardEvent#keyCode because the handleShortcut handler is
85+
// also registered for the keydown event, because Blink doesn't fire
86+
// keypress on hitting the Escape key.
8487
//
85-
// Note: event.type must be keypress !
86-
function getChar(event) {
87-
if (event.which == null) {
88-
return String.fromCharCode(event.keyCode) // IE
89-
} else if (event.which!=0 && event.charCode!=0) {
90-
return String.fromCharCode(event.which) // the rest
91-
} else {
92-
return null // special key
93-
}
88+
// So I guess you could say things are getting pretty interoperable.
89+
function getVirtualKey(ev) {
90+
if ("key" in ev && typeof ev.key != "undefined")
91+
return ev.key;
92+
93+
var c = ev.charCode || ev.keyCode;
94+
if (c == 27)
95+
return "Escape";
96+
return String.fromCharCode(c);
9497
}
9598

96-
$(document).on('keypress', function handleKeyboardShortcut(e) {
97-
if (document.activeElement.tagName === 'INPUT') {
99+
function handleShortcut(ev) {
100+
if (document.activeElement.tagName == "INPUT")
98101
return;
99-
}
100102

101-
if (getChar(e) === '?') {
102-
if (e.shiftKey && $('#help').hasClass('hidden')) {
103-
e.preventDefault();
104-
$('#help').removeClass('hidden');
103+
switch (getVirtualKey(ev)) {
104+
case "Escape":
105+
if (!$("#help").hasClass("hidden")) {
106+
ev.preventDefault();
107+
$("#help").addClass("hidden");
108+
} else if (!$("#search").hasClass("hidden")) {
109+
ev.preventDefault();
110+
$("#search").addClass("hidden");
111+
$("#main").removeClass("hidden");
105112
}
106-
} else if (getChar(e) === 's' || getChar(e) === 'S') {
107-
e.preventDefault();
108-
$('.search-input').focus();
109-
}
110-
}).on('keydown', function(e) {
111-
// The escape key event has to be captured with the keydown event.
112-
// Because keypressed has no keycode for the escape key
113-
// (and other special keys in general)...
114-
if (document.activeElement.tagName === 'INPUT') {
115-
return;
116-
}
117-
118-
if (e.keyCode === 27) { // escape key
119-
if (!$('#help').hasClass('hidden')) {
120-
e.preventDefault();
121-
$('#help').addClass('hidden');
122-
} else if (!$('#search').hasClass('hidden')) {
123-
e.preventDefault();
124-
$('#search').addClass('hidden');
125-
$('#main').removeClass('hidden');
113+
break;
114+
115+
case "s":
116+
case "S":
117+
ev.preventDefault();
118+
$(".search-input").focus();
119+
break;
120+
121+
case "?":
122+
if (ev.shiftKey && $("#help").hasClass("hidden")) {
123+
ev.preventDefault();
124+
$("#help").removeClass("hidden");
126125
}
126+
break;
127127
}
128-
}).on('click', function(e) {
129-
if (!$(e.target).closest('#help').length) {
130-
$('#help').addClass('hidden');
128+
}
129+
130+
$(document).on("keypress", handleShortcut);
131+
$(document).on("keydown", handleShortcut);
132+
$(document).on("click", function(ev) {
133+
if (!$(ev.target).closest("#help").length) {
134+
$("#help").addClass("hidden");
131135
}
132136
});
133137

134-
135138
$('.version-selector').on('change', function() {
136139
var i, match,
137140
url = document.location.href,
@@ -150,6 +153,7 @@
150153

151154
document.location.href = url;
152155
});
156+
153157
/**
154158
* A function to compute the Levenshtein distance between two strings
155159
* Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported

src/librustdoc/html/static/playpen.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ document.addEventListener('DOMContentLoaded', function() {
1717
}
1818

1919
var featureRegexp = new RegExp('^\s*#!\\[feature\\(\.*?\\)\\]');
20-
var elements = document.querySelectorAll('pre.rust');
20+
var elements = document.querySelectorAll('pre.rust-example-rendered');
2121

2222
Array.prototype.forEach.call(elements, function(el) {
2323
el.onmouseover = function(e) {

src/libstd/io/prelude.rs

-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717
//! # #![allow(unused_imports)]
1818
//! use std::io::prelude::*;
1919
//! ```
20-
//!
21-
//! This module contains reexports of many core I/O traits such as `Read`,
22-
//! `Write` and `BufRead`. Structures and functions are not
23-
//! contained in this module.
2420
2521
#![stable(feature = "rust1", since = "1.0.0")]
2622

0 commit comments

Comments
 (0)