Skip to content

Commit

Permalink
Auto merge of #44169 - arielb1:rollup, r=arielb1
Browse files Browse the repository at this point in the history
Rollup of 12 pull requests

- Successful merges: #43705, #43778, #43918, #44076, #44117, #44121, #44126, #44134, #44135, #44141, #44144, #44158
- Failed merges:
  • Loading branch information
bors committed Aug 29, 2017
2 parents 630e02f + be0ac01 commit c11f689
Show file tree
Hide file tree
Showing 15 changed files with 207 additions and 92 deletions.
6 changes: 6 additions & 0 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,9 @@ impl Step for Src {
let dst_src = dst.join("rust");
t!(fs::create_dir_all(&dst_src));

let src_files = [
"src/Cargo.lock",
];
// This is the reduced set of paths which will become the rust-src component
// (essentially libstd and all of its path dependencies)
let std_src_dirs = [
Expand Down Expand Up @@ -759,6 +762,9 @@ impl Step for Src {
];

copy_src_dirs(build, &std_src_dirs[..], &std_src_dirs_exclude[..], &dst_src);
for file in src_files.iter() {
copy(&build.src.join(file), &dst_src.join(file));
}

// Create source tarball in rust-installer format
let mut cmd = rust_installer(builder);
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`");
None => {
// No subcommand -- show the general usage and subcommand help
println!("{}\n", subcommand_help);
process::exit(0);
process::exit(1);
}
};

Expand Down
1 change: 0 additions & 1 deletion src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ extern crate build_helper;
extern crate serde_derive;
#[macro_use]
extern crate lazy_static;
extern crate serde;
extern crate serde_json;
extern crate cmake;
extern crate filetime;
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ tool!(
Linkchecker, "src/tools/linkchecker", "linkchecker", Mode::Libstd;
CargoTest, "src/tools/cargotest", "cargotest", Mode::Libstd;
Compiletest, "src/tools/compiletest", "compiletest", Mode::Libtest;
BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::Librustc;
BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::Libstd;
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::Libstd;
RustInstaller, "src/tools/rust-installer", "rust-installer", Mode::Libstd;
);
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/fmt/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ macro_rules! impl_Display {
// decode last 1 or 2 chars
if n < 10 {
curr -= 1;
*buf_ptr.offset(curr) = (n as u8) + 48;
*buf_ptr.offset(curr) = (n as u8) + b'0';
} else {
let d1 = n << 1;
curr -= 2;
Expand Down
20 changes: 20 additions & 0 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,26 @@ impl<'a, T: Clone> Option<&'a T> {
}
}

impl<'a, T: Clone> Option<&'a mut T> {
/// Maps an `Option<&mut T>` to an `Option<T>` by cloning the contents of the
/// option.
///
/// # Examples
///
/// ```
/// #![feature(option_ref_mut_cloned)]
/// let mut x = 12;
/// let opt_x = Some(&mut x);
/// assert_eq!(opt_x, Some(&mut 12));
/// let cloned = opt_x.cloned();
/// assert_eq!(cloned, Some(12));
/// ```
#[unstable(feature = "option_ref_mut_cloned", issue = "43738")]
pub fn cloned(self) -> Option<T> {
self.map(|t| t.clone())
}
}

impl<T: Default> Option<T> {
/// Returns the contained value or a default
///
Expand Down
6 changes: 6 additions & 0 deletions src/librustc_errors/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,12 @@ impl Handler {
self.continue_after_error.set(continue_after_error);
}

// NOTE: DO NOT call this function from rustc, as it relies on `err_count` being non-zero
// if an error happened to avoid ICEs. This function should only be called from tools.
pub fn reset_err_count(&self) {
self.err_count.set(0);
}

pub fn struct_dummy<'a>(&'a self) -> DiagnosticBuilder<'a> {
DiagnosticBuilder::new(self, Level::Cancelled, "")
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl<'a> fmt::Display for WhereClause<'a> {
}

if end_newline {
//add a space so stripping <br> tags and breaking spaces still renders properly
// add a space so stripping <br> tags and breaking spaces still renders properly
if f.alternate() {
clause.push(' ');
} else {
Expand Down
58 changes: 43 additions & 15 deletions src/librustdoc/html/highlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,21 @@ impl<'a> Classifier<'a> {
}
}

/// Gets the next token out of the lexer, emitting fatal errors if lexing fails.
fn try_next_token(&mut self) -> io::Result<TokenAndSpan> {
match self.lexer.try_next_token() {
Ok(tas) => Ok(tas),
Err(_) => {
self.lexer.emit_fatal_errors();
self.lexer.sess.span_diagnostic
.struct_warn("Backing out of syntax highlighting")
.note("You probably did not intend to render this as a rust code-block")
.emit();
Err(io::Error::new(io::ErrorKind::Other, ""))
}
}
}

/// Exhausts the `lexer` writing the output into `out`.
///
/// The general structure for this method is to iterate over each token,
Expand All @@ -183,18 +198,7 @@ impl<'a> Classifier<'a> {
out: &mut W)
-> io::Result<()> {
loop {
let next = match self.lexer.try_next_token() {
Ok(tas) => tas,
Err(_) => {
self.lexer.emit_fatal_errors();
self.lexer.sess.span_diagnostic
.struct_warn("Backing out of syntax highlighting")
.note("You probably did not intend to render this as a rust code-block")
.emit();
return Err(io::Error::new(io::ErrorKind::Other, ""));
}
};

let next = self.try_next_token()?;
if next.tok == token::Eof {
break;
}
Expand Down Expand Up @@ -255,13 +259,37 @@ impl<'a> Classifier<'a> {
}
}

// This is the start of an attribute. We're going to want to
// This might be the start of an attribute. We're going to want to
// continue highlighting it as an attribute until the ending ']' is
// seen, so skip out early. Down below we terminate the attribute
// span when we see the ']'.
token::Pound => {
self.in_attribute = true;
out.enter_span(Class::Attribute)?;
// We can't be sure that our # begins an attribute (it could
// just be appearing in a macro) until we read either `#![` or
// `#[` from the input stream.
//
// We don't want to start highlighting as an attribute until
// we're confident there is going to be a ] coming up, as
// otherwise # tokens in macros highlight the rest of the input
// as an attribute.

// Case 1: #![inner_attribute]
if self.lexer.peek().tok == token::Not {
self.try_next_token()?; // NOTE: consumes `!` token!
if self.lexer.peek().tok == token::OpenDelim(token::Bracket) {
self.in_attribute = true;
out.enter_span(Class::Attribute)?;
}
out.string("#", Class::None, None)?;
out.string("!", Class::None, None)?;
return Ok(());
}

// Case 2: #[outer_attribute]
if self.lexer.peek().tok == token::OpenDelim(token::Bracket) {
self.in_attribute = true;
out.enter_span(Class::Attribute)?;
}
out.string("#", Class::None, None)?;
return Ok(());
}
Expand Down
6 changes: 2 additions & 4 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1523,17 +1523,15 @@ impl<'a> fmt::Display for Item<'a> {
} else {
write!(fmt, "Module ")?;
},
clean::FunctionItem(..) | clean::ForeignFunctionItem(..) =>
write!(fmt, "Function ")?,
clean::FunctionItem(..) | clean::ForeignFunctionItem(..) => write!(fmt, "Function ")?,
clean::TraitItem(..) => write!(fmt, "Trait ")?,
clean::StructItem(..) => write!(fmt, "Struct ")?,
clean::UnionItem(..) => write!(fmt, "Union ")?,
clean::EnumItem(..) => write!(fmt, "Enum ")?,
clean::TypedefItem(..) => write!(fmt, "Type Definition ")?,
clean::MacroItem(..) => write!(fmt, "Macro ")?,
clean::PrimitiveItem(..) => write!(fmt, "Primitive Type ")?,
clean::StaticItem(..) | clean::ForeignStaticItem(..) =>
write!(fmt, "Static ")?,
clean::StaticItem(..) | clean::ForeignStaticItem(..) => write!(fmt, "Static ")?,
clean::ConstantItem(..) => write!(fmt, "Constant ")?,
_ => {
// We don't generate pages for any other type.
Expand Down
7 changes: 6 additions & 1 deletion src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@ h4 > code, h3 > code, .invisible > code {
display: inline-block;
}

.in-band > code {
display: inline-block;
}

#main { position: relative; }
#main > .since {
top: inherit;
Expand Down Expand Up @@ -447,7 +451,8 @@ a {
}

.in-band:hover > .anchor {
display: initial;
display: inline-block;
position: absolute;
}
.anchor {
display: none;
Expand Down
88 changes: 66 additions & 22 deletions src/libstd/net/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,30 +705,74 @@ impl hash::Hash for SocketAddrV6 {
///
/// # Examples
///
/// Creating a [`SocketAddr`] iterator that yields one item:
///
/// ```
/// use std::net::{ToSocketAddrs, SocketAddr};
///
/// let addr = SocketAddr::from(([127, 0, 0, 1], 443));
/// let mut addrs_iter = addr.to_socket_addrs().unwrap();
///
/// assert_eq!(Some(addr), addrs_iter.next());
/// assert!(addrs_iter.next().is_none());
/// ```
///
/// Creating a [`SocketAddr`] iterator from a hostname:
///
/// ```no_run
/// use std::net::{SocketAddrV4, TcpStream, UdpSocket, TcpListener, Ipv4Addr};
///
/// fn main() {
/// let ip = Ipv4Addr::new(127, 0, 0, 1);
/// let port = 12345;
///
/// // The following lines are equivalent modulo possible "localhost" name
/// // resolution differences
/// let tcp_s = TcpStream::connect(SocketAddrV4::new(ip, port));
/// let tcp_s = TcpStream::connect((ip, port));
/// let tcp_s = TcpStream::connect(("127.0.0.1", port));
/// let tcp_s = TcpStream::connect(("localhost", port));
/// let tcp_s = TcpStream::connect("127.0.0.1:12345");
/// let tcp_s = TcpStream::connect("localhost:12345");
///
/// // TcpListener::bind(), UdpSocket::bind() and UdpSocket::send_to()
/// // behave similarly
/// let tcp_l = TcpListener::bind("localhost:12345");
///
/// let mut udp_s = UdpSocket::bind(("127.0.0.1", port)).unwrap();
/// udp_s.send_to(&[7], (ip, 23451)).unwrap();
/// }
/// use std::net::{SocketAddr, ToSocketAddrs};
///
/// // assuming 'localhost' resolves to 127.0.0.1
/// let mut addrs_iter = "localhost:443".to_socket_addrs().unwrap();
/// assert_eq!(addrs_iter.next(), Some(SocketAddr::from(([127, 0, 0, 1], 443))));
/// assert!(addrs_iter.next().is_none());
///
/// // assuming 'foo' does not resolve
/// assert!("foo:443".to_socket_addrs().is_err());
/// ```
///
/// Creating a [`SocketAddr`] iterator that yields multiple items:
///
/// ```
/// use std::net::{SocketAddr, ToSocketAddrs};
///
/// let addr1 = SocketAddr::from(([0, 0, 0, 0], 80));
/// let addr2 = SocketAddr::from(([127, 0, 0, 1], 443));
/// let addrs = vec![addr1, addr2];
///
/// let mut addrs_iter = (&addrs[..]).to_socket_addrs().unwrap();
///
/// assert_eq!(Some(addr1), addrs_iter.next());
/// assert_eq!(Some(addr2), addrs_iter.next());
/// assert!(addrs_iter.next().is_none());
/// ```
///
/// Attempting to create a [`SocketAddr`] iterator from an improperly formatted
/// socket address `&str` (missing the port):
///
/// ```
/// use std::io;
/// use std::net::ToSocketAddrs;
///
/// let err = "127.0.0.1".to_socket_addrs().unwrap_err();
/// assert_eq!(err.kind(), io::ErrorKind::InvalidInput);
/// ```
///
/// [`TcpStream::connect`] is an example of an function that utilizes
/// `ToSocketsAddr` as a trait bound on its parameter in order to accept
/// different types:
///
/// ```no_run
/// use std::net::{TcpStream, Ipv4Addr};
///
/// let stream = TcpStream::connect(("127.0.0.1", 443));
/// // or
/// let stream = TcpStream::connect("127.0.0.1.443");
/// // or
/// let stream = TcpStream::connect((Ipv4Addr::new(127, 0, 0, 1), 443));
/// ```
///
/// [`TcpStream::connect`]: ../../std/net/struct.TcpStream.html#method.connect
#[stable(feature = "rust1", since = "1.0.0")]
pub trait ToSocketAddrs {
/// Returned iterator over socket addresses which this type may correspond
Expand Down
8 changes: 6 additions & 2 deletions src/test/rustdoc/issue-41783.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@
// @!has - 'space'
// @!has - 'comment'
// @has - '# <span class="ident">single'
// @has - '#<span class="attribute"># <span class="ident">double</span>'
// @has - '#<span class="attribute">#<span class="attribute"># <span class="ident">triple</span>'
// @has - '## <span class="ident">double</span>'
// @has - '### <span class="ident">triple</span>'
// @has - '<span class="attribute">#[<span class="ident">outer</span>]</span>'
// @has - '<span class="attribute">#![<span class="ident">inner</span>]</span>'

/// ```no_run
/// # # space
/// # comment
/// ## single
/// ### double
/// #### triple
/// ##[outer]
/// ##![inner]
/// ```
pub struct Foo;
13 changes: 9 additions & 4 deletions src/tools/build-manifest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,12 @@ impl Builder {
self.package("rust-std", &mut manifest.pkg, TARGETS);
self.package("rust-docs", &mut manifest.pkg, TARGETS);
self.package("rust-src", &mut manifest.pkg, &["*"]);
self.package("rls", &mut manifest.pkg, HOSTS);
let rls_package_name = if self.rust_release == "nightly" {
"rls"
} else {
"rls-preview"
};
self.package(rls_package_name, &mut manifest.pkg, HOSTS);
self.package("rust-analysis", &mut manifest.pkg, TARGETS);

let mut pkg = Package {
Expand Down Expand Up @@ -276,7 +281,7 @@ impl Builder {
}

extensions.push(Component {
pkg: "rls".to_string(),
pkg: rls_package_name.to_string(),
target: host.to_string(),
});
extensions.push(Component {
Expand Down Expand Up @@ -353,7 +358,7 @@ impl Builder {
format!("rust-src-{}.tar.gz", self.rust_release)
} else if component == "cargo" {
format!("cargo-{}-{}.tar.gz", self.cargo_release, target)
} else if component == "rls" {
} else if component == "rls" || component == "rls-preview" {
format!("rls-{}-{}.tar.gz", self.rls_release, target)
} else {
format!("{}-{}-{}.tar.gz", component, self.rust_release, target)
Expand All @@ -363,7 +368,7 @@ impl Builder {
fn cached_version(&self, component: &str) -> &str {
if component == "cargo" {
&self.cargo_version
} else if component == "rls" {
} else if component == "rls" || component == "rls-preview" {
&self.rls_version
} else {
&self.rust_version
Expand Down
Loading

0 comments on commit c11f689

Please sign in to comment.