Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit ec12cd8

Browse files
committed
Auto merge of rust-lang#135279 - matthiaskrgr:rollup-ek2qere, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - rust-lang#135212 (Remove outdated information in the `unreachable_pub` lint description) - rust-lang#135225 (Explicitly build proc macro test with panic=unwind) - rust-lang#135242 (add missing provenance APIs on NonNull) - rust-lang#135247 (Add a list of symbols for stable standard library crates) - rust-lang#135269 (Remove some unnecessary `.into()` calls) r? `@ghost` `@rustbot` modify labels: rollup
2 parents b6b8361 + a1cadea commit ec12cd8

File tree

15 files changed

+76
-36
lines changed

15 files changed

+76
-36
lines changed

compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ rm tests/ui/mir/mir_raw_fat_ptr.rs # same
123123
rm tests/ui/consts/issue-33537.rs # same
124124
rm tests/ui/consts/const-mut-refs-crate.rs # same
125125
rm tests/ui/abi/large-byval-align.rs # exceeds implementation limit of Cranelift
126-
rm tests/ui/invalid-compile-flags/crate-type-flag.rs # warning about proc-macros and panic=abort
127126

128127
# doesn't work due to the way the rustc test suite is invoked.
129128
# should work when using ./x.py test the way it is intended

compiler/rustc_expand/src/config.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc_lint_defs::BuiltinLintDiag;
1818
use rustc_parse::validate_attr;
1919
use rustc_session::Session;
2020
use rustc_session::parse::feature_err;
21-
use rustc_span::{Span, Symbol, sym};
21+
use rustc_span::{STDLIB_STABLE_CRATES, Span, Symbol, sym};
2222
use thin_vec::ThinVec;
2323
use tracing::instrument;
2424

@@ -107,14 +107,11 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute], crate_name: Symbol) -
107107

108108
// If the enabled feature is unstable, record it.
109109
if UNSTABLE_LANG_FEATURES.iter().find(|f| name == f.name).is_some() {
110-
// When the ICE comes from core, alloc or std (approximation of the standard
111-
// library), there's a chance that the person hitting the ICE may be using
112-
// -Zbuild-std or similar with an untested target. The bug is probably in the
113-
// standard library and not the compiler in that case, but that doesn't really
114-
// matter - we want a bug report.
115-
if features.internal(name)
116-
&& ![sym::core, sym::alloc, sym::std].contains(&crate_name)
117-
{
110+
// When the ICE comes a standard library crate, there's a chance that the person
111+
// hitting the ICE may be using -Zbuild-std or similar with an untested target.
112+
// The bug is probably in the standard library and not the compiler in that case,
113+
// but that doesn't really matter - we want a bug report.
114+
if features.internal(name) && !STDLIB_STABLE_CRATES.contains(&crate_name) {
118115
sess.using_internal_features.store(true, std::sync::atomic::Ordering::Relaxed);
119116
}
120117

@@ -133,7 +130,7 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute], crate_name: Symbol) -
133130

134131
// Similar to above, detect internal lib features to suppress
135132
// the ICE message that asks for a report.
136-
if features.internal(name) && ![sym::core, sym::alloc, sym::std].contains(&crate_name) {
133+
if features.internal(name) && !STDLIB_STABLE_CRATES.contains(&crate_name) {
137134
sess.using_internal_features.store(true, std::sync::atomic::Ordering::Relaxed);
138135
}
139136
}

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ fn check_type_defn<'tcx>(
11201120
} else {
11211121
// Evaluate the constant proactively, to emit an error if the constant has
11221122
// an unconditional error. We only do so if the const has no type params.
1123-
let _ = tcx.const_eval_poly(def_id.into());
1123+
let _ = tcx.const_eval_poly(def_id);
11241124
}
11251125
}
11261126
let field_id = field.did.expect_local();

compiler/rustc_hir_typeck/src/method/prelude_edition_lints.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_lint::{ARRAY_INTO_ITER, BOXED_SLICE_INTO_ITER};
88
use rustc_middle::span_bug;
99
use rustc_middle::ty::{self, Ty};
1010
use rustc_session::lint::builtin::{RUST_2021_PRELUDE_COLLISIONS, RUST_2024_PRELUDE_COLLISIONS};
11-
use rustc_span::{Ident, Span, kw, sym};
11+
use rustc_span::{Ident, STDLIB_STABLE_CRATES, Span, kw, sym};
1212
use rustc_trait_selection::infer::InferCtxtExt;
1313
use tracing::debug;
1414

@@ -76,7 +76,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
7676
};
7777

7878
// No need to lint if method came from std/core, as that will now be in the prelude
79-
if matches!(self.tcx.crate_name(pick.item.def_id.krate), sym::std | sym::core) {
79+
if STDLIB_STABLE_CRATES.contains(&self.tcx.crate_name(pick.item.def_id.krate)) {
8080
return;
8181
}
8282

@@ -252,7 +252,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
252252
}
253253

254254
// No need to lint if method came from std/core, as that will now be in the prelude
255-
if matches!(self.tcx.crate_name(pick.item.def_id.krate), sym::std | sym::core) {
255+
if STDLIB_STABLE_CRATES.contains(&self.tcx.crate_name(pick.item.def_id.krate)) {
256256
return;
257257
}
258258

compiler/rustc_lint/src/builtin.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,9 +1271,8 @@ declare_lint! {
12711271
/// `pub(crate)` visibility is recommended to be used instead. This more clearly expresses the
12721272
/// intent that the item is only visible within its own crate.
12731273
///
1274-
/// This lint is "allow" by default because it will trigger for a large
1275-
/// amount of existing Rust code, and has some false-positives. Eventually it
1276-
/// is desired for this to become warn-by-default.
1274+
/// This lint is "allow" by default because it will trigger for a large amount of existing Rust code.
1275+
/// Eventually it is desired for this to become warn-by-default.
12771276
///
12781277
/// [`unnameable_types`]: #unnameable-types
12791278
pub UNREACHABLE_PUB,
@@ -1304,9 +1303,9 @@ impl UnreachablePub {
13041303
cx.effective_visibilities.effective_vis(def_id).map(|effective_vis| {
13051304
effective_vis.at_level(rustc_middle::middle::privacy::Level::Reachable)
13061305
})
1307-
&& let parent_parent = cx.tcx.parent_module_from_def_id(
1308-
cx.tcx.parent_module_from_def_id(def_id.into()).into(),
1309-
)
1306+
&& let parent_parent = cx
1307+
.tcx
1308+
.parent_module_from_def_id(cx.tcx.parent_module_from_def_id(def_id).into())
13101309
&& *restricted_did == parent_parent.to_local_def_id()
13111310
&& !restricted_did.to_def_id().is_crate_root()
13121311
{

compiler/rustc_parse/src/parser/tests.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2366,8 +2366,7 @@ fn string_to_tts_1() {
23662366
token::Ident(sym::i32, IdentIsRaw::No),
23672367
sp(8, 11),
23682368
),
2369-
])
2370-
.into(),
2369+
]),
23712370
),
23722371
TokenTree::Delimited(
23732372
DelimSpan::from_pair(sp(13, 14), sp(18, 19)),
@@ -2383,8 +2382,7 @@ fn string_to_tts_1() {
23832382
),
23842383
// `Alone` because the `;` is followed by whitespace.
23852384
TokenTree::token_alone(token::Semi, sp(16, 17)),
2386-
])
2387-
.into(),
2385+
]),
23882386
),
23892387
]);
23902388

compiler/rustc_span/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ mod span_encoding;
6767
pub use span_encoding::{DUMMY_SP, Span};
6868

6969
pub mod symbol;
70-
pub use symbol::{Ident, MacroRulesNormalizedIdent, Symbol, kw, sym};
70+
pub use symbol::{Ident, MacroRulesNormalizedIdent, STDLIB_STABLE_CRATES, Symbol, kw, sym};
7171

7272
mod analyze_source_file;
7373
pub mod fatal_error;

compiler/rustc_span/src/symbol.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2240,6 +2240,10 @@ symbols! {
22402240
}
22412241
}
22422242

2243+
/// Symbols for crates that are part of the stable standard library: `std`, `core`, `alloc`, and
2244+
/// `proc_macro`.
2245+
pub const STDLIB_STABLE_CRATES: &[Symbol] = &[sym::std, sym::core, sym::alloc, sym::proc_macro];
2246+
22432247
#[derive(Copy, Clone, Eq, HashStable_Generic, Encodable, Decodable)]
22442248
pub struct Ident {
22452249
pub name: Symbol,

compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use rustc_middle::ty::{
2727
self, ToPolyTraitRef, TraitRef, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, Upcast,
2828
};
2929
use rustc_middle::{bug, span_bug};
30-
use rustc_span::{BytePos, DUMMY_SP, Span, Symbol, sym};
30+
use rustc_span::{BytePos, DUMMY_SP, STDLIB_STABLE_CRATES, Span, Symbol, sym};
3131
use tracing::{debug, instrument};
3232

3333
use super::on_unimplemented::{AppendConstMessage, OnUnimplementedNote};
@@ -520,7 +520,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
520520
match obligation.cause.span.ctxt().outer_expn_data().macro_def_id {
521521
Some(macro_def_id) => {
522522
let crate_name = tcx.crate_name(macro_def_id.krate);
523-
crate_name == sym::std || crate_name == sym::core
523+
STDLIB_STABLE_CRATES.contains(&crate_name)
524524
}
525525
None => false,
526526
};

compiler/rustc_trait_selection/src/traits/const_evaluatable.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub fn is_const_evaluatable<'tcx>(
7979
Err(
8080
EvaluateConstErr::EvaluationFailure(e)
8181
| EvaluateConstErr::InvalidConstParamTy(e),
82-
) => Err(NotConstEvaluatable::Error(e.into())),
82+
) => Err(NotConstEvaluatable::Error(e)),
8383
Ok(_) => Ok(()),
8484
}
8585
}
@@ -140,7 +140,7 @@ pub fn is_const_evaluatable<'tcx>(
140140
}
141141
Err(
142142
EvaluateConstErr::EvaluationFailure(e) | EvaluateConstErr::InvalidConstParamTy(e),
143-
) => Err(NotConstEvaluatable::Error(e.into())),
143+
) => Err(NotConstEvaluatable::Error(e)),
144144
Ok(_) => Ok(()),
145145
}
146146
}

0 commit comments

Comments
 (0)