Skip to content

Commit 4f9e4e1

Browse files
committed
Auto merge of #155953 - ShoyuVanilla:rollup-BrmB2HL, r=ShoyuVanilla
Rollup of 6 pull requests Successful merges: - #152443 (NVPTX: Drop support for old architectures and old ISAs) - #155648 (`-Znext-solver` Propagate `stalled_on_coroutines` as a field in `Certainty::Maybe`) - #155896 (Shrink `ParseSess`) - #155922 (delete unused auxiliary test files) - #155943 (fix: ✏️ forgot to change the stable version for `assert_matches!` macro.) - #155947 (tests: mark simple UI tests as check-pass)
2 parents 37d85e5 + 7ffff36 commit 4f9e4e1

65 files changed

Lines changed: 415 additions & 546 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

compiler/rustc_attr_parsing/src/attributes/cfg.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ pub(crate) fn parse_name_value<S: Stage>(
222222
}
223223
};
224224

225-
match cx.sess.psess.check_config.expecteds.get(&name) {
225+
match cx.sess.check_config.expecteds.get(&name) {
226226
Some(ExpectedValues::Some(values)) if !values.contains(&value.map(|(v, _)| v)) => cx
227227
.emit_lint_with_sess(
228228
UNEXPECTED_CFGS,
@@ -232,7 +232,7 @@ pub(crate) fn parse_name_value<S: Stage>(
232232
},
233233
span,
234234
),
235-
None if cx.sess.psess.check_config.exhaustive_names => cx.emit_lint_with_sess(
235+
None if cx.sess.check_config.exhaustive_names => cx.emit_lint_with_sess(
236236
UNEXPECTED_CFGS,
237237
move |dcx, level, sess| {
238238
check_cfg::unexpected_cfg_name(sess, (name, name_span), value).into_diag(dcx, level)
@@ -280,7 +280,7 @@ pub fn eval_config_entry(sess: &Session, cfg_entry: &CfgEntry) -> EvalConfigResu
280280
}
281281
}
282282
CfgEntry::NameValue { name, value, span } => {
283-
if sess.psess.config.contains(&(*name, *value)) {
283+
if sess.config.contains(&(*name, *value)) {
284284
EvalConfigResult::True
285285
} else {
286286
EvalConfigResult::False { reason: cfg_entry.clone(), reason_span: *span }
@@ -294,7 +294,7 @@ pub fn eval_config_entry(sess: &Session, cfg_entry: &CfgEntry) -> EvalConfigResu
294294
};
295295
};
296296
// See https://github.com/rust-lang/rust/issues/64796#issuecomment-640851454 for details
297-
let min_version_ok = if sess.psess.assume_incomplete_release {
297+
let min_version_ok = if sess.opts.unstable_opts.assume_incomplete_release {
298298
RustcVersion::current_overridable() > *min_version
299299
} else {
300300
RustcVersion::current_overridable() >= *min_version

compiler/rustc_attr_parsing/src/attributes/diagnostic/check_cfg.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ fn sort_and_truncate_possibilities(
2525
} else {
2626
match filter_well_known_names {
2727
FilterWellKnownNames::Yes => {
28-
possibilities.retain(|cfg_name| {
29-
!sess.psess.check_config.well_known_names.contains(cfg_name)
30-
});
28+
possibilities
29+
.retain(|cfg_name| !sess.check_config.well_known_names.contains(cfg_name));
3130
}
3231
FilterWellKnownNames::No => {}
3332
};
@@ -105,13 +104,12 @@ pub(crate) fn unexpected_cfg_name(
105104
value: Option<(Symbol, Span)>,
106105
) -> errors::UnexpectedCfgName {
107106
#[allow(rustc::potential_query_instability)]
108-
let possibilities: Vec<Symbol> = sess.psess.check_config.expecteds.keys().copied().collect();
107+
let possibilities: Vec<Symbol> = sess.check_config.expecteds.keys().copied().collect();
109108

110109
let mut names_possibilities: Vec<_> = if value.is_none() {
111110
// We later sort and display all the possibilities, so the order here does not matter.
112111
#[allow(rustc::potential_query_instability)]
113-
sess.psess
114-
.check_config
112+
sess.check_config
115113
.expecteds
116114
.iter()
117115
.filter_map(|(k, v)| match v {
@@ -167,7 +165,7 @@ pub(crate) fn unexpected_cfg_name(
167165
is_feature_cfg |= best_match == sym::feature;
168166

169167
if let Some(ExpectedValues::Some(best_match_values)) =
170-
sess.psess.check_config.expecteds.get(&best_match)
168+
sess.check_config.expecteds.get(&best_match)
171169
{
172170
// We will soon sort, so the initial order does not matter.
173171
#[allow(rustc::potential_query_instability)]
@@ -285,7 +283,7 @@ pub(crate) fn unexpected_cfg_value(
285283
(name, name_span): (Symbol, Span),
286284
value: Option<(Symbol, Span)>,
287285
) -> errors::UnexpectedCfgValue {
288-
let Some(ExpectedValues::Some(values)) = &sess.psess.check_config.expecteds.get(&name) else {
286+
let Some(ExpectedValues::Some(values)) = &sess.check_config.expecteds.get(&name) else {
289287
panic!(
290288
"it shouldn't be possible to have a diagnostic on a value whose name is not in values"
291289
);
@@ -305,7 +303,7 @@ pub(crate) fn unexpected_cfg_value(
305303
let is_from_external_macro = name_span.in_external_macro(sess.source_map());
306304

307305
let code_sugg = if let Some((value, _)) = value
308-
&& sess.psess.check_config.well_known_names.contains(&name)
306+
&& sess.check_config.well_known_names.contains(&name)
309307
&& let valid_names = possible_well_known_names_for_cfg_value(sess, value)
310308
&& !valid_names.is_empty()
311309
{
@@ -378,12 +376,12 @@ pub(crate) fn unexpected_cfg_value(
378376
// We don't want to encourage people to add values to a well-known names, as these are
379377
// defined by rustc/Rust itself. Users can still do this if they wish, but should not be
380378
// encouraged to do so.
381-
let can_suggest_adding_value = !sess.psess.check_config.well_known_names.contains(&name)
379+
let can_suggest_adding_value = !sess.check_config.well_known_names.contains(&name)
382380
// Except when working on rustc or the standard library itself, in which case we want to
383381
// suggest adding these cfgs to the "normal" place because of bootstrapping reasons. As a
384382
// basic heuristic, we use the "cheat" unstable feature enable method and the
385383
// non-ui-testing enabled option.
386-
|| (matches!(sess.psess.unstable_features, rustc_feature::UnstableFeatures::Cheat)
384+
|| (matches!(sess.unstable_features, rustc_feature::UnstableFeatures::Cheat)
387385
&& !sess.opts.unstable_opts.ui_testing);
388386

389387
let inst = |escape_quotes| {
@@ -429,13 +427,11 @@ pub(crate) fn unexpected_cfg_value(
429427
fn possible_well_known_names_for_cfg_value(sess: &Session, value: Symbol) -> Vec<Symbol> {
430428
#[allow(rustc::potential_query_instability)]
431429
let mut names = sess
432-
.psess
433430
.check_config
434431
.well_known_names
435432
.iter()
436433
.filter(|name| {
437-
sess.psess
438-
.check_config
434+
sess.check_config
439435
.expecteds
440436
.get(*name)
441437
.map(|expected_values| expected_values.contains(&Some(value)))

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,9 @@ fn print_target_cpus(sess: &Session, tm: &llvm::TargetMachine, out: &mut String)
514514
};
515515
let mut cpus = cpu_names
516516
.lines()
517+
.filter(|cpu_name| {
518+
!sess.target.unsupported_cpus.contains(&std::borrow::Cow::Borrowed(*cpu_name))
519+
})
517520
.map(|cpu_name| Cpu { cpu_name, remark: make_remark(cpu_name) })
518521
.collect::<VecDeque<_>>();
519522

compiler/rustc_codegen_ssa/src/assert_module_sources.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl<'tcx> AssertModuleSource<'tcx> {
171171
/// Scan for a `cfg="foo"` attribute and check whether we have a
172172
/// cfg flag called `foo`.
173173
fn check_config(&self, value: Symbol) -> bool {
174-
let config = &self.tcx.sess.psess.config;
174+
let config = &self.tcx.sess.config;
175175
debug!("check_config(config={:?}, value={:?})", config, value);
176176
if config.iter().any(|&(name, _)| name == value) {
177177
debug!("check_config: matched");

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,13 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
696696
tcx.dcx().emit_fatal(errors::CpuRequired);
697697
}
698698

699+
if let Some(target_cpu) = &tcx.sess.opts.cg.target_cpu
700+
&& tcx.sess.target.unsupported_cpus.contains(&target_cpu.into())
701+
{
702+
// The target cpu is explicitly listed as an unsupported cpu
703+
tcx.dcx().emit_fatal(errors::CpuUnsupported { target_cpu: target_cpu.clone() });
704+
}
705+
699706
let cgu_name_builder = &mut CodegenUnitNameBuilder::new(tcx);
700707

701708
// Run the monomorphization collector and partition the collected items into

compiler/rustc_codegen_ssa/src/errors.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,12 @@ pub(crate) struct InsufficientVSCodeProduct;
540540
#[diag("target requires explicitly specifying a cpu with `-C target-cpu`")]
541541
pub(crate) struct CpuRequired;
542542

543+
#[derive(Diagnostic)]
544+
#[diag("target cpu `{$target_cpu}` is known but unsupported")]
545+
pub(crate) struct CpuUnsupported {
546+
pub target_cpu: String,
547+
}
548+
543549
#[derive(Diagnostic)]
544550
#[diag("processing debug info with `dsymutil` failed: {$status}")]
545551
#[note("{$output}")]

compiler/rustc_codegen_ssa/src/target_features.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,20 @@ pub fn target_spec_to_backend_features<'a>(
387387
sess: &'a Session,
388388
mut extend_backend_features: impl FnMut(&'a str, /* enable */ bool),
389389
) {
390-
// Compute implied features
391390
let mut rust_features = vec![];
391+
392+
// This check handles SM versions that defaults (by LLVM) to unsupported (by Rust) PTX ISA versions.
393+
// sm_70, sm_72 and sm_75 defaults to PTX ISA versions with major version 6, while sm_80 default to 7.0
394+
if sess.target.arch == Arch::Nvptx64
395+
&& matches!(
396+
sess.opts.cg.target_cpu.as_deref(),
397+
None | Some("sm_70") | Some("sm_72") | Some("sm_75")
398+
)
399+
{
400+
rust_features.push((true, "ptx70"));
401+
}
402+
403+
// Compute implied features
392404
parse_rust_feature_list(
393405
sess,
394406
&sess.target.features,

compiler/rustc_driver_impl/src/lib.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,6 @@ fn print_crate_info(
734734
}
735735
Cfg => {
736736
let mut cfgs = sess
737-
.psess
738737
.config
739738
.iter()
740739
.filter_map(|&(name, value)| {
@@ -763,7 +762,7 @@ fn print_crate_info(
763762

764763
// INSTABILITY: We are sorting the output below.
765764
#[allow(rustc::potential_query_instability)]
766-
for (name, expected_values) in &sess.psess.check_config.expecteds {
765+
for (name, expected_values) in &sess.check_config.expecteds {
767766
use crate::config::ExpectedValues;
768767
match expected_values {
769768
ExpectedValues::Any => {
@@ -791,9 +790,7 @@ fn print_crate_info(
791790
}
792791

793792
check_cfgs.sort_unstable();
794-
if !sess.psess.check_config.exhaustive_names
795-
&& sess.psess.check_config.exhaustive_values
796-
{
793+
if !sess.check_config.exhaustive_names && sess.check_config.exhaustive_values {
797794
println_info!("cfg(any())");
798795
}
799796
for check_cfg in check_cfgs {

compiler/rustc_expand/src/proc_macro_server.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use rustc_proc_macro::bridge::{
1515
DelimSpan, Diagnostic, ExpnGlobals, Group, Ident, LitKind, Literal, Punct, TokenTree, server,
1616
};
1717
use rustc_proc_macro::{Delimiter, Level};
18+
use rustc_session::Session;
1819
use rustc_session::parse::ParseSess;
1920
use rustc_span::def_id::CrateNum;
2021
use rustc_span::{BytePos, FileName, Pos, Span, Symbol, sym};
@@ -440,6 +441,10 @@ impl<'a, 'b> Rustc<'a, 'b> {
440441
}
441442
}
442443

444+
fn sess(&self) -> &Session {
445+
&self.ecx.sess
446+
}
447+
443448
fn psess(&self) -> &ParseSess {
444449
self.ecx.psess()
445450
}
@@ -825,7 +830,7 @@ impl server::Server for Rustc<'_, '_> {
825830
/// since we've loaded `my_proc_macro` from disk in order to execute it).
826831
/// In this way, we have obtained a span pointing into `my_proc_macro`
827832
fn span_save_span(&mut self, span: Self::Span) -> usize {
828-
self.psess().save_proc_macro_span(span)
833+
self.sess().save_proc_macro_span(span)
829834
}
830835

831836
fn span_recover_proc_macro_span(&mut self, id: usize) -> Self::Span {

compiler/rustc_hir_typeck/src/coercion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2099,7 +2099,7 @@ impl<'tcx> ProofTreeVisitor<'tcx> for CoerceVisitor<'_, 'tcx> {
20992099
ControlFlow::Break(())
21002100
}
21012101
}
2102-
Ok(Certainty::Maybe { .. }) => {
2102+
Ok(Certainty::Maybe(_)) => {
21032103
// FIXME: structurally normalize?
21042104
if self.fcx.tcx.is_lang_item(pred.def_id(), LangItem::Unsize)
21052105
&& let ty::Dynamic(..) = pred.skip_binder().trait_ref.args.type_at(1).kind()

0 commit comments

Comments
 (0)