Skip to content

Commit

Permalink
Auto merge of #68526 - JohnTitor:rollup-3mmljof, r=JohnTitor
Browse files Browse the repository at this point in the history
Rollup of 6 pull requests

Successful merges:

 - #68111 (Print constants in `type_name` for const generics)
 - #68374 (Fix invalid link to the C++ Exception Handling ABI documentation)
 - #68504 (Use check-pass mode for lint tests and nll tests)
 - #68509 (Clean up error codes E0223 and E0225 explanations)
 - #68511 (Remove unused ignore-license directives)
 - #68515 (Support feature process_set_argv0 for VxWorks)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Jan 24, 2020
2 parents c2d141d + f998e27 commit 8647aa1
Show file tree
Hide file tree
Showing 70 changed files with 131 additions and 90 deletions.
2 changes: 1 addition & 1 deletion src/libpanic_unwind/gcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! "Exception Handling in LLVM" (llvm.org/docs/ExceptionHandling.html) and
//! documents linked from it.
//! These are also good reads:
//! http://mentorembedded.github.io/cxx-abi/abi-eh.html
//! https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html
//! http://monoinfinito.wordpress.com/series/exception-handling-in-c/
//! http://www.airs.com/blog/index.php?s=exception+frames
//!
Expand Down
38 changes: 30 additions & 8 deletions src/librustc/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -831,14 +831,27 @@ pub trait PrettyPrinter<'tcx>:
Ok(self)
}

fn pretty_print_const(mut self, ct: &'tcx ty::Const<'tcx>) -> Result<Self::Const, Self::Error> {
fn pretty_print_const(
mut self,
ct: &'tcx ty::Const<'tcx>,
print_ty: bool,
) -> Result<Self::Const, Self::Error> {
define_scoped_cx!(self);

if self.tcx().sess.verbose() {
p!(write("Const({:?}: {:?})", ct.val, ct.ty));
return Ok(self);
}

macro_rules! print_underscore {
() => {{
p!(write("_"));
if print_ty {
p!(write(": "), print(ct.ty));
}
}};
}

match (ct.val, &ct.ty.kind) {
(_, ty::FnDef(did, substs)) => p!(print_value_path(*did, substs)),
(ty::ConstKind::Unevaluated(did, substs, promoted), _) => {
Expand All @@ -857,22 +870,27 @@ pub trait PrettyPrinter<'tcx>:
{
p!(write("{}", snip))
} else {
p!(write("_: "), print(ct.ty))
print_underscore!()
}
} else {
p!(write("_: "), print(ct.ty))
print_underscore!()
}
}
}
}
}
(ty::ConstKind::Infer(..), _) => p!(write("_: "), print(ct.ty)),
(ty::ConstKind::Infer(..), _) => print_underscore!(),
(ty::ConstKind::Param(ParamConst { name, .. }), _) => p!(write("{}", name)),
(ty::ConstKind::Value(value), _) => return self.pretty_print_const_value(value, ct.ty),
(ty::ConstKind::Value(value), _) => {
return self.pretty_print_const_value(value, ct.ty, print_ty);
}

_ => {
// fallback
p!(write("{:?} : ", ct.val), print(ct.ty))
p!(write("{:?}", ct.val));
if print_ty {
p!(write(" : "), print(ct.ty));
}
}
};
Ok(self)
Expand All @@ -882,6 +900,7 @@ pub trait PrettyPrinter<'tcx>:
mut self,
ct: ConstValue<'tcx>,
ty: Ty<'tcx>,
print_ty: bool,
) -> Result<Self::Const, Self::Error> {
define_scoped_cx!(self);

Expand Down Expand Up @@ -988,7 +1007,10 @@ pub trait PrettyPrinter<'tcx>:
};
if !printed {
// fallback
p!(write("{:?} : ", ct), print(ty))
p!(write("{:?}", ct));
if print_ty {
p!(write(" : "), print(ty));
}
}
}
};
Expand Down Expand Up @@ -1162,7 +1184,7 @@ impl<F: fmt::Write> Printer<'tcx> for FmtPrinter<'_, 'tcx, F> {
}

fn print_const(self, ct: &'tcx ty::Const<'tcx>) -> Result<Self::Const, Self::Error> {
self.pretty_print_const(ct)
self.pretty_print_const(ct, true)
}

fn path_crate(mut self, cnum: CrateNum) -> Result<Self::Path, Self::Error> {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_utils/symbol_names/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ impl Printer<'tcx> for SymbolPrinter<'tcx> {
// only print integers
if let ty::ConstKind::Value(ConstValue::Scalar(Scalar::Raw { .. })) = ct.val {
if ct.ty.is_integral() {
return self.pretty_print_const(ct);
return self.pretty_print_const(ct, true);
}
}
self.write_str("_")?;
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_error_codes/error_codes/E0223.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
An attempt was made to retrieve an associated type, but the type was ambiguous.
For example:

Erroneous code example:

```compile_fail,E0223
trait MyTrait {type X; }
Expand Down
7 changes: 5 additions & 2 deletions src/librustc_error_codes/error_codes/E0225.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
You attempted to use multiple types as bounds for a closure or trait object.
Rust does not currently support this. A simple example that causes this error:
Multiple types were used as bounds for a closure or trait object.

Erroneous code example:

```compile_fail,E0225
fn main() {
let _: Box<dyn std::io::Read + std::io::Write>;
}
```

Rust does not currently support this.

Auto traits such as Send and Sync are an exception to this rule:
It's possible to have bounds of one non-builtin trait, plus any number of
auto traits. For example, the following compiles correctly:
Expand Down
5 changes: 2 additions & 3 deletions src/librustc_mir/interpret/intrinsics/type_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
}
}

fn print_const(self, _: &'tcx ty::Const<'tcx>) -> Result<Self::Const, Self::Error> {
// don't print constants to the user
Ok(self)
fn print_const(self, ct: &'tcx ty::Const<'tcx>) -> Result<Self::Const, Self::Error> {
self.pretty_print_const(ct, false)
}

fn print_dyn_existential(
Expand Down
3 changes: 0 additions & 3 deletions src/libstd/sys/cloudabi/abi/bitflags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.

// Appease Rust's tidy.
// ignore-license

#[cfg(feature = "bitflags")]
use bitflags::bitflags;

Expand Down
1 change: 0 additions & 1 deletion src/libstd/sys/cloudabi/abi/cloudabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
// Source: https://github.com/NuxiNL/cloudabi

// Appease Rust's tidy.
// ignore-license
// ignore-tidy-linelength

//! **PLEASE NOTE: This entire crate including this
Expand Down
18 changes: 18 additions & 0 deletions src/libstd/sys/vxworks/ext/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#![stable(feature = "rust1", since = "1.0.0")]

use crate::ffi::OsStr;
use crate::io;
use crate::process;
use crate::sys;
Expand Down Expand Up @@ -105,6 +106,15 @@ pub trait CommandExt {
/// cross-platform `spawn` instead.
#[stable(feature = "process_exec2", since = "1.9.0")]
fn exec(&mut self) -> io::Error;

/// Set executable argument
///
/// Set the first process argument, `argv[0]`, to something other than the
/// default executable path.
#[unstable(feature = "process_set_argv0", issue = "66510")]
fn arg0<S>(&mut self, arg: S) -> &mut process::Command
where
S: AsRef<OsStr>;
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand All @@ -130,6 +140,14 @@ impl CommandExt for process::Command {
fn exec(&mut self) -> io::Error {
self.as_inner_mut().exec(sys::process::Stdio::Inherit)
}

fn arg0<S>(&mut self, arg: S) -> &mut process::Command
where
S: AsRef<OsStr>,
{
self.as_inner_mut().set_arg_0(arg.as_ref());
self
}
}

/// Unix-specific extensions to [`process::ExitStatus`].
Expand Down
24 changes: 20 additions & 4 deletions src/libstd/sys/vxworks/process/process_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ impl Command {
let program = os2c(program, &mut saw_nul);
Command {
argv: Argv(vec![program.as_ptr(), ptr::null()]),
args: vec![program.clone()],
program,
args: Vec::new(),
env: Default::default(),
cwd: None,
uid: None,
Expand All @@ -104,11 +104,19 @@ impl Command {
}
}

pub fn set_arg_0(&mut self, arg: &OsStr) {
// Set a new arg0
let arg = os2c(arg, &mut self.saw_nul);
debug_assert!(self.argv.0.len() > 1);
self.argv.0[0] = arg.as_ptr();
self.args[0] = arg;
}

pub fn arg(&mut self, arg: &OsStr) {
// Overwrite the trailing NULL pointer in `argv` and then add a new null
// pointer.
let arg = os2c(arg, &mut self.saw_nul);
self.argv.0[self.args.len() + 1] = arg.as_ptr();
self.argv.0[self.args.len()] = arg.as_ptr();
self.argv.0.push(ptr::null());

// Also make sure we keep track of the owned value to schedule a
Expand All @@ -133,6 +141,10 @@ impl Command {
&self.argv.0
}

pub fn get_program(&self) -> &CStr {
&*self.program
}

#[allow(dead_code)]
pub fn get_cwd(&self) -> &Option<CString> {
&self.cwd
Expand Down Expand Up @@ -315,8 +327,12 @@ impl ChildStdio {

impl fmt::Debug for Command {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self.program)?;
for arg in &self.args {
if self.program != self.args[0] {
write!(f, "[{:?}] ", self.program)?;
}
write!(f, "{:?}", self.args[0])?;

for arg in &self.args[1..] {
write!(f, " {:?}", arg)?;
}
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/vxworks/process/process_vxworks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl Command {
let _lock = sys::os::env_lock();

let ret = libc::rtpSpawn(
self.get_argv()[0], // executing program
self.get_program().as_ptr(),
self.get_argv().as_ptr() as *mut *const c_char, // argv
c_envp as *mut *const c_char,
100 as c_int, // initial priority
Expand Down
5 changes: 0 additions & 5 deletions src/test/pretty/top-level-doc-comments.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
/// Some doc comment.
struct X;

// ignore-license

// http://rust-lang.org/COPYRIGHT.
//

// pp-exact

// Test that rust can properly pretty print a doc comment if it's the first line in a file. some
Expand Down
1 change: 0 additions & 1 deletion src/test/run-make-fulldeps/c-dynamic-dylib/cfoo.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ignore-license
#ifdef _WIN32
__declspec(dllexport)
#endif
Expand Down
2 changes: 0 additions & 2 deletions src/test/run-make-fulldeps/c-dynamic-rlib/cfoo.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// ignore-license

#ifdef _WIN32
__declspec(dllexport)
#endif
Expand Down
1 change: 0 additions & 1 deletion src/test/run-make-fulldeps/c-link-to-rust-dylib/bar.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ignore-license
void foo();

int main() {
Expand Down
1 change: 0 additions & 1 deletion src/test/run-make-fulldeps/c-link-to-rust-staticlib/bar.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ignore-license
void foo();

int main() {
Expand Down
1 change: 0 additions & 1 deletion src/test/run-make-fulldeps/c-static-dylib/cfoo.c
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// ignore-license
int foo() { return 0; }
1 change: 0 additions & 1 deletion src/test/run-make-fulldeps/c-static-rlib/cfoo.c
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// ignore-license
int foo() { return 0; }
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ignore-license
extern "C" void foo() {
int *a = new int(3);
delete a;
Expand Down
1 change: 0 additions & 1 deletion src/test/run-make-fulldeps/extern-fn-generic/test.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ignore-license
#include <stdint.h>

typedef struct TestStruct {
Expand Down
1 change: 0 additions & 1 deletion src/test/run-make-fulldeps/extern-fn-mangle/test.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ignore-license
#include <stdint.h>

uint32_t foo();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ignore-license
#include <stdio.h>
#include <stdint.h>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ignore-license
// Pragma needed cause of gcc bug on windows: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991

#include <assert.h>
Expand Down
1 change: 0 additions & 1 deletion src/test/run-make-fulldeps/extern-fn-with-union/ctest.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ignore-license
#include <stdio.h>
#include <stdint.h>

Expand Down
1 change: 0 additions & 1 deletion src/test/run-make-fulldeps/glibc-staticlib-args/program.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ignore-license
void args_check();

int main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ignore-license
void foo();

void bar() { foo(); }
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// ignore-license
void foo() {}
1 change: 0 additions & 1 deletion src/test/run-make-fulldeps/issue-25581/test.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ignore-license
#include <stddef.h>
#include <stdint.h>

Expand Down
1 change: 0 additions & 1 deletion src/test/run-make-fulldeps/link-path-order/correct.c
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// ignore-license
int should_return_one() { return 1; }
1 change: 0 additions & 1 deletion src/test/run-make-fulldeps/link-path-order/wrong.c
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// ignore-license
int should_return_one() { return 0; }
1 change: 0 additions & 1 deletion src/test/run-make-fulldeps/linkage-attr-on-static/foo.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ignore-license
#include <stdint.h>

extern int32_t BAZ;
Expand Down
1 change: 0 additions & 1 deletion src/test/run-make-fulldeps/lto-smoke-c/bar.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ignore-license
void foo();

int main() {
Expand Down
1 change: 0 additions & 1 deletion src/test/run-make-fulldeps/manual-link/bar.c
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// ignore-license
void bar() {}
1 change: 0 additions & 1 deletion src/test/run-make-fulldeps/manual-link/foo.c
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// ignore-license
void bar() {}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ignore-license
void overflow();

int main() {
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/attr-shebang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
#![allow(stable_features)]
#![feature(rust1)]
pub fn main() { }
// ignore-license
Loading

0 comments on commit 8647aa1

Please sign in to comment.