Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 283db70

Browse files
committed
Auto merge of #141545 - GuillaumeGomez:rollup-myrvuqq, r=GuillaumeGomez
Rollup of 6 pull requests Successful merges: - #141413 (Make #[cfg(version)] respect RUSTC_OVERRIDE_VERSION_STRING) - #141443 (make teach_help message for cast-before-pass-to-variadic more precise) - #141508 (bootstrap: clippy: set TESTNAME based on given paths) - #141512 (Avoid extra path trimming in method not found error) - #141530 (Added unstable feature doc comments to unstable book) - #141541 (Random nits) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 88b3b52 + 43cb506 commit 283db70

File tree

38 files changed

+197
-62
lines changed

38 files changed

+197
-62
lines changed

‎compiler/rustc_attr_data_structures/src/version.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::fmt::{self, Display};
2+
use std::sync::OnceLock;
23

34
use rustc_macros::{
45
Decodable, Encodable, HashStable_Generic, PrintAttribute, current_rustc_version,
@@ -16,8 +17,29 @@ pub struct RustcVersion {
1617

1718
impl RustcVersion {
1819
pub const CURRENT: Self = current_rustc_version!();
20+
pub fn current_overridable() -> Self {
21+
*CURRENT_OVERRIDABLE.get_or_init(|| {
22+
if let Ok(override_var) = std::env::var("RUSTC_OVERRIDE_VERSION_STRING")
23+
&& let Some(override_) = Self::parse_str(&override_var)
24+
{
25+
override_
26+
} else {
27+
Self::CURRENT
28+
}
29+
})
30+
}
31+
fn parse_str(value: &str) -> Option<Self> {
32+
// Ignore any suffixes such as "-dev" or "-nightly".
33+
let mut components = value.split('-').next().unwrap().splitn(3, '.');
34+
let major = components.next()?.parse().ok()?;
35+
let minor = components.next()?.parse().ok()?;
36+
let patch = components.next().unwrap_or("0").parse().ok()?;
37+
Some(RustcVersion { major, minor, patch })
38+
}
1939
}
2040

41+
static CURRENT_OVERRIDABLE: OnceLock<RustcVersion> = OnceLock::new();
42+
2143
impl Display for RustcVersion {
2244
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
2345
write!(formatter, "{}.{}.{}", self.major, self.minor, self.patch)

‎compiler/rustc_attr_parsing/src/attributes/cfg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ pub fn eval_condition(
129129

130130
// See https://github.com/rust-lang/rust/issues/64796#issuecomment-640851454 for details
131131
if sess.psess.assume_incomplete_release {
132-
RustcVersion::CURRENT > min_version
132+
RustcVersion::current_overridable() > min_version
133133
} else {
134-
RustcVersion::CURRENT >= min_version
134+
RustcVersion::current_overridable() >= min_version
135135
}
136136
}
137137
MetaItemKind::List(mis) => {

‎compiler/rustc_hir_typeck/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ hir_typeck_option_result_copied = use `{$def_path}::copied` to copy the value in
169169
170170
hir_typeck_pass_to_variadic_function = can't pass `{$ty}` to variadic function
171171
.suggestion = cast the value to `{$cast_ty}`
172-
.teach_help = certain types, like `{$ty}`, must be casted before passing them to a variadic function, because of arcane ABI rules dictated by the C standard
172+
.teach_help = certain types, like `{$ty}`, must be cast before passing them to a variadic function to match the implicit cast that a C compiler would perform as part of C's numeric promotion rules
173173
174174
hir_typeck_ptr_cast_add_auto_to_object = cannot add {$traits_len ->
175175
[1] auto trait {$traits}

‎compiler/rustc_hir_typeck/src/method/suggest.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
599599
let tcx = self.tcx;
600600
let rcvr_ty = self.resolve_vars_if_possible(rcvr_ty);
601601
let mut ty_file = None;
602-
let (mutty_str, short_ty_str) =
602+
let (ty_str, short_ty_str) =
603603
if trait_missing_method && let ty::Dynamic(predicates, _, _) = rcvr_ty.kind() {
604604
(predicates.to_string(), with_forced_trimmed_paths!(predicates.to_string()))
605605
} else {
@@ -738,10 +738,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
738738
err.span_label(within_macro_span, "due to this macro variable");
739739
}
740740

741-
if short_ty_str.len() < ty_str.len() && ty_str.len() > 10 {
742-
ty_str = short_ty_str;
743-
}
744-
745741
if rcvr_ty.references_error() {
746742
err.downgrade_to_delayed_bug();
747743
}

‎compiler/rustc_infer/src/infer/canonical/query_response.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::infer::canonical::{
2323
QueryOutlivesConstraint, QueryRegionConstraints, QueryResponse,
2424
};
2525
use crate::infer::region_constraints::{Constraint, RegionConstraintData};
26-
use crate::infer::{DefineOpaqueTypes, InferCtxt, InferOk, InferResult};
26+
use crate::infer::{DefineOpaqueTypes, InferCtxt, InferOk, InferResult,SubregionOrigin};
2727
use crate::traits::query::NoSolution;
2828
use crate::traits::{
2929
Obligation, ObligationCause, PredicateObligation, PredicateObligations, ScrubbedTraitError,
@@ -593,10 +593,10 @@ impl<'tcx> InferCtxt<'tcx> {
593593
// no action needed
594594
}
595595
(GenericArgKind::Lifetime(v1), GenericArgKind::Lifetime(v2)) => {
596-
obligations.extend(
597-
self.at(cause, param_env)
598-
.eq(DefineOpaqueTypes::Yes,v1, v2)?
599-
.into_obligations(),
596+
self.inner.borrow_mut().unwrap_region_constraints().make_eqregion(
597+
SubregionOrigin::RelateRegionParamBound(cause.span,None),
598+
v1,
599+
v2,
600600
);
601601
}
602602
(GenericArgKind::Const(v1), GenericArgKind::Const(v2)) => {

‎compiler/rustc_trait_selection/src/solve/select.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use crate::solve::inspect::{self, ProofTreeInferCtxtExt};
1515

1616
#[extension(pub trait InferCtxtSelectExt<'tcx>)]
1717
impl<'tcx> InferCtxt<'tcx> {
18+
/// Do not use this directly. This is called from [`crate::traits::SelectionContext::select`].
1819
fn select_in_new_trait_solver(
1920
&self,
2021
obligation: &TraitObligation<'tcx>,

‎src/bootstrap/src/core/build_steps/test.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ impl Step for Clippy {
739739
const DEFAULT: bool = false;
740740

741741
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
742-
run.path("src/tools/clippy")
742+
run.suite_path("src/tools/clippy/tests").path("src/tools/clippy")
743743
}
744744

745745
fn make_run(run: RunConfig<'_>) {
@@ -783,6 +783,23 @@ impl Step for Clippy {
783783
let host_libs = builder.stage_out(compiler, Mode::ToolRustc).join(builder.cargo_dir());
784784
cargo.env("HOST_LIBS", host_libs);
785785

786+
// Collect paths of tests to run
787+
'partially_test: {
788+
let paths = &builder.config.paths[..];
789+
let mut test_names = Vec::new();
790+
for path in paths {
791+
if let Some(path) =
792+
helpers::is_valid_test_suite_arg(path, "src/tools/clippy/tests", builder)
793+
{
794+
test_names.push(path);
795+
} else if path.ends_with("src/tools/clippy") {
796+
// When src/tools/clippy is called directly, all tests should be run.
797+
break 'partially_test;
798+
}
799+
}
800+
cargo.env("TESTNAME", test_names.join(","));
801+
}
802+
786803
cargo.add_rustc_lib_path(builder);
787804
let cargo = prepare_cargo_test(cargo, &[], &[], host, builder);
788805

‎src/tools/tidy/src/features.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ pub struct Feature {
5454
pub tracking_issue: Option<NonZeroU32>,
5555
pub file: PathBuf,
5656
pub line: usize,
57+
pub description: Option<String>,
5758
}
5859
impl Feature {
5960
fn tracking_issue_display(&self) -> impl fmt::Display {
@@ -296,6 +297,7 @@ fn collect_lang_features_in(features: &mut Features, base: &Path, file: &str, ba
296297
let mut prev_names = vec![];
297298

298299
let lines = contents.lines().zip(1..);
300+
let mut doc_comments: Vec<String> = Vec::new();
299301
for (line, line_number) in lines {
300302
let line = line.trim();
301303

@@ -332,6 +334,13 @@ fn collect_lang_features_in(features: &mut Features, base: &Path, file: &str, ba
332334
continue;
333335
}
334336

337+
if in_feature_group {
338+
if let Some(doc_comment) = line.strip_prefix("///") {
339+
doc_comments.push(doc_comment.trim().to_string());
340+
continue;
341+
}
342+
}
343+
335344
let mut parts = line.split(',');
336345
let level = match parts.next().map(|l| l.trim().trim_start_matches('(')) {
337346
Some("unstable") => Status::Unstable,
@@ -438,9 +447,15 @@ fn collect_lang_features_in(features: &mut Features, base: &Path, file: &str, ba
438447
tracking_issue,
439448
file: path.to_path_buf(),
440449
line: line_number,
450+
description: if doc_comments.is_empty() {
451+
None
452+
} else {
453+
Some(doc_comments.join(" "))
454+
},
441455
});
442456
}
443457
}
458+
doc_comments.clear();
444459
}
445460
}
446461

@@ -564,6 +579,7 @@ fn map_lib_features(
564579
tracking_issue: find_attr_val(line, "issue").and_then(handle_issue_none),
565580
file: file.to_path_buf(),
566581
line: i + 1,
582+
description: None,
567583
};
568584
mf(Ok((feature_name, feature)), file, i + 1);
569585
continue;
@@ -600,6 +616,7 @@ fn map_lib_features(
600616
tracking_issue,
601617
file: file.to_path_buf(),
602618
line: i + 1,
619+
description: None,
603620
};
604621
if line.contains(']') {
605622
mf(Ok((feature_name, feature)), file, i + 1);

‎src/tools/unstable-book-gen/src/main.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@ use tidy::unstable_book::{
1212
collect_unstable_feature_names,
1313
};
1414

15-
fn generate_stub_issue(path: &Path, name: &str, issue: u32) {
16-
let content = format!(include_str!("stub-issue.md"), name = name, issue = issue);
15+
fn generate_stub_issue(path: &Path, name: &str, issue: u32, description: &str) {
16+
let content = format!(
17+
include_str!("stub-issue.md"),
18+
name = name,
19+
issue = issue,
20+
description = description
21+
);
1722
t!(write(path, content), path);
1823
}
1924

20-
fn generate_stub_no_issue(path: &Path, name: &str) {
21-
let content = format!(include_str!("stub-no-issue.md"), name = name);
25+
fn generate_stub_no_issue(path: &Path, name: &str,description:&str) {
26+
let content = format!(include_str!("stub-no-issue.md"), name = name, description = description);
2227
t!(write(path, content), path);
2328
}
2429

@@ -58,11 +63,17 @@ fn generate_unstable_book_files(src: &Path, out: &Path, features: &Features) {
5863
let file_name = format!("{feature_name}.md");
5964
let out_file_path = out.join(&file_name);
6065
let feature = &features[&feature_name_underscore];
66+
let description = feature.description.as_deref().unwrap_or_default();
6167

6268
if let Some(issue) = feature.tracking_issue {
63-
generate_stub_issue(&out_file_path, &feature_name_underscore, issue.get());
69+
generate_stub_issue(
70+
&out_file_path,
71+
&feature_name_underscore,
72+
issue.get(),
73+
&description,
74+
);
6475
} else {
65-
generate_stub_no_issue(&out_file_path, &feature_name_underscore);
76+
generate_stub_no_issue(&out_file_path, &feature_name_underscore,&description);
6677
}
6778
}
6879
}

‎src/tools/unstable-book-gen/src/stub-issue.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# `{name}`
22

3+
{description}
4+
35
The tracking issue for this feature is: [#{issue}]
46

57
[#{issue}]: https://github.com/rust-lang/rust/issues/{issue}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /