Skip to content

Rollup of 8 pull requests #59922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Apr 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
bd7a802
Remove check_match from const_eval
whitfin Apr 7, 2019
77bdb35
Add test demonstrating existing behaviour.
davidtwco Apr 7, 2019
d4d2317
Update test cases for changes to error messages
whitfin Apr 8, 2019
6688b03
proc_macro: stop using LEB128 for RPC.
eddyb Apr 9, 2019
bbdeafc
clarify what the item is in "not a module" error
euclio Apr 1, 2019
4a938b5
Special error when using catch after try
Kampfkarren Apr 10, 2019
de02dd9
Adhere to tidy script
Kampfkarren Apr 10, 2019
2b61431
Fix error brought up by changing tabs to spaces
Kampfkarren Apr 10, 2019
4af7cf3
Fix tests, I think
Kampfkarren Apr 10, 2019
16592f6
Suggest removing `?` to resolve type errors.
davidtwco Apr 10, 2019
ac037c1
Recover from missing semicolon based on the found token
estebank Apr 11, 2019
3ab9706
Tweak unstable diagnostic output
estebank Apr 10, 2019
1156ce6
Feedback
Kampfkarren Apr 11, 2019
8678164
Impl RawFd converstion traits for TcpListener, TcpStream and UdpSocket
rylev Apr 11, 2019
146d040
Reword tracking issue note
estebank Apr 11, 2019
66ed5d9
Fix ui-fulldeps test
estebank Apr 11, 2019
9b6b3d6
review comments
estebank Apr 11, 2019
1fb4837
Rollup merge of #59781 - whitfin:issue-59378, r=oli-obk
Centril Apr 12, 2019
ed1dd1e
Rollup merge of #59820 - eddyb:proc-macro-rpc-opt, r=nnethercote
Centril Apr 12, 2019
29f9dd2
Rollup merge of #59846 - euclio:not-a-module, r=davidtwco
Centril Apr 12, 2019
8f11195
Rollup merge of #59847 - Kampfkarren:try-block-catch, r=estebank
Centril Apr 12, 2019
2bc127d
Rollup merge of #59859 - davidtwco:issue-59756, r=cramertj
Centril Apr 12, 2019
ca9f04e
Rollup merge of #59862 - estebank:tweak-unstable-diag, r=petrochenkov
Centril Apr 12, 2019
af4acd0
Rollup merge of #59866 - estebank:recover-missing-semi, r=petrochenkov
Centril Apr 12, 2019
ba17313
Rollup merge of #59892 - rylev:as-raw-fd, r=alexcrichton
Centril Apr 12, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 13 additions & 23 deletions src/libproc_macro/bridge/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,22 @@ pub(super) trait DecodeMut<'a, 's, S>: Sized {
}

macro_rules! rpc_encode_decode {
(uleb128 $ty:ty) => {
(le $ty:ty) => {
impl<S> Encode<S> for $ty {
fn encode(mut self, w: &mut Writer, s: &mut S) {
let mut byte = 0x80;
while byte & 0x80 != 0 {
byte = (self & 0x7f) as u8;
self >>= 7;
if self != 0 {
byte |= 0x80;
}
byte.encode(w, s);
}
fn encode(self, w: &mut Writer, _: &mut S) {
w.write_all(&self.to_le_bytes()).unwrap();
}
}

impl<S> DecodeMut<'_, '_, S> for $ty {
fn decode(r: &mut Reader<'_>, s: &mut S) -> Self {
let mut byte = 0x80;
let mut v = 0;
let mut shift = 0;
while byte & 0x80 != 0 {
byte = u8::decode(r, s);
v |= ((byte & 0x7f) as Self) << shift;
shift += 7;
}
v
fn decode(r: &mut Reader<'_>, _: &mut S) -> Self {
const N: usize = ::std::mem::size_of::<$ty>();

let mut bytes = [0; N];
bytes.copy_from_slice(&r[..N]);
*r = &r[N..];

Self::from_le_bytes(bytes)
}
}
};
Expand Down Expand Up @@ -136,8 +126,8 @@ impl<S> DecodeMut<'_, '_, S> for u8 {
}
}

rpc_encode_decode!(uleb128 u32);
rpc_encode_decode!(uleb128 usize);
rpc_encode_decode!(le u32);
rpc_encode_decode!(le usize);

impl<S> Encode<S> for bool {
fn encode(self, w: &mut Writer, s: &mut S) {
Expand Down
28 changes: 27 additions & 1 deletion src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,13 +604,39 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
source,
ref prior_arms,
last_ty,
discrim_hir_id,
..
} => match source {
hir::MatchSource::IfLetDesugar { .. } => {
let msg = "`if let` arms have incompatible types";
err.span_label(cause.span, msg);
}
hir::MatchSource::TryDesugar => {}
hir::MatchSource::TryDesugar => {
if let Some(ty::error::ExpectedFound { expected, .. }) = exp_found {
let discrim_expr = self.tcx.hir().expect_expr_by_hir_id(discrim_hir_id);
let discrim_ty = if let hir::ExprKind::Call(_, args) = &discrim_expr.node {
let arg_expr = args.first().expect("try desugaring call w/out arg");
self.in_progress_tables.and_then(|tables| {
tables.borrow().expr_ty_opt(arg_expr)
})
} else {
bug!("try desugaring w/out call expr as discriminant");
};

match discrim_ty {
Some(ty) if expected == ty => {
let source_map = self.tcx.sess.source_map();
err.span_suggestion(
source_map.end_point(cause.span),
"try removing this `?`",
"".to_string(),
Applicability::MachineApplicable,
);
},
_ => {},
}
}
}
_ => {
let msg = "`match` arms have incompatible types";
err.span_label(cause.span, msg);
Expand Down
1 change: 1 addition & 0 deletions src/librustc/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ pub enum ObligationCauseCode<'tcx> {
source: hir::MatchSource,
prior_arms: Vec<Span>,
last_ty: Ty<'tcx>,
discrim_hir_id: hir::HirId,
},

/// Computing common supertype in the pattern guard for the arms of a match expression
Expand Down
2 changes: 2 additions & 0 deletions src/librustc/traits/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,13 +519,15 @@ impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCauseCode<'a> {
source,
ref prior_arms,
last_ty,
discrim_hir_id,
} => {
tcx.lift(&last_ty).map(|last_ty| {
super::MatchExpressionArm {
arm_span,
source,
prior_arms: prior_arms.clone(),
last_ty,
discrim_hir_id,
}
})
}
Expand Down
19 changes: 3 additions & 16 deletions src/librustc_mir/const_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,22 +615,9 @@ pub fn const_eval_raw_provider<'a, 'tcx>(
let cid = key.value;
let def_id = cid.instance.def.def_id();

if let Some(id) = tcx.hir().as_local_hir_id(def_id) {
let tables = tcx.typeck_tables_of(def_id);

// Do match-check before building MIR
// FIXME(#59378) check_match may have errored but we're not checking for that anymore
tcx.check_match(def_id);

if let hir::BodyOwnerKind::Const = tcx.hir().body_owner_kind_by_hir_id(id) {
tcx.mir_const_qualif(def_id);
}

// Do not continue into miri if typeck errors occurred; it will fail horribly
if tables.tainted_by_errors {
return Err(ErrorHandled::Reported)
}
};
if def_id.is_local() && tcx.typeck_tables_of(def_id).tainted_by_errors {
return Err(ErrorHandled::Reported);
}

let (res, ecx) = eval_body_and_ecx(tcx, cid, None, key.param_env);
res.and_then(|place| {
Expand Down
9 changes: 8 additions & 1 deletion src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3731,9 +3731,16 @@ impl<'a> Resolver<'a> {
def, path.len() - i - 1
));
} else {
let label = format!(
"`{}` is {} {}, not a module",
ident,
def.article(),
def.kind_name(),
);

return PathResult::Failed {
span: ident.span,
label: format!("not a module `{}`", ident),
label,
suggestion: None,
is_error_from_last_segment: is_last,
};
Expand Down
1 change: 1 addition & 0 deletions src/librustc_typeck/check/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
source: match_src,
prior_arms: other_arms.clone(),
last_ty: prior_arm_ty.unwrap(),
discrim_hir_id: discrim.hir_id,
})
};
coercion.coerce(self, &cause, &arm.body, arm_ty);
Expand Down
55 changes: 55 additions & 0 deletions src/libstd/sys/wasi/ext/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use crate::fs;
use crate::io;
use crate::sys;
use crate::net;
use crate::sys_common::{AsInner, FromInner, IntoInner};

/// Raw file descriptors.
Expand Down Expand Up @@ -50,6 +51,60 @@ pub trait IntoRawFd {
fn into_raw_fd(self) -> RawFd;
}

impl AsRawFd for net::TcpStream {
fn as_raw_fd(&self) -> RawFd {
self.as_inner().fd().as_raw()
}
}

impl FromRawFd for net::TcpStream {
unsafe fn from_raw_fd(fd: RawFd) -> net::TcpStream {
net::TcpStream::from_inner(sys::net::TcpStream::from_inner(fd))
}
}

impl IntoRawFd for net::TcpStream {
fn into_raw_fd(self) -> RawFd {
self.into_inner().into_fd().into_raw()
}
}

impl AsRawFd for net::TcpListener {
fn as_raw_fd(&self) -> RawFd {
self.as_inner().fd().as_raw()
}
}

impl FromRawFd for net::TcpListener {
unsafe fn from_raw_fd(fd: RawFd) -> net::TcpListener {
net::TcpListener::from_inner(sys::net::TcpListener::from_inner(fd))
}
}

impl IntoRawFd for net::TcpListener {
fn into_raw_fd(self) -> RawFd {
self.into_inner().into_fd().into_raw()
}
}

impl AsRawFd for net::UdpSocket {
fn as_raw_fd(&self) -> RawFd {
self.as_inner().fd().as_raw()
}
}

impl FromRawFd for net::UdpSocket {
unsafe fn from_raw_fd(fd: RawFd) -> net::UdpSocket {
net::UdpSocket::from_inner(sys::net::UdpSocket::from_inner(fd))
}
}

impl IntoRawFd for net::UdpSocket {
fn into_raw_fd(self) -> RawFd {
self.into_inner().into_fd().into_raw()
}
}

impl AsRawFd for fs::File {
fn as_raw_fd(&self) -> RawFd {
self.as_inner().fd().as_raw()
Expand Down
Loading