Skip to content

Commit 8647aa1

Browse files
committed
Auto merge of #68526 - JohnTitor:rollup-3mmljof, r=JohnTitor
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
2 parents c2d141d + f998e27 commit 8647aa1

File tree

70 files changed

+131
-90
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+131
-90
lines changed

src/libpanic_unwind/gcc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//! "Exception Handling in LLVM" (llvm.org/docs/ExceptionHandling.html) and
55
//! documents linked from it.
66
//! These are also good reads:
7-
//! http://mentorembedded.github.io/cxx-abi/abi-eh.html
7+
//! https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html
88
//! http://monoinfinito.wordpress.com/series/exception-handling-in-c/
99
//! http://www.airs.com/blog/index.php?s=exception+frames
1010
//!

src/librustc/ty/print/pretty.rs

+30-8
Original file line numberDiff line numberDiff line change
@@ -831,14 +831,27 @@ pub trait PrettyPrinter<'tcx>:
831831
Ok(self)
832832
}
833833

834-
fn pretty_print_const(mut self, ct: &'tcx ty::Const<'tcx>) -> Result<Self::Const, Self::Error> {
834+
fn pretty_print_const(
835+
mut self,
836+
ct: &'tcx ty::Const<'tcx>,
837+
print_ty: bool,
838+
) -> Result<Self::Const, Self::Error> {
835839
define_scoped_cx!(self);
836840

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

846+
macro_rules! print_underscore {
847+
() => {{
848+
p!(write("_"));
849+
if print_ty {
850+
p!(write(": "), print(ct.ty));
851+
}
852+
}};
853+
}
854+
842855
match (ct.val, &ct.ty.kind) {
843856
(_, ty::FnDef(did, substs)) => p!(print_value_path(*did, substs)),
844857
(ty::ConstKind::Unevaluated(did, substs, promoted), _) => {
@@ -857,22 +870,27 @@ pub trait PrettyPrinter<'tcx>:
857870
{
858871
p!(write("{}", snip))
859872
} else {
860-
p!(write("_: "), print(ct.ty))
873+
print_underscore!()
861874
}
862875
} else {
863-
p!(write("_: "), print(ct.ty))
876+
print_underscore!()
864877
}
865878
}
866879
}
867880
}
868881
}
869-
(ty::ConstKind::Infer(..), _) => p!(write("_: "), print(ct.ty)),
882+
(ty::ConstKind::Infer(..), _) => print_underscore!(),
870883
(ty::ConstKind::Param(ParamConst { name, .. }), _) => p!(write("{}", name)),
871-
(ty::ConstKind::Value(value), _) => return self.pretty_print_const_value(value, ct.ty),
884+
(ty::ConstKind::Value(value), _) => {
885+
return self.pretty_print_const_value(value, ct.ty, print_ty);
886+
}
872887

873888
_ => {
874889
// fallback
875-
p!(write("{:?} : ", ct.val), print(ct.ty))
890+
p!(write("{:?}", ct.val));
891+
if print_ty {
892+
p!(write(" : "), print(ct.ty));
893+
}
876894
}
877895
};
878896
Ok(self)
@@ -882,6 +900,7 @@ pub trait PrettyPrinter<'tcx>:
882900
mut self,
883901
ct: ConstValue<'tcx>,
884902
ty: Ty<'tcx>,
903+
print_ty: bool,
885904
) -> Result<Self::Const, Self::Error> {
886905
define_scoped_cx!(self);
887906

@@ -988,7 +1007,10 @@ pub trait PrettyPrinter<'tcx>:
9881007
};
9891008
if !printed {
9901009
// fallback
991-
p!(write("{:?} : ", ct), print(ty))
1010+
p!(write("{:?}", ct));
1011+
if print_ty {
1012+
p!(write(" : "), print(ty));
1013+
}
9921014
}
9931015
}
9941016
};
@@ -1162,7 +1184,7 @@ impl<F: fmt::Write> Printer<'tcx> for FmtPrinter<'_, 'tcx, F> {
11621184
}
11631185

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

11681190
fn path_crate(mut self, cnum: CrateNum) -> Result<Self::Path, Self::Error> {

src/librustc_codegen_utils/symbol_names/legacy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ impl Printer<'tcx> for SymbolPrinter<'tcx> {
237237
// only print integers
238238
if let ty::ConstKind::Value(ConstValue::Scalar(Scalar::Raw { .. })) = ct.val {
239239
if ct.ty.is_integral() {
240-
return self.pretty_print_const(ct);
240+
return self.pretty_print_const(ct, true);
241241
}
242242
}
243243
self.write_str("_")?;

src/librustc_error_codes/error_codes/E0223.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
An attempt was made to retrieve an associated type, but the type was ambiguous.
2-
For example:
2+
3+
Erroneous code example:
34

45
```compile_fail,E0223
56
trait MyTrait {type X; }

src/librustc_error_codes/error_codes/E0225.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
You attempted to use multiple types as bounds for a closure or trait object.
2-
Rust does not currently support this. A simple example that causes this error:
1+
Multiple types were used as bounds for a closure or trait object.
2+
3+
Erroneous code example:
34

45
```compile_fail,E0225
56
fn main() {
67
let _: Box<dyn std::io::Read + std::io::Write>;
78
}
89
```
910

11+
Rust does not currently support this.
12+
1013
Auto traits such as Send and Sync are an exception to this rule:
1114
It's possible to have bounds of one non-builtin trait, plus any number of
1215
auto traits. For example, the following compiles correctly:

src/librustc_mir/interpret/intrinsics/type_name.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
6969
}
7070
}
7171

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

7776
fn print_dyn_existential(

src/libstd/sys/cloudabi/abi/bitflags.rs

-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2222
// SUCH DAMAGE.
2323

24-
// Appease Rust's tidy.
25-
// ignore-license
26-
2724
#[cfg(feature = "bitflags")]
2825
use bitflags::bitflags;
2926

src/libstd/sys/cloudabi/abi/cloudabi.rs

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
// Source: https://github.com/NuxiNL/cloudabi
2727

2828
// Appease Rust's tidy.
29-
// ignore-license
3029
// ignore-tidy-linelength
3130

3231
//! **PLEASE NOTE: This entire crate including this

src/libstd/sys/vxworks/ext/process.rs

+18
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
#![stable(feature = "rust1", since = "1.0.0")]
44

5+
use crate::ffi::OsStr;
56
use crate::io;
67
use crate::process;
78
use crate::sys;
@@ -105,6 +106,15 @@ pub trait CommandExt {
105106
/// cross-platform `spawn` instead.
106107
#[stable(feature = "process_exec2", since = "1.9.0")]
107108
fn exec(&mut self) -> io::Error;
109+
110+
/// Set executable argument
111+
///
112+
/// Set the first process argument, `argv[0]`, to something other than the
113+
/// default executable path.
114+
#[unstable(feature = "process_set_argv0", issue = "66510")]
115+
fn arg0<S>(&mut self, arg: S) -> &mut process::Command
116+
where
117+
S: AsRef<OsStr>;
108118
}
109119

110120
#[stable(feature = "rust1", since = "1.0.0")]
@@ -130,6 +140,14 @@ impl CommandExt for process::Command {
130140
fn exec(&mut self) -> io::Error {
131141
self.as_inner_mut().exec(sys::process::Stdio::Inherit)
132142
}
143+
144+
fn arg0<S>(&mut self, arg: S) -> &mut process::Command
145+
where
146+
S: AsRef<OsStr>,
147+
{
148+
self.as_inner_mut().set_arg_0(arg.as_ref());
149+
self
150+
}
133151
}
134152

135153
/// Unix-specific extensions to [`process::ExitStatus`].

src/libstd/sys/vxworks/process/process_common.rs

+20-4
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ impl Command {
9090
let program = os2c(program, &mut saw_nul);
9191
Command {
9292
argv: Argv(vec![program.as_ptr(), ptr::null()]),
93+
args: vec![program.clone()],
9394
program,
94-
args: Vec::new(),
9595
env: Default::default(),
9696
cwd: None,
9797
uid: None,
@@ -104,11 +104,19 @@ impl Command {
104104
}
105105
}
106106

107+
pub fn set_arg_0(&mut self, arg: &OsStr) {
108+
// Set a new arg0
109+
let arg = os2c(arg, &mut self.saw_nul);
110+
debug_assert!(self.argv.0.len() > 1);
111+
self.argv.0[0] = arg.as_ptr();
112+
self.args[0] = arg;
113+
}
114+
107115
pub fn arg(&mut self, arg: &OsStr) {
108116
// Overwrite the trailing NULL pointer in `argv` and then add a new null
109117
// pointer.
110118
let arg = os2c(arg, &mut self.saw_nul);
111-
self.argv.0[self.args.len() + 1] = arg.as_ptr();
119+
self.argv.0[self.args.len()] = arg.as_ptr();
112120
self.argv.0.push(ptr::null());
113121

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

144+
pub fn get_program(&self) -> &CStr {
145+
&*self.program
146+
}
147+
136148
#[allow(dead_code)]
137149
pub fn get_cwd(&self) -> &Option<CString> {
138150
&self.cwd
@@ -315,8 +327,12 @@ impl ChildStdio {
315327

316328
impl fmt::Debug for Command {
317329
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
318-
write!(f, "{:?}", self.program)?;
319-
for arg in &self.args {
330+
if self.program != self.args[0] {
331+
write!(f, "[{:?}] ", self.program)?;
332+
}
333+
write!(f, "{:?}", self.args[0])?;
334+
335+
for arg in &self.args[1..] {
320336
write!(f, " {:?}", arg)?;
321337
}
322338
Ok(())

src/libstd/sys/vxworks/process/process_vxworks.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl Command {
6767
let _lock = sys::os::env_lock();
6868

6969
let ret = libc::rtpSpawn(
70-
self.get_argv()[0], // executing program
70+
self.get_program().as_ptr(),
7171
self.get_argv().as_ptr() as *mut *const c_char, // argv
7272
c_envp as *mut *const c_char,
7373
100 as c_int, // initial priority

src/test/pretty/top-level-doc-comments.rs

-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
/// Some doc comment.
22
struct X;
33

4-
// ignore-license
5-
6-
// http://rust-lang.org/COPYRIGHT.
7-
//
8-
94
// pp-exact
105

116
// Test that rust can properly pretty print a doc comment if it's the first line in a file. some

src/test/run-make-fulldeps/c-dynamic-dylib/cfoo.c

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// ignore-license
21
#ifdef _WIN32
32
__declspec(dllexport)
43
#endif

src/test/run-make-fulldeps/c-dynamic-rlib/cfoo.c

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// ignore-license
2-
31
#ifdef _WIN32
42
__declspec(dllexport)
53
#endif

src/test/run-make-fulldeps/c-link-to-rust-dylib/bar.c

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// ignore-license
21
void foo();
32

43
int main() {

src/test/run-make-fulldeps/c-link-to-rust-staticlib/bar.c

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// ignore-license
21
void foo();
32

43
int main() {
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
// ignore-license
21
int foo() { return 0; }
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
// ignore-license
21
int foo() { return 0; }

src/test/run-make-fulldeps/compiler-rt-works-on-mingw/foo.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// ignore-license
21
extern "C" void foo() {
32
int *a = new int(3);
43
delete a;

src/test/run-make-fulldeps/extern-fn-generic/test.c

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// ignore-license
21
#include <stdint.h>
32

43
typedef struct TestStruct {

src/test/run-make-fulldeps/extern-fn-mangle/test.c

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// ignore-license
21
#include <stdint.h>
32

43
uint32_t foo();

src/test/run-make-fulldeps/extern-fn-with-extern-types/ctest.c

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// ignore-license
21
#include <stdio.h>
32
#include <stdint.h>
43

src/test/run-make-fulldeps/extern-fn-with-packed-struct/test.c

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

43
#include <assert.h>

src/test/run-make-fulldeps/extern-fn-with-union/ctest.c

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// ignore-license
21
#include <stdio.h>
32
#include <stdint.h>
43

src/test/run-make-fulldeps/glibc-staticlib-args/program.c

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// ignore-license
21
void args_check();
32

43
int main() {
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// ignore-license
21
void foo();
32

43
void bar() { foo(); }
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
// ignore-license
21
void foo() {}

src/test/run-make-fulldeps/issue-25581/test.c

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// ignore-license
21
#include <stddef.h>
32
#include <stdint.h>
43

Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
// ignore-license
21
int should_return_one() { return 1; }
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
// ignore-license
21
int should_return_one() { return 0; }

src/test/run-make-fulldeps/linkage-attr-on-static/foo.c

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// ignore-license
21
#include <stdint.h>
32

43
extern int32_t BAZ;

src/test/run-make-fulldeps/lto-smoke-c/bar.c

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// ignore-license
21
void foo();
32

43
int main() {
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
// ignore-license
21
void bar() {}
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
// ignore-license
21
void bar() {}

src/test/run-make-fulldeps/sanitizer-staticlib-link/program.c

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// ignore-license
21
void overflow();
32

43
int main() {

src/test/ui/attr-shebang.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
#![allow(stable_features)]
44
#![feature(rust1)]
55
pub fn main() { }
6-
// ignore-license

0 commit comments

Comments
 (0)