Skip to content

Commit 1e34b5e

Browse files
authored
Merge pull request #38884 from nikomatsakis/beta-unmerged
More beta backports
2 parents c80d225 + 793a395 commit 1e34b5e

File tree

13 files changed

+264
-40
lines changed

13 files changed

+264
-40
lines changed

src/bootstrap/doc.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,16 @@ pub fn std(build: &Build, stage: u32, target: &str) {
147147
cargo.arg("--manifest-path")
148148
.arg(build.src.join("src/rustc/std_shim/Cargo.toml"))
149149
.arg("--features").arg(build.std_features())
150-
.arg("-p").arg("std");
150+
.arg("--no-deps");
151+
152+
for krate in &["alloc", "collections", "core", "std", "std_unicode"] {
153+
cargo.arg("-p").arg(krate);
154+
// Create all crate output directories first to make sure rustdoc uses
155+
// relative links.
156+
// FIXME: Cargo should probably do this itself.
157+
t!(fs::create_dir_all(out_dir.join(krate)));
158+
}
159+
151160
build.run(&mut cargo);
152161
cp_r(&out_dir, &out)
153162
}

src/librustc/session/config.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,8 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
11721172
the compiler to emit",
11731173
"[asm|llvm-bc|llvm-ir|obj|link|dep-info]"),
11741174
opt::multi_s("", "print", "Comma separated list of compiler information to \
1175-
print on stdout", &print_opts.join("|")),
1175+
print on stdout", &format!("[{}]",
1176+
&print_opts.join("|"))),
11761177
opt::flagmulti_s("g", "", "Equivalent to -C debuginfo=2"),
11771178
opt::flagmulti_s("O", "", "Equivalent to -C opt-level=2"),
11781179
opt::opt_s("o", "", "Write output to <filename>", "FILENAME"),

src/librustc_trans/mir/block.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,11 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
222222
load
223223
} else {
224224
let op = self.trans_consume(&bcx, &mir::Lvalue::Local(mir::RETURN_POINTER));
225-
op.pack_if_pair(&bcx).immediate()
225+
if let Ref(llval) = op.val {
226+
bcx.with_block(|bcx| base::load_ty(&bcx, llval, op.ty))
227+
} else {
228+
op.pack_if_pair(&bcx).immediate()
229+
}
226230
};
227231
bcx.ret(llval);
228232
}

src/librustc_typeck/check/mod.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -4580,7 +4580,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
45804580
// Check provided lifetime parameters.
45814581
let lifetime_defs = segment.map_or(&[][..], |(_, generics)| &generics.regions);
45824582
if lifetimes.len() > lifetime_defs.len() {
4583-
let span = lifetimes[lifetime_defs.len()].span;
45844583
struct_span_err!(self.tcx.sess, span, E0088,
45854584
"too many lifetime parameters provided: \
45864585
expected {}, found {}",
@@ -4589,6 +4588,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
45894588
.span_label(span, &format!("unexpected lifetime parameter{}",
45904589
match lifetimes.len() { 1 => "", _ => "s" }))
45914590
.emit();
4591+
} else if lifetimes.len() > 0 && lifetimes.len() < lifetime_defs.len() {
4592+
struct_span_err!(self.tcx.sess, span, E0090,
4593+
"too few lifetime parameters provided: \
4594+
expected {}, found {}",
4595+
count(lifetime_defs.len()),
4596+
count(lifetimes.len()))
4597+
.span_label(span, &format!("too few lifetime parameters"))
4598+
.emit();
45924599
}
45934600

45944601
// The case where there is not enough lifetime parameters is not checked,

src/libstd/sys/windows/c.rs

+1
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ pub const EXCEPTION_STACK_OVERFLOW: DWORD = 0xc00000fd;
282282
pub const EXCEPTION_MAXIMUM_PARAMETERS: usize = 15;
283283

284284
pub const PIPE_ACCESS_INBOUND: DWORD = 0x00000001;
285+
pub const PIPE_ACCESS_OUTBOUND: DWORD = 0x00000002;
285286
pub const FILE_FLAG_FIRST_PIPE_INSTANCE: DWORD = 0x00080000;
286287
pub const FILE_FLAG_OVERLAPPED: DWORD = 0x40000000;
287288
pub const PIPE_WAIT: DWORD = 0x00000000;

src/libstd/sys/windows/pipe.rs

+57-20
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,43 @@ pub struct AnonPipe {
2929
inner: Handle,
3030
}
3131

32-
pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> {
32+
pub struct Pipes {
33+
pub ours: AnonPipe,
34+
pub theirs: AnonPipe,
35+
}
36+
37+
/// Although this looks similar to `anon_pipe` in the Unix module it's actually
38+
/// subtly different. Here we'll return two pipes in the `Pipes` return value,
39+
/// but one is intended for "us" where as the other is intended for "someone
40+
/// else".
41+
///
42+
/// Currently the only use case for this function is pipes for stdio on
43+
/// processes in the standard library, so "ours" is the one that'll stay in our
44+
/// process whereas "theirs" will be inherited to a child.
45+
///
46+
/// The ours/theirs pipes are *not* specifically readable or writable. Each
47+
/// one only supports a read or a write, but which is which depends on the
48+
/// boolean flag given. If `ours_readable` is true then `ours` is readable where
49+
/// `theirs` is writable. Conversely if `ours_readable` is false then `ours` is
50+
/// writable where `theirs` is readable.
51+
///
52+
/// Also note that the `ours` pipe is always a handle opened up in overlapped
53+
/// mode. This means that technically speaking it should only ever be used
54+
/// with `OVERLAPPED` instances, but also works out ok if it's only ever used
55+
/// once at a time (which we do indeed guarantee).
56+
pub fn anon_pipe(ours_readable: bool) -> io::Result<Pipes> {
3357
// Note that we specifically do *not* use `CreatePipe` here because
3458
// unfortunately the anonymous pipes returned do not support overlapped
35-
// operations.
36-
//
37-
// Instead, we create a "hopefully unique" name and create a named pipe
38-
// which has overlapped operations enabled.
59+
// operations. Instead, we create a "hopefully unique" name and create a
60+
// named pipe which has overlapped operations enabled.
3961
//
40-
// Once we do this, we connect do it as usual via `CreateFileW`, and then we
41-
// return those reader/writer halves.
62+
// Once we do this, we connect do it as usual via `CreateFileW`, and then
63+
// we return those reader/writer halves. Note that the `ours` pipe return
64+
// value is always the named pipe, whereas `theirs` is just the normal file.
65+
// This should hopefully shield us from child processes which assume their
66+
// stdout is a named pipe, which would indeed be odd!
4267
unsafe {
43-
let reader;
68+
let ours;
4469
let mut name;
4570
let mut tries = 0;
4671
let mut reject_remote_clients_flag = c::PIPE_REJECT_REMOTE_CLIENTS;
@@ -54,11 +79,16 @@ pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> {
5479
.encode_wide()
5580
.chain(Some(0))
5681
.collect::<Vec<_>>();
82+
let mut flags = c::FILE_FLAG_FIRST_PIPE_INSTANCE |
83+
c::FILE_FLAG_OVERLAPPED;
84+
if ours_readable {
85+
flags |= c::PIPE_ACCESS_INBOUND;
86+
} else {
87+
flags |= c::PIPE_ACCESS_OUTBOUND;
88+
}
5789

5890
let handle = c::CreateNamedPipeW(wide_name.as_ptr(),
59-
c::PIPE_ACCESS_INBOUND |
60-
c::FILE_FLAG_FIRST_PIPE_INSTANCE |
61-
c::FILE_FLAG_OVERLAPPED,
91+
flags,
6292
c::PIPE_TYPE_BYTE |
6393
c::PIPE_READMODE_BYTE |
6494
c::PIPE_WAIT |
@@ -101,21 +131,28 @@ pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> {
101131
}
102132
return Err(err)
103133
}
104-
reader = Handle::new(handle);
134+
ours = Handle::new(handle);
105135
break
106136
}
107137

108-
// Connect to the named pipe we just created in write-only mode (also
109-
// overlapped for async I/O below).
138+
// Connect to the named pipe we just created. This handle is going to be
139+
// returned in `theirs`, so if `ours` is readable we want this to be
140+
// writable, otherwise if `ours` is writable we want this to be
141+
// readable.
142+
//
143+
// Additionally we don't enable overlapped mode on this because most
144+
// client processes aren't enabled to work with that.
110145
let mut opts = OpenOptions::new();
111-
opts.write(true);
112-
opts.read(false);
146+
opts.write(ours_readable);
147+
opts.read(!ours_readable);
113148
opts.share_mode(0);
114-
opts.attributes(c::FILE_FLAG_OVERLAPPED);
115-
let writer = File::open(Path::new(&name), &opts)?;
116-
let writer = AnonPipe { inner: writer.into_handle() };
149+
let theirs = File::open(Path::new(&name), &opts)?;
150+
let theirs = AnonPipe { inner: theirs.into_handle() };
117151

118-
Ok((AnonPipe { inner: reader }, AnonPipe { inner: writer.into_handle() }))
152+
Ok(Pipes {
153+
ours: AnonPipe { inner: ours },
154+
theirs: AnonPipe { inner: theirs.into_handle() },
155+
})
119156
}
120157
}
121158

src/libstd/sys/windows/process.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -264,19 +264,15 @@ impl Stdio {
264264
}
265265

266266
Stdio::MakePipe => {
267-
let (reader, writer) = pipe::anon_pipe()?;
268-
let (ours, theirs) = if stdio_id == c::STD_INPUT_HANDLE {
269-
(writer, reader)
270-
} else {
271-
(reader, writer)
272-
};
273-
*pipe = Some(ours);
267+
let ours_readable = stdio_id != c::STD_INPUT_HANDLE;
268+
let pipes = pipe::anon_pipe(ours_readable)?;
269+
*pipe = Some(pipes.ours);
274270
cvt(unsafe {
275-
c::SetHandleInformation(theirs.handle().raw(),
271+
c::SetHandleInformation(pipes.theirs.handle().raw(),
276272
c::HANDLE_FLAG_INHERIT,
277273
c::HANDLE_FLAG_INHERIT)
278274
})?;
279-
Ok(theirs.into_handle())
275+
Ok(pipes.theirs.into_handle())
280276
}
281277

282278
Stdio::Handle(ref handle) => {

src/libsyntax/fold.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -544,19 +544,19 @@ pub fn noop_fold_arg<T: Folder>(Arg {id, pat, ty}: Arg, fld: &mut T) -> Arg {
544544
pub fn noop_fold_tt<T: Folder>(tt: &TokenTree, fld: &mut T) -> TokenTree {
545545
match *tt {
546546
TokenTree::Token(span, ref tok) =>
547-
TokenTree::Token(span, fld.fold_token(tok.clone())),
547+
TokenTree::Token(fld.new_span(span), fld.fold_token(tok.clone())),
548548
TokenTree::Delimited(span, ref delimed) => {
549-
TokenTree::Delimited(span, Rc::new(
549+
TokenTree::Delimited(fld.new_span(span), Rc::new(
550550
Delimited {
551551
delim: delimed.delim,
552-
open_span: delimed.open_span,
552+
open_span: fld.new_span(delimed.open_span),
553553
tts: fld.fold_tts(&delimed.tts),
554-
close_span: delimed.close_span,
554+
close_span: fld.new_span(delimed.close_span),
555555
}
556556
))
557557
},
558558
TokenTree::Sequence(span, ref seq) =>
559-
TokenTree::Sequence(span,
559+
TokenTree::Sequence(fld.new_span(span),
560560
Rc::new(SequenceRepetition {
561561
tts: fld.fold_tts(&seq.tts),
562562
separator: seq.separator.clone().map(|tok| fld.fold_token(tok)),
@@ -649,7 +649,7 @@ pub fn noop_fold_fn_decl<T: Folder>(decl: P<FnDecl>, fld: &mut T) -> P<FnDecl> {
649649
inputs: inputs.move_map(|x| fld.fold_arg(x)),
650650
output: match output {
651651
FunctionRetTy::Ty(ty) => FunctionRetTy::Ty(fld.fold_ty(ty)),
652-
FunctionRetTy::Default(span) => FunctionRetTy::Default(span),
652+
FunctionRetTy::Default(span) => FunctionRetTy::Default(fld.new_span(span)),
653653
},
654654
variadic: variadic
655655
})
@@ -676,7 +676,7 @@ pub fn noop_fold_ty_param<T: Folder>(tp: TyParam, fld: &mut T) -> TyParam {
676676
ident: ident,
677677
bounds: fld.fold_bounds(bounds),
678678
default: default.map(|x| fld.fold_ty(x)),
679-
span: span
679+
span: fld.new_span(span),
680680
}
681681
}
682682

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2016 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+
// force-host
12+
// no-prefer-dynamic
13+
14+
#![feature(proc_macro, proc_macro_lib)]
15+
#![crate_type = "proc-macro"]
16+
17+
extern crate proc_macro;
18+
19+
#[proc_macro_derive(A)]
20+
pub fn derive_a(_: proc_macro::TokenStream) -> proc_macro::TokenStream {
21+
"fn f() { println!(\"{}\", foo); }".parse().unwrap()
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2016 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+
// aux-build:issue_38586.rs
12+
13+
#![feature(proc_macro)]
14+
15+
#[macro_use]
16+
extern crate issue_38586;
17+
18+
#[derive(A)] //~ ERROR `foo`
19+
struct A;
20+
21+
fn main() {}

src/test/compile-fail/E0090.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2016 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+
fn foo<'a: 'b, 'b: 'a>() {}
12+
fn main() {
13+
foo::<'static>();//~ ERROR E0090
14+
//~^ too few lifetime parameters
15+
}

src/test/run-pass/issue-38727.rs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2017 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+
#[repr(u64)]
12+
enum A {
13+
A = 0u64,
14+
B = !0u64,
15+
}
16+
17+
fn cmp() -> A {
18+
A::B
19+
}
20+
21+
fn main() {}

0 commit comments

Comments
 (0)