Skip to content

Commit beac68a

Browse files
committed
Auto merge of #69612 - Dylan-DPC:rollup-f180gcc, r=Dylan-DPC
Rollup of 7 pull requests Successful merges: - #69504 (Use assert_ne in hash tests) - #69554 (Cleanup e0374) - #69568 (Clarify explanation of Vec<T> 'fn resize') - #69569 (simplify boolean expressions) - #69577 (Clean up E0375 explanation) - #69598 (rustdoc: HTML escape crate version) - #69607 (Clean up E0376 explanation) Failed merges: r? @ghost
2 parents 360e42d + d3a5a5d commit beac68a

File tree

15 files changed

+55
-42
lines changed

15 files changed

+55
-42
lines changed

src/liballoc/collections/binary_heap.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ impl<T: Ord> BinaryHeap<T> {
536536
while child < end {
537537
let right = child + 1;
538538
// compare with the greater of the two children
539-
if right < end && !(hole.get(child) > hole.get(right)) {
539+
if right < end && hole.get(child) <= hole.get(right) {
540540
child = right;
541541
}
542542
// if we are already in order, stop.
@@ -568,7 +568,7 @@ impl<T: Ord> BinaryHeap<T> {
568568
while child < end {
569569
let right = child + 1;
570570
// compare with the greater of the two children
571-
if right < end && !(hole.get(child) > hole.get(right)) {
571+
if right < end && hole.get(child) <= hole.get(right) {
572572
child = right;
573573
}
574574
hole.move_to(child);

src/liballoc/vec.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1476,8 +1476,9 @@ impl<T: Clone> Vec<T> {
14761476
/// difference, with each additional slot filled with `value`.
14771477
/// If `new_len` is less than `len`, the `Vec` is simply truncated.
14781478
///
1479-
/// This method requires [`Clone`] to be able clone the passed value. If
1480-
/// you need more flexibility (or want to rely on [`Default`] instead of
1479+
/// This method requires `T` to implement [`Clone`],
1480+
/// in order to be able to clone the passed value.
1481+
/// If you need more flexibility (or want to rely on [`Default`] instead of
14811482
/// [`Clone`]), use [`resize_with`].
14821483
///
14831484
/// # Examples

src/libcore/tests/hash/sip.rs

-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@ fn test_hash_no_concat_alias() {
298298
let t = ("aabb", "");
299299
let u = ("a", "abb");
300300

301-
assert!(s != t && t != u);
302301
assert_ne!(s, t);
303302
assert_ne!(t, u);
304303
assert_ne!(hash(&s), hash(&t));

src/librustc_codegen_llvm/debuginfo/metadata.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2135,7 +2135,7 @@ fn set_members_of_composite_type(
21352135
/// Computes the type parameters for a type, if any, for the given metadata.
21362136
fn compute_type_parameters(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>) -> Option<&'ll DIArray> {
21372137
if let ty::Adt(def, substs) = ty.kind {
2138-
if !substs.types().next().is_none() {
2138+
if substs.types().next().is_some() {
21392139
let generics = cx.tcx.generics_of(def.did);
21402140
let names = get_parameter_names(cx, generics);
21412141
let template_params: Vec<_> = substs

src/librustc_codegen_ssa/mir/debuginfo.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub struct DebugScope<D> {
4848

4949
impl<D> DebugScope<D> {
5050
pub fn is_valid(&self) -> bool {
51-
!self.scope_metadata.is_none()
51+
self.scope_metadata.is_some()
5252
}
5353
}
5454

@@ -304,7 +304,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
304304
) -> Option<IndexVec<mir::Local, Vec<PerLocalVarDebugInfo<'tcx, Bx::DIVariable>>>> {
305305
let full_debug_info = self.cx.sess().opts.debuginfo == DebugInfo::Full;
306306

307-
if !(full_debug_info || !self.cx.sess().fewer_names()) {
307+
if !full_debug_info && self.cx.sess().fewer_names() {
308308
return None;
309309
}
310310

src/librustc_error_codes/error_codes/E0374.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
A struct without a field containing an unsized type cannot implement
2-
`CoerceUnsized`. An [unsized type][1] is any type that the compiler
3-
doesn't know the length or alignment of at compile time. Any struct
4-
containing an unsized type is also unsized.
5-
6-
[1]: https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait
1+
`CoerceUnsized` was implemented on a struct which does not contain a field with
2+
an unsized type.
73

84
Example of erroneous code:
95

@@ -20,6 +16,12 @@ impl<T, U> CoerceUnsized<Foo<U>> for Foo<T>
2016
where T: CoerceUnsized<U> {}
2117
```
2218

19+
An [unsized type][1] is any type where the compiler does not know the length or
20+
alignment of at compile time. Any struct containing an unsized type is also
21+
unsized.
22+
23+
[1]: https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait
24+
2325
`CoerceUnsized` is used to coerce one struct containing an unsized type
2426
into another struct containing a different unsized type. If the struct
2527
doesn't have any fields of unsized types then you don't need explicit

src/librustc_error_codes/error_codes/E0375.md

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
A struct with more than one field containing an unsized type cannot implement
2-
`CoerceUnsized`. This only occurs when you are trying to coerce one of the
3-
types in your struct to another type in the struct. In this case we try to
4-
impl `CoerceUnsized` from `T` to `U` which are both types that the struct
5-
takes. An [unsized type][1] is any type that the compiler doesn't know the
6-
length or alignment of at compile time. Any struct containing an unsized type
7-
is also unsized.
1+
`CoerceUnsized` was implemented on a struct which contains more than one field
2+
with an unsized type.
83

9-
Example of erroneous code:
4+
Erroneous code example:
105

116
```compile_fail,E0375
127
#![feature(coerce_unsized)]
@@ -22,6 +17,14 @@ struct Foo<T: ?Sized, U: ?Sized> {
2217
impl<T, U> CoerceUnsized<Foo<U, T>> for Foo<T, U> {}
2318
```
2419

20+
A struct with more than one field containing an unsized type cannot implement
21+
`CoerceUnsized`. This only occurs when you are trying to coerce one of the
22+
types in your struct to another type in the struct. In this case we try to
23+
impl `CoerceUnsized` from `T` to `U` which are both types that the struct
24+
takes. An [unsized type][1] is any type that the compiler doesn't know the
25+
length or alignment of at compile time. Any struct containing an unsized type
26+
is also unsized.
27+
2528
`CoerceUnsized` only allows for coercion from a structure with a single
2629
unsized type field to another struct with a single unsized type field.
2730
In fact Rust only allows for a struct to have one unsized type in a struct

src/librustc_error_codes/error_codes/E0376.md

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
1-
The type you are trying to impl `CoerceUnsized` for is not a struct.
2-
`CoerceUnsized` can only be implemented for a struct. Unsized types are
3-
already able to be coerced without an implementation of `CoerceUnsized`
4-
whereas a struct containing an unsized type needs to know the unsized type
5-
field it's containing is able to be coerced. An [unsized type][1]
6-
is any type that the compiler doesn't know the length or alignment of at
7-
compile time. Any struct containing an unsized type is also unsized.
8-
9-
[1]: https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait
1+
`CoerceUnsized` was implemented on something that isn't a struct.
102

11-
Example of erroneous code:
3+
Erroneous code example:
124

135
```compile_fail,E0376
146
#![feature(coerce_unsized)]
@@ -22,6 +14,15 @@ struct Foo<T: ?Sized> {
2214
impl<T, U> CoerceUnsized<U> for Foo<T> {}
2315
```
2416

17+
`CoerceUnsized` can only be implemented for a struct. Unsized types are
18+
already able to be coerced without an implementation of `CoerceUnsized`
19+
whereas a struct containing an unsized type needs to know the unsized type
20+
field it's containing is able to be coerced. An [unsized type][1]
21+
is any type that the compiler doesn't know the length or alignment of at
22+
compile time. Any struct containing an unsized type is also unsized.
23+
24+
[1]: https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait
25+
2526
The `CoerceUnsized` trait takes a struct type. Make sure the type you are
2627
providing to `CoerceUnsized` is a struct with only the last field containing an
2728
unsized type.

src/librustc_infer/infer/freshen.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
143143
}
144144

145145
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
146-
if !t.needs_infer()
147-
&& !t.has_erasable_regions()
148-
&& !(t.has_closure_types() && self.infcx.in_progress_tables.is_some())
146+
if !(t.needs_infer()
147+
|| t.has_erasable_regions()
148+
|| (t.has_closure_types() && self.infcx.in_progress_tables.is_some()))
149149
{
150150
return t;
151151
}

src/librustc_infer/infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
14841484

14851485
// Even if the type may have no inference variables, during
14861486
// type-checking closure types are in local tables only.
1487-
if !self.in_progress_tables.is_some() || !ty.has_closure_types() {
1487+
if self.in_progress_tables.is_none() || !ty.has_closure_types() {
14881488
if !(param_env, ty).has_local_value() {
14891489
return ty.is_copy_modulo_regions(self.tcx, param_env, span);
14901490
}

src/librustc_passes/stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ impl Visitor<'tcx> for Checker<'tcx> {
551551
.emit();
552552
} else {
553553
let param_env = self.tcx.param_env(def_id);
554-
if !can_type_implement_copy(self.tcx, param_env, ty).is_ok() {
554+
if can_type_implement_copy(self.tcx, param_env, ty).is_err() {
555555
feature_err(
556556
&self.tcx.sess.parse_sess,
557557
sym::untagged_unions,

src/librustc_resolve/imports.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,9 @@ impl<'a> Resolver<'a> {
313313
}
314314
}
315315

316-
if !self.is_accessible_from(binding.vis, parent_scope.module) &&
316+
if !(self.is_accessible_from(binding.vis, parent_scope.module) ||
317317
// Remove this together with `PUB_USE_OF_PRIVATE_EXTERN_CRATE`
318-
!(self.last_import_segment && binding.is_extern_crate())
318+
(self.last_import_segment && binding.is_extern_crate()))
319319
{
320320
self.privacy_errors.push(PrivacyError {
321321
ident,

src/librustdoc/html/render.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,8 @@ impl Context {
13131313
<p>Version {}</p>\
13141314
</div>\
13151315
<a id='all-types' href='index.html'><p>Back to index</p></a>",
1316-
crate_name, version
1316+
crate_name,
1317+
Escape(version),
13171318
)
13181319
} else {
13191320
String::new()
@@ -3974,7 +3975,7 @@ fn print_sidebar(cx: &Context, it: &clean::Item, buffer: &mut Buffer) {
39743975
"<div class='block version'>\
39753976
<p>Version {}</p>\
39763977
</div>",
3977-
version
3978+
Escape(version)
39783979
);
39793980
}
39803981
}

src/libstd/net/parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ impl<'a> Parser<'a> {
206206
}
207207

208208
// read `::` if previous code parsed less than 8 groups
209-
if !self.read_given_char(':').is_some() || !self.read_given_char(':').is_some() {
209+
if self.read_given_char(':').is_none() || self.read_given_char(':').is_none() {
210210
return None;
211211
}
212212

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// compile-flags: --crate-version=<script>alert("hi")</script> -Z unstable-options
2+
3+
#![crate_name = "foo"]
4+
5+
// @has 'foo/index.html' '//div[@class="block version"]/p' 'Version <script>alert("hi")</script>'
6+
// @has 'foo/all.html' '//div[@class="block version"]/p' 'Version <script>alert("hi")</script>'

0 commit comments

Comments
 (0)