Skip to content

Commit 9ba169a

Browse files
committedSep 2, 2022
Auto merge of #101333 - matthiaskrgr:rollup-qpf1otj, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #100121 (Try normalizing types without RevealAll in ParamEnv in MIR validation) - #100200 (Change implementation of `-Z gcc-ld` and `lld-wrapper` again) - #100814 ( Porting 'compiler/rustc_trait_selection' to translatable diagnostics - Part 1) - #101215 (Also replace the version placeholder in rustc_attr) - #101260 (Use `FILE_ATTRIBUTE_TAG_INFO` to get reparse tag) - #101323 (Remove unused .toggle-label CSS rule) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents b88e510 + e77b8ce commit 9ba169a

File tree

28 files changed

+303
-144
lines changed

28 files changed

+303
-144
lines changed
 

Diff for: ‎compiler/rustc_attr/src/builtin.rs

+12
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ use std::num::NonZeroU32;
1515

1616
use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause};
1717

18+
/// The version placeholder that recently stabilized features contain inside the
19+
/// `since` field of the `#[stable]` attribute.
20+
///
21+
/// For more, see [this pull request](https://github.com/rust-lang/rust/pull/100591).
22+
pub const VERSION_PLACEHOLDER: &str = "CURRENT_RUSTC_VERSION";
23+
1824
pub fn is_builtin_attr(attr: &Attribute) -> bool {
1925
attr.is_doc_comment() || attr.ident().filter(|ident| is_builtin_attr_name(ident.name)).is_some()
2026
}
@@ -483,6 +489,12 @@ where
483489
}
484490
}
485491

492+
if let Some(s) = since && s.as_str() == VERSION_PLACEHOLDER {
493+
let version = option_env!("CFG_VERSION").unwrap_or("<current>");
494+
let version = version.split(' ').next().unwrap();
495+
since = Some(Symbol::intern(&version));
496+
}
497+
486498
match (feature, since) {
487499
(Some(feature), Some(since)) => {
488500
let level = Stable { since, allowed_through_unstable_modules: false };

Diff for: ‎compiler/rustc_codegen_ssa/src/back/link.rs

+18-14
Original file line numberDiff line numberDiff line change
@@ -2797,20 +2797,24 @@ fn add_gcc_ld_path(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
27972797
if let LinkerFlavor::Gcc = flavor {
27982798
match ld_impl {
27992799
LdImpl::Lld => {
2800-
let tools_path = sess.get_tools_search_paths(false);
2801-
let gcc_ld_dir = tools_path
2802-
.into_iter()
2803-
.map(|p| p.join("gcc-ld"))
2804-
.find(|p| {
2805-
p.join(if sess.host.is_like_windows { "ld.exe" } else { "ld" }).exists()
2806-
})
2807-
.unwrap_or_else(|| sess.fatal("rust-lld (as ld) not found"));
2808-
cmd.arg({
2809-
let mut arg = OsString::from("-B");
2810-
arg.push(gcc_ld_dir);
2811-
arg
2812-
});
2813-
cmd.arg(format!("-Wl,-rustc-lld-flavor={}", sess.target.lld_flavor.as_str()));
2800+
// Implement the "self-contained" part of -Zgcc-ld
2801+
// by adding rustc distribution directories to the tool search path.
2802+
for path in sess.get_tools_search_paths(false) {
2803+
cmd.arg({
2804+
let mut arg = OsString::from("-B");
2805+
arg.push(path.join("gcc-ld"));
2806+
arg
2807+
});
2808+
}
2809+
// Implement the "linker flavor" part of -Zgcc-ld
2810+
// by asking cc to use some kind of lld.
2811+
cmd.arg("-fuse-ld=lld");
2812+
if sess.target.lld_flavor != LldFlavor::Ld {
2813+
// Tell clang to use a non-default LLD flavor.
2814+
// Gcc doesn't understand the target option, but we currently assume
2815+
// that gcc is not used for Apple and Wasm targets (#97402).
2816+
cmd.arg(format!("--target={}", sess.target.llvm_target));
2817+
}
28142818
}
28152819
}
28162820
} else {

Diff for: ‎compiler/rustc_const_eval/src/transform/validate.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,23 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
181181
if (src, dest).has_opaque_types() {
182182
return true;
183183
}
184-
// Normalize projections and things like that.
185-
let param_env = self.param_env.with_reveal_all_normalized(self.tcx);
186-
let src = self.tcx.normalize_erasing_regions(param_env, src);
187-
let dest = self.tcx.normalize_erasing_regions(param_env, dest);
188184

185+
// Normalize projections and things like that.
189186
// Type-changing assignments can happen when subtyping is used. While
190187
// all normal lifetimes are erased, higher-ranked types with their
191188
// late-bound lifetimes are still around and can lead to type
192189
// differences. So we compare ignoring lifetimes.
193-
equal_up_to_regions(self.tcx, param_env, src, dest)
190+
191+
// First, try with reveal_all. This might not work in some cases, as the predicates
192+
// can be cleared in reveal_all mode. We try the reveal first anyways as it is used
193+
// by some other passes like inlining as well.
194+
let param_env = self.param_env.with_reveal_all_normalized(self.tcx);
195+
if equal_up_to_regions(self.tcx, param_env, src, dest) {
196+
return true;
197+
}
198+
199+
// If this fails, we can try it without the reveal.
200+
equal_up_to_regions(self.tcx, self.param_env, src, dest)
194201
}
195202
}
196203

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
trait_selection_dump_vtable_entries = vtable entries for `{$trait_ref}`: {$entries}
2+
3+
trait_selection_unable_to_construct_constant_value = unable to construct a constant value for the unevaluated constant {$unevaluated}
4+
5+
trait_selection_auto_deref_reached_recursion_limit = reached the recursion limit while auto-dereferencing `{$ty}`
6+
.label = deref recursion limit reached
7+
.help = consider increasing the recursion limit by adding a `#![recursion_limit = "{$suggested_limit}"]` attribute to your crate (`{$crate_name}`)
8+
9+
trait_selection_empty_on_clause_in_rustc_on_unimplemented = empty `on`-clause in `#[rustc_on_unimplemented]`
10+
.label = empty on-clause here
11+
12+
trait_selection_invalid_on_clause_in_rustc_on_unimplemented = invalid `on`-clause in `#[rustc_on_unimplemented]`
13+
.label = invalid on-clause here
14+
15+
trait_selection_no_value_in_rustc_on_unimplemented = this attribute must have a valid value
16+
.label = expected value here
17+
.note = eg `#[rustc_on_unimplemented(message="foo")]`
18+
19+
trait_selection_negative_positive_conflict = found both positive and negative implementation of trait `{$trait_desc}`{$self_desc ->
20+
[none] {""}
21+
*[default] {" "}for type `{$self_desc}`
22+
}:
23+
.negative_implementation_here = negative implementation here
24+
.negative_implementation_in_crate = negative implementation in crate `{$negative_impl_cname}`
25+
.positive_implementation_here = positive implementation here
26+
.positive_implementation_in_crate = positive implementation in crate `{$positive_impl_cname}`

Diff for: ‎compiler/rustc_error_messages/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ fluent_messages! {
5353
plugin_impl => "../locales/en-US/plugin_impl.ftl",
5454
privacy => "../locales/en-US/privacy.ftl",
5555
query_system => "../locales/en-US/query_system.ftl",
56+
trait_selection => "../locales/en-US/trait_selection.ftl",
5657
save_analysis => "../locales/en-US/save_analysis.ftl",
5758
ty_utils => "../locales/en-US/ty_utils.ftl",
5859
typeck => "../locales/en-US/typeck.ftl",

Diff for: ‎compiler/rustc_middle/src/ty/consts/kind.rs

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ pub struct Unevaluated<'tcx, P = Option<Promoted>> {
2020
pub promoted: P,
2121
}
2222

23+
impl rustc_errors::IntoDiagnosticArg for Unevaluated<'_> {
24+
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
25+
format!("{:?}", self).into_diagnostic_arg()
26+
}
27+
}
28+
2329
impl<'tcx> Unevaluated<'tcx> {
2430
#[inline]
2531
pub fn shrink(self) -> Unevaluated<'tcx, ()> {

Diff for: ‎compiler/rustc_middle/src/ty/sty.rs

+6
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,12 @@ impl<'tcx> PolyTraitRef<'tcx> {
849849
}
850850
}
851851

852+
impl rustc_errors::IntoDiagnosticArg for PolyTraitRef<'_> {
853+
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
854+
self.to_string().into_diagnostic_arg()
855+
}
856+
}
857+
852858
/// An existential reference to a trait, where `Self` is erased.
853859
/// For example, the trait object `Trait<'a, 'b, X, Y>` is:
854860
/// ```ignore (illustrative)

Diff for: ‎compiler/rustc_passes/src/lib_features.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
//! collect them instead.
66
77
use rustc_ast::{Attribute, MetaItemKind};
8+
use rustc_attr::VERSION_PLACEHOLDER;
89
use rustc_errors::struct_span_err;
910
use rustc_hir::intravisit::Visitor;
1011
use rustc_middle::hir::nested_filter;
@@ -54,7 +55,6 @@ impl<'tcx> LibFeatureCollector<'tcx> {
5455
}
5556
}
5657
}
57-
const VERSION_PLACEHOLDER: &str = "CURRENT_RUSTC_VERSION";
5858

5959
if let Some(s) = since && s.as_str() == VERSION_PLACEHOLDER {
6060
let version = option_env!("CFG_VERSION").unwrap_or("<current>");

Diff for: ‎compiler/rustc_session/src/session.rs

+6
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ impl Mul<usize> for Limit {
110110
}
111111
}
112112

113+
impl rustc_errors::IntoDiagnosticArg for Limit {
114+
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
115+
self.to_string().into_diagnostic_arg()
116+
}
117+
}
118+
113119
#[derive(Clone, Copy, Debug, HashStable_Generic)]
114120
pub struct Limits {
115121
/// The maximum recursion limit for potentially infinitely recursive

Diff for: ‎compiler/rustc_trait_selection/src/autoderef.rs

+5-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use crate::errors::AutoDerefReachedRecursionLimit;
12
use crate::traits::query::evaluate_obligation::InferCtxtExt;
23
use crate::traits::{self, TraitEngine};
3-
use rustc_errors::struct_span_err;
44
use rustc_hir as hir;
55
use rustc_infer::infer::InferCtxt;
66
use rustc_middle::ty::{self, TraitRef, Ty, TyCtxt};
@@ -222,19 +222,10 @@ pub fn report_autoderef_recursion_limit_error<'tcx>(tcx: TyCtxt<'tcx>, span: Spa
222222
Limit(0) => Limit(2),
223223
limit => limit * 2,
224224
};
225-
struct_span_err!(
226-
tcx.sess,
225+
tcx.sess.emit_err(AutoDerefReachedRecursionLimit {
227226
span,
228-
E0055,
229-
"reached the recursion limit while auto-dereferencing `{:?}`",
230-
ty
231-
)
232-
.span_label(span, "deref recursion limit reached")
233-
.help(&format!(
234-
"consider increasing the recursion limit by adding a \
235-
`#![recursion_limit = \"{}\"]` attribute to your crate (`{}`)",
227+
ty,
236228
suggested_limit,
237-
tcx.crate_name(LOCAL_CRATE),
238-
))
239-
.emit();
229+
crate_name: tcx.crate_name(LOCAL_CRATE),
230+
});
240231
}

Diff for: ‎compiler/rustc_trait_selection/src/errors.rs

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
use rustc_errors::{fluent, ErrorGuaranteed};
2+
use rustc_macros::SessionDiagnostic;
3+
use rustc_middle::ty::{PolyTraitRef, Ty, Unevaluated};
4+
use rustc_session::{parse::ParseSess, Limit, SessionDiagnostic};
5+
use rustc_span::{Span, Symbol};
6+
7+
#[derive(SessionDiagnostic)]
8+
#[diag(trait_selection::dump_vtable_entries)]
9+
pub struct DumpVTableEntries<'a> {
10+
#[primary_span]
11+
pub span: Span,
12+
pub trait_ref: PolyTraitRef<'a>,
13+
pub entries: String,
14+
}
15+
16+
#[derive(SessionDiagnostic)]
17+
#[diag(trait_selection::unable_to_construct_constant_value)]
18+
pub struct UnableToConstructConstantValue<'a> {
19+
#[primary_span]
20+
pub span: Span,
21+
pub unevaluated: Unevaluated<'a>,
22+
}
23+
24+
#[derive(SessionDiagnostic)]
25+
#[help]
26+
#[diag(trait_selection::auto_deref_reached_recursion_limit, code = "E0055")]
27+
pub struct AutoDerefReachedRecursionLimit<'a> {
28+
#[primary_span]
29+
#[label]
30+
pub span: Span,
31+
pub ty: Ty<'a>,
32+
pub suggested_limit: Limit,
33+
pub crate_name: Symbol,
34+
}
35+
36+
#[derive(SessionDiagnostic)]
37+
#[diag(trait_selection::empty_on_clause_in_rustc_on_unimplemented, code = "E0232")]
38+
pub struct EmptyOnClauseInOnUnimplemented {
39+
#[primary_span]
40+
#[label]
41+
pub span: Span,
42+
}
43+
44+
#[derive(SessionDiagnostic)]
45+
#[diag(trait_selection::invalid_on_clause_in_rustc_on_unimplemented, code = "E0232")]
46+
pub struct InvalidOnClauseInOnUnimplemented {
47+
#[primary_span]
48+
#[label]
49+
pub span: Span,
50+
}
51+
52+
#[derive(SessionDiagnostic)]
53+
#[diag(trait_selection::no_value_in_rustc_on_unimplemented, code = "E0232")]
54+
#[note]
55+
pub struct NoValueInOnUnimplemented {
56+
#[primary_span]
57+
#[label]
58+
pub span: Span,
59+
}
60+
61+
pub struct NegativePositiveConflict<'a> {
62+
pub impl_span: Span,
63+
pub trait_desc: &'a str,
64+
pub self_desc: &'a Option<String>,
65+
pub negative_impl_span: Result<Span, Symbol>,
66+
pub positive_impl_span: Result<Span, Symbol>,
67+
}
68+
69+
impl SessionDiagnostic<'_> for NegativePositiveConflict<'_> {
70+
fn into_diagnostic(
71+
self,
72+
sess: &ParseSess,
73+
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
74+
let mut diag = sess.struct_err(fluent::trait_selection::negative_positive_conflict);
75+
diag.set_arg("trait_desc", self.trait_desc);
76+
diag.set_arg(
77+
"self_desc",
78+
self.self_desc.clone().map_or_else(|| String::from("none"), |ty| ty),
79+
);
80+
diag.set_span(self.impl_span);
81+
diag.code(rustc_errors::error_code!(E0751));
82+
match self.negative_impl_span {
83+
Ok(span) => {
84+
diag.span_label(span, fluent::trait_selection::negative_implementation_here);
85+
}
86+
Err(cname) => {
87+
diag.note(fluent::trait_selection::negative_implementation_in_crate);
88+
diag.set_arg("negative_impl_cname", cname.to_string());
89+
}
90+
}
91+
match self.positive_impl_span {
92+
Ok(span) => {
93+
diag.span_label(span, fluent::trait_selection::positive_implementation_here);
94+
}
95+
Err(cname) => {
96+
diag.note(fluent::trait_selection::positive_implementation_in_crate);
97+
diag.set_arg("positive_impl_cname", cname.to_string());
98+
}
99+
}
100+
diag
101+
}
102+
}

Diff for: ‎compiler/rustc_trait_selection/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ extern crate rustc_middle;
3737
extern crate smallvec;
3838

3939
pub mod autoderef;
40+
pub mod errors;
4041
pub mod infer;
4142
pub mod traits;

Diff for: ‎compiler/rustc_trait_selection/src/traits/auto_trait.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
use super::*;
55

6+
use crate::errors::UnableToConstructConstantValue;
67
use crate::infer::region_constraints::{Constraint, RegionConstraintData};
78
use crate::infer::InferCtxt;
89
use crate::traits::project::ProjectAndUnifyResult;
@@ -830,8 +831,11 @@ impl<'tcx> AutoTraitFinder<'tcx> {
830831
Ok(None) => {
831832
let tcx = self.tcx;
832833
let def_id = unevaluated.def.did;
833-
let reported = tcx.sess.struct_span_err(tcx.def_span(def_id), &format!("unable to construct a constant value for the unevaluated constant {:?}", unevaluated)).emit();
834-
834+
let reported =
835+
tcx.sess.emit_err(UnableToConstructConstantValue {
836+
span: tcx.def_span(def_id),
837+
unevaluated,
838+
});
835839
Err(ErrorHandled::Reported(reported))
836840
}
837841
Err(err) => Err(err),

Diff for: ‎compiler/rustc_trait_selection/src/traits/mod.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ mod structural_match;
2323
mod util;
2424
pub mod wf;
2525

26+
use crate::errors::DumpVTableEntries;
2627
use crate::infer::outlives::env::OutlivesEnvironment;
2728
use crate::infer::{InferCtxt, TyCtxtInferExt};
2829
use crate::traits::error_reporting::InferCtxtExt as _;
@@ -763,8 +764,11 @@ fn dump_vtable_entries<'tcx>(
763764
trait_ref: ty::PolyTraitRef<'tcx>,
764765
entries: &[VtblEntry<'tcx>],
765766
) {
766-
let msg = format!("vtable entries for `{}`: {:#?}", trait_ref, entries);
767-
tcx.sess.struct_span_err(sp, &msg).emit();
767+
tcx.sess.emit_err(DumpVTableEntries {
768+
span: sp,
769+
trait_ref,
770+
entries: format!("{:#?}", entries),
771+
});
768772
}
769773

770774
fn own_existential_vtable_entries<'tcx>(

Diff for: ‎compiler/rustc_trait_selection/src/traits/on_unimplemented.rs

+7-40
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ use rustc_parse_format::{ParseMode, Parser, Piece, Position};
88
use rustc_span::symbol::{kw, sym, Symbol};
99
use rustc_span::{Span, DUMMY_SP};
1010

11+
use crate::errors::{
12+
EmptyOnClauseInOnUnimplemented, InvalidOnClauseInOnUnimplemented, NoValueInOnUnimplemented,
13+
};
14+
1115
#[derive(Clone, Debug)]
1216
pub struct OnUnimplementedFormatString(Symbol);
1317

@@ -35,21 +39,6 @@ pub struct OnUnimplementedNote {
3539
pub append_const_msg: Option<Option<Symbol>>,
3640
}
3741

38-
fn parse_error(
39-
tcx: TyCtxt<'_>,
40-
span: Span,
41-
message: &str,
42-
label: &str,
43-
note: Option<&str>,
44-
) -> ErrorGuaranteed {
45-
let mut diag = struct_span_err!(tcx.sess, span, E0232, "{}", message);
46-
diag.span_label(span, label);
47-
if let Some(note) = note {
48-
diag.note(note);
49-
}
50-
diag.emit()
51-
}
52-
5342
impl<'tcx> OnUnimplementedDirective {
5443
fn parse(
5544
tcx: TyCtxt<'tcx>,
@@ -70,25 +59,9 @@ impl<'tcx> OnUnimplementedDirective {
7059
} else {
7160
let cond = item_iter
7261
.next()
73-
.ok_or_else(|| {
74-
parse_error(
75-
tcx,
76-
span,
77-
"empty `on`-clause in `#[rustc_on_unimplemented]`",
78-
"empty on-clause here",
79-
None,
80-
)
81-
})?
62+
.ok_or_else(|| tcx.sess.emit_err(EmptyOnClauseInOnUnimplemented { span }))?
8263
.meta_item()
83-
.ok_or_else(|| {
84-
parse_error(
85-
tcx,
86-
span,
87-
"invalid `on`-clause in `#[rustc_on_unimplemented]`",
88-
"invalid on-clause here",
89-
None,
90-
)
91-
})?;
64+
.ok_or_else(|| tcx.sess.emit_err(InvalidOnClauseInOnUnimplemented { span }))?;
9265
attr::eval_condition(cond, &tcx.sess.parse_sess, Some(tcx.features()), &mut |cfg| {
9366
if let Some(value) = cfg.value && let Err(guar) = parse_value(value) {
9467
errored = Some(guar);
@@ -150,13 +123,7 @@ impl<'tcx> OnUnimplementedDirective {
150123
}
151124

152125
// nothing found
153-
parse_error(
154-
tcx,
155-
item.span(),
156-
"this attribute must have a valid value",
157-
"expected value here",
158-
Some(r#"eg `#[rustc_on_unimplemented(message="foo")]`"#),
159-
);
126+
tcx.sess.emit_err(NoValueInOnUnimplemented { span: item.span() });
160127
}
161128

162129
if let Some(reported) = errored {

Diff for: ‎compiler/rustc_trait_selection/src/traits/specialize/mod.rs

+8-29
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
pub mod specialization_graph;
1313
use specialization_graph::GraphExt;
1414

15+
use crate::errors::NegativePositiveConflict;
1516
use crate::infer::{InferCtxt, InferOk, TyCtxtInferExt};
1617
use crate::traits::select::IntercrateAmbiguityCause;
1718
use crate::traits::{self, coherence, FutureCompatOverlapErrorKind, ObligationCause};
@@ -327,35 +328,13 @@ fn report_negative_positive_conflict(
327328
positive_impl_def_id: DefId,
328329
sg: &mut specialization_graph::Graph,
329330
) {
330-
let impl_span = tcx.def_span(local_impl_def_id);
331-
332-
let mut err = struct_span_err!(
333-
tcx.sess,
334-
impl_span,
335-
E0751,
336-
"found both positive and negative implementation of trait `{}`{}:",
337-
overlap.trait_desc,
338-
overlap.self_desc.clone().map_or_else(String::new, |ty| format!(" for type `{}`", ty))
339-
);
340-
341-
match tcx.span_of_impl(negative_impl_def_id) {
342-
Ok(span) => {
343-
err.span_label(span, "negative implementation here");
344-
}
345-
Err(cname) => {
346-
err.note(&format!("negative implementation in crate `{}`", cname));
347-
}
348-
}
349-
350-
match tcx.span_of_impl(positive_impl_def_id) {
351-
Ok(span) => {
352-
err.span_label(span, "positive implementation here");
353-
}
354-
Err(cname) => {
355-
err.note(&format!("positive implementation in crate `{}`", cname));
356-
}
357-
}
358-
331+
let mut err = tcx.sess.create_err(NegativePositiveConflict {
332+
impl_span: tcx.def_span(local_impl_def_id),
333+
trait_desc: &overlap.trait_desc,
334+
self_desc: &overlap.self_desc,
335+
negative_impl_span: tcx.span_of_impl(negative_impl_def_id),
336+
positive_impl_span: tcx.span_of_impl(positive_impl_def_id),
337+
});
359338
sg.has_errored = Some(err.emit());
360339
}
361340

Diff for: ‎library/std/src/sys/windows/c.rs

+6
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,12 @@ pub enum FILE_INFO_BY_HANDLE_CLASS {
454454
MaximumFileInfoByHandlesClass,
455455
}
456456

457+
#[repr(C)]
458+
pub struct FILE_ATTRIBUTE_TAG_INFO {
459+
pub FileAttributes: DWORD,
460+
pub ReparseTag: DWORD,
461+
}
462+
457463
#[repr(C)]
458464
pub struct FILE_DISPOSITION_INFO {
459465
pub DeleteFile: BOOLEAN,

Diff for: ‎library/std/src/sys/windows/fs.rs

+18-8
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,15 @@ impl File {
326326
cvt(c::GetFileInformationByHandle(self.handle.as_raw_handle(), &mut info))?;
327327
let mut reparse_tag = 0;
328328
if info.dwFileAttributes & c::FILE_ATTRIBUTE_REPARSE_POINT != 0 {
329-
let mut b =
330-
Align8([MaybeUninit::<u8>::uninit(); c::MAXIMUM_REPARSE_DATA_BUFFER_SIZE]);
331-
if let Ok((_, buf)) = self.reparse_point(&mut b) {
332-
reparse_tag = (*buf).ReparseTag;
329+
let mut attr_tag: c::FILE_ATTRIBUTE_TAG_INFO = mem::zeroed();
330+
cvt(c::GetFileInformationByHandleEx(
331+
self.handle.as_raw_handle(),
332+
c::FileAttributeTagInfo,
333+
ptr::addr_of_mut!(attr_tag).cast(),
334+
mem::size_of::<c::FILE_ATTRIBUTE_TAG_INFO>().try_into().unwrap(),
335+
))?;
336+
if attr_tag.FileAttributes & c::FILE_ATTRIBUTE_REPARSE_POINT != 0 {
337+
reparse_tag = attr_tag.ReparseTag;
333338
}
334339
}
335340
Ok(FileAttr {
@@ -390,10 +395,15 @@ impl File {
390395
attr.file_size = info.AllocationSize as u64;
391396
attr.number_of_links = Some(info.NumberOfLinks);
392397
if attr.file_type().is_reparse_point() {
393-
let mut b =
394-
Align8([MaybeUninit::<u8>::uninit(); c::MAXIMUM_REPARSE_DATA_BUFFER_SIZE]);
395-
if let Ok((_, buf)) = self.reparse_point(&mut b) {
396-
attr.reparse_tag = (*buf).ReparseTag;
398+
let mut attr_tag: c::FILE_ATTRIBUTE_TAG_INFO = mem::zeroed();
399+
cvt(c::GetFileInformationByHandleEx(
400+
self.handle.as_raw_handle(),
401+
c::FileAttributeTagInfo,
402+
ptr::addr_of_mut!(attr_tag).cast(),
403+
mem::size_of::<c::FILE_ATTRIBUTE_TAG_INFO>().try_into().unwrap(),
404+
))?;
405+
if attr_tag.FileAttributes & c::FILE_ATTRIBUTE_REPARSE_POINT != 0 {
406+
reparse_tag = attr_tag.ReparseTag;
397407
}
398408
}
399409
Ok(attr)

Diff for: ‎src/bootstrap/compile.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,9 @@ impl Step for Assemble {
12811281
compiler: build_compiler,
12821282
target: target_compiler.host,
12831283
});
1284-
builder.copy(&lld_wrapper_exe, &gcc_ld_dir.join(exe("ld", target_compiler.host)));
1284+
for name in crate::LLD_FILE_NAMES {
1285+
builder.copy(&lld_wrapper_exe, &gcc_ld_dir.join(exe(name, target_compiler.host)));
1286+
}
12851287
}
12861288

12871289
if builder.config.rust_codegen_backends.contains(&INTERNER.intern_str("llvm")) {

Diff for: ‎src/bootstrap/dist.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,11 @@ impl Step for Rustc {
423423
let gcc_lld_src_dir = src_dir.join("gcc-ld");
424424
let gcc_lld_dst_dir = dst_dir.join("gcc-ld");
425425
t!(fs::create_dir(&gcc_lld_dst_dir));
426-
let exe_name = exe("ld", compiler.host);
427-
builder.copy(&gcc_lld_src_dir.join(&exe_name), &gcc_lld_dst_dir.join(&exe_name));
426+
for name in crate::LLD_FILE_NAMES {
427+
let exe_name = exe(name, compiler.host);
428+
builder
429+
.copy(&gcc_lld_src_dir.join(&exe_name), &gcc_lld_dst_dir.join(&exe_name));
430+
}
428431
}
429432

430433
// Man pages

Diff for: ‎src/bootstrap/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ const LLVM_TOOLS: &[&str] = &[
187187
"opt", // used to optimize LLVM bytecode
188188
];
189189

190+
/// LLD file names for all flavors.
191+
const LLD_FILE_NAMES: &[&str] = &["ld.lld", "ld64.lld", "lld-link", "wasm-ld"];
192+
190193
pub const VERSION: usize = 2;
191194

192195
/// Extra --check-cfg to add when building

Diff for: ‎src/librustdoc/html/static/css/rustdoc.css

-6
Original file line numberDiff line numberDiff line change
@@ -1241,12 +1241,6 @@ h3.variant {
12411241
margin-left: 24px;
12421242
}
12431243

1244-
.toggle-label {
1245-
display: inline-block;
1246-
margin-left: 4px;
1247-
margin-top: 3px;
1248-
}
1249-
12501244
:target > code, :target > .code-header {
12511245
opacity: 1;
12521246
}

Diff for: ‎src/librustdoc/html/static/css/themes/ayu.css

-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ a.test-arrow:hover {
242242
color: #c5c5c5;
243243
}
244244

245-
.toggle-label,
246245
.code-attribute {
247246
color: #999;
248247
}

Diff for: ‎src/librustdoc/html/static/css/themes/dark.css

-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ a.test-arrow:hover{
197197
background-color: #4e8bca;
198198
}
199199

200-
.toggle-label,
201200
.code-attribute {
202201
color: #999;
203202
}

Diff for: ‎src/librustdoc/html/static/css/themes/light.css

-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ a.test-arrow:hover{
182182
background-color: #4e8bca;
183183
}
184184

185-
.toggle-label,
186185
.code-attribute {
187186
color: #999;
188187
}

Diff for: ‎src/test/ui/mir/issue-99866.rs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// check-pass
2+
pub trait Backend {
3+
type DescriptorSetLayout;
4+
}
5+
6+
pub struct Back;
7+
8+
impl Backend for Back {
9+
type DescriptorSetLayout = u32;
10+
}
11+
12+
pub struct HalSetLayouts {
13+
vertex_layout: <Back as Backend>::DescriptorSetLayout,
14+
}
15+
16+
impl HalSetLayouts {
17+
pub fn iter<DSL>(self) -> DSL
18+
where
19+
Back: Backend<DescriptorSetLayout = DSL>,
20+
{
21+
self.vertex_layout
22+
}
23+
}
24+
25+
fn main() {}

Diff for: ‎src/tools/lld-wrapper/src/main.rs

+19-16
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
//! make gcc/clang pass `-flavor <flavor>` as the first two arguments in the linker invocation
99
//! and since Windows does not support symbolic links for files this wrapper is used in place of a
1010
//! symbolic link. It execs `../rust-lld -flavor <flavor>` by propagating the flavor argument
11-
//! passed to the wrapper as the first two arguments. On Windows it spawns a `..\rust-lld.exe`
12-
//! child process.
11+
//! obtained from the wrapper's name as the first two arguments.
12+
//! On Windows it spawns a `..\rust-lld.exe` child process.
1313
1414
use std::fmt::Display;
1515
use std::path::{Path, PathBuf};
@@ -53,29 +53,32 @@ fn get_rust_lld_path(current_exe_path: &Path) -> PathBuf {
5353
rust_lld_path
5454
}
5555

56+
/// Extract LLD flavor name from the lld-wrapper executable name.
57+
fn get_lld_flavor(current_exe_path: &Path) -> Result<&'static str, String> {
58+
let stem = current_exe_path.file_stem();
59+
Ok(match stem.and_then(|s| s.to_str()) {
60+
Some("ld.lld") => "gnu",
61+
Some("ld64.lld") => "darwin",
62+
Some("lld-link") => "link",
63+
Some("wasm-ld") => "wasm",
64+
_ => return Err(format!("{:?}", stem)),
65+
})
66+
}
67+
5668
/// Returns the command for invoking rust-lld with the correct flavor.
57-
/// LLD only accepts the flavor argument at the first two arguments, so move it there.
69+
/// LLD only accepts the flavor argument at the first two arguments, so pass it there.
5870
///
5971
/// Exits on error.
6072
fn get_rust_lld_command(current_exe_path: &Path) -> process::Command {
6173
let rust_lld_path = get_rust_lld_path(current_exe_path);
6274
let mut command = process::Command::new(rust_lld_path);
6375

64-
let mut flavor = None;
65-
let args = env::args_os()
66-
.skip(1)
67-
.filter(|arg| match arg.to_str().and_then(|s| s.strip_prefix("-rustc-lld-flavor=")) {
68-
Some(suffix) => {
69-
flavor = Some(suffix.to_string());
70-
false
71-
}
72-
None => true,
73-
})
74-
.collect::<Vec<_>>();
76+
let flavor =
77+
get_lld_flavor(current_exe_path).unwrap_or_exit_with("executable has unexpected name");
7578

7679
command.arg("-flavor");
77-
command.arg(flavor.unwrap_or_exit_with("-rustc-lld-flavor=<flavor> is not passed"));
78-
command.args(args);
80+
command.arg(flavor);
81+
command.args(env::args_os().skip(1));
7982
command
8083
}
8184

Diff for: ‎src/tools/replace-version-placeholder/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn main() {
1414
walk::filter_dirs(path)
1515
// We exempt these as they require the placeholder
1616
// for their operation
17-
|| path.ends_with("compiler/rustc_passes/src/lib_features.rs")
17+
|| path.ends_with("compiler/rustc_attr/src/builtin.rs")
1818
|| path.ends_with("src/tools/tidy/src/features/version.rs")
1919
|| path.ends_with("src/tools/replace-version-placeholder")
2020
},

0 commit comments

Comments
 (0)
Please sign in to comment.