Auto merge of #67246 - JohnTitor:rollup-nfa7skn, r=JohnTitor
Rollup of 8 pull requests Successful merges: - #62514 (Clarify `Box<T>` representation and its use in FFI) - #66983 (Fix `unused_parens` triggers on macro by example code) - #67215 (Fix `-Z print-type-sizes`'s handling of zero-sized fields.) - #67230 (Remove irelevant comment on `register_dtor`) - #67236 (resolve: Always resolve visibilities on impl items) - #67237 (Some small readability improvements) - #67238 (Small std::borrow::Cow improvements) - #67239 (Make TinyList::remove iterate instead of recurse) Failed merges: r? @ghost
This commit is contained in:
commit
f284f8b4be
18 changed files with 220 additions and 100 deletions
|
|
@ -17,10 +17,7 @@ macro_rules! the_worship_the_heart_lifts_above {
|
|||
|
||||
macro_rules! and_the_heavens_reject_not {
|
||||
() => {
|
||||
// ↓ But let's test that we still lint for unused parens around
|
||||
// function args inside of simple, one-deep macros.
|
||||
#[allow(dead_code)] fn the_night_for_the_morrow() -> Option<isize> { Some((2)) }
|
||||
//~^ WARN unnecessary parentheses around function argument
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
warning: unnecessary parentheses around function argument
|
||||
--> $DIR/issue-47775-nested-macro-unnecessary-parens-arg.rs:22:83
|
||||
|
|
||||
LL | #[allow(dead_code)] fn the_night_for_the_morrow() -> Option<isize> { Some((2)) }
|
||||
| ^^^ help: remove these parentheses
|
||||
...
|
||||
LL | and_the_heavens_reject_not!();
|
||||
| ------------------------------ in this macro invocation
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/issue-47775-nested-macro-unnecessary-parens-arg.rs:3:9
|
||||
|
|
||||
LL | #![warn(unused_parens)]
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
|
|
@ -25,6 +25,12 @@ fn passes_unused_parens_lint() -> &'static (dyn Trait) {
|
|||
panic!()
|
||||
}
|
||||
|
||||
macro_rules! baz {
|
||||
($($foo:expr),+) => {
|
||||
($($foo),*)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
foo();
|
||||
bar((true)); //~ ERROR unnecessary parentheses around function argument
|
||||
|
|
@ -55,4 +61,7 @@ fn main() {
|
|||
let mut _a = (0); //~ ERROR unnecessary parentheses around assigned value
|
||||
_a = (0); //~ ERROR unnecessary parentheses around assigned value
|
||||
_a += (1); //~ ERROR unnecessary parentheses around assigned value
|
||||
|
||||
let _a = baz!(3, 4);
|
||||
let _b = baz!(3);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,25 +23,25 @@ LL | fn unused_parens_around_return_type() -> (u32) {
|
|||
| ^^^^^ help: remove these parentheses
|
||||
|
||||
error: unnecessary parentheses around function argument
|
||||
--> $DIR/lint-unnecessary-parens.rs:30:9
|
||||
--> $DIR/lint-unnecessary-parens.rs:36:9
|
||||
|
|
||||
LL | bar((true));
|
||||
| ^^^^^^ help: remove these parentheses
|
||||
|
||||
error: unnecessary parentheses around `if` condition
|
||||
--> $DIR/lint-unnecessary-parens.rs:32:8
|
||||
--> $DIR/lint-unnecessary-parens.rs:38:8
|
||||
|
|
||||
LL | if (true) {}
|
||||
| ^^^^^^ help: remove these parentheses
|
||||
|
||||
error: unnecessary parentheses around `while` condition
|
||||
--> $DIR/lint-unnecessary-parens.rs:33:11
|
||||
--> $DIR/lint-unnecessary-parens.rs:39:11
|
||||
|
|
||||
LL | while (true) {}
|
||||
| ^^^^^^ help: remove these parentheses
|
||||
|
||||
warning: denote infinite loops with `loop { ... }`
|
||||
--> $DIR/lint-unnecessary-parens.rs:33:5
|
||||
--> $DIR/lint-unnecessary-parens.rs:39:5
|
||||
|
|
||||
LL | while (true) {}
|
||||
| ^^^^^^^^^^^^ help: use `loop`
|
||||
|
|
@ -49,43 +49,43 @@ LL | while (true) {}
|
|||
= note: `#[warn(while_true)]` on by default
|
||||
|
||||
error: unnecessary parentheses around `match` head expression
|
||||
--> $DIR/lint-unnecessary-parens.rs:35:11
|
||||
--> $DIR/lint-unnecessary-parens.rs:41:11
|
||||
|
|
||||
LL | match (true) {
|
||||
| ^^^^^^ help: remove these parentheses
|
||||
|
||||
error: unnecessary parentheses around `let` head expression
|
||||
--> $DIR/lint-unnecessary-parens.rs:38:16
|
||||
--> $DIR/lint-unnecessary-parens.rs:44:16
|
||||
|
|
||||
LL | if let 1 = (1) {}
|
||||
| ^^^ help: remove these parentheses
|
||||
|
||||
error: unnecessary parentheses around `let` head expression
|
||||
--> $DIR/lint-unnecessary-parens.rs:39:19
|
||||
--> $DIR/lint-unnecessary-parens.rs:45:19
|
||||
|
|
||||
LL | while let 1 = (2) {}
|
||||
| ^^^ help: remove these parentheses
|
||||
|
||||
error: unnecessary parentheses around method argument
|
||||
--> $DIR/lint-unnecessary-parens.rs:53:24
|
||||
--> $DIR/lint-unnecessary-parens.rs:59:24
|
||||
|
|
||||
LL | X { y: false }.foo((true));
|
||||
| ^^^^^^ help: remove these parentheses
|
||||
|
||||
error: unnecessary parentheses around assigned value
|
||||
--> $DIR/lint-unnecessary-parens.rs:55:18
|
||||
--> $DIR/lint-unnecessary-parens.rs:61:18
|
||||
|
|
||||
LL | let mut _a = (0);
|
||||
| ^^^ help: remove these parentheses
|
||||
|
||||
error: unnecessary parentheses around assigned value
|
||||
--> $DIR/lint-unnecessary-parens.rs:56:10
|
||||
--> $DIR/lint-unnecessary-parens.rs:62:10
|
||||
|
|
||||
LL | _a = (0);
|
||||
| ^^^ help: remove these parentheses
|
||||
|
||||
error: unnecessary parentheses around assigned value
|
||||
--> $DIR/lint-unnecessary-parens.rs:57:11
|
||||
--> $DIR/lint-unnecessary-parens.rs:63:11
|
||||
|
|
||||
LL | _a += (1);
|
||||
| ^^^ help: remove these parentheses
|
||||
|
|
|
|||
46
src/test/ui/print_type_sizes/zero-sized-fields.rs
Normal file
46
src/test/ui/print_type_sizes/zero-sized-fields.rs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
// compile-flags: -Z print-type-sizes
|
||||
// build-pass (FIXME(62277): could be check-pass?)
|
||||
|
||||
// At one point, zero-sized fields such as those in this file were causing
|
||||
// incorrect output from `-Z print-type-sizes`.
|
||||
|
||||
#![feature(start)]
|
||||
|
||||
struct S1 {
|
||||
x: u32,
|
||||
y: u32,
|
||||
tag: (),
|
||||
}
|
||||
|
||||
struct Void();
|
||||
struct Empty {}
|
||||
|
||||
struct S5<TagW, TagZ> {
|
||||
tagw: TagW,
|
||||
w: u32,
|
||||
unit: (),
|
||||
x: u32,
|
||||
void: Void,
|
||||
y: u32,
|
||||
empty: Empty,
|
||||
z: u32,
|
||||
tagz: TagZ,
|
||||
}
|
||||
|
||||
#[start]
|
||||
fn start(_: isize, _: *const *const u8) -> isize {
|
||||
let _s1: S1 = S1 { x: 0, y: 0, tag: () };
|
||||
|
||||
let _s5: S5<(), Empty> = S5 {
|
||||
tagw: (),
|
||||
w: 1,
|
||||
unit: (),
|
||||
x: 2,
|
||||
void: Void(),
|
||||
y: 3,
|
||||
empty: Empty {},
|
||||
z: 4,
|
||||
tagz: Empty {},
|
||||
};
|
||||
0
|
||||
}
|
||||
16
src/test/ui/print_type_sizes/zero-sized-fields.stdout
Normal file
16
src/test/ui/print_type_sizes/zero-sized-fields.stdout
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
print-type-size type: `S5<(), Empty>`: 16 bytes, alignment: 4 bytes
|
||||
print-type-size field `.tagw`: 0 bytes
|
||||
print-type-size field `.unit`: 0 bytes
|
||||
print-type-size field `.void`: 0 bytes
|
||||
print-type-size field `.empty`: 0 bytes
|
||||
print-type-size field `.tagz`: 0 bytes
|
||||
print-type-size field `.w`: 4 bytes
|
||||
print-type-size field `.x`: 4 bytes
|
||||
print-type-size field `.y`: 4 bytes
|
||||
print-type-size field `.z`: 4 bytes
|
||||
print-type-size type: `S1`: 8 bytes, alignment: 4 bytes
|
||||
print-type-size field `.tag`: 0 bytes
|
||||
print-type-size field `.x`: 4 bytes
|
||||
print-type-size field `.y`: 4 bytes
|
||||
print-type-size type: `Empty`: 0 bytes, alignment: 1 bytes
|
||||
print-type-size type: `Void`: 0 bytes, alignment: 1 bytes
|
||||
25
src/test/ui/resolve/impl-items-vis-unresolved.rs
Normal file
25
src/test/ui/resolve/impl-items-vis-unresolved.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// Visibilities on impl items expanded from macros are resolved (issue #64705).
|
||||
|
||||
macro_rules! perftools_inline {
|
||||
($($item:tt)*) => (
|
||||
$($item)*
|
||||
);
|
||||
}
|
||||
|
||||
mod state {
|
||||
pub struct RawFloatState;
|
||||
impl RawFloatState {
|
||||
perftools_inline! {
|
||||
pub(super) fn new() {} // OK
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct RawFloatState;
|
||||
impl RawFloatState {
|
||||
perftools_inline! {
|
||||
pub(super) fn new() {} //~ ERROR failed to resolve: there are too many initial `super`s
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
9
src/test/ui/resolve/impl-items-vis-unresolved.stderr
Normal file
9
src/test/ui/resolve/impl-items-vis-unresolved.stderr
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
error[E0433]: failed to resolve: there are too many initial `super`s.
|
||||
--> $DIR/impl-items-vis-unresolved.rs:21:13
|
||||
|
|
||||
LL | pub(super) fn new() {}
|
||||
| ^^^^^ there are too many initial `super`s.
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0433`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue