Skip to content

Commit 664f2e1

Browse files
committed
Auto merge of #147284 - cuviper:beta-next, r=cuviper
[beta] backports - remove incorrect fast path #146919 - Update LLVM to 21.1.2 #146953 - Fix infinite recursion in Path::eq with String #146958 - Make #[link="dl"] an FCW rather than an error #147262 r? cuviper
2 parents aa7859c + d215429 commit 664f2e1

File tree

13 files changed

+135
-60
lines changed

13 files changed

+135
-60
lines changed

compiler/rustc_attr_parsing/src/attributes/link_attrs.rs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,22 @@ impl<S: Stage> CombineAttributeParser<S> for LinkParser {
6565
cx: &'c mut AcceptContext<'_, '_, S>,
6666
args: &'c ArgParser<'_>,
6767
) -> impl IntoIterator<Item = Self::Item> + 'c {
68-
let mut result = None;
69-
let Some(items) = args.list() else {
70-
cx.expected_list(cx.attr_span);
71-
return result;
68+
let items = match args {
69+
ArgParser::List(list) => list,
70+
// This is an edgecase added because making this a hard error would break too many crates
71+
// Specifically `#[link = "dl"]` is accepted with a FCW
72+
// For more information, see https://github.com/rust-lang/rust/pull/143193
73+
ArgParser::NameValue(nv) if nv.value_as_str().is_some_and(|v| v == sym::dl) => {
74+
let suggestions = <Self as CombineAttributeParser<S>>::TEMPLATE
75+
.suggestions(cx.attr_style, "link");
76+
let span = cx.attr_span;
77+
cx.emit_lint(AttributeLintKind::IllFormedAttributeInput { suggestions }, span);
78+
return None;
79+
}
80+
_ => {
81+
cx.expected_list(cx.attr_span);
82+
return None;
83+
}
7284
};
7385

7486
let sess = cx.sess();
@@ -113,7 +125,7 @@ impl<S: Stage> CombineAttributeParser<S> for LinkParser {
113125
}
114126
};
115127
if !cont {
116-
return result;
128+
return None;
117129
}
118130
}
119131

@@ -202,7 +214,7 @@ impl<S: Stage> CombineAttributeParser<S> for LinkParser {
202214
}
203215
let Some((name, name_span)) = name else {
204216
cx.emit_err(LinkRequiresName { span: cx.attr_span });
205-
return result;
217+
return None;
206218
};
207219

208220
// 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 {
218230
cx.emit_err(RawDylibNoNul { span: name_span });
219231
}
220232

221-
result = Some(LinkEntry {
233+
Some(LinkEntry {
222234
span: cx.attr_span,
223235
kind: kind.unwrap_or(NativeLibKind::Unspecified),
224236
name,
225237
cfg,
226238
verbatim,
227239
import_name_type,
228-
});
229-
result
240+
})
230241
}
231242
}
232243

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,7 @@ symbols! {
871871
div,
872872
div_assign,
873873
diverging_block_default,
874+
dl,
874875
do_not_recommend,
875876
doc,
876877
doc_alias,

compiler/rustc_trait_selection/src/infer.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_middle::infer::canonical::{
99
Canonical, CanonicalQueryInput, CanonicalQueryResponse, QueryResponse,
1010
};
1111
use rustc_middle::traits::query::NoSolution;
12-
use rustc_middle::ty::{self, GenericArg, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, Upcast};
12+
use rustc_middle::ty::{self, GenericArg, Ty, TyCtxt, TypeFoldable, Upcast};
1313
use rustc_span::DUMMY_SP;
1414
use tracing::instrument;
1515

@@ -31,19 +31,7 @@ impl<'tcx> InferCtxt<'tcx> {
3131

3232
fn type_is_copy_modulo_regions(&self, param_env: ty::ParamEnv<'tcx>, ty: Ty<'tcx>) -> bool {
3333
let ty = self.resolve_vars_if_possible(ty);
34-
35-
// FIXME(#132279): This should be removed as it causes us to incorrectly
36-
// handle opaques in their defining scope, and stalled coroutines.
37-
if !self.next_trait_solver() && !(param_env, ty).has_infer() && !ty.has_coroutines() {
38-
return self.tcx.type_is_copy_modulo_regions(self.typing_env(param_env), ty);
39-
}
40-
4134
let copy_def_id = self.tcx.require_lang_item(LangItem::Copy, DUMMY_SP);
42-
43-
// This can get called from typeck (by euv), and `moves_by_default`
44-
// rightly refuses to work with inference variables, but
45-
// moves_by_default has a cache, which we want to use in other
46-
// cases.
4735
traits::type_known_to_meet_bound_modulo_regions(self, param_env, ty, copy_def_id)
4836
}
4937

library/std/src/path.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,31 +2107,31 @@ impl PartialEq for PathBuf {
21072107
impl cmp::PartialEq<str> for PathBuf {
21082108
#[inline]
21092109
fn eq(&self, other: &str) -> bool {
2110-
Path::eq(self, other)
2110+
self.as_path() == other
21112111
}
21122112
}
21132113

21142114
#[stable(feature = "eq_str_for_path", since = "1.91.0")]
21152115
impl cmp::PartialEq<PathBuf> for str {
21162116
#[inline]
21172117
fn eq(&self, other: &PathBuf) -> bool {
2118-
other == self
2118+
self == other.as_path()
21192119
}
21202120
}
21212121

21222122
#[stable(feature = "eq_str_for_path", since = "1.91.0")]
21232123
impl cmp::PartialEq<String> for PathBuf {
21242124
#[inline]
21252125
fn eq(&self, other: &String) -> bool {
2126-
**self == **other
2126+
self.as_path() == other.as_str()
21272127
}
21282128
}
21292129

21302130
#[stable(feature = "eq_str_for_path", since = "1.91.0")]
21312131
impl cmp::PartialEq<PathBuf> for String {
21322132
#[inline]
21332133
fn eq(&self, other: &PathBuf) -> bool {
2134-
other == self
2134+
self.as_str() == other.as_path()
21352135
}
21362136
}
21372137

@@ -3426,15 +3426,15 @@ impl cmp::PartialEq<Path> for str {
34263426
impl cmp::PartialEq<String> for Path {
34273427
#[inline]
34283428
fn eq(&self, other: &String) -> bool {
3429-
self == &*other
3429+
self == other.as_str()
34303430
}
34313431
}
34323432

34333433
#[stable(feature = "eq_str_for_path", since = "1.91.0")]
34343434
impl cmp::PartialEq<Path> for String {
34353435
#[inline]
34363436
fn eq(&self, other: &Path) -> bool {
3437-
other == self
3437+
self.as_str() == other
34383438
}
34393439
}
34403440

library/std/tests/path.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2528,7 +2528,17 @@ fn normalize_lexically() {
25282528
}
25292529

25302530
#[test]
2531-
/// See issue#146183
2532-
fn compare_path_to_str() {
2533-
assert!(&PathBuf::from("x") == "x");
2531+
/// See issue#146183 and issue#146940
2532+
fn compare_path_like_to_str_like() {
2533+
let path_buf = PathBuf::from("x");
2534+
let path = Path::new("x");
2535+
let s = String::from("x");
2536+
assert!(path == "x");
2537+
assert!("x" == path);
2538+
assert!(path == &s);
2539+
assert!(&s == path);
2540+
assert!(&path_buf == "x");
2541+
assert!("x" == &path_buf);
2542+
assert!(path_buf == s);
2543+
assert!(s == path_buf);
25342544
}

src/llvm-project

Submodule llvm-project updated 68 files
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Future incompatibility report: Future breakage diagnostic:
2+
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 = "...")]`
3+
--> $DIR/link-dl.rs:14:1
4+
|
5+
LL | #[link="dl"]
6+
| ^^^^^^^^^^^^
7+
|
8+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
9+
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
10+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
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 = "...")]`
2+
--> $DIR/link-dl.rs:14:1
3+
|
4+
LL | #[link="dl"]
5+
| ^^^^^^^^^^^^
6+
|
7+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
8+
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
9+
= note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default
10+
11+
error: aborting due to 1 previous error
12+
13+
Future incompatibility report: Future breakage diagnostic:
14+
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 = "...")]`
15+
--> $DIR/link-dl.rs:14:1
16+
|
17+
LL | #[link="dl"]
18+
| ^^^^^^^^^^^^
19+
|
20+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
21+
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
22+
= note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default
23+

tests/ui/attributes/link-dl.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// 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
2+
// Malformed #[link] attribute was supposed to be deny-by-default report-in-deps FCW,
3+
// but accidentally was landed as a hard error.
4+
//
5+
// revision `default_fcw` tests that with `ill_formed_attribute_input` (the default) denied,
6+
// the attribute produces an FCW
7+
// revision `allowed` tests that with `ill_formed_attribute_input` allowed the test passes
8+
9+
//@ revisions: default_fcw allowed
10+
//@[allowed] check-pass
11+
12+
#[cfg_attr(allowed, allow(ill_formed_attribute_input))]
13+
14+
#[link="dl"]
15+
//[default_fcw]~^ ERROR valid forms for the attribute are
16+
//[default_fcw]~| WARN previously accepted
17+
extern "C" { }
18+
19+
fn main() {}

0 commit comments

Comments
 (0)