diff --git a/library/alloc/src/borrow.rs b/library/alloc/src/borrow.rs index 4659fb2a8426d..d2ab5412eeabc 100644 --- a/library/alloc/src/borrow.rs +++ b/library/alloc/src/borrow.rs @@ -16,12 +16,13 @@ use crate::fmt; #[cfg(not(no_global_oom_handling))] use crate::string::String; +// FIXME(inference): const bounds removed due to inference regressions found by crater; +// see https://github.com/rust-lang/rust/issues/147964 +// #[rustc_const_unstable(feature = "const_convert", issue = "143773")] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_unstable(feature = "const_convert", issue = "143773")] -impl<'a, B: ?Sized> const Borrow for Cow<'a, B> -where - B: ToOwned, - B::Owned: [const] Borrow, +impl<'a, B: ?Sized + ToOwned> Borrow for Cow<'a, B> +// where +// B::Owned: [const] Borrow, { fn borrow(&self) -> &B { &**self @@ -327,11 +328,13 @@ impl Cow<'_, B> { } } +// FIXME(inference): const bounds removed due to inference regressions found by crater; +// see https://github.com/rust-lang/rust/issues/147964 +// #[rustc_const_unstable(feature = "const_convert", issue = "143773")] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_unstable(feature = "const_convert", issue = "143773")] -impl const Deref for Cow<'_, B> -where - B::Owned: [const] Borrow, +impl Deref for Cow<'_, B> +// where +// B::Owned: [const] Borrow, { type Target = B; diff --git a/tests/ui/frontmatter/space-in-infostring.rs b/tests/ui/frontmatter/space-in-infostring.rs new file mode 100644 index 0000000000000..a8448af113443 --- /dev/null +++ b/tests/ui/frontmatter/space-in-infostring.rs @@ -0,0 +1,9 @@ +--- cargo clippy +//~^ ERROR: invalid infostring for frontmatter +--- + +// infostrings cannot have spaces + +#![feature(frontmatter)] + +fn main() {} diff --git a/tests/ui/frontmatter/space-in-infostring.stderr b/tests/ui/frontmatter/space-in-infostring.stderr new file mode 100644 index 0000000000000..b876ddae782e9 --- /dev/null +++ b/tests/ui/frontmatter/space-in-infostring.stderr @@ -0,0 +1,10 @@ +error: invalid infostring for frontmatter + --> $DIR/space-in-infostring.rs:1:4 + | +LL | --- cargo clippy + | ^^^^^^^^^^^^^ + | + = note: frontmatter infostrings must be a single identifier immediately following the opening + +error: aborting due to 1 previous error + diff --git a/tests/ui/traits/generic-cow-inference-regression.rs b/tests/ui/traits/generic-cow-inference-regression.rs new file mode 100644 index 0000000000000..6fd4715f85bbd --- /dev/null +++ b/tests/ui/traits/generic-cow-inference-regression.rs @@ -0,0 +1,20 @@ +//@ run-pass + +// regression test for #147964: +// constification of these traits resulted in inference errors due to additional where clauses + +use std::borrow::{Cow, Borrow}; + +pub fn generic_deref<'a, T: ToOwned, U>(cow: Cow<'a, T>) { + let _: &T = &cow; +} + +pub fn generic_borrow<'a, T: ToOwned, U>(cow: Cow<'a, T>) { + let _: &T = cow.borrow(); +} + +pub fn generic_as_ref<'a, T: ToOwned, U>(cow: Cow<'a, T>) { + let _: &T = cow.as_ref(); +} + +fn main() {} diff --git a/triagebot.toml b/triagebot.toml index fbe29dd182452..a0d0b1892e4fe 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -1370,6 +1370,7 @@ compiler = [ "@jackh726", "@jieyouxu", "@jdonszelmann", + "@JonathanBrouwer", "@lcnr", "@madsmtm", "@Nadrieril",