Skip to content

Commit 80d46c5

Browse files
committed
Auto merge of #148055 - Zalathar:rollup-7y9yo35, r=Zalathar
Rollup of 3 pull requests Successful merges: - #148016 (Revert constification of `Borrow` and `Deref for Cow` due to inference failure) - #148039 (Add myself to the review rotation) - #148042 (test(frontmatter): Cover spaces between infostring parts) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 27050c0 + f4cb48c commit 80d46c5

File tree

5 files changed

+52
-9
lines changed

5 files changed

+52
-9
lines changed

library/alloc/src/borrow.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ use crate::fmt;
1616
#[cfg(not(no_global_oom_handling))]
1717
use crate::string::String;
1818

19+
// FIXME(inference): const bounds removed due to inference regressions found by crater;
20+
// see https://github.com/rust-lang/rust/issues/147964
21+
// #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
1922
#[stable(feature = "rust1", since = "1.0.0")]
20-
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
21-
impl<'a, B: ?Sized> const Borrow<B> for Cow<'a, B>
22-
where
23-
B: ToOwned,
24-
B::Owned: [const] Borrow<B>,
23+
impl<'a, B: ?Sized + ToOwned> Borrow<B> for Cow<'a, B>
24+
// where
25+
// B::Owned: [const] Borrow<B>,
2526
{
2627
fn borrow(&self) -> &B {
2728
&**self
@@ -327,11 +328,13 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
327328
}
328329
}
329330

331+
// FIXME(inference): const bounds removed due to inference regressions found by crater;
332+
// see https://github.com/rust-lang/rust/issues/147964
333+
// #[rustc_const_unstable(feature = "const_convert", issue = "143773")]
330334
#[stable(feature = "rust1", since = "1.0.0")]
331-
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
332-
impl<B: ?Sized + ToOwned> const Deref for Cow<'_, B>
333-
where
334-
B::Owned: [const] Borrow<B>,
335+
impl<B: ?Sized + ToOwned> Deref for Cow<'_, B>
336+
// where
337+
// B::Owned: [const] Borrow<B>,
335338
{
336339
type Target = B;
337340

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--- cargo clippy
2+
//~^ ERROR: invalid infostring for frontmatter
3+
---
4+
5+
// infostrings cannot have spaces
6+
7+
#![feature(frontmatter)]
8+
9+
fn main() {}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: invalid infostring for frontmatter
2+
--> $DIR/space-in-infostring.rs:1:4
3+
|
4+
LL | --- cargo clippy
5+
| ^^^^^^^^^^^^^
6+
|
7+
= note: frontmatter infostrings must be a single identifier immediately following the opening
8+
9+
error: aborting due to 1 previous error
10+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//@ run-pass
2+
3+
// regression test for #147964:
4+
// constification of these traits resulted in inference errors due to additional where clauses
5+
6+
use std::borrow::{Cow, Borrow};
7+
8+
pub fn generic_deref<'a, T: ToOwned<Owned = U>, U>(cow: Cow<'a, T>) {
9+
let _: &T = &cow;
10+
}
11+
12+
pub fn generic_borrow<'a, T: ToOwned<Owned = U>, U>(cow: Cow<'a, T>) {
13+
let _: &T = cow.borrow();
14+
}
15+
16+
pub fn generic_as_ref<'a, T: ToOwned<Owned = U>, U>(cow: Cow<'a, T>) {
17+
let _: &T = cow.as_ref();
18+
}
19+
20+
fn main() {}

triagebot.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,6 +1370,7 @@ compiler = [
13701370
"@jackh726",
13711371
"@jieyouxu",
13721372
"@jdonszelmann",
1373+
"@JonathanBrouwer",
13731374
"@lcnr",
13741375
"@madsmtm",
13751376
"@Nadrieril",

0 commit comments

Comments
 (0)