Skip to content

Commit a08c473

Browse files
committed
Auto merge of #71985 - Dylan-DPC:rollup-9ceqump, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - #71938 (Use trait_object_dummy_self instead of err) - #71952 (Add some regression tests) - #71959 (tests: Fix warnings in `rust_test_helpers.c`) - #71962 (Grammar) - #71972 (use hex for pointers in Miri error messages) - #71980 (Allow a few warnings.) Failed merges: r? @ghost
2 parents 4802f09 + c818e84 commit a08c473

File tree

14 files changed

+134
-18
lines changed

14 files changed

+134
-18
lines changed

src/liballoc/fmt.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
//! The internal iterator over the argument has not been advanced by the time
5151
//! the first `{}` is seen, so it prints the first argument. Then upon reaching
5252
//! the second `{}`, the iterator has advanced forward to the second argument.
53-
//! Essentially, parameters which explicitly name their argument do not affect
54-
//! parameters which do not name an argument in terms of positional specifiers.
53+
//! Essentially, parameters that explicitly name their argument do not affect
54+
//! parameters that do not name an argument in terms of positional specifiers.
5555
//!
5656
//! A format string is required to use all of its arguments, otherwise it is a
5757
//! compile-time error. You may refer to the same argument more than once in the
@@ -60,7 +60,7 @@
6060
//! ## Named parameters
6161
//!
6262
//! Rust itself does not have a Python-like equivalent of named parameters to a
63-
//! function, but the [`format!`] macro is a syntax extension which allows it to
63+
//! function, but the [`format!`] macro is a syntax extension that allows it to
6464
//! leverage named parameters. Named parameters are listed at the end of the
6565
//! argument list and have the syntax:
6666
//!
@@ -77,7 +77,7 @@
7777
//! ```
7878
//!
7979
//! It is not valid to put positional parameters (those without names) after
80-
//! arguments which have names. Like with positional parameters, it is not
80+
//! arguments that have names. Like with positional parameters, it is not
8181
//! valid to provide named parameters that are unused by the format string.
8282
//!
8383
//! # Formatting Parameters
@@ -130,7 +130,7 @@
130130
//!
131131
//! The default [fill/alignment](#fillalignment) for non-numerics is a space and
132132
//! left-aligned. The
133-
//! defaults for numeric formatters is also a space but with right-alignment. If
133+
//! default for numeric formatters is also a space character but with right-alignment. If
134134
//! the `0` flag (see below) is specified for numerics, then the implicit fill character is
135135
//! `0`.
136136
//!
@@ -161,7 +161,7 @@
161161
//! `Signed` trait. This flag indicates that the correct sign (`+` or `-`)
162162
//! should always be printed.
163163
//! * `-` - Currently not used
164-
//! * `#` - This flag is indicates that the "alternate" form of printing should
164+
//! * `#` - This flag indicates that the "alternate" form of printing should
165165
//! be used. The alternate forms are:
166166
//! * `#?` - pretty-print the [`Debug`] formatting
167167
//! * `#x` - precedes the argument with a `0x`
@@ -173,9 +173,9 @@
173173
//! like `{:08}` would yield `00000001` for the integer `1`, while the
174174
//! same format would yield `-0000001` for the integer `-1`. Notice that
175175
//! the negative version has one fewer zero than the positive version.
176-
//! Note that padding zeroes are always placed after the sign (if any)
176+
//! Note that padding zeros are always placed after the sign (if any)
177177
//! and before the digits. When used together with the `#` flag, a similar
178-
//! rule applies: padding zeroes are inserted after the prefix but before
178+
//! rule applies: padding zeros are inserted after the prefix but before
179179
//! the digits. The prefix is included in the total width.
180180
//!
181181
//! ## Precision
@@ -251,7 +251,7 @@
251251
//!
252252
//! In some programming languages, the behavior of string formatting functions
253253
//! depends on the operating system's locale setting. The format functions
254-
//! provided by Rust's standard library do not have any concept of locale, and
254+
//! provided by Rust's standard library do not have any concept of locale and
255255
//! will produce the same results on all systems regardless of user
256256
//! configuration.
257257
//!
@@ -470,7 +470,7 @@
470470
//!
471471
//! ### `format_args!`
472472
//!
473-
//! This is a curious macro which is used to safely pass around
473+
//! This is a curious macro used to safely pass around
474474
//! an opaque object describing the format string. This object
475475
//! does not require any heap allocations to create, and it only
476476
//! references information on the stack. Under the hood, all of
@@ -495,7 +495,7 @@
495495
//! This structure can then be passed to the [`write`] and [`format`] functions
496496
//! inside this module in order to process the format string.
497497
//! The goal of this macro is to even further prevent intermediate allocations
498-
//! when dealing formatting strings.
498+
//! when dealing with formatting strings.
499499
//!
500500
//! For example, a logging library could use the standard formatting syntax, but
501501
//! it would internally pass around this structure until it has been determined

src/librustc_mir/interpret/validity.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,12 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
321321
try_validation!(
322322
self.ecx.read_drop_type_from_vtable(vtable),
323323
self.path,
324-
err_ub!(InvalidDropFn(..)) |
325324
err_ub!(DanglingIntPointer(..)) |
326325
err_ub!(InvalidFunctionPointer(..)) |
327326
err_unsup!(ReadBytesAsPointer) =>
328-
{ "invalid drop function pointer in vtable" },
327+
{ "invalid drop function pointer in vtable (not pointing to a function)" },
328+
err_ub!(InvalidDropFn(..)) =>
329+
{ "invalid drop function pointer in vtable (function has incompatible signature)" },
329330
);
330331
try_validation!(
331332
self.ecx.read_size_and_align_from_vtable(vtable),
@@ -400,7 +401,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
400401
err_ub!(DanglingIntPointer(0, _)) =>
401402
{ "a NULL {}", kind },
402403
err_ub!(DanglingIntPointer(i, _)) =>
403-
{ "a dangling {} (address {} is unallocated)", kind, i },
404+
{ "a dangling {} (address 0x{:x} is unallocated)", kind, i },
404405
err_ub!(PointerOutOfBounds { .. }) =>
405406
{ "a dangling {} (going beyond the bounds of its allocation)", kind },
406407
err_unsup!(ReadBytesAsPointer) =>

src/librustc_typeck/check/closure.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
178178
match expected_ty.kind {
179179
ty::Dynamic(ref object_type, ..) => {
180180
let sig = object_type.projection_bounds().find_map(|pb| {
181-
let pb = pb.with_self_ty(self.tcx, self.tcx.types.err);
181+
let pb = pb.with_self_ty(self.tcx, self.tcx.types.trait_object_dummy_self);
182182
self.deduce_sig_from_projection(None, &pb)
183183
});
184184
let kind = object_type

src/libstd/sys/unix/ext/net.rs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use libc;
77

88
// FIXME(#43348): Make libc adapt #[doc(cfg(...))] so we don't need these fake definitions here?
99
#[cfg(not(unix))]
10+
#[allow(non_camel_case_types)]
1011
mod libc {
1112
pub use libc::c_int;
1213
pub type socklen_t = u32;

src/libstd/sys/unix/ext/raw.rs

+5
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@
1111
#![allow(deprecated)]
1212

1313
#[stable(feature = "raw_ext", since = "1.1.0")]
14+
#[allow(non_camel_case_types)]
1415
pub type uid_t = u32;
16+
1517
#[stable(feature = "raw_ext", since = "1.1.0")]
18+
#[allow(non_camel_case_types)]
1619
pub type gid_t = u32;
20+
1721
#[stable(feature = "raw_ext", since = "1.1.0")]
22+
#[allow(non_camel_case_types)]
1823
pub type pid_t = i32;
1924

2025
#[doc(inline)]

src/test/auxiliary/rust_test_helpers.c

+2
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ rust_dbg_unpack_option_u64(struct U8TaggedEnumOptionU64 o, uint64_t *into) {
368368
return 0;
369369
default:
370370
assert(0 && "unexpected tag");
371+
return 0;
371372
}
372373
}
373374

@@ -411,5 +412,6 @@ rust_dbg_unpack_option_u64u64(struct U8TaggedEnumOptionU64U64 o, uint64_t *a, ui
411412
return 0;
412413
default:
413414
assert(0 && "unexpected tag");
415+
return 0;
414416
}
415417
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Regression test for #29988
2+
3+
// compile-flags: -C no-prepopulate-passes
4+
// only-x86_64
5+
// ignore-windows
6+
7+
#[repr(C)]
8+
struct S {
9+
f1: i32,
10+
f2: i32,
11+
f3: i32,
12+
}
13+
14+
extern {
15+
fn foo(s: S);
16+
}
17+
18+
fn main() {
19+
let s = S { f1: 1, f2: 2, f3: 3 };
20+
unsafe {
21+
// CHECK: load { i64, i32 }, { i64, i32 }* {{.*}}, align 4
22+
// CHECK: call void @foo({ i64, i32 } {{.*}})
23+
foo(s);
24+
}
25+
}

src/test/ui/consts/const-eval/ub-wide-ptr.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -170,23 +170,23 @@ error[E0080]: it is undefined behavior to use this value
170170
--> $DIR/ub-wide-ptr.rs:109:1
171171
|
172172
LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) };
173-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop function pointer in vtable
173+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop function pointer in vtable (not pointing to a function)
174174
|
175175
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
176176

177177
error[E0080]: it is undefined behavior to use this value
178178
--> $DIR/ub-wide-ptr.rs:111:1
179179
|
180180
LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) };
181-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop function pointer in vtable
181+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop function pointer in vtable (not pointing to a function)
182182
|
183183
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
184184

185185
error[E0080]: it is undefined behavior to use this value
186186
--> $DIR/ub-wide-ptr.rs:113:1
187187
|
188188
LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: &dyn Trait = unsafe { mem::transmute((&92u8, &[&42u8; 8])) };
189-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop function pointer in vtable
189+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop function pointer in vtable (not pointing to a function)
190190
|
191191
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
192192

src/test/ui/enum/issue-67945-1.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
enum Bug<S> {
2+
Var = {
3+
let x: S = 0; //~ ERROR: mismatched types
4+
0
5+
},
6+
}
7+
8+
fn main() {}

src/test/ui/enum/issue-67945-1.stderr

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/issue-67945-1.rs:3:20
3+
|
4+
LL | enum Bug<S> {
5+
| - this type parameter
6+
LL | Var = {
7+
LL | let x: S = 0;
8+
| - ^ expected type parameter `S`, found integer
9+
| |
10+
| expected due to this
11+
|
12+
= note: expected type parameter `S`
13+
found type `{integer}`
14+
15+
error: aborting due to previous error
16+
17+
For more information about this error, try `rustc --explain E0308`.

src/test/ui/enum/issue-67945-2.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![feature(type_ascription)]
2+
3+
enum Bug<S> {
4+
Var = 0: S,
5+
//~^ ERROR: mismatched types
6+
//~| ERROR: mismatched types
7+
}
8+
9+
fn main() {}

src/test/ui/enum/issue-67945-2.stderr

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/issue-67945-2.rs:4:11
3+
|
4+
LL | enum Bug<S> {
5+
| - this type parameter
6+
LL | Var = 0: S,
7+
| ^ expected type parameter `S`, found integer
8+
|
9+
= note: expected type parameter `S`
10+
found type `{integer}`
11+
12+
error[E0308]: mismatched types
13+
--> $DIR/issue-67945-2.rs:4:11
14+
|
15+
LL | enum Bug<S> {
16+
| - this type parameter
17+
LL | Var = 0: S,
18+
| ^^^^ expected `isize`, found type parameter `S`
19+
|
20+
= note: expected type `isize`
21+
found type parameter `S`
22+
23+
error: aborting due to 2 previous errors
24+
25+
For more information about this error, try `rustc --explain E0308`.

src/test/ui/lifetimes/issue-34979.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
trait Foo {}
2+
impl<'a, T> Foo for &'a T {}
3+
4+
struct Ctx<'a>(&'a ())
5+
where
6+
&'a (): Foo, //~ ERROR: type annotations needed
7+
&'static (): Foo;
8+
9+
fn main() {}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0283]: type annotations needed
2+
--> $DIR/issue-34979.rs:6:13
3+
|
4+
LL | trait Foo {}
5+
| --------- required by this bound in `Foo`
6+
...
7+
LL | &'a (): Foo,
8+
| ^^^ cannot infer type for reference `&'a ()`
9+
|
10+
= note: cannot satisfy `&'a (): Foo`
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0283`.

0 commit comments

Comments
 (0)