Skip to content

Commit 9ba169a

Browse files
committed
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

compiler/rustc_attr/src/builtin.rs

Lines changed: 12 additions & 0 deletions
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 };

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 18 additions & 14 deletions
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 {

compiler/rustc_const_eval/src/transform/validate.rs

Lines changed: 12 additions & 5 deletions
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

Lines changed: 26 additions & 0 deletions
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}`

compiler/rustc_error_messages/src/lib.rs

Lines changed: 1 addition & 0 deletions
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",

compiler/rustc_middle/src/ty/consts/kind.rs

Lines changed: 6 additions & 0 deletions
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, ()> {

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 6 additions & 0 deletions
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)

compiler/rustc_passes/src/lib_features.rs

Lines changed: 1 addition & 1 deletion
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>");

compiler/rustc_session/src/session.rs

Lines changed: 6 additions & 0 deletions
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

compiler/rustc_trait_selection/src/autoderef.rs

Lines changed: 5 additions & 14 deletions
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
}

0 commit comments

Comments
 (0)