Auto merge of #147284 - cuviper:beta-next, r=cuviper
[beta] backports - remove incorrect fast path rust-lang/rust#146919 - Fix infinite recursion in Path::eq with String rust-lang/rust#146958 - Make #[link="dl"] an FCW rather than an error rust-lang/rust#147262 r? cuviper
This commit is contained in:
commit
21cd82aa63
12 changed files with 134 additions and 59 deletions
|
|
@ -65,10 +65,22 @@ impl<S: Stage> CombineAttributeParser<S> for LinkParser {
|
|||
cx: &'c mut AcceptContext<'_, '_, S>,
|
||||
args: &'c ArgParser<'_>,
|
||||
) -> impl IntoIterator<Item = Self::Item> + 'c {
|
||||
let mut result = None;
|
||||
let Some(items) = args.list() else {
|
||||
cx.expected_list(cx.attr_span);
|
||||
return result;
|
||||
let items = match args {
|
||||
ArgParser::List(list) => list,
|
||||
// This is an edgecase added because making this a hard error would break too many crates
|
||||
// Specifically `#[link = "dl"]` is accepted with a FCW
|
||||
// For more information, see https://github.com/rust-lang/rust/pull/143193
|
||||
ArgParser::NameValue(nv) if nv.value_as_str().is_some_and(|v| v == sym::dl) => {
|
||||
let suggestions = <Self as CombineAttributeParser<S>>::TEMPLATE
|
||||
.suggestions(cx.attr_style, "link");
|
||||
let span = cx.attr_span;
|
||||
cx.emit_lint(AttributeLintKind::IllFormedAttributeInput { suggestions }, span);
|
||||
return None;
|
||||
}
|
||||
_ => {
|
||||
cx.expected_list(cx.attr_span);
|
||||
return None;
|
||||
}
|
||||
};
|
||||
|
||||
let sess = cx.sess();
|
||||
|
|
@ -113,7 +125,7 @@ impl<S: Stage> CombineAttributeParser<S> for LinkParser {
|
|||
}
|
||||
};
|
||||
if !cont {
|
||||
return result;
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -202,7 +214,7 @@ impl<S: Stage> CombineAttributeParser<S> for LinkParser {
|
|||
}
|
||||
let Some((name, name_span)) = name else {
|
||||
cx.emit_err(LinkRequiresName { span: cx.attr_span });
|
||||
return result;
|
||||
return None;
|
||||
};
|
||||
|
||||
// Do this outside of the loop so that `import_name_type` can be specified before `kind`.
|
||||
|
|
@ -218,15 +230,14 @@ impl<S: Stage> CombineAttributeParser<S> for LinkParser {
|
|||
cx.emit_err(RawDylibNoNul { span: name_span });
|
||||
}
|
||||
|
||||
result = Some(LinkEntry {
|
||||
Some(LinkEntry {
|
||||
span: cx.attr_span,
|
||||
kind: kind.unwrap_or(NativeLibKind::Unspecified),
|
||||
name,
|
||||
cfg,
|
||||
verbatim,
|
||||
import_name_type,
|
||||
});
|
||||
result
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -871,6 +871,7 @@ symbols! {
|
|||
div,
|
||||
div_assign,
|
||||
diverging_block_default,
|
||||
dl,
|
||||
do_not_recommend,
|
||||
doc,
|
||||
doc_alias,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use rustc_middle::infer::canonical::{
|
|||
Canonical, CanonicalQueryInput, CanonicalQueryResponse, QueryResponse,
|
||||
};
|
||||
use rustc_middle::traits::query::NoSolution;
|
||||
use rustc_middle::ty::{self, GenericArg, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, Upcast};
|
||||
use rustc_middle::ty::{self, GenericArg, Ty, TyCtxt, TypeFoldable, Upcast};
|
||||
use rustc_span::DUMMY_SP;
|
||||
use tracing::instrument;
|
||||
|
||||
|
|
@ -31,19 +31,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
|
||||
fn type_is_copy_modulo_regions(&self, param_env: ty::ParamEnv<'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
let ty = self.resolve_vars_if_possible(ty);
|
||||
|
||||
// FIXME(#132279): This should be removed as it causes us to incorrectly
|
||||
// handle opaques in their defining scope, and stalled coroutines.
|
||||
if !self.next_trait_solver() && !(param_env, ty).has_infer() && !ty.has_coroutines() {
|
||||
return self.tcx.type_is_copy_modulo_regions(self.typing_env(param_env), ty);
|
||||
}
|
||||
|
||||
let copy_def_id = self.tcx.require_lang_item(LangItem::Copy, DUMMY_SP);
|
||||
|
||||
// This can get called from typeck (by euv), and `moves_by_default`
|
||||
// rightly refuses to work with inference variables, but
|
||||
// moves_by_default has a cache, which we want to use in other
|
||||
// cases.
|
||||
traits::type_known_to_meet_bound_modulo_regions(self, param_env, ty, copy_def_id)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2107,7 +2107,7 @@ impl PartialEq for PathBuf {
|
|||
impl cmp::PartialEq<str> for PathBuf {
|
||||
#[inline]
|
||||
fn eq(&self, other: &str) -> bool {
|
||||
Path::eq(self, other)
|
||||
self.as_path() == other
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2115,7 +2115,7 @@ impl cmp::PartialEq<str> for PathBuf {
|
|||
impl cmp::PartialEq<PathBuf> for str {
|
||||
#[inline]
|
||||
fn eq(&self, other: &PathBuf) -> bool {
|
||||
other == self
|
||||
self == other.as_path()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2123,7 +2123,7 @@ impl cmp::PartialEq<PathBuf> for str {
|
|||
impl cmp::PartialEq<String> for PathBuf {
|
||||
#[inline]
|
||||
fn eq(&self, other: &String) -> bool {
|
||||
**self == **other
|
||||
self.as_path() == other.as_str()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2131,7 +2131,7 @@ impl cmp::PartialEq<String> for PathBuf {
|
|||
impl cmp::PartialEq<PathBuf> for String {
|
||||
#[inline]
|
||||
fn eq(&self, other: &PathBuf) -> bool {
|
||||
other == self
|
||||
self.as_str() == other.as_path()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3426,7 +3426,7 @@ impl cmp::PartialEq<Path> for str {
|
|||
impl cmp::PartialEq<String> for Path {
|
||||
#[inline]
|
||||
fn eq(&self, other: &String) -> bool {
|
||||
self == &*other
|
||||
self == other.as_str()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3434,7 +3434,7 @@ impl cmp::PartialEq<String> for Path {
|
|||
impl cmp::PartialEq<Path> for String {
|
||||
#[inline]
|
||||
fn eq(&self, other: &Path) -> bool {
|
||||
other == self
|
||||
self.as_str() == other
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2528,7 +2528,17 @@ fn normalize_lexically() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
/// See issue#146183
|
||||
fn compare_path_to_str() {
|
||||
assert!(&PathBuf::from("x") == "x");
|
||||
/// See issue#146183 and issue#146940
|
||||
fn compare_path_like_to_str_like() {
|
||||
let path_buf = PathBuf::from("x");
|
||||
let path = Path::new("x");
|
||||
let s = String::from("x");
|
||||
assert!(path == "x");
|
||||
assert!("x" == path);
|
||||
assert!(path == &s);
|
||||
assert!(&s == path);
|
||||
assert!(&path_buf == "x");
|
||||
assert!("x" == &path_buf);
|
||||
assert!(path_buf == s);
|
||||
assert!(s == path_buf);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 24bb93c388fb8c211a37986539f24a819dc669d3
|
||||
Subproject commit 785a383cf715417fcd68c4a98a4523c2d082bb0f
|
||||
10
tests/ui/attributes/link-dl.allowed.stderr
Normal file
10
tests/ui/attributes/link-dl.allowed.stderr
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
Future incompatibility report: Future breakage diagnostic:
|
||||
warning: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", wasm_import_module = "...")]`
|
||||
--> $DIR/link-dl.rs:14:1
|
||||
|
|
||||
LL | #[link="dl"]
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
|
||||
|
||||
23
tests/ui/attributes/link-dl.default_fcw.stderr
Normal file
23
tests/ui/attributes/link-dl.default_fcw.stderr
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", wasm_import_module = "...")]`
|
||||
--> $DIR/link-dl.rs:14:1
|
||||
|
|
||||
LL | #[link="dl"]
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
|
||||
= note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
Future incompatibility report: Future breakage diagnostic:
|
||||
error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", wasm_import_module = "...")]`
|
||||
--> $DIR/link-dl.rs:14:1
|
||||
|
|
||||
LL | #[link="dl"]
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
|
||||
= note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default
|
||||
|
||||
19
tests/ui/attributes/link-dl.rs
Normal file
19
tests/ui/attributes/link-dl.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// Regression test for an issue discovered in https://github.com/rust-lang/rust/pull/143193/files and rediscovered in https://github.com/rust-lang/rust/issues/147254#event-20049906781
|
||||
// Malformed #[link] attribute was supposed to be deny-by-default report-in-deps FCW,
|
||||
// but accidentally was landed as a hard error.
|
||||
//
|
||||
// revision `default_fcw` tests that with `ill_formed_attribute_input` (the default) denied,
|
||||
// the attribute produces an FCW
|
||||
// revision `allowed` tests that with `ill_formed_attribute_input` allowed the test passes
|
||||
|
||||
//@ revisions: default_fcw allowed
|
||||
//@[allowed] check-pass
|
||||
|
||||
#[cfg_attr(allowed, allow(ill_formed_attribute_input))]
|
||||
|
||||
#[link="dl"]
|
||||
//[default_fcw]~^ ERROR valid forms for the attribute are
|
||||
//[default_fcw]~| WARN previously accepted
|
||||
extern "C" { }
|
||||
|
||||
fn main() {}
|
||||
40
tests/ui/coroutine/copy-fast-path-query-cycle.rs
Normal file
40
tests/ui/coroutine/copy-fast-path-query-cycle.rs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
//@ edition: 2024
|
||||
//@ revisions: current next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@ check-pass
|
||||
|
||||
// Regression test for #146813. We previously used a pseudo-canonical
|
||||
// query during HIR typeck which caused a query cycle when looking at the
|
||||
// witness of a coroutine.
|
||||
|
||||
use std::future::Future;
|
||||
|
||||
trait ConnectMiddleware {}
|
||||
|
||||
trait ConnectHandler: Sized {
|
||||
fn with<M>(self, _: M) -> impl ConnectHandler
|
||||
where
|
||||
M: ConnectMiddleware,
|
||||
{
|
||||
LayeredConnectHandler
|
||||
}
|
||||
}
|
||||
|
||||
struct LayeredConnectHandler;
|
||||
impl ConnectHandler for LayeredConnectHandler {}
|
||||
impl<F> ConnectHandler for F where F: FnOnce() {}
|
||||
|
||||
impl<F, Fut> ConnectMiddleware for F
|
||||
where
|
||||
F: FnOnce() -> Fut,
|
||||
Fut: Future<Output = ()> + Send,
|
||||
{
|
||||
}
|
||||
|
||||
pub async fn fails() {
|
||||
{ || {} }
|
||||
.with(async || ())
|
||||
.with(async || ())
|
||||
.with(async || ());
|
||||
}
|
||||
fn main() {}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
#![feature(lang_items, no_core)]
|
||||
#![no_core]
|
||||
#![no_main]
|
||||
|
||||
#[lang = "pointee_sized"]
|
||||
pub trait PointeeSized {}
|
||||
|
||||
#[lang = "meta_sized"]
|
||||
pub trait MetaSized: PointeeSized {}
|
||||
|
||||
#[lang = "sized"]
|
||||
trait Sized: MetaSized { }
|
||||
|
||||
struct S;
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 {
|
||||
argc //~ ERROR requires `copy` lang_item
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
error: requires `copy` lang_item
|
||||
--> $DIR/missing-copy-lang-item-issue-19660.rs:18:5
|
||||
|
|
||||
LL | argc
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue